dwinterfeldt    02/02/25 21:03:27

  Modified:    contrib/validator build.properties.sample build.xml
               contrib/validator/src/example/org/apache/struts/validator/example
                        MultiRegistrationAction.java
                        RegistrationAction.java TypeAction.java
               contrib/validator/src/share/org/apache/struts/validator/action
                        ValidatorActionForm.java ValidatorForm.java
                        ValidatorServlet.java
               contrib/validator/src/share/org/apache/struts/validator/util
                        StrutsValidator.java
  Added:       contrib/validator .cvsignore
  Log:
  Switched to Commons Logging.
  
  Revision  Changes    Path
  1.5       +4 -0      jakarta-struts/contrib/validator/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/validator/build.properties.sample,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build.properties.sample   15 Jan 2002 06:24:59 -0000      1.4
  +++ build.properties.sample   26 Feb 2002 05:03:27 -0000      1.5
  @@ -21,6 +21,10 @@
   # from the Jakarta Commons project.
   commons-logging.jar=e:/software/commons-logging/commons-logging.jar
   
  +# The JAR file containing version 1.1 (or later) of the Logging package
  +# from the Jakarta Log4J core.
  +log4j-core.jar=d:/java/lib/log4j-core.jar
  +
   struts.jar=d:/office/struts/jakarta-struts/target/library/struts.jar
   struts.tlds=d:/office/struts/jakarta-struts/target/library
   
  
  
  
  1.6       +17 -0     jakarta-struts/contrib/validator/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/validator/build.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.xml 15 Jan 2002 06:24:59 -0000      1.5
  +++ build.xml 26 Feb 2002 05:03:27 -0000      1.6
  @@ -43,6 +43,7 @@
        <pathelement path="${commons-beanutils.jar}"/>
        <pathelement path="${commons-collections.jar}"/>
        <pathelement path="${commons-digester.jar}"/>
  +     <pathelement path="${commons-logging.jar}"/>
        <pathelement path="${regexp.jar}"/>
     </path>
   
  @@ -109,6 +110,7 @@
       <copy file="${commons-collections.jar}" todir="lib"/>
       <copy file="${commons-digester.jar}" todir="lib"/>
       <copy file="${commons-logging.jar}" todir="lib"/>
  +    <copy file="${log4j-core.jar}" todir="lib"/>
       <copy file="${regexp.jar}" todir="lib"/>
       
       <!-- default validation rules -->
  @@ -178,6 +180,21 @@
            <include name="**/**" />
         </fileset>
       </copy>
  +  </target>
  +
  +  <!-- Clean -->
  +  <target name="clean" description="Delete build, dist, and doc directories">
  +     <delete dir="${build}" />
  +     <delete dir="${target}" />
  +     <delete dir="${lib}" />
  +     <delete dir="${webapps}" />
  +     <delete dir="${build.javadocs}" />
  +
  +     <delete dir="${dist}/${src}"/>
  +     <delete dir="${dist}/${web}"/>
  +     <delete dir="${dist}/${webapps}"/>
  +     <delete dir="${dist}/${docs}"/>
  +     <delete file="${dist}/${validator.jar}"/>
     </target>
         
   </project>
  
  
  
  1.1                  jakarta-struts/contrib/validator/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build
  lib
  target
  webapps
  build.properties
  dist/docs
  dist/src
  dist/web
  dist/webapps
  dist/struts-validator.jar
  
  
  
  1.2       +10 -26    
jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/MultiRegistrationAction.java
  
  Index: MultiRegistrationAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/MultiRegistrationAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultiRegistrationAction.java      15 Jan 2002 03:48:05 -0000      1.1
  +++ MultiRegistrationAction.java      26 Feb 2002 05:03:27 -0000      1.2
  @@ -61,6 +61,8 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
  @@ -77,6 +79,11 @@
   */
   public final class MultiRegistrationAction extends Action {
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +
   
       /**
        * Process the specified HTTP request, and create the corresponding HTTP
  @@ -108,7 +115,9 @@
        
        // Was this transaction cancelled?
        if (isCancelled(request)) {
  -         log(" " + mapping.getAttribute() + " - Registration transaction was 
cancelled");
  +         if (log.isInfoEnabled()) {
  +            log.info(" " + mapping.getAttribute() + " - Registration transaction 
was cancelled");
  +         }
            
            removeFormBean(mapping, request);
   
  @@ -131,31 +140,6 @@
        }
        
        return mapping.findForward("input1");   
  -    }
  -
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -    */
  -    protected void log(String message) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message);
  -    }
  -    
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -     * @param        throwable       Throwable error or exception
  -    */
  -    protected void log(String message, Throwable throwable) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message, throwable);
       }
   
       /**
  
  
  
  1.2       +9 -26     
jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/RegistrationAction.java
  
  Index: RegistrationAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/RegistrationAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegistrationAction.java   15 Jan 2002 03:48:05 -0000      1.1
  +++ RegistrationAction.java   26 Feb 2002 05:03:27 -0000      1.2
  @@ -61,6 +61,8 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
  @@ -75,6 +77,10 @@
   */
   public final class RegistrationAction extends Action {
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
        * Process the specified HTTP request, and create the corresponding HTTP
  @@ -106,7 +112,9 @@
        
        // Was this transaction cancelled?
        if (isCancelled(request)) {
  -         log(" " + mapping.getAttribute() + " - Registration transaction was 
cancelled");
  +         if (log.isInfoEnabled()) {
  +            log.info(" " + mapping.getAttribute() + " - Registration transaction 
was cancelled");
  +         }
            
            removeFormBean(mapping, request);
   
  @@ -114,31 +122,6 @@
        }
   
        return mapping.findForward("success");
  -    }
  -
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -    */
  -    protected void log(String message) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message);
  -    }
  -    
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -     * @param        throwable       Throwable error or exception
  -    */
  -    protected void log(String message, Throwable throwable) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message, throwable);
       }
   
       /**
  
  
  
  1.2       +9 -26     
jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/TypeAction.java
  
  Index: TypeAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/example/org/apache/struts/validator/example/TypeAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeAction.java   15 Jan 2002 03:48:05 -0000      1.1
  +++ TypeAction.java   26 Feb 2002 05:03:27 -0000      1.2
  @@ -61,6 +61,8 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
  @@ -75,6 +77,10 @@
   */
   public final class TypeAction extends Action {
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
        * Process the specified HTTP request, and create the corresponding HTTP
  @@ -106,7 +112,9 @@
        
        // Was this transaction cancelled?
        if (isCancelled(request)) {
  -         log(" " + mapping.getAttribute() + " - Type transaction was cancelled");
  +         if (log.isInfoEnabled()) {
  +            log.info(" " + mapping.getAttribute() + " - Type transaction was 
cancelled");
  +         }
            
            removeFormBean(mapping, request);
   
  @@ -114,31 +122,6 @@
        }
   
        return mapping.findForward("success");  
  -    }
  -
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -    */
  -    protected void log(String message) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message);
  -    }
  -    
  -    /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to 
