diff options
author | Simon Rettberg | 2018-05-11 17:36:45 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-05-11 17:36:45 +0200 |
commit | b3557ec2e121f91ca842ca37f0e4b582556046a4 (patch) | |
tree | 21f6feb3f678db1da60b6f72fea6ef1cbb72fee0 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java | |
parent | [client] Fix inverted logic for slowed down hashing (diff) | |
download | tutor-module-b3557ec2e121f91ca842ca37f0e4b582556046a4.tar.gz tutor-module-b3557ec2e121f91ca842ca37f0e4b582556046a4.tar.xz tutor-module-b3557ec2e121f91ca842ca37f0e4b582556046a4.zip |
[server] Support server side chunk copying
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java index 8018e86a..0e47994a 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java @@ -22,6 +22,8 @@ import org.openslx.bwlp.sat.mail.SmtpMailer.EncryptionMode; import org.openslx.bwlp.sat.maintenance.DeleteOldImages; import org.openslx.bwlp.sat.maintenance.ImageValidCheck; import org.openslx.bwlp.sat.maintenance.ImageValidCheck.CheckResult; +import org.openslx.bwlp.sat.maintenance.ImageValidCheck.SubmitResult; +import org.openslx.util.Json; import org.openslx.util.Util; import fi.iki.elonen.NanoHTTPD; @@ -36,9 +38,12 @@ public class WebRpc { if (uri.equals("delete-images")) { return deleteImages(); } - if (uri.equals("check-image")) { + if (uri.equals("start-image-check")) { return checkImage(params); } + if (uri.equals("query-image-check")) { + return queryImageCheck(params); + } if (uri.equals("reset-mail-templates")) { return resetMailTemplates(); } @@ -52,12 +57,28 @@ public class WebRpc { private static Response checkImage(Map<String, String> params) { String versionId = params.get("versionid"); - boolean checkHashes = Boolean.valueOf(params.get("hash")); if (versionId == null) return WebServer.badRequest("Missing versionid param"); - CheckResult res = ImageValidCheck.check(versionId, checkHashes); - return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/plain; charset=utf-8", - res.name()); + versionId = versionId.toLowerCase(); + boolean checkHashes = Boolean.valueOf(params.get("hash")); + boolean updateState = Boolean.valueOf(params.get("update")); + SubmitResult res = ImageValidCheck.check(versionId, checkHashes, updateState); + return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/plain; charset=utf-8", res.name()); + } + + private static Response queryImageCheck(Map<String, String> params) { + String versionId = params.get("versionid"); + Map<String, CheckResult> result; + if (versionId == null) { + result = ImageValidCheck.getAll(); + } else { + versionId = versionId.toLowerCase(); + CheckResult res = ImageValidCheck.getStatus(versionId); + result = new HashMap<>(); + result.put(versionId, res); + } + return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "application/json; charset=utf-8", + Json.serialize(result)); } /** |