2

I have created a Custom web Application using Java Servlets, and connected to Alfresco Repository using CMIS.

Now my requirement is to built a Library Navigator; for this I have to display the document thumbnail image in front of the document name using <IMG/> tag.

How can I achieve this using CMIS or any other alfresco rest api.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Arjun Patil
  • 111
  • 9

2 Answers2

3

CMIS understands the concept of renditions. Thumbnails and web previews in Alfresco are exposed as CMIS renditions. This blog post gives details. In it, you will see a code example, and I've included it below:

OperationContext context = session.createOperationContext();
context.setRenditionFilterString("cmis:thumbnail");
CmisObject doc = session.getObjectByPath("/Sites/ren/documentLibrary/Spring Surf and OpenCMIS Integration", context);
List<Rendition> renditions = doc.getRenditions();
for (Rendition rendition : renditions)
{
   System.out.println("kind: " + rendition.getKind());
   System.out.println("mimetype: " + rendition.getMimeType());
   System.out.println("width: " + rendition.getWidth());
   System.out.println("height: " + rendition.getHeight());
   System.out.println("stream id: " + rendition.getStreamId());
}

Note that something that might trip you up is that renditions are not created automatically when objects are added to the repository. Normally, they are created asynchronously when someone requests to see the document library view through the Alfresco Share client.

If you need to be able to create a document and then immediately retrieve its renditions without ever logging in to the Alfresco Share client, you'll need to use rules or behaviors to trigger the creation of the renditions you want.

Jeff Potts
  • 10,468
  • 17
  • 40
  • HI Jeff , I tried above code but as you said someone has requests to see the document library view through the Alfresco Share client is necessory. And i also tried for setting a rule but my rule is not working if i created document object Using Cmis no Js script get executed. – Arjun Patil Oct 20 '16 at 05:08
  • Rules should always trigger regardless of how the document is added. What specific version are you running? – Jeff Potts Oct 20 '16 at 14:12
2

It seems that you are looking for document place holder.

Instead of yousing CMIS, better to go for Alfresco REST API. Below is the REST API to get document place holder, in that you need to pass Document Node refrence And ALF Ticket Dynamically

 "http://localhost:8080/alfresco/s/api/node/workspace/"+noderef+"/content/thumbnails/doclib?c=queue&ph=true&lastModified=doclib:1475322106180&alf_ticket="+alf_ticket

I hope, this will Help you.

Deepak Talape
  • 997
  • 1
  • 9
  • 35
  • My default alfresco share is not getting thumbnails in Library view. Is there any configuration in properties file. – Arjun Patil Oct 19 '16 at 13:24
  • This statement is not true: "Actually its not possible to get document place holder using CMIS." CMIS understand renditions, and the document library thumbnail is a rendition named "doclib" which is accessible via CMIS. – Jeff Potts Oct 19 '16 at 17:36