Search in sources :

Example 1 with EnvironmentProperty

use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.

the class WebBundleDescriptorImpl method combineEnvironmentEntries.

@Override
protected void combineEnvironmentEntries(JndiNameEnvironment env) {
    for (Object oenve : env.getEnvironmentProperties()) {
        EnvironmentEntry enve = (EnvironmentEntry) oenve;
        EnvironmentProperty envProp = _getEnvironmentPropertyByName(enve.getName());
        if (envProp != null) {
            combineInjectionTargets(envProp, (EnvironmentProperty) enve);
            EnvironmentProperty envP = (EnvironmentProperty) enve;
            if (!envProp.hasInjectionTargetFromXml() && (!envProp.isSetValueCalled()) && envP.isSetValueCalled()) {
                envProp.setValue(enve.getValue());
            }
        } else {
            if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictEnvironmentEntry()) {
                throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictenventry", "There are more than one environment entries defined in web fragments with the same name, but not overrided in web.xml"));
            } else {
                addEnvironmentEntry(enve);
            }
        }
    }
}
Also used : EnvironmentEntry(com.sun.enterprise.deployment.web.EnvironmentEntry) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 2 with EnvironmentProperty

use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.

the class FilterInitParamName method check.

/**
 *  Filter Param Name exists test.
 *
 * @param descriptor the Web deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(WebBundleDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    Enumeration filterEnum = descriptor.getServletFilterDescriptors().elements();
    if (filterEnum.hasMoreElements()) {
        // get the filters in this .war
        while (filterEnum.hasMoreElements()) {
            ServletFilterDescriptor filter = (ServletFilterDescriptor) filterEnum.nextElement();
            HashSet<String> envSet = new HashSet<String>();
            Vector epVector = filter.getInitializationParameters();
            for (int i = 0; i < epVector.size(); i++) {
                EnvironmentProperty ep = (EnvironmentProperty) epVector.elementAt(i);
                String epName = ep.getName();
                if (epName.length() == 0) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed1", "Error: Param name/value entry should of finite length."));
                } else {
                    // Do duplicate name test.
                    if (!envSet.contains(epName)) {
                        envSet.add(epName);
                    } else {
                        oneFailed = true;
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed2", "Error: Duplicate param names are not allowed."));
                    }
                }
            }
        }
        if (oneFailed) {
            result.setStatus(Result.FAILED);
        } else {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString(getClass().getName() + ".passed", "All init parameter names are unique"));
        }
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no initialization parameters for the filter within the web archive [ {0} ]", new Object[] { descriptor.getName() }));
    }
    return result;
}
Also used : ServletFilterDescriptor(org.glassfish.web.deployment.descriptor.ServletFilterDescriptor) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Result(com.sun.enterprise.tools.verifier.Result)

Example 3 with EnvironmentProperty

use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.

the class EjbEnvEntryValue method check.

/**
 *If the Bean Provider provides a value for an environment entry using the
 * env-entry-value element, the value can be changed later by the Application
 * Assembler or Deployer. The value must be a string that is valid for the
 * constructor of the specified type that takes a single String parameter.
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.getEnvironmentProperties().isEmpty()) {
        // constructor of the specified type that takes a single String parameter
        for (Iterator itr = descriptor.getEnvironmentProperties().iterator(); itr.hasNext(); ) {
            EnvironmentProperty nextEnvironmentProperty = (EnvironmentProperty) itr.next();
            if ((nextEnvironmentProperty.getValue() != null) && (nextEnvironmentProperty.getValue().length() > 0)) {
                if (!validEnvType(nextEnvironmentProperty)) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Environment entry name [ {0} ] does not have" + " valid value [ {1} ] for constructor of the specified type" + " [ {2} ] that takes a single String parameter within bean [ {3} ]", new Object[] { nextEnvironmentProperty.getName(), nextEnvironmentProperty.getValue(), nextEnvironmentProperty.getType(), descriptor.getName() }));
                }
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Environment entry name has valid value"));
    }
    return result;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Iterator(java.util.Iterator) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 4 with EnvironmentProperty

use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.

the class EjbEnvEntryValueType method check.

/**
 * The environment entry value type must be one of the following Java types:
 * String, Integer, Boolean, Double, Byte, Short, Long, and Float.
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.getEnvironmentProperties().isEmpty()) {
        // String, Integer, Boolean, Double, Byte, Short, Long, and Float.
        for (Iterator itr = descriptor.getEnvironmentProperties().iterator(); itr.hasNext(); ) {
            EnvironmentProperty nextEnvironmentProperty = (EnvironmentProperty) itr.next();
            String envType = nextEnvironmentProperty.getType();
            if (!((envType.equals("java.lang.String")) || (envType.equals("java.lang.Integer")) || (envType.equals("java.lang.Boolean")) || (envType.equals("java.lang.Double")) || (envType.equals("java.lang.Byte")) || (envType.equals("java.lang.Short")) || (envType.equals("java.lang.Long")) || (envType.equals("java.lang.Character")) || (envType.equals("java.lang.Float")))) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Environment entry value [ {0} ] does not have" + " valid value type [ {1} ] within bean [ {2} ]", new Object[] { nextEnvironmentProperty.getName(), envType, descriptor.getName() }));
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Environment entry value has valid value type"));
    }
    return result;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Iterator(java.util.Iterator) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 5 with EnvironmentProperty

use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.

the class CheckConfigPropertyType method check.

/**
 * <p>
 * Properties names defined in the resource adapter config-propery should
 * be of an acceptable type
 * </p>
 *
 * @paramm descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // Set properties = descriptor.getConfigProperties();
    ConnectionDefDescriptor desc = descriptor.getConnectionDefinitionByCFType(null, true);
    Set properties = desc.getConfigProperties();
    if (properties.size() != 0) {
        Iterator iterator = properties.iterator();
        // HashSet hs = new HashSet();
        while (iterator.hasNext()) {
            EnvironmentProperty ep = (EnvironmentProperty) iterator.next();
            String type = ep.getType();
            if (type == null) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".notdefined", "Error: The configuration property named [ {0} ] has no type ", new Object[] { ep.getName() }));
                return result;
            }
            Class typeClass = null;
            // is it loadable ?
            try {
                typeClass = Class.forName(type);
            } catch (Throwable t) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".nonexist", "Error: The type [ {0} ] of the configuration property named [ {1} ] cannot be loaded", new Object[] { ep.getType(), ep.getName() }));
                return result;
            }
            boolean allowedType = false;
            for (int i = 0; i < allowedTypes.length; i++) {
                if (allowedTypes[i].equals(typeClass)) {
                    allowedType = true;
                    break;
                }
            }
            if (!allowedType) {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The type [ {0} ] for the configuration property named [ {1} ] is not allowed", new Object[] { ep.getType(), ep.getName() }));
                return result;
            }
        }
        // for failure, result has been set before
        if (!oneFailed) {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all properties have an allowed type"));
        }
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "Not Applicable: There are no config-property element defined"));
    }
    return result;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)29 Result (com.sun.enterprise.tools.verifier.Result)10 Iterator (java.util.Iterator)6 Node (org.w3c.dom.Node)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)3 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)3 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)3 Set (java.util.Set)3 ServletFilterDescriptor (org.glassfish.web.deployment.descriptor.ServletFilterDescriptor)3 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)2 MessageListener (com.sun.enterprise.deployment.MessageListener)2 Method (java.lang.reflect.Method)2 URISyntaxException (java.net.URISyntaxException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)2 WebInitParam (javax.servlet.annotation.WebInitParam)2 MultiException (org.glassfish.hk2.api.MultiException)2 AdminObject (com.sun.enterprise.deployment.AdminObject)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1