07-13-2009 08:41 AM
if(bpm_package.children[i].name.endsWith(".odt")){
template = {};
template.name = person.properties.firstName;
template.surname = person.properties.lastName;
template.date = new Date().toString();
ooTemplateWriter.transform(bpm_package.children[i], bpm_package.children[i], template);
}
ContentReader reader = contentService.getReader(source.getNodeRef(), ContentModel.PROP_CONTENT);
// create temporary files to convert from and to
File tempFromFile = TempFileProvider.createTempFile("OpenOfficeContentFiller-source-", ".odt");
File tempToFile = TempFileProvider.createTempFile("OpenOfficeContentFiller-target-", ".odt");
// download the content from the source reader
reader.getContent(tempFromFile);
InputStream is = new FileInputStream(tempFromFile);
ZippedDocumentTemplate zippedDocumentTemplate = new ZippedDocumentTemplate(is);
OutputStream os = new FileOutputStream(tempToFile);
zippedDocumentTemplate.createDocument(m, os);
is.close();
ContentWriter writer = contentService.getWriter(destinationNode.getNodeRef(), ContentModel.PROP_CONTENT, true);
// upload the temp output to the writer given us
writer.putContent(tempToFile);
07-13-2009 10:49 AM
writer.putContent(content.getInputStream());
// update cached variables after putContent()
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property);
07-13-2009 11:20 AM
I found something interesting. If I save the document (using the custom action: script) I have the same behavior of the workflow.
Looking into the ScriptNode class, I also found something interesting: in method setContent(String) the operations are apparently the same as I followed, but at the end of the method we have:
writer.putContent(content.getInputStream());
// update cached variables after putContent()
this.contentData = (ContentData) services.getNodeService().getProperty(nodeRef, this.property);
Is it possible that I write the 'good' url into the Node but not on the ScriptNode using the writer.putContent (since I see it is explicitly set in ScriptNode), and then at the end of the Workflow task we have a sort of autosave on the ScriptNode that is overwriting the contentUrl with the old one?
File tempFromFile = TempFileProvider.createTempFile("OpenOfficeContentFiller-source-", ".odt");
File tempToFile = TempFileProvider.createTempFile("OpenOfficeContentFiller-target-", ".odt");
// download the content from the source reader
reader.getContent(tempFromFile);
InputStream is = new FileInputStream(tempFromFile);
ZippedDocumentTemplate zippedDocumentTemplate = new ZippedDocumentTemplate(is);
OutputStream os = new FileOutputStream(tempToFile);
zippedDocumentTemplate.createDocument(m, os);
os.close();
InputStream is2 = new FileInputStream(tempToFile);
ScriptContentData contentData = (ScriptContentData)destinationNode.getProperties().get(ContentModel.PROP_CONTENT);
contentData.write(is2);
notice the last 2 lines
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.