FileDocCategorySizeDatePackage
FormErrorPage.javaAPI DocGlassfish v2 API6648Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

FormErrorPage

public class FormErrorPage extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements WebCheck
The Web form-error-page value defines the location in the web application where the page can be used for error page can be found within web application test

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
The Web form-error-page value defines the location in the web application where the page can be used for error page can be found within web application test

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


	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

	if (descriptor.getLoginConfiguration() != null) {
	    boolean foundIt = false;
//            ZipEntry ze=null;
//            JarFile jar=null;
            FileArchive arch=null;
            
	    String formErrorPage = descriptor.getLoginConfiguration().getFormErrorPage();
            if (formErrorPage.length() > 0) {
	       
                try{
                    
//                    File f = Verifier.getArchiveFile(descriptor.getModuleDescriptor().getArchiveUri());
//                    if(f==null){
                        
                        String uri=getAbstractArchiveUri(descriptor);
                        
                        try{
                            arch = new FileArchive();
                            arch.open(uri);
                        }catch(IOException e){
                            throw e;
                        }
//                    }else{
//                        jar = new JarFile(f);
//                    }
                    if (formErrorPage.startsWith("/")) 
                        formErrorPage=formErrorPage.substring(1);
//                    if (f!=null){
//                        ze = jar.getEntry(formErrorPage);
//                        foundIt = (ze != null);
//                    }
//                    else{
                        File fep = new File(arch.getArchiveUri() + File.separator + formErrorPage);
                        if(fep.exists())
                            foundIt=true;
                        fep = null;
//                    }
//                    if (jar!=null)
//                        jar.close();
                }catch (Exception ex) {
		    //should be aldready set?
		    foundIt = false;
	        }               
	        if (foundIt) {
		    result.addGoodDetails(smh.getLocalString
			("tests.componentNameConstructor",
			"For [ {0} ]",
			new Object[] {compName.toString()}));
		    result.passed(smh.getLocalString
			          (getClass().getName() + ".passed",
			           "The form-error-page [ {0} ] value defines the location in the web application where the error page that is displayed when login is not successful can be found within web application [ {1} ]",
			           new Object[] {formErrorPage, descriptor.getName()}));
	        } else {
		    result.addErrorDetails(smh.getLocalString
			("tests.componentNameConstructor",
			"For [ {0} ]",
			new Object[] {compName.toString()}));
                    result.failed(smh.getLocalString
			      (getClass().getName() + ".failed",
			       "Error: The form-error-page [ {0} ] value does not define the location in the web application where the error page that is displayed when login is not successful can be found within web application [ {1} ]",
			       new Object[] {formErrorPage, descriptor.getName()}));
	        }
	    } else {
		result.addNaDetails(smh.getLocalString
			("tests.componentNameConstructor",
			"For [ {0} ]",
			new Object[] {compName.toString()}));
	        result.notApplicable(smh.getLocalString
	    			 (getClass().getName() + ".notApplicable",
	    			  "There are no form-error-page elements within this web archive [ {0} ]",
	    			  new Object[] {descriptor.getName()}));
	    }
	} else {
	    result.addNaDetails(smh.getLocalString
			("tests.componentNameConstructor",
			"For [ {0} ]",
			new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
				 (getClass().getName() + ".notApplicable",
				  "There are no form-error-page elements within this web archive [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}

	return result;