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);
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations