Skip to content

Commit

Permalink
AssignmentProcessor: merged provenance metadata are compared as LITERAL
Browse files Browse the repository at this point in the history
This prevents changes in operational flag in the metadata schema to
change the behavior in the future.
Also, setReferences uses "old vlaues" from focusCtx.getObjectCurrent,
instead of getObjectOld, to reflect already applied modifications and
not repeating them (DeltaExecution would later skip them, but that's
not the point).
  • Loading branch information
virgo47 committed Feb 13, 2023
1 parent 66929c5 commit 11f9755
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1089,13 +1089,13 @@ private <F extends ObjectType> void setReferences(LensFocusContext<F> focusConte
Collection<PrismReferenceValue> targetState) throws SchemaException {

ItemName itemName = ItemName.fromQName(name);
PrismObject<F> focusOld = focusContext.getObjectOld();
if (focusOld == null) {
PrismObject<F> existingFocus = focusContext.getObjectCurrent();
if (existingFocus == null) {
if (targetState.isEmpty()) {
return;
}
} else {
PrismReference existingState = focusOld.findReference(itemName);
PrismReference existingState = existingFocus.findReference(itemName);
if (existingState == null || existingState.isEmpty()) {
if (targetState.isEmpty()) {
return;
Expand All @@ -1104,7 +1104,7 @@ private <F extends ObjectType> void setReferences(LensFocusContext<F> focusConte
List<PrismReferenceValue> existingValues = existingState.getValues();
adoptExistingStorageCreateTimestampValueMetadata(targetState, existingValues);
// We don't use QNameUtil.match here, because we want to ensure we store qualified values there
// (and newValues are all qualified)
// (and newValues are all qualified).
EqualsChecker<PrismReferenceValue> comparator =
(a, b) -> Objects.equals(a.getOid(), b.getOid())
&& Objects.equals(a.getRelation(), b.getRelation())
Expand Down Expand Up @@ -1149,7 +1149,10 @@ private void mergeAssignmentPathMetadata(PrismReferenceValue ref, PrismReference
}

PrismContainerValue<Containerable> originalMetadataValue = originalMetadataValues.stream()
.filter(m -> provenance.equals(((ValueMetadataType) m.asContainerable()).getProvenance()))
// LITERAL is important here not to ignore "operational" elements.
.filter(m -> provenance.asPrismContainerValue()
.equals(((ValueMetadataType) m.asContainerable()).getProvenance().asPrismContainerValue(),
EquivalenceStrategy.LITERAL))
.findFirst()
.orElse(null);
if (originalMetadataValue == null) {
Expand Down

0 comments on commit 11f9755

Please sign in to comment.