You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/01/04 05:02:11 UTC

svn commit: r124065 - /struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java

Author: craigmcc
Date: Mon Jan  3 20:02:09 2005
New Revision: 124065

URL: http://svn.apache.org/viewcvs?view=rev&rev=124065
Log:
Correct matching order for filter tests to be more generally useful.

Modified:
   struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java

Modified: struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java
Url: http://svn.apache.org/viewcvs/struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java?view=diff&rev=124065&p1=struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java&r1=124064&p2=struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java&r2=124065
==============================================================================
--- struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java	(original)
+++ struts/sandbox/trunk/struts-shale/src/java/org/apache/shale/application/AbstractRegExpFilter.java	Mon Jan  3 20:02:09 2005
@@ -25,6 +25,8 @@
 import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.shale.faces.ShaleWebContext;
 
 /**
@@ -37,12 +39,12 @@
  * <li>If the specified value is <code>null</code>, call <code>reject()</code>
  *     and return <code>true</code> to indicate that request procesing is
  *     complete.</li>
- * <li>If there are any exclude patterns, and the value matches one of
- *     these patterns, call <code>reject()</code> and return
- *     <code>true</code> to indicate that request processing is complete.</li>
  * <li>If there are any include patterns, and the value matches one of
  *     these patterns, call <code>accept()</code> and return
  *     <code>false</code> to indicate request processing should continue.</li>
+ * <li>If there are any exclude patterns, and the value matches one of
+ *     these patterns, call <code>reject()</code> and return
+ *     <code>true</code> to indicate that request processing is complete.</li>
  * <li>If there are any include patterns, and the value does not match one of
  *     these patterns, call <code>reject()</code> and return
  *     <code>true</code> to indicate that request processing is complete.</li>
@@ -66,6 +68,15 @@
 
 
 
+    // -------------------------------------------------------- Static Variables
+
+
+    /**
+     * <p>Log instance for this class.</p>
+     */
+    private static final Log log = LogFactory.getLog(AbstractRegExpFilter.class);
+
+
     // ------------------------------------------------------ Instance Variables
 
 
@@ -154,24 +165,49 @@
         // Acquire the value to be tested
         ShaleWebContext webContext = (ShaleWebContext) context;
         String value = value(webContext);
+        if (log.isDebugEnabled()) {
+            log.debug("execute(" + value + ")");
+        }
         if (value == null) {
+            if (log.isTraceEnabled()) {
+                log.trace("  reject(null)");
+            }
             reject(webContext);
             return true;
         }
 
+        // Check for a match on the included list
+        if (matches(value, includesPatterns, true)) {
+            if (log.isTraceEnabled()) {
+                log.trace("  accept(include)");
+            }
+            accept(webContext);
+            return false;
+        }
+
         // Check for a match on the excluded list
         if (matches(value, excludesPatterns, false)) {
+            if (log.isTraceEnabled()) {
+                log.trace("  reject(exclude)");
+            }
             reject(webContext);
             return true;
         }
 
-        // Check for a match on the included list
-        if (matches(value, includesPatterns, true)) {
-            accept(webContext);
-            return false;
+        // If there was at least one include pattern,
+        // unconditionally reject this request
+        if ((includesPatterns != null) && (includesPatterns.length > 0)) {
+            if (log.isTraceEnabled()) {
+                log.trace("  reject(not include)");
+            }
+            reject(webContext);
+            return true;
         }
 
         // Unconditionally accept this request
+        if (log.isTraceEnabled()) {
+            log.trace("  accept(default)");
+        }
         accept(webContext);
         return false;
 

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