Search in sources :

Example 1 with ResourceObjectLifecycleDefinitionType

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

the class ActivationProcessor method processLifecycleFocus.

private <F extends FocusType> void processLifecycleFocus(LensContext<F> context, LensProjectionContext projCtx, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException, SecurityViolationException {
    LensFocusContext<F> focusContext = context.getFocusContext();
    if (focusContext == null) {
        LOGGER.trace("Skipping lifecycle evaluation because there is no focus");
        return;
    }
    ResourceObjectLifecycleDefinitionType lifecycleDef = null;
    ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
    if (resourceAccountDefType != null) {
        lifecycleDef = resourceAccountDefType.getLifecycle();
    }
    ResourceBidirectionalMappingType lifecycleStateMappingType = null;
    if (lifecycleDef != null) {
        lifecycleStateMappingType = lifecycleDef.getLifecycleState();
    }
    if (lifecycleStateMappingType == null || lifecycleStateMappingType.getOutbound() == null) {
        if (!projCtx.isAdd()) {
            LOGGER.trace("Skipping lifecycle evaluation because this is not add operation (default expression)");
            return;
        }
        PrismObject<F> focusNew = focusContext.getObjectNew();
        if (focusNew == null) {
            LOGGER.trace("Skipping lifecycle evaluation because there is no new focus (default expression)");
            return;
        }
        PrismObject<ShadowType> projectionNew = projCtx.getObjectNew();
        if (projectionNew == null) {
            LOGGER.trace("Skipping lifecycle evaluation because there is no new projection (default expression)");
            return;
        }
        String lifecycle = midpointFunctions.computeProjectionLifecycle(focusNew.asObjectable(), projectionNew.asObjectable(), projCtx.getResource());
        LOGGER.trace("Computed projection lifecycle (default expression): {}", lifecycle);
        if (lifecycle != null) {
            PrismPropertyDefinition<String> propDef = projCtx.getObjectDefinition().findPropertyDefinition(SchemaConstants.PATH_LIFECYCLE_STATE);
            PropertyDelta<String> lifeCycleDelta = propDef.createEmptyDelta(SchemaConstants.PATH_LIFECYCLE_STATE);
            PrismPropertyValue<String> pval = new PrismPropertyValue<String>(lifecycle);
            pval.setOriginType(OriginType.OUTBOUND);
            lifeCycleDelta.setValuesToReplace(pval);
            projCtx.swallowToSecondaryDelta(lifeCycleDelta);
        }
    } else {
        LOGGER.trace("Computing projection lifecycle (mapping): {}", lifecycleStateMappingType);
        evaluateActivationMapping(context, projCtx, lifecycleStateMappingType, SchemaConstants.PATH_LIFECYCLE_STATE, SchemaConstants.PATH_LIFECYCLE_STATE, null, now, true, ObjectType.F_LIFECYCLE_STATE.getLocalPart(), task, result);
    }
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ResourceBidirectionalMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType) ResourceObjectLifecycleDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectLifecycleDefinitionType)

Aggregations

ResourceBidirectionalMappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType)1 ResourceObjectLifecycleDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectLifecycleDefinitionType)1 ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1