authz fixes
This commit is contained in:
parent
86a12ba089
commit
05a9ddddc8
|
@ -161,7 +161,7 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
|||
this.logger.debug("checking related - {}", TagEntity.class.getSimpleName());
|
||||
|
||||
List<UUID> tagIds = data.stream().map(FieldEntity::getTextListValue).filter(Objects::nonNull).flatMap(List::stream).filter(x-> !this.conventionService.isNullOrEmpty(x)).map(UUID::fromString).distinct().collect(Collectors.toList());
|
||||
List<TagEntity> existingTags = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.AllExceptPublic).disableTracking().ids(tagIds).collectAs(new BaseFieldSet().ensure(Tag._id).ensure(Tag._label));
|
||||
List<TagEntity> existingTags = this.queryFactory.query(TagQuery.class).authorize(this.authorize).disableTracking().ids(tagIds).collectAs(new BaseFieldSet().ensure(Tag._id).ensure(Tag._label));
|
||||
|
||||
Map<UUID, String> itemMap = new HashMap<>();
|
||||
for (UUID tag : tagIds){
|
||||
|
|
|
@ -6,10 +6,9 @@ import gr.cite.tools.data.query.QueryFactory;
|
|||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.PlanVersionStatus;
|
||||
import org.opencdmp.commons.enums.EntityType;
|
||||
import org.opencdmp.commons.enums.IsActive;
|
||||
import org.opencdmp.commons.enums.PlanVersionStatus;
|
||||
import org.opencdmp.data.*;
|
||||
import org.opencdmp.model.PlanDescriptionTemplate;
|
||||
import org.opencdmp.model.description.Description;
|
||||
|
@ -104,7 +103,7 @@ public class PlanDeleter implements Deleter {
|
|||
|
||||
for (PlanEntity item : data) {
|
||||
logger.trace("deleting item {}", item.getId());
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(item.getId());
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.Plan).entityIds(item.getId());
|
||||
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted");
|
||||
if(item.getVersionStatus().equals(PlanVersionStatus.Current)) throw new MyApplicationException("Plan is current can not deleted");
|
||||
item.setIsActive(IsActive.Inactive);
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.opencdmp.model.persist;
|
|||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.XmlHandlingService;
|
||||
import org.opencdmp.commons.enums.DescriptionStatus;
|
||||
import org.opencdmp.commons.enums.IsActive;
|
||||
|
@ -245,7 +244,7 @@ public class DescriptionPersist {
|
|||
PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first();
|
||||
if (planDescriptionTemplateEntity == null) return true;
|
||||
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
|
||||
|
||||
for (SectionEntity section: definition.getSections()) {
|
||||
if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.opencdmp.model.persist;
|
|||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.XmlHandlingService;
|
||||
import org.opencdmp.commons.enums.*;
|
||||
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||
|
@ -274,8 +273,8 @@ public class PlanPersist {
|
|||
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition());
|
||||
if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true;
|
||||
|
||||
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).isActive(IsActive.Active).planIds(planId).collect();
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).isActive(IsActive.Active).collect();
|
||||
List<PlanDescriptionTemplateEntity> planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(planId).collect();
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).isActive(IsActive.Active).collect();
|
||||
|
||||
for (SectionEntity section: definition.getSections()) {
|
||||
if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.opencdmp.model.persist.planproperties;
|
||||
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.commons.enums.PlanBlueprintExtraFieldDataType;
|
||||
import org.opencdmp.commons.enums.PlanBlueprintFieldCategory;
|
||||
import org.opencdmp.commons.types.planblueprint.DefinitionEntity;
|
||||
|
@ -15,8 +13,6 @@ import org.opencdmp.commons.validation.BaseValidator;
|
|||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.model.persist.ReferencePersist;
|
||||
import org.opencdmp.model.referencetype.ReferenceType;
|
||||
import org.opencdmp.query.ReferenceTypeQuery;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
@ -169,13 +165,6 @@ public class PlanBlueprintValuePersist {
|
|||
this.definition = definition;
|
||||
return this;
|
||||
}
|
||||
|
||||
private String getReferenceTypeName(FieldEntity fieldEntity){
|
||||
if (fieldEntity instanceof ReferenceTypeFieldEntity) {
|
||||
return this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(((ReferenceTypeFieldEntity)fieldEntity).getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._name)).getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,13 +60,13 @@ import org.opencdmp.model.deleter.DescriptionReferenceDeleter;
|
|||
import org.opencdmp.model.deleter.DescriptionTagDeleter;
|
||||
import org.opencdmp.model.description.Description;
|
||||
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
|
||||
import org.opencdmp.model.plan.Plan;
|
||||
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||
import org.opencdmp.model.file.FileEnvelope;
|
||||
import org.opencdmp.model.persist.*;
|
||||
import org.opencdmp.model.persist.descriptionproperties.*;
|
||||
import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist;
|
||||
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
|
||||
import org.opencdmp.model.plan.Plan;
|
||||
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||
import org.opencdmp.model.reference.Reference;
|
||||
import org.opencdmp.model.referencetype.ReferenceType;
|
||||
import org.opencdmp.query.*;
|
||||
|
@ -294,7 +294,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(planDescriptionTemplateId).isActive(IsActive.Active).planIds(planId).first();
|
||||
if (planDescriptionTemplateEntity == null) return true;
|
||||
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().planIds(planId).planDescriptionTemplateIds(planDescriptionTemplateId).isActive(IsActive.Active).collect();
|
||||
|
||||
for (SectionEntity section: definition.getSections()) {
|
||||
if (planDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||
|
@ -501,7 +501,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
public List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException {
|
||||
List<DescriptionValidationResult> descriptionValidationResults = new ArrayList<>();
|
||||
|
||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(descriptionIds).isActive(IsActive.Active).collect();
|
||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionIds).isActive(IsActive.Active).collect();
|
||||
if (descriptions == null){
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.opencdmp.commons.scope.tenant.TenantScope;
|
|||
import org.opencdmp.commons.scope.user.UserScope;
|
||||
import org.opencdmp.commons.types.actionconfirmation.PlanInvitationEntity;
|
||||
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
|
||||
import org.opencdmp.commons.types.notification.*;
|
||||
import org.opencdmp.commons.types.plan.PlanBlueprintValueEntity;
|
||||
import org.opencdmp.commons.types.plan.PlanContactEntity;
|
||||
import org.opencdmp.commons.types.plan.PlanPropertiesEntity;
|
||||
|
@ -56,14 +57,13 @@ import org.opencdmp.commons.types.planblueprint.importexport.BlueprintExtraField
|
|||
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintReferenceTypeFieldImportExport;
|
||||
import org.opencdmp.commons.types.planblueprint.importexport.BlueprintSectionImportExport;
|
||||
import org.opencdmp.commons.types.planreference.PlanReferenceDataEntity;
|
||||
import org.opencdmp.commons.types.notification.*;
|
||||
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
||||
import org.opencdmp.commons.types.reference.FieldEntity;
|
||||
import org.opencdmp.convention.ConventionService;
|
||||
import org.opencdmp.data.*;
|
||||
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||
import org.opencdmp.event.PlanTouchedEvent;
|
||||
import org.opencdmp.event.EventBroker;
|
||||
import org.opencdmp.event.PlanTouchedEvent;
|
||||
import org.opencdmp.filetransformerbase.models.misc.PreprocessingPlanModel;
|
||||
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
|
||||
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
||||
|
@ -77,9 +77,6 @@ import org.opencdmp.model.builder.plan.PlanBuilder;
|
|||
import org.opencdmp.model.deleter.*;
|
||||
import org.opencdmp.model.description.Description;
|
||||
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
|
||||
import org.opencdmp.model.plan.Plan;
|
||||
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||
import org.opencdmp.model.planreference.PlanReferenceData;
|
||||
import org.opencdmp.model.file.FileEnvelope;
|
||||
import org.opencdmp.model.persist.*;
|
||||
import org.opencdmp.model.persist.actionconfirmation.PlanInvitationPersist;
|
||||
|
@ -89,15 +86,18 @@ import org.opencdmp.model.persist.planproperties.PlanPropertiesPersist;
|
|||
import org.opencdmp.model.persist.planreference.PlanReferenceDataPersist;
|
||||
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
|
||||
import org.opencdmp.model.persist.referencedefinition.FieldPersist;
|
||||
import org.opencdmp.model.plan.Plan;
|
||||
import org.opencdmp.model.planblueprint.PlanBlueprint;
|
||||
import org.opencdmp.model.planreference.PlanReferenceData;
|
||||
import org.opencdmp.model.reference.Reference;
|
||||
import org.opencdmp.model.referencetype.ReferenceType;
|
||||
import org.opencdmp.query.*;
|
||||
import org.opencdmp.service.actionconfirmation.ActionConfirmationService;
|
||||
import org.opencdmp.service.description.DescriptionService;
|
||||
import org.opencdmp.service.descriptiontemplate.DescriptionTemplateService;
|
||||
import org.opencdmp.service.planblueprint.PlanBlueprintService;
|
||||
import org.opencdmp.service.elastic.ElasticService;
|
||||
import org.opencdmp.service.filetransformer.FileTransformerService;
|
||||
import org.opencdmp.service.planblueprint.PlanBlueprintService;
|
||||
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -264,7 +264,7 @@ public class PlanServiceImpl implements PlanService {
|
|||
}
|
||||
|
||||
private void checkIfDescriptionTemplateIsUse (List<PlanDescriptionTemplatePersist> descriptionTemplates, UUID id){
|
||||
List<PlanDescriptionTemplateEntity> existingPlanDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).planIds(id).isActive(IsActive.Active).collect();
|
||||
List<PlanDescriptionTemplateEntity> existingPlanDescriptionTemplates = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().planIds(id).isActive(IsActive.Active).collect();
|
||||
|
||||
List<PlanDescriptionTemplateEntity> removedDescriptionTemplates = existingPlanDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList();
|
||||
PlanDescriptionTemplateQuery planDescriptionTemplateQuery = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().isActive(IsActive.Active).planIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(PlanDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList()));
|
||||
|
@ -354,7 +354,7 @@ public class PlanServiceImpl implements PlanService {
|
|||
PlanEntity data = this.entityManager.find(PlanEntity.class, id);
|
||||
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(data.getId());
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().types(EntityType.Plan).entityIds(data.getId());
|
||||
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited can not deleted");
|
||||
|
||||
PlanEntity previousPlan = null;
|
||||
|
@ -1201,7 +1201,7 @@ public class PlanServiceImpl implements PlanService {
|
|||
|
||||
if (!plan.getStatus().equals(PlanStatus.Finalized)) throw new MyApplicationException("Plan is already drafted");
|
||||
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.AllExceptPublic).types(EntityType.Plan).entityIds(plan.getId()).isActive(IsActive.Active);
|
||||
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.Plan).entityIds(plan.getId()).isActive(IsActive.Active);
|
||||
if (entityDoiQuery.count() > 0) throw new MyApplicationException("Plan is deposited");
|
||||
|
||||
plan.setStatus(PlanStatus.Draft);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
|||
if (d == null)
|
||||
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
} else {
|
||||
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).disableTracking().languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||
|
||||
if(data != null && !data.isEmpty()){
|
||||
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
||||
|
|
Loading…
Reference in New Issue