From 4ee640e6888796cefa8b0a640ef2648aa598f771 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 12:29:18 +0200 Subject: [PATCH] Added missing class and chaged port --- .../in/web/TaskAvailableController.java | 36 +++++++++++++++++++ .../src/main/resources/application.properties | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java new file mode 100644 index 0000000..5501885 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java @@ -0,0 +1,36 @@ +package ch.unisg.executor1.executor.adapter.in.web; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorType; + +@RestController +public class TaskAvailableController { + private final TaskAvailableUseCase taskAvailableUseCase; + + public TaskAvailableController(TaskAvailableUseCase taskAvailableUseCase) { + this.taskAvailableUseCase = taskAvailableUseCase; + } + + @GetMapping(path = "/newtask/{taskType}") + public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { + + if (ExecutorType.contains(taskType.toUpperCase())) { + TaskAvailableCommand command = new TaskAvailableCommand( + ExecutorType.valueOf(taskType.toUpperCase())); + taskAvailableUseCase.newTaskAvailable(command); + } + + // Add the content type as a response header + HttpHeaders responseHeaders = new HttpHeaders(); + + return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK); + } +} diff --git a/executor1/src/main/resources/application.properties b/executor1/src/main/resources/application.properties index 4d360de..5e3bb81 100644 --- a/executor1/src/main/resources/application.properties +++ b/executor1/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8081 +server.port=8084