use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class AdminObjectManager method isValidRAName.
private ResourceStatus isValidRAName() {
// TODO turn on validation. For now, turn validation off until connector modules ready
// boolean retVal = false;
ResourceStatus status = new ResourceStatus(ResourceStatus.SUCCESS, "");
if ((raName == null) || (raName.equals(""))) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.null_res_adapter", "Resource Adapter Name is null.");
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
} else {
// System RA, so don't validate
if (!ConnectorsUtil.getNonJdbcSystemRars().contains(raName)) {
// Check if the raName contains double underscore or hash.
// If that is the case then this is the case of an embedded rar,
// hence look for the application which embeds this rar,
// otherwise look for the webconnector module with this raName.
int indx = raName.indexOf(EMBEDDEDRAR_NAME_DELIMITER);
if (indx != -1) {
String appName = raName.substring(0, indx);
Application app = applications.getModule(Application.class, appName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_app_not_found", "Invalid raname. Application with name {0} not found.", appName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
Application app = applications.getModule(Application.class, raName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_cm_not_found", "Invalid raname. Connector Module with name {0} not found.", raName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
}
return status;
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus 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 org.glassfish.resourcebase.resources.api.ResourceStatus 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 org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ConnectorConnectionPoolManager method isValidRAName.
private ResourceStatus isValidRAName(String raName) {
// TODO turn on validation. For now, turn validation off until connector modules ready
// boolean retVal = false;
ResourceStatus status = new ResourceStatus(ResourceStatus.SUCCESS, "");
if ((raName == null) || (raName.equals(""))) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.null_res_adapter", "Resource Adapter Name is null.");
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
} else {
// System RA, so don't validate
if (!ConnectorsUtil.getNonJdbcSystemRars().contains(raName)) {
// Check if the raName contains double underscore or hash.
// If that is the case then this is the case of an embedded rar,
// hence look for the application which embeds this rar,
// otherwise look for the webconnector module with this raName.
int indx = raName.indexOf(EMBEDDEDRAR_NAME_DELIMITER);
if (indx != -1) {
String appName = raName.substring(0, indx);
Application app = applications.getModule(Application.class, appName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_app_not_found", "Invalid raname. Application with name {0} not found.", appName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
Application app = applications.getModule(Application.class, raName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_cm_not_found", "Invalid raname. Connector Module with name {0} not found.", raName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
}
return status;
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ConnectorConnectionPoolManager method createConfigBean.
public Resource createConfigBean(Resources resources, HashMap attributes, Properties properties, boolean validate) throws Exception {
setParams(attributes);
ResourceStatus status = null;
if (!validate) {
status = new ResourceStatus(ResourceStatus.SUCCESS, "");
} else {
status = isValid(resources, false);
}
if (status.getStatus() == ResourceStatus.SUCCESS) {
return createConfigBean(resources, properties);
} else {
throw new ResourceException(status.getMessage());
}
}
Aggregations