/** * FIXME: This method is NOT namespace aware. Incoming element has NO namespace information * * @param participantTypes */ private void handleParticipantTypesElement(Element participantTypes) { ArrayList<String> typeRecorder = new ArrayList<String>(); ArrayList<Element> uselessChildren = new ArrayList<Element>(); NodeList childrenList = participantTypes.getChildNodes(); for (int i = 0; i < childrenList.getLength(); i++) { Node child = childrenList.item(i); if (child instanceof Element && child.getNodeName().equals("participantType")) { Element childElement = (Element) child; String pbd = childElement.getAttribute("participantBehaviorDescription"); if (pbd == "") { uselessChildren.add(childElement); } else { // record type only if BPD is existed String type = childElement.getAttribute("name"); typeRecorder.add(type); String namespace = childElement.getAttribute("processNamespace"); String prefix = childElement.lookupPrefix(namespace); if (prefix == null) { // prefix = "ns" + pbd; prefix = pbd; } childElement.setAttribute("participantBehaviorDescription", prefix + ":" + pbd); childElement.setAttribute("xmlns:" + prefix, namespace); } } } Element movingChild; Iterator<Element> movingList = uselessChildren.iterator(); while (movingList.hasNext()) { movingChild = movingList.next(); participantTypes.removeChild(movingChild); } }
public void executor(TicketEntity ticketEntity, SOAPMessage respn) throws Exception { if (respn == null) respn = utility.getSOAPMessageFromStream( new ByteArrayInputStream(ticketEntity.getDataEntity().getMesData())); Document docSource = respn.getSOAPPart().getEnvelope().getOwnerDocument(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); WriterXML wx = new WriterXML(byteArrayOutputStream); try { wx.startDocument(); wx.openTag("AppData"); wx.openTag("ImportDataResponse").attr("ref", ticketEntity.getMessagesEntity().getBisRefNm()); Element elMsg = (Element) XPathAPI.selectSingleNode( docSource.getDocumentElement(), "//*[local-name()='UnifoTransferMsg' and namespace-uri()='" + Const.SCHEMA_SmevUnifoService + "']"); if (elMsg != null) { String pref_tick = elMsg.lookupPrefix(Const.SCHEMA_TICKET); Element elTicket = (Element) XPathAPI.selectSingleNode(elMsg, ".//" + pref_tick + ":Ticket"); wx.openTag("Ticket"); Element elPost = (Element) XPathAPI.selectSingleNode(elTicket, "./PostBlock"); if (elPost != null) { wx.openTag("PostBlock"); try { wx.tagValue("ID", ticketEntity.getMessagesEntity().getPostBlockId()); wx.tagValue( "TimeStamp", XPathAPI.selectSingleNode(elPost, "./TimeStamp").getTextContent()); wx.tagValue( "SenderIdentifier", XPathAPI.selectSingleNode(elPost, "./SenderIdentifier").getTextContent()); } finally { wx.closeTag(); } } Element elResult = (Element) XPathAPI.selectSingleNode(elTicket, "./RequestProcessResult"); if (elResult != null) { wx.openTag("RequestProcessResult"); try { wx.tagValue("ErrorCode", ticketEntity.getErrorKd()); wx.tagValue("ErrorDescription", ticketEntity.getErrorMsg()); wx.tagValue("ErrorData", ""); } finally { wx.closeTag(); } } } else { String pref_tick = docSource.getDocumentElement().lookupPrefix(Const.SCHEMA_SOAP); Element elResult = (Element) XPathAPI.selectSingleNode( docSource.getDocumentElement(), "//" + pref_tick + ":Fault"); if (elResult != null) { try { wx.openTag("RequestProcessResult"); wx.tagValue( "ErrorCode", XPathAPI.selectSingleNode(elResult, "./faultcode").getNodeValue()); wx.tagValue( "ErrorDescription", XPathAPI.selectSingleNode(elResult, "./faultstring").getNodeValue()); wx.tagValue("ErrorData", ""); } finally { wx.closeTag(); } } } } finally { wx.closeTags(); } wx.close(); FileObject rootFile = MyVFS.getManager().resolveFile(exportPath); FileObject destFile = rootFile.resolveFile( ticketEntity.getMessagesEntity().getDataSourceEntity().getFileNm() + ".ticket." + ticketEntity.getTicketId()); destFile.createFile(); OutputStream out = destFile.getContent().getOutputStream(); try { out.write(byteArrayOutputStream.toByteArray()); } finally { out.close(); } }
@Override protected String prefixForNamespace(final URI namespace) { return element.lookupPrefix(namespace.toString()); }