"Kevin A. Burton" wrote:
>
> So I want people within JetSpeed to request any screen without having to
> be forced to a new url.
<snip>
This is done. If anyone doesn't have any implementation
suggestions/problems I am going to commit.
Basically the following is done.
Create a SessionValidator (new abstract class... see below) if it
requires a new Session, and data.getSession.isNew() then start a new
session.
Also, instead of calling ActionLoader.getInstance().exec() I am calling
the build method directly. This removes one more instantiation and is
exactly what ActionLoader does internally.
I also created one more package:
org.apache.turbine.modules.actions.sessionvalidator that will hold the
new SessionValidator and DefaultSessionValidator.
======================== BEGIN DIFF: ==============================
Index: conf/TurbineResources.properties
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/TurbineResources.properties,v
retrieving revision 1.22
diff -r1.22 TurbineResources.properties
1d0
< # The scheduler service
111c110
< action.sessionvalidator=SessionValidator
---
> action.sessionvalidator=sessionvalidator.DefaultSessionValidator
Index: src/java/Turbine.java
===================================================================
RCS file: /products/cvs/turbine/turbine/src/java/Turbine.java,v
retrieving revision 1.41
diff -r1.41 Turbine.java
75a76
> import org.apache.turbine.modules.actions.sessionvalidator.SessionValidator;
176a178,183
>
>
> //FIX ME: correctly get the session validator here...
> SessionValidator sessionValidator =
>(SessionValidator)ActionLoader.getInstance().getInstance(
> TurbineResources.getInstance().getString("action.sessionvalidator")
>);
>
183,184c190,192
< // "data.res" represents the HTTP servlet response
< if (data.getSession().isNew())
---
> // "data.getResponse()" represents the HTTP servlet response
> if ( sessionValidator.requiresNewSession(data) &&
> data.getSession().isNew() )
262,265c270,272
< ActionLoader.getInstance()
< .exec(data, TurbineResources.getInstance()
< .getString("action.sessionvalidator"));
<
---
> sessionValidator.build( data );
>
>
--------------------- SessionValidator.java
----------------------------
package org.apache.turbine.modules.actions.sessionvalidator;
// Java Core Classes
import java.io.*;
import java.sql.*;
import java.util.*;
// Java Servlet Classes
import javax.servlet.*;
import javax.servlet.http.*;
// Turbine Modules
import org.apache.turbine.modules.*;
// Turbine Utility Classes
import org.apache.turbine.util.*;
// Village Database Classes
import com.workingdogs.village.*;
/**
The SessionValidator attempts to retrive the User object from the
Servlet API session that is associated with the request. If the
data cannot be retrieved, it is handled here. If the user has not
been
marked as being logged into the system, the user is rejected and the
screen is set to the screen.homepage value in
TurbineResources.properties.
<p>
Other systems generally have a database table which stores this
information,
but we take advantage of the Servlet API here to save a hit to the
database
for each and every connection that a user makes.
<p>
This action is special in that it should only be executed by the
Turbine servlet.
*/
public abstract class SessionValidator extends Action
{
public abstract boolean requiresNewSession(RunData data);
}
--------------------- DefaultSessionValidator.java
--------------------------
package org.apache.turbine.modules.actions.sessionvalidator;
// Java Core Classes
import java.io.*;
import java.sql.*;
import java.util.*;
// Java Servlet Classes
import javax.servlet.*;
import javax.servlet.http.*;
// Turbine Modules
import org.apache.turbine.modules.*;
// Turbine Utility Classes
import org.apache.turbine.util.*;
// Village Database Classes
import com.workingdogs.village.*;
public class DefaultSessionValidator extends SessionValidator
{
public void build( RunData data ) throws Exception
{
data.populate();
// make sure the User object exists in the Session and
// that the user has logged into the system.
if ( (data.getUser() == null) || (!
data.getUser().hasLoggedIn()) )
{
data.setMessage(TurbineResources
.getInstance().getString("login.message"));
data.setScreen(TurbineResources
.getInstance().getString("screen.homepage"));
}
else if ( ! data.hasScreen() )
{
data.setMessage(TurbineResources
.getInstance().getString("login.message.noscreen"));
data.setScreen(TurbineResources
.getInstance().getString("screen.homepage"));
}
else if (
data.getParameters().containsKey("_session_access_counter") )
{
// see comments in screens.error.InvalidState
if ( data.getParameters().getInt("_session_access_counter")
<
(((Integer)data.getUser().getTemp("_session_access_counter")).intValue()-1)
)
{
data.getUser().setTemp( "prev_screen", data.getScreen()
);
data.getUser().setTemp( "prev_parameters",
data.getParameters() );
data.setScreen(
TurbineResources.getInstance().getString("screen.invalidstate") );
data.setAction( "" );
}
}
}
public boolean requiresNewSession(RunData data) {
return true;
}
}
--
Kevin A Burton
http://relativity.yi.org
Message to SUN: "Open Source Java!"
"For evil to win is for good men to do nothing."
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]