Home > DOCUMENTUM > Handling Basic Operations in DCTM using DFC

Handling Basic Operations in DCTM using DFC

April 20, 2010

1.Check out a document from docbase:

public void checkoutDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (!sysObj.isCheckedOut()) // if it is not checked out
sysObj.checkout();
System.out.println(“is Check out ” + sysObj.isCheckedOut());
}

2.Check in a document to docbase:

public void checkinDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (sysObj.isCheckedOut()) { // if it is checked out
sysObj.checkin(false,”CURRENT”);
}
}

3.Delete a document from docbase:

public void deleteDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (sysObj != null ) {
sysObj.destroyAllVersions(); // delete all versions
System.out.println(“object destroyed…..”);
}
}

4.Update document’s metadata\attributes in docbase:

public void updateAttributes() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/New Document”);
sysObj.setString(“object_name”, “New Document”);
sysObj.setString(“authors”, “author1”);
sysObj.setRepeatingString(“authors”,1,”author2″);
sysObj.save();
}

5.Retrieve document’s metadata\attributes from docbase:

public void getAttributes() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/New Document”);
if (sysObj != null ) {
System.out.println(“objectName ” + sysObj.getString(“object_name”));
//System.out.println(“authors ” + sysObj.getString(“authors”));
String authors = sysObj.getAllRepeatingStrings(“authors”, “,”);
ArrayList list = new ArrayList();
StringTokenizer st = new StringTokenizer(authors, “,”);
System.out.println(“length of st ” + st.countTokens());
while( st.hasMoreTokens()) {
list.add(st.nextElement());
}
System.out.println(“length ” + list.size());
for (int i=0;i<list.size();i++) {
System.out.println("Author["+i+"] " + list.get(i));
}
}
}

%d bloggers like this: