dion        02/05/19 21:45:02

  Modified:    src/java/org/apache/maven/j2ee WarValidator.java
  Log:
  Added validation for error pages specified in web.xml
  
  Revision  Changes    Path
  1.15      +41 -1     
jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarValidator.java
  
  Index: WarValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarValidator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WarValidator.java 19 May 2002 22:49:59 -0000      1.14
  +++ WarValidator.java 20 May 2002 04:45:02 -0000      1.15
  @@ -94,7 +94,7 @@
    *          &lt;taglib-location&gt;</code> that exists in the war</li>
    * </ol>
    * @author  dIon Gillard
  - * @version $Id: WarValidator.java,v 1.14 2002/05/19 22:49:59 dion Exp $
  + * @version $Id: WarValidator.java,v 1.15 2002/05/20 04:45:02 dion Exp $
    * @task add validator for error-page/locations
    * @task add validator for form-login-config
    */
  @@ -222,6 +222,7 @@
               validateServlets(war);
               validateJSPs(war);
               validateTaglibs(war);
  +            validateErrorPages(war);
           }
           catch (IOException ioe)
           {
  @@ -379,6 +380,45 @@
                   getWarFileName(), "Error reading WEB-INF/web.xml"));
           }
       }
  +
  +    /** Validate the error pages defined in the war file (as defined by a
  +     * <code>&lt;error-page&gt;</code> tag in web.xml), making sure that the 
  +     * location specifed by the nested <code>&lt;location&gt;</code> exists in 
  +     * the war file
  +     */
  +     public void validateErrorPages(WarFile war)
  +     {
  +        try
  +        {
  +            Map pages = war.getErrorPages();
  +            if (pages.size() != 0)
  +            {
  +                Map.Entry entry = null;
  +                for (Iterator entries = pages.entrySet().iterator();
  +                    entries.hasNext();)
  +                {
  +                    entry = (Map.Entry)entries.next();
  +                    String errorQualifier = (String)entry.getKey();
  +                    String location = (String)entry.getValue();
  +                    getBroadcaster().fireInformationEvent( new 
  +                        ValidationEvent(this, getWarFileName(), 
  +                        "validating error page for: " + errorQualifier));
  +                    if (!war.hasFile(location))
  +                    {
  +                        getBroadcaster().fireErrorEvent( new ValidationEvent(
  +                            this, getWarFileName(), "Error page location: '" + 
  +                            location + "' not found"));
  +                    }
  +                }
  +            }
  +        }
  +        catch (IOException ioe)
  +        {
  +            ioe.printStackTrace();
  +            getBroadcaster().fireErrorEvent(new ValidationEvent(this,
  +                getWarFileName(), "Error reading WEB-INF/web.xml"));
  +        }
  +     }
       
       /**
        * add a listener to the list to be notified
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to