Upload new version with CMIS

cancel
Showing results for 
Search instead for 
Did you mean: 
narkuss
Established Member II

Upload new version with CMIS

Hi all,

I'm uploading a new version of a node using CMIS, by following this instructions. I'm using Alfresco 6.2 ootb installation with docker.

I'm able to retrieve nodes' content, and to upload a new version, but I wonder if I can provide a version description, as can be done through the Alfresco ReST API and Alfresco Version2Service.

I've tried adding form data to the http call, but I see no results:

 

// Post new content to Alfresco as a new version using CMIS API
HttpPut put = new HttpPut(alfrescoBaseUrl + CMIS_URL + "content?id=" + ocrNodeId);
// Create request entity
requestEntityBuilder = MultipartEntityBuilder.create();
requestEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
requestEntityBuilder.addBinaryBody("file", inputStream);
requestEntityBuilder.addPart("versionComment", new StringBody("new version test", ContentType.MULTIPART_FORM_DATA));
// Tried with description, versionComment, versionDescription
requestEntity = requestEntityBuilder.build();
put.setEntity(requestEntity);

It's the first time I'm using CMIS, and I've seen that Alfresco documented in a different way CMIS operations for the new 201911 GA version, so I'd like to know:

 

  • Is it possible what I'm trying to do, or should I call other endpoint/s to set version description?
  • Should I use "old" CMIS approach (using chemistry for example)? Would it give me the ability to update content and set version description in one call?
  • Should I use Alfresco v1 ReST API instead of CMIS? What are the differences, if any / if you know it, about the two approaches, regarding liability/speed/consistency/server load?

I've already looked at the service document as stated here, but I don't get a s***, nor I haven't found any "getting started guide" for OASIS standard but the oasis standard specification, which is too much for me at the moment.

Thanks in advance!

1 Reply
jpotts
Professional

Re: Upload new version with CMIS

You should be using a CMIS client (like one from Apache Chemistry). It will save you a lot of trouble.

What you are trying to do is set a checkin comment. With something like OpenCMIS, it is as easy as:

ObjectId newVersionId = pwc.checkIn(true, null, null, "new version comment");

You can see additional OpenCMIS sample code here:

https://chemistry.apache.org/docs/cmis-samples/samples/versions/index.html

You might also take a look at the CMIS related examples in my custom content types tutorial, although I do not cover checkout/checkin.

As to whether you should use the REST API or CMIS, it is up to you and how closely each API meets your requirements.