You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2006/02/22 06:12:35 UTC

svn commit: r379686 - /struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java

Author: niallp
Date: Tue Feb 21 21:12:29 2006
New Revision: 379686

URL: http://svn.apache.org/viewcvs?rev=379686&view=rev
Log:
Port fix to RequestProcessor for Bug 38374 from 1.2.x branch - Validation always skipped with Globals.CANCEL_KEY - patch submitted by  Paul Benedict

Modified:
    struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java

Modified: struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java?rev=379686&r1=379685&r2=379686&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java Tue Feb 21 21:12:29 2006
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 2000-2005 The Apache Software Foundation.
+ * Copyright 2000-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,8 +48,7 @@
  * this class and overriding the method(s) whose behavior you are interested
  * in changing.</p>
  *
- * @version $Rev$ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005)
- *          $
+ * @version $Rev$ $Date$
  * @since Struts 1.1
  */
 public class RequestProcessor {
@@ -191,8 +190,19 @@
 
         processPopulate(request, response, form, mapping);
 
-        if (!processValidate(request, response, form, mapping)) {
-            return;
+        // Validate any fields of the ActionForm bean, if applicable
+        try {
+            if (!processValidate(request, response, form, mapping)) {
+                return;
+            }
+        } catch (InvalidCancelException e) {
+            ActionForward forward = processException(request, response, e, form, mapping);
+            processForwardConfig(request, response, forward);
+            return;
+        } catch (IOException e) {
+            throw e;
+        } catch (ServletException e) {
+            throw e;
         }
 
         // Process a forward or include specified by this mapping
@@ -872,22 +882,32 @@
      *         <code>false</code> if a response has been created.
      * @throws IOException      if an input/output error occurs
      * @throws ServletException if a servlet exception occurs
+     * @throws InvalidCancelException if a cancellation is attempted
+     *         without the proper action configuration.
      */
     protected boolean processValidate(HttpServletRequest request,
         HttpServletResponse response, ActionForm form, ActionMapping mapping)
-        throws IOException, ServletException {
+        throws IOException, ServletException, InvalidCancelException {
         if (form == null) {
             return (true);
         }
 
-        // Was this request cancelled?
+        // Was this request cancelled? If it has been, the mapping also
+        // needs to state whether the cancellation is permissable; otherwise
+        // the cancellation is considered to be a symptom of a programmer
+        // error or a spoof.
         if (request.getAttribute(Globals.CANCEL_KEY) != null) {
-            if (log.isDebugEnabled()) {
-                log.debug(" Cancelled transaction, skipping validation");
+            if (mapping.getCancellable()) {
+                if (log.isDebugEnabled()) {
+                    log.debug(" Cancelled transaction, skipping validation");
+                }
+                return (true);
+            } else {
+                request.removeAttribute(Globals.CANCEL_KEY);
+                throw new InvalidCancelException();
             }
-
-            return (true);
         }
+
 
         // Has validation been turned off for this mapping?
         if (!mapping.getValidate()) {



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