From 5e7ccbd8c6d436c6c9213d82d1a3ccd06e743c65 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Tue, 22 Jun 2021 05:38:48 +0300 Subject: [PATCH] Add the "addWorkerReport" endpoint. --- .../controllers/UrlController.java | 20 +++++++++++++++---- .../urls_controller/models/Payload.java | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java b/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java index f320cd1..37cc55e 100644 --- a/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java +++ b/src/main/java/eu/openaire/urls_controller/controllers/UrlController.java @@ -4,16 +4,15 @@ import com.google.common.collect.HashMultimap; import eu.openaire.urls_controller.models.Assignment; import eu.openaire.urls_controller.models.Datasource; import eu.openaire.urls_controller.models.Task; +import eu.openaire.urls_controller.payloads.requests.WorkerReport; import eu.openaire.urls_controller.payloads.responces.AssignmentResponse; import eu.openaire.urls_controller.util.FileUtils; import eu.openaire.urls_controller.util.GenericUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.*; @@ -46,6 +45,19 @@ public class UrlController { return ResponseEntity.status(200).header("Content-Type", "application/json").body(new AssignmentResponse(assignment)); } + @PostMapping("addWorkerReport") + public ResponseEntity addWorkerReport(@RequestBody WorkerReport workerReport) { + + if ( workerReport == null ) + return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); + + logger.debug("Received the WorkerReport:\n" + workerReport.toString()); + + // TODO - Store the workerReport into the database. + + return ResponseEntity.status(HttpStatus.OK).build(); + } + private static int assignmentId = -1; // Just for the "getTestUrls"-endpoint. diff --git a/src/main/java/eu/openaire/urls_controller/models/Payload.java b/src/main/java/eu/openaire/urls_controller/models/Payload.java index 55377ec..664b728 100644 --- a/src/main/java/eu/openaire/urls_controller/models/Payload.java +++ b/src/main/java/eu/openaire/urls_controller/models/Payload.java @@ -41,7 +41,7 @@ public class Payload { private Long size; // In bytes. @JsonProperty("more_info") - private String more_info; + private String more_info; @JsonProperty("md5") private String md5;