From dadd53653919660dcf48b84bb184858a8aa1cea5 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 24 Apr 2024 15:09:45 +0300 Subject: [PATCH] description upload fix issue --- .../description/DescriptionServiceImpl.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index ac508aa75..d11c87a4f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -497,24 +497,20 @@ public class DescriptionServiceImpl implements DescriptionService { if (FieldType.isTextType(fieldType)) { if (FieldType.UPLOAD.equals(fieldType)){ UUID newFileId = this.conventionService.isValidUUID(persist.getTextValue()) ? UUID.fromString(persist.getTextValue()) : null; - UUID existingFileId = this.conventionService.isValidUUID(data.getTextValue()) ? UUID.fromString(data.getTextValue()) : null; if (newFileId != null){ - if (!newFileId.equals(existingFileId)) { + StorageFileEntity existingFile = this.queryFactory.query(StorageFileQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(newFileId).firstAs(new BaseFieldSet().ensure(StorageFile._id)); + if (existingFile == null){ StorageFile storageFile = this.storageFileService.copyToStorage(newFileId, StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id)); this.storageFileService.updatePurgeAt(storageFile.getId(), null); - if (existingFileId != null){ + data.setTextValue(storageFile.getId().toString()); + } else { + if (existingFile.getId() != null){ //DO NOT Remove we can not be sure uf the description is copied //this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); } - data.setTextValue(storageFile.getId().toString()); - } else { data.setTextValue(newFileId.toString()); } } else { - if (existingFileId != null){ - //DO NOT Remove we can not be sure uf the description is copied - //this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); - } data.setTextValue(null); } } else {