cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of thumbnail 'doclib' failed

ankurkhandelwal
Champ in-the-making
Champ in-the-making
Dear All,

I am using Alfresco 3.4.5 Vesrion.

I am pushing a pdf document in Alfresco using a dot net code that creates a node and then I apply permission on the document through webscripts.

The problem is that I am not able to get preview of the pdf document that I am pushing through dot net code.However I am getting preview of document uploaded by share.

I am using the following code to set permission on my node created.

var group="";
var documentName="";
var location="";
var workflowNeeded = false;
function callWorkflow(documentNodeRef)
{
try
    {
logger.log("kcwfdll.post.json.js is called");   
         logger.log("callWorkflowt ist called");
         logger.log("documentNodeRef"+documentNodeRef);
         var document = search.findNode(documentNodeRef);
         logger.log("document"+document);
         var uploadedby = document.properties["kb:docuementAcceptedBy"];   
         if(uploadedby==null)
         {
            uploadedby = "admin";
         }

            
            
         var uploader = people.getPerson(uploadedby);
         var description="";
         var errorMessage = "";
         documentName = "";
         var level1 = "";
         var level2 = "";
         var level3 = "";
         group = uploader.properties["kb:vertical"];
         group = "GROUP_"+group+"_KC";
         
         var groupNode = people.getGroup(group);
         
         if(groupNode==null)
         {
            group = "GROUP_ALFRESCO_ADMINISTRATORS";
            groupNode = people.getGroup(group);
            errorMessage="Sent to admin for approval as no KC found for this document.";
         }
         
         //var fileNodeRefs = [];
         //var jsonArray = json.get("ref");
         
         //rahul s
         var workflowDefinition = workflow.getDefinitionByName("jbpm$publish:approvepublishDocument");
         var workflowPackage = workflow.createPackage();
         workflowPackage.addNode(document);
         logger.log("Before getting node");
         documentName = documentName + document.properties["cm:name"]+",";
         logger.log("Before getting level1");
         level1=document.properties["kb:ilLevelOne"];
         logger.log("Before getting level1"+level1);
         level2=document.properties["kb:ilLevelTwo"];
         logger.log("Before getting level2"+level2);
         level3=document.properties["kb:ilLevelThree"];
         logger.log("Before getting level1"+level3);
               
         location = "\\"+level1+"\\"+level2+"\\"+level3;
         var workflowParameters = new Array();
         description="KC approval needed for the document \""+documentName+"\" uploaded by "+uploadedby+" at "+level1+"\\"+level2+"\\"+level3+".";
         description=description+errorMessage;
         workflowParameters["bpm:workflowDescription"]  = description;
         workflowParameters["bpm:groupAssignee"]  = people.getGroup(group);
         workflowParameters["publish:doclist"]  = documentName;

         var workflowPath = workflowDefinition.startWorkflow(workflowPackage,workflowParameters);//This code just initiates workflow
         
         logger.log("workflowPackage"+workflowPackage);
         logger.log("workflowParameters"+workflowParameters);
         logger.log("workflowPath"+workflowPath);

         //Following code would end start task
         var tasks = workflowPath.getTasks();
         for(task in tasks)
         {
            tasks[task].endTask(null);
         }
         
         
         
   }       
       catch (e)
    {
      //group = "GROUP_ALFRESCO_ADMINISTRATORS";
     location = location+". But due to some error workflow deployment has failed."
     logger.log("location is "+location)
     //sendmail(group,documentName,location);
     logger.log("In Excpetion");
     var errordate = new Date();
     logger.log("Document uplaoded on   "+errordate+ " by "+uploader);
     logger.log(e);
      throw e;
    }
}   
function sendmail(group,documentName,location)
{
   logger.log("Mail method called while triggering workflow "+group+"documentName"+documentName+"location"+location);
   try
   {
      var groups = new Array("group");
      var mail = actions.create("mail");
       logger.log("location is "+location)
      mail.parameters.to_many = groups;
      mail.parameters.subject = "KC Workflow Task";
      //mail.parameters.from = "eservices@ymycompany.com";
      mail.parameters.text = "Document "+documentName+" has come for approval at "+location;
      logger.log("Body is "+mail.parameters.text);
      mail.execute(companyhome);
   }catch(e)
   {
      logger.log("Mail sending failed");
   }
}

