public List<String> getDefinedTasks()
throws WorkflowException {
List<String> result = new ArrayList<String>();
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);
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse(procDefIS);
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodeList = (NodeList) xpath.evaluate("//userTask | //serviceTask | //scriptTask", doc,
XPathConstants.NODESET);
for (int i = 0; i < nodeList.getLength(); i++) {
result.add(nodeList.item(i).getAttributes().getNamedItem("id").getNodeValue());
}
} catch (Exception e) {
throw new WorkflowException(e);
} finally {
try {
procDefIS.close();
} catch (IOException ioe) {
LOG.error("While closing input stream for {}", procDef.getKey(), ioe);
}
}
return result;
}