@Override
public WorkflowDefinitionTO getDefinition()
throws WorkflowException {
ProcessDefinition procDef;
try {
procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
ActivitiUserWorkflowAdapter.WF_PROCESS_ID).latestVersion().singleResult();
} catch (ActivitiException e) {
throw new WorkflowException(e);
}
InputStream procDefIS = repositoryService.getResourceAsStream(procDef.getDeploymentId(), WF_PROCESS_RESOURCE);
Reader reader = null;
Writer writer = new StringWriter();
try {
reader = new BufferedReader(new InputStreamReader(procDefIS));
int n;
char[] buffer = new char[1024];
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
} catch (IOException e) {
LOG.error("While reading workflow definition {}", procDef.getKey(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
if (procDefIS != null) {
procDefIS.close();
}
} catch (IOException ioe) {
LOG.error("While closing input stream for {}", procDef.getKey(), ioe);
}
}
WorkflowDefinitionTO definitionTO = new WorkflowDefinitionTO();
definitionTO.setId(ActivitiUserWorkflowAdapter.WF_PROCESS_ID);