/** * Converts xml element to string. * @param element parent (document) element * @return String value, or null on error. */ static public String OMToStr(OMElement element) { try { return element.toStringWithConsume(); } catch (XMLStreamException e) { return null; } }
private String convertOMElementToString(OMElement element) throws IOException { String serializedToken = ""; if (null == element) { return serializedToken; } try { serializedToken = element.toStringWithConsume(); } catch (XMLStreamException e) { throw new IOException("Could not serialize token OM element"); } return serializedToken; }
public void putMessageIntoMsgBox(String msgBoxID, String messageID, String soapAction, OMElement message) throws Exception { synchronized (map) { if (!map.containsKey(msgBoxID)) { throw new IllegalArgumentException("no message box with key " + msgBoxID + " to store the msg"); } List<Content> list = map.get(msgBoxID); list.add(new Content(message.toStringWithConsume(), System.currentTimeMillis())); logger.debug("Message Stored in list with key " + msgBoxID); } }
public void putMessageIntoMsgBox(String msgBoxID, String messageID, String soapAction, OMElement message) throws Exception { synchronized (map) { if (!map.containsKey(msgBoxID)) { throw new IllegalArgumentException("no message box with key " + msgBoxID + " to store the msg"); } List<Content> list = map.get(msgBoxID); list.add(new Content(message.toStringWithConsume(), System.currentTimeMillis())); logger.debug("Message Stored in list with key " + msgBoxID); } }
private void abbreviate(OMElement msg) { try { abbrFlag = false; prs(msg); if (abbrFlag) { String str = msg.toStringWithConsume(); FileUtils.writeStringToFile(new File("/opt/xdsi/last-trans.xml"), str); } } catch (Exception e) { logger.warn("abbreviate error: " + e.getMessage()); } } /**
/** * Method to serialize an XML element into a string. * * @param element the XML element. * @return the corresponding String representation * @throws GovernanceException if the operation failed. */ public static String serializeOMElement(OMElement element) throws GovernanceException { try { return element.toStringWithConsume(); } catch (XMLStreamException e) { String msg = "Error in serializing the OMElement."; log.error(msg, e); throw new GovernanceException(msg, e); } }
/** * @param element OMElement which would most probably contain <xs:schema> * @return a SAX inputsource from the OMElement */ public static InputSource getInputSource(OMElement element){ String elementString; byte[] bytes = new byte[0]; //Obtain the String value of the OMElement after building the OM tree try { elementString = element.toStringWithConsume(); bytes= elementString.getBytes(); } catch (XMLStreamException e) { e.printStackTrace(); } //Deserialize from a byte array InputStream inputStream = new ByteArrayInputStream(bytes); return new InputSource(inputStream); }
public static String getSoapBodyContent(String wholeMessage) throws XMLStreamException { SOAPEnvelope messageEl = reader2SOAPEnvilope(new StringReader(wholeMessage)); OMElement messageBodyContent = messageEl.getBody().getFirstElement(); return messageBodyContent.toStringWithConsume(); }
public String getImageFeed() { try { return Utils.buildImageFeed(getUserList()).toStringWithConsume(); } catch (Exception e) { log.error("Failed to serialize payload", e); return null; } }
/** * Returns the passed response message in string form, replacing text in * {@code <Document>} elements with "...". <b>Destructive</b> * @param resp passed message * @return String version of abbreviated response */ @SuppressWarnings("unchecked") private String abbreviateResponse(OMElement resp) throws XMLStreamException { Iterator<OMElement> dri = resp.getChildrenWithLocalName("DocumentResponse"); while (dri.hasNext()) { OMElement dr = dri.next(); Iterator<OMElement> di = dr.getChildrenWithLocalName("Document"); while (di.hasNext()) { OMElement d = di.next(); d.setText("..."); } // <Document> loop } // <DocumentResponse> loop return resp.toStringWithConsume(); }
public synchronized void addMessage(String msgBoxID, String messageID, String soapAction, OMElement message) throws SQLException, IOException, XMLStreamException { if (msgBoxids.contains(msgBoxID)) { Connection connection = null; try { connection = db.connect(); PreparedStatement stmt = connection.prepareStatement(SQL_STORE_MESSAGE_STATEMENT); ByteArrayOutputStream output = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(output); out.writeObject(message.toStringWithConsume()); byte[] buffer = output.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(buffer); stmt.setBinaryStream(1, in, buffer.length); stmt.setString(2, msgBoxID); stmt.setString(3, messageID); stmt.setString(4, soapAction); db.executeUpdateAndClose(stmt); db.commitAndFree(connection); } catch (SQLException sql) { db.rollbackAndFree(connection); throw sql; } } else { throw new IOException("Currently a messagebox is not available with given message box id :" + msgBoxID); } }
/** * Returns the passed response message in string form, replacing text in * {@code <Document>} elements with "...". <b>Destructive</b> * @param resp passed message * @return String version of abbreviated response */ @SuppressWarnings("unchecked") public static String abbreviateResponse(OMElement resp) throws XMLStreamException { Iterator<OMElement> dri = resp.getChildrenWithLocalName("DocumentResponse"); while (dri.hasNext()) { OMElement dr = dri.next(); Iterator<OMElement> di = dr.getChildrenWithLocalName("Document"); while (di.hasNext()) { OMElement d = di.next(); d.setText("..."); } // <Document> loop } // <DocumentResponse> loop return resp.toStringWithConsume(); }
public static String getBrokerPublishEPR(String brokerURL, String topic) { brokerURL = WorkFlowUtils.formatURLString(brokerURL); EndpointReference encodedEpr = WSEProtocolClient.createEndpointReference(brokerURL, topic); String ret = null; try { OMElement eprCrEl = EndpointReferenceHelper.toOM(OMAbstractFactory.getOMFactory(), encodedEpr, new QName( "EndpointReference"), NameSpaceConstants.WSA_NS.getNamespaceURI()); ret = eprCrEl.toStringWithConsume(); } catch (Exception e) { logger.error("unable to convert broker url", e); } return ret; /* * String epr = null; brokerURL = WorkFlowUtils.formatURLString(brokerURL); if (brokerURL.endsWith("/")) { epr = * brokerURL + STRING_TOPIC + topic; } else { epr = brokerURL + "/" + STRING_TOPIC + topic; } * * epr = "<wsa:EndpointReference " + "xmlns:wsa='http://www.w3.org/2005/08/addressing'>" + "<wsa:Address>" + epr * + "</wsa:Address>" + "</wsa:EndpointReference>"; return epr; */ } }
@Override protected InvocationResponse doProcessing(final MessageContext mc) throws Exception { // We use a specific log for the SOAP headers so it can easily be enabled or disabled final Log soapEnvLog = LogFactory.getLog("org.holodeckb2b.msgproc.soapenvlog." + (isInFlow(IN_FLOW) || isInFlow(IN_FAULT_FLOW) ? "IN" : "OUT")); // Only do something when logging is enabled if (soapEnvLog.isInfoEnabled()) { try { soapEnvLog.info(mc.getEnvelope().cloneOMElement().toStringWithConsume() + "\n"); } catch (Exception invalidSOAP) { if (isInFlow((byte) (IN_FLOW | IN_FAULT_FLOW))) { log.warn("Received a message with invalid SOAP envelope! Details: " + Utils.getExceptionTrace(invalidSOAP)); soapEnvLog.error("Received message cannot be logged because its SOAP envelope is not valid!"); } else { log.error("Created message does not contain a valid SOAP envelope! Details: " + Utils.getExceptionTrace(invalidSOAP)); } } } return InvocationResponse.CONTINUE; }
private EntitlementPolicy preProcess(EntitlementPolicy policy){ String policyContent = policy.getPolicyContent(); try { OMElement contentElement = AXIOMUtil.stringToOM(policyContent); // Replace PolicyId attribute with the generated Id. contentElement.addAttribute("PolicyId", policy.getPolicyId(), null); policy.setPolicyContent(contentElement.toStringWithConsume()); return policy; } catch (XMLStreamException e) { log.error("Cannot process XACML policy content."); return null; } }
private String getTopic(MessageContext context) { SOAPHeader header = context.getEnvelope().getHeader(); OMElement contextHeader = header.getFirstChildWithName(new QName( "http://schemas.airavata.apache.org/workflow-execution-context", "context-header")); String topic = null; try { ContextHeaderDocument document = ContextHeaderDocument.Factory.parse(contextHeader.toStringWithConsume()); topic = document.getContextHeader().getWorkflowMonitoringContext().getWorkflowInstanceId(); } catch (XmlException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } catch (XMLStreamException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } topic = topic.substring(1); return topic.replaceAll("_", "-"); }
private String getEventBrokerURL(MessageContext context) { SOAPHeader header = context.getEnvelope().getHeader(); OMElement contextHeader = header.getFirstChildWithName(new QName( "http://airavata.apache.org/schemas/wec/2012/05", "context-header")); String address = null; try { ContextHeaderDocument document = ContextHeaderDocument.Factory.parse(contextHeader.toStringWithConsume()); address = document.getContextHeader().getWorkflowMonitoringContext().getEventPublishEpr(); } catch (XmlException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } catch (XMLStreamException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } return address; }
private String getEventBrokerURL(MessageContext context) { SOAPHeader header = context.getEnvelope().getHeader(); OMElement contextHeader = header.getFirstChildWithName(new QName( "http://schemas.airavata.apache.org/workflow-execution-context", "context-header")); String address = null; try { ContextHeaderDocument document = ContextHeaderDocument.Factory.parse(contextHeader.toStringWithConsume()); address = document.getContextHeader().getWorkflowMonitoringContext().getEventPublishEpr(); } catch (XmlException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } catch (XMLStreamException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } return address; }
private String getTopic(MessageContext context) { OMElement contextHeader = getHeader(context); String topic = null; try { ContextHeaderDocument document = ContextHeaderDocument.Factory.parse(contextHeader.toStringWithConsume()); topic = document.getContextHeader().getWorkflowMonitoringContext().getExperimentId(); } catch (XmlException e) { e.printStackTrace(); } catch (XMLStreamException e) { e.printStackTrace(); } return topic; }
public RetrievedDocumentsModel retrieve( RetrieveImageRequestModel rModel) throws Exception { if (!direct) endpoint = site.getEndpoint(type, isTls(), false); OMElement retrieveRequest = buildRetrieve(rModel); Soap soap = new Soap(); for (OMElement ele : extraSoapHeaderElements) { soap.addHeader(ele); } OMElement result = soap.soapCall(retrieveRequest, endpoint, true, // mtom true, // addressing true, // SOAP1.2 type.getRequestAction(), type.getResponseAction()); logger.info(result.toStringWithConsume()); if (messageDir != null) { writeToFile(soap.getOutHeader().toString(), messageDir, "RequestHeader.xml"); writeToFile(soap.getInHeader().toString(), messageDir, "ResponseHeader.xml"); writeToFile(retrieveRequest.toString(), messageDir, "RequestBody.xml"); } return parseResponse(result); } // EO retrieve method