You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/03/21 05:09:19 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/acting AbstractValidatorAction.java FormValidatorAction.java SessionIsValidAction.java SessionValidatorAction.java

vgritsenko    02/03/20 20:09:19

  Modified:    src/java/org/apache/cocoon/acting
                        AbstractValidatorAction.java
                        FormValidatorAction.java SessionIsValidAction.java
                        SessionValidatorAction.java
  Log:
  Fix bug #5558: Do not ignore invalid values. Cleaned up debug messages a bit.
  
  Revision  Changes    Path
  1.7       +133 -199  xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractValidatorAction.java
  
  Index: AbstractValidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractValidatorAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractValidatorAction.java	22 Feb 2002 06:59:26 -0000	1.6
  +++ AbstractValidatorAction.java	21 Mar 2002 04:09:19 -0000	1.7
  @@ -146,7 +146,7 @@
   * </table>
   * @author <a href="mailto:Martin.Man@seznam.cz">Martin Man</a>
   * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  -* @version CVS $Id: AbstractValidatorAction.java,v 1.6 2002/02/22 06:59:26 cziegeler Exp $
  +* @version CVS $Id: AbstractValidatorAction.java,v 1.7 2002/03/21 04:09:19 vgritsenko Exp $
   */
   public abstract class AbstractValidatorAction
   extends AbstractComplementaryConfigurableAction
  @@ -160,17 +160,17 @@
        * @param conf Configuration of all parameters as taken from the
        * description XML file.
        * @param params The map of parameters.
  -     * @param is_string Indicates wheter given param to validate is string
  +     * @param isString Indicates wheter given param to validate is string
        * (as taken from HTTP request for example) or wheteher it should be
        * regular instance of java.lang.Double, java.lang.Long, etc.
        * @return The validated parameter.
        */
  -    public ValidatorActionHelper validateParameter (String name, Configuration constraints,
  -            Configuration[] conf, Map params, boolean is_string) {
  +    public ValidatorActionHelper validateParameter(String name, Configuration constraints,
  +            Configuration[] conf, Map params, boolean isString) {
           String type = null;
           int i = 0;
   
  -        getLogger().debug ("VALIDATOR: validating parameter: " + name);
  +        getLogger().debug ("Validating parameter: " + name);
   
           /* try to find matching param description in conf tree */
           try {
  @@ -183,7 +183,7 @@
               }
   
               if (!found) {
  -                getLogger ().debug ("VALIDATOR: description for parameter "
  +                getLogger().debug("Description for parameter "
                           + name + " not found");
                   return null;
               }
  @@ -191,8 +191,7 @@
               /* check parameter's type */
               type = conf[i].getAttribute ("type");
           } catch (Exception e) {
  -            getLogger ().debug ("VALIDATOR: no type specified for parameter "
  -                    + name);
  +            getLogger().debug("No type specified for parameter " + name);
               return null;
           }
   
  @@ -200,16 +199,13 @@
            * Validation phase
            */
           if ("string".equals (type)) {
  -            return validateString (name, constraints,
  -                    conf[i],params, is_string);
  +            return validateString(name, constraints, conf[i], params);
           } else if ("long".equals (type)) {
  -            return validateLong (name, constraints,
  -                    conf[i], params, is_string);
  +            return validateLong(name, constraints, conf[i], params, isString);
           } else if ("double".equals (type)) {
  -            return validateDouble (name, constraints,
  -                    conf[i], params, is_string);
  +            return validateDouble(name, constraints, conf[i], params, isString);
           } else {
  -            getLogger().debug ("VALIDATOR: unknown type " + type
  +            getLogger().debug ("Unknown type " + type
                       + " specified for parameter " + name);
           }
           return null;
  @@ -219,25 +215,26 @@
        * Validates nullability and default value for given parameter. If given
        * constraints are not null they are validated as well.
        */
  -    private ValidatorActionHelper validateString (String name, Configuration constraints,
  -            Configuration conf, Map params, boolean is_string) {
  -        Object param = params.get (name);
  +    private ValidatorActionHelper validateString(String name, Configuration constraints,
  +            Configuration conf, Map params) {
  +        Object param = params.get(name);
           String value = null;
  -        String dflt = getDefault (conf, constraints);
  -        boolean nullable = getNullable (conf, constraints);
  +        String dflt = getDefault(conf, constraints);
  +        boolean nullable = getNullable(conf, constraints);
   
  -        getLogger().debug ("VALIDATOR: validating string parameter "
  -                + name + " (encoded in a string: " + is_string + ")");
  -        value = getStringValue (name, conf, param, is_string);
  +        getLogger().debug ("Validating string parameter " + name);
  +        try {
  +            value = getStringValue(param);
  +        } catch (Exception e) {
  +            // ClassCastException
  +            return new ValidatorActionHelper(value, ValidatorActionResult.ERROR);
  +        }
           if (value == null) {
  -            getLogger().debug ("VALIDATOR: string parameter "
  -                    + name + " is null");
  -            if ( !nullable ) {
  -                return new ValidatorActionHelper ( value,
  -                        ValidatorActionResult.ISNULL );
  +            getLogger().debug ("String parameter " + name + " is null");
  +            if (!nullable) {
  +                return new ValidatorActionHelper(value, ValidatorActionResult.ISNULL);
               } else {
  -                value = dflt;
  -                return new ValidatorActionHelper (value);
  +                return new ValidatorActionHelper(dflt);
               }
           }
           if (constraints != null) {
  @@ -255,10 +252,10 @@
   
               // Validate whether param is equal to constant
               if (!"".equals (eq)) {
  -                getLogger().debug ("VALIDATOR: string parameter "
  +                getLogger().debug ("String parameter "
                           + name + " should be equal to " + eq);
                   if (!value.equals (eq)) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
               }
  @@ -267,20 +264,20 @@
               // FIXME: take default value of param being compared with into
               // account?
               if (!"".equals (eqp)) {
  -                getLogger().debug ("VALIDATOR: string parameter "
  +                getLogger().debug ("String parameter "
                           + name + " should be equal to " + params.get (eqp));
                   if (!value.equals (params.get (eqp))) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
               }
   
               // Validate whether param length is at least of minimum length
               if (minlen != null) {
  -                getLogger().debug ("VALIDATOR: string parameter "
  +                getLogger().debug ("String parameter "
                           + name + " should be at least " + minlen + " characters long");
                   if ( value.length() < minlen.longValue() ) {
  -                    getLogger().debug ("VALIDATOR: and it is shorter (" +
  +                    getLogger().debug ("and it is shorter (" +
                               value.length() + ")" );
                       return new ValidatorActionHelper ( value, ValidatorActionResult.TOOSMALL);
                   }
  @@ -288,11 +285,11 @@
   
               // Validate whether param length is at most of maximum length
               if (maxlen != null) {
  -                getLogger().debug ("VALIDATOR: string parameter "
  +                getLogger().debug ("String parameter "
                           + name + " should be at most " + maxlen + " characters long");
   
                   if ( value.length() > maxlen.longValue() ) {
  -                    getLogger().debug ("VALIDATOR: and it is longer (" +
  +                    getLogger().debug ("and it is longer (" +
                               value.length() + ")" );
                       return new ValidatorActionHelper ( value, ValidatorActionResult.TOOLARGE);
                   }
  @@ -300,16 +297,16 @@
   
               // Validate wheter param matches regular expression
               if (!"".equals (regex)) {
  -                getLogger().debug ("VALIDATOR: string parameter " + name +
  +                getLogger().debug ("String parameter " + name +
                           " should match regexp \"" + regex + "\"" );
                   try {
                       RE r = new RE ( regex );
                       if ( !r.match(value) ) {
  -                        getLogger().debug("VALIDATOR: and it does not match");
  +                        getLogger().debug("and it does not match");
                           return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                       };
                   } catch ( RESyntaxException rese ) {
  -                    getLogger().error ("VALIDATOR: string parameter " + name +
  +                    getLogger().error ("String parameter " + name +
                               " regex error ", rese);
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
  @@ -323,29 +320,27 @@
        * Validates nullability and default value for given parameter. If given
        * constraints are not null they are validated as well.
        */
  -    private ValidatorActionHelper validateLong (String name, Configuration constraints,
  +    private ValidatorActionHelper validateLong(String name, Configuration constraints,
               Configuration conf, Map params, boolean is_string) {
           Object param = params.get (name);
           boolean nullable = getNullable (conf, constraints);
           Long value = null;
  -        Long dflt = null;
  -        {
  -            String tmp = getDefault (conf, constraints);
  -            if ( tmp != null ) dflt = Long.decode(tmp);
  -        }
  +        Long dflt = getLongValue(getDefault(conf, constraints), true);
   
  -        getLogger().debug ("VALIDATOR: validating long parameter "
  +        getLogger().debug ("Validating long parameter "
                   + name + " (encoded in a string: " + is_string + ")");
  -        value = getLongValue (name, conf, param, is_string);
  +        try {
  +            value = getLongValue(param, is_string);
  +        } catch (Exception e) {
  +            // Unable to parse long
  +            return new ValidatorActionHelper(value, ValidatorActionResult.ERROR);
  +        }
           if (value == null) {
  -            getLogger().debug ("VALIDATOR: long parameter "
  -                    + name + " is null");
  +            getLogger().debug ("Long parameter " + name + " is null");
               if (!nullable) {
  -                return new ValidatorActionHelper ( value,
  -                        ValidatorActionResult.ISNULL);
  +                return new ValidatorActionHelper(value, ValidatorActionResult.ISNULL);
               } else {
  -                value = dflt;
  -                return new ValidatorActionHelper (value);
  +                return new ValidatorActionHelper(dflt);
               }
           }
           if (constraints != null) {
  @@ -360,11 +355,11 @@
   
               // Validate whether param is equal to constant
               if (eq != null) {
  -                getLogger().debug ("VALIDATOR: long parameter "
  +                getLogger().debug ("Long parameter "
                           + name + " should be equal to " + eq);
   
                   if (!value.equals(eq)) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
               }
  @@ -373,39 +368,39 @@
               // FIXME: take default value of param being compared with into
               // account?
               if (!"".equals (eqp)) {
  -                getLogger().debug ("VALIDATOR: long parameter "
  +                getLogger().debug ("Long parameter "
                           + name + " should be equal to " + params.get (eqp));
                   // Request parameter is stored as string.
                   // Need to convert it beforehand.
                   try {
                       Long _eqp = new Long ( Long.parseLong((String) params.get(eqp)) );
                       if (!value.equals (_eqp)) {
  -                        getLogger().debug ("VALIDATOR: and it is not");
  -                        return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
  +                        getLogger().debug ("and it is not");
  +                        return new ValidatorActionHelper(value, ValidatorActionResult.NOMATCH);
                       }
                   } catch ( NumberFormatException nfe ) {
  -                    getLogger().debug("VALIDATOR: long parameter "+ name +": "+eqp+" is no long", nfe);
  -                    return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
  +                    getLogger().debug("Long parameter "+ name +": "+eqp+" is no long", nfe);
  +                    return new ValidatorActionHelper(value, ValidatorActionResult.NOMATCH);
                   }
               }
   
               // Validate wheter param is at least min
               if (min != null) {
  -                getLogger().debug ("VALIDATOR: long parameter "
  +                getLogger().debug ("Long parameter "
                           + name + " should be at least " + min);
   
                   if (min.compareTo(value)>0) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.TOOSMALL);
                   }
               }
   
               // Validate wheter param is at most max
               if (max != null) {
  -                getLogger().debug ("VALIDATOR: long parameter "
  +                getLogger().debug ("Long parameter "
                           + name + " should be at most " + max);
                   if (max.compareTo(value)<0) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.TOOLARGE);
                   }
               }
  @@ -417,29 +412,27 @@
        * Validates nullability and default value for given parameter. If given
        * constraints are not null they are validated as well.
        */
  -    private ValidatorActionHelper validateDouble (String name, Configuration constraints,
  +    private ValidatorActionHelper validateDouble(String name, Configuration constraints,
               Configuration conf, Map params, boolean is_string) {
  -        Object param = params.get (name);
  -        boolean nullable = getNullable (conf, constraints);
  +        Object param = params.get(name);
  +        boolean nullable = getNullable(conf, constraints);
           Double value = null;
  -        Double dflt = null;
  -        {
  -            String tmp = getDefault (conf, constraints);
  -            if ( tmp!=null ) dflt = Double.valueOf(tmp);
  -        }
  +        Double dflt = getDoubleValue(getDefault(conf, constraints), true);
   
  -        getLogger().debug ("VALIDATOR: validating double parameter "
  +        getLogger().debug ("Validating double parameter "
                   + name + " (encoded in a string: " + is_string + ")");
  -        value = getDoubleValue (name, conf, param, is_string);
  +        try {
  +            value = getDoubleValue(param, is_string);
  +        } catch (Exception e) {
  +            // Unable to parse double
  +            return new ValidatorActionHelper(value, ValidatorActionResult.ERROR);
  +        }
           if (value == null) {
  -            getLogger().debug ("VALIDATOR: double parameter "
  -                    + name + " is null");
  +            getLogger().debug ("double parameter " + name + " is null");
               if (!nullable) {
  -                return new ValidatorActionHelper ( value,
  -                        ValidatorActionResult.ISNULL);
  +                return new ValidatorActionHelper(value, ValidatorActionResult.ISNULL);
               } else {
  -                value = dflt;
  -                return new ValidatorActionHelper (value);
  +                return new ValidatorActionHelper(dflt);
               }
           }
           if (constraints != null) {
  @@ -454,11 +447,11 @@
   
               // Validate whether param is equal to constant
               if (eq != null) {
  -                getLogger().debug ("VALIDATOR: Double parameter "
  +                getLogger().debug ("Double parameter "
                           + name + " should be equal to " + eq);
   
                   if (!value.equals (eq)) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  +                    getLogger().debug ("and it is not");
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
               }
  @@ -467,39 +460,39 @@
               // FIXME: take default value of param being compared with into
               // account?
               if (!"".equals (eqp)) {
  -                getLogger().debug ("VALIDATOR: Double parameter "
  +                getLogger().debug ("Double parameter "
                           + name + " should be equal to " + params.get (eqp));
                   // Request parameter is stored as string.
                   // Need to convert it beforehand.
                   try {
                       Double _eqp = new Double ( Double.parseDouble((String) params.get(eqp)));
                       if (!value.equals (_eqp)) {
  -                        getLogger().debug ("VALIDATOR: and it is not");
  +                        getLogger().debug ("and it is not");
                           return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                       }
                   } catch ( NumberFormatException nfe ) {
  -                    getLogger().debug("VALIDATOR: Double parameter "+ name +": "+eqp+" is no double", nfe);
  +                    getLogger().debug("Double parameter "+ name +": "+eqp+" is no double", nfe);
                       return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                   }
               }
   
               // Validate wheter param is at least min
               if (min != null) {
  -                getLogger().debug ("VALIDATOR: Double parameter "
  +                getLogger().debug ("Double parameter "
                           + name + " should be at least " + min);
  -                if (0>value.compareTo(min)) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  -                    return new ValidatorActionHelper ( value, ValidatorActionResult.TOOSMALL);
  +                if (0 > value.compareTo(min)) {
  +                    getLogger().debug ("and it is not");
  +                    return new ValidatorActionHelper (value, ValidatorActionResult.TOOSMALL);
                   }
               }
   
               // Validate wheter param is at most max
               if (max != null) {
  -                getLogger().debug ("VALIDATOR: Double parameter "
  +                getLogger().debug ("Double parameter "
                           + name + " should be at most " + max);
                   if (0<value.compareTo(max)) {
  -                    getLogger().debug ("VALIDATOR: and it is not");
  -                    return new ValidatorActionHelper ( value, ValidatorActionResult.TOOLARGE);
  +                    getLogger().debug ("and it is not");
  +                    return new ValidatorActionHelper (value, ValidatorActionResult.TOOLARGE);
                   }
               }
           }
  @@ -508,83 +501,49 @@
   
       /**
        * Returns the parsed Double value.
  -     *
  -     * FIXME: is the name parameter needed? It is not used
        */
  -    private Double getDoubleValue (String name,
  -            Configuration conf, Object param, boolean is_string) {
  -        Double value = null;
  +    private Double getDoubleValue (Object param, boolean is_string)
  +            throws ClassCastException, NumberFormatException {
   
           /* convert param to double */
           if (is_string) {
  -            String tmp = (String)param;
  -            if (tmp != null && "".equals (tmp.trim ())) {
  -                tmp = null;
  -            }
  -            try {
  -                value = Double.valueOf (tmp);
  -            } catch (Exception e) {
  -                value = null;
  +            String tmp = getStringValue(param);
  +            if (tmp == null) {
  +                return null;
               }
  +            return new Double(tmp);
           } else {
  -            try {
  -                value = (Double)param;
  -            } catch (Exception e) {
  -                value = null;
  -            }
  +            return (Double)param;
           }
  -        return value;
       }
   
       /**
  -     * Returns the parsed Double value.
  -     *
  -     * FIXME:
  -     * Is the name parameter needed? it is not used.  */
  -    private Long getLongValue (String name,
  -            Configuration conf, Object param, boolean is_string) {
  -        Long value = null;
  +     * Returns the parsed Long value.
  +     */
  +    private Long getLongValue (Object param, boolean is_string)
  +            throws ClassCastException, NumberFormatException {
   
           /* convert param to long */
           if (is_string) {
  -            String tmp = (String)param;
  -            if (tmp != null && "".equals (tmp.trim ())) {
  -                tmp = null;
  -            }
  -            try {
  -                value = Long.decode (tmp);
  -            } catch (Exception e) {
  -                value = null;
  +            String tmp = getStringValue(param);
  +            if (tmp == null) {
  +                return null;
               }
  +            return Long.decode(tmp);
           } else {
  -            try {
  -                value = (Long)param;
  -            } catch (Exception e) {
  -                value = null;
  -            }
  +            return (Long)param;
           }
  -        return value;
       }
   
       /**
  -     * Checks whether param is nullable, and returns it, otherwise it
  -     * returns the parsed Double value.
  -     *
  -     * FIXME:
  -     * Is the "is_string" parameter really needed?
  -     * Is the "name" parameter really needed?
  -     * Neither are used */
  -    private String getStringValue (String name,
  -            Configuration conf, Object param, boolean is_string) {
  -        String value = null;
  +     * Returns string
  +     * @throws ClassCastException if param is not a String object
  +     */
  +    private String getStringValue(Object param) throws ClassCastException {
   
           /* convert param to string */
  -        try {
  -            value = (String)param;
  -            if (value != null && "".equals (value.trim ())) {
  -                value = null;
  -            }
  -        } catch (Exception e) {
  +        String value = (String)param;
  +        if (value != null && "".equals(value.trim())) {
               value = null;
           }
           return value;
  @@ -595,23 +554,15 @@
        * from given constraints, value present in constrints takes precedence,
        * false when attribute is not present in either of them.
        */
  -    private boolean getNullable (Configuration conf, Configuration cons) {
  +    private boolean getNullable(Configuration conf, Configuration cons) {
           /* check nullability */
           try {
  -            String tmp = cons.getAttribute ("nullable", "no");
  -            if ("yes".equals (tmp) || "true".equals (tmp)) {
  -                return true;
  -            }
  -        } catch (Exception e) {
  -            try {
  -                String tmp = conf.getAttribute ("nullable", "no");
  -                if ("yes".equals (tmp) || "true".equals (tmp)) {
  -                    return true;
  -                }
  -            } catch (Exception e1) {
  -            }
  +            String tmp = cons.getAttribute("nullable");
  +            return "yes".equals(tmp) || "true".equals(tmp);
  +        } catch (ConfigurationException e) {
  +            String tmp = conf.getAttribute("nullable", "no");
  +            return "yes".equals(tmp) || "true".equals(tmp);
           }
  -        return false;
       }
   
       /**
  @@ -619,22 +570,15 @@
        * Value present in constraints takes precedence, null is returned when no
        * default attribute is present in eiher of them.
        */
  -    private String getDefault (Configuration conf, Configuration cons) {
  +    private String getDefault(Configuration conf, Configuration cons) {
           String dflt = null;
           try {
  -            dflt = cons.getAttribute ("default", "");
  -            if ("".equals (dflt.trim ())) {
  -                return null;
  -            }
  -        } catch (Exception e) {
  -            try {
  -                dflt = conf.getAttribute ("default", "");
  -                if ("".equals (dflt.trim ())) {
  -                    return null;
  -                }
  -            } catch (Exception e1) {
  -                return null;
  -            }
  +            dflt = cons.getAttribute("default");
  +        } catch (ConfigurationException e) {
  +            dflt = conf.getAttribute("default", "");
  +        }
  +        if ("".equals(dflt.trim())) {
  +            dflt = null;
           }
           return dflt;
       }
  @@ -651,16 +595,15 @@
        * @return Parameter's value in <code>configuration</code> or
        * <code>dflt</code> if parameter is not set or couldn't be
        * converted to a <code>Long</code>
  -     * @see org.apache.avalon.Configuration.getParameterAsLong */
  -
  -    private Long getAttributeAsLong (Configuration conf, String name, Long dflt) {
  -        Long value = null;
  +     * @throws NumberFormatException if conversion fails
  +     */
  +    private Long getAttributeAsLong(Configuration conf, String name, Long dflt)
  +            throws NumberFormatException {
           try {
  -            value = new Long(conf.getAttributeAsLong(name));
  +            return new Long(conf.getAttribute(name));
           } catch (ConfigurationException e) {
  -            value = dflt;
  +            return dflt;
           }
  -        return value;
       }
   
       /**
  @@ -673,23 +616,14 @@
        * @return Parameter's value in <code>configuration</code> or
        * <code>dflt</code> if parameter is not set or couldn't be
        * converted to a <code>Double</code>
  -     * @see org.apache.avalon.Configuration.getParameterAsFloat
  +     * @throws NumberFormatException if conversion fails
        */
  -
  -    private Double getAttributeAsDouble (Configuration conf, String name, Double dflt) {
  -        Double value = null;
  -        String tmp = null;
  +    private Double getAttributeAsDouble(Configuration conf, String name, Double dflt)
  +            throws NumberFormatException {
           try {
  -            tmp = conf.getAttribute(name);
  -            try {
  -                value = new Double ( Double.parseDouble(tmp) );
  -            } catch ( NumberFormatException nfe ) {
  -                value = null;
  -            }
  +            return new Double(conf.getAttribute(name));
           } catch (ConfigurationException e) {
  -            value = dflt;
  +            return dflt;
           }
  -        return value;
       }
  -
   }
  
  
  
  1.8       +21 -24    xml-cocoon2/src/java/org/apache/cocoon/acting/FormValidatorAction.java
  
  Index: FormValidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/FormValidatorAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FormValidatorAction.java	22 Feb 2002 06:59:26 -0000	1.7
  +++ FormValidatorAction.java	21 Mar 2002 04:09:19 -0000	1.8
  @@ -105,7 +105,7 @@
    *
    * @author <a href="mailto:Martin.Man@seznam.cz">Martin Man</a>
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Id: FormValidatorAction.java,v 1.7 2002/02/22 06:59:26 cziegeler Exp $
  + * @version CVS $Id: FormValidatorAction.java,v 1.8 2002/03/21 04:09:19 vgritsenko Exp $
    */
   public class FormValidatorAction extends AbstractValidatorAction implements ThreadSafe
   {
  @@ -118,16 +118,17 @@
   
           /* check request validity */
           if (req == null) {
  -            getLogger().debug ("FORMVALIDATOR: no request object");
  +            getLogger().debug ("No request object");
               return null;
           }
   
  -    // read global parameter settings
  -    boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  -    if (this.settings.containsKey("reloadable"))
  -        reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  -    String constraints = (String) this.settings.get("constraint-set");
  -    // read local settings
  +        // read global parameter settings
  +        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  +        if (this.settings.containsKey("reloadable")) {
  +            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  +        }
  +
  +        // read local settings
           try {
               Configuration conf = this.getConfiguration (
                       parameters.getParameter ("descriptor", (String) this.settings.get("descriptor")), resolver,
  @@ -138,12 +139,13 @@
               Configuration[] csets = conf.getChildren ("constraint-set");
               HashMap actionMap = new HashMap ();
               HashMap resultMap = new HashMap ();
  -        boolean allOK = true;
  +            boolean allOK = true;
  +
               /*
                * old obsoleted method
                */
               if (!"".equals (valstr.trim ())) {
  -                getLogger().debug ("FORMVALIDATOR: validating parameters "
  +                getLogger().debug ("Validating parameters "
                           + "as specified via 'validate' parameter");
                   /* get list of params to be validated */
                   String[] rparams = Tokenizer.tokenize (valstr, ",", false);
  @@ -156,8 +158,7 @@
                   for (int i = 0; i < rparams.length; i ++) {
                       name = rparams[i];
                       if (name == null || "".equals (name.trim ())) {
  -                        getLogger().debug ("FORMVALIDATOR: "
  -                        + "wrong syntax of the 'validate' parameter");
  +                        getLogger().debug ("Wrong syntax of the 'validate' parameter");
                           return null;
                       }
                       name = name.trim ();
  @@ -168,8 +169,7 @@
                       result = validateParameter (name, null, desc,
                               params, true);
                       if (!result.isOK()) {
  -                        getLogger().debug ("FORMVALIDATOR: "
  -                                + "validation failed for parameter " + name);
  +                        getLogger().debug ("Validation failed for parameter " + name);
                           allOK = false;
                       }
                       actionMap.put (name, result.getObject());
  @@ -180,7 +180,7 @@
                * new set-based method
                */
               if (!"".equals (valsetstr.trim ())) {
  -                getLogger().debug ("FORMVALIDATOR: validating parameters "
  +                getLogger().debug ("Validating parameters "
                           + "from given constraint-set " + valsetstr);
                   Configuration cset = null;
                   String setname = null;
  @@ -194,7 +194,7 @@
                       }
                   }
                   if (!found) {
  -                    getLogger().debug ("FORMVALIDATOR: given set "
  +                    getLogger().debug ("Given set "
                               + valsetstr
                               + " does not exist in a description file");
                       return null;
  @@ -207,14 +207,14 @@
                   ValidatorActionHelper result = null;
                   String name = null;
                   HashMap params = new HashMap (set.length);
  -                getLogger().debug ("FORMVALIDATOR: given set "
  +                getLogger().debug ("Given set "
                           + valsetstr
                           + " contains " + set.length + " rules");
                   /* put required params into hash */
                   for (int i = 0; i < set.length; i ++) {
                       name = set[i].getAttribute ("name", "");
                       if ("".equals (name.trim ())) {
  -                        getLogger().debug ("FORMVALIDATOR: wrong syntax "
  +                        getLogger().debug ("Wrong syntax "
                                   + " of 'validate' children nr. " + i);
                           return null;
                       }
  @@ -226,8 +226,7 @@
                       result = validateParameter (name, set[i],
                               desc, params, true);
                       if (!result.isOK()) {
  -                        getLogger().debug ("FORMVALIDATOR: "
  -                                + "validation failed for parameter " + name);
  +                        getLogger().debug ("Validation failed for parameter " + name);
                           allOK = false;
                       }
                       actionMap.put (name, result.getObject());
  @@ -237,11 +236,9 @@
               if (!allOK) {
                   // if any validation failed return an empty map
                   actionMap = null;
  -                getLogger().debug ("FORMVALIDATOR: all form "
  -                                   + "params validated. An error occurred.");
  +                getLogger().debug ("All form params validated. An error occurred.");
               } else {
  -                getLogger().debug ("FORMVALIDATOR: all form "
  -                                   + "params successfully validated");
  +                getLogger().debug ("All form params successfully validated");
               }
               // store validation results in request attribute
               req.setAttribute(Constants.XSP_FORMVALIDATOR_PATH, resultMap);
  
  
  
  1.7       +7 -9      xml-cocoon2/src/java/org/apache/cocoon/acting/SessionIsValidAction.java
  
  Index: SessionIsValidAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionIsValidAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SessionIsValidAction.java	22 Feb 2002 06:59:26 -0000	1.6
  +++ SessionIsValidAction.java	21 Mar 2002 04:09:19 -0000	1.7
  @@ -68,10 +68,9 @@
    * seesion is still valid.
    *
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Id: SessionIsValidAction.java,v 1.6 2002/02/22 06:59:26 cziegeler Exp $
  + * @version CVS $Id: SessionIsValidAction.java,v 1.7 2002/03/21 04:09:19 vgritsenko Exp $
    */
  -
  -public class SessionIsValidAction extends AbstractValidatorAction implements ThreadSafe
  +public class SessionIsValidAction extends AbstractAction implements ThreadSafe
   {
       /**
        * Main invocation routine.
  @@ -81,22 +80,21 @@
           Request req = ObjectModelHelper.getRequest(objectModel);
   
           if (req == null) {
  -            getLogger ().debug ("SESSIONVALIDATOR: no request object");
  +            getLogger().debug("No request object");
               return null;
           }
   
           /* check session validity */
           Session session = req.getSession (false);
           if (session == null) {
  -            getLogger ().debug ("SESSIONVALIDATOR: no session object");
  +            getLogger().debug("No session object");
               return null;
           }
  -    if (!req.isRequestedSessionIdValid()) {
  -            getLogger ().debug ("SESSIONVALIDATOR: requested session id is invalid");
  +        if (!req.isRequestedSessionIdValid()) {
  +            getLogger().debug("Requested session id is invalid");
               return null;
           }
   
  -    return EMPTY_MAP;
  -
  +        return EMPTY_MAP;
       }
   }
  
  
  
  1.8       +18 -21    xml-cocoon2/src/java/org/apache/cocoon/acting/SessionValidatorAction.java
  
  Index: SessionValidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionValidatorAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SessionValidatorAction.java	22 Feb 2002 06:59:26 -0000	1.7
  +++ SessionValidatorAction.java	21 Mar 2002 04:09:19 -0000	1.8
  @@ -102,7 +102,7 @@
    * all validated parameters to the sitemap via {name} expression.
    *
    * @author <a href="mailto:Martin.Man@seznam.cz">Martin Man</a>
  - * @version CVS $Id: SessionValidatorAction.java,v 1.7 2002/02/22 06:59:26 cziegeler Exp $
  + * @version CVS $Id: SessionValidatorAction.java,v 1.8 2002/03/21 04:09:19 vgritsenko Exp $
    */
   public class SessionValidatorAction extends AbstractValidatorAction implements ThreadSafe
   {
  @@ -113,21 +113,22 @@
               Parameters parameters) throws Exception {
           Request req = ObjectModelHelper.getRequest(objectModel);
           if (req == null) {
  -            getLogger ().debug ("SESSIONVALIDATOR: no request object");
  +            getLogger ().debug ("No request object");
               return null;
           }
   
           /* check session validity */
           Session session = req.getSession (false);
           if (session == null) {
  -            getLogger ().debug ("SESSIONVALIDATOR: no session object");
  +            getLogger ().debug ("No session object");
               return null;
           }
   
  -    // read global parameter settings
  -    boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  -    if (this.settings.containsKey("reloadable"))
  -        reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  +        // read global parameter settings
  +        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
  +        if (this.settings.containsKey("reloadable")) {
  +            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
  +        }
   
           try {
               Configuration conf = this.getConfiguration (
  @@ -144,7 +145,7 @@
                * old obsoleted method
                */
               if (valstr != null && !"".equals (valstr.trim ())) {
  -                getLogger ().debug ("SESSIONVALIDATOR: validating parameters "
  +                getLogger ().debug ("Validating parameters "
                           + "as specified via 'validate' parameter");
                   /* get list of params to be validated */
                   String[] rparams = Tokenizer.tokenize (valstr, ",", false);
  @@ -157,8 +158,7 @@
                   for (int i = 0; i < rparams.length; i ++) {
                       name = rparams[i];
                       if (name == null || "".equals (name.trim ())) {
  -                        getLogger ().debug ("SESSIONVALIDATOR: "
  -                        + "wrong syntax of the 'validate' parameter");
  +                        getLogger ().debug ("Wrong syntax of the 'validate' parameter");
                           return null;
                       }
                       name = name.trim ();
  @@ -169,8 +169,7 @@
                       result = validateParameter (name, null, desc,
                               params, false);
                       if (!result.isOK()) {
  -                        getLogger().debug ("SESSIONVALIDATOR: "
  -                                + "validation failed for parameter " + name);
  +                        getLogger().debug ("Validation failed for parameter " + name);
                           return null;
                       }
                       session.setAttribute (name, result.getObject());
  @@ -181,7 +180,7 @@
                * new set-based method
                */
               if (valsetstr != null && !"".equals (valsetstr.trim ())) {
  -                getLogger ().debug ("SESSIONVALIDATOR: validating parameters "
  +                getLogger ().debug ("Validating parameters "
                           + "from given constraint-set " + valsetstr);
                   Configuration cset = null;
                   String setname = null;
  @@ -195,7 +194,7 @@
                       }
                   }
                   if (!found) {
  -                    getLogger ().debug ("SESSIONVALIDATOR: given set "
  +                    getLogger ().debug ("Given set "
                               + valsetstr
                               + " does not exist in a description file");
                       return null;
  @@ -208,14 +207,14 @@
                   ValidatorActionHelper result = null;
                   String name = null;
                   HashMap params = new HashMap (set.length);
  -                getLogger ().debug ("SESSIONVALIDATOR: given set "
  +                getLogger ().debug ("Given set "
                           + valsetstr
                           + " contains " + set.length + " rules");
                   /* put required params into hash */
                   for (int i = 0; i < set.length; i ++) {
                       name = set[i].getAttribute ("name", "");
                       if ("".equals (name.trim ())) {
  -                        getLogger ().debug ("SESSIONVALIDATOR: wrong syntax "
  +                        getLogger ().debug ("Wrong syntax "
                                   + " of 'validate' children nr. " + i);
                           return null;
                       }
  @@ -224,19 +223,17 @@
                   }
                   for (int i = 0; i < set.length; i ++) {
                       name = set[i].getAttribute ("name", null);
  -                    result = validateParameter (name, set[i],
  +                    result = validateParameter(name, set[i],
                               desc, params, false);
                       if (!result.isOK()) {
  -                        getLogger().debug ("SESSIONVALIDATOR: "
  -                                + "validation failed for parameter " + name);
  +                        getLogger().debug("Validation failed for parameter " + name);
                           return null;
                       }
                       session.setAttribute (name, result.getObject());
                       actionMap.put (name, result.getObject());
                   }
               }
  -            getLogger().debug ("SESSIONVALIDATOR: all session "
  -                    + "params validated");
  +            getLogger().debug("All session params validated");
               return Collections.unmodifiableMap (actionMap);
           } catch (Exception e) {
               getLogger().debug ("exception: ", e);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org