use of com.evolveum.midpoint.model.api.context.EvaluatedModificationTrigger in project midpoint by Evolveum.
the class ObjectModificationConstraintEvaluator method evaluate.
@Override
public <AH extends AssignmentHolderType> EvaluatedModificationTrigger evaluate(@NotNull JAXBElement<ModificationPolicyConstraintType> constraint, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
try {
if (!(rctx instanceof ObjectPolicyRuleEvaluationContext)) {
LOGGER.trace("Policy rule evaluation context is not of type ObjectPolicyRuleEvaluationContext. Skipping processing.");
return null;
}
ObjectPolicyRuleEvaluationContext<AH> ctx = (ObjectPolicyRuleEvaluationContext<AH>) rctx;
if (modificationConstraintMatches(constraint, ctx, result)) {
LocalizableMessage message = createMessage(constraint, rctx, result);
LocalizableMessage shortMessage = createShortMessage(constraint, rctx, result);
return new EvaluatedModificationTrigger(PolicyConstraintKindType.OBJECT_MODIFICATION, constraint.getValue(), null, message, shortMessage);
} else {
LOGGER.trace("No operation matches.");
return null;
}
} catch (Throwable t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.model.api.context.EvaluatedModificationTrigger in project midpoint by Evolveum.
the class AssignmentModificationConstraintEvaluator method evaluate.
@Override
public <AH extends AssignmentHolderType> EvaluatedModificationTrigger evaluate(@NotNull JAXBElement<AssignmentModificationPolicyConstraintType> constraintElement, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
try {
if (!(rctx instanceof AssignmentPolicyRuleEvaluationContext)) {
LOGGER.trace("Not an AssignmentPolicyRuleEvaluationContext: {}", rctx.getClass());
return null;
}
AssignmentPolicyRuleEvaluationContext<AH> ctx = (AssignmentPolicyRuleEvaluationContext<AH>) rctx;
if (!ctx.isDirect) {
LOGGER.trace("Assignment is indirect => not triggering");
return null;
}
AssignmentModificationPolicyConstraintType constraint = constraintElement.getValue();
if (!operationMatches(constraint, ctx.isAdded, ctx.isKept, ctx.isDeleted) || !relationMatches(constraint, ctx) || !pathsMatch(constraint, ctx) || !expressionPasses(constraintElement, ctx, result)) {
// Logging is done inside matcher methods
return null;
}
// TODO check modifications
EvaluatedModificationTrigger rv = new EvaluatedModificationTrigger(PolicyConstraintKindType.ASSIGNMENT_MODIFICATION, constraint, ctx.evaluatedAssignment.getTarget(), createMessage(constraintElement, ctx, result), createShortMessage(constraintElement, ctx, result));
result.addReturn("trigger", rv.toDiagShortcut());
return rv;
} catch (Throwable t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
Aggregations