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
katkav committed Sep 27, 2017
2 parents c57f278 + b17e252 commit 4836936
Show file tree
Hide file tree
Showing 84 changed files with 2,224 additions and 811 deletions.
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.util.CertCampaignTypeUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil;
import com.evolveum.midpoint.web.component.util.Selectable;
import com.evolveum.midpoint.web.page.admin.certification.CertDecisionHelper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -208,12 +209,11 @@ public String getConflictingTargets() {
return "";
}
Set<String> exclusions = new TreeSet<>();
for (EvaluatedPolicyRuleTriggerType trigger : assignmentCase.getAssignment().getTrigger()) {
if (!(trigger instanceof EvaluatedExclusionTriggerType)) {
continue;
}
EvaluatedExclusionTriggerType exclusionTrigger = (EvaluatedExclusionTriggerType) trigger;
ObjectReferenceType conflicting = exclusionTrigger.getConflictingObjectRef();
List<EvaluatedExclusionTriggerType> allExclusionTriggers = PolicyRuleTypeUtil
.getAllExclusionTriggers(assignmentCase.getAssignment().getTriggeredPolicyRule());

for (EvaluatedExclusionTriggerType trigger : allExclusionTriggers) {
ObjectReferenceType conflicting = trigger.getConflictingObjectRef();
if (conflicting == null) {
continue;
}
Expand Down
Expand Up @@ -32,6 +32,7 @@
import java.lang.reflect.Constructor;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Item is a common abstraction of Property and PropertyContainer.
Expand Down Expand Up @@ -312,6 +313,12 @@ public PrismValue findValue(PrismValue value, boolean ignoreMetadata) {
return null;
}

public List<? extends PrismValue> findValuesIgnoreMetadata(PrismValue value) {
return getValues().stream()
.filter(v -> v.equalsComplex(value, true, false))
.collect(Collectors.toList());
}

/**
* Returns value that is previous to the specified value.
* Note that the order is semantically insignificant and this is used only
Expand Down
Expand Up @@ -1671,6 +1671,10 @@ public static <C extends Containerable> List<C> asContainerables(List<PrismConta
return pcvs.stream().map(c -> c.asContainerable()).collect(Collectors.toList());
}

public static <C extends Containerable> Collection<C> asContainerables(Collection<PrismContainerValue<C>> pcvs) {
return pcvs.stream().map(c -> c.asContainerable()).collect(Collectors.toList());
}

/**
* Set origin type to all values and subvalues
*/
Expand Down
Expand Up @@ -27,6 +27,8 @@
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import org.apache.commons.collections4.CollectionUtils;

public class ContainerDelta<V extends Containerable> extends ItemDelta<PrismContainerValue<V>,PrismContainerDefinition<V>> implements PrismContainerable<V> {

Expand Down Expand Up @@ -183,9 +185,9 @@ private Collection findItemValues(Long id, ItemPath path, Collection<PrismContai
* Post processing of delta to expand missing values from the object. E.g. a delete deltas may
* be "id-only" so they contain only id of the value to delete. In such case locate the full value
* in the object and fill it into the delta.
* This method may even delete in-only values that are no longer present in the object.
* This method may even delete id-only values that are no longer present in the object.
*/
public <O extends Objectable> void expand(PrismObject<O> object) throws SchemaException {
public <O extends Objectable> void expand(PrismObject<O> object, Trace logger) throws SchemaException {
if (valuesToDelete != null) {
ItemPath path = this.getPath();
PrismContainer<Containerable> container = null;
Expand All @@ -195,7 +197,7 @@ public <O extends Objectable> void expand(PrismObject<O> object) throws SchemaEx
Iterator<PrismContainerValue<V>> iterator = valuesToDelete.iterator();
while (iterator.hasNext()) {
PrismContainerValue<V> deltaCVal = iterator.next();
if ((deltaCVal.getItems() == null || deltaCVal.getItems().isEmpty())) {
if (CollectionUtils.isEmpty(deltaCVal.getItems())) {
Long id = deltaCVal.getId();
if (id == null) {
throw new IllegalArgumentException("No id and no items in value "+deltaCVal+" in delete set in "+this);
Expand All @@ -216,7 +218,7 @@ public <O extends Objectable> void expand(PrismObject<O> object) throws SchemaEx
}
}

@Override
@Override
protected boolean isValueEquivalent(PrismContainerValue<V> a, PrismContainerValue<V> b) {
if (!super.isValueEquivalent(a, b)) {
return false;
Expand Down
Expand Up @@ -1500,6 +1500,12 @@ private void filterValuesSet(Collection<V> set, Function<V, Boolean> function) {

public abstract ItemDelta<V,D> clone();

public ItemDelta<V,D> cloneWithChangedParentPath(ItemPath newParentPath) {
ItemDelta<V,D> clone = clone();
clone.setParentPath(newParentPath);
return clone;
}

protected void copyValues(ItemDelta<V,D> clone) {
clone.definition = this.definition;
clone.elementName = this.elementName;
Expand Down
Expand Up @@ -185,6 +185,41 @@ public S_MaybeDelete add(Collection<? extends PrismValue> values) {
return this;
}

@Override
public S_ValuesEntry old(Object... realValues) {
return oldRealValues(Arrays.asList(realValues));
}

@Override
public S_ValuesEntry oldRealValues(Collection<?> realValues) {
for (Object v : realValues) {
if (v != null) {
currentDelta.addEstimatedOldValue(toPrismValue(currentDelta, v));
}
}
return this;
}

@Override
public S_ValuesEntry old(PrismValue... values) {
for (PrismValue v : values) {
if (v != null) {
currentDelta.addEstimatedOldValue(v);
}
}
return this;
}

@Override
public S_ValuesEntry old(Collection<? extends PrismValue> values) {
for (PrismValue v : values) {
if (v != null) {
currentDelta.addEstimatedOldValue(v);
}
}
return this;
}

@Override
public S_ItemEntry delete(Object... realValues) {
return deleteRealValues(Arrays.asList(realValues));
Expand Down
Expand Up @@ -42,5 +42,8 @@ public interface S_ValuesEntry {
S_ItemEntry replaceRealValues(Collection<?> realValues);
S_ItemEntry replace(PrismValue... values);
S_ItemEntry replace(Collection<? extends PrismValue> values);

S_ValuesEntry old(Object... realValues);
S_ValuesEntry oldRealValues(Collection<?> realValues);
S_ValuesEntry old(PrismValue... values);
S_ValuesEntry old(Collection<? extends PrismValue> values);
}
Expand Up @@ -72,19 +72,21 @@ public ItemPath(String... names) {
}
}

public ItemPath(Object... namesOrIds) {
this.segments = new ArrayList<>(namesOrIds.length);
for (Object nameOrId : namesOrIds) {
if (nameOrId instanceof QName) {
add((QName) nameOrId);
} else if (nameOrId instanceof String) {
add(stringToQName((String) nameOrId));
} else if (nameOrId instanceof Long) {
this.segments.add(new IdItemPathSegment((Long) nameOrId));
} else if (nameOrId instanceof Integer) {
this.segments.add(new IdItemPathSegment(((Integer) nameOrId).longValue()));
public ItemPath(Object... namesOrIdsOrSegments) {
this.segments = new ArrayList<>(namesOrIdsOrSegments.length);
for (Object nameOrIdOrSegment : namesOrIdsOrSegments) {
if (nameOrIdOrSegment instanceof ItemPathSegment) {
add((ItemPathSegment) nameOrIdOrSegment);
} else if (nameOrIdOrSegment instanceof QName) {
add((QName) nameOrIdOrSegment);
} else if (nameOrIdOrSegment instanceof String) {
add(stringToQName((String) nameOrIdOrSegment));
} else if (nameOrIdOrSegment instanceof Long) {
this.segments.add(new IdItemPathSegment((Long) nameOrIdOrSegment));
} else if (nameOrIdOrSegment instanceof Integer) {
this.segments.add(new IdItemPathSegment(((Integer) nameOrIdOrSegment).longValue()));
} else {
throw new IllegalArgumentException("Invalid item path segment value: " + nameOrId);
throw new IllegalArgumentException("Invalid item path segment value: " + nameOrIdOrSegment);
}
}
}
Expand Down
Expand Up @@ -633,4 +633,32 @@ private static Supplier<List<Map.Entry<String, JAXBElement<? extends AbstractPol
};
}

@NotNull
public static List<EvaluatedExclusionTriggerType> getAllExclusionTriggers(List<EvaluatedPolicyRuleType> rules) {
List<EvaluatedExclusionTriggerType> rv = new ArrayList<>();
getExclusionTriggersFromRules(rv, rules);
return rv;
}

private static void getExclusionTriggersFromRules(List<EvaluatedExclusionTriggerType> rv, List<EvaluatedPolicyRuleType> rules) {
for (EvaluatedPolicyRuleType rule : rules) {
getExclusionTriggersFromRule(rv, rule);
}
}

private static void getExclusionTriggersFromRule(List<EvaluatedExclusionTriggerType> rv, EvaluatedPolicyRuleType rule) {
getExclusionTriggersFromTriggers(rv, rule.getTrigger());
}

private static void getExclusionTriggersFromTriggers(List<EvaluatedExclusionTriggerType> rv, List<EvaluatedPolicyRuleTriggerType> triggers) {
for (EvaluatedPolicyRuleTriggerType trigger : triggers) {
if (trigger instanceof EvaluatedExclusionTriggerType) {
rv.add((EvaluatedExclusionTriggerType) trigger);
} else if (trigger instanceof EvaluatedEmbeddingTriggerType) {
getExclusionTriggersFromTriggers(rv, ((EvaluatedEmbeddingTriggerType) trigger).getEmbedded());
} else if (trigger instanceof EvaluatedSituationTriggerType) {
getExclusionTriggersFromRules(rv, ((EvaluatedSituationTriggerType) trigger).getSourceRule());
}
}
}
}
Expand Up @@ -363,8 +363,50 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:sequence>

<xsd:element name="policySituation" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
The policy situation(s) of this object. The situations are result of
evaluation of the policy rules. This property is recorded for each object
and can be used for reporting, diagnostics, target selection in certification
campaigns, etc.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.5</a:since>
<a:operational>true</a:operational>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="triggeredPolicyRule" type="tns:EvaluatedPolicyRuleType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Triggered policy rules for this assignment. (Not necessarily complete; subject to specified storage strategy.)
This is EXPERIMENTAL functionality. It is possibly to change in the near future.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7</a:since>
<a:operational>true</a:operational>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="policyException" type="tns:PolicyExceptionType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Recorded exception from a policy rule. The exceptions that are approved are
recoded here to avoid re-evaluating and re-approving them all the time.
This is EXPERIMENTAL functionality. It is likely to change in the near future.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.5</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:sequence>

<xsd:attribute name="oid" type="xsd:string" use="optional">
<xsd:annotation>
Expand Down Expand Up @@ -2400,22 +2442,7 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="policySituation" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
The policy situation(s) of this object. The situations are result of
evaluation of the policy rules. This property is recorded for each object
and can be used for reporting, diagnostics, target selection in certification
campaigns, etc.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.5</a:since>
<a:operational>true</a:operational>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:sequence>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down Expand Up @@ -3493,12 +3520,25 @@
<xsd:element name="trigger" type="tns:EvaluatedPolicyRuleTriggerType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Fired policy rule triggers for this assignment. (Some fields of the triggers might be zeroed out
in order to save space. This is yet to be decided.)
This is EXPERIMENTAL functionality. It is likely to change in the near future.
DEPRECATED. DO NOT USE.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>3.7</a:deprecatedSince>
<a:operational>true</a:operational>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="triggeredPolicyRule" type="tns:EvaluatedPolicyRuleType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Triggered policy rules for this assignment. (Not necessarily complete; subject to specified storage strategy.)
This is EXPERIMENTAL functionality. It is possibly to change in the near future.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7</a:since>
<a:operational>true</a:operational>
</xsd:appinfo>
</xsd:annotation>
Expand Down

0 comments on commit 4836936

Please sign in to comment.