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; ...@@ -75,6 +75,7 @@ import org.ofbiz.entity.condition.EntityCondition;
75 import org.ofbiz.service.DispatchContext; 75 import org.ofbiz.service.DispatchContext;
76 import org.ofbiz.service.LocalDispatcher; 76 import org.ofbiz.service.LocalDispatcher;
77 import org.ofbiz.service.ModelService; 77 import org.ofbiz.service.ModelService;
78 import org.ofbiz.service.ServiceAuthException;
78 import org.ofbiz.service.ServiceContainer; 79 import org.ofbiz.service.ServiceContainer;
79 80
80 import org.apache.commons.csv.CSVFormat; 81 import org.apache.commons.csv.CSVFormat;
...@@ -247,6 +248,11 @@ public class DirectControlServlet extends HttpServlet { ...@@ -247,6 +248,11 @@ public class DirectControlServlet extends HttpServlet {
247 processRequest(); 248 processRequest();
248 } catch (IOException e) { 249 } catch (IOException e) {
249 throw e; 250 throw e;
251 } catch (ServiceAuthException e) {
252 e.printStackTrace();
253 Debug.logError(e, "ServiceAuthException", module);
254 response.setStatus(401);
255 setResponseNoCache();
250 } catch (Exception e) { 256 } catch (Exception e) {
251 e.printStackTrace(); 257 e.printStackTrace();
252 throw (IOException) new IOException(e.getMessage()).initCause(e); 258 throw (IOException) new IOException(e.getMessage()).initCause(e);
...@@ -265,6 +271,20 @@ public class DirectControlServlet extends HttpServlet { ...@@ -265,6 +271,20 @@ public class DirectControlServlet extends HttpServlet {
265 return file; 271 return file;
266 } 272 }
267 273
274 protected void setResponseNoCache() {
275 // Set to expire far in the past.
276 response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
277
278 // Set standard HTTP/1.1 no-cache headers.
279 response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
280
281 // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
282 response.addHeader("Cache-Control", "post-check=0, pre-check=0");
283
284 // Set standard HTTP/1.0 no-cache header.
285 response.setHeader("Pragma", "no-cache");
286 }
287
268 protected void processRequest() throws Exception { 288 protected void processRequest() throws Exception {
269 Map<String, Object> context = new HashMap<String, Object>(); 289 Map<String, Object> context = new HashMap<String, Object>();
270 290
...@@ -396,7 +416,7 @@ public class DirectControlServlet extends HttpServlet { ...@@ -396,7 +416,7 @@ public class DirectControlServlet extends HttpServlet {
396 416
397 // prolong the session 417 // prolong the session
398 if (UtilValidate.isNotEmpty(checkSessionService)) { 418 if (UtilValidate.isNotEmpty(checkSessionService)) {
399 dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("authSessionId", authToken, "userLogin", userLogin)); 419 dispatcher.runSync(checkSessionService, UtilMisc.<String, Object>toMap("sessionId", authToken, "userLogin", userLogin));
400 } 420 }
401 } 421 }
402 } 422 }
...@@ -426,17 +446,7 @@ public class DirectControlServlet extends HttpServlet { ...@@ -426,17 +446,7 @@ public class DirectControlServlet extends HttpServlet {
426 } 446 }
427 response.setStatus(statusCode); 447 response.setStatus(statusCode);
428 448
429 // Set to expire far in the past. 449 setResponseNoCache();
430 response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
431
432 // Set standard HTTP/1.1 no-cache headers.
433 response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
434
435 // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
436 response.addHeader("Cache-Control", "post-check=0, pre-check=0");
437
438 // Set standard HTTP/1.0 no-cache header.
439 response.setHeader("Pragma", "no-cache");
440 450
441 if ("JSON".equals(outputHandler)) { 451 if ("JSON".equals(outputHandler)) {
442 response.setContentType("application/x-json"); 452 response.setContentType("application/x-json");
......