use of com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger in project midpoint by Evolveum.
the class FocusProcessor method triggerRule.
private <F extends FocusType> void triggerRule(LensFocusContext<F> focusContext, EvaluatedPolicyRule policyRule) throws PolicyViolationException, SchemaException {
PolicyConstraintsType policyConstraints = policyRule.getPolicyConstraints();
if (policyConstraints == null) {
return;
}
for (ModificationPolicyConstraintType modificationConstraintType : policyConstraints.getModification()) {
focusContext.addPolicyRule(policyRule);
if (modificationConstraintMatches(focusContext, policyRule, modificationConstraintType)) {
EvaluatedPolicyRuleTrigger<?> trigger = new EvaluatedPolicyRuleTrigger<>(PolicyConstraintKindType.MODIFICATION, modificationConstraintType, "Focus " + focusContext.getHumanReadableName() + " was modified");
focusContext.triggerConstraint(policyRule, trigger);
}
}
}
use of com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger in project midpoint by Evolveum.
the class TransitionConstraintEvaluator method evaluate.
@Override
public <AH extends AssignmentHolderType> EvaluatedPolicyRuleTrigger evaluate(@NotNull JAXBElement<TransitionPolicyConstraintType> constraintElement, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
try {
TransitionPolicyConstraintType trans = constraintElement.getValue();
List<EvaluatedPolicyRuleTrigger<?>> triggers = new ArrayList<>();
boolean match = evaluateState(trans, rctx, ObjectState.BEFORE, trans.isStateBefore(), triggers, result) && evaluateState(trans, rctx, ObjectState.AFTER, trans.isStateAfter(), triggers, result);
if (match) {
return new EvaluatedTransitionTrigger(PolicyConstraintKindType.TRANSITION, trans, createMessage(constraintElement, rctx, result), createShortMessage(constraintElement, rctx, result), triggers);
} else {
return null;
}
} catch (Throwable t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger in project midpoint by Evolveum.
the class PolicyRuleBasedAspect method logApprovalActions.
private void logApprovalActions(EvaluatedAssignment<?> newAssignment, List<EvaluatedPolicyRule> triggeredApprovalActionRules, PlusMinusZero plusMinusZero) {
if (LOGGER.isDebugEnabled() && !triggeredApprovalActionRules.isEmpty()) {
LOGGER.trace("-------------------------------------------------------------");
LOGGER.debug("Assignment to be {}: {}: {} this target policy rules, {} triggered approval actions:", plusMinusZero == PlusMinusZero.PLUS ? "added" : "deleted", newAssignment, newAssignment.getThisTargetPolicyRules().size(), triggeredApprovalActionRules.size());
for (EvaluatedPolicyRule t : triggeredApprovalActionRules) {
LOGGER.debug(" - Approval action: {}", t.getActions().getApproval());
for (EvaluatedPolicyRuleTrigger trigger : t.getTriggers()) {
LOGGER.debug(" - {}", trigger);
}
}
}
}
use of com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger in project midpoint by Evolveum.
the class CompositeConstraintEvaluator method evaluate.
@Override
public <AH extends AssignmentHolderType> EvaluatedCompositeTrigger evaluate(@NotNull JAXBElement<PolicyConstraintsType> constraint, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
try {
boolean isAnd = QNameUtil.match(PolicyConstraintsType.F_AND, constraint.getName());
boolean isOr = QNameUtil.match(PolicyConstraintsType.F_OR, constraint.getName());
boolean isNot = QNameUtil.match(PolicyConstraintsType.F_NOT, constraint.getName());
assert isAnd || isOr || isNot;
List<EvaluatedPolicyRuleTrigger<?>> triggers = policyRuleProcessor.evaluateConstraints(constraint.getValue(), !isOr, rctx, result);
EvaluatedCompositeTrigger rv;
if (isNot) {
if (triggers.isEmpty()) {
rv = createTrigger(NOT, constraint, triggers, rctx, result);
} else {
rv = null;
}
} else {
if (!triggers.isEmpty()) {
rv = createTrigger(isAnd ? AND : OR, constraint, triggers, rctx, result);
} else {
rv = null;
}
}
if (rv != null) {
result.addReturn("trigger", rv.toDiagShortcut());
}
return rv;
} catch (Throwable t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
Aggregations