Search in sources :

Example 46 with ResourceStatus

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

Example 47 with ResourceStatus

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);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 48 with ResourceStatus

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);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 49 with ResourceStatus

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

Example 50 with ResourceStatus

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

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 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1 NamingException (javax.naming.NamingException)1