11f2b42c by Ean Schuessler

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

2 parents a72036e1 6591e7b0
......@@ -75,6 +75,7 @@ import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceAuthException;
import org.ofbiz.service.ServiceContainer;
import org.apache.commons.csv.CSVFormat;
......@@ -247,6 +248,11 @@ public class DirectControlServlet extends HttpServlet {
processRequest();
} catch (IOException e) {
throw e;
} catch (ServiceAuthException e) {
e.printStackTrace();
Debug.logError(e, "ServiceAuthException", module);
response.setStatus(401);
setResponseNoCache();
} catch (Exception e) {
e.printStackTrace();
throw (IOException) new IOException(e.getMessage()).initCause(e);
......@@ -265,6 +271,20 @@ public class DirectControlServlet extends HttpServlet {
return file;
}
protected void setResponseNoCache() {
// Set to expire far in the past.
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
}
protected void processRequest() throws Exception {
Map<String, Object> context = new HashMap<String, Object>();
......@@ -396,7 +416,7 @@ public class DirectControlServlet extends HttpServlet {
// prolong the session
if (UtilValidate.isNotEmpty(checkSessionService)) {
dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("authSessionId", authToken, "userLogin", userLogin));
dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("sessionId", authToken, "userLogin", userLogin));
}
}
}
......@@ -426,17 +446,7 @@ public class DirectControlServlet extends HttpServlet {
}
response.setStatus(statusCode);
// Set to expire far in the past.
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
setResponseNoCache();
if ("JSON".equals(outputHandler)) {
response.setContentType("application/x-json");
......