RED-9225: Fixed findings in new customer api #521

Merged
dominique.eiflaender1 merged 1 commits from RED-9225-fp into master 2024-06-05 11:23:42 +02:00
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,
@RequestBody DossierAttributes dossierAttributes) {
dossierTemplateController.getDossierTemplate(dossierTemplateId);
accessControlService.checkDossierExistenceAndAccessPermissionsToDossier(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) {
dossierTemplateController.getDossierTemplate(dossierTemplateId);
dossierController.getDossier(dossierId, includeArchived, includeSoftDeleted);
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);
}
@ -154,6 +155,8 @@ public class FileControllerV2 implements FileResource {
@PathVariable(FILE_ID_PARAM) String fileId,
@RequestBody DownloadRequest downloadRequest) {
fileStatusManagementService.getFileStatus(fileId, false);
return prepareBulkDownload(dossierTemplateId,
dossierId,
BulkDownloadRequest.builder()
@ -169,6 +172,8 @@ public class FileControllerV2 implements FileResource {
@PathVariable(DOSSIER_ID_PARAM) String dossierId,
@RequestBody BulkDownloadRequest bulkDownloadRequest) {
dossierTemplateController.getDossierTemplate(dossierTemplateId);
var storageId = downloadController.prepareDownload(PrepareDownloadWithOptionRequest.builder()
.dossierId(dossierId)
.fileIds(statusController.getDossierStatus(dossierId)

View File

@ -92,7 +92,7 @@ public interface DossierResource {
@ResponseBody
@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.")
@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,

View File

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

View File

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

View File

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

View File

@ -55,7 +55,7 @@ public class DossierAttributesManagementService {
private void validateDossierAttribute(Map<String, DossierAttributeType> typeById, DossierAttribute dossierAttribute) {
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());

View File

@ -450,10 +450,7 @@ public class FileStatusPersistenceService {
var now = OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS);
int countUpdate = fileRepository.hardDeleteFiles(List.of(fileId), ProcessingStatus.PROCESSED, now);
if (countUpdate == 0) {
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
}
fileRepository.hardDeleteFiles(List.of(fileId), ProcessingStatus.PROCESSED, now);
fileAttributesRepository.deleteByFileId(fileId);
}
@ -461,10 +458,7 @@ public class FileStatusPersistenceService {
@Transactional
public void softDelete(String fileId, OffsetDateTime softDeletedTime) {
int countUpdate = 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));
}
fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), softDeletedTime);
}