Home > DOCUMENTUM > Documentum Foundation Classes Examples for Java-Contd.

Documentum Foundation Classes Examples for Java-Contd.

April 19, 2010

Today let us discuss few more examples on DFC.
1. Check out a document from docbase using IDfOperations:

public void checkoutDocument() throws Exception {
IDfCheckoutOperation checkoutOpr = new DfCheckoutOperation();
System.out.println(“Checkout Dir ” + checkoutOpr.getDefaultDestinationDirectory()); checkoutOper.setDestinationDirectory(checkoutOpr.getDefaultDestinationDirectory());
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet Name/Folder Level 2/ Test-Document”);
IDfCheckoutNode node = (IDfCheckoutNode) checkoutOpr.add(sysObj); boolean flag = checkoutOpr.execute();
}

2.Check in a document to docbase using IDfOperations:

public void checkinDocument() throws Exception {
IDfCheckinOperation checkinOpr = new DfCheckinOperation();
IDfCheckinNode node = (IDfCheckinNode) checkinOpr.add(sysObj);
System.out.println(“Flag —->” + checkinOpr.execute());
}

3.Making use of IAPI methods:

public void dmclAPI() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByQualification (“dm_document where object_name=’Test-Document'”);
String objId = sysObj.getObjectId().getId();
String name = (String)idfSession.apiGet(“get”, objId + “,object_name”);
System.out.println(“Name :” + name); //idfSession.apiSet(“set”, objId +”,title”,”sample-doc”); idfSession.apiExec(“link”, objId +”,/Cabinet Name/Folder Level 2″);
System.out.println(“Linked ” + idfSession.apiExec(“save”, objId));
}

4.To import a document into docbase:

public void importDocument() throws Exception {
IDfSysObject sysObj= (IDfFolder) idfSession.getObjectByPath (“/Cabinet Name/Folder Level 2”); System.out.println(“Object ID” + sysObj.getObjectId());
IDfImportOperation importOpr = new DfImportOperation();
importOper.setSession(idfSession);
if (importOpr == null ) {
System.out.println(“operation object is null”);
return;
}
importOpr.setDestinationFolderId(sysObj.getObjectId());
importOpr.setVersionLabels(“imported using operation”);
IDfImportNode node = (IDfImportNode) importOpr.add (“C:\\Documentum\\config\\ Test-Document”);
node.setFormat(“pdf”);
boolean flag = importOpr.execute();
}

5.Cancelcheckout a document into docbase:

public void cancelCheckoutDocument() throws Exception {
IDfCancelCheckoutOperation cancelcheckoutOpr = new DfCancelCheckoutOperation();
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath (“/Cabinet Name/Folder Level 2/ Test-Document”);
IDfCancelCheckoutNode node = (IDfCancelCheckoutNode) cancelcheckoutOpr.add (sysObj); boolean flag = cancelcheckoutOpr.execute();
}

Stay tuned preparing few more examples.

%d bloggers like this: