Search in sources :

Example 1 with LensObjectDeltaOperation

use of com.evolveum.midpoint.model.impl.lens.LensObjectDeltaOperation in project midpoint by Evolveum.

the class ContextLoader method removeRottenContexts.

/**
	 * Removes projection contexts that are not fresh.
	 * These are usually artifacts left after the context reload. E.g. an account that used to be linked to a user before
	 * but was removed in the meantime.
	 */
private <F extends ObjectType> void removeRottenContexts(LensContext<F> context) {
    Iterator<LensProjectionContext> projectionIterator = context.getProjectionContextsIterator();
    while (projectionIterator.hasNext()) {
        LensProjectionContext projectionContext = projectionIterator.next();
        if (projectionContext.getPrimaryDelta() != null && !projectionContext.getPrimaryDelta().isEmpty()) {
            // Vox populi vox dei
            continue;
        }
        if (projectionContext.getWave() >= context.getExecutionWave()) {
            // chance to be executed yet
            continue;
        }
        ResourceShadowDiscriminator discr = projectionContext.getResourceShadowDiscriminator();
        if (discr != null && discr.getOrder() > 0) {
            // HACK never rot higher-order context. TODO: check if lower-order context is rotten, the also rot this one
            continue;
        }
        if (!projectionContext.isFresh()) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Removing rotten context {}", projectionContext.getHumanReadableName());
            }
            if (projectionContext.isToBeArchived()) {
                context.getHistoricResourceObjects().add(projectionContext.getResourceShadowDiscriminator());
            }
            List<LensObjectDeltaOperation<ShadowType>> executedDeltas = projectionContext.getExecutedDeltas();
            context.getRottenExecutedDeltas().addAll(executedDeltas);
            projectionIterator.remove();
        }
    }
}
Also used : LensObjectDeltaOperation(com.evolveum.midpoint.model.impl.lens.LensObjectDeltaOperation) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 2 with LensObjectDeltaOperation

use of com.evolveum.midpoint.model.impl.lens.LensObjectDeltaOperation in project midpoint by Evolveum.

the class DependencyProcessor method wasProvisioned.

private <F extends ObjectType> boolean wasProvisioned(LensProjectionContext accountContext, int executionWave) {
    int accountWave = accountContext.getWave();
    if (accountWave >= executionWave) {
        // This had no chance to be provisioned yet, so we assume it will be provisioned
        return true;
    }
    if (accountContext.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN || accountContext.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.IGNORE) {
        return false;
    }
    PrismObject<ShadowType> objectCurrent = accountContext.getObjectCurrent();
    if (objectCurrent != null && objectCurrent.asObjectable().getFailedOperationType() != null) {
        // There is unfinished operation in the shadow. We cannot continue.
        return false;
    }
    if (accountContext.isExists()) {
        return true;
    }
    if (accountContext.isAdd()) {
        List<LensObjectDeltaOperation<ShadowType>> executedDeltas = accountContext.getExecutedDeltas();
        if (executedDeltas == null || executedDeltas.isEmpty()) {
            return false;
        }
        for (LensObjectDeltaOperation<ShadowType> executedDelta : executedDeltas) {
            OperationResult executionResult = executedDelta.getExecutionResult();
            if (executionResult == null || !executionResult.isSuccess()) {
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : LensObjectDeltaOperation(com.evolveum.midpoint.model.impl.lens.LensObjectDeltaOperation) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

LensObjectDeltaOperation (com.evolveum.midpoint.model.impl.lens.LensObjectDeltaOperation)2 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1