From 94298293a81b7e28a1753639b6be70a5dde2d3db Mon Sep 17 00:00:00 2001 From: Rajbir Singh Date: Tue, 22 Oct 2024 15:50:36 +0200 Subject: [PATCH] PMT-26 refactor try/catch getAListOfAllEmployeesFromASpecificProject --- src/main/java/de/hmmh/pmt/ApiController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index b8da582..7388184 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -159,14 +159,17 @@ public class ApiController implements DefaultApi { .map(Allocation::getEmployeeId) .collect(Collectors.toSet()); - List employees = apiClientFactory.getEmployeeApi().findAll1().stream() - .filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId())) - .toList(); + try { + List employees = apiClientFactory.getEmployeeApi().findAll1().stream() + .filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId())) + .toList(); + return new ResponseEntity<>(employees, HttpStatus.OK); + } catch (RestClientException exception) { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } // Was wenn, die Liste der Allocation und die Liste der EmployeeResponseDTO nicht die gleiche Anzahl haben. // Das EmployeeResponseDTO wird vom EmployeeService gestellt, sollte man die Daten auf eigenes DTO mappen. - return new ResponseEntity<>(employees, HttpStatus.OK); - } }