the 
  -     * servlet log file.
  -     *
  -     * @param        message         String that describes the error or exception
  -     * @param        throwable       Throwable error or exception
  -    */
  -    protected void log(String message, Throwable throwable) {
  -       if (servlet.getDebug() >= 1)
  -           servlet.log(message, throwable);
       }
   
       /**
  
  
  
  1.2       +8 -1      
jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorActionForm.java
  
  Index: ValidatorActionForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorActionForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidatorActionForm.java  15 Jan 2002 03:48:06 -0000      1.1
  +++ ValidatorActionForm.java  26 Feb 2002 05:03:27 -0000      1.2
  @@ -59,6 +59,8 @@
   import java.util.Locale;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionMapping;
  @@ -82,6 +84,11 @@
   public class ValidatorActionForm extends ValidatorForm implements Serializable {
   
       /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +
  +    /**
        * Validate the properties that have been set from this HTTP request,
        * and return an <code>ActionErrors</code> object that encapsulates any
        * validation errors that have been found.  If no errors are found, return
  @@ -100,7 +107,7 @@
        try {
           validator.validate();
           } catch (ValidatorException e) {
  -        log("ValidatorActionForm::validate() - " + e.getMessage(), e);
  +        log.error("ValidatorActionForm::validate() - " + e.getMessage(), e);
        }
   
           return errors;
  
  
  
  1.2       +9 -1      
jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorForm.java
  
  Index: ValidatorForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidatorForm.java        15 Jan 2002 03:48:06 -0000      1.1
  +++ ValidatorForm.java        26 Feb 2002 05:03:27 -0000      1.2
  @@ -59,6 +59,8 @@
   import java.util.Locale;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionMapping;
  @@ -82,6 +84,12 @@
   */
   
   public class ValidatorForm extends ActionForm implements Serializable {
  +
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +
       /**
        * Used to indicate the current page of a multi-page form.
       */
  @@ -120,7 +128,7 @@
        try {
           validator.validate();
           } catch (ValidatorException e) {
  -        log("ValidatorForm::validate() - " + e.getMessage(), e);
  +        log.error("ValidatorForm::validate() - " + e.getMessage(), e);
        }
   
           return errors;
  
  
  
  1.3       +27 -12    
jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorServlet.java
  
  Index: ValidatorServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/action/ValidatorServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValidatorServlet.java     15 Jan 2002 06:24:59 -0000      1.2
  +++ ValidatorServlet.java     26 Feb 2002 05:03:27 -0000      1.3
  @@ -63,6 +63,8 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.commons.validator.ValidatorResources;
   import org.apache.commons.validator.ValidatorResourcesInitializer;
   
  @@ -74,6 +76,16 @@
    */
   
   public class ValidatorServlet extends HttpServlet {
  +    
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +
  +
  +    /**
  +     * Application scope key that <code>ValidatorResources</code> is stored under.
  +    */
       public final static String VALIDATOR_KEY = 
"org.apache.struts.validator.action.VALIDATOR";
   
       /**
  @@ -106,8 +118,9 @@
        */
       public void destroy() {
   
  -     if (debug >= 1)
  -         log("Destroying ValidatorServlet");
  +     if (log.isDebugEnabled()) {
  +         log.debug("Destroying ValidatorServlet");
  +     }
   
           destroyMapping();
   
  @@ -183,8 +196,9 @@
        */
       public void reload() throws IOException, ServletException {
   
  -        if (debug >= 1)
  -            log("Reloading ValidatorServlet");
  +        if (log.isDebugEnabled()) {
  +            log.debug("Reloading ValidatorServlet");
  +        }
   
   
           // Restart from our confirmation files
  @@ -215,8 +229,8 @@
        if (value != null) {
           configRules = value;
        }
  -     if (debug >= 1) {
  -        log("Loading validation rules file from '" + configRules + "'");
  +     if (log.isDebugEnabled()) {
  +        log.debug("Loading validation rules file from '" + configRules + "'");
        }
   
        InputStream input = null;
  @@ -230,10 +244,10 @@
                 // until second file is loaded
                 ValidatorResourcesInitializer.initialize(resources, bis, false);
              } catch (Exception e) {
  -              log("ValidatorServlet::initMapping - " + e.getMessage(), debug);
  +              log.error("ValidatorServlet::initMapping - " + e.getMessage(), e);
              }
        } else {
  -        log("Skipping validation rules file from '" + configRules + "'.  No stream 
could be opened.");       
  +        log.error("Skipping validation rules file from '" + configRules + "'.  No 
stream could be opened."); 
        }
   
   
  @@ -241,8 +255,8 @@
        if (value != null) {
           config = value;
        }
  -     if (debug >= 1) {
  -        log("Loading validation file from '" + config + "'");
  +     if (log.isDebugEnabled()) {
  +        log.debug("Loading validation file from '" + config + "'");
        }
   
        input = getServletContext().getResourceAsStream(config);
  @@ -256,7 +270,7 @@
              // pass in true so resources are processed
              ValidatorResourcesInitializer.initialize(resources, bis, true);
           } catch (Exception e) {
  -           log("ValidatorServlet::initMapping - " + e.getMessage(), debug);
  +           log.error("ValidatorServlet::initMapping - " + e.getMessage(), e);
           }
   
       }
  @@ -295,8 +309,9 @@
        */
       public void log(String message, int level) {
   
  -        if (debug >= level)
  +        if (debug >= level) {
               log(message);
  +        }
   
       }
   
  
  
  
  1.2       +11 -4     
jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/util/StrutsValidator.java
  
  Index: StrutsValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/validator/src/share/org/apache/struts/validator/util/StrutsValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StrutsValidator.java      15 Jan 2002 03:48:06 -0000      1.1
  +++ StrutsValidator.java      26 Feb 2002 05:03:27 -0000      1.2
  @@ -59,12 +59,14 @@
   import java.util.Locale;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  -import org.apache.struts.action.ActionErrors;
  -import org.apache.regexp.RESyntaxException;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.commons.validator.Field;
   import org.apache.commons.validator.GenericValidator;
   import org.apache.commons.validator.ValidatorAction;
   import org.apache.commons.validator.ValidatorUtil;
  +import org.apache.regexp.RESyntaxException;
  +import org.apache.struts.action.ActionErrors;
   
   
   /**
  @@ -76,6 +78,11 @@
   public class StrutsValidator implements Serializable {
   
       /**
  +     * Commons Logging instance.
  +    */
  +    private static Log LOG = LogSource.getInstance(StrutsValidator.class.getName());
  +    
  +    /**
        * <p>Checks if the field isn't null and length of the field is greater than 
zero not 
        * including whitespace.</p>
        *
  @@ -137,9 +144,9 @@
                     return true;       
                  }
            } catch (RESyntaxException e) {
  -            StrutsValidatorUtil.log(application, "Validator::validateMask() - " + 
e.getMessage(), e);
  +            LOG.error(e.getMessage(), e);
            } catch (Exception e) {
  -            StrutsValidatorUtil.log(application, "Validator::validateMask() - " + 
e.getMessage(), e);
  +            LOG.error(e.getMessage(), e);
            }
            }
            
  
  
  

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

Reply via email to