cancel
Showing results for 
Search instead for 
Did you mean: 

How to Retrieve document url ?

imranuddin
Champ in-the-making
Champ in-the-making
Hi All,

I have a requirement where in I have multiple version for a document and i need to retrieve the url of a particular version document

Following are the details

Node Reference Id workspace://SpacesStore/453e9426-645f-470e-b850-92e5d6ff30b7

v1.1

http://vfwappora147:9080/alfresco/d/d/versionStore/version2Store/10ebbb79-bf14-47ab-

8497-2fc434ceb1e6/RyanRobertspassport.pdf

v1.0

http://vfwappora147:9080/alfresco/d/d/versionStore/version2Store/c46c2345-e7f0-450c-

9cde-5423f03f22f7/RyanRobertspassport.pdf

My requirement is for example I want to Retrieve v1.1 document I need to get the v1.1 document id 10ebbb79-bf14-47ab-

8497-2fc434ceb1e6 so as i can frame the url and show up in the UI as a link.


I am able to retrieve meta data

name: RyanRobertspassport.pdf
version label: 1.1
version series id: workspace://SpacesStore/453e9426-645f-470e-b850-92e5d6ff30b7

using code

com.pega.apache.chemistry.opencmis.client.api.Session session =
  (com.pega.apache.chemistry.opencmis.client.api.Session)sessionObj;
String objIdString = "workspace://SpacesStore/453e9426-645f-470e-b850-92e5d6ff30b7";
com.pega.apache.chemistry.opencmis.client.api.CmisObject obj = null;
obj =  session.getObject(session.createObjectId(objIdString));
com.pega.apache.chemistry.opencmis.client.api.Document document = (com.pega.apache.chemistry.opencmis.client.api.Document) obj;
List<com.pega.apache.chemistry.opencmis.client.api.Document> documents = document.getAllVersions();
Iterator itr = documents.iterator();
while(itr.hasNext()) {
com.pega.apache.chemistry.opencmis.client.api.Document version = (com.pega.apache.chemistry.opencmis.client.api.Document)itr.next();
              oLog.infoForced("name: " + version.getName());
            oLog.infoForced("version label: " + version.getVersionLabel());
            oLog.infoForced("version series id: " + version.getVersionSeriesId());
            
I will be thankful if we can retrieve the url as meta data similar to version label, version serial id etc.

1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
If what you mean by "URL" is a URL with which you can download the content stream, then here is one way to do it:


Session cmisSession = getCmisSession();
Document document = (Document) cmisSession.getObjectByPath("/test/test.txt");
List<Document> documents = document.getAllVersions();
Iterator<Document> itr = documents.iterator();
while(itr.hasNext()) {
   Document version = (Document) itr.next();
   System.out.println(
          ((LinkAccess) cmisSession.getBinding().getObjectService())
            .loadContentLink(
                cmisSession.getRepositoryInfo().getId(),
                version.getId()
            )
        );
      }


Jeff