477760f7 by Ean Schuessler

#5185 #5144 Prevent caching, don't return CSV nulls

1 parent 8cf89907
......@@ -275,6 +275,18 @@ public class DirectControlServlet extends HttpServlet {
response.setStatus(400);
}
// 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");
if ("JSON".equals(outputHandler)) {
response.setContentType("application/x-json");
......@@ -313,7 +325,8 @@ public class DirectControlServlet extends HttpServlet {
}
if (data.size() > 0) {
Iterator hi = ((Map) data.get(0)).keySet().iterator();
Set keys = ((Map) data.get(0)).keySet();
Iterator hi = keys.iterator();
StringBuffer csvBuf = new StringBuffer();
while(hi.hasNext()) {
csvBuf.append(hi.next());
......@@ -322,10 +335,11 @@ public class DirectControlServlet extends HttpServlet {
writer.println(csvBuf);
for (Map row : data) {
Iterator i = row.values().iterator();
Iterator i = keys.iterator();
csvBuf = new StringBuffer();
while(i.hasNext()) {
csvBuf.append(i.next());
Object val = row.get(i.next());
if (!"null".equals("" + val)) csvBuf.append(val);
if (i.hasNext()) csvBuf.append(",");
}
writer.println(csvBuf);
......
......@@ -53,8 +53,8 @@ public class LibreOfficeRenderer {
ProcessBuilder pb = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "pdf", outputFile.getPath(), "--outdir", outputFile.getParentFile().getPath());
Map<String, String> env = pb.environment();
env.put("HOME", "/home/ofbiz");
env.put("USERNAME", "ofbiz");
env.put("HOME", "/home/driverup");
env.put("USERNAME", "driverup");
Process process = pb.start();
InputStream is = process.getInputStream();
process.waitFor();
......