Search in sources :

Example 6 with Result

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

the class ASConstraintField method check.

public Result check(WebBundleDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String value = null;
    int count = 0;
    boolean oneFailed = false;
    try {
        count = getCountNodeSet("sun-web-app/cache/cache-mapping/constraint-field");
        if (count > 0) {
            for (int i = 1; i <= count; i++) {
                // name attribute
                value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field[" + i + "]/@name");
                if (value == null || value.length() == 0) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-WEB constraint-field] :  name attribute is required", new Object[] { descriptor.getName() }));
                } else {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-WEB constraint-field] : name attribute is {1}", new Object[] { descriptor.getName(), value }));
                }
                // scope attribute
                value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field[" + i + "]/@scope");
                if (value == null || value.length() == 0) {
                    result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-WEB constraint-field] : scope attribute not defined"));
                } else {
                    String[] scopeValue = { "context.attribute", "request.header", "request.parameter", "request.cookie", "request.attribute", "session.attribute" };
                    boolean found = false;
                    for (int j = 0; j < scopeValue.length; j++) {
                        if (scopeValue[j].compareTo(value) == 0) {
                            found = true;
                        }
                    }
                    if (found) {
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-WEB constraint-field] : scope attribute is {1}", new Object[] { descriptor.getName(), value }));
                    } else {
                        oneFailed = true;
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-WEB constraint-field] :  scope attribute must be one of context.attribute, request.header, request.parameter, request.cookie, request.attribute, session.attribute", new Object[] { descriptor.getName() }));
                    }
                }
                // cache-on-match % boolean "(yes | no | on | off | 1 | 0 | true | false)">
                value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field[" + i + "]/@cache-on-match");
                if (value == null || value.length() == 0) {
                    result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-WEB constraint-field] : cache-on-match attribute not defined"));
                } else {
                    String[] cacheOnMatchValue = { "yes", "no", "on", "off", "1", "0", "true", "false" };
                    boolean foundCacheOnMatch = false;
                    for (int j = 0; j < cacheOnMatchValue.length; j++) {
                        if (cacheOnMatchValue[j].compareTo(value) == 0) {
                            foundCacheOnMatch = true;
                        }
                    }
                    if (foundCacheOnMatch) {
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-WEB constraint-field] : cache-on-match attribute is {1}", new Object[] { descriptor.getName(), value }));
                    } else {
                        oneFailed = true;
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-WEB constraint-field] :  cache-on-match attribute must be one of yes, no, on, off, 1, 0, true, false", new Object[] { descriptor.getName() }));
                    }
                }
                // cache-on-match-failure
                value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field[" + i + "]/@cache-on-match-failure");
                if (value == null || value.length() == 0) {
                    result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable2", "NOT APPLICABLE [AS-WEB constraint-field] : cache-on-match-failure attribute not defined"));
                } else {
                    String[] cacheOnMatchFailureValue = { "yes", "no", "on", "off", "1", "0", "true", "false" };
                    boolean found = false;
                    for (int j = 0; j < cacheOnMatchFailureValue.length; j++) {
                        if (cacheOnMatchFailureValue[j].compareTo(value) == 0) {
                            found = true;
                        }
                    }
                    if (found) {
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.passed(smh.getLocalString(getClass().getName() + ".passed3", "PASSED [AS-WEB constraint-field] : cache-on-match-failure attribute is {1}", new Object[] { descriptor.getName(), value }));
                    } else {
                        oneFailed = true;
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed3", "FAILED [AS-WEB constraint-field] :  cache-on-match-failure attribute must be one of yes, no, on, off, 1, 0, true, false", new Object[] { descriptor.getName() }));
                    }
                }
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable3", "NOT APPLICABLE [AS-WEB sun-web-app] : constraint-field Element not defined"));
        }
        if (oneFailed)
            result.setStatus(Result.FAILED);
    } catch (Exception ex) {
        result.failed(smh.getLocalString(getClass().getName() + ".failed4", "FAILED [AS-WEB sun-web-app] could not create the constraint-field object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 7 with Result

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

the class ASWebEjbRef method check.

public Result check(WebBundleDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    String refName;
    Set<EjbReference> ejbRefs = descriptor.getEjbReferenceDescriptors();
    if (ejbRefs != null && ejbRefs.size() > 0) {
        for (EjbReference ejbRef : ejbRefs) {
            refName = ejbRef.getName();
            if (validEjbRefName(refName, descriptor)) {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] properly defined in the war file.", new Object[] { refName }));
            } else {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] is not valid, either empty or not defined in web.xml.", new Object[] { refName }));
            }
        }
    } else {
        addNaDetails(result, compName);
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-WEB sun-web-app] ejb-ref element(s) not defined in the web archive [ {0} ].", new Object[] { descriptor.getName() }));
        return result;
    }
    if (oneFailed) {
        result.setStatus(Result.FAILED);
    } else {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-WEB sun-web-app] ejb-ref element(s) defined are valid within the web archive [ {0} ].", new Object[] { descriptor.getName() }));
    }
    return result;
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 8 with Result

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

