Danial Kosarifa Danial Kosarifa - 1 year ago 75
Java Question

Migrating a file or a folder from one repository to another in Documentum

I am working on a

project connected to
data storage . And I am trying to configure how to move a file (lets call it file1) placed in a folder (lets call it Folder1) into another folder (lets call it Folder2) . It's worth mentioning that both of the Folders are in the same cabinet . I have implemented the following class :

package application;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfId;
import com.documentum.operations.IDfMoveNode;
import com.documentum.operations.IDfMoveOperation;

public class Migrate {
public Migrate(){}
public String move ( IDfSession mySession,String docId, String destination){
String str ="";

IDfClientX clientx = new DfClientX();

IDfMoveOperation mo = clientx . getMoveOperation();

IDfFolder destinationDirectory = mySession . getFolderByPath(destination);

//Here is the line that causes error
mo.setDestinationFolderId(destinationDirectory . getObjectId());

IDfDocument doc = (IDfDocument) mySession . getObject(new DfId(docId));

IDfMoveNode node = (IDfMoveNode)mo.add(doc);

if (mo.execute()) {
str= "Move operation successful . ";
else {
str = "Move operation failed . ";
}catch(DfException e){

return str;



instead of docId I am passing through the r_object_id of the file I am wishing to be moved but I get the following error :

com.documentum.fc.client.DfFolder___PROXY cannot be cast to

Does any one know where my mistake is ? Or where am I doing it wrong ?

Answer Source

It's obvious, in line

IDfDocument doc = (IDfDocument) mySession . getObject(new DfId(docId));

the docId parameter represents folder object, not the document object. Do the type check first to be sure and than use either IDfFolder or IDfDocument. If you're sure that you're moving folder to another folder than just change IDfDocument -> IDfFolder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download