cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS Version History - Retrieving Assets from version2Store correctly

manifest0
Champ in-the-making
Champ in-the-making
Hi all,

Recently I have been developing a tool for the developers in my organisation to use to create manifest files for their projects. My tool uses CMIS queries to our alfresco CMIS node to browse and retrieve documents, group them into sections and then export them with an .xml file which can be read by a manifest loader. I'm having some issues with retrieving the previous versions of documents.

For example, if I have a document called white.png (v1.0) which gets updated to black.png (v1.1), I want the developer to be able to choose either of these versions to use and export to their manifest. However, my tool currently browses the workspace IDs and as only black.png exists in the workspace store, it is the only one that the developer is able to select (the older version exists in the version2Store). If I execute a C# CMIS query such as doc.getAllVersions() I get a list of size 2, with both elements sharing the same VersionSeriesId. They do, however, have separate ContentStreamIds, and point to different .bin files. I reasoned that my task was to get the version2Store ID of the previous versions, with which I could retrieve the data correctly. As C#'s DotCMIS doesn't appear to allow me to do this, I used a REST HttpRequest as follows:
http://<HOST>/alfresco/service/cmis/i/< DOCUMENT-ID>/versions?

and parsed the resulting data, which successfully points me to the version2Store ID.

This is where I am stuck however, as I cannot put that ID back into my CMIS layer in my calls such as getNameByID(version2StoreId) as the CMIS layer only connects to the workspace - and that document doesn't exist in the workspace! Am I missing some crucial way to get previous versions of documents correctly using CMIS? On a similar note, does Alfresco support branching assets - as this is effectively what I'm trying to achieve.

Thanks for your time.
2 REPLIES 2

manifest0
Champ in-the-making
Champ in-the-making
So apparently the versionStore is automatically accessed if I just type
session.getObject(object.Id + ';' + object.versionLabel)


Marking as solved.

jpotts
World-Class Innovator
World-Class Innovator
When you use getObject() you are expected to pass in a CMIS Object ID. Those are defined by the spec as opaque which means you are not to infer any meaning from them. By constructing the ID yourself, you are violating that and are setting yourself up for heartache down the road when Alfresco changes how it creates object ID's. We're free to do that without warning because, as I said, those are opaque strings.

So, to be clear: Do not construct your own object ID's and expect them to work going forward.

The API has plenty of methods related to retrieving the version tree and fetching specific versions. Look at the JavaDoc and let me know if you can't find what you need.

Jeff
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.