AnsweredAssumed Answered

Uploaded documents and availability of thumbnails ?

Question asked by mcs130 on Nov 2, 2012
Latest reply on Jul 12, 2013 by nancyaggarwal
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 cmis:Document objects, build a List<String> containing the cmis:objectId 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 cmis:Document objects, build a List<String> containing the cmis:objectId 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

Outcomes