* @param m notification message contents to pack
* @return packed notification messages
*/
private Document packWorkMessage(Message m) {
Work work = (Work) m.getMessageData();
// Create instance of DocumentBuilderFactory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// Get the DocumentBuilder
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException ex) {
Logger.getLogger(XmlPacker.class.getName()).log(Level.SEVERE, null, ex);
}
Document doc = db.newDocument(); // Create a blank Document
MessageType messageType = m.getMessageType();
String rootName = messageType.getRootXmlTag();//get's the root tag
Element root = doc.createElement(rootName);
doc.appendChild(root); // Root element is child of the Document
packNewElement(doc, root, "sourceAddress", work.getSourceAddress());
packNewElement(doc, root, "notificationId", work.getNotificationId());
packNewElement(doc, root, "reassignAddress", work.getReassignAddress());
return doc;
}