Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selfrelation #122

Open
wants to merge 2 commits into
base: support-4.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ test-output/

_mess
.checkstyle
gui/bin/com/
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.evolveum.midpoint.schema.RelationRegistry;
import com.evolveum.midpoint.schema.constants.ExpressionConstants;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.RelationTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.expression.ExpressionProfile;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
Expand Down Expand Up @@ -509,7 +510,8 @@ private <O extends ObjectType> boolean evaluateSegmentContent(AssignmentPathSegm
setEvaluatedAssignmentTarget(segment, targets, ctx);
}
for (PrismObject<O> target : targets) {
if (hasCycle(segment, target, ctx)) {
//MID-6341
if (hasCycle(segment, target, relation, ctx)) {
continue;
}
if (isDelegationToNonDelegableTarget(assignment, target, ctx)) {
Expand Down Expand Up @@ -549,10 +551,11 @@ private <O extends ObjectType> boolean isDelegationToNonDelegableTarget(Assignme
// number of times any given target is allowed to occur in the assignment path
private static final int MAX_TARGET_OCCURRENCES = 2;

//MID-6341
private <O extends ObjectType> boolean hasCycle(AssignmentPathSegmentImpl segment, @NotNull PrismObject<O> target,
EvaluationContext ctx) throws PolicyViolationException {
QName relation, EvaluationContext ctx) throws PolicyViolationException {
// TODO reconsider this
if (target.getOid().equals(segment.source.getOid())) {
if (target.getOid().equals(segment.source.getOid()) && !relation.equals(RelationTypes.APPROVER.getRelation())) {
throw new PolicyViolationException("The "+segment.source+" refers to itself in assignment/inducement");
}
// removed condition "&& segment.getEvaluationOrder().equals(ctx.assignmentPath.getEvaluationOrder())"
Expand Down