cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS atompub: getAllVersions is returning invalid objects

stefankopf
Confirmed Champ
Confirmed Champ
Hi all,

I have noticed that getAllVersions returns different properties for the exact same version than a call to getObject.

Example sequence:
<ol>
<li>Create a new Document named "TestV0.doc" (Version is 1.0)
<li>Rename document to "TestV1.doc" (Version is still 1.0)
<li>Check-out document
<li>Check-in document as major (Version is now 2.0)
<li>Rename document to "TestV2.doc" (Version is 2.0)
</ol>

When getting all versions, these objects are returned:
1.0 -> "TestV0.doc"
2.0 -> "TestV1.doc"
But when using getObject, these objects are returned:
1.0 -> "TestV0.doc"
2.0 -> "TestV2.doc"

You can reproduce this by running this Groovy script in the CMIS Workbench:

import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*

Document document = (Document) session.getObjectByPath("/test/TestV2.doc");

println "Latest version name: " + document.getName();
println "Latest version label: " + document.getVersionLabel();

for(CmisObject ver : document.getAllVersions())
{
    println "Before: Version " + ver.getVersionLabel() + " name: " + ver.getName();
    ver.refresh();
    println "After:  Version " + ver.getVersionLabel() + " name: " + ver.getName();
}

The refresh() call triggers OpenCMIS to read the object again by its ID.
The above script produces this output:

Latest version name: TestV2.doc
Latest version label: 2.0
Before: Version 2.0 name: TestV1.doc
After:  Version 2.0 name: TestV2.doc
Before: Version 1.0 name: TestV0.doc
After:  Version 1.0 name: TestV0.doc

Please note also that the set of properties with name "TestV1.doc" is not accessible by ID.

It seems like Alfresco is creating a new version of a node on each modification but keeps the version label unchanged. So there can be multiple versions of a node with the same version label. BOTH methods getObject() and getAllVersions() fail in returning the latest version for every node.

The expected correct output is this:

Latest version name: TestV2.doc
Latest version label: 2.0
Before: Version 2.0 name: TestV2.doc
After:  Version 2.0 name: TestV2.doc
Before: Version 1.0 name: TestV1.doc
After:  Version 1.0 name: TestV1.doc

2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
I have reproduced this (although with slightly different results) running against Alfresco 4.2.c Community Edition, OpenCMIS Workbench 0.9-beta1 (and cmislib 0.5.1).

I thought maybe it was an OpenCMIS cache issue on the client side but cmislib has no such cache.

My results from the Groovy console in Workbench are:
<blockcode>
Latest version name: testv2.docx
Latest version label: 2.0
Before: Version 2.0 name: testv1.docx
After:  Version 2.0 name: testv2.docx
Before: Version 1.0 name: testv1.docx
After:  Version 1.0 name: testv1.docx
</blockcode>

What version of Alfresco and OpenCMIS are you running?

Jeff

Hi Jeff,

This test has been performed against
Alfresco Enterprise v4.1.4
(r49301-b80) schema 5118