Skip to content

Commit

Permalink
Fix identifier attribute consolidation
Browse files Browse the repository at this point in the history
An assert in IvwoConsolidator was wrong when dealing with identifier
attributes (that are known because they are in repo) of shadows that
were not fetched. This is now fixed by weakening the assert as well
as treating identifier attributes as always known.
  • Loading branch information
mederly committed Jul 5, 2021
1 parent f3a849d commit bcf7a05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ default boolean isPrimaryIdentifier(QName attrName) {
.anyMatch(idDef -> QNameUtil.match(idDef.getItemName(), attrName));
}

default boolean isIdentifier(QName attrName) {
return isPrimaryIdentifier(attrName) || isSecondaryIdentifier(attrName);
}

/**
* Returns the definition of secondary identifier attributes of a resource
* object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private void addValueIfNeeded() throws CommunicationException, ObjectNotFoundExc
}

LOGGER.trace("Decided to ADD value {} to delta for item {} in {}", equivalenceClass, itemPath, contextDescription);
assert equivalenceClass.getPresenceInExistingItem().isEmpty();
assert !existingItemKnown || equivalenceClass.getPresenceInExistingItem().isEmpty();

if (valueMetadataComputer != null) {
decideAccordingToMetadata("adding-new (#1)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ private <V extends PrismValue,D extends ItemDefinition> ItemDelta<V,D> consolida
LOGGER.trace("CONSOLIDATE {}\n ({}) completeShadow={}, addUnchangedValues={}, forceAddUnchangedValues={}",
itemDesc, discr, projCtx.hasFullShadow(), addUnchangedValues, forceAddUnchangedValues);

boolean existingItemKnown = projCtx.hasFullShadow() || rOcDef.isIdentifier(itemDefinition.getItemName());
ItemDelta<V, D> itemDelta;
// Use the consolidator to do the computation. It does most of the work.
try (IvwoConsolidator<V,D,ItemValueWithOrigin<V,D>> consolidator = new IvwoConsolidatorBuilder<V,D,ItemValueWithOrigin<V, D>>()
Expand All @@ -413,10 +414,10 @@ private <V extends PrismValue,D extends ItemDefinition> ItemDelta<V,D> consolida
.comparator(comparator)
.addUnchangedValues(addUnchangedValues || forceAddUnchangedValues)
.addUnchangedValuesExceptForNormalMappings(true) // todo
.existingItemKnown(projCtx.hasFullShadow())
.existingItemKnown(existingItemKnown)
.isExclusiveStrong(isExclusiveStrong)
.contextDescription(discr.toHumanReadableDescription())
.strengthSelector(projCtx.hasFullShadow() ? strengthSelector : strengthSelector.notWeak())
.strengthSelector(existingItemKnown ? strengthSelector : strengthSelector.notWeak())
.result(result)
.prismContext(prismContext)
.build()) {
Expand Down

0 comments on commit bcf7a05

Please sign in to comment.