AnsweredAssumed Answered

About document.updateProperties() and versioning

Question asked by sepgs2004 on Jul 24, 2018
Latest reply on Jul 26, 2018 by sepgs2004

I am using CMIS 1.1 API, Alfresco Community 5.1

I have our custom model, and in the model, I did not do anything with versioning related flags.

Our model extends cm:content. And we have a custom aspect with set of properties associated.

However, it is documented that CMIS API automatically turn on versioning on (binary) content changes, and not on update of (meta/custom) properties.

 

Let us say, I have a (custom aspect) property in my document called Roll.

After I created a document as shown in the code below, when I print the details of the properties, I see the version as 1.0, and value of the Roll property is "1".

ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(
mDocument.getFileName(), Long.valueOf(content.length), mimeType, stream);
insertedDocument = entityFolder.createDocument(cmisProperties, contentStream, VersioningState.MAJOR);

 

Now, afterwards, say I did call document.updateProperties(), by setting the value of the Roll property to "2". Please note that I do not have versioning turned on for property updates.

Even then, when I print the details of the document after updating the properties, it shows the Roll property value as "2" for version 1.0.

I also used CMIS workbench directly to check on the value of the Roll property, and it says "2" for version 1.0.

 

Now, say I am uploading a new content for this document, with a value of "3" for the Roll property 

 

Document existingDocument = getAlfrescoCMISDocumentByProperties(uniqueProperties, user);
if (!existingDocument.isLatestVersion()) {
     existingDocument = existingDocument.getObjectOfLatestVersion(false);
}

String pwcId = null;
if (existingDocument.isVersionSeriesCheckedOut()) {
    pwcId = existingDocument.getVersionSeriesCheckedOutId();
}
else {
   ObjectId oId = existingDocument.checkOut();
   pwcId = oId.getId();
   existingDocument.refresh();
}

Document pwc = (Document) cmisSession.getObject(pwcId);

...

ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(
       mDocument.getFileName(), Long.valueOf(content.length), mimeType, stream);
ObjectId insertedDocumentObjectId = pwc.checkIn(false, cmisProperties, contentStream, user);     

 

Now after I do the above, I have two versions in the repository: Version 1.0 and Version 1.1 

Version 1.0 has the value of Roll property as "1"

Version 1.1 has the value of Roll property as "3"

 

The challenging/misleading thing is, CMIS/Alfresco was showing the value as "2" for the Roll property up until I created version 1.1. Once it created version 1.1, then 1.0's Roll property value went back to "1" which was the value when it was originally created in the first place, and not the updated value (which is "2")....

 

I have asked this question once before. Please pardon me for repeating.

 

However, besides Alfresco, our product integrates with Documentum, KwikTag, Oracle IP/M, Sharepoint, etc.

I have verified that the Documentum, takes the property updates and maintains them against the current version we are working with. Even after making a new version 1.1, it has the latest values for the version 1.0. In the above case, after creating version 1.1, we have the following data.

Version 1.0 has the value of Roll property as "2".

Version 1.1 has the value of Roll property as "3"

Documentum behaves like it allows property updates on a version ("current version") that was created a while ago and keeps it updated with all property changes, at least until we create another version.

 

I just want to confirm once more that this is the behavior in Alfresco, with my case explained.

I want to rule out the situation that I do not know how to do updateProperties or creating a new version of a document.

I do not want to conclude things prematurely and do something wrong...

 

Could you please help me?

Outcomes