a9fc2c01 by Ean Schuessler

Merge branch 'BF-3980' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet

2 parents 0f8e94b0 965b5d26
...@@ -41,7 +41,7 @@ import org.ofbiz.base.util.UtilHttp; ...@@ -41,7 +41,7 @@ import org.ofbiz.base.util.UtilHttp;
41 import org.ofbiz.base.util.UtilMisc; 41 import org.ofbiz.base.util.UtilMisc;
42 import org.ofbiz.base.util.UtilProperties; 42 import org.ofbiz.base.util.UtilProperties;
43 import org.ofbiz.base.util.UtilIO; 43 import org.ofbiz.base.util.UtilIO;
44 44 import org.ofbiz.base.util.UtilValidate;
45 import org.ofbiz.entity.Delegator; 45 import org.ofbiz.entity.Delegator;
46 import org.ofbiz.entity.DelegatorFactory; 46 import org.ofbiz.entity.DelegatorFactory;
47 import org.ofbiz.entity.GenericValue; 47 import org.ofbiz.entity.GenericValue;
...@@ -53,16 +53,18 @@ import org.ofbiz.service.ServiceContainer; ...@@ -53,16 +53,18 @@ import org.ofbiz.service.ServiceContainer;
53 53
54 import groovy.lang.GroovyClassLoader; 54 import groovy.lang.GroovyClassLoader;
55 import groovy.lang.Script; 55 import groovy.lang.Script;
56 import org.codehaus.groovy.runtime.InvokerHelper;
57 56
57 import org.codehaus.groovy.runtime.InvokerHelper;
58 import org.ofbiz.base.json.JSON; 58 import org.ofbiz.base.json.JSON;
59 import org.ofbiz.base.json.ParseException; 59 import org.ofbiz.base.json.ParseException;
60
60 import net.sf.json.JSONObject; 61 import net.sf.json.JSONObject;
61 62
62 public class DirectControlServlet extends HttpServlet { 63 public class DirectControlServlet extends HttpServlet {
63 public static final String module = DirectControlServlet.class.getName(); 64 public static final String module = DirectControlServlet.class.getName();
64 public static final Map<String, String> serviceURLMappings = new HashMap<String, String>(); 65 public static final Map<String, String> serviceURLMappings = new HashMap<String, String>();
65 private String sessionTokenName = "_AUTHTOKEN"; 66 private String sessionTokenName = "_AUTHTOKEN";
67 private String checkSessionService;
66 68
67 public void init(ServletConfig config) throws ServletException { 69 public void init(ServletConfig config) throws ServletException {
68 // get the mapping file for this webapp 70 // get the mapping file for this webapp
...@@ -89,6 +91,9 @@ public class DirectControlServlet extends HttpServlet { ...@@ -89,6 +91,9 @@ public class DirectControlServlet extends HttpServlet {
89 throw new ServletException("Could not read mapping file " + mappingFile); 91 throw new ServletException("Could not read mapping file " + mappingFile);
90 } 92 }
91 } 93 }
94
95 checkSessionService = context.getInitParameter("checkSessionService");
96 Debug.logInfo("Checking session with service: " + checkSessionService, module);
92 } 97 }
93 98
94 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 99 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
...@@ -179,7 +184,7 @@ public class DirectControlServlet extends HttpServlet { ...@@ -179,7 +184,7 @@ public class DirectControlServlet extends HttpServlet {
179 delegator.findList("Visit", 184 delegator.findList("Visit",
180 EntityCondition.makeCondition("cookie", 185 EntityCondition.makeCondition("cookie",
181 EntityOperator.EQUALS, authToken), 186 EntityOperator.EQUALS, authToken),
182 null, null, null, true) 187 null, null, null, false)
183 ) 188 )
184 ); 189 );
185 190
...@@ -194,6 +199,11 @@ public class DirectControlServlet extends HttpServlet { ...@@ -194,6 +199,11 @@ public class DirectControlServlet extends HttpServlet {
194 if (userLogin != null) { 199 if (userLogin != null) {
195 context.put("userLogin", userLogin); 200 context.put("userLogin", userLogin);
196 } 201 }
202
203 // prolong the session
204 if (UtilValidate.isNotEmpty(checkSessionService)) {
205 dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("authSessionId", authToken, "userLogin", userLogin));
206 }
197 } 207 }
198 } 208 }
199 209
......