diff --git a/backend/core/src/main/java/org/opencdmp/service/custompolicy/CustomPolicyCacheService.java b/backend/core/src/main/java/org/opencdmp/service/custompolicy/CustomPolicyCacheService.java index 919ae7a04..2c2384c61 100644 --- a/backend/core/src/main/java/org/opencdmp/service/custompolicy/CustomPolicyCacheService.java +++ b/backend/core/src/main/java/org/opencdmp/service/custompolicy/CustomPolicyCacheService.java @@ -7,7 +7,6 @@ import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity; import org.opencdmp.event.DescriptionStatusTouchedEvent; import org.opencdmp.event.PlanStatusTouchedEvent; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -57,13 +56,11 @@ public class CustomPolicyCacheService extends CacheService descriptionWorkflowEntities = query.collect(); + if (this.conventionService.isListNullOrEmpty(descriptionWorkflowEntities)) throw new MyApplicationException("Description workflows not found!"); + + DescriptionWorkflowEntity entity = null; + if (!this.tenantScope.isDefaultTenant()) { + entity = descriptionWorkflowEntities.stream().filter(x -> { + try { + return (this.tenantScope.getTenant().equals(x.getTenantId())); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + }).findFirst().orElse(null); + } + + // fallback to default tenant + if (entity == null) { + entity = descriptionWorkflowEntities.stream().filter(x -> x.getTenantId() == null).findFirst().orElse(null); + } - DescriptionWorkflowEntity entity = query.first(); if (entity == null) throw new MyApplicationException("Description workflow not found!"); DescriptionWorkflowDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DescriptionWorkflowDefinitionEntity.class, entity.getDefinition()); diff --git a/backend/core/src/main/java/org/opencdmp/service/planworkflow/PlanWorkflowServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/planworkflow/PlanWorkflowServiceImpl.java index bee1bc568..8d81e2f3e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/planworkflow/PlanWorkflowServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/planworkflow/PlanWorkflowServiceImpl.java @@ -150,12 +150,26 @@ public class PlanWorkflowServiceImpl implements PlanWorkflowService { public PlanWorkflowDefinitionEntity getWorkFlowDefinition() throws InvalidApplicationException { PlanWorkflowQuery query = this.queryFactory.query(PlanWorkflowQuery.class).authorize(AuthorizationFlags.AllExceptPublic).isActives(IsActive.Active); - if (this.tenantScope.isDefaultTenant()) - query = query.defaultTenant(true); - else - query = query.tenantIds(this.tenantScope.getTenant()); + if (this.tenantScope.isDefaultTenant()) query = query.defaultTenant(true); + + List planWorkflowEntities = query.collect(); + if (this.conventionService.isListNullOrEmpty(planWorkflowEntities)) throw new MyApplicationException("Plan workflows not found!"); + PlanWorkflowEntity entity = null; + if (!this.tenantScope.isDefaultTenant()) { + entity = planWorkflowEntities.stream().filter(x -> { + try { + return (this.tenantScope.getTenant().equals(x.getTenantId())); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + }).findFirst().orElse(null); + } + + // fallback to default tenant + if (entity == null) { + entity = planWorkflowEntities.stream().filter(x -> x.getTenantId() == null).findFirst().orElse(null); + } - PlanWorkflowEntity entity = query.first(); if (entity == null) throw new MyApplicationException("Plan workflow not found!"); PlanWorkflowDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(PlanWorkflowDefinitionEntity.class, entity.getDefinition()); diff --git a/backend/web/src/main/java/org/opencdmp/configurations/OpencdmpPermissionPolicyContextImpl.java b/backend/web/src/main/java/org/opencdmp/configurations/OpencdmpPermissionPolicyContextImpl.java index e4f1376c6..62e693c9c 100644 --- a/backend/web/src/main/java/org/opencdmp/configurations/OpencdmpPermissionPolicyContextImpl.java +++ b/backend/web/src/main/java/org/opencdmp/configurations/OpencdmpPermissionPolicyContextImpl.java @@ -50,11 +50,13 @@ public class OpencdmpPermissionPolicyContextImpl extends PermissionPolicyContext @EventListener public void handlePlanTouchedEvent(PlanStatusTouchedEvent event) { + this.customPolicyCacheService.clearCache(event); this.refresh(true); } @EventListener public void handleDescriptionStatusTouchedEvent(DescriptionStatusTouchedEvent event) { + this.customPolicyCacheService.clearCache(event); this.refresh(true); } diff --git a/frontend/src/app/ui/description/editor/description-editor.component.html b/frontend/src/app/ui/description/editor/description-editor.component.html index 3b549a454..686a06144 100644 --- a/frontend/src/app/ui/description/editor/description-editor.component.html +++ b/frontend/src/app/ui/description/editor/description-editor.component.html @@ -67,7 +67,7 @@ - + diff --git a/frontend/src/app/ui/description/overview/description-overview.component.html b/frontend/src/app/ui/description/overview/description-overview.component.html index 79aa428a1..931ba9d43 100644 --- a/frontend/src/app/ui/description/overview/description-overview.component.html +++ b/frontend/src/app/ui/description/overview/description-overview.component.html @@ -134,7 +134,7 @@
- +
diff --git a/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html b/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html index 362491ebf..e10941092 100644 --- a/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html +++ b/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html @@ -52,7 +52,7 @@
-
+