I am writing a custom application that interfaces with Alfresco community 4.2. I have a custom data model integrated, and learned to my chagrin that I can't copy a document using CMIS, because custom aspects are not recognized (as in this issue). I could do it manually, I suppose, by copying all the properties and setting the type as appropriate, but I hit upon the idea of using the built-in copy action to accomplish my task, and call this action via REST API. It seems as if this should copy custom types properly, no?
1) Does this sound like a good approach?
2) How do I call the copy action via REST? I can't even figure out the URL I should be using for this. I've seen some documentation, but haven't been able to sort it out yet.
Thanks!
You are using 4.2.e, so, as Gagravarr says, aspects are supported in CMIS 1.0 using the OpenCMIS Extension for Alfresco. And in CMIS 1.1, which is supported in 4.2.e, as secondaryTypes (synonym for aspects).
Important to note is that in 4.2 the CMIS URLs have changed. If you want to use CMIS 1.0 AtomPub the URL is:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom
And if you want to use CMIS 1.1 AtomPub the URL is:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom
Given those URLs, Alfresco 4.2.e, OpenCMIS 0.10.0, and the OpenCMIS extension 0.7, the following is the outcome of running this code:
Document sourceDoc = (Document) cmisSession.getObjectByPath("/Someco/Whitepapers/whitepaper2.txt");
Folder targetFolder = (Folder) cmisSession.getObjectByPath("/destinationFolder");
sourceDoc.copy(targetFolder);
Where whitepaper2.txt is a document with multiple custom aspects and custom metadata set:
CMIS 1.0 AtomPub, no OpenCMIS extension: Copy succeeds without the custom aspects.
CMIS 1.0 AtomPub, OpenCMIS extension: Copy fails with IllegalArgumentException.
CMIS 1.1, no OpenCMIS extension (it isn't needed): Copy succeeds with all custom aspects and property values intact.
So the answer is to use CMIS 1.1 support when running against 4.2.x.