Search in sources :

Example 51 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class ShadowIntegrityCheckResultHandler method doFixIntent.

private void doFixIntent(ShadowCheckResult checkResult, PrismObject<ShadowType> fetchedShadow, PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) {
    PrismObject<ShadowType> fullShadow;
    if (!checkFetch) {
        fullShadow = fetchShadow(checkResult, shadow, resource, task, result);
    } else {
        fullShadow = fetchedShadow;
    }
    if (fullShadow == null) {
        checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Cannot fix missing intent, because the resource object couldn't be fetched"));
        return;
    }
    ObjectSynchronizationType synchronizationPolicy;
    try {
        synchronizationPolicy = synchronizationService.determineSynchronizationPolicy(resource.asObjectable(), fullShadow, configuration, task, result);
    } catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException e) {
        checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Couldn't prepare fix for missing intent, because the synchronization policy couldn't be determined", e));
        return;
    }
    if (synchronizationPolicy != null) {
        if (synchronizationPolicy.getIntent() != null) {
            PropertyDelta delta = PropertyDelta.createReplaceDelta(fullShadow.getDefinition(), ShadowType.F_INTENT, synchronizationPolicy.getIntent());
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Intent fix delta (not executed now) = \n{}", delta.debugDump());
            }
            checkResult.addFixDelta(delta, Statistics.NO_INTENT_SPECIFIED);
        } else {
            LOGGER.info("Synchronization policy does not contain intent: {}", synchronizationPolicy);
        }
    } else {
        LOGGER.info("Intent couldn't be fixed, because no synchronization policy was found");
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta)

Example 52 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class MidpointFunctionsImpl method computeProjectionLifecycle.

@Override
public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowType shadow, ResourceType resource) {
    if (focus == null || shadow == null) {
        return null;
    }
    if (!(focus instanceof UserType)) {
        return null;
    }
    if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) {
        return null;
    }
    ProtectedStringType passwordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
    if (passwordPs != null && passwordPs.canGetCleartext()) {
        return null;
    }
    CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    if (credentialsCapabilityType == null) {
        return null;
    }
    PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword();
    if (passwordCapabilityType == null) {
        return null;
    }
    if (passwordCapabilityType.isEnabled() == Boolean.FALSE) {
        return null;
    }
    return SchemaConstants.LIFECYCLE_PROPOSED;
}
Also used : PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 53 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class ObjectMerger method computeProjectionDeltas.

private <O extends ObjectType> void computeProjectionDeltas(final ObjectDelta<O> leftLinkDelta, ObjectDelta<O> rightLinkDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException {
    List<ShadowType> projectionsLeft = getProjections(objectLeft, task, result);
    List<ShadowType> projectionsRight = getProjections(objectRight, task, result);
    List<ShadowType> mergedProjections = new ArrayList<>();
    List<ShadowType> matchedProjections = new ArrayList<>();
    ProjectionMergeConfigurationType defaultProjectionMergeConfig = null;
    for (ProjectionMergeConfigurationType projectionMergeConfig : mergeConfiguration.getProjection()) {
        if (projectionMergeConfig.getProjectionDiscriminator() == null && projectionMergeConfig.getSituation() == null) {
            defaultProjectionMergeConfig = projectionMergeConfig;
        } else {
            takeProjections(projectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft, projectionsLeft, projectionsRight, projectionMergeConfig);
            takeProjections(projectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight, projectionsLeft, projectionsRight, projectionMergeConfig);
        }
    }
    LOGGER.trace("Merged projections (before default): {}", mergedProjections);
    LOGGER.trace("Matched projections (before default): {}", matchedProjections);
    if (defaultProjectionMergeConfig != null) {
        takeUnmatchedProjections(defaultProjectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft);
        takeUnmatchedProjections(defaultProjectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight);
    }
    LOGGER.trace("Merged projections: {}", mergedProjections);
    checkConflict(mergedProjections);
    for (ShadowType mergedProjection : mergedProjections) {
        PrismReferenceValue leftLinkRef = findLinkRef(objectLeft, mergedProjection);
        if (leftLinkRef == null) {
            PrismReferenceValue linkRefRight = findLinkRef(objectRight, mergedProjection);
            LOGGER.trace("Moving projection right->left: {}", mergedProjection);
            addUnlinkDelta(rightLinkDelta, linkRefRight);
            addLinkDelta(leftLinkDelta, linkRefRight);
        } else {
            LOGGER.trace("Projection already at the left: {}", mergedProjection);
        }
    }
    for (PrismReferenceValue leftLinkRef : getLinkRefs(objectLeft)) {
        if (!hasProjection(mergedProjections, leftLinkRef)) {
            LOGGER.trace("Removing left projection: {}", leftLinkRef);
            addUnlinkDelta(leftLinkDelta, leftLinkRef);
        } else {
            LOGGER.trace("Left projection stays: {}", leftLinkRef);
        }
    }
}
Also used : ProjectionMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList)

Example 54 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class ObjectMerger method takeProjections.

private void takeProjections(MergeStategyType strategy, List<ShadowType> mergedProjections, List<ShadowType> matchedProjections, List<ShadowType> candidateProjections, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("TAKE: Evaluating situation {}, discriminator: {}", projectionMergeConfig.getSituation(), projectionMergeConfig.getProjectionDiscriminator());
    }
    for (ShadowType candidateProjection : candidateProjections) {
        if (projectionMatches(candidateProjection, projectionsLeft, projectionsRight, projectionMergeConfig)) {
            LOGGER.trace("Projection matches {}", candidateProjection);
            matchedProjections.add(candidateProjection);
            if (strategy == MergeStategyType.TAKE) {
                mergedProjections.add(candidateProjection);
            } else if (strategy == null || strategy == MergeStategyType.IGNORE) {
            // Nothing to do here
            } else {
                throw new UnsupportedOperationException("Merge strategy " + strategy + " is not supported");
            }
        } else {
            LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
        }
    }
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 55 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class ObjectMerger method getProjections.

private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> objectRight, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    if (!objectRight.canRepresent(FocusType.class)) {
        return new ArrayList<>(0);
    }
    List<ObjectReferenceType> linkRefs = ((FocusType) objectRight.asObjectable()).getLinkRef();
    List<ShadowType> projections = new ArrayList<>(linkRefs.size());
    for (ObjectReferenceType linkRef : linkRefs) {
        projections.add(getProjection(linkRef, task, result));
    }
    return projections;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ArrayList(java.util.ArrayList)

Aggregations

ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)903 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)728 Test (org.testng.annotations.Test)693 Task (com.evolveum.midpoint.task.api.Task)600 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)398 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)170 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)154 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)153 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)129 QName (javax.xml.namespace.QName)123 PrismObject (com.evolveum.midpoint.prism.PrismObject)105 ArrayList (java.util.ArrayList)95 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)89 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)78 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)74 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)64 Entry (org.apache.directory.api.ldap.model.entry.Entry)61 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)60 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)55