我的文件夹迁移使用DFC在Documentum中继续失败

时间:2016-10-13 09:17:30

标签: java javafx documentum dfc

我正在开发一个连接到Documentum数据存储的JavaFx项目。我正在尝试配置如何将放置在文件夹中的文件夹(让我们称之为文件夹11)移动到另一个文件夹(让我们称之为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);


              mo.setDestinationFolderId(destinationDirectory . getObjectId());


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

              //System.out.println(doc); The output is : com.documentum.fc.client.DfFolder___PROXY@ec9178
              //System.out.println(mo.execute); output is : true
              IDfMoveNode node = (IDfMoveNode)mo.add(doc);
             // System.out.println(node);  the output : com.documentum.operations.nodes.impl.DfMoveNode@1ad8a67
              //System.out.println(mo.execute); output is : false

                 if (!mo.execute()) {
                     str= "Move operation faild . ";
                     }
                     else {
                     str = "Move operation success . ";
                     }
        }catch(DfException e){
            System.out.println(e.getLocalizedMessage());
        }catch(Exception e){

            System.out.println(e.getLocalizedMessage());
        }


    return str;


    }


    }

以下是我的称呼方式:

 Migrate test = new Migrate();
 System.out.println(test.move(_session, "0b01b66980028599" ,"Cabinet/LEXOPEDIA/Sateri/Hong Kong" ));

但问题是mo.execute始终返回false并且迁移总是失败。有谁知道我的错误在哪里? :)

1 个答案:

答案 0 :(得分:1)

您对该操作有正确/足够的权限吗? 您好像不打电话给setSourceFolderId()。看看这个。

另外,请尝试使用此concept来检查错误:

private void doMoveOp(ArrayList objList, IDfFolder fromFolder, IDfFolder toFolder ) {

  try {

    // #1 - manufacture an operation
    IDfMoveOperation moveOpObj = cx.getMoveOperation();

    // #2 - add objects to the operation for processing
    for (IDfSysObject sObj : objList) {
      moveOpObj.add(sObj);
    }

    // #3 - set the source and target folder
    moveOpObj.setDestinationFolderId(toFolder.getObjectId());
    moveOpObj.setSourceFolderId(fromFolder.getObjectId());

    // #4 - execute the operation
    boolean result = moveOpObj.execute();

    // #5 - check for errors
    if (!result) {
      IDfList errors = moveOpObj.getErrors();
      for (int i=0; i<errors.getCount(); i++) {
        IDfOperationError err = (IDfOperationError) errors.get(i);
        System.out.println("Error in Move operation: " + err.getErrorCode() + " - " + err.getMessage());
      }
    } else {
      // #6 - get new obj ids
      IDfList newObjs = moveOpObj.getObjects();
        for (int i=0; i<newObjs.getCount(); i++) {
          IDfSysObject sObj = (IDfSysObject) newObjs.get(i);
          System.out.println("\tmoved object " + sObj.getObjectId().toString());
        }
    }

  } catch(Exception e) {
    System.out.println("Exception in Move operation: " + e.getMessage());
    e.printStackTrace();
  }

}