Java Code Examples for org.apache.axiom.om.impl.builder.StAXOMBuilder#getDocumentElement()
The following examples show how to use
org.apache.axiom.om.impl.builder.StAXOMBuilder#getDocumentElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java From openxds with Apache License 2.0 | 6 votes |
public static OMElement parse_xml(InputStream is) throws FactoryConfigurationError, XdsInternalException { // create the parser XMLStreamReader parser=null; try { parser = XMLInputFactory.newInstance().createXMLStreamReader(is); } catch (XMLStreamException e) { throw new XdsInternalException("Could not create XMLStreamReader from InputStream"); } // create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); // get the root element (in this case the envelope) OMElement documentElement = builder.getDocumentElement(); if (documentElement == null) throw new XdsInternalException("No document element"); return documentElement; }
Example 2
Source File: DBUtils.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Get roles using the AuthorizationProvider using the config given. * * @param authProviderConfig xml config. * @return role array * @throws DataServiceFault */ public static String[] getAllRolesUsingAuthorizationProvider(String authProviderConfig) throws DataServiceFault { try { AuthorizationProvider authorizationProvider; if (authProviderConfig != null && !authProviderConfig.isEmpty()) { StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(authProviderConfig.getBytes(StandardCharsets.UTF_8))); OMElement documentElement = builder.getDocumentElement(); authorizationProvider = generateAuthProviderFromXMLOMElement(documentElement); } else { authorizationProvider = new UserStoreAuthorizationProvider(); } return authorizationProvider.getAllRoles(); } catch (XMLStreamException e) { throw new DataServiceFault(e, "Error reading XML file data - " + authProviderConfig + " Error - " + e.getMessage()); } }
Example 3
Source File: XdsTest.java From openxds with Apache License 2.0 | 6 votes |
OMElement parse_xml_string(String input_string) { byte[] ba = input_string.getBytes(); // create the parser XMLStreamReader parser=null; try { parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(ba)); } catch (XMLStreamException e) { assertTrue("Could not create XMLStreamReader from " + "input stream", false); } // create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); // get the root element (in this case the envelope) OMElement documentElement = builder.getDocumentElement(); return documentElement; }
Example 4
Source File: PolicyUtil.java From micro-integrator with Apache License 2.0 | 6 votes |
public static OMElement getPolicyAsOMElement(Policy policy) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos); policy.serialize(writer); writer.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(bais); StAXOMBuilder staxOMBuilder = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder( OMAbstractFactory.getOMFactory(), xmlStreamReader); return staxOMBuilder.getDocumentElement(); } catch (Exception ex) { throw new RuntimeException("can't convert the policy to an OMElement", ex); } }
Example 5
Source File: LocalEntryUtil.java From micro-integrator with Apache License 2.0 | 5 votes |
public static OMElement nonCoalescingStringToOm(String xmlStr) throws XMLStreamException { StringReader strReader = new StringReader(xmlStr); XMLInputFactory xmlInFac = XMLInputFactory.newInstance(); // Non-Coalescing parsing xmlInFac.setProperty("javax.xml.stream.isCoalescing", false); XMLStreamReader parser = xmlInFac.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(parser); return builder.getDocumentElement(); }
Example 6
Source File: MessageStoreAdminClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public void addMessageStore(DataHandler dh) throws IOException, XMLStreamException, org.wso2.carbon.message.store.stub.Exception { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement messageStore = builder.getDocumentElement(); messageStoreAdminServiceStub.addMessageStore(messageStore.toString()); }
Example 7
Source File: ProxyServiceAdminClient.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Adding proxy service * * @param dh Data Handler * @throws ProxyServiceAdminProxyAdminException Proxy service admin exception * @throws java.rmi.RemoteException Remote exception * @throws javax.xml.stream.XMLStreamException Exception */ public void addProxyService(DataHandler dh) throws ProxyServiceAdminProxyAdminException, IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); //get the root element (in this case the envelope) OMElement documentElement = builder.getDocumentElement(); ProxyData proxyData = getProxyData(documentElement.toString()); log.info("Proxy Added"); }
Example 8
Source File: SequenceAdminServiceClient.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * adding sequence * * @param dh * @throws SequenceEditorException * @throws java.io.IOException * @throws javax.xml.stream.XMLStreamException */ public void addSequence(DataHandler dh) throws SequenceEditorException, IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement sequenceElem = builder.getDocumentElement(); sequenceAdminServiceStub.addSequence(sequenceElem); }
Example 9
Source File: DBDeployer.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * This method checks if the given data service has a corresponding "services.xml" is available, * if so, the AxisService representing the data service is applied the instructions from its * "services.xml". */ private AxisService handleTransports(DeploymentFileData file, AxisService axisService) throws DataServiceFault { try (FileInputStream fis = new FileInputStream(file.getFile().getAbsoluteFile())) { StAXOMBuilder builder = new StAXOMBuilder(fis); OMElement documentElement = builder.getDocumentElement(); OMAttribute transports = documentElement.getAttribute(new QName(DBSFields.TRANSPORTS)); if (transports != null) { String [] transportArr = transports.getAttributeValue().split(" "); axisService.setExposedTransports(Arrays.asList(transportArr)); } } catch (Exception e) { throw new DataServiceFault(e, "Error in processing transports info"); } return axisService; }
Example 10
Source File: AdminServiceLocalEntryAdminService.java From micro-integrator with Apache License 2.0 | 5 votes |
public void addLocalEntry(String sessionCookie, DataHandler dh) throws LocalEntryAdminException, IOException, XMLStreamException { AuthenticateStub.authenticateStub(sessionCookie, localEntryAdminServiceStub); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement localEntryElem = builder.getDocumentElement(); localEntryAdminServiceStub.addEntry(localEntryElem.toString()); }
Example 11
Source File: MassageStoreAdminClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public void addMessageStore(DataHandler dh) throws IOException, LocalEntryAdminException, XMLStreamException, Exception { messageStoreAdminServiceStub = this.setMessageStoreStubStub(); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement localEntryElem = builder.getDocumentElement(); messageStoreAdminServiceStub.addMessageStore(localEntryElem.toString()); }
Example 12
Source File: SequenceTemplateAdminServiceClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public void addSequenceTemplate(DataHandler dh) throws IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement template = builder.getDocumentElement(); templateAdminStub.addTemplate(template); }
Example 13
Source File: SequenceTemplateAdminServiceClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public void addDynamicSequenceTemplate(String key, DataHandler dh) throws IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement template = builder.getDocumentElement(); templateAdminStub.addDynamicTemplate(key, template); }
Example 14
Source File: MediationPersistenceTest.java From micro-integrator with Apache License 2.0 | 5 votes |
protected OMElement parse(InputStream in) { try { StAXOMBuilder builder = new StAXOMBuilder(in); return builder.getDocumentElement(); } catch (XMLStreamException e) { fail("Error while parsing the XML from the input stream"); return null; } }
Example 15
Source File: SequenceAdminServiceClient.java From product-ei with Apache License 2.0 | 5 votes |
/** * adding sequence * * @param dh * @throws SequenceEditorException * @throws java.io.IOException * @throws javax.xml.stream.XMLStreamException */ public void addSequence(DataHandler dh) throws SequenceEditorException, IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement sequenceElem = builder.getDocumentElement(); sequenceAdminServiceStub.addSequence(sequenceElem); }
Example 16
Source File: DatabaseBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
private OMElement getRealmElement(InputStream inputStream) throws XMLStreamException, org.wso2.carbon.user.core.UserStoreException { try { inputStream = CarbonUtils.replaceSystemVariablesInXml(inputStream); StAXOMBuilder builder = new StAXOMBuilder(inputStream); OMElement documentElement = builder.getDocumentElement(); setSecretResolver(documentElement); return documentElement; } catch (CarbonException e) { throw new org.wso2.carbon.user.core.UserStoreException(e.getMessage(), e); } }
Example 17
Source File: ManagementApiParser.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Returns the document OMElement from the internal-apis.xml file. * * @param fileInputStream input stream of internal-apis.xml * @return OMelement of internal-apis.xml */ private static OMElement getOMElementFromFile(InputStream fileInputStream) throws CarbonException, XMLStreamException { InputStream inputStream = MicroIntegratorBaseUtils.replaceSystemVariablesInXml(fileInputStream); StAXOMBuilder builder = new StAXOMBuilder(inputStream); return builder.getDocumentElement(); }
Example 18
Source File: SequenceTemplateAdminServiceClient.java From product-ei with Apache License 2.0 | 5 votes |
public void addSequenceTemplate(DataHandler dh) throws IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement template = builder.getDocumentElement(); templateAdminStub.addTemplate(template); }
Example 19
Source File: DBReportMediatorTestCase.java From product-ei with Apache License 2.0 | 5 votes |
private OMElement updateSynapseConfiguration(File synapseFile) throws IOException, XMLStreamException { OMElement synapseContent; BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(synapseFile)); XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(bufferedInputStream); StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(xmlStreamReader); synapseContent = stAXOMBuilder.getDocumentElement(); synapseContent.build(); bufferedInputStream.close(); OMElement targetElement = synapseContent.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "target")); OMElement outSequenceElement = targetElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "outSequence")); OMElement dbReportElement = outSequenceElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "dbreport")); OMElement connectionElement = dbReportElement.getFirstChildWithName( new QName("http://ws.apache.org/ns/synapse", "connection")); OMElement poolElement = connectionElement.getFirstElement(); OMElement driverElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "driver")); OMElement urlElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "url")); OMElement userElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "user")); OMElement passwordElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "password")); driverElemnt.setText(JDBC_DRIVER); urlElemnt.setText(JDBC_URL); userElemnt.setText(DB_USER); passwordElemnt.setText(DB_PASSWORD); return synapseContent; }
Example 20
Source File: LocalEntriesAdminClient.java From product-ei with Apache License 2.0 | 3 votes |
/** * Add Local entry by DataHandler * * @param dh * @return * @throws java.io.IOException * @throws LocalEntryAdminException * @throws javax.xml.stream.XMLStreamException */ public boolean addLocalEntery(DataHandler dh) throws IOException, LocalEntryAdminException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement localEntryElem = builder.getDocumentElement(); return (localEntryAdminServiceStub.addEntry(localEntryElem.toString())); }