Tuesday, August 6, 2013

Running syndicator from IBM WCM API

try
{
 Context ic = null;
 System.out.println("----------------------JNDI Connection Syndicator---------------------");
 Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, "iiop://localhost:10035");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
ic = new InitialContext(env);
SyndicationService syndicationService = (SyndicationService) ic.lookup("portal:service/wcm/SyndicationService");

System.out.println("Context starting at: " + ic.getNameInNamespace());

Workspace workspace = WCM_API.getRepository().getWorkspace( );

Syndicator synd = syndicationService.getSyndicatorByName(workspace, "DEV2INT-TestSydContent");

 System.out.println("Syndicator Name :--"+synd.getName());

System.out.println("Syndicator Status :-"+synd.getStatus());

synd.setEnabled(true, workspace);
 synd.update();
SyndicationStatus syndStatus = synd.getStatus();
 while(syndStatus.isRunning()) {
 System.out.println("Updating");
}
synd.setEnabled(false, workspace);
 }catch(Exception e) {
 e.printStackTrace();
}

No comments:

Post a Comment