Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 21, 2016
2 parents 278d1f8 + 742fc56 commit 0c4e28b
Show file tree
Hide file tree
Showing 6 changed files with 551 additions and 17 deletions.
Expand Up @@ -8267,9 +8267,72 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="strength" type="tns:ConstructionStrengthType" minOccurs="0" maxOccurs="1" default="strong">
<xsd:annotation>
<xsd:documentation>
Strength of the construction defines how aggressively will
the construction be applied. Strong constructions are applied
all the time (relative changes, reconciliation, ...).
Weak constructions are applied only if there is another
strong construction.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.5</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="construction" type="tns:ConstructionType"/>

<xsd:simpleType name="ConstructionStrengthType">
<xsd:annotation>
<xsd:documentation>
<p>
Strength of the construction defines how aggressively will
the construction be applied. Strong constructions are applied
all the time (relative changes, reconciliation, ...).
Weak constructions are applied only if there is another
strong construction.
</p>
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="strong">
<xsd:annotation>
<xsd:documentation>
<p>
Always applied, regardless of context.
</p>
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="STRONG"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="weak">
<xsd:annotation>
<xsd:documentation>
<p>
Construction is applied only if there is another
strong construction for the same project. I.e.
weak construction do not entitle the focus to anything
just by themselves. There must be another reason for the
projection to exist. If there is, then the weak construction
will be also applied. If it is not then the weak construction
is ignored.
</p>
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="WEAK"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>


<xsd:complexType name="ObjectTemplateType">
Expand Down
Expand Up @@ -76,6 +76,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionStrengthType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType;
Expand Down Expand Up @@ -260,6 +261,10 @@ public String getIntent() {
public Object getDescription() {
return constructionType.getDescription();
}

public boolean isWeak() {
return constructionType.getStrength() == ConstructionStrengthType.WEAK;
}

public boolean isValid() {
return isValid;
Expand Down Expand Up @@ -789,6 +794,9 @@ public String debugDump(int indent) {
} else {
sb.append(refinedObjectClassDefinition.getShadowDiscriminator());
}
if (constructionType != null && constructionType.getStrength() == ConstructionStrengthType.WEAK) {
sb.append(" weak");
}
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "isValid", isValid, indent + 1);
sb.append("\n");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Evolveum
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +57,16 @@ public boolean hasValidAssignment() {
public void setHasValidAssignment(boolean hasValidAssignment) {
this.hasValidAssignment = hasValidAssignment;
}


public boolean hasStrongConstruction() {
for (PrismPropertyValue<Construction> construction: constructions) {
if (!construction.getValue().isWeak()) {
return true;
}
}
return false;
}

@Override
public String toString() {
return "ConstructionPack(" + SchemaDebugUtil.prettyPrint(constructions) + (forceRecon ? ", forceRecon" : "") + ")";
Expand All @@ -80,7 +89,5 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabel(sb, "Constructions", constructions, indent + 1);
return sb.toString();
}



}
Expand Up @@ -603,11 +603,30 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo

String desc = rat.toHumanReadableString();

ConstructionPack zeroConstructionPack = constructionMapTriple.getZeroMap().get(rat);
ConstructionPack plusConstructionPack = constructionMapTriple.getPlusMap().get(rat);

if (LOGGER.isTraceEnabled()) {
if (zeroConstructionPack == null) {
LOGGER.trace("ZERO construction pack: null");
} else {
LOGGER.trace("ZERO construction pack (hasValidAssignment={}, hasStrongConstruction={})\n{}",
new Object[]{zeroConstructionPack.hasValidAssignment(), zeroConstructionPack.hasStrongConstruction(),
zeroConstructionPack.debugDump(1)});
}
if (plusConstructionPack == null) {
LOGGER.trace("PLUS construction pack: null");
} else {
LOGGER.trace("PLUS construction pack (hasValidAssignment={}, hasStrongConstruction={})\n{}",
new Object[]{plusConstructionPack.hasValidAssignment(), plusConstructionPack.hasStrongConstruction(),
plusConstructionPack.debugDump(1)});
}
}

// SITUATION: The projection is ASSIGNED
if (constructionMapTriple.getPlusMap().containsKey(rat)) {
if (plusConstructionPack != null && plusConstructionPack.hasStrongConstruction()) {

ConstructionPack constructionPack = constructionMapTriple.getPlusMap().get(rat);
if (constructionPack.hasValidAssignment()) {
if (plusConstructionPack.hasValidAssignment()) {
LensProjectionContext projectionContext = LensUtil.getOrCreateProjectionContext(context, rat);
projectionContext.setAssigned(true);
projectionContext.setAssignedOld(false);
Expand All @@ -623,7 +642,7 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
}

// SITUATION: The projection should exist (is valid), there is NO CHANGE in assignments
} else if (constructionMapTriple.getZeroMap().containsKey(rat) && constructionMapTriple.getZeroMap().get(rat).hasValidAssignment()) {
} else if (zeroConstructionPack != null && zeroConstructionPack.hasValidAssignment() && zeroConstructionPack.hasStrongConstruction()) {

LensProjectionContext projectionContext = context.findProjectionContext(rat);
if (projectionContext == null) {
Expand Down Expand Up @@ -767,22 +786,34 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
projectionContext.setLegalOld(false);
projectionContext.setAssigned(false);
projectionContext.setAssignedOld(false);

// This is a legal state. We do not need to do anything. But we want to log the message
// and we do not want the "looney" error below.
} else if (plusConstructionPack != null && !plusConstructionPack.hasStrongConstruction()) {

// Just ignore it, do not even create projection context
LOGGER.trace("Projection {} ignoring: assigned (weak only)", desc);


} else {
throw new IllegalStateException("Projection " + desc + " went looney");
}

PrismValueDeltaSetTriple<PrismPropertyValue<Construction>> accountDeltaSetTriple =
PrismValueDeltaSetTriple<PrismPropertyValue<Construction>> projectionConstructionDeltaSetTriple =
new PrismValueDeltaSetTriple<PrismPropertyValue<Construction>>(
getConstructions(constructionMapTriple.getZeroMap().get(rat), true),
getConstructions(constructionMapTriple.getPlusMap().get(rat), true),
getConstructions(constructionMapTriple.getMinusMap().get(rat), false));
LensProjectionContext accountContext = context.findProjectionContext(rat);
if (accountContext != null) {
LensProjectionContext projectionContext = context.findProjectionContext(rat);
if (projectionContext != null) {
// This can be null in a exotic case if we delete already deleted account
accountContext.setConstructionDeltaSetTriple(accountDeltaSetTriple);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Construction delta set triple for {}:\n{}", rat,
projectionConstructionDeltaSetTriple.debugDump(1));
}
projectionContext.setConstructionDeltaSetTriple(projectionConstructionDeltaSetTriple);
if (isForceRecon(constructionMapTriple.getZeroMap().get(rat)) || isForceRecon(constructionMapTriple.getPlusMap().get(rat)) || isForceRecon(constructionMapTriple.getMinusMap().get(rat))) {
accountContext.setDoReconciliation(true);
projectionContext.setDoReconciliation(true);
}
}

Expand Down Expand Up @@ -935,7 +966,7 @@ private <F extends FocusType> void collectToConstructionMaps(LensContext<F> cont
collectToConstructionMapFromEvaluatedAssignments(context, evaluatedAssignmentTriple.getMinusSet(), constructionMapTriple, PlusMinusZero.MINUS, task, result);
}

private <F extends FocusType> void collectToConstructionMapFromEvaluatedAssignments(LensContext<F> context,
private <F extends FocusType> void collectToConstructionMapFromEvaluatedAssignments(LensContext<F> context,
Collection<EvaluatedAssignmentImpl<F>> evaluatedAssignments,
DeltaMapTriple<ResourceShadowDiscriminator, ConstructionPack> constructionMapTriple, PlusMinusZero mode, Task task,
OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
Expand Down Expand Up @@ -988,9 +1019,6 @@ private <F extends FocusType> void collectToConstructionMapFromEvaluatedConstruc
}
}




private Collection<PrismContainerValue<AssignmentType>> mergeAssignments(
Collection<PrismContainerValue<AssignmentType>> currentAssignments,
Collection<PrismContainerValue<AssignmentType>> changedAssignments) {
Expand Down

0 comments on commit 0c4e28b

Please sign in to comment.