title: Migrating a file or a folder from one repository to another in Documentum
body: <p>I am working on a <code>JavaFx</code> project connected to <code>Documentum</code> 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 : </p>
  
  <pre><code>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;
  
  
      }
  
  
      }
  </code></pre>
  
  <p>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 : </p>
  
  <blockquote>
    <p>com.documentum.fc.client.DfFolder___PROXY cannot be cast to
    com.documentum.fc.client.IDfDocument</p>
  </blockquote>
  
  <p>Does any one know where my mistake is ? Or where am I doing it wrong ? </p>