Search in sources :

Example 86 with Result

use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.

the class ASEjbName method check.

/**
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        String ejbName = descriptor.getName();
        if (ejbName.length() == 0) {
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "failed [AS-EJB ejb] : ejb-name cannot not be empty. It should be a valid ejb-name as defined in ejb-jar.xml"));
        } else {
            EjbDescriptor testDesc = descriptor.getEjbBundleDescriptor().getEjbByName(ejbName);
            if (testDesc != null && testDesc.getName().equals(ejbName)) {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] :  ejb-name is {0} and verified with ejb-jar.xml", new Object[] { ejbName }));
            } else {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB ejb] :  ejb-name {0} is not found in ejb-jar.xml. It should exist in ejb-jar.xml also.", new Object[] { ejbName }));
            }
        }
    } catch (Exception ex) {
        oneFailed = true;
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) Result(com.sun.enterprise.tools.verifier.Result)

Example 87 with Result

use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.

the class ASEntBeanCmpResource method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        EjbBundleDescriptorImpl ejbBundleDesc = descriptor.getEjbBundleDescriptor();
        ResourceReferenceDescriptor cmpResource = ejbBundleDesc.getCMPResourceReference();
        if (cmpResource != null) {
            // String jndiName = cmpResource.getJndiName();
            String jndiName = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/jndi-name");
            if (jndiName == null || jndiName.length() == 0) {
                // 4698046
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB cmp-resource] : jndi-name cannot be an empty string"));
            } else {
                if (jndiName.startsWith("jdbc/") || jndiName.startsWith("jdo/")) {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB cmp-resource] : jndi-name is {0}", new Object[] { jndiName }));
                } else {
                    // 4698046
                    oneWarning = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB cmp-resource] : The jndi-name  is {0}, the preferred jndi-name should start with  jdbc/ or jdo/", new Object[] { jndiName }));
                }
            }
            ResourcePrincipal defPrincipal = cmpResource.getResourcePrincipal();
            if (defPrincipal != null) {
                // String name = defPrincipal.getName();
                String name = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/default-resource-principal/name");
                if (name == null || name.length() == 0) {
                    // 4698046
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB default-resource-principal] :  name cannot be an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB default-resource-principal] : name is {0}", new Object[] { name }));
                }
                // String password = defPrincipal.getPassword();
                char[] password = getXPathValueasCharArray("sun-ejb-jar/enterprise-beans/cmp-resource/default-resource-principal/password");
                if (password == null || password.length == 0) {
                    // 4698046
                    oneWarning = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning1", "WARNING [AS-EJB default-resource-principal] : password is an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB default-resource-principal] : password is  {0}", new Object[] { new String(password) }));
                }
                Arrays.fill(password, ' ');
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB cmp-resource] : default-resource-principal Element not defined"));
            }
            Float specVer = getRuntimeSpecVersion();
            if ((Float.compare(specVer.floatValue(), (new Float("2.1")).floatValue()) >= 0)) {
                // property
                result = testProperty("property", result, "sun-ejb-jar/enterprise-beans/cmp-resource/property", compName, descriptor);
                // schema-generator-properties
                result = testProperty("schema-generator-properties", result, "sun-ejb-jar/enterprise-beans/cmp-resource/schema-generator-properties/property", compName, descriptor);
            }
            if (// 4698046
            oneFailed)
                result.setStatus(Result.FAILED);
            else if (oneWarning)
                result.setStatus(Result.WARNING);
        } else {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB enterprise-beans] : cmp-resource element is not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
    return result;
}
Also used : ResourcePrincipal(com.sun.enterprise.deployment.ResourcePrincipal) ResourceReferenceDescriptor(com.sun.enterprise.deployment.ResourceReferenceDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 88 with Result

use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.

the class ASEntBeanPmDescriptors method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    compName = getVerifierContext().getComponentNameConstructor();
    // String value=null;
    int count = 0;
    try {
        count = getCountNodeSet("sun-ejb-jar/enterprise-beans/pm-descriptors");
        if (count > 0) {
            Map<String, String> pmIdVer = new HashMap<String, String>();
            count = getCountNodeSet("sun-ejb-jar/enterprise-beans/pm-descriptors/pm-descriptor");
            if (count > 0) {
                for (int i = 0; i < count; i++) {
                    testPmDescriptor(i, result, pmIdVer, descriptor);
                }
                count = getCountNodeSet("sun-ejb-jar/enterprise-beans/pm-descriptors/pm-inuse");
                if (count > 0) {
                    String pmIdentifier = getXPathValue("sun-ejb-jar/enterprise-beans/pm-descriptors/pm-inuse/pm-identifier");
                    String pmVersion = getXPathValue("sun-ejb-jar/enterprise-beans/pm-descriptors/pm-inuse/pm-version");
                    if (pmIdentifier != null) {
                        if (pmVersion != null) {
                            if (pmIdVer.containsKey(pmIdentifier)) {
                                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB pm-inuse] : pm-identifier {0} is valid", new Object[] { pmIdentifier }));
                                String testVersion = (String) pmIdVer.get(pmIdentifier);
                                if (testVersion.equals(pmVersion)) {
                                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                    result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB pm-inuse] : pm-version {0} is valid", new Object[] { pmVersion }));
                                } else {
                                    // <addition> srini@sun.com Bug: 4698038
                                    // result.failed(smh.getLocalString(getClass().getName()+".failed",
                                    // "FAILED [AS-EJB pm-inuse] : pm-version {0} for pm-identifier {0} not defined in pm-descriptors"
                                    // , new Object[]{pmVersion, pmIdentifier}));
                                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                    result.failed(smh.getLocalString(getClass().getName() + ".failed5", "FAILED [AS-EJB pm-inuse] : pm-version {0} for pm-identifier {1} not defined in pm-descriptors", new Object[] { pmVersion, pmIdentifier }));
                                    // </addition> Bug: 4698038
                                    oneFailed = true;
                                }
                            } else {
                                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB pm-inuse] : pm-identifier {0} is not defined in pm-descriptors", new Object[] { pmIdentifier }));
                                oneFailed = true;
                            }
                        } else {
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.failed(smh.getLocalString(getClass().getName() + ".failed12", "FAILED [AS-EJB pm-inuse] : pm-version {0} is not defined in pm-inuse", new Object[] { pmIdentifier }));
                            oneFailed = true;
                        }
                    } else {
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed14", "FAILED [AS-EJB pm-inuse] : pm-identifier {0} is not defined in pm-inuse", new Object[] { pmIdentifier }));
                        oneFailed = true;
                    }
                } else {
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed10", "FAILED [AS-EJB pm-descriptors] : pm-inuse {0} is not defined in pm-descriptors"));
                    oneFailed = true;
                }
            } else {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed11", "FAILED [AS-EJB pm-descriptors] : pm-descriptor is not defined in pm-descriptors"));
                oneFailed = true;
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB enterprise-beans] : pm-descriptors Element not defined"));
        }
        if (oneFailed)
            result.setStatus(Result.FAILED);
        else if (oneWarning)
            result.setStatus(Result.WARNING);
    } catch (Exception ex) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] Could not create descriptor Object."));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Result(com.sun.enterprise.tools.verifier.Result)

Example 89 with Result

use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.

the class ASEjbBCCacheIdleTimeout method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String idleTimeout = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            try {
                idleTimeout = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/cache-idle-timeout-in-seconds");
                if (idleTimeout != null) {
                    idleTimeout = idleTimeout.trim();
                    if (idleTimeout.length() == 0) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds cannot be empty. It should be between 0 and {0}", new Object[] { new Long(Long.MAX_VALUE) }));
                    } else {
                        long value = new Integer(idleTimeout).longValue();
                        if (value < 0 || value > Long.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds cannot be {0}. It should be between 0 and {1}", new Object[] { new Long(value), new Long(Long.MAX_VALUE) }));
                        } else {
                            addGoodDetails(result, compName);
                            result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds is [{0}]", new Object[] { new Long(value) }));
                        }
                    }
                } else // idle-timeout-in-seconds not defined
                {
                    addNaDetails(result, compName);
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : cache-idle-timeout-in-seconds element not defined"));
                }
            } catch (NumberFormatException nfex) {
                Verifier.debug(nfex);
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-cache] : [{0}] is not a valid Long number", new Object[] { idleTimeout }));
            }
        } else // bean-cache element not defined
        {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 90 with Result

use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.

the class ASEjbBCRemovalTimeout method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String removeTime = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            removeTime = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/removal-timeout-in-seconds");
            if (removeTime != null) {
                try {
                    removeTime = removeTime.trim();
                    if (removeTime.length() == 0) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be empty. It should be between 0 and {0}", new Object[] { new Long(Long.MAX_VALUE) }));
                    } else {
                        long value = new Integer(removeTime).longValue();
                        if (value < 0 || value > Long.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be {0}. It should be between 0 and {1}", new Object[] { new Long(value), new Long(Long.MAX_VALUE) }));
                        } else {
                            addGoodDetails(result, compName);
                            result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : removal-timeout-in-seconds is {0}", new Object[] { new Long(value) }));
                        }
                    }
                } catch (NumberFormatException nfex) {
                    Verifier.debug(nfex);
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-cache] : [{0}] is not a valid Long number", new Object[] { removeTime }));
                }
            } else // removal-timeout not defined
            {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : removal-timeout-in-seconds element not defined"));
            }
        } else // bean-cache not defined
        {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

Result (com.sun.enterprise.tools.verifier.Result)288 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)212 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)88 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)66 Method (java.lang.reflect.Method)66 Iterator (java.util.Iterator)50 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)28 Set (java.util.Set)26 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)17 Enumeration (java.util.Enumeration)15 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)14 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)14 Field (java.lang.reflect.Field)13 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)10 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)9 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)9 FieldDescriptor (org.glassfish.ejb.deployment.descriptor.FieldDescriptor)9 TagLibDescriptor (com.sun.enterprise.tools.verifier.TagLibDescriptor)7 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)6 EjbReferenceDescriptor (com.sun.enterprise.deployment.EjbReferenceDescriptor)6