Search in sources :

Example 46 with ActivationStatusType

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

the class FocusProcessor method processActivationAdministrativeAndValidity.

private <F extends FocusType> void processActivationAdministrativeAndValidity(LensFocusContext<F> focusContext, XMLGregorianCalendar now, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
    TimeIntervalStatusType validityStatusNew = null;
    TimeIntervalStatusType validityStatusCurrent = null;
    XMLGregorianCalendar validityChangeTimestamp = null;
    String lifecycleStateNew = null;
    String lifecycleStateCurrent = null;
    ActivationType activationNew = null;
    ActivationType activationCurrent = null;
    PrismObject<F> focusNew = focusContext.getObjectNew();
    if (focusNew != null) {
        F focusTypeNew = focusNew.asObjectable();
        activationNew = focusTypeNew.getActivation();
        if (activationNew != null) {
            validityStatusNew = activationComputer.getValidityStatus(activationNew, now);
            validityChangeTimestamp = activationNew.getValidityChangeTimestamp();
        }
        lifecycleStateNew = focusTypeNew.getLifecycleState();
    }
    PrismObject<F> focusCurrent = focusContext.getObjectCurrent();
    if (focusCurrent != null) {
        F focusCurrentType = focusCurrent.asObjectable();
        activationCurrent = focusCurrentType.getActivation();
        if (activationCurrent != null) {
            validityStatusCurrent = activationComputer.getValidityStatus(activationCurrent, validityChangeTimestamp);
        }
        lifecycleStateCurrent = focusCurrentType.getLifecycleState();
    }
    if (validityStatusCurrent == validityStatusNew) {
        // No change, (almost) no work
        if (validityStatusNew != null && activationNew.getValidityStatus() == null) {
            // There was no validity change. But the status is not recorded. So let's record it so it can be used in searches. 
            recordValidityDelta(focusContext, validityStatusNew, now);
        } else {
            LOGGER.trace("Skipping validity processing because there was no change ({} -> {})", validityStatusCurrent, validityStatusNew);
        }
    } else {
        LOGGER.trace("Validity change {} -> {}", validityStatusCurrent, validityStatusNew);
        recordValidityDelta(focusContext, validityStatusNew, now);
    }
    ActivationStatusType effectiveStatusNew = activationComputer.getEffectiveStatus(lifecycleStateNew, activationNew, validityStatusNew);
    ActivationStatusType effectiveStatusCurrent = activationComputer.getEffectiveStatus(lifecycleStateCurrent, activationCurrent, validityStatusCurrent);
    if (effectiveStatusCurrent == effectiveStatusNew) {
        // No change, (almost) no work
        if (effectiveStatusNew != null && (activationNew == null || activationNew.getEffectiveStatus() == null)) {
            // There was no effective status change. But the status is not recorded. So let's record it so it can be used in searches. 
            recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
        } else {
            if (focusContext.getPrimaryDelta() != null && focusContext.getPrimaryDelta().hasItemDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS)) {
                LOGGER.trace("Forcing effective status delta even though there was no change ({} -> {}) because there is explicit administrativeStatus delta", effectiveStatusCurrent, effectiveStatusNew);
                // We need this to force the change down to the projections later in the activation processor
                // some of the mappings will use effectiveStatus as a source, therefore there has to be a delta for the mapping to work correctly
                recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
            } else {
                LOGGER.trace("Skipping effective status processing because there was no change ({} -> {})", effectiveStatusCurrent, effectiveStatusNew);
            }
        }
    } else {
        LOGGER.trace("Effective status change {} -> {}", effectiveStatusCurrent, effectiveStatusNew);
        recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 47 with ActivationStatusType

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

the class AbstractActivationComputerTest method testGetDeprecatedAdministrativeEnabled.

@Test
public void testGetDeprecatedAdministrativeEnabled() throws Exception {
    // GIVEN
    Clock clock = createClock(SUMMER_SOLSTICE);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DEPRECATED, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest) Test(org.testng.annotations.Test)

Example 48 with ActivationStatusType

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

the class AbstractActivationComputerTest method testGetAdministrativeEnabled.

@Test
public void testGetAdministrativeEnabled() throws Exception {
    // GIVEN
    Clock clock = createClock(YEAR_START);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest) Test(org.testng.annotations.Test)

Example 49 with ActivationStatusType

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

the class AbstractActivationComputerTest method testGetInValidity.

@Test
public void testGetInValidity() throws Exception {
    // GIVEN
    Clock clock = createClock(SUMMER_SOLSTICE);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(null, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest) Test(org.testng.annotations.Test)

Example 50 with ActivationStatusType

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

the class AbstractActivationComputerTest method createActivationType.

protected ActivationType createActivationType(ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) {
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(administrativeStatus);
    activationType.setValidFrom(validFrom);
    activationType.setValidTo(validTo);
    return activationType;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Aggregations

ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)48 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)43 Test (org.testng.annotations.Test)30 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)2 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)2 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1