Skip to content

Commit

Permalink
Fixing delta processing
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Dec 15, 2015
1 parent 30b476c commit 4448413
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Expand Up @@ -606,17 +606,16 @@ public ObjectDelta getObjectDelta() throws SchemaException {
if (!itemWrapper.hasChanged()) {
continue;
}
ItemPath path = containerWrapper.getPath() != null ? containerWrapper.getPath()
: new ItemPath();
ItemPath containerPath = containerWrapper.getPath() != null ? containerWrapper.getPath() : new ItemPath();
if (itemWrapper instanceof PropertyWrapper) {
ItemDelta pDelta = computePropertyDeltas((PropertyWrapper) itemWrapper, path);
ItemDelta pDelta = computePropertyDeltas((PropertyWrapper) itemWrapper, containerPath);
if (!pDelta.isEmpty()) {
delta.addModification(pDelta);
}
}

if (itemWrapper instanceof ReferenceWrapper) {
ReferenceDelta pDelta = computeReferenceDeltas((ReferenceWrapper) itemWrapper, path);
ReferenceDelta pDelta = computeReferenceDeltas((ReferenceWrapper) itemWrapper, containerPath);
if (!pDelta.isEmpty()) {
delta.addModification(pDelta);
}
Expand All @@ -633,33 +632,25 @@ public ObjectDelta getObjectDelta() throws SchemaException {
return delta;
}

private ItemDelta computePropertyDeltas(PropertyWrapper propertyWrapper, ItemPath path) {
private ItemDelta computePropertyDeltas(PropertyWrapper propertyWrapper, ItemPath containerPath) {
ItemDefinition itemDef = propertyWrapper.getItem().getDefinition();

ItemDelta pDelta = itemDef.createEmptyDelta(path);
// PropertyDelta pDelta = new PropertyDelta(path, itemDef.getName(), itemDef,
// itemDef.getPrismContext()); // hoping the
// // prismContext is there

addItemDelta(propertyWrapper, pDelta, itemDef, path);
ItemDelta pDelta = itemDef.createEmptyDelta(containerPath.subPath(itemDef.getName()));
addItemDelta(propertyWrapper, pDelta, itemDef, containerPath);
return pDelta;

}

private ReferenceDelta computeReferenceDeltas(ReferenceWrapper referenceWrapper, ItemPath path) {
private ReferenceDelta computeReferenceDeltas(ReferenceWrapper referenceWrapper, ItemPath containerPath) {
PrismReferenceDefinition propertyDef = referenceWrapper.getItem().getDefinition();

ReferenceDelta pDelta = new ReferenceDelta(path, propertyDef.getName(), propertyDef,
propertyDef.getPrismContext()); // hoping the
// prismContext is there

addItemDelta(referenceWrapper, pDelta, propertyDef, path);
ReferenceDelta pDelta = new ReferenceDelta(containerPath, propertyDef.getName(), propertyDef,
propertyDef.getPrismContext());
addItemDelta(referenceWrapper, pDelta, propertyDef, containerPath.subPath(propertyDef.getName()));
return pDelta;

}

private void addItemDelta(ItemWrapper itemWrapper, ItemDelta pDelta, ItemDefinition propertyDef,
ItemPath path) {
ItemPath containerPath) {
for (ValueWrapper valueWrapper : itemWrapper.getValues()) {
valueWrapper.normalize(propertyDef.getPrismContext());
ValueStatus valueStatus = valueWrapper.getStatus();
Expand All @@ -672,7 +663,7 @@ private void addItemDelta(ItemWrapper itemWrapper, ItemDelta pDelta, ItemDefinit
// capabilities
// todo this is bad hack because now we have not tri-state
// checkbox
if (SchemaConstants.PATH_ACTIVATION.equivalent(path)) {
if (SchemaConstants.PATH_ACTIVATION.equivalent(containerPath)) {

if (object.asObjectable() instanceof ShadowType
&& (((ShadowType) object.asObjectable()).getActivation() == null || ((ShadowType) object
Expand All @@ -690,7 +681,7 @@ private void addItemDelta(ItemWrapper itemWrapper, ItemDelta pDelta, ItemDefinit
switch (valueWrapper.getStatus()) {
case ADDED:
if (newValCloned != null) {
if (SchemaConstants.PATH_PASSWORD.equivalent(path)) {
if (SchemaConstants.PATH_PASSWORD.equivalent(containerPath)) {
// password change will always look like
// add,
// therefore we push replace
Expand Down
Expand Up @@ -135,6 +135,9 @@ public void setParentPath(ItemPath parentPath) {

@Override
public ItemPath getPath() {
if (getParentPath() == null) {
throw new IllegalStateException("No parent path in "+this);
}
return getParentPath().subPath(elementName);
}

Expand Down

0 comments on commit 4448413

Please sign in to comment.