Search in sources :

Example 16 with ResourceStatus

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, "");
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus)

Example 17 with ResourceStatus

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;
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Example 18 with ResourceStatus

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());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 19 with ResourceStatus

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());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 20 with ResourceStatus

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;
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Aggregations

ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)60 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)17 HashMap (java.util.HashMap)15 ActionReport (org.glassfish.api.ActionReport)15 Resources (com.sun.enterprise.config.serverbeans.Resources)14 PropertyVetoException (java.beans.PropertyVetoException)14 ResourceException (javax.resource.ResourceException)13 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 Properties (java.util.Properties)2 ContextService (org.glassfish.concurrent.config.ContextService)2 ManagedExecutorService (org.glassfish.concurrent.config.ManagedExecutorService)2 ManagedThreadFactory (org.glassfish.concurrent.config.ManagedThreadFactory)2 JdbcResource (org.glassfish.jdbc.config.JdbcResource)2 MailResource (org.glassfish.resources.javamail.config.MailResource)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 Module (com.sun.enterprise.config.serverbeans.Module)1 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1