You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Edgar González <eg...@valhallaproject.com> on 2004/04/17 00:02:27 UTC

[PATCH] Selective context cleaning in the Turbine servlet after the LoginAction execution for T2.3

Patch to correct the following bug in T2.3:

After the execution of the LoginAction the Context is completly cleared.
This 
means that anything that has been put into the Context by the LoginAction
isn't 
available in the associated template (even the Request Pull-Tools are
removed).

This patch selectively removes from the Context the:

- Session Pull-Tools
- Authorized Pull-Tools
- Persistent Pull-Tools

After the LoginAction has been executed

The patch is following:

Index: Turbine.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v
retrieving revision 1.45
diff -u -r1.45 Turbine.java
--- Turbine.java	2 Jul 2003 16:52:24 -0000	1.45
+++ Turbine.java	16 Apr 2004 21:03:48 -0000
@@ -58,6 +58,7 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.Iterator;
 import java.util.Properties;
 
 import javax.servlet.ServletConfig;
@@ -88,6 +89,7 @@
 import org.apache.turbine.services.TurbineServices;
 import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
 import org.apache.turbine.services.component.ComponentService;
+import org.apache.turbine.services.pull.PullService;
 import org.apache.turbine.services.template.TemplateService;
 import org.apache.turbine.services.template.TurbineTemplate;
 import org.apache.turbine.services.rundata.RunDataService;
@@ -102,6 +104,8 @@
 import org.apache.turbine.util.template.TemplateInfo;
 import org.apache.turbine.util.uri.URIConstants;
 
+import org.apache.velocity.context.Context;
+
 /**
  * Turbine is the main servlet for the entire system. It is
<code>final</code>
  * because you should <i>not</i> ever need to subclass this servlet.  If
you
@@ -322,8 +326,8 @@
         // /WEB-INF/conf/TurbineResources.properties relative to the
         // web application root.
 
-        String confFile= findInitParameter(context, config, 
-                TurbineConfig.CONFIGURATION_PATH_KEY, 
+        String confFile= findInitParameter(context, config,
+                TurbineConfig.CONFIGURATION_PATH_KEY,
                 null);
 
         String confPath;
@@ -388,7 +392,7 @@
         // Now report our successful configuration to the world
         log.info("Loaded configuration  (" + confStyle + ") from " +
confFile + " (" + confPath + ")");
 
-        
+
         setTurbineServletConfig(config);
         setTurbineServletContext(context);
 
@@ -950,7 +954,40 @@
         TemplateInfo ti = data.getTemplateInfo();
         if (ti != null)
         {
-            ti.removeTemp(VelocityService.CONTEXT);
+            Context context = (Context)ti.getTemplateContext(
+
VelocityService.CONTEXT);
+            Configuration toolConfig = null;
+            String toolName = null;
+            // Remove the Session Pull-Tools from the context
+            toolConfig =
getConfiguration().subset(PullService.SESSION_TOOL);
+            if (toolConfig != null)
+            {
+                for (Iterator it = toolConfig.getKeys(); it.hasNext();)
+                {
+                    toolName = (String) it.next();
+                    context.remove(toolName);
+                }
+            }
+            // Remove the Authorized Pull-Tools from the context
+            toolConfig =
getConfiguration().subset(PullService.AUTHORIZED_TOOL);
+            if (toolConfig != null)
+            {
+                for (Iterator it = toolConfig.getKeys(); it.hasNext();)
+                {
+                    toolName = (String) it.next();
+                    context.remove(toolName);
+                }
+            }
+            // Remove the Persistent Pull-Tools from the context
+            toolConfig =
getConfiguration().subset(PullService.PERSISTENT_TOOL);
+            if (toolConfig != null)
+            {
+                for (Iterator it = toolConfig.getKeys(); it.hasNext();)
+                {
+                    toolName = (String) it.next();
+                    context.remove(toolName);
+                }
+            }
         }
     }
 

----------------------------------------------------------------------------
Edgar González González
VALHALLA Project, s.a.
Chief Technology Officer
Web: www.valhallaproject.com
E-mail: egg@valhallaproject.com / egg@cantv.net
Phone: +58-212-242.4379 / 6662 / 4055 / 6475
Fax: +58-212-242.6809 
"The limits of my language mean the limits of my world."
Ludwig Wittgenstein 
----------------------------------------------------------------------------




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