FileDocCategorySizeDatePackage
IASWebEjbRef.javaAPI DocGlassfish v2 API7070Fri May 04 22:35:18 BST 2007com.sun.enterprise.tools.verifier.tests.web.ias

IASWebEjbRef

public class IASWebEjbRef extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements com.sun.enterprise.tools.verifier.tests.web.WebCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)


	Result result = getInitializedResult();
	WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor);
        EjbRef[] ejbRefs = descriptor.getIasWebApp().getEjbRef();

	boolean oneFailed = false;
        String jndiName;
        String refName;

    	if (ejbRefs.length > 0) {
            boolean isValidResRefName;
	    for (int rep=0; rep<ejbRefs.length; rep++ ) {
                //System.out.println(">>>>>>>>>>>>>rep is " + rep);
                isValidResRefName=false;

		jndiName = ejbRefs[rep].getJndiName();
                refName = ejbRefs[rep].getEjbRefName();

                if (validEjbRefName(refName,descriptor)) {
                    isValidResRefName=true;
                    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addGoodDetails(smh.getLocalString
					  (getClass().getName() + ".passed",
					   "Proper ejb reference name  [ {0} ] defined in the war file.",
					   new Object[] {refName}));
                } else {
                    if (!oneFailed)
                        oneFailed = true;
		    result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addErrorDetails(smh.getLocalString
                                        (getClass().getName() + ".failed",
                                        "Error: Ejb reference name [ {0} ] is not valid, either empty or not defined in web.xml.",
                                        new Object[] {refName}));
                }

                if (isValidResRefName && validJndiName(jndiName, refName,descriptor)){
                    //                 foundIt  = true;
		    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addGoodDetails(smh.getLocalString
					  (getClass().getName() + ".passed",
					   "Proper jndi name  [ {0} ] defined in the war file.",
					   new Object[] {jndiName}));
                } else {
                    if (!oneFailed)
                        oneFailed = true;
		    result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addErrorDetails(smh.getLocalString
                                        (getClass().getName() + ".failed",
                                        "Error: Jndi name [ {0} ] is not validis not valid, either empty or not starts with \"ejb/\".",
                                        new Object[] {jndiName}));
                }




	    }
	} else {
	    result.addNaDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
				 (getClass().getName() + ".notApplicable",
				  "There is no ejb env reference element present in  this web archive [ {0} ].",
				  new Object[] {descriptor.getName()}));
	    return result;
	}

	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 ejb env reference elements are valid within the web archive [ {0} ].",
                    new Object[] {descriptor.getName()} ));
	    }
	return result;
    
booleanvalidEjbRefName(java.lang.String name, WebBundleDescriptor descriptor)

        boolean valid =true;
        if(name !=null && name.length()!=0) {
            try{
              descriptor.getEjbReferenceByName(name);
            }
            catch(IllegalArgumentException e){
            valid=false;
            }
        }  else{
         valid=false;

        }
        return valid;
    
booleanvalidJndiName(java.lang.String refJndiName, java.lang.String refName, WebBundleDescriptor descriptor)

        boolean valid =true;

        if(refJndiName !=null && refJndiName.length()!=0 && refJndiName.startsWith("ejb/")) {

         }
        else{
        valid=false;
        }

        return valid;