简体   繁体   中英

My Folder Migration keeps on failing in Documentum using DFCs

I am working on a JavaFx project connected to Documentum data storage . And I am trying to configure how to move a folder (lets call it folder11) 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 ="";
        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;


    }


    }

And here is how I call it :

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

But the problem is no matter what mo.execute always return false and the migration always fails . Does any one know where my mistake is ? :)

Do you have correct / adequate permissions for that action? It seems that you don't call setSourceFolderId() . Check it out.

Also, try to use this concept to check for errors:

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();
  }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM