0

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 ? :)

Danial Kosarifa
  • 1,044
  • 4
  • 18
  • 51

1 Answers1

1

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

}
Miki
  • 2,493
  • 2
  • 27
  • 39
  • just for debugging purposes I have updated the question but I believe I am a superuser XD – Danial Kosarifa Oct 13 '16 at 10:11
  • that doesn't mean you'll have permission to write to folder ;) – Miki Oct 13 '16 at 10:14
  • I was wondering if is it possible to define loops like ( `" for (IDfSysObject sObj : objList) "` ) in java . I've seen it in other languages . But I think it wont work in `Java` right ? – Danial Kosarifa Oct 14 '16 at 06:06
  • of course [it will work](http://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work). It seems you are not very good at Java? – Miki Oct 14 '16 at 07:27
  • well .... I am learning . There is no problem in asking questions and gain knowledge rather than pretending to know and stay fool for ever :) (The purpose is learning ) – Danial Kosarifa Oct 14 '16 at 10:40
  • I totally agree, but you need to google things first to avoid asking obvious questions – Miki Oct 14 '16 at 10:42
  • Thanks for your constructive comment :) – Danial Kosarifa Oct 18 '16 at 02:49