Skip to content

Commit

Permalink
Fixing MID-1709. Fixing gui bug when editing user account values. Whe…
Browse files Browse the repository at this point in the history
…n adding single-valued properties, pushing values via REPLACE (instead of ADD).
  • Loading branch information
mederly committed Mar 18, 2015
1 parent e9e8944 commit c5f31d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Expand Up @@ -537,6 +537,11 @@ public ObjectDelta getObjectDelta() throws SchemaException {
// password change will always look like add,
// therefore we push replace
pDelta.setValuesToReplace(Arrays.asList(newValCloned));
} else if (propertyDef.isSingleValue()) {
// values for single-valued properties should be pushed via replace
// in order to prevent problems e.g. with summarizing deltas for
// unreachable resources
pDelta.setValueToReplace(newValCloned);
} else {
pDelta.addValueToAdd(newValCloned);
}
Expand Down
Expand Up @@ -1493,8 +1493,10 @@ private Collection<SimpleValidationError> performCustomValidation(PrismObject<Us
if(userModel != null && userModel.getObject() != null && userModel.getObject().getObject() != null){
user = userModel.getObject().getObject();

for(ObjectDelta delta: deltas){
delta.applyTo(user);
for (ObjectDelta delta: deltas) {
if (UserType.class.isAssignableFrom(delta.getObjectTypeClass())) { // because among deltas there can be also ShadowType deltas
delta.applyTo(user);
}
}
}
}
Expand Down
Expand Up @@ -162,9 +162,14 @@ private ObjectDelta mergeDeltas(PrismObject<ShadowType> shadow, Collection<? ext
Collection<? extends ItemDelta> pendingModifications = DeltaConvertor.toModifications(
deltaType.getItemDelta(), shadow.getDefinition());

return ObjectDelta.summarize(ObjectDelta.createModifyDelta(shadow.getOid(), modifications,
ShadowType.class, getPrismContext()), ObjectDelta.createModifyDelta(shadow.getOid(),
pendingModifications, ShadowType.class, getPrismContext()));
// pendingModifications must come before modifications, otherwise REPLACE of value X (pending),
// followed by ADD of value Y (current) would become "REPLACE X", which is obviously wrong.
// See e.g. MID-1709.
return ObjectDelta.summarize(
ObjectDelta.createModifyDelta(shadow.getOid(), pendingModifications,
ShadowType.class, getPrismContext()),
ObjectDelta.createModifyDelta(shadow.getOid(), modifications,
ShadowType.class, getPrismContext()));
}
return null;
}
Expand Down

0 comments on commit c5f31d9

Please sign in to comment.