cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco copy error

vipul_n
Champ in-the-making
Champ in-the-making
Hi,

Is there a way for us to copy a file from one folder to another folder through CMIS APIs.

I am connecting with ATOMPUB,

<!–break–>
when I try to copy with
DocumentImpl.copy() 
I get the below exception,
org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException: createDocumentFromSource is not supported by the AtomPub binding! 



Then it tries to copy via the DocumentImpl.copyViaClient() which gives the below error,

Cannot close source stream! 


Which gets wrapped into this error
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Internal Server Error


Thanks in advance,
5 REPLIES 5

kaynezhang
World-Class Innovator
World-Class Innovator
Have you tried following  method signature of Document  class ,it will work

    copy(ObjectId targetFolderId, Map<String, ?> properties, VersioningState versioningState,
            List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs, OperationContext context);

vipul_n
Champ in-the-making
Champ in-the-making
Yes we have already tried. Please refer to the following code and we are still not able to make out.


public void copyDocument(String alfrescoId) {
              Folder destinationFolder = (Folder) session.getObjectByPath("/Test1");
              Document document = (Document) session.getObject(alfrescoId);
           Map<String, Object> documentProperties = new HashMap<String, Object>(1);
              documentProperties.put(PropertyIds.NAME, document.getName());
              document.copy(destinationFolder, documentProperties, null, null, null, null, null);
       }

Can you pl. let us know if we are missing something?
Thanks in advance,

kaynezhang
World-Class Innovator
World-Class Innovator
Following is my test code,it works fine,you can try it

      Document document = (Document)session.getObjectByPath( "/TESTFOLDER1/20130822.doc") ;
      Folder root = session.getRootFolder();
      ObjectId rootid = session.createObjectId(root.getId());

      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled,P:cm:author");
      document.copy(rootid, properties, VersioningState.MAJOR, null, null, null, null);

Can you explain "session" ? which value is passed from this "session"? 

kaynezhang
World-Class Innovator
World-Class Innovator
session???

session is the cmis session object you created using cmis SessionFactory