Search in sources :

Example 6 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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 7 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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 8 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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 9 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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)

Example 10 with ComponentNameConstructor

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

the class EjbNameIsValidJavaIdentifier method check.

/**
 * For an entity-bean the ejb-name must be a valid Java identifier.
 * See ejb specification 2.1 section 10.3.13
 * @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();
    String ejbName = descriptor.getName();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (descriptor instanceof EjbEntityDescriptor) {
        if (((EjbEntityDescriptor) descriptor).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) {
            boolean isJavaIdentifier = true;
            boolean startChar = Character.isJavaIdentifierStart(ejbName.charAt(0));
            if (startChar) {
                for (int i = 1; i < ejbName.length(); i++) if (!Character.isJavaIdentifierPart(ejbName.charAt(i))) {
                    isJavaIdentifier = false;
                    break;
                }
            } else {
                isJavaIdentifier = false;
            }
            // valid JavaIdentifier
            if (isJavaIdentifier) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "ejb-name [ {0} ] within bean [ {1} ] is a valid java identifier", new Object[] { ejbName, descriptor.getName() }));
                return result;
            } else {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "ejb-name [ {0} ] within bean [ {1} ] is not a valid java identifier", new Object[] { ejbName, descriptor.getName() }));
                return result;
            }
        }
    }
    result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, with Container Managed Persistence.", new Object[] { getClass(), "Entity" }));
    return result;
}
Also used : EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)237 Result (com.sun.enterprise.tools.verifier.Result)212 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)87 Method (java.lang.reflect.Method)70 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)66 Iterator (java.util.Iterator)40 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)28 Set (java.util.Set)19 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)16 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)15 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)14 Field (java.lang.reflect.Field)13 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)12 Enumeration (java.util.Enumeration)11 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)11 FieldDescriptor (org.glassfish.ejb.deployment.descriptor.FieldDescriptor)9 TagLibDescriptor (com.sun.enterprise.tools.verifier.TagLibDescriptor)7 EjbReferenceDescriptor (com.sun.enterprise.deployment.EjbReferenceDescriptor)6 ResourceReferenceDescriptor (com.sun.enterprise.deployment.ResourceReferenceDescriptor)6 Vector (java.util.Vector)6