From bf764018b3fc581fe9c71372426cfb774a740535 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 8 May 2024 11:41:17 +0300 Subject: [PATCH] add no tracking find --- .../model/persist/DescriptionPersist.java | 6 +-- .../opencdmp/model/persist/DmpPersist.java | 2 +- .../ActionConfirmationServiceImpl.java | 46 +++++++++---------- .../description/DescriptionServiceImpl.java | 12 ++--- .../DescriptionTemplateServiceImpl.java | 6 +-- .../DescriptionTemplateTypeServiceImpl.java | 24 +++++----- .../opencdmp/service/dmp/DmpServiceImpl.java | 10 ++-- .../dmpblueprint/DmpBlueprintServiceImpl.java | 6 +-- .../service/elastic/ElasticServiceImpl.java | 4 +- .../service/language/LanguageServiceImpl.java | 25 +++++----- .../PrefillingSourceServiceImpl.java | 2 +- .../reference/ReferenceServiceImpl.java | 2 +- .../storage/StorageFileServiceImpl.java | 20 ++++---- .../opencdmp/service/tag/TagServiceImpl.java | 26 +++++------ .../TenantConfigurationServiceImpl.java | 4 +- .../service/user/UserServiceImpl.java | 4 +- .../settings/UserSettingsServiceImpl.java | 18 ++++---- 17 files changed, 108 insertions(+), 109 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java index 3d1980ab3..cfbd43d95 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java @@ -180,9 +180,9 @@ public class DescriptionPersist { DmpEntity dmpEntity = null; DmpBlueprintEntity dmpBlueprintEntity = null; try { - descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId()) : null; - dmpEntity = this.isValidGuid(item.getDmpId()) ? this.entityManager.find(DmpEntity.class, item.getDmpId()) : null; - dmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, dmpEntity.getBlueprintId()); + descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId(), true) : null; + dmpEntity = this.isValidGuid(item.getDmpId()) ? this.entityManager.find(DmpEntity.class, item.getDmpId(), true) : null; + dmpBlueprintEntity = dmpEntity == null ? null : this.entityManager.find(DmpBlueprintEntity.class, dmpEntity.getBlueprintId()); } catch (InvalidApplicationException e) { throw new RuntimeException(e); diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java index 9aa4b4381..db26b6452 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DmpPersist.java @@ -192,7 +192,7 @@ public class DmpPersist { protected List specifications(DmpPersist item) { DmpBlueprintEntity dmpBlueprintEntity = null; try { - dmpBlueprintEntity = this.isValidGuid(item.getBlueprint()) ? this.entityManager.find(DmpBlueprintEntity.class, item.getBlueprint()) : null; + dmpBlueprintEntity = this.isValidGuid(item.getBlueprint()) ? this.entityManager.find(DmpBlueprintEntity.class, item.getBlueprint(), true) : null; } catch (InvalidApplicationException e) { throw new RuntimeException(e); diff --git a/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java index a8fc436de..08808e569 100644 --- a/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/actionconfirmation/ActionConfirmationServiceImpl.java @@ -1,26 +1,5 @@ package org.opencdmp.service.actionconfirmation; -import org.opencdmp.authorization.OwnedResource; -import org.opencdmp.authorization.Permission; -import org.opencdmp.commons.XmlHandlingService; -import org.opencdmp.commons.enums.IsActive; -import org.opencdmp.commons.scope.user.UserScope; -import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; -import org.opencdmp.commons.types.actionconfirmation.MergeAccountConfirmationEntity; -import org.opencdmp.commons.types.actionconfirmation.RemoveCredentialRequestEntity; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.ActionConfirmationEntity; -import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.errorcode.ErrorThesaurusProperties; -import org.opencdmp.model.actionconfirmation.ActionConfirmation; -import org.opencdmp.model.referencetype.ReferenceType; -import org.opencdmp.model.builder.actionconfirmation.ActionConfirmationBuilder; -import org.opencdmp.model.deleter.ActionConfirmationDeleter; -import org.opencdmp.model.persist.ActionConfirmationPersist; -import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; -import org.opencdmp.model.persist.actionconfirmation.DmpInvitationPersist; -import org.opencdmp.model.persist.actionconfirmation.MergeAccountConfirmationPersist; -import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -34,6 +13,27 @@ import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import jakarta.xml.bind.JAXBException; import org.jetbrains.annotations.NotNull; +import org.opencdmp.authorization.OwnedResource; +import org.opencdmp.authorization.Permission; +import org.opencdmp.commons.XmlHandlingService; +import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.commons.scope.user.UserScope; +import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity; +import org.opencdmp.commons.types.actionconfirmation.MergeAccountConfirmationEntity; +import org.opencdmp.commons.types.actionconfirmation.RemoveCredentialRequestEntity; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.ActionConfirmationEntity; +import org.opencdmp.data.TenantEntityManager; +import org.opencdmp.errorcode.ErrorThesaurusProperties; +import org.opencdmp.model.actionconfirmation.ActionConfirmation; +import org.opencdmp.model.builder.actionconfirmation.ActionConfirmationBuilder; +import org.opencdmp.model.deleter.ActionConfirmationDeleter; +import org.opencdmp.model.persist.ActionConfirmationPersist; +import org.opencdmp.model.persist.actionconfirmation.DmpInvitationPersist; +import org.opencdmp.model.persist.actionconfirmation.MergeAccountConfirmationPersist; +import org.opencdmp.model.persist.actionconfirmation.RemoveCredentialRequestPersist; +import org.opencdmp.model.referencetype.ReferenceType; +import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -84,7 +84,7 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService ActionConfirmationEntity data; if (isUpdate) { data = this.entityManager.find(ActionConfirmationEntity.class, model.getId()); - if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); } else { @@ -92,7 +92,7 @@ public class ActionConfirmationServiceImpl implements ActionConfirmationService data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); - data.setCreatedById(userScope.getUserId()); + data.setCreatedById(this.userScope.getUserId()); } this.authorizationService.authorizeAtLeastOneForce(List.of(new OwnedResource(data.getCreatedById())), Permission.EditActionConfirmation); diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index 38ec3f2a3..8fcb566be 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -215,12 +215,12 @@ public class DescriptionServiceImpl implements DescriptionService { data.setDmpDescriptionTemplateId(model.getDmpDescriptionTemplateId()); } - DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId()); + DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId(), true); if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!dmpDescriptionTemplate.getDescriptionTemplateGroupId().equals(descriptionTemplateEntity.getGroupId())) throw new MyValidationException(this.errors.getInvalidDescriptionTemplate().getCode(), this.errors.getInvalidDescriptionTemplate().getMessage()); - DmpEntity dmp = this.entityManager.find(DmpEntity.class, data.getDmpId()); + DmpEntity dmp = this.entityManager.find(DmpEntity.class, data.getDmpId(), true); if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (dmp.getStatus().equals(DmpStatus.Finalized) && isUpdate) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); @@ -271,10 +271,10 @@ public class DescriptionServiceImpl implements DescriptionService { if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); - DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId()); + DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId(), true); if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId()); + DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId(), true); if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -425,7 +425,7 @@ public class DescriptionServiceImpl implements DescriptionService { if (!data.getStatus().equals(model.getStatus())){ if (data.getStatus().equals(DescriptionStatus.Finalized)){ this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.FinalizeDescription); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, data.getDmpId()); + DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, data.getDmpId(), true); if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); if(!dmpEntity.getStatus().equals(DmpStatus.Draft)) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage()); } @@ -975,7 +975,7 @@ public class DescriptionServiceImpl implements DescriptionService { DescriptionPersist persist = new DescriptionPersist(); if (data == null) return persist; - DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId()); + DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId(), true); if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); persist.setLabel(data.getLabel()); diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index deaf175e2..da9b91407 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -258,7 +258,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic private void sendDescriptionTemplateInvitationEvent(UserDescriptionTemplateEntity userDescriptionTemplate) throws InvalidApplicationException { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); - UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId()); + UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId(), true); if (user == null){ throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); } @@ -664,7 +664,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic this.authorizationService.authorizeForce(Permission.CreateNewVersionDescriptionTemplate); - DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getId()); + DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getId(), true); if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash())) @@ -751,7 +751,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic persist.setDefinition(this.xmlDefinitionToPersist(importXml)); persist.setType(importXml.getType()); - DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id); + DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id, true); if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); persist.setHash(this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt())); diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java index 282e48251..923518565 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplatetype/DescriptionTemplateTypeServiceImpl.java @@ -1,5 +1,16 @@ package org.opencdmp.service.descriptiontemplatetype; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.IsActive; @@ -13,17 +24,6 @@ import org.opencdmp.model.DescriptionTemplateType; import org.opencdmp.model.builder.DescriptionTemplateTypeBuilder; import org.opencdmp.model.deleter.DescriptionTemplateTypeDeleter; import org.opencdmp.model.persist.DescriptionTemplateTypePersist; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.deleter.DeleterFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.exception.MyValidationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -86,7 +86,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy DescriptionTemplateTypeEntity data; if (isUpdate) { data = this.entityManager.find(DescriptionTemplateTypeEntity.class, model.getId()); - if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); } else { data = new DescriptionTemplateTypeEntity(); diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java index c7f992f1f..452997696 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java @@ -207,7 +207,7 @@ public class DmpServiceImpl implements DmpService { DmpEntity data = this.patchAndSave(model); - DmpBlueprintEntity blueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId()); + DmpBlueprintEntity blueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId(), true); if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class, blueprintEntity.getDefinition()); if (definition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), org.opencdmp.commons.types.dmpblueprint.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); @@ -365,7 +365,7 @@ public class DmpServiceImpl implements DmpService { logger.debug(new MapLogEntry("persisting data bew version").And("model", model).And("fields", fields)); this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation( model.getId())), Permission.CreateNewVersionDmp); - DmpEntity oldDmpEntity = this.entityManager.find(DmpEntity.class, model.getId()); + DmpEntity oldDmpEntity = this.entityManager.find(DmpEntity.class, model.getId(), true); if (oldDmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(oldDmpEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); @@ -612,7 +612,7 @@ public class DmpServiceImpl implements DmpService { if (!disableDelete && (model == null || model.stream().noneMatch(x-> x.getUser() != null && DmpUserRole.Owner.equals(x.getRole())))) throw new MyApplicationException("At least one owner required"); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, dmpId); + DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, dmpId, true); if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); List existingUsers = this.queryFactory.query(DmpUserQuery.class) @@ -658,7 +658,7 @@ public class DmpServiceImpl implements DmpService { @Override public Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException { this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(model.getDmpId())), Permission.AssignDmpUsers); - DmpEntity data = this.entityManager.find(DmpEntity.class, model.getDmpId()); + DmpEntity data = this.entityManager.find(DmpEntity.class, model.getDmpId(), true); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); List existingUsers = this.queryFactory.query(DmpUserQuery.class) @@ -1045,7 +1045,7 @@ public class DmpServiceImpl implements DmpService { DmpPersist persist = new DmpPersist(); if (data == null) return persist; - DmpBlueprintEntity dmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId()); + DmpBlueprintEntity dmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, data.getBlueprintId(), true); if (dmpBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getBlueprintId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); persist.setId(data.getId()); diff --git a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java index bfa777b77..30a113a27 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -322,7 +322,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { } public boolean fieldInBlueprint(UUID id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException { - DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id); + DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, id, true); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); return this.fieldInBlueprint(data, type); @@ -390,7 +390,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { this.authorizationService.authorizeForce(Permission.CreateNewVersionDmpBlueprint); - DmpBlueprintEntity oldDmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, model.getId()); + DmpBlueprintEntity oldDmpBlueprintEntity = this.entityManager.find(DmpBlueprintEntity.class, model.getId(), true); if (oldDmpBlueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(oldDmpBlueprintEntity.getUpdatedAt()).equals(model.getHash())) @@ -602,7 +602,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { persist.setDefinition(this.xmlDefinitionToPersist(dmpDefinition.getDmpBlueprintDefinition())); if (dmpDefinition.getId() != null) { persist.setId(dmpDefinition.getId()); - DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, dmpDefinition.getId()); + DmpBlueprintEntity data = this.entityManager.find(DmpBlueprintEntity.class, dmpDefinition.getId(), true); if (data == null) { throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDefinition.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); } diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java index 8d70e18cc..6724fdd65 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java @@ -306,7 +306,7 @@ public class ElasticServiceImpl implements ElasticService { DescriptionElasticEntity descriptionElasticEntity = this.builderFactory.builder(DescriptionElasticBuilder.class).build(description); this.elasticsearchTemplate.save(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName())); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId()); + DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true); if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (dmpEntity.getIsActive().equals(IsActive.Active)) { DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity); @@ -323,7 +323,7 @@ public class ElasticServiceImpl implements ElasticService { if (descriptionElasticEntity == null) return; this.elasticsearchTemplate.delete(descriptionElasticEntity, IndexCoordinates.of(this.appElasticProperties.getDescriptionIndexName())); - DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId()); + DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, description.getDmpId(), true); if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{description.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (dmpEntity.getIsActive().equals(IsActive.Active)) { DmpElasticEntity dmpElasticEntity = this.builderFactory.builder(DmpElasticBuilder.class).build(dmpEntity); diff --git a/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java index cadf1a1de..630c88f13 100644 --- a/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/language/LanguageServiceImpl.java @@ -1,5 +1,16 @@ package org.opencdmp.service.language; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.IsActive; @@ -13,18 +24,6 @@ import org.opencdmp.model.deleter.LanguageDeleter; import org.opencdmp.model.persist.LanguagePersist; import org.opencdmp.service.dmpblueprint.DmpBlueprintServiceImpl; import org.opencdmp.service.storage.StorageFileService; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.deleter.DeleterFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.exception.MyValidationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; -import org.hibernate.FlushMode; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -76,7 +75,7 @@ public class LanguageServiceImpl implements LanguageService { if (isUpdate) { data = this.entityManager.find(LanguageEntity.class, model.getId()); if (data == null) - throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); + throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Language.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); } else { diff --git a/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java index f2290ba78..314676784 100644 --- a/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java @@ -368,7 +368,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { data = model.getData() == null ? new HashMap<>() : model.getData().getData(); } - DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId()); + DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId(), true); if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition()); diff --git a/backend/core/src/main/java/org/opencdmp/service/reference/ReferenceServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/reference/ReferenceServiceImpl.java index 20e521b77..0dbbdd8f9 100644 --- a/backend/core/src/main/java/org/opencdmp/service/reference/ReferenceServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/reference/ReferenceServiceImpl.java @@ -174,7 +174,7 @@ public class ReferenceServiceImpl implements ReferenceService { lookup.getPage().setOffset(0); } - ReferenceTypeEntity data = this.entityManager.find(ReferenceTypeEntity.class, lookup.getTypeId()); + ReferenceTypeEntity data = this.entityManager.find(ReferenceTypeEntity.class, lookup.getTypeId(), true); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{lookup.getTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); String like; diff --git a/backend/core/src/main/java/org/opencdmp/service/storage/StorageFileServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/storage/StorageFileServiceImpl.java index 7123bad17..b0866334f 100644 --- a/backend/core/src/main/java/org/opencdmp/service/storage/StorageFileServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/storage/StorageFileServiceImpl.java @@ -1,5 +1,11 @@ package org.opencdmp.service.storage; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.StorageFilePermission; @@ -11,12 +17,6 @@ import org.opencdmp.data.TenantEntityManager; import org.opencdmp.model.StorageFile; import org.opencdmp.model.builder.StorageFileBuilder; import org.opencdmp.model.persist.StorageFilePersist; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -193,7 +193,7 @@ public class StorageFileServiceImpl implements StorageFileService { @Override public boolean exists(UUID fileId) { try { - StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId); + StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId, true); if (storageFile == null) return false; this.authorizeForce(storageFile, StorageFilePermission.Read); @@ -262,7 +262,7 @@ public class StorageFileServiceImpl implements StorageFileService { public byte[] readAsBytesSafe(UUID fileId) { byte[] bytes = null; try { - StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId); + StorageFileEntity storageFile = this.entityManager.find(StorageFileEntity.class, fileId, true); if (storageFile == null) return null; this.authorizeForce(storageFile, StorageFilePermission.Read); @@ -313,9 +313,9 @@ public class StorageFileServiceImpl implements StorageFileService { if (!file.exists()) return null; try(InputStream inputStream = new FileInputStream(file)){ bytes = inputStream.readAllBytes(); - }; + } - return bytes; + return bytes; } //endregion diff --git a/backend/core/src/main/java/org/opencdmp/service/tag/TagServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/tag/TagServiceImpl.java index bc67ae43e..f3396796a 100644 --- a/backend/core/src/main/java/org/opencdmp/service/tag/TagServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/tag/TagServiceImpl.java @@ -1,5 +1,16 @@ package org.opencdmp.service.tag; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.Permission; import org.opencdmp.commons.enums.IsActive; @@ -14,17 +25,6 @@ import org.opencdmp.model.Tag; import org.opencdmp.model.builder.TagBuilder; import org.opencdmp.model.deleter.TagDeleter; import org.opencdmp.model.persist.TagPersist; -import gr.cite.commons.web.authz.service.AuthorizationService; -import gr.cite.tools.data.builder.BuilderFactory; -import gr.cite.tools.data.deleter.DeleterFactory; -import gr.cite.tools.exception.MyApplicationException; -import gr.cite.tools.exception.MyForbiddenException; -import gr.cite.tools.exception.MyNotFoundException; -import gr.cite.tools.exception.MyValidationException; -import gr.cite.tools.fieldset.BaseFieldSet; -import gr.cite.tools.fieldset.FieldSet; -import gr.cite.tools.logging.LoggerService; -import gr.cite.tools.logging.MapLogEntry; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -92,14 +92,14 @@ public class TagServiceImpl implements TagService { TagEntity data; if (isUpdate) { data = this.entityManager.find(TagEntity.class, model.getId()); - if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); } else { data = new TagEntity(); data.setId(UUID.randomUUID()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); - data.setCreatedById(userScope.getUserId()); + data.setCreatedById(this.userScope.getUserId()); } data.setLabel(model.getLabel()); diff --git a/backend/core/src/main/java/org/opencdmp/service/tenantconfiguration/TenantConfigurationServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/tenantconfiguration/TenantConfigurationServiceImpl.java index 8cdaf9713..211ba7c08 100644 --- a/backend/core/src/main/java/org/opencdmp/service/tenantconfiguration/TenantConfigurationServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/tenantconfiguration/TenantConfigurationServiceImpl.java @@ -168,7 +168,7 @@ public class TenantConfigurationServiceImpl implements TenantConfigurationServic this.entityManager.flush(); if (data.getTenantId() != null) { - TenantEntity tenant = this.entityManager.find(TenantEntity.class, data.getTenantId()); + TenantEntity tenant = this.entityManager.find(TenantEntity.class, data.getTenantId(), true); if (tenant == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getTenantId(), TenantEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.eventBroker.emit(new TenantConfigurationTouchedEvent(tenant.getId(), tenant.getCode(), data.getType())); } else { @@ -290,7 +290,7 @@ public class TenantConfigurationServiceImpl implements TenantConfigurationServic this.deleterFactory.deleter(TenantConfigurationDeleter.class).deleteAndSaveByIds(List.of(id)); if (data.getTenantId() != null) { - TenantEntity tenant = this.entityManager.find(TenantEntity.class, data.getTenantId()); + TenantEntity tenant = this.entityManager.find(TenantEntity.class, data.getTenantId(), true); if (tenant == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getTenantId(), TenantEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); this.eventBroker.emit(new TenantConfigurationTouchedEvent(tenant.getId(), tenant.getCode(), data.getType())); } else { diff --git a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java index 62e5bed17..343600019 100644 --- a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java @@ -243,7 +243,7 @@ public class UserServiceImpl implements UserService { logger.debug(new MapLogEntry("persisting data UserRole").And("model", model).And("fields", fields)); this.authorizationService.authorizeForce(Permission.EditUser); - UserEntity data = this.entityManager.find(UserEntity.class, model.getId()); + UserEntity data = this.entityManager.find(UserEntity.class, model.getId(), true); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); @@ -457,7 +457,7 @@ public class UserServiceImpl implements UserService { } public void sendRemoveCredentialConfirmation(RemoveCredentialRequestPersist model) throws InvalidApplicationException, JAXBException { - UserCredentialEntity data = this.entityManager.find(UserCredentialEntity.class, model.getCredentialId()); + UserCredentialEntity data = this.entityManager.find(UserCredentialEntity.class, model.getCredentialId(), true); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getCredentialId(), UserCredentialEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!data.getUserId().equals(this.userScope.getUserId())) throw new MyForbiddenException(this.errors.getForbidden().getCode(), this.errors.getForbidden().getMessage()); diff --git a/backend/core/src/main/java/org/opencdmp/service/user/settings/UserSettingsServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/user/settings/UserSettingsServiceImpl.java index e3b16efe4..e5166c243 100644 --- a/backend/core/src/main/java/org/opencdmp/service/user/settings/UserSettingsServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/user/settings/UserSettingsServiceImpl.java @@ -1,13 +1,5 @@ package org.opencdmp.service.user.settings; -import org.opencdmp.authorization.AuthorizationFlags; -import org.opencdmp.authorization.Permission; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.TenantEntityManager; -import org.opencdmp.data.UserSettingsEntity; -import org.opencdmp.model.UserSettings; -import org.opencdmp.model.builder.UserSettingsBuilder; -import org.opencdmp.model.persist.UserSettingsPersist; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; @@ -18,6 +10,14 @@ import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.authorization.Permission; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.data.TenantEntityManager; +import org.opencdmp.data.UserSettingsEntity; +import org.opencdmp.model.UserSettings; +import org.opencdmp.model.builder.UserSettingsBuilder; +import org.opencdmp.model.persist.UserSettingsPersist; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -64,7 +64,7 @@ public class UserSettingsServiceImpl implements UserSettingsService { UserSettingsEntity data; if (isUpdate) { data = this.entityManager.find(UserSettingsEntity.class, model.getId()); - if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), UserSettings.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), UserSettings.class.getSimpleName()}, LocaleContextHolder.getLocale())); } else { data = new UserSettingsEntity(); data.setCreatedAt(Instant.now());