use of org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef in project kie-wb-common by kiegroup.
the class WildflyDataSourceProvider method getDeployments.
/**
* Gets the list of data source definitions for the currently defined data sources in the Wildfly server.
* @return list with the definitions for the defined data sources.
* @throws Exception exceptions may be thrown if e.g. communication with the Wildfly server fails, etc.
*/
@Override
public List<DataSourceDef> getDeployments() throws Exception {
List<WildflyDataSourceDef> dataSources;
List<DataSourceDef> dataSourceDefs = new ArrayList<>();
DataSourceDef dataSourceDef;
String dataSourceUuid;
String driverUuid;
dataSources = dataSourceMgmtClient.getDataSources();
for (WildflyDataSourceDef internalDef : dataSources) {
dataSourceDef = new DataSourceDef();
try {
dataSourceUuid = DeploymentIdGenerator.extractUuid(internalDef.getName());
} catch (Exception e) {
dataSourceUuid = internalDef.getName();
}
try {
driverUuid = DeploymentIdGenerator.extractUuid(internalDef.getDriverName());
} catch (Exception e) {
driverUuid = internalDef.getDriverName();
}
dataSourceDef.setUuid(dataSourceUuid);
dataSourceDef.setName(internalDef.getName());
dataSourceDef.setConnectionURL(internalDef.getConnectionURL());
dataSourceDef.setDriverUuid(driverUuid);
dataSourceDef.setUser(internalDef.getUser());
dataSourceDef.setPassword(internalDef.getPassword());
dataSourceDefs.add(dataSourceDef);
}
return dataSourceDefs;
}
use of org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef in project kie-wb-common by kiegroup.
the class WildflyDataSourceProvider method buildWFDataSource.
private WildflyDataSourceDef buildWFDataSource(String deploymentId, String jndi, DataSourceDef dataSourceDef, String driverDeploymentId) {
WildflyDataSourceDef wfDataSourceDef = new WildflyDataSourceDef();
wfDataSourceDef.setName(deploymentId);
wfDataSourceDef.setDriverName(driverDeploymentId);
wfDataSourceDef.setJndi(jndi);
wfDataSourceDef.setConnectionURL(dataSourceDef.getConnectionURL());
wfDataSourceDef.setUser(dataSourceDef.getUser());
wfDataSourceDef.setPassword(dataSourceDef.getPassword());
wfDataSourceDef.setUseJTA(true);
return wfDataSourceDef;
}
use of org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef in project kie-wb-common by kiegroup.
the class WildflyDataSourceProvider method deploy.
/**
* Creates a data source in the Wildfly server.
* @param dataSourceDef Data source definition to be created.
* @param jndi jndi name to be use the Wildly server to bound the data source in the jndi context.
* @return returns the deployment information for the created data source.
* @throws Exception exceptions may be thrown if the data source couldn't be created.
*/
private DataSourceDeploymentInfo deploy(final DataSourceDef dataSourceDef, final String jndi, String deploymentId) throws Exception {
DriverDeploymentInfo driverDeploymentInfo = driverProvider.getDeploymentInfo(dataSourceDef.getDriverUuid());
if (driverDeploymentInfo == null) {
throw new Exception("Required driver: " + dataSourceDef.getDriverUuid() + " is not deployed.");
}
WildflyDataSourceDef wfDataSourceDef = buildWFDataSource(deploymentId, jndi, dataSourceDef, driverDeploymentInfo.getDriverDeploymentId());
dataSourceMgmtClient.createDataSource(wfDataSourceDef);
return new DataSourceDeploymentInfo(deploymentId, true, dataSourceDef.getUuid(), jndi, false);
}
use of org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef in project kie-wb-common by kiegroup.
the class WildflyDataSourceProvider method getDeploymentsInfo.
/**
* Gets the deployment information for all the data sources currently defined on the Wildfly server.
* @return a list with the deployment information for all the data sources.
* @throws Exception exceptions may be thrown if e.g. communication with the Wildfly server fails, etc.
*/
public List<DataSourceDeploymentInfo> getDeploymentsInfo() throws Exception {
List<WildflyDataSourceDef> dataSources = dataSourceMgmtClient.getDataSources();
List<DataSourceDeploymentInfo> result = new ArrayList<>();
DataSourceDeploymentInfo deploymentInfo;
String uuid;
WildlfyDataSource managedDataSource;
boolean managed;
String jndi;
for (WildflyDataSourceDef internalDef : dataSources) {
try {
uuid = DeploymentIdGenerator.extractUuid(internalDef.getName());
} catch (Exception e) {
uuid = internalDef.getName();
}
managedDataSource = managedDataSources.get(internalDef.getName());
if (managedDataSource != null) {
managed = true;
jndi = managedDataSource.getExternalJndi();
} else {
managed = false;
jndi = internalDef.getJndi();
}
deploymentInfo = new DataSourceDeploymentInfo(internalDef.getName(), managed, uuid, jndi, wasReferenced(internalDef.getName()));
result.add(deploymentInfo);
}
return result;
}
use of org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef in project kie-wb-common by kiegroup.
the class WildflyDataSourceProviderTest method createWFDataSources.
private List<WildflyDataSourceDef> createWFDataSources() {
// emulates the data sources deployments information returned by the WF server.
List<WildflyDataSourceDef> result = new ArrayList<>();
WildflyDataSourceDef dataSourceDef = new WildflyDataSourceDef();
dataSourceDef.setName(DS1_DEPLOYMENT_ID);
dataSourceDef.setDriverName(DRIVER1_DEPLOYMENT_ID);
dataSourceDef.setConnectionURL(DS1_CONNECTION_URL);
dataSourceDef.setPassword(DS1_PASSWORD);
dataSourceDef.setUser(DS1_USER);
dataSourceDef.setJndi(DS1_JNID);
result.add(dataSourceDef);
dataSourceDef = new WildflyDataSourceDef();
dataSourceDef.setName(DS2_DEPLOYMENT_ID);
dataSourceDef.setDriverName(DRIVER1_DEPLOYMENT_ID);
dataSourceDef.setConnectionURL(DS2_CONNECTION_URL);
dataSourceDef.setPassword(DS2_PASSWORD);
dataSourceDef.setUser(DS2_USER);
dataSourceDef.setJndi(DS2_JNID);
result.add(dataSourceDef);
return result;
}
Aggregations