Author: ajaquith
Date: Sat Sep  6 20:58:22 2008
New Revision: 692772

URL: http://svn.apache.org/viewvc?rev=692772&view=rev
Log:
Cleaned up RedirectException; it now properly implements the Stripes Resolution 
interface.

Removed:
    
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/ResolutionException.java
Modified:
    
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/RedirectException.java

Modified: 
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/RedirectException.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/RedirectException.java?rev=692772&r1=692771&r2=692772&view=diff
==============================================================================
--- 
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/RedirectException.java
 (original)
+++ 
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/filters/RedirectException.java
 Sat Sep  6 20:58:22 2008
@@ -20,21 +20,29 @@
  */
 package com.ecyrd.jspwiki.filters;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.sourceforge.stripes.action.RedirectResolution;
 import net.sourceforge.stripes.action.Resolution;
 
 /**
  *  This exception may be thrown if a filter wants to reject something and
- *  redirect the user elsewhere.
+ *  redirect the user elsewhere. In addition to being a subclass of 
FilterException,
+ *  this class also implements the Stripes [EMAIL PROTECTED] 
net.sourceforge.stripes.action.Resolution}
+ *  interface, which means it can be caught and used by Stripes for 
redirection.
  *
  *  @since 2.1.112
  */
 public class RedirectException
     extends FilterException implements Resolution
 {
-    private static final long serialVersionUID = 0L;
+    private static final long serialVersionUID = 1L;
 
     private final String m_where;
 
+    private Resolution m_resolution = null;
+
     /**
      *  Constructs a new RedirectException.
      *  
@@ -46,6 +54,8 @@
         super( msg );
 
         m_where = redirect;
+
+        m_resolution = new RedirectResolution( redirect );
     }
 
     /**
@@ -57,4 +67,36 @@
     {
         return m_where;
     }
+
+    /**
+     * Sets the Resolution executed by [EMAIL PROTECTED] 
#execute(HttpServletRequest, HttpServletResponse)}. Calling
+     * this method overrides the default RedirectResolution created during 
construction.
+     * @param resolution the Resolution to set
+     */
+    public void setResolution( Resolution resolution )
+    {
+        m_resolution = resolution;
+    }
+    
+    /**
+     * Returns the Resolution that will be executed by [EMAIL PROTECTED] 
#execute(HttpServletRequest, HttpServletResponse)}.
+     * If not set explicitly by [EMAIL PROTECTED] #setResolution(Resolution)}, 
this method returns a
+     * [EMAIL PROTECTED] net.sourceforge.stripes.action.RedirectResolution} 
that redirects to the URL supplied during
+     * construction.
+     * @return the Resolution
+     */
+    public Resolution getResolution()
+    {
+        return m_resolution;
+    }
+    
+    /**
+     * Executes the Stripes redirect activity by calling
+     * [EMAIL PROTECTED] 
net.sourceforge.stripes.action.Resolution#execute(HttpServletRequest, 
HttpServletResponse)}
+     * for the Resolution returned by [EMAIL PROTECTED] #getResolution()}.
+     */
+    public void execute( HttpServletRequest request, HttpServletResponse 
response ) throws Exception
+    {
+        m_resolution.execute( request, response );
+    }
 }


Reply via email to