Search in sources :

Example 56 with ActivationStatusType

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

the class ActivationComputer method getEffectiveStatus.

public ActivationStatusType getEffectiveStatus(String lifecycleStatus, ActivationType activationType, TimeIntervalStatusType validityStatus, LifecycleStateModelType stateModel) {
    ActivationStatusType forcedLifecycleActivationStatus = getForcedLifecycleActivationStatus(lifecycleStatus, stateModel);
    if (forcedLifecycleActivationStatus != null) {
        return forcedLifecycleActivationStatus;
    }
    if (activationType == null) {
        return ActivationStatusType.ENABLED;
    }
    ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
    if (administrativeStatus != null) {
        // Explicit administrative status overrides everything
        return administrativeStatus;
    }
    if (validityStatus == null) {
        // No administrative status, no validity. Return default.
        return ActivationStatusType.ENABLED;
    }
    switch(validityStatus) {
        case AFTER:
        case BEFORE:
            return ActivationStatusType.DISABLED;
        case IN:
            return ActivationStatusType.ENABLED;
    }
    // This should not happen
    return null;
}
Also used : ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 57 with ActivationStatusType

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

the class ActivationComputer method computeEffective.

public void computeEffective(String lifecycleStatus, ActivationType activationType, XMLGregorianCalendar referenceTime, LifecycleStateModelType stateModel) {
    ActivationStatusType effectiveStatus = getForcedLifecycleActivationStatus(lifecycleStatus, stateModel);
    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);
}
Also used : TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 58 with ActivationStatusType

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

the class InactivateShadowAction method handle.

@Override
public <F extends FocusType> void handle(@NotNull LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) {
    ActivationStatusType desiredStatus = ActivationStatusType.DISABLED;
    ItemPath pathAdminStatus = SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS;
    LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
    PrismObject<ShadowType> objectCurrent = projectionContext.getObjectCurrent();
    if (objectCurrent != null) {
        PrismProperty<Object> administrativeStatusProp = objectCurrent.findProperty(pathAdminStatus);
        if (administrativeStatusProp != null) {
            if (desiredStatus.equals(administrativeStatusProp.getRealValue())) {
                // Desired status already set, nothing to do
                return;
            }
        }
    }
    ObjectDelta<ShadowType> activationDelta = getPrismContext().deltaFactory().object().createModificationReplaceProperty(ShadowType.class, projectionContext.getOid(), pathAdminStatus, desiredStatus);
    projectionContext.setPrimaryDelta(activationDelta);
}
Also used : ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) PrismObject(com.evolveum.midpoint.prism.PrismObject) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 59 with ActivationStatusType

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

the class UserAsserter method assertAdministrativeStatus.

public UserAsserter<RA> assertAdministrativeStatus(ActivationStatusType expected) {
    ActivationType activation = getActivation();
    if (activation == null) {
        if (expected == null) {
            return this;
        } else {
            fail("No activation in " + desc());
        }
    }
    assertEquals("Wrong activation administrativeStatus in " + desc(), expected, activation.getAdministrativeStatus());
    return this;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Example 60 with ActivationStatusType

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

the class ActivationConverter method determineActivationStatus.

/**
 * Determines activation status for resource object. Uses either native or simulated value.
 */
private ActivationStatusType determineActivationStatus(PrismObject<ShadowType> resourceObject, ActivationCapabilityType activationCapability, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationType existingActivation = resourceObject.asObjectable().getActivation();
    ActivationStatusType nativeValue = existingActivation != null ? existingActivation.getAdministrativeStatus() : null;
    ActivationStatusCapabilityType statusCapability = CapabilityUtil.getEnabledActivationStatusStrict(activationCapability);
    if (statusCapability == null) {
        if (nativeValue != null) {
            LOGGER.trace("The status capability is disabled. Ignoring native value: {}", nativeValue);
        }
        // TODO Reconsider this. Maybe we should return native value.
        return null;
    }
    if (statusCapability.getAttribute() == null) {
        LOGGER.trace("Simulated activation status is not configured. Using native value: {}", nativeValue);
        return nativeValue;
    }
    Collection<Object> simulatingAttributeValues = getSimulatingAttributeValues(resourceObject, statusCapability.getAttribute());
    TwoStateSimulatedToRealConverter<ActivationStatusType> converter = new TwoStateSimulatedToRealConverter<>(statusCapability.getEnableValue(), statusCapability.getDisableValue(), ActivationStatusType.ENABLED, ActivationStatusType.DISABLED, "activation status", ctx);
    ActivationStatusType status = converter.convert(simulatingAttributeValues, result);
    LOGGER.trace("Detected simulated activation administrativeStatus attribute {} on {} with value {}, resolved into {}", lazy(() -> SchemaDebugUtil.prettyPrint(statusCapability.getAttribute())), ctx.getResource(), simulatingAttributeValues, status);
    if (!Boolean.FALSE.equals(statusCapability.isIgnoreAttribute())) {
        removeSimulatingAttribute(resourceObject, statusCapability.getAttribute());
    }
    return status;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

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