Well, in the meantime I tried to implement generation of an image after workflow is deployed.
I tried to get image with the following code:
NewDeployment deployment = repositoryService.createDeployment();
String name = workflow.getName().replaceAll(" ", "_");
String key = deployment.addResourceFromString(
name + "_" + workflow.getVersion() + ".jpdl.xml",
workflowSerializer.serialize(workflow)).deploy();
ProcessDefinitionQuery pdq = repositoryService
.createProcessDefinitionQuery();
List<ProcessDefinition> processDefinitions = pdq.processDefinitionKey(
key).list();
for (ProcessDefinition pd : processDefinitions) {
String imageName = pd.getImageResourceName();
File f = new File("/home/bofh/" + imageName);
try {
FileOutputStream fos = new FileOutputStream(f);
System.out.println("Created file " + f.getAbsolutePath());
InputStream imageInputStream = repositoryService
.getResourceAsStream(pd.getDeploymentId(), imageName);
byte[] buffer = new byte[10240];
int read = 0;
while ((read = imageInputStream.read(buffer)) > 0) {
fos.write(buffer, 0, read);
}
fos.flush();
fos.close();
imageInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
However the name of image at line
String imageName = pd.getImageResourceName();
is always null, which causes NPE on getting the actual image stream
Am I missing something?
Thank you in advance!