use of com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType in project midpoint by Evolveum.
the class TestActivationComputer method testCompute.
void testCompute(final String TEST_NAME, String lifecycleState, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) {
// GIVEN
Clock clock = createClock(now);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(administrativeStatus, validFrom, validTo);
// WHEN
activationComputer.computeEffective(lifecycleState, activationType);
// THEN
assertEquals("Unexpected effective status", expectedEffective, activationType.getEffectiveStatus());
assertEquals("Unexpected validity status", expectedValidity, activationType.getValidityStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType in project midpoint by Evolveum.
the class TestActivation method assertValidity.
private <F extends FocusType> void assertValidity(PrismObject<F> focus, TimeIntervalStatusType expectedValidityStatus) {
ActivationType activation = focus.asObjectable().getActivation();
assertNotNull("No activation in " + focus, activation);
assertEquals("Unexpected validity status in " + focus, expectedValidityStatus, activation.getValidityStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType in project midpoint by Evolveum.
the class ActivationComputer method computeEffective.
public void computeEffective(String lifecycleStatus, ActivationType activationType, XMLGregorianCalendar referenceTime) {
ActivationStatusType effectiveStatus = null;
if (lifecycleStatus != null && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_ACTIVE) && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_DEPRECATED)) {
effectiveStatus = ActivationStatusType.DISABLED;
}
if (SchemaConstants.LIFECYCLE_ARCHIVED.equals(lifecycleStatus)) {
effectiveStatus = ActivationStatusType.ARCHIVED;
}
ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
if (effectiveStatus == null && administrativeStatus != null) {
// Explicit administrative status overrides everything
effectiveStatus = administrativeStatus;
}
TimeIntervalStatusType validityStatus = getValidityStatus(activationType);
if (effectiveStatus == null) {
if (validityStatus == null) {
// No administrative status, no validity. Defaults to enabled.
effectiveStatus = ActivationStatusType.ENABLED;
} else {
switch(validityStatus) {
case AFTER:
case BEFORE:
effectiveStatus = ActivationStatusType.DISABLED;
break;
case IN:
effectiveStatus = ActivationStatusType.ENABLED;
break;
}
}
}
activationType.setEffectiveStatus(effectiveStatus);
activationType.setValidityStatus(validityStatus);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType 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.TimeIntervalStatusType in project midpoint by Evolveum.
the class FocusProcessor method recordValidityDelta.
private <F extends ObjectType> void recordValidityDelta(LensFocusContext<F> focusContext, TimeIntervalStatusType validityStatusNew, XMLGregorianCalendar now) throws SchemaException {
PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition();
PrismPropertyDefinition<TimeIntervalStatusType> validityStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_STATUS);
PropertyDelta<TimeIntervalStatusType> validityStatusDelta = validityStatusDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_STATUS));
if (validityStatusNew == null) {
validityStatusDelta.setValueToReplace();
} else {
validityStatusDelta.setValueToReplace(new PrismPropertyValue<>(validityStatusNew, OriginType.USER_POLICY, null));
}
focusContext.swallowToProjectionWaveSecondaryDelta(validityStatusDelta);
PrismPropertyDefinition<XMLGregorianCalendar> validityChangeTimestampDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_CHANGE_TIMESTAMP);
PropertyDelta<XMLGregorianCalendar> validityChangeTimestampDelta = validityChangeTimestampDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_CHANGE_TIMESTAMP));
validityChangeTimestampDelta.setValueToReplace(new PrismPropertyValue<>(now, OriginType.USER_POLICY, null));
focusContext.swallowToProjectionWaveSecondaryDelta(validityChangeTimestampDelta);
}
Aggregations