Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Sep 5, 2019
2 parents 351cd77 + 234429e commit 9dd6137
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 18 deletions.
Expand Up @@ -217,7 +217,7 @@ public String getDocumentationPreview() {
public String getIntent() {
return structuralObjectClassDefinition.getIntent();
}

@Override
public ShadowKindType getKind() {
return structuralObjectClassDefinition.getKind();
Expand Down Expand Up @@ -379,6 +379,11 @@ public AttributeFetchStrategyType getActivationFetchStrategy(QName propertyName)
public boolean matches(ShadowType shadowType) {
return structuralObjectClassDefinition.matches(shadowType);
}

@Override
public boolean matchesWithoutIntent(ShadowType shadowType) {
return structuralObjectClassDefinition.matchesWithoutIntent(shadowType);
}

@Override
public CapabilitiesType getCapabilities() {
Expand Down
Expand Up @@ -556,6 +556,11 @@ public Collection<? extends QName> getNamesOfAssociationsWithInboundExpressions(
public boolean matches(ShadowType shadowType) {
return refinedObjectClassDefinition.matches(shadowType);
}

@Override
public boolean matchesWithoutIntent(ShadowType shadowType) {
return refinedObjectClassDefinition.matchesWithoutIntent(shadowType);
}

@Override
public int hashCode() {
Expand Down
Expand Up @@ -136,7 +136,6 @@ default Collection<? extends RefinedAttributeDefinition<?>> getAllIdentifiers()
ProjectionPolicyType getProjection();
//endregion


//region Generating and matching artifacts ========================================================
PrismObjectDefinition<ShadowType> getObjectDefinition();

Expand All @@ -150,6 +149,8 @@ default PrismObject<ShadowType> createBlankShadow() {

@Override
boolean matches(ShadowType shadowType);

boolean matchesWithoutIntent(ShadowType shadowType);
//endregion

//region Accessing parts of schema handling ========================================================
Expand Down
Expand Up @@ -303,7 +303,7 @@ public void setSearchHierarchyScope(SearchHierarchyScope searchHierarchyScope) {
public String getIntent() {
return intent;
}

public void setIntent(String intent) {
this.intent = intent;
}
Expand Down Expand Up @@ -401,6 +401,23 @@ public ResourceShadowDiscriminator getShadowDiscriminator() {

@Override
public boolean matches(ShadowType shadowType) {
if (!matchesWithoutIntent(shadowType)) {
return false;
}
if (shadowType.getIntent() != null) {
// if (isDefault) {
// return true;
// } else {
// return false;
// }
// } else {
return MiscUtil.equals(intent, shadowType.getIntent());
}
return true;
}

@Override
public boolean matchesWithoutIntent(ShadowType shadowType) {
if (shadowType == null) {
return false;
}
Expand All @@ -416,15 +433,6 @@ public boolean matches(ShadowType shadowType) {
return false;
}
}
if (shadowType.getIntent() != null) {
// if (isDefault) {
// return true;
// } else {
// return false;
// }
// } else {
return MiscUtil.equals(intent, shadowType.getIntent());
}
return true;
}

Expand Down
Expand Up @@ -45,6 +45,7 @@
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
Expand Down Expand Up @@ -300,15 +301,24 @@ public TaskWorkBucketProcessingResult run(RunningTask localCoordinatorTask, Work
long beforeResourceReconTimestamp = clock.currentTimeMillis();
long afterResourceReconTimestamp;
long afterShadowReconTimestamp;

boolean intentIsNull = false;
PrismProperty<String> intentProperty = localCoordinatorTask.getExtensionPropertyOrClone(ModelConstants.INTENT_PROPERTY_NAME);
String intent = null;
if (intentProperty != null) {
intent = intentProperty.getValue().getValue();
}
intentIsNull = (intent == null);

try {
if (isStage(stage, Stage.SECOND) && !performResourceReconciliation(resource, objectclassDef, reconResult,
localCoordinatorTask, partitionDefinition, workBucket, opResult)) {
localCoordinatorTask, partitionDefinition, workBucket, opResult, intentIsNull)) {
processInterruption(runResult, resource, localCoordinatorTask, opResult);
return runResult;
}
afterResourceReconTimestamp = clock.currentTimeMillis();
if (isStage(stage, Stage.THIRD) && !performShadowReconciliation(resource, objectclassDef, reconStartTimestamp,
afterResourceReconTimestamp, reconResult, localCoordinatorTask, workBucket, opResult)) {
afterResourceReconTimestamp, reconResult, localCoordinatorTask, workBucket, opResult, intentIsNull)) {
processInterruption(runResult, resource, localCoordinatorTask, opResult);
return runResult;
}
Expand Down Expand Up @@ -511,7 +521,7 @@ private void processErrorPartial(TaskRunResult runResult, String errorDesc, Exce
private boolean performResourceReconciliation(PrismObject<ResourceType> resource,
ObjectClassComplexTypeDefinition objectclassDef,
ReconciliationTaskResult reconResult, RunningTask localCoordinatorTask,
TaskPartitionDefinitionType partitionDefinition, WorkBucketType workBucket, OperationResult result)
TaskPartitionDefinitionType partitionDefinition, WorkBucketType workBucket, OperationResult result, boolean intentIsNull)
throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException,
SecurityViolationException, ExpressionEvaluationException {

Expand All @@ -527,6 +537,7 @@ private boolean performResourceReconciliation(PrismObject<ResourceType> resource
handler.setStopOnError(false);
handler.setEnableSynchronizationStatistics(true);
handler.setEnableActionsExecutedStatistics(true);
handler.setIntentIsNull(intentIsNull);

localCoordinatorTask.setExpectedTotal(null);

Expand Down Expand Up @@ -582,7 +593,7 @@ private boolean performResourceReconciliation(PrismObject<ResourceType> resource
private boolean performShadowReconciliation(final PrismObject<ResourceType> resource,
final ObjectClassComplexTypeDefinition objectclassDef,
long startTimestamp, long endTimestamp, ReconciliationTaskResult reconResult, RunningTask localCoordinatorTask,
WorkBucketType workBucket, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, ConfigurationException, CommunicationException {
WorkBucketType workBucket, OperationResult result, boolean intentIsNull) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, ConfigurationException, CommunicationException {
boolean interrupted;

// find accounts
Expand All @@ -609,7 +620,14 @@ private boolean performShadowReconciliation(final PrismObject<ResourceType> reso
final Holder<Long> countHolder = new Holder<>(0L);

ResultHandler<ShadowType> handler = (shadow, parentResult) -> {
if ((objectclassDef instanceof RefinedObjectClassDefinition) && !objectclassDef.matches(shadow.asObjectable())) {
boolean isMatches;
if (intentIsNull && objectclassDef instanceof RefinedObjectClassDefinition) {
isMatches = ((RefinedObjectClassDefinition)objectclassDef).matchesWithoutIntent(shadow.asObjectable());
} else {
isMatches = objectclassDef.matches(shadow.asObjectable());
}

if ((objectclassDef instanceof RefinedObjectClassDefinition) && !isMatches) {
return true;
}

Expand Down
Expand Up @@ -17,6 +17,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.model.impl.importer.ImportAccountsFromResourceTaskHandler;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.prism.PrismObject;
Expand Down Expand Up @@ -66,6 +67,7 @@ public class SynchronizeAccountResultHandler extends AbstractSearchIterativeResu
private ObjectClassComplexTypeDefinition objectClassDef;
private QName sourceChannel;
private boolean forceAdd;
private boolean intentIsNull;

public SynchronizeAccountResultHandler(ResourceType resource, ObjectClassComplexTypeDefinition objectClassDef,
String processShortName, RunningTask coordinatorTask, ResourceObjectChangeListener objectChangeListener,
Expand All @@ -80,6 +82,10 @@ public SynchronizeAccountResultHandler(ResourceType resource, ObjectClassComplex
// we are not called via AbstractSearchIterativeResultHandler.processRequest
}

public void setIntentIsNull(boolean intentIsNull) {
this.intentIsNull = intentIsNull;
}

public boolean isForceAdd() {
return forceAdd;
}
Expand Down Expand Up @@ -151,7 +157,15 @@ protected boolean handleObjectInternal(PrismObject<ShadowType> accountShadow, Ru
return workerTask.canRun();
}

if (objectClassDef != null && !isShadowUnknown(newShadowType) && !objectClassDef.matches(newShadowType)) {
boolean isMatches;
if (intentIsNull && objectClassDef instanceof RefinedObjectClassDefinition) {
isMatches = ((RefinedObjectClassDefinition)objectClassDef).matchesWithoutIntent(newShadowType);
} else {
isMatches = objectClassDef.matches(newShadowType);
}


if (objectClassDef != null && !isShadowUnknown(newShadowType) && !isMatches) {
LOGGER.trace("{} skipping {} because it does not match objectClass/kind/intent specified in {}",
getProcessShortNameCapitalized(), accountShadow, objectClassDef);
result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it does not match objectClass/kind/intent");
Expand Down

0 comments on commit 9dd6137

Please sign in to comment.