add no tracking find
This commit is contained in:
parent
03c5c7b8c2
commit
bf764018b3
|
@ -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);
|
||||
|
|
|
@ -192,7 +192,7 @@ public class DmpPersist {
|
|||
protected List<Specification> 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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<DmpUserEntity> 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<DmpUserEntity> 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());
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,7 +313,7 @@ public class StorageFileServiceImpl implements StorageFileService {
|
|||
if (!file.exists()) return null;
|
||||
try(InputStream inputStream = new FileInputStream(file)){
|
||||
bytes = inputStream.readAllBytes();
|
||||
};
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue