cancel
Showing results for 
Search instead for 
Did you mean: 

Syndicate via MDM JAVA API

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182007
Active Contributor
0 Kudos

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

[original link is broken]

Hope it helps.

Deep

Former Member
0 Kudos

Hi Deepak,

I have checked and found that my syndication server was not running.

I made it running and the records gets syndicated.

Thanks for your reply.

Regards,

Amol