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;
public class NGINXUploadProcessor extends HttpServlet {
class ProgressRecord {
boolean complete = false;
long bytesRead;
long contentLength;
int items;
final boolean complete;
final long bytesRead;
final long contentLength;
final int items;
public ProgressRecord(long bytesRead, long contentLength, int items) {
public ProgressRecord(long bytesRead, long contentLength, int items, boolean complete) {
this.bytesRead = bytesRead;
this.contentLength = contentLength;
this.items = items;
this.complete = complete;
}
}
......@@ -75,7 +76,7 @@ public class NGINXUploadProcessor extends HttpServlet {
} else {
String xProgressId = request.getParameter("X-Progress-ID");
System.err.println("STORE: [" + xProgressId + "]");
progress.put(xProgressId, new ProgressRecord(-1, 0, 1));
progress.put(xProgressId, new ProgressRecord(-1, 0, 1, false));
if (ServletFileUpload.isMultipartContent(request)) {
// Create a factory for disk-based file items
......@@ -105,9 +106,9 @@ public class NGINXUploadProcessor extends HttpServlet {
this.progress = progress;
}
@Override
public void update(long sent, long length, int items) {
System.err.println("PROGRESS: " + sent + " " + length + " " + items);
progress.put(xProgressId, new ProgressRecord(sent, length, items));
public void update(long bytesRead, long contentLength, int items) {
System.err.println("PROGRESS: " + bytesRead + " " + contentLength + " " + items);
progress.put(xProgressId, new ProgressRecord(bytesRead, contentLength, items, false));
}
};
......@@ -130,7 +131,8 @@ public class NGINXUploadProcessor extends HttpServlet {
System.err.println("FINISHED:" + pResponse);
out.print(pResponse);
progress.get(xProgressId).complete = true;
ProgressRecord oldRecord = progress.get(xProgressId);
progress.put(xProgressId, new ProgressRecord(oldRecord.bytesRead, oldRecord.contentLength, oldRecord.items, true));
} catch (Exception ex) {
ex.printStackTrace();
}
......