Friday, August 9, 2013

Getting content path IBM WCM API

DocumentIdIterator contentIterator = workspace.findByType(DocumentTypes.Content);
while(contentIterator.hasNext())
    {   
        contentId = contentIterator.nextId();
    System.out.println(workspace.getPathById(contentId, false, false));
    }

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();
}

Sunday, August 4, 2013

Checking Cross Referencing of contents in IBM WCM Libraries

try

{

Repository repository = WCM_API.getRepository();

Workspace workspace = repository.getWorkspace(request.getUserPrincipal());
String libname="Test-library";

workspace.setCurrentDocumentLibrary(workspace.getDocumentLibrary(libNames));

DocumentIdIterator contentIterator = workspace.findByType(DocumentTypes.Content);

DocumentId contentId = null;

while(contentIterator.hasNext())

{

contentId = contentIterator.nextId();

ArrayList<String> arrayList = new ArrayList<String>();

Reference []ref =workspace.getReferencesFrom(contentId);

for(int i=0 ; i< ref.length ;i++)

{

String refLibName = ref[i].getRefererDocumentId().getContainingLibrary().getName();
System.out.println("--------------Referenced Library Name-------------"+refLibName);

}
}
}