use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class DeleteResourceAdapterConfig method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
if (raName == null) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.noRARName", "No RAR name defined for resource adapter config."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// ensure we already have this resource
if (ConnectorsUtil.getResourceByName(domain.getResources(), ResourceAdapterConfig.class, raName) == null) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.notfound", "Resource-Adapter-Config for {0} does not exist.", raName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
// delete resource-adapter-config
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
ResourceAdapterConfig resource = (ResourceAdapterConfig) ConnectorsUtil.getResourceByName(domain.getResources(), ResourceAdapterConfig.class, raName);
if (resource != null && resource.getResourceAdapterName().equals(raName)) {
return param.getResources().remove(resource);
}
// not found
return null;
}
}, domain.getResources()) == null) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.fail", "Unable to delete resource adapter config {0}", raName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
} catch (TransactionFailure tfe) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.fail", "Unable to delete resource adapter config {0}", raName) + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
// report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.success",
// "Resource adapter config {0} deleted", raName));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations