cancel
Showing results for 
Search instead for 
Did you mean: 

How to get document link

kurdy
Champ in-the-making
Champ in-the-making
Hi,

I am using CMIS with Apache Chemistry OpenCMIS 0.3.0-incubating-SNAPSHOT  and Alfresco 3.4.d.

How could I get document link(cifs, webdav) for a document using cmis properties or query ?

I would get something like:

http://localhost:8080/alfresco/webdav/test/test1/2011/2/my.docx
or
file:////test/test1/2011/2/my.docx

I would like to avoid (if possible) the use of a second request and use webscript just for that.

1) get document id
2) request document link


Thanks for any advices or help.
4 REPLIES 4

kurdy
Champ in-the-making
Champ in-the-making
My mistake was I tried to get the Path using properties from a queryResult. The solution is to get the cmis Document and then use the getter getPaths(…)

Bye

nareshthota
Champ in-the-making
Champ in-the-making
hi kurdy…
I am also looking for the same thing….if possible could u please share the code snippet in which u got the document link…

Thanks…

thomas_x
Champ on-the-rise
Champ on-the-rise
String queryString = "SELECT * FROM cmis:document WHERE cmis:name LIKE '%.pdf' ";
//        String queryString = "SELECT * FROM cmis:document WHERE cmis:name LIKE '%12-3123.%'";
        ItemIterable<QueryResult> queryResult2 = session.query(queryString, false);
        for (QueryResult item : queryResult2) {
           System.out.println("Datei: " + item.getPropertyByQueryName("cmis:name").getFirstValue() +  " createdBy "
                 + item.getPropertyByQueryName("cmis:createdBy").getFirstValue());
           
           String objectId = item.getPropertyValueByQueryName("cmisSmiley SurprisedbjectId");
           Document document = (Document) session.getObject(session.createObjectId(objectId));
           System.out.println("Datei: " + getDocumentURL(document, session));
        }
       
  
   public static 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;
    }

… i hope this helps

String objectId = result.getPropertyValueByQueryName("cmisSmiley SurprisedbjectId");

returns NULL. 

This "cmisSmiley SurprisedbjectId" do not exist anymore.

PropertiesByQueryName returns this now:

{D.cmis:name=Property [id=cmis:name, display Name=null, local name=name, query name=D.cmis:name, values=[VIVIANE.pdf]][extensions=null], T.cm:title=Property [id=cm:title, display Name=Título, local name=title, query name=T.cm:title, values=[1234]][extensions=null], T.cm:description=Property [id=cm:description, display Name=Descrição, local name=description, query name=T.cm:description, values=[]][extensions=null]}

How can I get the "cmisSmiley SurprisedbjectId" now? Can you help me please?