function checkForKc(documentNodeRef)
{
         var document =  search.findNode(documentNodeRef);
         if (document.hasAspect("kb:MailKM"))
         {
            logger.log("MailKM aspect already applied–start");            
            document.properties["kb:ilMailContent"] = "|";
            document.properties["kb:ilMailAttachments"] = "|";
            document.save();            
            logger.log("MailKM aspect already applied–end");
         }else{
            logger.log("Applying MailKM Aspect on Doc–Client–start");
            document.addAspect("kb:MailKM");
            document.save();
            document.properties["kb:ilMailContent"] = "|";
            document.properties["kb:ilMailAttachments"] = "|";
            document.save();
            logger.log("Applying MailKM Aspect on Doc–end");
         }
         
         /* commented by vivek on 1st nov 2012 because workflow not needed
         
         var level1 = document.properties["kb:ilLevelOne"];
         var level2 = document.properties["kb:ilLevelTwo"];
         var level3 = document.properties["kb:ilLevelThree"];
         //var category = document.properties["kb:ilDocumentCategory"];
         var categories = document.properties["cm:categories"];
         var category="";
         logger.log("categories is"+categories);
         if(categories!=null && categories.length >0)
         {
            category = categories[0].properties["cm:name"];
         }
         logger.log("Category is"+category);
//         var uploadedby = document.properties["kb:docuementAcceptedBy"];   
         var uploadedby = null;   
         if(uploadedby==null)
         {
            uploadedby = "admin";
         }
         var uploader = people.getPerson(uploadedby);
         group = uploader.properties["kb:vertical"];
         group = "GROUP_"+group+"_KC";
         
         var groupNode = people.getGroup(group);
         if(groupNode==null)
         {
            group = "GROUP_ALFRESCO_ADMINISTRATORS";
            groupNode = people.getGroup(group);
         }
         
         var searchQuery = "PATH:\"app:company_home/app:dictionary/cm:ILKM/cm:Config/cm:taxonomy.xml\"";
         var  queryParameters = {
            
            query : searchQuery,
         };
         var nodeList = search.query(queryParameters);
         logger.log("Outside if");
         if(nodeList!=null && nodeList.length > 0)
         {
            
            var fileNodeRef = nodeList[0].nodeRef;
            var fileNode = search.findNode(fileNodeRef);
            var str = fileNode.properties.content.getContent();
            
            if ( str.substr(0,5).indexOf("?xml") != -1 )
            {
             positionRootElement = str.indexOf("<", 10);//get first real tag
             str = str.substr( positionRootElement, str.length - 1 );
            }
            var pressrelease = new XML(str);

            var entry = pressrelease.entry;
            for(var k = 0; k < entry.length(); k++)
            {
               
               var categoryXml = entry[k].category.toString();
               var level1Xml =  entry[k].level1.toString();
               var level2Xml =  entry[k].level2.toString();
               var level3Xml =  entry[k].level3.toString();
               
            
               if(((category.equals(categoryXml)) && ((level1Xml.equals("")) && (level2Xml.equals("")) && (level3Xml.equals(""))))
               || (((level1.equals(level1Xml)) && (level2.equals(level2Xml)) && (level3.equals(level3Xml))) && (categoryXml.equals("")))
               || ((level1.equals(level1Xml)) && (level2.equals(level2Xml)) && (level3.equals(level3Xml) && (category.equals(categoryXml)))))
               {
                  logger.log("Workflow Needed");
                  workflowNeeded = true;
                  break;
               }else{
                 workflowNeeded = false;
               }
            }
               
            if(workflowNeeded)
            {                  
               document.setInheritsPermissions(false);
               document.removePermission("Read");
               document.removePermission("Write");
               document.removePermission("Delete");
               document.setPermission("SiteCollaborator", uploadedby); 
               if(groupNode!=null)
               {
                document.setPermission("SiteCollaborator", group); 
               }else{
                logger.log("Group "+group+" does not exist");
               }
            }
         }
         */
         
}

