Merge branch 'RED-9225-findings-4.0' into 'release/2.349.x'

RED-9225: Fixed findings in new customer api

See merge request redactmanager/persistence-service!517
This commit is contained in:
Dominique Eifländer 2024-06-04 13:24:45 +02:00
commit f1c7970e5b
8 changed files with 17 additions and 15 deletions

View File

@ -108,6 +108,8 @@ public class DossierControllerV2 implements DossierResource {
@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(DOSSIER_ID_PARAM) String dossierId,
@RequestBody DossierAttributes dossierAttributes) { @RequestBody DossierAttributes dossierAttributes) {
dossierTemplateController.getDossierTemplate(dossierTemplateId);
accessControlService.checkDossierExistenceAndAccessPermissionsToDossier(dossierId); accessControlService.checkDossierExistenceAndAccessPermissionsToDossier(dossierId);
accessControlService.verifyUserIsDossierOwner(dossierId); accessControlService.verifyUserIsDossierOwner(dossierId);

View File

@ -75,10 +75,11 @@ public class FileControllerV2 implements FileResource {
@RequestParam(name = INCLUDE_SOFT_DELETED_PARAM, defaultValue = "false", required = false) boolean includeSoftDeleted) { @RequestParam(name = INCLUDE_SOFT_DELETED_PARAM, defaultValue = "false", required = false) boolean includeSoftDeleted) {
dossierTemplateController.getDossierTemplate(dossierTemplateId); dossierTemplateController.getDossierTemplate(dossierTemplateId);
dossierController.getDossier(dossierId, includeArchived, includeSoftDeleted);
List<FileStatus> fileStatusList = new ArrayList<>(); List<FileStatus> fileStatusList = new ArrayList<>();
if (!includeArchived && dossierController.getDossier(dossierId, includeArchived, includeSoftDeleted).getArchivedTime() != null) { if (!includeArchived && dossierController.getDossier(dossierId, false, includeSoftDeleted).getArchivedTime() != null) {
return new FileStatusList(fileStatusList); return new FileStatusList(fileStatusList);
} }
@ -154,6 +155,8 @@ public class FileControllerV2 implements FileResource {
@PathVariable(FILE_ID_PARAM) String fileId, @PathVariable(FILE_ID_PARAM) String fileId,
@RequestBody DownloadRequest downloadRequest) { @RequestBody DownloadRequest downloadRequest) {
fileStatusManagementService.getFileStatus(fileId, false);
return prepareBulkDownload(dossierTemplateId, return prepareBulkDownload(dossierTemplateId,
dossierId, dossierId,
BulkDownloadRequest.builder() BulkDownloadRequest.builder()
@ -169,6 +172,8 @@ public class FileControllerV2 implements FileResource {
@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(DOSSIER_ID_PARAM) String dossierId,
@RequestBody BulkDownloadRequest bulkDownloadRequest) { @RequestBody BulkDownloadRequest bulkDownloadRequest) {
dossierTemplateController.getDossierTemplate(dossierTemplateId);
var storageId = downloadController.prepareDownload(PrepareDownloadWithOptionRequest.builder() var storageId = downloadController.prepareDownload(PrepareDownloadWithOptionRequest.builder()
.dossierId(dossierId) .dossierId(dossierId)
.fileIds(statusController.getDossierStatus(dossierId) .fileIds(statusController.getDossierStatus(dossierId)

View File

@ -92,7 +92,7 @@ public interface DossierResource {
@ResponseBody @ResponseBody
@ResponseStatus(value = HttpStatus.OK) @ResponseStatus(value = HttpStatus.OK)
@PostMapping(value = PATH + CREATE_DOWNLOAD_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = PATH + DOSSIER_ID_PATH_PARAM + CREATE_DOWNLOAD_PATH, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Initiate the creation of a download package for all files of a dossier.") @Operation(summary = "Initiate the creation of a download package for all files of a dossier.")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successfully started the creation of the download package for all files of the requested dossier."), @ApiResponse(responseCode = "404", description = "Not found")}) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successfully started the creation of the download package for all files of the requested dossier."), @ApiResponse(responseCode = "404", description = "Not found")})
DownloadStatus prepareDossierDownload(@Parameter(name = DOSSIER_TEMPLATE_ID_PARAM, description = "The identifier of a dossier template", required = true) @PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId, DownloadStatus prepareDossierDownload(@Parameter(name = DOSSIER_TEMPLATE_ID_PARAM, description = "The identifier of a dossier template", required = true) @PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,

View File

@ -20,10 +20,11 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public interface DownloadResource { public interface DownloadResource {
String DOWNLOAD_PATH = "/download"; String DOWNLOADS_PATH = "/downloads";
String PATH = ExternalApiConstants.BASE_PATH + DOWNLOAD_PATH; String PATH = ExternalApiConstants.BASE_PATH + DOWNLOADS_PATH;
String DOWNLOAD_ID_PARAM = "downloadId"; String DOWNLOAD_ID_PARAM = "downloadId";
String DOWNLOAD_ID_PATH_PARAM = "/{" + DOWNLOAD_ID_PARAM + "}"; String DOWNLOAD_ID_PATH_PARAM = "/{" + DOWNLOAD_ID_PARAM + "}";
String DOWNLOAD_PATH = "/download";
@GetMapping(value = PATH, produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = PATH, produces = MediaType.APPLICATION_JSON_VALUE)

View File

@ -1039,7 +1039,7 @@ paths:
$ref: '#/components/responses/429' $ref: '#/components/responses/429'
"500": "500":
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
/api/download: /api/downloads:
get: get:
operationId: getDownloadStatusList operationId: getDownloadStatusList
tags: tags:

View File

@ -805,7 +805,7 @@ paths:
$ref: '#/components/responses/429' $ref: '#/components/responses/429'
"500": "500":
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
/api/download: /api/downloads:
get: get:
operationId: getDownloadStatusList operationId: getDownloadStatusList
tags: tags:

View File

@ -54,7 +54,7 @@ public class DossierAttributesManagementService {
private void validateDossierAttribute(Map<String, DossierAttributeType> typeById, DossierAttribute dossierAttribute) { private void validateDossierAttribute(Map<String, DossierAttributeType> typeById, DossierAttribute dossierAttribute) {
if (!typeById.containsKey(dossierAttribute.getDossierAttributeConfigId())) { if (!typeById.containsKey(dossierAttribute.getDossierAttributeConfigId())) {
throw new ConflictException("Dossier attribute configuration does not exist."); throw new BadRequestException("Dossier attribute configuration does not exist.");
} }
DossierAttributeType type = typeById.get(dossierAttribute.getDossierAttributeConfigId()); DossierAttributeType type = typeById.get(dossierAttribute.getDossierAttributeConfigId());

View File

@ -397,10 +397,7 @@ public class FileStatusPersistenceService {
@Transactional @Transactional
public void hardDelete(String fileId, OffsetDateTime date) { public void hardDelete(String fileId, OffsetDateTime date) {
int countUpdate = fileRepository.setHardDelete(fileId, ProcessingStatus.PROCESSED, date, date, date); fileRepository.setHardDelete(fileId, ProcessingStatus.PROCESSED, date, date, date);
if (countUpdate == 0) {
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
}
fileAttributesRepository.deleteByFileId(fileId); fileAttributesRepository.deleteByFileId(fileId);
} }
@ -408,10 +405,7 @@ public class FileStatusPersistenceService {
@Transactional @Transactional
public void softDelete(String fileId, OffsetDateTime softDeletedTime) { public void softDelete(String fileId, OffsetDateTime softDeletedTime) {
int countUpdate = fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), softDeletedTime); fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), softDeletedTime);
if (countUpdate == 0) {
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
}
} }