c6e31085 by Ean Schuessler

Do not change status to "done" until the OFBiz service call returns

1 parent 707be16d
......@@ -19,6 +19,7 @@ import org.ofbiz.base.util.HttpClient;
public class NGINXUploadProcessor extends HttpServlet {
class ProgressRecord {
boolean complete = false;
long bytesRead;
long contentLength;
int items;
......@@ -65,11 +66,7 @@ public class NGINXUploadProcessor extends HttpServlet {
System.err.println("QUERY PROGRESS: [" + xProgressId + "] - " + progress.get(xProgressId));
if (xProgressId != null && progress.get(xProgressId) != null) {
ProgressRecord record = progress.get(xProgressId);
String status = "done";
if (record.bytesRead < record.contentLength) {
status = "uploading";
}
out.println("({ \"state\" : \""+ status +"\", \"received\" : " +
out.println("({ \"state\" : \""+ (record.complete ? "done" : "uploading") +"\", \"received\" : " +
record.bytesRead + ", \"size\" : " + record.contentLength + " });");
} else {
out.println("({ \"error\" : \"Invalid X-Progress-ID\" });");
......@@ -132,6 +129,8 @@ public class NGINXUploadProcessor extends HttpServlet {
String pResponse = http.post();
System.err.println("FINISHED:" + pResponse);
out.print(pResponse);
progress.get(xProgressId).complete = true;
} catch (Exception ex) {
ex.printStackTrace();
}
......