function main()
{
   var store_type = url.templateArgs.store_type;
   var store_id = url.templateArgs.store_id;
   var nodeId = url.templateArgs.id;
   var documentNodeRef = store_type+"://"+store_id+"/"+nodeId;
var ownername=url.templateArgs.username;
   logger.log("Doc NodeRef is||"+documentNodeRef)
   var docNode = search.findNode(documentNodeRef);
   if(documentNodeRef!=null && docNode!=null)
   {
      
      logger.log("before calling checkkc flag is "+workflowNeeded);
         //docNode.setPermission("Coordinator", ownername); 
         docNode.properties["cm:owner"] = ownername;
         docNode.properties["kb:docuementAcceptedBy"] = ownername;
         docNode.save();
         if(docNode.properties["cm:description"] !=""){

                if(docNode.properties["cm:description"] == "IeClient"){
                docNode.properties["kb:uploadVia"] = "ieclient";
                docNode.properties["cm:description"] = "";
                docNode.save();
                }
                else{
                docNode.properties["kb:uploadVia"] = "desktopclient";
                docNode.properties["cm:description"] = "";
                docNode.save();
                }

            }else{
            docNode.properties["kb:uploadVia"] = "ieclient";
            docNode.save();
            }
      checkForKc(documentNodeRef);
      logger.log("after calling checkkc flag is "+workflowNeeded);
      /* if workflow not needed – added by vivek on 1st nov 2012*/
      workflowNeeded = false;
      var mimetype = docNode.mimetype;
      logger.log("ffffffffffffffffffffffffffffffff" +mimetype);
      mimetype = mimetype.toLowerCase();
      logger.log("1111111111111111111111111111111111111" +mimetype);
      var fileExt = "";
      //logger.log("||||||||||||||||||"+docNode.properties["cm:name"]+"!!!!!!!!!!!!!!!!"+(docNode.properties["cm:name"]).indexOf("."));
      if((docNode.properties["cm:name"]).indexOf(".") != -1){
      }else{
      if(mimetype == "application/pdf".toLowerCase()){fileExt =".pdf";}
      else if(mimetype =="text/html".toLowerCase()){fileExt =".html";}
      else if(mimetype =="application/msword".toLowerCase()){fileExt =".doc";}
      else if(mimetype =="application/vnd.openxmlformats-officedocument.wordprocessingml.document".toLowerCase()){fileExt =".docx";}
      else if(mimetype =="application/vnd.oasis.opendocument.text".toLowerCase()){fileExt =".odt";}
      else if(mimetype =="text/plain".toLowerCase()){fileExt =".txt";}
      else if(mimetype =="application/rtf".toLowerCase()){fileExt =".rtf";}
      else if(mimetype =="application/vnd.ms-excel".toLowerCase()){fileExt =".xls";}
      else if(mimetype =="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".toLowerCase()){fileExt =".xlsx";}
      else if(mimetype =="application/vnd.ms-powerpoint".toLowerCase()){fileExt =".ppt";}
      else if(mimetype =="application/vnd.openxmlformats-officedocument.presentationml.presentation".toLowerCase()){fileExt =".pptx";}
      else if(mimetype =="image/bmp".toLowerCase()){fileExt =".bmp";}
      else if(mimetype =="message/rfc822".toLowerCase()){fileExt =".eml";}
      else if(mimetype =="image/gif".toLowerCase()){fileExt =".gif";}
      else if(mimetype =="text/csv".toLowerCase()){fileExt =".csv";}
      else if(mimetype =="image/ief".toLowerCase()){fileExt =".ief";}
      else if(mimetype =="application/x-javascript".toLowerCase()){fileExt =".js";}
      else if(mimetype =="image/jpeg".toLowerCase()){fileExt =".jpeg";}
      else if(mimetype =="application/vnd.oasis.opendocument.chart".toLowerCase()){fileExt =".odc";}
      else if(mimetype =="application/vnd.oasis.opendocument.database".toLowerCase()){fileExt =".odb";}
      else if(mimetype =="application/vnd.oasis.opendocument.graphics".toLowerCase()){fileExt =".odg";}
      else if(mimetype =="application/vnd.oasis.opendocument.graphics-template".toLowerCase()){fileExt =".otg";}
      else if(mimetype =="application/vnd.oasis.opendocument.formula".toLowerCase()){fileExt =".odf";}
      else if(mimetype =="application/vnd.oasis.opendocument.image".toLowerCase()){fileExt =".odi";}
      else if(mimetype =="application/vnd.oasis.opendocument.text-master".toLowerCase()){fileExt =".odm";}
      else if(mimetype =="application/vnd.oasis.opendocument.presentation".toLowerCase()){fileExt =".odp";}
      else if(mimetype =="application/vnd.oasis.opendocument.presentation-template".toLowerCase()){fileExt =".otp";}
      else if(mimetype =="application/vnd.oasis.opendocument.spreadsheet".toLowerCase()){fileExt =".ods";}
      else if(mimetype =="application/vnd.oasis.opendocument.spreadsheet-template".toLowerCase()){fileExt =".ots";}
      else if(mimetype =="application/vnd.oasis.opendocument.text-template".toLowerCase()){fileExt =".ott";}
      else if(mimetype =="application/vnd.sun.xml.calc".toLowerCase()){fileExt =".sxc";}
      else if(mimetype =="application/vnd.sun.xml.draw".toLowerCase()){fileExt =".sxd";}
      else if(mimetype =="application/vnd.sun.xml.impress".toLowerCase()){fileExt =".sxi";}
      else if(mimetype =="application/vnd.sun.xml.writer".toLowerCase()){fileExt =".sxw";}
      else if(mimetype =="image/png".toLowerCase()){fileExt =".png";}
      else if(mimetype =="application/vnd.stardivision.chart".toLowerCase()){fileExt =".sds";}
      else if(mimetype =="application/vnd.stardivision.calc".toLowerCase()){fileExt =".sdc";}
      else if(mimetype =="application/vnd.stardivision.draw".toLowerCase()){fileExt =".sda";}
      else if(mimetype =="application/vnd.stardivision.impress".toLowerCase()){fileExt =".sdd";}
      else if(mimetype =="application/vnd.stardivision.impress-packed".toLowerCase()){fileExt =".sdp";}
      else if(mimetype =="application/vnd.stardivision.math".toLowerCase()){fileExt =".smf";}
      else if(mimetype =="application/vnd.stardivision.writer".toLowerCase()){fileExt =".sdw";}
      else if(mimetype =="application/vnd.stardivision.writer-global".toLowerCase()){fileExt =".sgl";}
      else if(mimetype =="text/css".toLowerCase()){fileExt =".css";}
      else if(mimetype =="image/tiff".toLowerCase()){fileExt =".tiff";}
      else if(mimetype =="application/xhtml+xml".toLowerCase()){fileExt =".xhtml";}
      else if(mimetype =="text/xml".toLowerCase()){fileExt =".xml";}
      /*logger.log("|||||||||||||||||||||" +docNode.mimetype);
      logger.log("233332323232222323342334" +fileExt);
      logger.log("333333333333333333333333" +(docNode.mimetype == "application/pdf"));
      if(docNode.mimetype == "application/pdf"){
      fileExt = ".pdf";
      }else if(docNode.mimetype == "text/html"){
      fileExt = ".html";
      }*/
      
      }
      /* */
      if(workflowNeeded)
      {
         logger.log("worlflow needed");
         //document.setOwner(ownername);
         callWorkflow(documentNodeRef);
      }else
      {
         logger.log("worlflow not needed");
         docNode.mimetype = "application/vnd.stardivision.writer";
           docNode.save();
         logger.log("docNode.mimetypedocNode 1111 :::::::::::  "+docNode.mimetype);
         docNode.properties["cm:name"] = docNode.properties["cm:name"]+fileExt;
         docNode.properties["cm:title"] = docNode.properties["cm:name"];
         docNode.properties["kb:docuementAcceptedBy"] = docNode.properties["cm:creator"];
         docNode.properties["kb:docuementAcceptedOn"] =  new Date();
         docNode.properties["kb:isPublished"] = true;
         docNode.properties["kb:PublishedDate"] =  new Date();
         //docNode.properties["cm:owner"] = docNode.properties["cm:creator"];
         docNode.properties["kb:PublishedBy"] = docNode.properties["cm:creator"];
         docNode.save();
         //docNode.mimetype = "application/pdf";
         docNode.mimetype = mimetype;
           docNode.save();
         docNode.createThumbnail("doclib",true);
         docNode.save();
         if(docNode.hasAspect("cm:ownable")){
         docNode.properties["cm:owner"] = docNode.properties["cm:creator"];
         docNode.save();

         }else{
         docNode.addAspect("cm:ownable");
         docNode.properties["cm:owner"] = docNode.properties["cm:creator"];
         docNode.save();

          }
            docNode.save();

         logger.log("docNode.mimetypedocNode 2222 :::::::::::  "+docNode.mimetype);
         if (docNode.hasAspect("kb:MailKM"))
         {
            logger.log("MailKM aspect already applied–start");
            
            docNode.properties["kb:ilMailContent"] = "|";
            docNode.properties["kb:ilMailAttachments"] = "|";
            docNode.save();
            
            logger.log("MailKM aspect already applied–end");
         }

         else{   

            logger.log("Applying MailKM Aspect on Doc–start");         

            docNode.addAspect("kb:MailKM");
            docNode.save();

            docNode.properties["kb:ilMailContent"] = "|";
            docNode.properties["kb:ilMailAttachments"] = "|";
            docNode.save();
            
            logger.log("Applying MailKM Aspect on Doc–end");

         }
         //docNode.properties["kb:PublishedBy"] = docNode.getOwner();
      }
      
      logger.log("befor4 Mail method called while triggering workflow "+group+"document_name"+documentName+"location"+location);
      //sendmail(group,documentName,location);
   }else
   {
      logger.log("Node ref passed is null");
   }
}


