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);
}
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);
}
Aggregations