no message

This commit is contained in:
Efstratios Giannopoulos 2024-04-11 11:14:26 +03:00
parent 0e0e40afeb
commit 1e568bb2dd
2 changed files with 20 additions and 10 deletions

View File

@ -491,16 +491,26 @@ public class DescriptionServiceImpl implements DescriptionService {
if (persist == null) return data;
if (FieldType.isTextType(fieldType)) {
if (FieldType.UPLOAD.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())){
UUID fileId = this.conventionService.isValidUUID(persist.getTextValue()) ? UUID.fromString(persist.getTextValue()) : null;
if (fileId != null && !this.storageFileService.fileRefExists(fileId.toString(), StorageType.Main)){
StorageFile storageFile = this.storageFileService.copyToStorage(fileId, StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id));
this.storageFileService.updatePurgeAt(storageFile.getId(), null);
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)) {
StorageFile storageFile = this.storageFileService.copyToStorage(newFileId, StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id));
this.storageFileService.updatePurgeAt(storageFile.getId(), null);
if (existingFileId != null){
this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60));
}
data.setTextValue(storageFile.getId().toString());
} else {
data.setTextValue(newFileId.toString());
}
} else {
if (existingFileId != null){
this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60));
}
data.setTextValue(null);
}
if (this.conventionService.isValidUUID(data.getTextValue()) && !UUID.fromString(data.getTextValue()).equals(fileId)) {
this.storageFileService.updatePurgeAt(UUID.fromString(data.getTextValue()), Instant.now().minusSeconds(60));
}
data.setTextValue(fileId == null ? null : fileId.toString());
} else {
data.setTextValue(persist.getTextValue());
}

View File

@ -181,7 +181,7 @@ public class StorageFileServiceImpl implements StorageFileService {
this.entityManager.persist(data);
this.entityManager.merge(storageFile);
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, StorageFile._id), data);
}
catch (Exception ex) {