currently I am working with XML, JSP, and Activiti Workflow Engine. On my project, I have following processes:
- An employee submit a JSP Form
- When the form is submitted, I will update my xml file to change the name of a tag. For example, from: "Sign Document" into "Sign Document 1". 1 here represent the ID of the data in my database
- After the file has successfully updated, the program will directly deploy Activiti Workflow Engine Process based on my updated XML file
I have successfully update my xml file and deploy the process, but when I got some problem with the name of the XML tag. The problem is:
- After the XML file successfully updated, my program will not directly used the latest file, but it used the old one. So for example, before I update the XML file, the name of the tag is "Sign Form" and after I updated the file, the tag name on the file will become "Sign Form 1". However, when I check my activiti database, it shows that activiti still used the xml file with tag name "Sign Form" not "Sign Form 1"
I guess it because I need to refresh the XML file first before run the deployment. But I don't know how to do so on JSP or Java. Anyone could help me? Thanks
Here is my code:
try {
String filepath = "path/to/the/filename.bpmn20.xml";
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(filepath);
// Get the process element by tag name directly
Node userTask = doc.getElementsByTagName("userTask").item(0);
// update userTask attribute
NamedNodeMap attr = userTask.getAttributes();
Node nodeAttr = attr.getNamedItem("name");
nodeAttr.setTextContent("Review and Sign Form "+id);
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File(filepath));
transformer.transform(source, result);
System.out.println("Done");
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (TransformerException tfe) {
tfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (SAXException sae) {
sae.printStackTrace();
}
ch.changeBO(id+1); dp.deployProcess();
ch.changeBO(id+1) was used to changed the XML file and dp.deployProcess() was used to deploy the process (which will used my xml file) And I think the problem is I tried to use my xml file without refresh them, so the compiler didnt notice the change. – pokopang Apr 03 '14 at 09:55