在Documentum中将文件或文件夹从一个存储库迁移到另一个存储库

时间:2016-10-13 03:09:10

标签: java javafx documentum dfc

我正在处理与JavaFx数据存储相关联的Documentum项目。我正在尝试配置如何将放置在文件夹中的文件(让我们称之为文件1)移动到另一个文件夹(让我们称之为Folder2)。值得一提的是,两个文件夹都在同一个文件柜中。我已经实现了以下类:

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 ="";
        try{

              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){
            System.out.println(e.getLocalizedMessage());
        }


    return str;


    }


    }

而不是docId我正在通过我希望被移动的文件的r_object_id,但是我收到以下错误:

  

com.documentum.fc.client.DfFolder ___ PROXY无法转换为   com.documentum.fc.client.IDfDocument

有人知道我的错误在哪里吗?或者我在哪里做错了?

1 个答案:

答案 0 :(得分:1)

很明显,在行

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

docId参数表示文件夹对象,而不是文档对象。首先进行类型检查以确保使用IDfFolderIDfDocument。如果您确定要将文件夹移动到另一个文件夹,而不仅仅是更改IDfDocument - > IDfFolder