on 06-24-2010 11:10 AM
Hi All,
I am trying to syndicate record via MDM JAVA API, i used the below code to syndicate and my code runs without any exception
but i am not finding any PortDataFiles
String portCode = "_A";
String filePrefix = "Data_";
ConnectionPool connections = ConnectionPoolFactory.getInstance(serverName);;
String session;
PortProperties[] portList;
RecordId[] recordIds = new RecordId[1];
RecordId recordId = new RecordId("R"+recordID);
recordIds[0] = recordId;
GetPortListCommand getPortsCmd = new GetPortListCommand(connections);
getPortsCmd.setSession(session);
getPortsCmd.execute();
portList = getPortsCmd.getPorts();
// Search a specific portCode
PortProperties port = null;
for (int i=0; i < portList.length; i++) {
if (portCode.equals(portList<i>.getCode())) {
port = portList<i>;
break;
}
}
if (port == null) {
wdComponentAPI.getMessageManager().reportException("Can't syndicate, port doesn't exist",false);
throw new RuntimeException("Can't syndicate, port doesn't exist" );
}
// Call sindication
AddSyndicationRecordIdsCommand addSyndRecordCmd = new AddSyndicationRecordIdsCommand(connections);
addSyndRecordCmd.setSession(session);
addSyndRecordCmd.setFilePrefix(filePrefix);
addSyndRecordCmd.setPortId(port.getId());
addSyndRecordCmd.setRemoteSystemId(port.getRemoteSystemId());
addSyndRecordCmd.setRecordIds(recordIds);
addSyndRecordCmd.execute();
GetPortDataFilesCommand getPortDataFilesCommand = new GetPortDataFilesCommand(connections);
getPortDataFilesCommand.setSession(session);
getPortDataFilesCommand.setRemoteSystemId(port.getRemoteSystemId());
getPortDataFilesCommand.setPortId(port.getId());
getPortDataFilesCommand.setFilePrefix(filePrefix);
getPortDataFilesCommand.execute();
PortDataFile[] portDataFiles = getPortDataFilesCommand.getFiles();
for (int i = 0; i < portDataFiles.length; i++) {
wdComponentAPI.getMessageManager().reportSuccess("File Name: "+portDataFiles<i>.getFilename());
}
Can anyone tell where i am wrong or anyone has a example on syndication of record?
Hi Amol,
for this some prerequsite are :
Syndication through Java API is asynchronous. Also Syndication Server must be running. You should also use EventDispatcher class in order to be notified when a Syndication Event occurs.
The following code syndicate specific records with the class AddSyndicationRecordIdsCommand :
String portCode = "PORT_CODE";
String filePrefix = "SomeFilePrefix";
SimpleConnection connection;
String session;
PortProperties[] portList;
RecordId[] recordIds;
...
GetPortListCommand getPortsCmd = new GetPortListCommand(connection);
getPortsCmd.setSession(session);
getPortsCmd.execute();
portList = getPortsCmd.getPorts();
// Search a specific portCode
PortProperties port = null;
for (int i=0; i < portList.length; i++) {
if (portCode.equals(portList<i>.getCode())) {
port = portList<i>;
break;
}
}
if (port == null) {
throw new RuntimeException("Can't syndicate, port doesn't exist" );
}
// Call sindication
AddSyndicationRecordIdsCommand addSyndRecordCmd = new AddSyndicationRecordIdsCommand(connection);
addSyndRecordCmd.setSession(session);
addSyndRecordCmd.setFilePrefix(filePrefix);
addSyndRecordCmd.setPortId(port.getId());
addSyndRecordCmd.setRemoteSystemId(port.getRemoteSystemId());
addSyndRecordCmd.setRecordIds(recordIds);
addSyndRecordCmd.execute();
you can also refer
Hope it helps.
Deep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.