svn commit: r1301989 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.j

2012-03-17 Thread lukaszlenart
Author: lukaszlenart
Date: Sat Mar 17 20:08:37 2012
New Revision: 1301989

URL: http://svn.apache.org/viewvc?rev=1301989&view=rev
Log:
WW-3773 recreates HttpSession and SessionMap if HttpSession doesn't exist

Modified:

struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java

struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java?rev=1301989&r1=1301988&r2=1301989&view=diff
==
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
 Sat Mar 17 20:08:37 2012
@@ -21,19 +21,21 @@
 
 package org.apache.struts2.interceptor;
 
-import org.apache.struts2.ServletActionContext;
-
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.SessionMap;
+
+import javax.servlet.http.HttpSession;
 
 /**
  * 
  *
- * This interceptor creates the HttpSession.
+ * This interceptor creates the HttpSession if it doesn't exist, also 
SessionMap is recreated and put in ServletActionContext.
  * 
- * This is particular usefull when using the <@s.token> tag in 
freemarker templates.
+ * This is particular useful when using the <@s.token> tag in freemarker 
templates.
  * The tag do require that a HttpSession is already created since 
freemarker commits
  * the response to the client immediately.
  *
@@ -88,11 +90,14 @@ public class CreateSessionInterceptor ex
  * @see 
com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
  */
 public String intercept(ActionInvocation invocation) throws Exception {
-if (LOG.isDebugEnabled()) {
-LOG.debug("Creating HttpSession");
+HttpSession httpSession = 
ServletActionContext.getRequest().getSession(false);
+if (httpSession == null) {
+if (LOG.isDebugEnabled()) {
+LOG.debug("Creating new HttpSession and new SessionMap in 
ServletActionContext");
+}
+ServletActionContext.getRequest().getSession(true);
+ServletActionContext.getContext().setSession(new 
SessionMap(ServletActionContext.getRequest()));
 }
-
-ServletActionContext.getRequest().getSession(true);
 return invocation.invoke();
 }
 

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java?rev=1301989&r1=1301988&r2=1301989&view=diff
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java
 Sat Mar 17 20:08:37 2012
@@ -21,15 +21,14 @@
 
 package org.apache.struts2.interceptor;
 
-import javax.servlet.http.HttpServletRequest;
-
+import com.opensymphony.xwork2.mock.MockActionInvocation;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsTestCase;
 import org.jmock.Mock;
 import org.jmock.core.constraint.IsEqual;
 import org.jmock.core.matcher.InvokeOnceMatcher;
 
-import com.opensymphony.xwork2.mock.MockActionInvocation;
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * Test case for CreateSessionInterceptor.
@@ -39,7 +38,9 @@ public class CreateSessionInterceptorTes
 
 public void testCreateSession() throws Exception {
 Mock httpServletRequestMock = new Mock(HttpServletRequest.class);
+httpServletRequestMock.expects(new 
InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.FALSE));
 httpServletRequestMock.expects(new 
InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.TRUE));
+httpServletRequestMock.expects(new 
InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.FALSE));
 HttpServletRequest request = (HttpServletRequest) 
httpServletRequestMock.proxy();
 
 ServletActionContext.setRequest(request);




[CONF] Confluence Changes in the last 24 hours

2012-03-17 Thread confluence
This is a daily summary of all recent changes in Confluence.

-
Updated Spaces:
-


Apache Bigtop (incubating) (https://cwiki.apache.org/confluence/display/BIGTOP)

Pages
-
How to install Hadoop distribution from Bigtop edited by  ap4dl  (07:30 PM)
https://cwiki.apache.org/confluence/display/BIGTOP/How+to+install+Hadoop+distribution+from+Bigtop



Apache Buildr (https://cwiki.apache.org/confluence/display/BUILDR)

Pages
-
Common Problems and Solutions edited by  alexismidon  (07:50 PM)
https://cwiki.apache.org/confluence/display/BUILDR/Common+Problems+and+Solutions



Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL)

Pages
-
Camel 2.10.0 Release edited by  bvahdat  (05:03 PM)
https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.10.0+Release

Articles edited by  davsclaus  (11:40 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Articles

Websocket created by davsclaus (10:22 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Websocket

Jetty edited by  davsclaus  (10:09 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Jetty

RSS edited by  davsclaus  (03:53 AM)
https://cwiki.apache.org/confluence/display/CAMEL/RSS



Apache Flex (https://cwiki.apache.org/confluence/display/FLEX)

Pages
-
User Groups edited by  keith_sutton  (08:10 PM)
https://cwiki.apache.org/confluence/display/FLEX/User+Groups



OFBiz Project Administration Workspace 
(https://cwiki.apache.org/confluence/display/OFBADMIN)

Pages
-
OFBiz Attic created by jacopoc (01:51 AM)
https://cwiki.apache.org/confluence/display/OFBADMIN/OFBiz+Attic

ASF Board Report 2012-03 created by jacopoc (01:37 AM)
https://cwiki.apache.org/confluence/display/OFBADMIN/ASF+Board+Report+2012-03



OFBiz (Open For Business) Project Open Wiki 
(https://cwiki.apache.org/confluence/display/OFBIZ)

Pages
-
make OFBiz social (Apache Shindig integration) edited by  
erwan.de-ferrie...@nereide.biz  (11:43 AM)
https://cwiki.apache.org/confluence/display/OFBIZ/make+OFBiz+social+%28Apache+Shindig+integration%29



Apache OpenOffice Community 
(https://cwiki.apache.org/confluence/display/OOOUSERS)

Pages
-
Logo Proposals edited by  drewjensen  (10:16 PM)
https://cwiki.apache.org/confluence/display/OOOUSERS/Logo+Proposals

AOO 3.4 Release Notes edited by  orcmid  (07:38 PM)
https://cwiki.apache.org/confluence/display/OOOUSERS/AOO+3.4+Release+Notes

Native Language Projects edited by  regina  (02:32 PM)
https://cwiki.apache.org/confluence/display/OOOUSERS/Native+Language+Projects



Apache Sling Website (https://cwiki.apache.org/confluence/display/SLINGxSITE)

Pages
-
Manipulating Content - The SlingPostServlet (servlets.post) edited by  edn  
(06:54 PM)
https://cwiki.apache.org/confluence/display/SLINGxSITE/Manipulating+Content+-+The+SlingPostServlet+%28servlets.post%29



Apache Tapestry (https://cwiki.apache.org/confluence/display/TAPESTRY)

Pages
-
Persistent Page Data edited by  bobharner  (09:06 AM)
https://cwiki.apache.org/confluence/display/TAPESTRY/Persistent+Page+Data




Change your notification preferences: 
https://cwiki.apache.org/confluence/users/viewnotifications.action