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;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilIO;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericValue;
......@@ -53,16 +53,18 @@ import org.ofbiz.service.ServiceContainer;
import groovy.lang.GroovyClassLoader;
import groovy.lang.Script;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.json.JSON;
import org.ofbiz.base.json.ParseException;
import net.sf.json.JSONObject;
public class DirectControlServlet extends HttpServlet {
public static final String module = DirectControlServlet.class.getName();
public static final Map<String, String> serviceURLMappings = new HashMap<String, String>();
private String sessionTokenName = "_AUTHTOKEN";
private String checkSessionService;
public void init(ServletConfig config) throws ServletException {
// get the mapping file for this webapp
......@@ -89,6 +91,9 @@ public class DirectControlServlet extends HttpServlet {
throw new ServletException("Could not read mapping file " + mappingFile);
}
}
checkSessionService = context.getInitParameter("checkSessionService");
Debug.logInfo("Checking session with service: " + checkSessionService, module);
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
......@@ -179,7 +184,7 @@ public class DirectControlServlet extends HttpServlet {
delegator.findList("Visit",
EntityCondition.makeCondition("cookie",
EntityOperator.EQUALS, authToken),
null, null, null, true)
null, null, null, false)
)
);
......@@ -194,6 +199,11 @@ public class DirectControlServlet extends HttpServlet {
if (userLogin != null) {
context.put("userLogin", userLogin);
}
// prolong the session
if (UtilValidate.isNotEmpty(checkSessionService)) {
dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("authSessionId", authToken, "userLogin", userLogin));
}
}
}
......