RED-9270: Fixed download of report template, RED-9225: Minor fixes for new customer api

This commit is contained in:
Dominique Eifländer 2024-06-06 12:53:07 +02:00
parent 7df8469f45
commit 2272681a02
5 changed files with 16 additions and 3 deletions

View File

@ -44,7 +44,7 @@ public class DownloadControllerV2 implements DownloadResource {
.creationDate(status.getCreationDate())
.lastDownload(status.getLastDownload())
.fileSize(status.getFileSize())
.dossierId(status.getDossier().getId())
.dossierId(status.getDossier() != null ? status.getDossier().getId() : null)
.fileIds(status.getFiles()
.stream()
.map(FileEntity::getId)

View File

@ -50,7 +50,7 @@ public interface DownloadResource {
@ResponseStatus(value = HttpStatus.OK)
@Operation(summary = "Download the download package.")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successfully downloaded the requested file."), @ApiResponse(responseCode = "404", description = "Download not found. This happens if the requested download does not exist for the current user.")})
@GetMapping(value = PATH + DOWNLOAD_ID_PATH_PARAM + DOWNLOAD_PATH)
@GetMapping(value = PATH + DOWNLOAD_ID_PATH_PARAM + DOWNLOAD_PATH, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE})
void download(@Parameter(name = DOWNLOAD_ID_PARAM, description = "The identifier for the file to download.", required = true) @PathVariable(DOWNLOAD_ID_PARAM) String downloadId);
}

View File

@ -118,6 +118,7 @@ public class DossierTemplateExportService {
objectMapper.registerModule(new JavaTimeModule());
DownloadStatusEntity downloadStatus = downloadStatusPersistenceService.getStatus(downloadJob.getStorageId());
downloadStatusPersistenceService.updateStatus(downloadJob.getStorageId(), DownloadStatusValue.GENERATING);
String dossierTemplateId = extractDossierTemplateId(downloadStatus.getFilename());
var dossierTemplate = dossierTemplatePersistenceService.getDossierTemplate(dossierTemplateId);
@ -141,7 +142,7 @@ public class DossierTemplateExportService {
objectMapper.writeValueAsBytes(convert(colors, Colors.class))));
// add dossier statuses
var dossierStatusList = dossierStatusPersistenceService.getAllDossierStatusForTemplate(dossierTemplateId);
var dossierStatusList = dossierStatusPersistenceService.getAllDossierStatusForTemplateWithoutSecurity(dossierTemplateId);
fileSystemBackedArchiver.addEntries(new FileSystemBackedArchiver.ArchiveModel(null,
getFilename(ExportFilename.DOSSIER_STATUS, JSON_EXT),
objectMapper.writeValueAsBytes(convert(dossierStatusList, DossierStatusInfo.class))));

View File

@ -104,6 +104,17 @@ public class DossierStatusPersistenceService {
}
@Transactional
public List<DossierStatusInfo> getAllDossierStatusForTemplateWithoutSecurity(String dossierTemplateId) {
return dossierStatusRepository.findByDossierTemplateIdIn(Collections.singletonList(dossierTemplateId))
.stream()
.map(d -> MagicConverter.convert(d, DossierStatusInfo.class))
.collect(Collectors.toList());
}
@Transactional
public List<DossierStatusInfo> getAllDossierStatuses(List<String> dossierTemplateIds) {

View File

@ -60,6 +60,7 @@ public class DownloadStatusPersistenceService {
downloadStatus.setDownloadFileTypes(downloadFileTypes != null ? new HashSet<>(downloadFileTypes) : new HashSet<>());
downloadStatus.setReports(reportTemplateIds != null ? reportTemplateRepository.findAllById(reportTemplateIds) : new ArrayList<>());
downloadStatus.setRedactionPreviewColor(redactionPreviewColor);
downloadStatus.setStatus(DownloadStatusValue.QUEUED);
downloadStatusRepository.save(downloadStatus);
}