RED-6497: Fixed issue where the file-size of download was saved incorrectly.
* Changed the update to the DownloadStatusEntity to use the entity object instead of using a query on JPA-repo. This prevents values from the object being incorrectly inserted otherwise. * Extended the DownloadPreparationTest to check the resulting download state and file size.
This commit is contained in:
parent
6e9bcd7bb1
commit
338b06079b
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -18,12 +18,7 @@ public interface DownloadStatusRepository extends JpaRepository<DownloadStatusEn
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.status = :status where ds.storageId = :storageId")
|
||||
void updateStatus(String storageId, DownloadStatusValue status);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.status = :status, ds.fileSize = :fileSize where ds.storageId = :storageId")
|
||||
void updateStatus(String storageId, DownloadStatusValue status, long fileSize);
|
||||
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.lastDownload = :lastDownload where ds.storageId = :storageId")
|
||||
|
||||
@ -36,6 +36,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.download.DownloadStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.download.DownloadStatusValue;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportResultMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
@ -111,10 +112,10 @@ public class DownloadPreparationTest extends AbstractPersistenceServerServiceTes
|
||||
.redactionPreviewColor("#aaaaaa")
|
||||
.build());
|
||||
|
||||
var statuses = downloadClient.getDownloadStatus();
|
||||
assertThat(statuses.getDownloadStatus()).isNotEmpty();
|
||||
List<DownloadStatus> 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<DownloadStatus> 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();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user