use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class ManagedThreadFactoryManager method delete.
public ResourceStatus delete(final Resources resources, final String jndiName, final String target) throws Exception {
if (jndiName == null) {
String msg = localStrings.getLocalString("managed.thread.factory.noJndiName", "No JNDI name defined for managed thread factory.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
Resource resource = ConnectorsUtil.getResourceByName(resources, ManagedThreadFactory.class, jndiName);
// ensure we already have this resource
if (resource == null) {
String msg = localStrings.getLocalString("delete.managed.thread.factory.notfound", "A managed thread factory 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.managed.thread.factory.resource-ref.exist", "This managed thread factory [ {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.managed.thread.factory.no.resource-ref", "This managed thread factory [ {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.managed.thread.factory.multiple.resource-refs", "This managed thread factory [ {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 managed-thread-factory
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
ManagedThreadFactory resource = (ManagedThreadFactory) ConnectorsUtil.getResourceByName(resources, ManagedThreadFactory.class, jndiName);
return param.getResources().remove(resource);
}
}, resources) == null) {
String msg = localStrings.getLocalString("delete.managed.thread.factory.failed", "Managed thread factory {0} deletion failed", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("delete.managed.thread.factory.failed", "Managed thread factory {0} deletion failed ", jndiName);
ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg);
status.setException(tfe);
return status;
}
String msg = localStrings.getLocalString("delete.managed.thread.factory.success", "Managed thread factory {0} deleted successfully", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class ConnectorResourceManager method create.
public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception {
setAttributes(attributes, target);
ResourceStatus validationStatus = isValid(resources, true, target);
if (validationStatus.getStatus() == ResourceStatus.FAILURE) {
return validationStatus;
}
try {
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
return createResource(param, properties);
}
}, resources);
resourceUtil.createResourceRef(jndiName, enabledValueForTarget, target);
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("create.connector.resource.fail", "Connector resource {0} create failed ", jndiName) + " " + tfe.getLocalizedMessage();
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
String msg = localStrings.getLocalString("create.connector.resource.success", "Connector resource {0} created successfully", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class ConnectorWorkSecurityMapResourceManager method create.
public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception {
setAttributes(attributes);
ResourceStatus validationStatus = isValid(resources);
if (validationStatus.getStatus() == ResourceStatus.FAILURE) {
return validationStatus;
}
try {
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
return createResource(param, properties);
}
}, resources);
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("create.connector.work.security.map.fail", "Unable to create connector work security map {0}.", mapName) + " " + tfe.getLocalizedMessage();
return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
}
String msg = localStrings.getLocalString("create.work.security.map.success", "Work security map {0} created.", mapName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg, true);
}
use of com.sun.enterprise.config.serverbeans.Resources 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);
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class JDBCResourceManager method delete.
public ResourceStatus delete(final Resources resources, final String jndiName, final String target) throws Exception {
if (jndiName == null) {
String msg = localStrings.getLocalString("jdbc.resource.noJndiName", "No JNDI name defined for JDBC resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// ensure we already have this resource
if (ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName) == null) {
String msg = localStrings.getLocalString("delete.jdbc.resource.notfound", "A JDBC resource named {0} does not exist.", 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.jdbc.resource.resource-ref.exist", "jdbc-resource [ {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.jdbc.resource.no.resource-ref", "jdbc-resource [ {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.jdbc.resource.multiple.resource-refs", "jdbc resource [ {0} ] is referenced in multiple " + "instance/cluster targets, Use delete-resource-ref on appropriate target", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
try {
JdbcResource jdbcResource = (JdbcResource) ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName);
if (ResourceConstants.SYSTEM_ALL_REQ.equals(jdbcResource.getObjectType())) {
String msg = localStrings.getLocalString("delete.jdbc.resource.system-all-req.object-type", "The jdbc resource [ {0} ] cannot be deleted as it is required to be configured in the system.", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// delete resource-ref
resourceUtil.deleteResourceRef(jndiName, target);
// delete jdbc-resource
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
JdbcResource resource = (JdbcResource) ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName);
return param.getResources().remove(resource);
}
}, resources) == null) {
String msg = localStrings.getLocalString("jdbc.resource.deletionFailed", "JDBC resource {0} delete failed ", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("jdbc.resource.deletionFailed", "JDBC resource {0} delete failed ", jndiName);
ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg);
status.setException(tfe);
return status;
}
String msg = localStrings.getLocalString("jdbc.resource.deleteSuccess", "JDBC resource {0} deleted successfully", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
Aggregations