Skip to content

Commit

Permalink
Fixing recording of modify provisioning deltas
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Sep 5, 2017
1 parent c7cfdf6 commit a0f5272
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
Expand Up @@ -497,7 +497,7 @@ public AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyVa
for (ItemDelta modification: itemDeltas) {
ItemPath path = modification.getPath();
QName firstPathName = ItemPath.getFirstName(path);
if (QNameUtil.match(firstPathName, ShadowType.F_ATTRIBUTES)) {
if (ProvisioningUtil.isAttributeModification(firstPathName)) {
hasResourceModification = true;
QName attrName = ItemPath.getFirstName(path.rest());
RefinedAttributeDefinition<Object> attrDef = ctx.getObjectClassDefinition().findAttributeDefinition(attrName);
Expand All @@ -506,8 +506,7 @@ public AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyVa
hasVolatilityTriggerModification = true;
break;
}
} else if (QNameUtil.match(firstPathName, ShadowType.F_ACTIVATION) || QNameUtil.match(firstPathName, ShadowType.F_CREDENTIALS) ||
QNameUtil.match(firstPathName, ShadowType.F_ASSOCIATION) || QNameUtil.match(firstPathName, ShadowType.F_AUXILIARY_OBJECT_CLASS)) {
} else if (ProvisioningUtil.isNonAttributeResourceModification(firstPathName)) {
hasResourceModification = true;
}
}
Expand Down
Expand Up @@ -1005,8 +1005,16 @@ private boolean isInProgressOrRequested(OperationResultStatusType resultStatus,

public PendingOperationType checkAndRecordPendingModifyOperationBeforeExecution(ProvisioningContext ctx,
PrismObject<ShadowType> repoShadow, Collection<? extends ItemDelta> modifications, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {

ObjectDelta<ShadowType> proposedDelta = createModifyDelta(repoShadow, modifications);
Collection<ItemDelta> resourceModifications = new ArrayList<>(modifications.size());
for (ItemDelta modification: modifications) {
if (ProvisioningUtil.isResourceModification(modification)) {
resourceModifications.add(modification);
}
}
if (resourceModifications.isEmpty()) {
return null;
}
ObjectDelta<ShadowType> proposedDelta = createModifyDelta(repoShadow, resourceModifications);
return checkAndRecordPendingOperationBeforeExecution(ctx, repoShadow, proposedDelta, task, parentResult);
}

Expand Down
Expand Up @@ -20,9 +20,11 @@
import com.evolveum.midpoint.common.StaticExpressionUtil;
import com.evolveum.midpoint.common.refinery.*;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.match.MatchingRule;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.provisioning.impl.ConnectorSpec;
import com.evolveum.midpoint.provisioning.impl.ProvisioningContext;
import com.evolveum.midpoint.provisioning.ucf.api.AttributesToReturn;
Expand Down Expand Up @@ -483,5 +485,32 @@ public static CachingStategyType getCachingStrategy(ProvisioningContext ctx)
public static boolean shouldDoRepoSearch(GetOperationOptions rootOptions) {
return GetOperationOptions.isNoFetch(rootOptions) || GetOperationOptions.isMaxStaleness(rootOptions);
}

public static boolean isResourceModification(ItemDelta modification) {
ItemPath path = modification.getPath();
QName firstPathName = ItemPath.getFirstName(path);
return isAttributeModification(firstPathName) || isNonAttributeResourceModification(firstPathName);
}

public static boolean isAttributeModification(ItemDelta modification) {
ItemPath path = modification.getPath();
QName firstPathName = ItemPath.getFirstName(path);
return isAttributeModification(firstPathName);
}

public static boolean isAttributeModification(QName firstPathName) {
return QNameUtil.match(firstPathName, ShadowType.F_ATTRIBUTES);
}

public static boolean isNonAttributeResourceModification(ItemDelta modification) {
ItemPath path = modification.getPath();
QName firstPathName = ItemPath.getFirstName(path);
return isNonAttributeResourceModification(firstPathName);
}

public static boolean isNonAttributeResourceModification(QName firstPathName) {
return QNameUtil.match(firstPathName, ShadowType.F_ACTIVATION) || QNameUtil.match(firstPathName, ShadowType.F_CREDENTIALS) ||
QNameUtil.match(firstPathName, ShadowType.F_ASSOCIATION) || QNameUtil.match(firstPathName, ShadowType.F_AUXILIARY_OBJECT_CLASS);
}

}
Expand Up @@ -20,16 +20,13 @@
package com.evolveum.midpoint.provisioning.impl.dummy;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand Down

0 comments on commit a0f5272

Please sign in to comment.