Search in sources :

Example 41 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ActivationConverter method createLockoutStatusChange.

private void createLockoutStatusChange(Collection<? extends ItemDelta<?, ?>> objectChange, ShadowType shadow, ActivationCapabilityType activationCapability, ResourceType resource, Collection<Operation> operations, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PropertyDelta<LockoutStatusType> propertyDelta = findPropertyDelta(objectChange, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
    if (propertyDelta == null) {
        return;
    }
    ActivationLockoutStatusCapabilityType lockoutCapability = CapabilityUtil.getEnabledActivationLockoutStrict(activationCapability);
    if (lockoutCapability == null) {
        SchemaException e = new SchemaException("Attempt to change activation lockoutStatus on " + resource + " which does not have the capability");
        result.recordFatalError(e);
        throw e;
    }
    QName simulatingAttributeName = lockoutCapability.getAttribute();
    if (simulatingAttributeName == null) {
        LOGGER.trace("No simulation attribute, using native value");
        addModification(operations, propertyDelta);
        return;
    }
    LockoutStatusType newStatus = getRealValue(propertyDelta.getPropertyNewMatchingPath());
    LOGGER.trace("Found activation lockout change to: {}", newStatus);
    PropertyModificationOperation<?> simulatingAttributeModification = TwoStateRealToSimulatedConverter.create(lockoutCapability, simulatingAttributeName, ctx, beans).convertDelta(newStatus, shadow, result);
    if (simulatingAttributeModification != null) {
        operations.add(simulatingAttributeModification);
    } else {
        addModification(operations, propertyDelta);
    }
}
Also used : ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) QName(javax.xml.namespace.QName)

Example 42 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ActivationConverter method transformActivationOnAdd.

// endregion
// region midPoint -> resource object (activation -> simulating/native) on object ADD
/**
 * Transforms activation information when an object is being added.
 */
void transformActivationOnAdd(ShadowType shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationType activation = shadow.getActivation();
    if (activation == null) {
        return;
    }
    ActivationCapabilityType activationCapability = ctx.getEffectiveCapability(ActivationCapabilityType.class);
    if (activation.getAdministrativeStatus() != null) {
        transformActivationStatusOnAdd(shadow, activationCapability, result);
    }
    if (activation.getLockoutStatus() != null) {
        transformLockoutStatusOnAdd(shadow, activationCapability, result);
    }
}
Also used : ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)

Example 43 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ActivationConverter method transformActivationStatusOnAdd.

private void transformActivationStatusOnAdd(ShadowType shadow, ActivationCapabilityType activationCapability, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationStatusCapabilityType statusCapability = CapabilityUtil.getEnabledActivationStatusStrict(activationCapability);
    LOGGER.trace("Activation status capability:\n{}", statusCapability);
    if (statusCapability == null) {
        throw new SchemaException("Attempt to set activation/administrativeStatus on " + ctx.getResource() + " that has neither native nor simulated activation/status capability");
    }
    QName simulatingAttributeName = statusCapability.getAttribute();
    if (simulatingAttributeName == null) {
        LOGGER.trace("Using native activation status capability");
        return;
    }
    boolean converted = TwoStateRealToSimulatedConverter.create(statusCapability, simulatingAttributeName, ctx, beans).convertProperty(shadow.getActivation().getAdministrativeStatus(), shadow, result);
    if (converted) {
        shadow.getActivation().setAdministrativeStatus(null);
    }
}
Also used : QName(javax.xml.namespace.QName) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 44 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType 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)

Example 45 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class AbstractManualResourceTest method test006Capabilities.

@Test
public void test006Capabilities() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = createOperationResult();
    // WHEN
    ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, task, result).asObjectable();
    // THEN
    display("Resource from provisioninig", resource);
    displayValue("Resource from provisioninig (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML));
    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
    CreateCapabilityType capCreate = CapabilityUtil.getCapability(nativeCapabilitiesList, CreateCapabilityType.class);
    assertNotNull("Missing create capability", capCreate);
    assertManual(capCreate);
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
    assertNotNull("Missing activation capability", capAct);
    ReadCapabilityType capRead = CapabilityUtil.getCapability(nativeCapabilitiesList, ReadCapabilityType.class);
    assertNotNull("Missing read capability", capRead);
    assertEquals("Wrong caching-only setting in read capability", Boolean.TRUE, capRead.isCachingOnly());
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CreateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Aggregations

ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)29 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)16 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)13 QName (javax.xml.namespace.QName)11 Test (org.testng.annotations.Test)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)8 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 ActivationValidityCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType)6 Task (com.evolveum.midpoint.task.api.Task)5 ReadCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType)5 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)4 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)4 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)4 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)3 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)3 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 CreateCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)3