FileDocCategorySizeDatePackage
AppWebContextUnique.javaAPI DocGlassfish v2 API4057Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.app

AppWebContextUnique

public class AppWebContextUnique extends com.sun.enterprise.tools.verifier.tests.app.ApplicationTest implements AppCheck
All web modules in the application must have unique context-root.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(Application descriptor)
All web modules in the application must have unique context-root. Applicable for j2ee 1.3 or below. For 1.4 and above xml schema takes care of this.

param
descriptor the Application deployment descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
        Set webs=descriptor.getWebBundleDescriptors();
        if(webs.size()<=1){
            result.notApplicable(smh.getLocalString
				 (getClass().getName() + ".notApplicable",
				  "There is one or less web component in application [ {0} ]",
				  new Object[] {descriptor.getName()}));        
            return result;
        }
        Set<String> contexts=new HashSet<String>();
        Iterator itr=webs.iterator();
        boolean oneFailed=false;
	while (itr.hasNext()) {
            WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
            String ctx=wbd.getContextRoot();
            if(!contexts.add(ctx)){
                oneFailed=true;
                result.failed(
                    (smh.getLocalString
                     (getClass().getName() + ".failed",
                      "Error: There is already a web module with context-root [ {0} ] within application [ {1} ]",
                      new Object[] {ctx, descriptor.getName()})));
            }
        }
	if(!oneFailed){
            result.passed(
                (smh.getLocalString
                 (getClass().getName() + ".passed",
                  "All the context-root values are unique within application [ {0} ]",
                  new Object[] {descriptor.getName()})));
        }
	return result;