Make puzzle response accept no fileName and sourceCode
This commit is contained in:
parent
b954c518ec
commit
a975b355b2
1 changed files with 12 additions and 4 deletions
|
@ -38,7 +38,11 @@ public class PuzzleResponse implements Response {
|
||||||
@Route(path = "^\\/puzzleResponse\\/([0-9]+)$", type = POST, needLogin = true)
|
@Route(path = "^\\/puzzleResponse\\/([0-9]+)$", type = POST, needLogin = true)
|
||||||
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
|
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
|
||||||
ReceivedResponse received = new ReceivedResponse(matcher, reader);
|
ReceivedResponse received = new ReceivedResponse(matcher, reader);
|
||||||
saveSourceCode(received, databaseRepo.getPlayer(user.getId()));
|
if (received.getResponse() == null) {
|
||||||
|
HttpUtil.responseHeaders(writer, 400, "Access-Control-Allow-Origin: *");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//saveSourceCode(received, databaseRepo.getPlayer(user.getId()));
|
||||||
|
|
||||||
JSONObject responseJSON = new JSONObject();
|
JSONObject responseJSON = new JSONObject();
|
||||||
Puzzle currentPuzzle = databaseRepo.getPuzzle(received.getPuzzleId());
|
Puzzle currentPuzzle = databaseRepo.getPuzzle(received.getPuzzleId());
|
||||||
|
@ -87,9 +91,13 @@ class ReceivedResponse {
|
||||||
puzzleId = Integer.parseInt(matcher.group(1));
|
puzzleId = Integer.parseInt(matcher.group(1));
|
||||||
|
|
||||||
List<String> multiPartData = HttpUtil.readMultiPartData(reader);
|
List<String> multiPartData = HttpUtil.readMultiPartData(reader);
|
||||||
this.response = multiPartData.get(0).getBytes();
|
if (multiPartData != null && multiPartData.size() > 0) {
|
||||||
this.fileName = multiPartData.get(1);
|
this.response = multiPartData.get(0).getBytes();
|
||||||
this.sourceCode = multiPartData.get(2).getBytes();
|
if (multiPartData.size() == 3) {
|
||||||
|
this.fileName = multiPartData.get(1);
|
||||||
|
this.sourceCode = multiPartData.get(2).getBytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPuzzleId() {
|
public int getPuzzleId() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue