Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 25, 2016
2 parents 9934f03 + 9744fa0 commit c44a5e5
Show file tree
Hide file tree
Showing 21 changed files with 743 additions and 551 deletions.
Expand Up @@ -44,6 +44,7 @@
*/
public class DeltaSetTriple<T> implements DebugDumpable, Serializable, SimpleVisitable<T>, Foreachable<T> {

// TODO decide if these sets can be null (and make them final)
/**
* Collection of values that were not changed.
*/
Expand Down Expand Up @@ -321,7 +322,7 @@ public DeltaSetTriple<T> clone(Cloner<T> cloner) {
protected void copyValues(DeltaSetTriple<T> clone, Cloner<T> cloner) {
clone.zeroSet = cloneSet(this.zeroSet, cloner);
clone.plusSet = cloneSet(this.plusSet, cloner);
clone.minusSet = cloneSet(this.minusSet, cloner);
clone.minusSet = cloneSet(this.minusSet, cloner);
}

private Collection<T> cloneSet(Collection<T> origSet, Cloner<T> cloner) {
Expand Down
Expand Up @@ -224,8 +224,8 @@ private <O extends ObjectType> void evaluateAssignment(EvaluatedAssignmentImpl<F
AssignmentPath assignmentPath, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException {
assertSource(source, evalAssignment);

LOGGER.trace("Evaluate assignment {} (eval constr: {}, mode: {})", new Object[]{
assignmentPath, assignmentPathSegment.isEvaluateConstructions(), mode});
LOGGER.trace("Evaluate assignment {} (eval constr: {}, mode: {})", assignmentPath, assignmentPathSegment.isEvaluateConstructions(),
mode);

ItemDeltaItem<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> assignmentIdi = assignmentPathSegment.getAssignmentIdi();
AssignmentType assignmentType = LensUtil.getAssignmentType(assignmentIdi, evaluateOld);
Expand All @@ -252,17 +252,20 @@ private <O extends ObjectType> void evaluateAssignment(EvaluatedAssignmentImpl<F
LOGGER.trace("Targets in {}: {}", source, targets);
if (targets != null) {
for (PrismObject<O> target: targets) {
evaluateAssignmentTarget(evalAssignment, assignmentPathSegment, evaluateOld, mode, isParentValid, source,
evaluateAssignmentWithResolvedTarget(evalAssignment, assignmentPathSegment, evaluateOld, mode, isParentValid, source,
sourceDescription, assignmentPath, assignmentType, target, task, result);
}
} else {
evaluateAssignmentTarget(evalAssignment, assignmentPathSegment, evaluateOld, mode, isParentValid, source,
evaluateAssignmentWithResolvedTarget(evalAssignment, assignmentPathSegment, evaluateOld, mode, isParentValid, source,
sourceDescription, assignmentPath, assignmentType, null, task, result);
}

}

private <O extends ObjectType> void evaluateAssignmentTarget(EvaluatedAssignmentImpl<F> evalAssignment, AssignmentPathSegment assignmentPathSegment,

/**
* Continues with assignment evaluation: Either there is a non-null (resolved) target, passed in "target" parameter,
* or traditional options stored in assignmentType (construction or focus mappings). TargetRef from assignmentType is ignored.
*/
private <O extends ObjectType> void evaluateAssignmentWithResolvedTarget(EvaluatedAssignmentImpl<F> evalAssignment, AssignmentPathSegment assignmentPathSegment,
boolean evaluateOld, PlusMinusZero mode, boolean isParentValid, ObjectType source, String sourceDescription,
AssignmentPath assignmentPath, AssignmentType assignmentType, PrismObject<O> target, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException {
if (target != null && evalAssignment.getTarget() == null) {
Expand All @@ -273,7 +276,7 @@ private <O extends ObjectType> void evaluateAssignmentTarget(EvaluatedAssignment
if (target.getOid().equals(source.getOid())) {
throw new PolicyViolationException("The "+source+" refers to itself in assignment/inducement");
}
if (assignmentPath.containsTarget((ObjectType) target.asObjectable())) {
if (assignmentPath.containsTarget(target.asObjectable())) {
throw new PolicyViolationException("Attempt to assign "+target+" creates a role cycle");
}
}
Expand All @@ -290,15 +293,14 @@ private <O extends ObjectType> void evaluateAssignmentTarget(EvaluatedAssignment
PlusMinusZero condMode = ExpressionUtil.computeConditionResultMode(condOld, condNew);
if (condMode == null || (condMode == PlusMinusZero.ZERO && !condNew)) {
LOGGER.trace("Skipping evaluation of "+assignmentType+" because of condition result ({} -> {}: {})",
new Object[]{ condOld, condNew, condMode });
condOld, condNew, condMode);
assignmentPath.remove(assignmentPathSegment);
evalAssignment.setValid(false);
return;
}
PlusMinusZero origMode = mode;
mode = PlusMinusZero.compute(mode, condMode);
LOGGER.trace("Evaluated condition in assignment {} -> {}: {} + {} = {}", new Object[]{
condOld, condNew, origMode, condMode, mode });
LOGGER.trace("Evaluated condition in assignment {} -> {}: {} + {} = {}", condOld, condNew, origMode, condMode, mode);
}

boolean isValid = LensUtil.isValid(assignmentType, now, activationComputer);
Expand Down Expand Up @@ -349,7 +351,7 @@ private void prepareConstructionEvaluation(EvaluatedAssignmentImpl<F> evaluatedA

LOGGER.trace("Preparing construction '{}' in {}", constructionType.getDescription(), source);

Construction<F> construction = new Construction<F>(constructionType, source);
Construction<F> construction = new Construction<>(constructionType, source);
// We have to clone here as the path is constantly changing during evaluation
construction.setAssignmentPath(assignmentPath.clone());
construction.setFocusOdo(focusOdo);
Expand Down Expand Up @@ -385,8 +387,8 @@ private void evaluateFocusMappings(EvaluatedAssignmentImpl<F> evaluatedAssignmen
AssignmentType assignmentTypeNew = LensUtil.getAssignmentType(assignmentPathSegment.getAssignmentIdi(), evaluateOld);
MappingsType mappingsType = assignmentTypeNew.getFocusMappings();

LOGGER.trace("Evaluate focus mappings '{}' in {} ({} mappings)",
new Object[]{mappingsType.getDescription(), source, mappingsType.getMapping().size()});
LOGGER.trace("Evaluate focus mappings '{}' in {} ({} mappings)",
mappingsType.getDescription(), source, mappingsType.getMapping().size());
AssignmentPathVariables assignmentPathVariables = LensUtil.computeAssignmentPathVariables(assignmentPath);

for (MappingType mappingType: mappingsType.getMapping()) {
Expand Down Expand Up @@ -497,6 +499,11 @@ private boolean evaluateAbstractRole(EvaluatedAssignmentImpl<F> assignment, Assi
boolean evaluateOld, PlusMinusZero mode, boolean isValid, AbstractRoleType roleType, ObjectType source, String sourceDescription,
AssignmentPath assignmentPath, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException {
assertSource(source, assignment);

if (!LensUtil.isValid(roleType, now, activationComputer)) {
LOGGER.trace("Skipping evaluation of " + roleType + " because it is not valid");
return false;
}

MappingType conditionType = roleType.getCondition();
if (conditionType != null) {
Expand Down Expand Up @@ -553,7 +560,7 @@ private boolean evaluateAbstractRole(EvaluatedAssignmentImpl<F> assignment, Assi
if (inducementOrder == evaluationOrder) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("E{}: evaluate inducement({}) {} in {}",
new Object[]{evaluationOrder, inducementOrder, dumpAssignment(roleInducement), roleType});
evaluationOrder, inducementOrder, dumpAssignment(roleInducement), roleType);
}
roleAssignmentPathSegment.setEvaluateConstructions(true);
roleAssignmentPathSegment.setEvaluationOrder(evaluationOrder);
Expand All @@ -568,14 +575,14 @@ private boolean evaluateAbstractRole(EvaluatedAssignmentImpl<F> assignment, Assi
} else {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("E{}: NOT evaluate inducement({}) {} in {}",
new Object[]{evaluationOrder, inducementOrder, dumpAssignment(roleInducement), roleType});
evaluationOrder, inducementOrder, dumpAssignment(roleInducement), roleType);
}
}
}
for (AssignmentType roleAssignment : roleType.getAssignment()) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("E{}: follow assignment {} in {}",
new Object[]{evaluationOrder, dumpAssignment(roleAssignment), roleType});
evaluationOrder, dumpAssignment(roleAssignment), roleType);
}
ItemDeltaItem<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> roleAssignmentIdi = new ItemDeltaItem<>();
roleAssignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(roleAssignment));
Expand Down Expand Up @@ -619,7 +626,7 @@ private boolean isApplicable(QName focusType, AbstractRoleType roleType) throws
if (!focusClass.equals(lensContext.getFocusClass())) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Skipping evaluation of {} because it is applicable only for {} and not for {}",
new Object[] { roleType, focusClass, lensContext.getFocusClass()});
roleType, focusClass, lensContext.getFocusClass());
}
return false;
}
Expand All @@ -633,7 +640,7 @@ private QName getTargetType(AssignmentPathSegment assignmentPathSegment){
public static String dumpAssignment(AssignmentType assignmentType) {
StringBuilder sb = new StringBuilder();
if (assignmentType.getConstruction() != null) {
sb.append("Constr '"+assignmentType.getConstruction().getDescription()+"' ");
sb.append("Constr '").append(assignmentType.getConstruction().getDescription()).append("' ");
}
if (assignmentType.getTargetRef() != null) {
sb.append("-> ").append(assignmentType.getTargetRef().getOid());
Expand Down
Expand Up @@ -304,7 +304,9 @@ public String debugDump(int indent) {
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "Target", target.toString(), indent+1);
}
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "Present in old object", isPresentInOldObject(), indent+1);
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "Present in current object", isPresentInCurrentObject(), indent+1);
return sb.toString();
}
Expand Down
Expand Up @@ -139,6 +139,12 @@ public class LensContext<F extends ObjectType> implements ModelContext<F> {

private Map<String,Long> sequences = new HashMap<>();

/**
* Moved from ProjectionValuesProcessor
* TODO consider if necessary to serialize to XML
*/
private List<LensProjectionContext> conflictingProjectionContexts = new ArrayList<>();

public LensContext(Class<F> focusClass, PrismContext prismContext, ProvisioningService provisioningService) {
Validate.notNull(prismContext, "No prismContext");

Expand Down Expand Up @@ -1015,4 +1021,16 @@ public Long getSequenceCounter(String sequenceOid) {
public void setSequenceCounter(String sequenceOid, long counter) {
sequences.put(sequenceOid, counter);
}

public List<LensProjectionContext> getConflictingProjectionContexts() {
return conflictingProjectionContexts;
}

public void addConflictingProjectionContext(LensProjectionContext conflictingContext) {
conflictingProjectionContexts.add(conflictingContext);
}

public void clearConflictingProjectionContexts() {
conflictingProjectionContexts.clear();
}
}
Expand Up @@ -154,18 +154,31 @@ public class LensProjectionContext extends LensElementContext<ShadowType> implem
*
* Intermediary computation result. It is stored to allow re-computing of account constructions during
* iterative computations.
*
* Source: AssignmentProcessor
* Target: ConsolidationProcessor / ReconciliationProcessor (via squeezed structures)
*/
private transient PrismValueDeltaSetTriple<PrismPropertyValue<Construction>> constructionDeltaSetTriple;

/**
* Triples for outbound mappings; similar to the above.
* Source: OutboundProcessor
* Target: ConsolidationProcessor / ReconciliationProcessor (via squeezed structures)
*/
private transient Construction outboundConstruction;

private transient Construction outboundConstruction;

private transient Collection<ResourceObjectTypeDependencyType> dependencies = null;

private transient Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>,PrismPropertyDefinition<?>>>> squeezedAttributes;
/**
* Postprocessed triples from the above two properties.
* Source: ConsolidationProcessor
* Target: ReconciliationProcessor
*/
private transient Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>,PrismPropertyDefinition<?>>>> squeezedAttributes;
private transient Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>,PrismContainerDefinition<ShadowAssociationType>>>> squeezedAssociations;
private transient Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<QName>,PrismPropertyDefinition<QName>>>> squeezedAuxiliaryObjectClasses;

// Cached copy, to avoid constructing it over and over again

private transient Collection<ResourceObjectTypeDependencyType> dependencies = null;

// Cached copy, to avoid constructing it over and over again
private transient PrismObjectDefinition<ShadowType> shadowDefinition = null;

private transient RefinedObjectClassDefinition structuralObjectClassDefinition;
Expand Down

0 comments on commit c44a5e5

Please sign in to comment.