From 1ac9f7ebcf05f8d67c0817bcab19e39d40966967 Mon Sep 17 00:00:00 2001 From: yhampe Date: Fri, 23 Aug 2024 10:30:08 +0200 Subject: [PATCH] RED-9790: manual changes not applied when too many redaction requests was sent added an exception to more easily filter the traces for the cases were no exception is produced, but the manualredactions are ignored/not processed --- .../controller/ManualRedactionController.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java index 80d969d62..e5ec4a8f7 100644 --- a/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java +++ b/persistence-service-v1/persistence-service-external-api-impl-v1/src/main/java/com/iqser/red/persistence/service/v1/external/api/impl/controller/ManualRedactionController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException; import com.iqser.red.service.persistence.management.v1.processor.model.ManualChangesQueryOptions; import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService; import com.iqser.red.service.persistence.management.v1.processor.service.CommentService; @@ -182,6 +183,9 @@ public class ManualRedactionController implements ManualRedactionResource { .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions added"); + } return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } @@ -216,6 +220,9 @@ public class ManualRedactionController implements ManualRedactionResource { .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions removed"); + } return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } @@ -239,6 +246,9 @@ public class ManualRedactionController implements ManualRedactionResource { .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions added"); + } return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } @@ -261,7 +271,9 @@ public class ManualRedactionController implements ManualRedactionResource { .message("Legal basis reason was changed") .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); - + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions changed "); + } return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } @@ -277,11 +289,7 @@ public class ManualRedactionController implements ManualRedactionResource { accessControlService.verifyFileIsNotApproved(dossierId, fileId); accessControlService.verifyUserIsMemberOrApprover(dossierId); - List responseList = manualRedactionService.addRecategorization(dossierId, - fileId, - dossier, - recategorizationRequests, - includeUnprocessed); + List responseList = manualRedactionService.addRecategorization(dossierId, fileId, dossier, recategorizationRequests, includeUnprocessed); responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder() .userId(KeycloakSecurity.getUserId()) @@ -291,6 +299,10 @@ public class ManualRedactionController implements ManualRedactionResource { .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions recategorized"); + } + return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } @@ -314,7 +326,9 @@ public class ManualRedactionController implements ManualRedactionResource { .message("Skipped annotation was resized to be redacted") .details(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, ANNOTATION_ID, response.getAnnotationId())) .build())); - + if (responseList.isEmpty()) { + throw new BadRequestException("There were no manualRedactions resized"); + } return ManualRedactionResponse.builder().manualAddResponses(responseList).build(); } -- 2.47.2