the class HandlerChainClassCheck method check.

public Result check(WebServiceEndpoint descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // Handler chains are applicable only in the context of JAX-WS 2.0. So
    // version check for this test is not required.
    List handlerChain = descriptor.getHandlerChain();
    for (Iterator it = handlerChain.iterator(); it.hasNext(); ) {
        List handlers = ((WebServiceHandlerChain) it.next()).getHandlers();
        for (Iterator itr = handlers.iterator(); itr.hasNext(); ) {
            String hClass = ((WebServiceHandler) itr.next()).getHandlerClass();
            try {
                Class cl = Class.forName(hClass, false, getVerifierContext().getClassLoader());
                if (!((javax.xml.ws.handler.Handler.class).isAssignableFrom(cl))) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "Handler Class [{0}] does not implement " + "javax.xml.ws.handler.Handler Interface", new Object[] { hClass }));
                }
            } catch (ClassNotFoundException e) {
                // result.fail, handler class not found
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.clfailed", "The [{0}] Class [{1}] could not be Loaded", new Object[] { "Handler Class", hClass }));
            }
        }
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed1", "Handler chains, if any, are defined properly"));
    }
    return result;
}
Also used : WebServiceHandler(com.sun.enterprise.deployment.WebServiceHandler) Result(com.sun.enterprise.tools.verifier.Result) Iterator(java.util.Iterator) List(java.util.List) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) WebServiceHandlerChain(com.sun.enterprise.deployment.WebServiceHandlerChain) WebServiceHandler(com.sun.enterprise.deployment.WebServiceHandler)

Example 9 with Result

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

the class SEIEJBTxAttrChk method check.

/**
 * @param descriptor the  WebService deployment descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(WebServiceEndpoint wsdescriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean pass = true;
    if (wsdescriptor.implementedByEjbComponent()) {
        EjbDescriptor descriptor = (EjbDescriptor) wsdescriptor.getEjbComponentImpl();
        try {
            ContainerTransaction ctx = descriptor.getContainerTransaction();
            if ((ctx != null) && (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) {
                // Call result.failed here : All methods are having Mandatory TX
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", new Object[] { "All the methods", compName.toString() }));
                return result;
            }
            Collection txMethDescs = descriptor.getTransactionMethodDescriptors();
            // get hold of the SEI Class
            String s = descriptor.getWebServiceEndpointInterfaceName();
            if (s == null) {
                // internal error, should never happen
                result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "Service Endpoint Interface Class Name Null" }));
                pass = false;
            }
            ClassLoader cl = getVerifierContext().getClassLoader();
            Class sei = null;
            try {
                sei = Class.forName(s, false, cl);
            } catch (ClassNotFoundException e) {
                result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "Could not Load Service Endpoint Interface Class" }));
                pass = false;
            }
            Iterator it = txMethDescs.iterator();
            while (it.hasNext()) {
                // need to check if this method is part of SEI
                MethodDescriptor methdesc = (MethodDescriptor) it.next();
                if (isSEIMethod(methdesc, descriptor, sei, cl)) {
                    ctx = descriptor.getContainerTransactionFor(methdesc);
                    if ((ctx != null) && (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) {
                        // Call result.failed here with Method details here
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", new Object[] { methdesc.getName(), compName.toString() }));
                        pass = false;
                    }
                }
            }
        } catch (Exception e) {
            // Call result.addErrorDetails here with exception details
            result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { e.getMessage() }));
            pass = false;
        }
        if (pass) {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString(getClass().getName() + ".passed", "None of the methods of this WebService [{0}] have Mandatory Transaction Attribute.", new Object[] { compName.toString() }));
        }
        return result;
    } else {
        // call result.notapplicable
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notapp", "Not applicable since this is not an EJB Service Endpoint."));
        return result;
    }
}
Also used : MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) Result(com.sun.enterprise.tools.verifier.Result) ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) Iterator(java.util.Iterator) Collection(java.util.Collection) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 10 with Result

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

the class WSWsdlPortComponentName method check.

/**
 * @param descriptor the WebServices  descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(WebServiceEndpoint descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean pass = true;
    String portcomponentname = null;
    try {
        portcomponentname = descriptor.getEndpointName();
        if (portcomponentname == null || portcomponentname.equals(""))
            pass = false;
        if (pass) {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString(getClass().getName() + ".passed", "The webservices.xml file for [ {0} ] has the port-component-name element specified.", new Object[] { compName.toString() }));
        } else {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "The webservices.xml file for [ {0} ] does not have the port-component-name element specified.", new Object[] { compName.toString() }));
        }
    } catch (Exception e) {
        // result.fail
        result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { e.getMessage() }));
    }
    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