cancel
Showing results for 
Search instead for 
Did you mean: 

Using CMIS to get list of document urls

michaelloveusa
Champ on-the-rise
Champ on-the-rise
Hi there - I am new to CMIS and this is my first post. I have a client application that requires that my document management system (Alfresco!) return a list of documents based on the value of a certain document attribure. I have this working as a query, but the client application requires that each item in the list contain the document's url as the key element. Is there a way that I can do this via CMIS query? Or do I have to query the results and get the content of each document to build the url? Any help on this would be greatly appreciated!

Thanks, Mike
7 REPLIES 7

openpj
Elite Collaborator
Elite Collaborator
I'm not sure, but I think that it is not possible to get the document url, you should implement your own servlet that returns in the response the byte stream for the download. Probably this problem exists because each product vendor has different servlets to get a content stream.

llemtt
Champ in-the-making
Champ in-the-making
issue a getObject request,it returns among other info the document content download url

openpj
Elite Collaborator
Elite Collaborator
If you are using the OpenCMIS library, there is no public method dedicated to retrieve the content stream url, but you can use the suggested following method to implement a getDocumentURL using Java Reflections:

public static final String getDocumentURL(final Document document, final Session session) {
    String link = null;
    try {
        Method loadLink = AbstractAtomPubService.class.getDeclaredMethod("loadLink",
            new Class[] { String.class, String.class, String.class, String.class });
       
        loadLink.setAccessible(true);
       
        link = (String) loadLink.invoke(session.getBinding().getObjectService(), session.getRepositoryInfo().getId(),
            document.getId(), AtomPubParser.LINK_REL_CONTENT, null);
    } catch (Exception e) {
       e.printStackTrace();
    }
    return link;
  }
Hope this helps.

nareshthota
Champ in-the-making
Champ in-the-making
hi…
I 've used the above code and it is returning the url…its a great work…but the problem is if we use this url it is asking alfresco login details…
our requirement is to directly download the file with out asking the alfresco credentials…

can any one suggest alternatives…

thanks in advance…

ashok
Champ on-the-rise
Champ on-the-rise
append access token at end of url, like after id=xxxxx-xxxx-xxx-xxx-xxx&access_token=xxxxx-xxxxx-xxxx-xxxx-xxxxxxx

kaynezhang
World-Class Innovator
World-Class Innovator
I think you'd better not display document url returned by cmis atom binding to end user.
Instead generate a url for every document,when user clicks your url which send request to your proxy servelt,Then your proxy servlet get the document id and user credentials and use user credentials to download file from repository and send stream to user browser.

fgjohnson
Champ in-the-making
Champ in-the-making