main();


My error log shows the following error.

11:05:09,176  ERROR [repo.action.AsynchronousActionExecutionQueueImpl] Failed to execute asynchronous action: Action[ id=270b5854-e013-4381-acc4-9f92481afc26, node=null ]
org.alfresco.error.AlfrescoRuntimeException: 10270107 Creation of thumbnail 'doclib' failed
        at org.alfresco.repo.thumbnail.CreateThumbnailActionExecuter.executeImpl(CreateThumbnailActionExecuter.java:133)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:196)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:780)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:700)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:403)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:253)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:412)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
        at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:415)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.alfresco.service.cmr.thumbnail.ThumbnailException: 10270106 10270105 Transformer for 'APPLICATION/PDF' source mime type and 'image/png' target mime type was not found. Operation can't be performed
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnailNode(ThumbnailServiceImpl.java:598)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.access$000(ThumbnailServiceImpl.java:67)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:248)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:245)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnail(ThumbnailServiceImpl.java:243)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:17
2)


at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:146)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy113.createThumbnail(Unknown Source)
        at org.alfresco.repo.thumbnail.CreateThumbnailActionExecuter.executeImpl(CreateThumbnailActionExecuter.java:124)
        … 12 more
Caused by: org.alfresco.service.cmr.rendition.RenditionServiceException: 10270105 Transformer for 'APPLICATION/PDF' source mime type and 'image/png' target mime type was not found. Operation can't be performed
        at org.alfresco.repo.rendition.executer.AbstractTransformationRenderingEngine.render(AbstractTransformationRenderingEngine.java:62)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeRenditionImpl(AbstractRenderingEngine.java:500)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$2.doWork(AbstractRenderingEngine.java:432)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$2.doWork(AbstractRenderingEngine.java:412)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:411)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:375)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:196)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:780)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:700)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:538)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:146)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy23.executeAction(Unknown Source)
        at org.alfresco.repo.rendition.RenditionServiceImpl.executeRenditionAction(RenditionServiceImpl.java:281)
        at org.alfresco.repo.rendition.RenditionServiceImpl.render(RenditionServiceImpl.java:183)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnailNode(ThumbnailServiceImpl.java:592)
        … 35 more
