Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 30, 2014
2 parents c10c8e9 + 179e6a9 commit 0bdde0f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 24 deletions.
Expand Up @@ -768,15 +768,16 @@ public boolean matches(ShadowType shadowType) {
return false;
}
}
if (shadowType.getIntent() == null) {
if (isDefault) {
return true;
} else {
return false;
}
} else {
if (shadowType.getIntent() != null) {
// if (isDefault) {
// return true;
// } else {
// return false;
// }
// } else {
return MiscUtil.equals(intent, shadowType.getIntent());
}
}
return true;
}

@Override
Expand Down
Expand Up @@ -47,6 +47,7 @@
import com.evolveum.midpoint.model.common.expression.ExpressionVariables;
import com.evolveum.midpoint.model.common.expression.Source;
import com.evolveum.midpoint.model.common.expression.StringPolicyResolver;
import com.evolveum.midpoint.model.impl.ModelConstants;
import com.evolveum.midpoint.model.impl.controller.ModelController;
import com.evolveum.midpoint.model.impl.lens.Clockwork;
import com.evolveum.midpoint.model.impl.lens.ContextFactory;
Expand Down Expand Up @@ -174,22 +175,20 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task

OperationResult subResult = parentResult.createSubresult(NOTIFY_CHANGE);
try {
ResourceType resourceType = change.getResource().asObjectable();

PrismObject<? extends ShadowType> currentShadow = change.getCurrentShadow();
if (currentShadow != null) {
ShadowType currentShadowType = currentShadow.asObjectable();
if (currentShadowType.isProtectedObject() != null && currentShadowType.isProtectedObject()) {
LOGGER.trace("SYNCHRONIZATION skipping {} because it is protected", currentShadowType);
// Just make sure there is no misleading synchronization situation in the shadow
if (currentShadowType.getSynchronizationSituation() != null) {
ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, currentShadowType.getOid(),
ShadowType.F_SYNCHRONIZATION_SITUATION, prismContext);
provisioningService.modifyObject(ShadowType.class, currentShadowType.getOid(),
shadowDelta.getModifications(), null, null, task, subResult);
}
subResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it is protected");
return;

if (isProtected((PrismObject<ShadowType>) currentShadow)){
LOGGER.trace("SYNCHRONIZATION skipping {} because it is protected", currentShadow);
// Just make sure there is no misleading synchronization situation in the shadow
if (currentShadow.asObjectable().getSynchronizationSituation() != null) {
ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, currentShadow.getOid(),
ShadowType.F_SYNCHRONIZATION_SITUATION, prismContext);
provisioningService.modifyObject(ShadowType.class, currentShadow.getOid(),
shadowDelta.getModifications(), null, null, task, subResult);
}
subResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it is protected");
return;
}

PrismObject<? extends ShadowType> applicableShadow = currentShadow;
Expand All @@ -198,6 +197,7 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
applicableShadow = change.getOldShadow();
}

ResourceType resourceType = change.getResource().asObjectable();
PrismObject<SystemConfigurationType> configuration = Utils.getSystemConfiguration(repositoryService, subResult);

ObjectSynchronizationType synchronizationPolicy = determineSynchronizationPolicy(resourceType,
Expand All @@ -210,7 +210,7 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
subResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, message);
return;
}

if (!isSynchronizationEnabled(synchronizationPolicy)) {
String message = "SYNCHRONIZATION is not enabled for " + resourceType
+ " ignoring change from channel " + change.getSourceChannel();
Expand All @@ -219,6 +219,14 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
return;
}

//check if the kind/intent in the syncPolicy satisfy constaints defined in task
if (!satisfyTaskConstaints(synchronizationPolicy, task)){
LOGGER.trace("SYNCHRONIZATION skipping {} because it does not match kind/intent defined in task",new Object[] {
applicableShadow});
subResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it does not match objectClass/kind/intent");
return;
}

Class<? extends FocusType> focusType = determineFocusClass(synchronizationPolicy, resourceType);

if (LOGGER.isTraceEnabled()) {
Expand Down Expand Up @@ -272,6 +280,42 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
}
}

private boolean satisfyTaskConstaints(ObjectSynchronizationType synchronizationPolicy, Task task) {
PrismProperty<ShadowKindType> kind = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_KIND);
if (kind != null && !kind.isEmpty()){
ShadowKindType kindValue = kind.getRealValue();
if (!synchronizationPolicy.getKind().equals(kindValue)){
return false;
}
}

PrismProperty<String> intent = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_INTENT);
if (intent != null && !intent.isEmpty()){
String intentValue = intent.getRealValue();
if (StringUtils.isEmpty(synchronizationPolicy.getIntent())){
return false;
}
if (!synchronizationPolicy.getIntent().equals(intentValue)){
return false;
}
}

return true;
}

private boolean isProtected(PrismObject<ShadowType> shadow){
if (shadow == null){
return false;
}

ShadowType currentShadowType = shadow.asObjectable();
if (currentShadowType.isProtectedObject() == null){
return false;
}

return currentShadowType.isProtectedObject();
}

private <F extends FocusType> Class<F> determineFocusClass(ObjectSynchronizationType synchronizationPolicy, ResourceType resource) throws ConfigurationException {
QName focusTypeQName = synchronizationPolicy.getFocusType();
if (focusTypeQName == null) {
Expand Down
Expand Up @@ -392,7 +392,7 @@ public static boolean isDryRun(Task task) throws SchemaException{
return false;
}

PrismProperty<Boolean> item = task.getExtension().findProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
PrismProperty<Boolean> item = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
if (item == null || item.isEmpty()){
return false;
}
Expand Down

0 comments on commit 0bdde0f

Please sign in to comment.