Skip to Content
avatar image
Former Member

Syndicate via MDM JAVA API

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jun 25, 2010 at 11:37 AM

    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

    Data Unification How-to Guides for SAP NetWeaver 7.0 [original link is broken]

    Hope it helps.

    Deep

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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