Search code examples
alfrescocmisthin-client

How to get the thin client URI of an Alfresco folder/document?


A thin client URI is a web address that you can type to see details about a file or folder, on a nice web user interface.

For instance, my Android app uses Alfresco's CMIS API, but for complex operations (eg. to start a workflow on this file), you could click on a link and it would bring you to the fully-fledged web interface (provided by the Alfresco server).

How to calculate this thin client URI, for any Alfresco folder/document?

A good start is to use the thinClientURI feature of the CMIS protocol. Unfortunately it only work for the root of the repository.

A perfect algorithm would show Alfresco Share nodes in their Alfresco Share site, rather than in Share's generic Repository Browser.


Solution

  • Alfresco does have a little known feature to do just what you need! I believe it was implemented in Enterprise 4.0.3ish, ready for 4.1, and the main use of it so far is in Cloud Sync.

    The webscript you're looking for is org.alfresco.repository.site.site-share-view-url.get and it is exposed as /api/sites/shareUrl?nodeRef=nodeRef . It returns a simple bit of JSON, such as:

    {
       "site": "alfresco-test",
       "url": "https:\/\/my.alfresco.com\/share\/test.com\/page\/site\/alfresco-test\/document-details?nodeRef=workspace:\/\/SpacesStore\/aae3b33fd-23d4-4091-ae64-44a8e332091341"
    }
    

    (The above example is taken from the Alfresco cloud version, but it should be present in late 4.0 enterprise releases, enterprise 4.1, and community + enterprise 4.2 onwards)

    If you want to see what kinds of content it supports, your best bet is to look at the java class which powers it, org.alfresco.repo.web.scripts.site.SiteShareViewUrlGet

    However, one slight restriction is that it only supports nodes that are located within sites. If you have a non-site node, you'll have to calculate a repository browser URL for it yourself...