cancel
Showing results for 
Search instead for 
Did you mean: 

Custom document transformation

birgir
Champ in-the-making
Champ in-the-making
I am trying to get document transformation working before I start my workflow. I am converting from PS to PDF which works fine when done manually via using rules. I only know the name of the folder to do the transformation on during runtime so I want to be able to call the transformation myself, programmatically. Here is what I did. When I run this nothing happens, not even a debug or info message in the consule (I have them turned on).



NodeRef compHomeRef = getCompanyHomeNode(actionedUponNodeRef.getStoreRef());
NodeRef uploadFolderRef = nodeService.getChildByName(compHomeRef, ContentModel.ASSOC_CONTAINS, UPLOAD_FOLDER);
NodeRef taskFolderRef = nodeService.getChildByName(uploadFolderRef, ContentModel.ASSOC_CONTAINS, folderName);
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(TransformActionExecuter.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_PDF);
params.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, taskFolderRef);
params.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CHILDREN);
params.put(TransformActionExecuter.PARAM_ASSOC_QNAME, QName.createQName("http://www.namespace.com/model/workflow/1.0", "transformed"));
        
Action tAction = new ActionImpl(taskFolderRef,ID,TransformActionExecuter.NAME,null);
transformAction = (TransformActionExecuter)applicationContext.getBean(TransformActionExecuter.NAME);
tAction.setParameterValues(params);       
transformAction.execute(tAction, taskFolderRef);


What am I doing wrong here ?
Any ideas how to do this ?
1 REPLY 1

birgir
Champ in-the-making
Champ in-the-making
To help anyone with similar problems, I might just answere my own question. The problem was simple, I was executing the action and sending the whole folder as a reference instead of individual files which is expected (i.e it exptects reference of TYPE_CONTENT). So this is what I did to do the transform.


private void doTransformation(Action action, NodeRef folderRef, String MIME)
{
   Iterator<ChildAssociationRef> it = nodeService.getChildAssocs(folderRef).iterator();
      
   while(it.hasNext())
   {
      ChildAssociationRef cref = (ChildAssociationRef)it.next();
      ContentData content = (ContentData)nodeService.getProperty(cref.getChildRef(), ContentModel.PROP_CONTENT);

      if(content.getMimetype().equals(MIME))
      {      
         this.transformAction.execute(action, cref.getChildRef());
      }
   }
   
}
The action is set up like in the previous post holding the destination folder and other params.