List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(String msg, Location location)
From source file:org.wso2.carbon.dataservices.core.engine.DSOMDataSource.java
public void execute(XMLStreamWriter xmlWriter) throws XMLStreamException { try {//ww w . j a v a 2s. co m this.getDataService().invoke(xmlWriter, this.getOpName(), this.getParams()); /* flush the stream, if there's a result */ if (xmlWriter != null) { xmlWriter.flush(); } } catch (DataServiceFault e) { throw new XMLStreamException(e.getMessage(), e); } }
From source file:org.wso2.carbon.dss.datasource.test.DataSourceInitializationAtStartUpTestCase.java
private DataHandler createArtifactWithDataSource(String serviceFileName) throws XMLStreamException, IOException { Assert.assertNotNull("Carbon data source name null. create carbon data source first", carbonDataSourceName); try {/*from w w w . j av a 2 s .co m*/ OMElement dbsFile = AXIOMUtil .stringToOM( FileManager .readFile(ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION + "artifacts" + File.separator + "DSS" + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "MySql" + File.separator + serviceFileName) .trim()); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("carbon_datasource_name".equals(value)) { property.setText(carbonDataSourceName); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.carbon.dss.faulty.service.test.EditFaultyDataServiceTest.java
@Test(groups = "wso2.dss", dependsOnMethods = { "isServiceFaulty" }, description = "Fix the fault and redeploy") public void editFaultyService() throws Exception { DataServiceAdminClient dataServiceAdminService = new DataServiceAdminClient(dssServer.getBackEndUrl(), dssServer.getSessionCookie()); String serviceContent;/*from w w w .ja va2s .c o m*/ String newServiceContent; SqlDataSourceUtil dssUtil = new SqlDataSourceUtil(dssServer.getSessionCookie(), dssServer.getBackEndUrl(), FrameworkFactory.getFrameworkProperties("DSS"), Integer.parseInt(userInfo.getUserId())); dssUtil.createDataSource(getSqlScript()); serviceContent = dataServiceAdminService.getDataServiceContent(serviceName); try { OMElement dbsFile = AXIOMUtil.stringToOM(serviceContent); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("org.wso2.ws.dataservice.protocol".equals(value)) { property.setText(dssUtil.getJdbcUrl()); } else if ("org.wso2.ws.dataservice.driver".equals(value)) { property.setText(dssUtil.getDriver()); } else if ("org.wso2.ws.dataservice.user".equals(value)) { property.setText(dssUtil.getDatabaseUser()); } else if ("org.wso2.ws.dataservice.password".equals(value)) { property.setText(dssUtil.getDatabasePassword()); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } newServiceContent = dbsFile.toString(); } catch (XMLStreamException e) { log.error("XMLStreamException while handling data service content ", e); throw new XMLStreamException("XMLStreamException while handling data service content ", e); } Assert.assertNotNull("Could not edited service content", newServiceContent); dataServiceAdminService.editDataService(serviceName, "", newServiceContent); log.info(serviceName + " edited"); }
From source file:org.wso2.carbon.dss.faulty.service.test.ServiceFaultyTest.java
@Test(groups = "wso2.dss", dependsOnMethods = { "serviceInvocation" }, description = "make the service invalie") public void faultyService() throws RemoteException, XMLStreamException { String serviceContent;/*from ww w . ja v a 2 s . c o m*/ String newServiceContent; Assert.assertTrue(isServiceDeployed(serviceName), "Service not in faulty service list"); serviceContent = dataServiceAdminClient.getDataServiceContent(serviceName); try { OMElement dbsFile = AXIOMUtil.stringToOM(serviceContent); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("org.wso2.ws.dataservice.user".equals(value)) { property.setText("invalidUser"); } else if ("org.wso2.ws.dataservice.password".equals(value)) { property.setText("password"); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } newServiceContent = dbsFile.toString(); } catch (XMLStreamException e) { log.error("XMLStreamException while handling data service content ", e); throw new XMLStreamException("XMLStreamException while handling data service content ", e); } Assert.assertNotNull("Could not edited service content", newServiceContent); dataServiceAdminClient.editDataService(serviceName, "", newServiceContent); log.info(serviceName + " edited"); }
From source file:org.wso2.carbon.dss.services.test.DataServiceSqlDriverTestCase.java
public DataHandler modifyExcelURL(String dbsFilePath) throws XMLStreamException, IOException { try {// w ww .j a v a2 s. c o m OMElement dbsFile = AXIOMUtil.stringToOM(FileManager.readFile(dbsFilePath)); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); String productFilePath = resourceFileLocation + File.separator + "resources" + File.separator + "Products-sql.xls"; while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("url".equals(value)) { property.setText("jdbc:wso2:excel:filePath=" + productFilePath); } } log.debug(dbsFile); ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.carbon.dss.services.test.DistributedTransactionTestCase.java
private DataHandler getArtifactWithDTP(String serviceFile) throws Exception { SqlDataSourceUtil dataSource1;/*from w w w .j a v a2s . c om*/ SqlDataSourceUtil dataSource2; String dtpDriver; dataSource1 = new SqlDataSourceUtil(dssServer.getSessionCookie(), dssServer.getBackEndUrl(), FrameworkFactory.getFrameworkProperties(ProductConstant.DSS_SERVER_NAME), userId); dataSource2 = new SqlDataSourceUtil(dssServer.getSessionCookie(), dssServer.getBackEndUrl(), FrameworkFactory.getFrameworkProperties(ProductConstant.DSS_SERVER_NAME), userId); dataSource1.createDataSource(getSqlScript()); dataSource2.createDataSource(databaseNameNew, databaseUserNew, databasePasswordNew, getSqlScript()); //this should be set according to tha database server if (dataSource1.getDriver().contains("h2")) { dtpDriver = "org.h2.jdbcx.JdbcDataSource"; } else if (dataSource1.getDriver().contains("mysql")) { dtpDriver = "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"; } else { dtpDriver = "Not.Defined"; } try { OMElement dbsFile = AXIOMUtil .stringToOM( FileManager .readFile(ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION + "artifacts" + File.separator + "DSS" + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "MySql" + File.separator + serviceFile) .trim()); OMElement dbsConfig; Iterator config = dbsFile.getChildrenWithName(new QName("config")); while (config.hasNext()) { String jdbc; String user; String passwd; dbsConfig = (OMElement) config.next(); if (dbsConfig.getAttributeValue(new QName("id")).equals("MySqlDataSource1")) { jdbc = dataSource1.getJdbcUrl(); user = dataSource1.getDatabaseUser(); passwd = dataSource1.getDatabasePassword(); } else { jdbc = dataSource2.getJdbcUrl(); user = dataSource2.getDatabaseUser(); passwd = dataSource2.getDatabasePassword(); } Iterator configElement = dbsConfig.getChildElements(); while (configElement.hasNext()) { OMElement properties = (OMElement) configElement.next(); String datasource = properties.getAttributeValue(new QName("name")); if (datasource.equals("org.wso2.ws.dataservice.xa_datasource_properties")) { Iterator dbPropertyElement = properties.getChildElements(); while (dbPropertyElement.hasNext()) { OMElement property = (OMElement) dbPropertyElement.next(); String value = property.getAttributeValue(new QName("name")); if ("URL".equals(value)) { property.setText(jdbc); } else if ("user".equals(value)) { property.setText(user); } else if ("password".equals(value)) { property.setText(passwd); } } } else if (datasource.equals("org.wso2.ws.dataservice.xa_datasource_class")) { properties.setText(dtpDriver); } } } log.debug(dbsFile); ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.carbon.esb.https.inbound.transport.test.HttpsInboundTransportTestCase.java
private OMElement getArtifactConfig(String fileName) throws Exception { OMElement synapseConfig = null;/*from w ww. j av a 2 s.c om*/ String path = "artifacts" + File.separator + "ESB" + File.separator + "https.inbound.transport" + File.separator + fileName; try { synapseConfig = esbUtils.loadResource(path); } catch (FileNotFoundException e) { throw new Exception("File Location " + path + " may be incorrect", e); } catch (XMLStreamException e) { throw new XMLStreamException("XML Stream Exception while reading file stream", e); } return synapseConfig; }
From source file:org.wso2.dss.integration.test.datasource.DataSourceInitializationAtStartUpTestCase.java
private DataHandler createArtifactWithDataSource(String serviceFileName) throws XMLStreamException, IOException, XPathExpressionException { Assert.assertNotNull("Carbon data source name null. create carbon data source first", carbonDataSourceName); try {// w w w.j a v a 2 s . co m OMElement dbsFile = AXIOMUtil .stringToOM( FileManager .readFile(getResourceLocation() + File.separator + "dbs" + File.separator + "rdbms" + File.separator + "MySql" + File.separator + serviceFileName) .trim()); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("carbon_datasource_name".equals(value)) { property.setText(carbonDataSourceName); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } ByteArrayDataSource dbs = new ByteArrayDataSource(dbsFile.toString().getBytes()); return new DataHandler(dbs); } catch (XMLStreamException e) { log.error("XMLStreamException when Reading Service File", e); throw new XMLStreamException("XMLStreamException when Reading Service File", e); } catch (IOException e) { log.error("IOException when Reading Service File", e); throw new IOException("IOException when Reading Service File", e); } }
From source file:org.wso2.dss.integration.test.faulty.service.EditFaultyDataServiceTest.java
@Test(groups = "wso2.dss", dependsOnMethods = { "isServiceFaulty" }, description = "Fix the fault and redeploy") public void editFaultyService() throws Exception { DataServiceAdminClient dataServiceAdminService = new DataServiceAdminClient( dssContext.getContextUrls().getBackEndUrl(), sessionCookie); String serviceContent;//from w w w. j av a2 s. c o m String newServiceContent; SqlDataSourceUtil dssUtil = new SqlDataSourceUtil(sessionCookie, dssContext.getContextUrls().getBackEndUrl()); dssUtil.createDataSource(getSqlScript()); serviceContent = dataServiceAdminService.getDataServiceContent(serviceName); try { OMElement dbsFile = AXIOMUtil.stringToOM(serviceContent); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("org.wso2.ws.dataservice.protocol".equals(value)) { property.setText(dssUtil.getJdbcUrl()); } else if ("org.wso2.ws.dataservice.driver".equals(value)) { property.setText(dssUtil.getDriver()); } else if ("org.wso2.ws.dataservice.user".equals(value)) { property.setText(dssUtil.getDatabaseUser()); } else if ("org.wso2.ws.dataservice.password".equals(value)) { property.setText(dssUtil.getDatabasePassword()); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } newServiceContent = dbsFile.toString(); } catch (XMLStreamException e) { log.error("XMLStreamException while handling data service content ", e); throw new XMLStreamException("XMLStreamException while handling data service content ", e); } Assert.assertNotNull("Could not edited service content", newServiceContent); dataServiceAdminService.editDataService(serviceName, "", newServiceContent); log.info(serviceName + " edited"); }
From source file:org.wso2.dss.integration.test.faulty.service.ServiceFaultyTestCase.java
@Test(groups = "wso2.dss", dependsOnMethods = { "serviceInvocation" }, description = "make the service invalie") public void faultyService() throws Exception { String serviceContent;// w w w . j a v a 2 s .c o m String newServiceContent; Assert.assertTrue(isServiceDeployed(serviceName), "Service not in faulty service list"); serviceContent = dataServiceAdminClient.getDataServiceContent(serviceName); try { OMElement dbsFile = AXIOMUtil.stringToOM(serviceContent); OMElement dbsConfig = dbsFile.getFirstChildWithName(new QName("config")); Iterator configElement1 = dbsConfig.getChildElements(); while (configElement1.hasNext()) { OMElement property = (OMElement) configElement1.next(); String value = property.getAttributeValue(new QName("name")); if ("org.wso2.ws.dataservice.user".equals(value)) { property.setText("invalidUser"); } else if ("org.wso2.ws.dataservice.password".equals(value)) { property.setText("password"); } } if (log.isDebugEnabled()) { log.debug(dbsFile); } newServiceContent = dbsFile.toString(); } catch (XMLStreamException e) { log.error("XMLStreamException while handling data service content ", e); throw new XMLStreamException("XMLStreamException while handling data service content ", e); } Assert.assertNotNull("Could not edited service content", newServiceContent); dataServiceAdminClient.editDataService(serviceName, "", newServiceContent); log.info(serviceName + " edited"); }