use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class CreateManagedExecutorService 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();
HashMap attrList = new HashMap();
setAttributeList(attrList);
ResourceStatus rs;
try {
rs = managedExecutorServiceMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.managed.executor.service.failed", "Managed executor service {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class CreateManagedScheduledExecutorService 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();
HashMap attrList = new HashMap();
setAttributeList(attrList);
ResourceStatus rs;
try {
rs = managedScheduledExecutorServiceMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.managed.scheduled.executor.service.failed", "Managed scheduled executor service {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ContextServiceManager method delete.
public ResourceStatus delete(final Resources resources, final String jndiName, final String target) throws Exception {
if (jndiName == null) {
String msg = localStrings.getLocalString("context.service.noJndiName", "No JNDI name defined for context service.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
Resource resource = ConnectorsUtil.getResourceByName(resources, ContextService.class, jndiName);
// ensure we already have this resource
if (resource == null) {
String msg = localStrings.getLocalString("delete.context.service.notfound", "A context service named {0} does not exist.", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (SYSTEM_ALL_REQ.equals(resource.getObjectType())) {
String msg = localStrings.getLocalString("delete.concurrent.resource.notAllowed", "The {0} resource cannot be deleted as it is required to be configured in the system.", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (environment.isDas()) {
if ("domain".equals(target)) {
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 0) {
String msg = localStrings.getLocalString("delete.context.service.resource-ref.exist", "This context service [ {0} ] is referenced in an instance/cluster target, use delete-resource-ref on appropriate target", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
if (!resourceUtil.isResourceRefInTarget(jndiName, target)) {
String msg = localStrings.getLocalString("delete.context.service.no.resource-ref", "This context service [ {0} ] is not referenced in target [ {1} ]", jndiName, target);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 1) {
String msg = localStrings.getLocalString("delete.context.service.multiple.resource-refs", "This context service [ {0} ] is referenced in multiple instance/cluster targets, Use delete-resource-ref on appropriate target", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
try {
// delete resource-ref
resourceUtil.deleteResourceRef(jndiName, target);
// delete context-service
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
ContextService resource = (ContextService) ConnectorsUtil.getResourceByName(resources, ContextService.class, jndiName);
return param.getResources().remove(resource);
}
}, resources) == null) {
String msg = localStrings.getLocalString("delete.context.service.failed", "Context service {0} deletion failed", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("delete.context.service.failed", "Context service {0} deletion failed ", jndiName);
ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg);
status.setException(tfe);
return status;
}
String msg = localStrings.getLocalString("delete.context.service.success", "Context service {0} deleted successfully", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ContextServiceManager method createConfigBean.
public Resource createConfigBean(final Resources resources, HashMap attributes, final Properties properties, boolean validate) throws Exception {
setAttributes(attributes, null);
ResourceStatus status = null;
if (!validate) {
status = new ResourceStatus(ResourceStatus.SUCCESS, "");
} else {
status = isValid(resources, false, null);
}
if (status.getStatus() == ResourceStatus.SUCCESS) {
return createConfigBean(resources, properties);
} else {
throw new ResourceException(status.getMessage());
}
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ContextServiceManager method isValid.
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
ResourceStatus status;
if (jndiName == null) {
String msg = localStrings.getLocalString("context.service.noJndiName", "No JNDI name defined for context service.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ContextService.class);
return status;
}
Aggregations