dion        02/05/19 21:32:40

  Modified:    src/java/org/apache/maven/j2ee WarFile.java
  Log:
  - Added errorPages property
  - It provides a map of error-code/exception-type to location
  
  Revision  Changes    Path
  1.3       +36 -1     
jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarFile.java
  
  Index: WarFile.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarFile.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WarFile.java      19 May 2002 22:49:59 -0000      1.2
  +++ WarFile.java      20 May 2002 04:32:40 -0000      1.3
  @@ -79,7 +79,7 @@
    * Represents a J2EE War File
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>dIon Gillard</a>
  - * @version $Id: WarFile.java,v 1.2 2002/05/19 22:49:59 dion Exp $
  + * @version $Id: WarFile.java,v 1.3 2002/05/20 04:32:40 dion Exp $
    */
   public class WarFile extends JarFile
   {
  @@ -324,5 +324,40 @@
           {
               return false;
           }
  +    }
  +    
  +    /** Get a map of error pages to error locations. The key of the map is
  +     * either the <code>&lt;error-code&gt;</code> or <code>&lt;
  +     * exception-type&gt;</code>, the value is <code>&lt;location&gt;</code>.
  +     * @throws IOException if there are problems reading from the war
  +     */
  +    public Map getErrorPages() throws IOException
  +    {
  +        Map errorPages = new HashMap();
  +        if (getWebXmlEntry() != null)
  +        {
  +            Document webXml = getWebXml();
  +            List errorNodes = webXml.selectNodes("//error-page");
  +            Node node = null;
  +            for (Iterator nodes = errorNodes.iterator(); nodes.hasNext();)
  +            {
  +                node = (Node) nodes.next();
  +                Node errorCodeNode = node.selectSingleNode("./error-code");
  +                Node exceptionTypeNode = node.selectSingleNode(
  +                    "./exception-type");
  +                String location = node.selectSingleNode("./location").getText();
  +                String key = null;
  +                if (errorCodeNode == null)
  +                {
  +                    key = exceptionTypeNode.getText();
  +                }
  +                else
  +                {
  +                    key = errorCodeNode.getText();
  +                }
  +                errorPages.put(key, location);
  +            }
  +        }
  +        return errorPages;
       }
   }
  
  
  

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

Reply via email to