Search in sources :

Example 16 with AssignmentHolderType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType in project midpoint by Evolveum.

the class ObjectModificationConstraintEvaluator method modificationConstraintMatches.

// TODO discriminate between primary and secondary changes (perhaps make it configurable)
// Primary changes are "approvable", secondary ones are not.
private <AH extends AssignmentHolderType> boolean modificationConstraintMatches(JAXBElement<ModificationPolicyConstraintType> constraintElement, ObjectPolicyRuleEvaluationContext<AH> ctx, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
    ModificationPolicyConstraintType constraint = constraintElement.getValue();
    if (!operationMatches(ctx.focusContext, constraint.getOperation())) {
        LOGGER.trace("Rule {} operation not applicable", ctx.policyRule.getName());
        return false;
    }
    ObjectDelta<?> summaryDelta = ctx.focusContext.getSummaryDelta();
    if (ObjectDelta.isEmpty(summaryDelta)) {
        LOGGER.trace("Focus context has no delta (primary nor secondary)");
        return false;
    }
    if (!constraint.getItem().isEmpty()) {
        boolean exactPathMatch = isTrue(constraint.isExactPathMatch());
        for (ItemPathType path : constraint.getItem()) {
            if (!pathMatches(summaryDelta, ctx.focusContext.getObjectOld(), prismContext.toPath(path), exactPathMatch)) {
                LOGGER.trace("Path {} does not match the constraint", path);
                return false;
            }
        }
    }
    return expressionPasses(constraintElement, ctx, result);
}
Also used : ModificationPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModificationPolicyConstraintType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType)

Example 17 with AssignmentHolderType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType in project midpoint by Evolveum.

the class StateConstraintEvaluator method createBuiltInMessage.

@NotNull
private <AH extends AssignmentHolderType> LocalizableMessage createBuiltInMessage(String keyPrefix, JAXBElement<StatePolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<AH> ctx, boolean assignmentTarget, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    StatePolicyConstraintType constraint = constraintElement.getValue();
    List<Object> args = new ArrayList<>();
    args.add(evaluatorHelper.createBeforeAfterMessage(ctx));
    if (assignmentTarget) {
        addAssignmentTargetArgument(args, ctx);
    }
    String keySuffix;
    if (constraint.getName() != null) {
        args.add(constraint.getName());
        keySuffix = KEY_NAMED;
    } else {
        keySuffix = KEY_UNNAMED;
    }
    LocalizableMessage builtInMessage = new LocalizableMessageBuilder().key(keyPrefix + keySuffix).args(args).build();
    return evaluatorHelper.createLocalizableMessage(constraintElement, ctx, builtInMessage, result);
}
Also used : LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) StatePolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.StatePolicyConstraintType) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 NotNull (org.jetbrains.annotations.NotNull)6 LocalizableMessage (com.evolveum.midpoint.util.LocalizableMessage)5 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)4 LensFocusContext (com.evolveum.midpoint.model.impl.lens.LensFocusContext)4 Trace (com.evolveum.midpoint.util.logging.Trace)4 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)4 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 Qualifier (org.springframework.beans.factory.annotation.Qualifier)4 Component (org.springframework.stereotype.Component)4 EvaluatedAssignmentImpl (com.evolveum.midpoint.model.impl.lens.assignments.EvaluatedAssignmentImpl)3 RelationRegistry (com.evolveum.midpoint.schema.RelationRegistry)3 ArrayList (java.util.ArrayList)3 EvaluatedExclusionTrigger (com.evolveum.midpoint.model.api.context.EvaluatedExclusionTrigger)2 EvaluatedStateTrigger (com.evolveum.midpoint.model.api.context.EvaluatedStateTrigger)2 LinkManager (com.evolveum.midpoint.model.common.LinkManager)2 ModelExpressionThreadLocalHolder (com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2