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
Solved! Go 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.
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.
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?
We answered this in a separate thread so I'm going to mark this one as answered.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.