Search in sources :

Example 1 with NotApplicableException

use of com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException in project midpoint by Evolveum.

the class InitializableMixin method initialize.

/**
 * Initializes given object.
 *
 * - Precondition: lifecycle state is CREATED.
 * - Postcondition (unless exception is thrown): lifecycle state is INITIALIZED or INITIALIZATION_FAILED.
 */
default void initialize(Task task, OperationResult result) {
    InitializationState state = getInitializationState();
    getLogger().trace("Item before initialization (state: {}):\n{}", state, debugDumpLazily());
    try {
        state.moveFromCreatedToInitializing();
        try {
            initializeInternal(task, result);
        } catch (NotApplicableException e) {
            state.recordNotApplicable();
            result.recordNotApplicable();
        }
        state.moveFromInitializingToInitialized();
        checkConsistence();
    } catch (CommonException | EncryptionException | RuntimeException e) {
        // TODO change to debug
        getLogger().warn("Got an exception during initialization of {}", this, e);
        getInitializationState().recordInitializationFailed(e);
        result.recordFatalError(e);
    }
    state.checkAfterInitialization();
    getLogger().trace("Item after initialization (state: {}):\n{}", state, debugDumpLazily());
}
Also used : InitializationState(com.evolveum.midpoint.provisioning.util.InitializationState) NotApplicableException(com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 2 with NotApplicableException

use of com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException in project midpoint by Evolveum.

the class ShadowedChange method constructShadowedObjectForDeletion.

/**
 * It looks like the current resource object should be present also for DELETE deltas.
 *
 * TODO clarify this
 *
 * TODO try to avoid repository get operation by applying known deltas to existing repo shadow object
 *
 * So until clarified, we provide here the shadow object, with properly applied definitions.
 */
private PrismObject<ShadowType> constructShadowedObjectForDeletion(OperationResult result) throws SchemaException, ExpressionEvaluationException, ConfigurationException, CommunicationException, NotApplicableException, ObjectNotFoundException {
    PrismObject<ShadowType> currentShadow;
    try {
        currentShadow = beans.repositoryService.getObject(ShadowType.class, this.repoShadow.getOid(), null, result);
    } catch (ObjectNotFoundException e) {
        LOGGER.debug("Shadow for delete synchronization event {} disappeared recently." + "Skipping this event.", this);
        throw new NotApplicableException();
    }
    context = beans.shadowCaretaker.applyAttributesDefinition(context, currentShadow);
    beans.shadowCaretaker.updateShadowState(context, currentShadow);
    return currentShadow;
}
Also used : NotApplicableException(com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 3 with NotApplicableException

use of com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException in project midpoint by Evolveum.

the class ShadowedObjectFound method initializeInternal.

/**
 * Acquires repo shadow, updates it, and prepares the shadowedObject.
 * In emergency does a minimalistic processing aimed at acquiring a shadow.
 */
@Override
public void initializeInternal(Task task, OperationResult result) throws CommonException, NotApplicableException, EncryptionException {
    if (!initializationState.isInitialStateOk()) {
        // The object is somehow flawed. However, we try to create a shadow.
        // 
        // To avoid any harm, we are minimalistic here: If a shadow can be found, it is used "as is". No updates here.
        // If it cannot be found, it is created. We will skip kind/intent/tag determination.
        // Most probably these would not be correct anyway.
        shadowedObject = acquireRepoShadowInEmergency(result);
        return;
    }
    PrismObject<ShadowType> repoShadow = acquireRepoShadow(result);
    try {
        // This determines the definitions exactly. Now the repo shadow should have proper kind/intent.
        ProvisioningContext preciseCtx = ictx.localBeans.shadowCaretaker.applyAttributesDefinition(ictx.ctx, repoShadow);
        ictx.localBeans.shadowCaretaker.updateShadowState(preciseCtx, repoShadow);
        PrismObject<ShadowType> updatedRepoShadow = updateRepoShadow(preciseCtx, repoShadow, result);
        shadowedObject = createShadowedObject(preciseCtx, updatedRepoShadow, result);
    } catch (Exception e) {
        // No need to log stack trace now. It will be logged at the place where the exception is processed.
        LOGGER.error("Couldn't initialize {}. Continuing with previously acquired repo shadow: {}. Error: {}", resourceObject, repoShadow, getClassWithMessage(e));
        shadowedObject = repoShadow;
        throw e;
    }
}
Also used : ProvisioningContext(com.evolveum.midpoint.provisioning.impl.ProvisioningContext) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) NotApplicableException(com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException)

Aggregations

NotApplicableException (com.evolveum.midpoint.provisioning.impl.shadows.sync.NotApplicableException)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ProvisioningContext (com.evolveum.midpoint.provisioning.impl.ProvisioningContext)1 InitializationState (com.evolveum.midpoint.provisioning.util.InitializationState)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1