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(); }