In the else part


I have Imagemagick and open office installed on my system.

Request for urgent help
4 REPLIES 4

loftux
Star Contributor
Star Contributor
Can it be that you have added the mimetype in uppercase? Try 'application/pdf' instead of 'APPLICATION/PDF'.
If it's not your code setting the mimetype, then this can be a bug.

For that particular document, I would try to manual go into edit properties, set the mimetype to something random, save, then set it back to Adobe PDF. See if the transformation works after that.

ankurkhandelwal
Champ in-the-making
Champ in-the-making
Hi Loftux,

Thanks for the reply.

I have converted the mimetype to lower case.
Please refer the following code.


var mimetype = docNode.mimetype;
      mimetype = mimetype.toLowerCase();
      var fileExt = "";
      if ((docNode.properties["cm:name"]).indexOf(".") != -1) {
      } else {
         if (mimetype == "application/pdf".toLowerCase()) {
            fileExt = ".pdf";
         } else if (mimetype == "text/html".toLowerCase()) {
            fileExt = ".html";
         } else if (mimetype == "application/msword".toLowerCase()) {
            fileExt = ".doc";
         } else if (mimetype == "application/vnd.openxmlformats-officedocument.wordprocessingml.document".toLowerCase()) {
            fileExt = ".docx";
         } else if (mimetype == "application/vnd.oasis.opendocument.text".toLowerCase()) {
            fileExt = ".odt";
         } else if (mimetype == "text/plain".toLowerCase()) {
            fileExt = ".txt";
         } else if (mimetype == "application/rtf".toLowerCase()) {
            fileExt = ".rtf";
         } else if (mimetype == "application/vnd.ms-excel".toLowerCase()) {
            fileExt = ".xls";
         } else if (mimetype == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".toLowerCase()) {
            fileExt = ".xlsx";
         } else if (mimetype == "application/vnd.ms-powerpoint".toLowerCase()) {
            fileExt = ".ppt";
         } else if (mimetype == "application/vnd.openxmlformats-officedocument.presentationml.presentation".toLowerCase()) {
            fileExt = ".pptx";
         } else if (mimetype == "image/bmp".toLowerCase()) {
            fileExt = ".bmp";
         } else if (mimetype == "message/rfc822".toLowerCase()) {
            fileExt = ".eml";
         } else if (mimetype == "image/gif".toLowerCase()) {
            fileExt = ".gif";
         } else if (mimetype == "text/csv".toLowerCase()) {
            fileExt = ".csv";
         } else if (mimetype == "image/ief".toLowerCase()) {
            fileExt = ".ief";
         } else if (mimetype == "application/x-javascript".toLowerCase()) {
            fileExt = ".js";
         } else if (mimetype == "image/jpeg".toLowerCase()) {
            fileExt = ".jpeg";
         } else if (mimetype == "application/vnd.oasis.opendocument.chart".toLowerCase()) {
            fileExt = ".odc";
         } else if (mimetype == "application/vnd.oasis.opendocument.database".toLowerCase()) {
            fileExt = ".odb";
         } else if (mimetype == "application/vnd.oasis.opendocument.graphics".toLowerCase()) {
            fileExt = ".odg";
         } else if (mimetype == "application/vnd.oasis.opendocument.graphics-template".toLowerCase()) {
            fileExt = ".otg";
         } else if (mimetype == "application/vnd.oasis.opendocument.formula".toLowerCase()) {
            fileExt = ".odf";
         } else if (mimetype == "application/vnd.oasis.opendocument.image".toLowerCase()) {
            fileExt = ".odi";
         } else if (mimetype == "application/vnd.oasis.opendocument.text-master".toLowerCase()) {
            fileExt = ".odm";
         } else if (mimetype == "application/vnd.oasis.opendocument.presentation".toLowerCase()) {
            fileExt = ".odp";
         } else if (mimetype == "application/vnd.oasis.opendocument.presentation-template".toLowerCase()) {
            fileExt = ".otp";
         } else if (mimetype == "application/vnd.oasis.opendocument.spreadsheet".toLowerCase()) {
            fileExt = ".ods";
         } else if (mimetype == "application/vnd.oasis.opendocument.spreadsheet-template".toLowerCase()) {
            fileExt = ".ots";
         } else if (mimetype == "application/vnd.oasis.opendocument.text-template".toLowerCase()) {
            fileExt = ".ott";
         } else if (mimetype == "application/vnd.sun.xml.calc".toLowerCase()) {
            fileExt = ".sxc";
         } else if (mimetype == "application/vnd.sun.xml.draw".toLowerCase()) {
            fileExt = ".sxd";
         } else if (mimetype == "application/vnd.sun.xml.impress".toLowerCase()) {
            fileExt = ".sxi";
         } else if (mimetype == "application/vnd.sun.xml.writer".toLowerCase()) {
            fileExt = ".sxw";
         } else if (mimetype == "image/png".toLowerCase()) {
            fileExt = ".png";
         } else if (mimetype == "application/vnd.stardivision.chart".toLowerCase()) {
            fileExt = ".sds";
         } else if (mimetype == "application/vnd.stardivision.calc".toLowerCase()) {
            fileExt = ".sdc";
         } else if (mimetype == "application/vnd.stardivision.draw".toLowerCase()) {
            fileExt = ".sda";
         } else if (mimetype == "application/vnd.stardivision.impress".toLowerCase()) {
            fileExt = ".sdd";
         } else if (mimetype == "application/vnd.stardivision.impress-packed".toLowerCase()) {
            fileExt = ".sdp";
         } else if (mimetype == "application/vnd.stardivision.math".toLowerCase()) {
            fileExt = ".smf";
         } else if (mimetype == "application/vnd.stardivision.writer".toLowerCase()) {
            fileExt = ".sdw";
         } else if (mimetype == "application/vnd.stardivision.writer-global".toLowerCase()) {
            fileExt = ".sgl";
         } else if (mimetype == "text/css".toLowerCase()) {
            fileExt = ".css";
         } else if (mimetype == "image/tiff".toLowerCase()) {
            fileExt = ".tiff";
         } else if (mimetype == "application/xhtml+xml".toLowerCase()) {
            fileExt = ".xhtml";
         } else if (mimetype == "text/xml".toLowerCase()) {
            fileExt = ".xml";
         }
      }
      docNode.mimetype = "application/vnd.stardivision.writer";
      docNode.save();
      docNode.properties["cm:name"] = docNode.properties["cm:name"] + fileExt;
      docNode.properties["cm:title"] = docNode.properties["cm:name"];
      docNode.properties["kb:docuementAcceptedBy"] = docNode.properties["cm:creator"];
      docNode.properties["kb:docuementAcceptedOn"] = new Date();
      docNode.properties["kb:isPublished"] = true;
      docNode.properties["kb:PublishedDate"] = new Date();
      docNode.properties["kb:PublishedBy"] = docNode.properties["cm:creator"];
      docNode.save();
      docNode.mimetype = mimetype;
      docNode.save();
      docNode.createThumbnail("doclib", true);
      docNode.save();

Also I checked content property in repository which comes as contentUrl=store://2012/11/27/14/47/b50b9d2d-916c-4392-a3f5-46f34f9a236b.bin|mimetype=APPLICATION/PDF|size=21006|encoding=UTF-8|locale=en_US_|id=181070

Also as sugeested by you I had randomly changed the mimetype to docNode.mimetype = "application/vnd.stardivision.writer"; and changed it back to mimetype coming on doc,but still preview is not available.

Regards,
Ankur Khandelwal

loftux
Star Contributor
Star Contributor
I think you need to use docNode.properties.content.mimetype.

You can try docNode.properties.content.guessMimetype(string filename)
http://wiki.alfresco.com/wiki/4.0_JavaScript_API#ScriptContent_API

ankurkhandelwal
Champ in-the-making
Champ in-the-making
Hi Loftux.

I am getting "undefined" when i used docNode.properties.content.guessMimetype(docNode.properties["cm:name"]).


Regards,
Ankur Khandelwal