You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/10/24 22:54:57 UTC
cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/pipeline ClassicPipeline.java
jon 01/10/24 13:54:57
Modified: src/java/org/apache/turbine Pipeline.java Turbine.java
src/java/org/apache/turbine/modules/actions
SessionValidator.java TemplateSessionValidator.java
src/java/org/apache/turbine/pipeline ClassicPipeline.java
Log:
the much anticipated removal of the session redirection code is now
complete. i tested it with scarab and catalina (turning cookies on and off
as well) and things seem fine. since turbine no longer works with jserv
anyway, i don't think that should be an issue.
-jon
Revision Changes Path
1.2 +1 -8 jakarta-turbine-3/src/java/org/apache/turbine/Pipeline.java
Index: Pipeline.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Pipeline.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Pipeline.java 2001/08/16 04:41:32 1.1
+++ Pipeline.java 2001/10/24 20:54:57 1.2
@@ -81,14 +81,7 @@
public void init()
throws Exception;
- // This return value is temporary until the pipeline
- // is complete and we have ValveContexts that will allow
- // us to stop/redirect pipeline processing. The main
- // body of the doGet is in this method for now and
- // there is the redirect sequence that happens on
- // the initial request and the pipeline processing
- // must stop and allow the redirect to go though.
- public boolean process(RunData data)
+ public void process(RunData data)
throws Exception;
public void preExecuteAction(RunData data)
1.11 +39 -41 jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
Index: Turbine.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Turbine.java 2001/10/13 19:58:32 1.10
+++ Turbine.java 2001/10/24 20:54:57 1.11
@@ -111,7 +111,7 @@
* @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
- * @version $Id: Turbine.java,v 1.10 2001/10/13 19:58:32 jon Exp $
+ * @version $Id: Turbine.java,v 1.11 2001/10/24 20:54:57 jon Exp $
*/
public class Turbine
extends HttpServlet
@@ -260,48 +260,46 @@
// in catalina there is also a ValveContext which
// can alter the execution path of the valves. What
// is listed below here could eventually be anything :-)
- if (pipeline.process(data))
+ try
{
- try
- {
- pipeline.preExecuteAction(data);
- pipeline.executeAction(data);
- pipeline.postExecuteAction(data);
- }
- catch (Exception e)
- {
- data.setTarget(configuration
- .getString("template.error","/Error.vm"));
- data.setStackTrace(StringUtils.stackTrace(e),e);
- }
- try
- {
- pipeline.execute(data);
- pipeline.finished(data);
- }
- catch (Exception f)
- {
- // try again with a different target
- data.setTarget(configuration
- .getString("template.error","/Error.vm"));
- data.setStackTrace(StringUtils.stackTrace(f),f);
- pipeline.execute(data);
- pipeline.finished(data);
- }
-
- /*
- TODO: Move this logic into the pipeline.
-
- // Handle the case where a module may want to send
- // a redirect.
- if (( data.getStatusCode() == 301 ||
- data.getStatusCode() == 302 ) &&
- data.getRedirectURI() != null )
- {
- data.getResponse().sendRedirect(data.getRedirectURI());
- }
- */
+ pipeline.process(data);
+ pipeline.preExecuteAction(data);
+ pipeline.executeAction(data);
+ pipeline.postExecuteAction(data);
+ }
+ catch (Exception e)
+ {
+ data.setTarget(configuration
+ .getString("template.error","/Error.vm"));
+ data.setStackTrace(StringUtils.stackTrace(e),e);
+ }
+ try
+ {
+ pipeline.execute(data);
+ pipeline.finished(data);
+ }
+ catch (Exception f)
+ {
+ // try again with a different target
+ data.setTarget(configuration
+ .getString("template.error","/Error.vm"));
+ data.setStackTrace(StringUtils.stackTrace(f),f);
+ pipeline.execute(data);
+ pipeline.finished(data);
+ }
+
+ /*
+ TODO: Move this logic into the pipeline.
+
+ // Handle the case where a module may want to send
+ // a redirect.
+ if (( data.getStatusCode() == 301 ||
+ data.getStatusCode() == 302 ) &&
+ data.getRedirectURI() != null )
+ {
+ data.getResponse().sendRedirect(data.getRedirectURI());
}
+ */
}
catch (Exception e)
{
1.2 +1 -11 jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/SessionValidator.java
Index: SessionValidator.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/SessionValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SessionValidator.java 2001/08/16 04:41:36 1.1
+++ SessionValidator.java 2001/10/24 20:54:57 1.2
@@ -78,19 +78,9 @@
* Turbine servlet.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: SessionValidator.java,v 1.1 2001/08/16 04:41:36 jvanzyl Exp $
+ * @version $Id: SessionValidator.java,v 1.2 2001/10/24 20:54:57 jon Exp $
*/
public abstract class SessionValidator
extends Action
{
- /**
- * Inform whether we require a new session in order to allow
- * people to access the system. We accomplish this by doing a
- * redirect and using the HttpSession spec.
- *
- * @param data Turbine information.
- * @return True if we require a new session in order to allow
- * people to access the system.
- */
- public abstract boolean requiresNewSession(RunData data);
}
1.4 +1 -15 jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/TemplateSessionValidator.java
Index: TemplateSessionValidator.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/TemplateSessionValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TemplateSessionValidator.java 2001/09/13 23:28:00 1.3
+++ TemplateSessionValidator.java 2001/10/24 20:54:57 1.4
@@ -71,7 +71,7 @@
* @see TemplateSecureSessionValidator
* @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: TemplateSessionValidator.java,v 1.3 2001/09/13 23:28:00 jon Exp $
+ * @version $Id: TemplateSessionValidator.java,v 1.4 2001/10/24 20:54:57 jon Exp $
*/
public class TemplateSessionValidator
extends SessionValidator
@@ -145,19 +145,5 @@
data.getUser().setTemp( "prev_parameters", data.getParameters() );
data.setAction( "" );
}
- }
-
- /**
- * By default, this is true. It says that we require a new session
- * in order to allow people to access the system. We accomplish
- * this by doing a redirect and using the HttpSession spec.
- *
- * @param data Turbine information.
- * @return True if we require a new session in order to allow
- * people to access the system.
- */
- public boolean requiresNewSession(RunData data)
- {
- return true;
}
}
1.4 +15 -90 jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java
Index: ClassicPipeline.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClassicPipeline.java 2001/09/01 16:58:11 1.3
+++ ClassicPipeline.java 2001/10/24 20:54:57 1.4
@@ -74,12 +74,16 @@
*
* The ClassicPipeline uses the 'template' as a
* starting point for output.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @version $Id: ClassicPipeline.java,v 1.4 2001/10/24 20:54:57 jon Exp $
*/
public class ClassicPipeline
implements Pipeline,TurbineConstants
{
- SessionValidator sessionValidator;
- AccessController accessController;
+ SessionValidator sessionValidator = null;
+ AccessController accessController = null;
/**
* Here we can setup objects that are thread safe and
@@ -103,97 +107,19 @@
}
- public boolean process(RunData data)
+ public void process(RunData data)
throws Exception
{
-
Log.debug("[ClassicPipeline] process()");
-
- // if this is the redirected stage of the initial request,
- // check that the session is now not new.
- // If it is not, then redirect back to the
- // original URL (i.e. remove the "redirected" pathinfo)
- if (data.getParameters().getString(
- REDIRECTED_PATHINFO_NAME, "false").equals("true"))
- {
- if (data.getSession().isNew())
- {
- String message = "Infinite redirect detected...";
- Log.info(message);
- throw new Exception(message);
- }
- else
- {
- DynamicURI duri = new DynamicURI (data, true);
- // Pass on the sent data in pathinfo.
- for (Enumeration e = data.getParameters().keys() ;
- e.hasMoreElements() ;)
- {
- String key = (String) e.nextElement();
- if (!key.equals(REDIRECTED_PATHINFO_NAME))
- {
- String value =
- (String) data.getParameters().getString ( key );
-
- duri.addPathInfo((String)key, (String)value );
- }
- }
-
- data.getResponse().sendRedirect(duri.toString());
-
- // This is where a ValveContext would be need
- // because the processing of valves should
- // stop here so the redirect can go through.
-
- return false;
- }
- }
- else
+ if (data.getSession().isNew())
{
- // Insist that the client starts a session before access
- // to data is allowed. this is done by redirecting them to
- // the "screen.homepage" page but you could have them go
- // to any page as a starter (ie: the homepage)
- // "data.getResponse()" represents the HTTP servlet
- // response.
- if (sessionValidator.requiresNewSession(data) &&
- data.getSession().isNew())
+ // as the session is new take this opportunity to
+ // set the session timeout if specified in TR.properties
+ int timeout = Turbine.getConfiguration().getInt(SESSION_TIMEOUT, -1);
+ if (timeout != -1)
{
- DynamicURI duri = new DynamicURI (data, true);
-
- // Pass on the sent data in pathinfo.
- for (Enumeration e = data.getParameters().keys() ;
- e.hasMoreElements() ;)
- {
- String key = (String) e.nextElement();
- String value = (String) data.getParameters().getString (key);
- duri.addPathInfo((String)key, (String)value );
- }
-
- // add a dummy bit of path info to fool browser into
- // thinking this is a new URL
- if (!data.getParameters().containsKey(REDIRECTED_PATHINFO_NAME))
- {
- duri.addPathInfo(REDIRECTED_PATHINFO_NAME, "true");
- }
-
- // as the session is new take this opportunity to
- // set the session timeout if specified in TR.properties
- int timeout = Turbine.getConfiguration().getInt(SESSION_TIMEOUT, -1);
-
- if (timeout != -1)
- {
- data.getSession().setMaxInactiveInterval(timeout);
- }
-
- data.getResponse().sendRedirect(duri.toString());
-
- // This is where a ValveContext would be need
- // because the processing of valves should
- // stop here so the redirect can go through.
-
- return false;
+ data.getSession().setMaxInactiveInterval(timeout);
}
}
@@ -237,7 +163,8 @@
}
}
- Turbine.getModuleLoader().getModule(ACTIONS, data.getAction()).execute(data);
+ Turbine.getModuleLoader()
+ .getModule(ACTIONS, data.getAction()).execute(data);
data.setAction(null);
}
@@ -257,8 +184,6 @@
// out the ACL to force it to be rebuilt based on more
// information.
accessController.execute(data);
-
- return true;
}
public void preExecuteAction(RunData data)
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org