Documentum Foundation Classes Examples for Java
时间:2010-09-13 来源:毁于随
http://hkishan.wordpress.com/2010/04/18/documentum-foundation-classes-examples-for-java/
Today i have to tried to put in some of the examples describing the DFC usage in Documentum.
1.Connecting to the content server docbase and establishing session :
public IDfSession getDfSession (String userName, String password, String docbaseName) throws Exception {
IDfLoginInfo loginInfo = new DfLoginInfo();
loginInfo.setUser(userName);
loginInfo.setPassword(password);
IDfClient client = new DfClient();
IDfSessionManager sessMgr = client.newSessionManager();
sessMgr.setIdentity(docbaseName, loginInfo);
idfSession = sessMgr.getSession(docbaseName);
if ( idfSession != null )
System.out.println(“Session created successfully”); return idfSession;
}
2.Get a list of available docbase:
public void getAllDocbases() throws Exception {
IDfClient client = DfClient.getLocalClient();
IDfDocbaseMap docbaseMap = client.getDocbaseMap();
for(int i=0;i<docbaseMap.getDocbaseCount();i++) {
System.out.println(“Docbase Name : ” + docbaseMap.getDocbaseName(i)); System.out.println(“Docbase Desc : ” + docbaseMap.getDocbaseDescription(i));
}
}
3. Create a cabinet (dm_cabinet object) in docbase:
public void createCabinet() throws Exception {
IDfFolder cabinetObj = (IDfFolder) idfSession.newObject(“dm_cabinet”);
if (cabinetObj != null) {
cabinetObj.setObjectName(“Cabinet Name”);
cabinetObj.save();
}
}
4. Create a folder (dm_folder object) in docbase:
public void createFolder() throws Exception {
IDfFolder folderObj = (IDfFolder) idfSession.newObject(“dm_folder”);
if (folderObj != null) {
folderObj.setObjectName(“Folder Level 2″);
folderObj.link(“/Cabinet Name”);
folderObj.save();
}
}
5. Create a document (dm_document object) in docbase:
public IDfDocument createDocument() throws Exception {
IDfDocument documentObj = (IDfDocument) idfSession.newObject(“dm_document”);
if (documentObj!= null) {
documentObj.setObjectName(“Test-Document”);
documentObj.setContentType(“crtext”); documentObj.setFile(“C:\\Documentum\\config\\dfc.properties”);
documentObj.link(“/Cabinet Name/Folder Level 2″); documentObj.save();
}
return documentObj;
}