dion        02/05/22 15:41:10

  Modified:    src/java/org/apache/maven/struts Struts10WarValidator.java
               xdocs/ref/struts build-file.xml futures.xml
  Log:
  no message
  
  Revision  Changes    Path
  1.5       +51 -48    
jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarValidator.java
  
  Index: Struts10WarValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarValidator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Struts10WarValidator.java 22 May 2002 10:06:49 -0000      1.4
  +++ Struts10WarValidator.java 22 May 2002 22:41:10 -0000      1.5
  @@ -74,7 +74,7 @@
    * </ol>
    *
    * @author  dion
  - * @version $Id: Struts10WarValidator.java,v 1.4 2002/05/22 10:06:49 dion Exp $
  + * @version $Id: Struts10WarValidator.java,v 1.5 2002/05/22 22:41:10 dion Exp $
    */
   public class Struts10WarValidator extends WarValidator
   {
  @@ -187,53 +187,56 @@
           for (int index = 0; index < actions.size(); index++) 
           {
               action = (Action) actions.get(index);
  -            info("validating action for path: '" + action.getPath() + "'");
  -            if (action.getClassName() != null)
  -            {
  -                validateClass(action.getClassName(), loader);
  -            }
  -            if (action.getName() != null)
  -            {
  -                if (formBeansByName.get(action.getName()) == null)
  -                {
  -                    error("action refers to a non-existent form bean: '" +
  -                        action.getName() + "'");
  -                }
  -            }
  -            if (!action.getPath().startsWith("/"))
  -            {
  -                error("action path doesn't start with a '/'");
  -            }
  -            if (action.getScope() != null)
  -            {
  -                // valid values are "request" or "session" according to the dtd
  -                String scope = action.getScope();
  -                if (!(scope.equals("request") || scope.equals("session")))
  -                {
  -                    error("scope is not 'request' or 'session': '" + scope + 
  -                        "'");
  -                }
  -            }
  -            if (action.getType() != null)
  -            {
  -                validateClass(action.getType(), loader);
  -            }
  -            if (action.getUnknown() != null) // true or false only
  -            {
  -                String unknown = action.getUnknown();
  -                if (!(unknown.equals("true") || unknown.equals("false")))
  -                {
  -                    error("unknown attribute is not 'true' or 'false'");
  -                }
  -            }
  -            if (action.getValidate() != null) // true or false only
  -            {
  -                String validate = action.getValidate();
  -                if (!(validate.equals("true") || validate.equals("false")))
  -                {
  -                    error("validate attribute is not 'true' or 'false'");
  -                }
  -            }
  +            validateAction(action, formBeansByName, loader);
           } // end for all actions
       } // end method
  +    
  +    /** validate a string that must contain a boolean value or be null
  +     * @return true if the provided string is true, false or null
  +     */
  +    private boolean isBoolean(String value) 
  +    {
  +        return value == null || value.equals("true") || value.equals("false");
  +    }
  +    
  +    /** validate the provided action object */
  +    private void validateAction(Action action, Map formBeans, ClassLoader 
  +        loader)
  +    {
  +        info("validating action for path: '" + action.getPath() + "'");
  +        if (action.getClassName() != null)
  +        {
  +            validateClass(action.getClassName(), loader);
  +        }
  +        if (action.getName() != null && 
  +            formBeans.get(action.getName()) == null)
  +        {
  +            error("action refers to a non-existent form bean: '" +
  +                    action.getName() + "'");
  +        }
  +        if (!action.getPath().startsWith("/"))
  +        {
  +            error("action path (" + action.getPath() + ") doesn't start " +
  +                "with a '/'");
  +        }
  +        if (action.getScope() != null && !(
  +            action.getScope().equals("request") || 
  +            action.getScope().equals("session")))
  +        {
  +            error("scope (" + action.getScope() + ") is not 'request' or " +
  +                "'session'");
  +        }
  +        if (action.getType() != null)
  +        {
  +            validateClass(action.getType(), loader);
  +        }
  +        if (!isBoolean(action.getUnknown())) // true or false only
  +        {
  +            error("unknown attribute is not 'true' or 'false'");
  +        }
  +        if (!isBoolean(action.getValidate())) // true or false only
  +        {
  +            error("validate attribute is not 'true' or 'false'");
  +        }
  +    }
   } // end class
  
  
  
  1.2       +18 -0     jakarta-turbine-maven/xdocs/ref/struts/build-file.xml
  
  Index: build-file.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/ref/struts/build-file.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build-file.xml    22 May 2002 07:23:46 -0000      1.1
  +++ build-file.xml    22 May 2002 22:41:10 -0000      1.2
  @@ -84,6 +84,24 @@
                       and <strong>not</strong> the classpath. If the form bean has
                       a <code>className</code>, that class too must be loaded from
                       the war</li>
  +                <li>Actions defined by a <code>&lt;action&lt;</code> tag have 
  +                    several validations:
  +                    <ol>
  +                        <li>the <code>className</code> attribute must be a 
  +                        class loadable from the war</li>
  +                        <li>the <code>name</code> attribute, must match a 
  +                        <code>&lt;form-bean&gt; name</code> attribute.</li>
  +                        <li>the <code>path</code> attribute must start with a 
  +                        forward slash, i.e. '/'</li>
  +                        <li>the <code>scope</code> attribute must be one of
  +                        <code>request</code> or <code>sesssion</code></li>
  +                        <li>the <code>type</code> attribute must be a class
  +                        loadable from the war</li>
  +                        <li>the <code>unknown</code> and <code>validate</code>
  +                        attributes must be either <code>true</code> or <code>
  +                        false</code></li>
  +                    </ol>
  +                </li>
               </ol>
           </p>
         </subsection>
  
  
  
  1.2       +0 -1      jakarta-turbine-maven/xdocs/ref/struts/futures.xml
  
  Index: futures.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/ref/struts/futures.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- futures.xml       22 May 2002 07:23:45 -0000      1.1
  +++ futures.xml       22 May 2002 22:41:10 -0000      1.2
  @@ -13,7 +13,6 @@
           for the Maven Struts Plug-in.
         </p>
         <ol>
  -        <li>Validate action mappings</li>
           <li>Validate forwards</li>
        </ol>
      </section>
  
  
  

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

Reply via email to