Handling Basic Operations in DCTM using DFC
时间:2010-09-13 来源:毁于随
http://hkishan.wordpress.com/2010/04/20/handling-basic-operations-in-dctm-using-dfc/
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));
}
}
}