description upload fix issue

This commit is contained in:
amentis 2024-04-24 15:09:45 +03:00
parent f8e6cb6462
commit dadd536539
1 changed files with 5 additions and 9 deletions

View File

@ -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 {