cancel
Showing results for 
Search instead for 
Did you mean: 

Uploaded documents and availability of thumbnails ?

mcs130
Champ in-the-making
Champ in-the-making
Hello

I have a question re: behavior we are seeing with Alfresco 4.2.a (Community Edition).  (we have been able to reproduce the sequence of events and behavior multiple times).  Running SLES 11, and JDK 6 with an OOTB installation (Postgress, Solr, Tomcat, etc).

We have developed an application that is strictly using CMIS and the OpenCMIS API (Chemistry) to interact with our Alfresco 4.2.a installation.  It has been working extremely well for the POC work we are doing.  We have code that creates folders (and subfolders) and then can upload a series of 20 test files of various types (.docx, .xslx, .pdf, .jpg, .txt, etc - about 10 types including audio and video media).  So far so good.

We have also written code to retrieve the thumbnails for these files based on information found here: http://chemistry.apache.org/java/developing/guide.html  using the OperationContext and it has worked great EXCEPT that we notice only under the following conditions:

1) we create folders and upload documents using the CMIS APIs from our code - OK
2) we open the web browser at: http://xx.xx.xx.xx:8080/share/page/repository  and inspect the folder structure and files listed and everything is CORRECT and as expected - OK
3) we run our test to go query and get those cmisSmiley Very Happyocument objects, build a List<String> containing the cmisSmiley SurprisedbjectId of the documents and then iterate to simply test retrieval of the "thumbnail" using code like this for each one:  (and this works OK as long as step 2 is done)


  public InputStream getDocumentThumbnail(String documentId) throws Exception {

      OperationContext context = this.cmisSession.createOperationContext();
      context.setRenditionFilterString("cmis:thumbnail");

      CmisObject targetDocument = this.cmisSession.getObject(documentId, context);
      List<Rendition> renditions = targetDocument.getRenditions();

      String streamId = null;
      InputStream inputStream = null;
      for (Rendition rendition : renditions) {
           streamId = rendition.getStreamId();
      }

      if (streamId != null) {
         CmisObject cmisObject = this.cmisSession.getObject(streamId);
         ContentStream stream = ((Document) cmisObject).getContentStream();
         if (stream != null) {
            inputStream = stream.getStream();
         }
      }

      return inputStream;

   }


4) HOWEVER - if we skip step 2 (opening the browser on the repository FIRST) …and then we run our test to go query and get those cmisSmiley Very Happyocument objects, build a List<String> containing the cmisSmiley SurprisedbjectId of the documents and then iterate to simply test retrieval of the "thumbnail" using the exact same code above - every InputStream that comes back is now null

Only if we go open the repository via the web and open the folders listing the files - will it work.  We run step #3 and then we get them all.

Perhaps

A) we are misunderstanding and need to set a configuration value to force the thumbnail rendition to be created, or
B) incorrectly using the code to retrieve the thumbnails, or
C) is this a possible defect?  (I would have to believe it's A or B)…this seems like something that should always be available regardless of interaction with the repository via the browser.

Thanks

Mark
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
The issue is that thumbnails are "lazily" created as and when requested.   By opening the browser it triggers the generation of the thumbnails if they don't already exist.

You probably want to create thumbnails via a rule instead.

mcs130
Champ in-the-making
Champ in-the-making
Ok… Could you perhaps share how one implements this idea of a rule ? Is this covered in the online docs somewhere and I just missed it? Is this something configurable with xml like the model extension concept?

We will require the need to have a thumbnail available on demand for any doucument uploaded via our application we are building. Will that be possible?

Thanks in advance for any insight.

mcs130
Champ in-the-making
Champ in-the-making
Let me also add that I have found the place in the Web admin page for Rules Management. http://xx.xx.xx.xx:8080/share/page/folder-rules?  I try navigating this and use the Rule creation dialog that has a dialog elements like:

Perform Action:

Transform and copy content:       Mimetype:    to…/____________   Select…


I can set the Mimetype to PNG Image but then what?

1) I assume there is some place to configure a size of the image
2) We will want this rule applied to the top level folder and ALL descending folders as they are created and content added (which I do see the option to have it apply to subfolders) … and the problem here is that it wants you to specify the "to" folder location.  But it requires you pick from a tree display of the folders but that won't work.  The thumbnail image should reside in the same folder as the actual document itself, no?  There is no ONE place for these, is there?

When the Admin page is used to navigate the tree hierarchy of the repository and then lists the documents and then this "lazy" creation (as you refer to it) of thumbnails is occurring - what is that rule doing?  Where is it storing these?

This raises far more questions than it answers.  Any additional input, example or reference link would be appreciated.

Thanks

jpotts
World-Class Innovator
World-Class Innovator
Unless one has been added recently that I missed, there is no out-of-the-box rule action that will create thumbnails in the same way that thumbnails are created when you view the document library. You have to write this yourself. One way to do it is to write server-side JavaScript that leverages the rendition service to force the creation of the thumbnail for the node when it is created.

Once your JavaScript is working you can point to it from a rule using the "Execute Script" action.

Word of warning: If you set this rule on your root folder and tell it to apply to all sub-folders, it will apply to ALL sub-folders, even sub-folders that aren't visible to the user interface. And your server will be very, very busy creating renditions for each and every node in your entire repository. So be very restrictive in your rule action and even in your JavaScript to make sure that you are only creating renditions for folders and nodes that you intend, otherwise it will get out-of-hand very quickly. It is easy to send your repository into a rendition death spiral if you don't pay attention.

Jeff

nancyaggarwal
Champ in-the-making
Champ in-the-making
Hi Mark

I also have to upload a file from local disk into the alfresco  repository but in my code it always shows the same mimetype for every file i.e application/octet .

So, can you share your code with me so that i can rectify my code

Thanks
Nancy