How to generate document location url for previous verions using OpenCMIS

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

How to generate document location url for previous verions using OpenCMIS

Jump to solution

Hello All,

I want to generate a url for a previous version of a document using OpenCMIS library and Alfresco 5.

My understanding is that previous version is to be obtained from version store:

{serverhost:port/regionalContext}/d/d/versionStore/version2Store/{nodeId}/{fileName}

but OpenCMIS doesnt give me back the nodeId in version store. Instead i get id of the main document while calling getAllVersions(), which doesnt help me.

Is there any way around it?

Regards,

Krzysztof

1 Solution

Accepted Solutions
jpotts
Professional

Re: How to generate document location url for previous verions using OpenCMIS

Jump to solution

Hi Krzysztof,

Suppose I create a document, sample-a.pdf, in Alfresco, and I version it twice by uploading new versions of the file, sample-b.pdf, and sample-c.pdf. I will end up with a version tree that looks like this:

sample-c.pdf 3.0 (Current)

sample-b.pdf 2.0

sample-a.pdf 1.0

Everything you need to be able to construct a download URL for each of those three versions is available from CMIS. To prove that, I'll launch Apache Chemistry OpenCMIS Workbench and connect to my Alfresco 5.2 repository using this service URL:

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser 

The key piece of info that you may be missing is that there is a special property called alfcmis:nodeRef that contains the Alfresco node reference. That's critical for being able to reconstruct an Alfresco download URL.

The CMIS object ID, CMIS download URL, alfcmis:nodeRef, cmis:name, and Alfresco Download URLs for each of the major versions is shown below:

Version 1.0

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B1.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef: versionStore://version2Store/524adbd3-d381-41f4-b7c6-2c0ab632774f
cmis:name: sample-a.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/versionStore/version2Store/524adbd3-d381...
Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/versionStore/version2Store/524adbd3-d381-41f4-b7c6...


Version 2.0

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B2.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef versionStore://version2Store/e39b9279-a2f6-4cb7-902c-e94d7efd4362
cmis:name: sample-b.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/versionStore/version2Store/e39b9279-a2f6...

Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/versionStore/version2Store/e39b9279-a2f6-4cb7-902c...

Version 3.0 (Current)

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B3.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef: workspace://SpacesStore/716668a8-9b95-427d-9818-7adebf31cee5
cmis:name: sample-c.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/workspace/SpacesStore/716668a8-9b95-427d...

Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/workspace/SpacesStore/716668a8-9b95-427d-9818-7ade...

There are a few different URLs in Alfresco that can be used to download, but they all use the node reference.

View solution in original post

3 Replies
jpotts
Professional

Re: How to generate document location url for previous verions using OpenCMIS

Jump to solution

Hi Krzysztof,

Suppose I create a document, sample-a.pdf, in Alfresco, and I version it twice by uploading new versions of the file, sample-b.pdf, and sample-c.pdf. I will end up with a version tree that looks like this:

sample-c.pdf 3.0 (Current)

sample-b.pdf 2.0

sample-a.pdf 1.0

Everything you need to be able to construct a download URL for each of those three versions is available from CMIS. To prove that, I'll launch Apache Chemistry OpenCMIS Workbench and connect to my Alfresco 5.2 repository using this service URL:

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser 

The key piece of info that you may be missing is that there is a special property called alfcmis:nodeRef that contains the Alfresco node reference. That's critical for being able to reconstruct an Alfresco download URL.

The CMIS object ID, CMIS download URL, alfcmis:nodeRef, cmis:name, and Alfresco Download URLs for each of the major versions is shown below:

Version 1.0

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B1.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef: versionStore://version2Store/524adbd3-d381-41f4-b7c6-2c0ab632774f
cmis:name: sample-a.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/versionStore/version2Store/524adbd3-d381...
Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/versionStore/version2Store/524adbd3-d381-41f4-b7c6...


Version 2.0

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B2.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef versionStore://version2Store/e39b9279-a2f6-4cb7-902c-e94d7efd4362
cmis:name: sample-b.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/versionStore/version2Store/e39b9279-a2f6...

Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/versionStore/version2Store/e39b9279-a2f6-4cb7-902c...

Version 3.0 (Current)

CMIS Object ID: 716668a8-9b95-427d-9818-7adebf31cee5%3B3.0
CMIS Download URL: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=716668a8...

alfcmis:nodeRef: workspace://SpacesStore/716668a8-9b95-427d-9818-7adebf31cee5
cmis:name: sample-c.pdf
Alfresco Download URL (Share): http://localhost:8080/share/proxy/alfresco/api/node/content/workspace/SpacesStore/716668a8-9b95-427d...

Alfresco Download URL (Alfresco): http://localhost:8080/alfresco/s/api/node/content/workspace/SpacesStore/716668a8-9b95-427d-9818-7ade...

There are a few different URLs in Alfresco that can be used to download, but they all use the node reference.

longinus
Member II

Re: How to generate document location url for previous verions using OpenCMIS

Jump to solution

Thank you so much, Jeff. This has solved my versioning problem with atompub. I missed that property, as I have seen it for latest version only which was matching object id.My mistake.

However, when I switch to browser binding using the same service url as you do (/api/-default-/public/cmis/versions/1.1/browser) i am getting repository id not set. It just gets overwritten to null by getRepositoryInfos() call. So not sure if it requires additional setup?

jpotts
Professional

Re: How to generate document location url for previous verions using OpenCMIS

Jump to solution

We answered this in a separate thread so I'm going to mark this one as answered.