Beruflich Dokumente
Kultur Dokumente
test;
import junit.framework.TestCase;
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
session = sessionMgr.newSession(DOCBASE);
}
package com.bluefish.dfc.test;
There are a couple of important points regarding the above code samples:
• Be sure always to clean up your IDfSessions when you're finished with them.
• If available, always use the session manager to access and release sessions.
Prior to DFC 5.x, there wasn't an IDfSessionManager and the developer was required to
call IDfSession.disconnect() whenever a session was no longer needed. However, the
IDfSessionManager supports session pooling, so it is critical that any session acquired
through a session manager is released through that session manager as well. Otherwise,
bad things can happen and probably will. This is typical Object/Relational Mapper
design, so those familiar with a similar persistence framework should find the transition
rather painless.
• Create folder
• Create file
• Modify file
• Delete file
• Delete folder
I've created a single test case class, DfcCrudTest.java, with test methods present for each
of our exercises. For some of our exercises, there turned out to be more than one viable
way of accomplishing our goal. For example, to obtain a folder's contents, you can
perform a simple DQL query, or if you have a handle on the IDfFolder object, you can
call the getContents(..) method on the folder object. To demonstrate this, I included both
options within my testFolderContents() method.
Please keep in mind that these tests are written for clarify, not for optimal design.
package com.bluefish.dfc.test;
import com.documentum.fc.client.DfQuery;
import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.common.IDfId;
initialize();
createFolder();
createFile();
linkFileToFolder();
modifyFile();
fetchFolderContents();
queryFiles();
deleteFile();
deleteFolder();
document = (IDfDocument)
session.newObject("dm_document");
document.setObjectName(FILE_NAME);
document.setContentType("crtext");
document.setFile("E:/clipboard.txt"); // add content to
this dm_document
document.save();
document.link(DIR_PATH);
document.save();
log(FILE_PATH);
assertNotNull("unexpected folder path",
session.getObjectByPath( FILE_PATH));
}
document.checkout();
int numAuthors = document.getAuthorsCount();
document.setAuthors(numAuthors, DOC_AUTHOR);
//doc.checkin(false, "Prevents promotion to CURRENT");
document.checkin(false, null); // When a null version
label is provided,
// DFC automatically gives
the new version
// an implicit version
label (1.1, 1.2, etc.)
// and the symbolic label
"CURRENT".
}