diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadPreparationService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadPreparationService.java index d5b62aa22..aa9444050 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadPreparationService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadPreparationService.java @@ -166,10 +166,7 @@ public class DownloadPreparationService { private void updateStatusToReady(DownloadStatusEntity downloadStatus, FileSystemBackedArchiver fileSystemBackedArchiver) { - downloadStatusPersistenceService.updateStatus(downloadStatus.getStorageId(), DownloadStatusValue.READY, fileSystemBackedArchiver.getContentLength()); - if (!Objects.equals(downloadStatus.getStatus(), DownloadStatusValue.READY)) { - downloadStatus.setStatus(DownloadStatusValue.READY); - } + downloadStatusPersistenceService.updateStatus(downloadStatus, DownloadStatusValue.READY, fileSystemBackedArchiver.getContentLength()); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/export/DossierTemplateExportService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/export/DossierTemplateExportService.java index ab897652c..c5f57e614 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/export/DossierTemplateExportService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/export/DossierTemplateExportService.java @@ -221,7 +221,7 @@ public class DossierTemplateExportService { } storeZipFile(downloadStatus.getStorageId(), fileSystemBackedArchiver); - downloadStatusPersistenceService.updateStatus(downloadStatus.getStorageId(), DownloadStatusValue.READY, fileSystemBackedArchiver.getContentLength()); + downloadStatusPersistenceService.updateStatus(downloadStatus, DownloadStatusValue.READY, fileSystemBackedArchiver.getContentLength()); } catch (JsonProcessingException e) { log.debug("fail ", e); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java index 6b461488b..538960fa3 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java @@ -73,9 +73,11 @@ public class DownloadStatusPersistenceService { @Transactional - public void updateStatus(String storageId, DownloadStatusValue status, long fileSize) { + public void updateStatus(DownloadStatusEntity entity, DownloadStatusValue statusValue, long fileSize) { - downloadStatusRepository.updateStatus(storageId, status, fileSize); + entity.setStatus(statusValue); + entity.setFileSize(fileSize); + downloadStatusRepository.save(entity); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadStatusRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadStatusRepository.java index 385575f15..30a9352f1 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadStatusRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/DownloadStatusRepository.java @@ -18,12 +18,7 @@ public interface DownloadStatusRepository extends JpaRepository downloadStatuses = downloadClient.getDownloadStatus().getDownloadStatus(); + assertThat(downloadStatuses).hasSize(1); - DownloadStatus firstDownloadStatus = statuses.getDownloadStatus().iterator().next(); + DownloadStatus firstDownloadStatus = downloadStatuses.get(0); assertThat(firstDownloadStatus.getLastDownload()).isNull(); String downloadId = firstDownloadStatus.getStorageId(); @@ -134,6 +135,12 @@ public class DownloadPreparationTest extends AbstractPersistenceServerServiceTes .redactionResultDetails(Collections.emptyList()) .build()); + List finalDownloadStatuses = downloadClient.getDownloadStatus().getDownloadStatus(); + assertThat(finalDownloadStatuses).hasSize(1); + DownloadStatus finalDownloadStatus = finalDownloadStatuses.get(0); + assertThat(finalDownloadStatus.getStatus()).isEqualTo(DownloadStatusValue.READY); + assertThat(finalDownloadStatus.getFileSize()).isGreaterThan(0); + clearTenantContext(); }