You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2001/08/03 09:24:00 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/intake/model FileItemField.java

mpoeschl    01/08/03 00:24:00

  Added:       src/java/org/apache/turbine/services/intake/validator Tag:
                        T_2_1_BRANCH FileValidator.java
                        InitableByConstraintMap.java
               src/java/org/apache/turbine/services/intake/model Tag:
                        T_2_1_BRANCH FileItemField.java
  Log:
  add some missing files
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.1   +54 -54    jakarta-turbine/src/java/org/apache/turbine/services/intake/validator/FileValidator.java
  
  Index: FileValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/validator/FileValidator.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- FileValidator.java	2001/08/02 05:59:41	1.9
  +++ FileValidator.java	2001/08/03 07:23:59	1.9.2.1
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -57,20 +57,20 @@
   import java.lang.reflect.Method;
   import java.util.Map;
   import org.apache.regexp.RE;
  -import org.apache.torque.om.Retrievable;
  +import org.apache.turbine.om.Retrievable;
   import org.apache.turbine.services.intake.TurbineIntake;
   import org.apache.turbine.services.intake.xmlmodel.Rule;
   import org.apache.turbine.services.intake.xmlmodel.XmlField;
   import org.apache.turbine.services.intake.xmlmodel.XmlGroup;
  -import org.apache.fulcrum.Log;
  -import org.apache.turbine.ParameterParser;
  -import org.apache.turbine.RunData;
  -import org.apache.fulcrum.ServiceException;
  -import org.apache.fulcrum.upload.FileItem;
  +import org.apache.turbine.util.Log;
  +import org.apache.turbine.util.ParameterParser;
  +import org.apache.turbine.util.RunData;
  +import org.apache.turbine.util.TurbineException;
  +import org.apache.turbine.util.upload.FileItem;
   
   /**
    * A validator that will compare a testValue against the following
  - * constraints: 
  + * constraints:
    * <table>
    * <tr><th>Name</th><th>Valid Values</th><th>Default Value</th></tr>
    * <tr><td>required</td><td>true|false</td><td>false</td></tr>
  @@ -79,10 +79,10 @@
    * <tr><td>maxLength</td><td>integer</td><td>&nbsp;</td></tr>
    * </table>
    *
  - * This validator can serve as the base class for more specific validators 
  + * This validator can serve as the base class for more specific validators
    *
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @version $Id: FileValidator.java,v 1.9 2001/08/02 05:59:41 jon Exp $
  + * @version $Id: FileValidator.java,v 1.9.2.1 2001/08/03 07:23:59 mpoeschl Exp $
    */
   public class FileValidator
       implements Validator, InitableByConstraintMap
  @@ -90,22 +90,22 @@
       protected boolean required;
       protected String requiredMessage;
       protected RE mask;
  -    protected String maskMessage; 
  +    protected String maskMessage;
       protected int minLength;
  -    protected String minLengthMessage; 
  +    protected String minLengthMessage;
       protected int maxLength;
  -    protected String maxLengthMessage; 
  +    protected String maxLengthMessage;
   
       protected String message;
   
       public FileValidator(Map paramMap)
  -        throws ServiceException
  -    {        
  +        throws TurbineException
  +    {
           init(paramMap);
       }
   
       public FileValidator()
  -    {        
  +    {
       }
   
   
  @@ -115,26 +115,26 @@
        *
        * @param paramMap a <code>Map</code> of <code>Rule</code>'s
        * containing constraints on the input.
  -     * @exception ServiceException if an error occurs
  +     * @exception TurbineException if an error occurs
        */
       public void init(Map paramMap)
  -        throws ServiceException
  +        throws TurbineException
       {
           minLength = 0;
  -        minLengthMessage = null;            
  +        minLengthMessage = null;
           maxLength = 0;
           maxLengthMessage = null;
   
           Constraint constraint = (Constraint)paramMap.get("minLength");
  -        if ( constraint != null ) 
  +        if ( constraint != null )
           {
               String param = constraint.getValue();
               minLength = Integer.parseInt(param);
               minLengthMessage = constraint.getMessage();
           }
   
  -        constraint = (Constraint)paramMap.get("maxLength"); 
  -        if ( constraint != null ) 
  +        constraint = (Constraint)paramMap.get("maxLength");
  +        if ( constraint != null )
           {
               String param = constraint.getValue();
               maxLength = Integer.parseInt(param);
  @@ -203,12 +203,12 @@
       {
           message = null;
   
  -        if ( (!required && minLength == 0) 
  +        if ( (!required && minLength == 0)
                && ( testValue == null || testValue.getSize() == 0) )
           {
               return;
           }
  -        else if ( required 
  +        else if ( required
                     && ( testValue == null || testValue.getSize() == 0))
           {
               message = requiredMessage;
  @@ -217,9 +217,9 @@
   
           // allow subclasses first chance at validation
           doAssertValidity(testValue);
  -        
  -        if ( minLength > 0 && testValue.getSize() < minLength ) 
  -        {        
  +
  +        if ( minLength > 0 && testValue.getSize() < minLength )
  +        {
               message = minLengthMessage;
               throw new ValidationException(minLengthMessage);
           }
  @@ -227,7 +227,7 @@
           {
               message = maxLengthMessage;
               throw new ValidationException(maxLengthMessage);
  -        }        
  +        }
       }
   
       /**
  @@ -237,7 +237,7 @@
        */
       public String getMessage()
       {
  -        if ( message == null ) 
  +        if ( message == null )
           {
               return "";
           }
  @@ -261,106 +261,106 @@
        * Get the value of required.
        * @return value of required.
        */
  -    public boolean isRequired() 
  +    public boolean isRequired()
       {
           return required;
       }
  -    
  +
       /**
        * Set the value of required.
        * @param v  Value to assign to required.
        */
  -    public void setRequired(boolean  v) 
  +    public void setRequired(boolean  v)
       {
           this.required = v;
       }
  -    
  +
       /**
        * Get the value of requiredMessage.
        * @return value of requiredMessage.
        */
  -    public String getRequiredMessage() 
  +    public String getRequiredMessage()
       {
           return requiredMessage;
       }
  -    
  +
       /**
        * Set the value of requiredMessage.
        * @param v  Value to assign to requiredMessage.
        */
  -    public void setRequiredMessage(String  v) 
  +    public void setRequiredMessage(String  v)
       {
           this.requiredMessage = v;
       }
  -    
  +
       /**
        * Get the value of minLength.
        * @return value of minLength.
        */
  -    public int getMinLength() 
  +    public int getMinLength()
       {
           return minLength;
       }
  -    
  +
       /**
        * Set the value of minLength.
        * @param v  Value to assign to minLength.
        */
  -    public void setMinLength(int  v) 
  +    public void setMinLength(int  v)
       {
           this.minLength = v;
       }
  -        
  +
       /**
        * Get the value of minLengthMessage.
        * @return value of minLengthMessage.
        */
  -    public String getMinLengthMessage() 
  +    public String getMinLengthMessage()
       {
           return minLengthMessage;
       }
  -    
  +
       /**
        * Set the value of minLengthMessage.
        * @param v  Value to assign to minLengthMessage.
        */
  -    public void setMinLengthMessage(String  v) 
  +    public void setMinLengthMessage(String  v)
       {
           this.minLengthMessage = v;
       }
  -    
  +
       /**
        * Get the value of maxLength.
        * @return value of maxLength.
        */
  -    public int getMaxLength() 
  +    public int getMaxLength()
       {
           return maxLength;
       }
  -    
  +
       /**
        * Set the value of maxLength.
        * @param v  Value to assign to maxLength.
        */
  -    public void setMaxLength(int  v) 
  +    public void setMaxLength(int  v)
       {
           this.maxLength = v;
       }
  -    
  +
       /**
        * Get the value of maxLengthMessage.
        * @return value of maxLengthMessage.
        */
  -    public String getMaxLengthMessage() 
  +    public String getMaxLengthMessage()
       {
           return maxLengthMessage;
       }
  -    
  +
       /**
        * Set the value of maxLengthMessage.
        * @param v  Value to assign to maxLengthMessage.
        */
  -    public void setMaxLengthMessage(String  v) 
  +    public void setMaxLengthMessage(String  v)
       {
           this.maxLengthMessage = v;
       }
  
  
  
  1.6.2.1   +9 -9      jakarta-turbine/src/java/org/apache/turbine/services/intake/validator/InitableByConstraintMap.java
  
  Index: InitableByConstraintMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/validator/InitableByConstraintMap.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- InitableByConstraintMap.java	2001/08/01 15:34:17	1.6
  +++ InitableByConstraintMap.java	2001/08/03 07:24:00	1.6.2.1
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -55,25 +55,25 @@
    */
   
   import java.util.Map;
  -import org.apache.fulcrum.ServiceException;
  +import org.apache.turbine.util.TurbineException;
   
   /**
    * This interface marks a bean/class that can have its properties set
    * by values in a Map.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: InitableByConstraintMap.java,v 1.6 2001/08/01 15:34:17 jvanzyl Exp $
  + * @version $Id: InitableByConstraintMap.java,v 1.6.2.1 2001/08/03 07:24:00 mpoeschl Exp $
    */
   public interface InitableByConstraintMap
  -{ 
  +{
       /**
        * Extract the relevant parameters from the constraints listed
        * in <input-param> tags within the intake.xml file.
        *
        * @param inputParameters a <code>Map</code> of <code>Constraint</code>'s
        * containing rules and error messages.
  -     * @exception ServiceException if an error occurs
  +     * @exception TurbineException if an error occurs
        */
       public void init(Map inputParameters)
  -        throws ServiceException;
  +        throws TurbineException;
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.1   +32 -32    jakarta-turbine/src/java/org/apache/turbine/services/intake/model/FileItemField.java
  
  Index: FileItemField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/FileItemField.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- FileItemField.java	2001/08/01 15:34:16	1.8
  +++ FileItemField.java	2001/08/03 07:24:00	1.8.2.1
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -57,15 +57,15 @@
   import java.util.Vector;
   import org.apache.turbine.services.intake.xmlmodel.Rule;
   import org.apache.turbine.services.intake.xmlmodel.XmlField;
  -import org.apache.turbine.ParameterParser;
  -import org.apache.turbine.RunData;
  +import org.apache.turbine.util.ParameterParser;
  +import org.apache.turbine.util.RunData;
   import org.apache.turbine.services.intake.validator.Validator;
   import org.apache.turbine.services.intake.validator.FileValidator;
   // import org.apache.turbine.services.intake.validator.InitableByConstraintMap;
   import org.apache.turbine.services.intake.validator.ValidationException;
   import org.apache.turbine.services.intake.validator.Constraint;
  -import org.apache.fulcrum.upload.FileItem;
  -import org.apache.fulcrum.ServiceException;
  +import org.apache.turbine.util.upload.FileItem;
  +import org.apache.turbine.util.TurbineException;
   
   /**  */
   public class FileItemField extends Field
  @@ -76,7 +76,7 @@
       {
           super(field, group);
       }
  -    
  +
       /**
        * A suitable validator.
        *
  @@ -88,28 +88,28 @@
       }
   
       /**
  -     * Method called when this field (the group it belongs to) is 
  +     * Method called when this field (the group it belongs to) is
        * pulled from the pool.  The request data is searched to determine
        * if a value has been supplied for this field.  if so, the value
        * is validated.
        *
        * @param data a <code>RunData</code> value
        * @return a <code>Field</code> value
  -     * @exception ServiceException if an error occurs
  +     * @exception TurbineException if an error occurs
        */
       public Field init(RunData data)
  -        throws ServiceException
  +        throws TurbineException
       {
           this.data = data;
           valid_flag = true;
  -        
  +
           ParameterParser pp = data.getParameters();
           if ( pp.containsKey(getKey()) )
           {
               set_flag = true;
               validate(pp);
           }
  -        
  +
           initialized = true;
           return this;
       }
  @@ -118,21 +118,21 @@
        * Compares request data with constraints and sets the valid flag.
        */
       protected boolean validate(ParameterParser pp)
  -    //    throws ServiceException
  -    {        
  -        if ( isMultiValued  ) 
  +    //    throws TurbineException
  +    {
  +        if ( isMultiValued  )
           {
               FileItem[] ss = pp.getFileItems(getKey());
               // this definition of not set might need refined.  But
               // not sure the situation will arise.
  -            if ( ss.length == 0 ) 
  +            if ( ss.length == 0 )
               {
                   set_flag = false;
               }
  -            
  -            if ( validator != null ) 
  +
  +            if ( validator != null )
               {
  -                for (int i=0; i<ss.length; i++) 
  +                for (int i=0; i<ss.length; i++)
                   {
                       try
                       {
  @@ -145,40 +145,40 @@
                   }
               }
   
  -            if ( set_flag && valid_flag ) 
  +            if ( set_flag && valid_flag )
               {
                   doSetValue(pp);
  -            }                    
  +            }
   
           }
  -        else 
  +        else
           {
               FileItem s = pp.getFileItem(getKey());
  -            if ( s == null || s.getSize() == 0 ) 
  +            if ( s == null || s.getSize() == 0 )
               {
                   set_flag = false;
               }
   
  -            if ( validator != null ) 
  +            if ( validator != null )
               {
                   try
                   {
                       ((FileValidator)validator).assertValidity(s);
   
  -                    if ( set_flag ) 
  +                    if ( set_flag )
                       {
                           doSetValue(pp);
  -                    }                    
  +                    }
                   }
                   catch (ValidationException ve)
                   {
                       setMessage(ve.getMessage());
                   }
               }
  -            else if ( set_flag ) 
  +            else if ( set_flag )
               {
                   doSetValue(pp);
  -            }                    
  +            }
           }
   
           return valid_flag;
  @@ -189,11 +189,11 @@
        */
       protected void doSetValue(ParameterParser pp)
       {
  -        if ( isMultiValued  ) 
  +        if ( isMultiValued  )
           {
               setTestValue(pp.getFileItems(getKey()));
           }
  -        else 
  +        else
           {
               setTestValue(pp.getFileItem(getKey()));
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org