use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class AdminObjectManager method isValidAdminObject.
// TODO Error checking taken from v2, need to refactor for v3
private ResourceStatus isValidAdminObject() {
// Check if the restype is valid -
// To check this, we need to get the list of admin-object-interface
// names and then find out if this list contains the restype.
// boolean isValidAdminObject = true;
boolean isValidAdminObject = false;
// be using that resType
if (className == null) {
String[] resTypes;
try {
resTypes = connectorRuntime.getAdminObjectInterfaceNames(raName);
} catch (ConnectorRuntimeException cre) {
Logger.getLogger(AdminObjectManager.class.getName()).log(Level.SEVERE, "Could not find admin-ojbect-interface names (resTypes) from ConnectorRuntime for resource adapter.", cre);
String msg = localStrings.getLocalString("admin.mbeans.rmb.null_ao_intf", "Resource Adapter {0} does not contain any resource type for admin-object. Please specify another res-adapter.", raName) + " " + cre.getLocalizedMessage();
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (resTypes == null || resTypes.length <= 0) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.null_ao_intf", "Resource Adapter {0} does not contain any resource type for admin-object. Please specify another res-adapter.", raName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
int count = 0;
for (int i = 0; i < resTypes.length; i++) {
if (resTypes[i].equals(resType)) {
isValidAdminObject = true;
count++;
}
}
if (count > 1) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.multiple_admin_objects.found.for.restype", "Need to specify admin-object classname parameter (--classname) as multiple admin objects " + "use this resType [ {0} ]", resType);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
try {
isValidAdminObject = connectorRuntime.hasAdminObject(raName, resType, className);
} catch (ConnectorRuntimeException cre) {
Logger.getLogger(AdminObjectManager.class.getName()).log(Level.SEVERE, "Could not find admin-object-interface names (resTypes) and admin-object-classnames from " + "ConnectorRuntime for resource adapter.", cre);
String msg = localStrings.getLocalString("admin.mbeans.rmb.ao_intf_impl_check_failed", "Could not determine admin object resource information of Resource Adapter [ {0} ] for" + "resType [ {1} ] and classname [ {2} ] ", raName, resType, className) + " " + cre.getLocalizedMessage();
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
if (!isValidAdminObject) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_res_type", "Invalid Resource Type: {0}", resType);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
return new ResourceStatus(ResourceStatus.SUCCESS, "");
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class AdminObjectManager method isValid.
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
ResourceStatus status;
if (jndiName == null) {
String msg = localStrings.getLocalString("create.admin.object.noJndiName", "No JNDI name defined for administered object.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, AdminObjectResource.class);
if (status.getStatus() == ResourceStatus.FAILURE) {
return status;
}
// no need to validate in remote instance as the validation would have happened in DAS.
if (environment.isDas()) {
status = isValidRAName();
if (status.getStatus() == ResourceStatus.FAILURE) {
return status;
}
status = isValidAdminObject();
if (status.getStatus() == ResourceStatus.FAILURE) {
return status;
}
}
return status;
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class AdminObjectManager method createConfigBean.
public Resource createConfigBean(Resources resources, HashMap attributes, 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 ConnectorResourceManager method createConfigBean.
public Resource createConfigBean(Resources resources, HashMap attributes, 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 ConnectorResourceManager method isValid.
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
ResourceStatus status;
if (jndiName == null) {
String msg = localStrings.getLocalString("create.connector.resource.noJndiName", "No JNDI name defined for connector resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ConnectorResource.class);
if (status.getStatus() == ResourceStatus.FAILURE) {
return status;
}
if (!isConnPoolExists(resources, poolName)) {
String msg = localStrings.getLocalString("create.connector.resource.connPoolNotFound", "Attribute value (pool-name = {0}) is not found in list of connector connection pools.", poolName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
return status;
}
Aggregations