fae8b167 by Ean Schuessler

Make ProgressRecord fields final, fix tabs

BFP-1784
1 parent c6e31085
...@@ -19,15 +19,16 @@ import org.ofbiz.base.util.HttpClient; ...@@ -19,15 +19,16 @@ import org.ofbiz.base.util.HttpClient;
19 19
20 public class NGINXUploadProcessor extends HttpServlet { 20 public class NGINXUploadProcessor extends HttpServlet {
21 class ProgressRecord { 21 class ProgressRecord {
22 boolean complete = false; 22 final boolean complete;
23 long bytesRead; 23 final long bytesRead;
24 long contentLength; 24 final long contentLength;
25 int items; 25 final int items;
26 26
27 public ProgressRecord(long bytesRead, long contentLength, int items) { 27 public ProgressRecord(long bytesRead, long contentLength, int items, boolean complete) {
28 this.bytesRead = bytesRead; 28 this.bytesRead = bytesRead;
29 this.contentLength = contentLength; 29 this.contentLength = contentLength;
30 this.items = items; 30 this.items = items;
31 this.complete = complete;
31 } 32 }
32 } 33 }
33 34
...@@ -75,7 +76,7 @@ public class NGINXUploadProcessor extends HttpServlet { ...@@ -75,7 +76,7 @@ public class NGINXUploadProcessor extends HttpServlet {
75 } else { 76 } else {
76 String xProgressId = request.getParameter("X-Progress-ID"); 77 String xProgressId = request.getParameter("X-Progress-ID");
77 System.err.println("STORE: [" + xProgressId + "]"); 78 System.err.println("STORE: [" + xProgressId + "]");
78 progress.put(xProgressId, new ProgressRecord(-1, 0, 1)); 79 progress.put(xProgressId, new ProgressRecord(-1, 0, 1, false));
79 80
80 if (ServletFileUpload.isMultipartContent(request)) { 81 if (ServletFileUpload.isMultipartContent(request)) {
81 // Create a factory for disk-based file items 82 // Create a factory for disk-based file items
...@@ -105,9 +106,9 @@ public class NGINXUploadProcessor extends HttpServlet { ...@@ -105,9 +106,9 @@ public class NGINXUploadProcessor extends HttpServlet {
105 this.progress = progress; 106 this.progress = progress;
106 } 107 }
107 @Override 108 @Override
108 public void update(long sent, long length, int items) { 109 public void update(long bytesRead, long contentLength, int items) {
109 System.err.println("PROGRESS: " + sent + " " + length + " " + items); 110 System.err.println("PROGRESS: " + bytesRead + " " + contentLength + " " + items);
110 progress.put(xProgressId, new ProgressRecord(sent, length, items)); 111 progress.put(xProgressId, new ProgressRecord(bytesRead, contentLength, items, false));
111 } 112 }
112 }; 113 };
113 114
...@@ -130,7 +131,8 @@ public class NGINXUploadProcessor extends HttpServlet { ...@@ -130,7 +131,8 @@ public class NGINXUploadProcessor extends HttpServlet {
130 System.err.println("FINISHED:" + pResponse); 131 System.err.println("FINISHED:" + pResponse);
131 out.print(pResponse); 132 out.print(pResponse);
132 133
133 progress.get(xProgressId).complete = true; 134 ProgressRecord oldRecord = progress.get(xProgressId);
135 progress.put(xProgressId, new ProgressRecord(oldRecord.bytesRead, oldRecord.contentLength, oldRecord.items, true));
134 } catch (Exception ex) { 136 } catch (Exception ex) {
135 ex.printStackTrace(); 137 ex.printStackTrace();
136 } 138 }
......