final String poolName) throws Exception {
if (poolName == null) {
String msg = localStrings.getLocalString("jdbcConnPool.resource.noJndiName",
"No id defined for JDBC Connection pool.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// ensure we already have this resource
if (!isResourceExists(resources, poolName)) {
String msg = localStrings.getLocalString("delete.jdbc.connection.pool.notfound",
"A JDBC connection pool named {0} does not exist.", poolName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
try {
// if cascade=true delete all the resources associated with this pool
// if cascade=false don't delete this connection pool if a resource is referencing it
Object obj = deleteAssociatedResources(servers, clusters, resources,
Boolean.parseBoolean(cascade), poolName);
if (obj instanceof Integer &&
(Integer) obj == ResourceStatus.FAILURE) {
String msg = localStrings.getLocalString(
"delete.jdbc.connection.pool.pool_in_use",
"JDBC Connection pool {0} delete failed ", poolName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// delete jdbc connection pool
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
JdbcConnectionPool cp = (JdbcConnectionPool)
resources.getResourceByName(JdbcConnectionPool.class, poolName);
return param.getResources().remove(cp);
}
}, resources) == null) {
String msg = localStrings.getLocalString("delete.jdbc.connection.pool.notfound",
"A JDBC connection pool named {0} does not exist.", poolName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} catch (TransactionFailure tfe) {
String msg = tfe.getMessage() != null ? tfe.getMessage() :
localStrings.getLocalString("jdbcConnPool.resource.deletionFailed",
"JDBC Connection pool {0} delete failed ", poolName);
ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg);
status.setException(tfe);
return status;
}
String msg = localStrings.getLocalString("jdbcConnPool.resource.deleteSuccess",
"JDBC Connection pool {0} deleted successfully", poolName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}