/** * @param xml * @return * @throws XMLStreamException */ public static OMElement stringToOM(String xml) throws XMLParserException { try { return AXIOMUtil.stringToOM(xml); } catch (XMLStreamException ex) { throw new XMLParserException(ex.getMessage()); } }
/** * Deploy the sequence to the gateway * * @param sequence * @param tenantDomain * @throws AxisFault */ public void addSequenceForTenant(String sequence, String tenantDomain) throws AxisFault { SequenceAdminServiceClient client = new SequenceAdminServiceClient(); if (sequence != null && !sequence.isEmpty()) { OMElement element = null; try { element = AXIOMUtil.stringToOM(sequence); client.addSequenceForTenant(element, tenantDomain); } catch (XMLStreamException e) { log.error("Exception occurred while converting String to an OM.", e); } } }
public static SOAPEnvelope str2Envelope(String xmlString) { try { // TODO: verify the SOAP version in the string SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); OMElement documentElement = AXIOMUtil.stringToOM(xmlString); StAXSOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder( soapFactory, documentElement.getXMLStreamReader()); return builder.getSOAPEnvelope(); } catch (XMLStreamException e) { return null; } }
/** * Deploy the sequence to the gateway for super tenant users. * * @param sequence - The sequence element , which to be deployed in synapse. * @throws AppManagementException on errors. */ public void addSequence(String sequence) throws AppManagementException { if (!StringUtils.isEmpty(sequence)) { OMElement element = null; try { element = AXIOMUtil.stringToOM(sequence); ServiceReferenceHolder.getInstance().getSequenceAdminService().addSequence(element); } catch (SequenceEditorException e) { String errorMsg = "Error while adding the sequence : " + sequence + " for super tenant."; throw new AppManagementException(errorMsg, e); } catch (XMLStreamException e) { String errorMsg = "Error while streaming the sequence : " + sequence + " for super tenant."; throw new AppManagementException(errorMsg, e); } } }