Skip to content

Commit

Permalink
Refactor ShadowManager a little bit
Browse files Browse the repository at this point in the history
Here we moved ShadowManager to a separate package and factored out
delta computation functionality to ShadowDeltaComputer class.

Also added tests for faulty update of index-only cached attributes
(MID-5832).
  • Loading branch information
mederly committed Oct 8, 2019
1 parent 249084b commit 597adb2
Show file tree
Hide file tree
Showing 18 changed files with 526 additions and 262 deletions.
2 changes: 1 addition & 1 deletion model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -87,7 +87,7 @@
<logger name="com.evolveum.midpoint.provisioning.impl.ConnectorManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ResourceCache" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ShadowCache" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ShadowManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.task" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.errorhandling" level="DEBUG" />
<!-- <logger name="com.evolveum.midpoint.provisioning.impl.sync" level="TRACE" />-->
Expand Down
Expand Up @@ -11,6 +11,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
Expand All @@ -32,9 +33,7 @@
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
import com.evolveum.midpoint.repo.common.expression.ExpressionUtil;
import com.evolveum.midpoint.repo.common.expression.ExpressionVariables;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.processor.ResourceAttribute;
import com.evolveum.midpoint.schema.processor.ResourceObjectIdentification;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.evolveum.midpoint.provisioning.api.*;
import com.evolveum.midpoint.provisioning.impl.errorhandling.ErrorHandler;
import com.evolveum.midpoint.provisioning.impl.errorhandling.ErrorHandlerLocator;
import com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager;
import com.evolveum.midpoint.provisioning.ucf.api.*;
import com.evolveum.midpoint.provisioning.util.ProvisioningUtil;
import com.evolveum.midpoint.repo.api.RepositoryService;
Expand Down Expand Up @@ -252,7 +253,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
Collection<? extends ResourceAttribute<?>> identifiers = ShadowUtil.getAllIdentifiers(repositoryShadow);
try {


try {

resourceShadow = resourceObjectConverter.getResourceObject(ctx, identifiers, true, parentResult);
Expand Down Expand Up @@ -289,30 +289,23 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
resourceShadow.asObjectable().setIntent(repositoryShadow.asObjectable().getIntent());
ProvisioningContext shadowCtx = ctx.spawn(resourceShadow);

resourceManager.modifyResourceAvailabilityStatus(resource.asPrismObject(),
AvailabilityStatusType.UP, parentResult);
resourceManager.modifyResourceAvailabilityStatus(resource.asPrismObject(), AvailabilityStatusType.UP, parentResult);

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Shadow from repository:\n{}", repositoryShadow.debugDump(1));
LOGGER.trace("Resource object fetched from resource:\n{}", resourceShadow.debugDump(1));
}

repositoryShadow = shadowManager.updateShadow(shadowCtx, resourceShadow, repositoryShadow,
shadowState, parentResult);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Repository shadow after update:\n{}", repositoryShadow.debugDump(1));
}
repositoryShadow = shadowManager.updateShadow(shadowCtx, resourceShadow, repositoryShadow, null, shadowState, parentResult);
LOGGER.trace("Repository shadow after update:\n{}", repositoryShadow.debugDumpLazily(1));

// Complete the shadow by adding attributes from the resource object
PrismObject<ShadowType> resultShadow = completeShadow(shadowCtx, resourceShadow, repositoryShadow, false, parentResult);
PrismObject<ShadowType> assembledShadow = completeShadow(shadowCtx, resourceShadow, repositoryShadow, false, parentResult);
LOGGER.trace("Shadow when assembled:\n{}", assembledShadow.debugDumpLazily(1));

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Shadow when assembled:\n{}", resultShadow.debugDump(1));
}
PrismObject<ShadowType> resultShadow = futurizeShadow(ctx, repositoryShadow, assembledShadow, options, now);
LOGGER.trace("Futurized assembled shadow:\n{}", resultShadow.debugDumpLazily(1));

resultShadow = futurizeShadow(ctx, repositoryShadow, resultShadow, options, now);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Futurized assembled shadow:\n{}", resultShadow.debugDump(1));
}
parentResult.recordSuccess();
validateShadow(resultShadow, true);
return resultShadow;
Expand All @@ -329,9 +322,9 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
// is returned
parentResult.setStatus(OperationResultStatus.PARTIAL_ERROR);
}
handledShadow = futurizeShadow(ctx, handledShadow, null, options, now);
validateShadow(handledShadow, true);
return handledShadow;
PrismObject<ShadowType> futurizedShadow = futurizeShadow(ctx, handledShadow, null, options, now);
validateShadow(futurizedShadow, true);
return futurizedShadow;

} catch (GenericFrameworkException | ObjectAlreadyExistsException | PolicyViolationException e) {
throw new SystemException(e.getMessage(), e);
Expand All @@ -344,7 +337,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
// fetch for protected objects?
if (!ShadowUtil.isProtected(resourceShadow)) {
InternalMonitor.recordCount(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);

}
}
}
Expand Down Expand Up @@ -1911,9 +1903,12 @@ public SearchResultMetadata searchObjectsIterative(final ProvisioningContext ctx
// shadow should have proper kind/intent
ProvisioningContext shadowCtx = shadowCaretaker.applyAttributesDefinition(ctx, repoShadow);
// TODO: shadowState
repoShadow = shadowManager.updateShadow(shadowCtx, resourceShadow, repoShadow, null, parentResult);
repoShadow = shadowManager.updateShadow(shadowCtx, resourceShadow, repoShadow, null,
null, parentResult);

resultShadow = completeShadow(shadowCtx, resourceShadow, repoShadow, isDoDiscovery, objResult);

// TODO do we want also to futurize the shadow like in getObject?

//check and fix kind/intent
ShadowType repoShadowType = repoShadow.asObjectable();
Expand Down
Expand Up @@ -7,7 +7,6 @@

package com.evolveum.midpoint.provisioning.impl.errorhandling;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

Expand All @@ -29,7 +28,7 @@
import com.evolveum.midpoint.provisioning.impl.ProvisioningContext;
import com.evolveum.midpoint.provisioning.impl.ProvisioningOperationState;
import com.evolveum.midpoint.provisioning.impl.ShadowCaretaker;
import com.evolveum.midpoint.provisioning.impl.ShadowManager;
import com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager;
import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException;
import com.evolveum.midpoint.provisioning.util.ProvisioningUtil;
import com.evolveum.midpoint.repo.api.RepositoryService;
Expand Down
Expand Up @@ -22,7 +22,7 @@
import com.evolveum.midpoint.provisioning.impl.ProvisioningContext;
import com.evolveum.midpoint.provisioning.impl.ProvisioningOperationState;
import com.evolveum.midpoint.provisioning.impl.ShadowCaretaker;
import com.evolveum.midpoint.provisioning.impl.ShadowManager;
import com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager;
import com.evolveum.midpoint.provisioning.impl.ShadowState;
import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException;
import com.evolveum.midpoint.provisioning.util.ProvisioningUtil;
Expand Down

0 comments on commit 597adb2

Please sign in to comment.