diff --git a/api/pmt.yml b/api/pmt.yml index c339ada..e2318d9 100644 --- a/api/pmt.yml +++ b/api/pmt.yml @@ -184,6 +184,8 @@ paths: $ref: "#/components/responses/UnprocessableContent" 500: $ref: "#/components/responses/InternalError" + 503: + $ref: "#/components/responses/ServiceUnavailable" delete: operationId: "deleteProject" diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index b201393..e7e702e 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -98,7 +98,6 @@ public class ApiController implements DefaultApi { @Override public ResponseEntity addEmployee(Long id, AddEmployeeDTO body) { - Optional optionalProject = projectRepository.findById(id); if (optionalProject.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); @@ -111,12 +110,14 @@ public class ApiController implements DefaultApi { } catch (HttpClientErrorException exception) { return new ResponseEntity<>(exception.getStatusCode().equals(HttpStatus.NOT_FOUND) ? HttpStatus.NOT_FOUND - : HttpStatus.INTERNAL_SERVER_ERROR); + : HttpStatus.SERVICE_UNAVAILABLE); + } catch (RestClientException exception) { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } if (employee.getSkillSet() .stream() - .anyMatch(qualification -> qualification.getId().equals(body.getQualificationId()))) { + .noneMatch(qualification -> qualification.getId().equals(body.getQualificationId()))) { return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY); } @@ -141,4 +142,4 @@ public class ApiController implements DefaultApi { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } -} \ No newline at end of file +}