Search in sources :

Example 21 with ActivationType

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

the class TestIntegrationObjectWrapperFactory method test150CreateWrapperShadow.

@Test
public void test150CreateWrapperShadow() throws Exception {
    final String TEST_NAME = "test150CreateWrapperShadow";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<ShadowType> shadow = getShadowModel(accountJackOid);
    shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    ObjectWrapper<ShadowType> objectWrapper = factory.createObjectWrapper("shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    display("Wrapper after", objectWrapper);
    WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
    assertEquals("wrong number of containers in " + objectWrapper, 9, objectWrapper.getContainers().size());
    ContainerWrapper<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
    PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), attributesContainer, true, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_JACK_FULL_NAME);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_JACK_USERNAME);
    assertEquals("wrong number of items in " + attributesContainerWrapper, 16, attributesContainerWrapper.getItems().size());
    ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    WrapperTestUtil.assertWrapper(activationContainerWrapper, "ShadowType.activation", UserType.F_ACTIVATION, shadow, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
    assertEquals("Wrong attributes container wrapper readOnly", Boolean.FALSE, (Boolean) attributesContainerWrapper.isReadonly());
    ItemWrapper fullnameWrapper = attributesContainerWrapper.findPropertyWrapper(dummyResourceCtl.getAttributeFullnameQName());
    // Is this OK?
    assertEquals("Wrong attribute fullname readOnly", Boolean.FALSE, (Boolean) fullnameWrapper.isReadonly());
    assertEquals("Wrong attribute fullname visible", Boolean.TRUE, (Boolean) fullnameWrapper.isVisible());
    ItemDefinition fullNameDefinition = fullnameWrapper.getItemDefinition();
    display("fullname attribute definition", fullNameDefinition);
    assertEquals("Wrong attribute fullname definition.canRead", Boolean.TRUE, (Boolean) fullNameDefinition.canRead());
    assertEquals("Wrong attribute fullname definition.canAdd", Boolean.TRUE, (Boolean) fullNameDefinition.canAdd());
    assertEquals("Wrong attribute fullname definition.canModify", Boolean.TRUE, (Boolean) fullNameDefinition.canModify());
    // MID-3144
    if (fullNameDefinition.getDisplayOrder() == null || fullNameDefinition.getDisplayOrder() < 100 || fullNameDefinition.getDisplayOrder() > 400) {
        AssertJUnit.fail("Wrong fullname definition.displayOrder: " + fullNameDefinition.getDisplayOrder());
    }
    assertEquals("Wrong attribute fullname definition.displayName", "Full Name", fullNameDefinition.getDisplayName());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 22 with ActivationType

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

the class TestSchemaDelta method testDeleteInducementActivationSameNullIdApplyToObject.

@Test
public void testDeleteInducementActivationSameNullIdApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteInducementActivationSameNullIdApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
    //Delta
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    // No container ID
    ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(ROLE_CONSTRUCTION_INDUCEMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
    // WHEN
    roleDelta.applyTo(role);
    // THEN
    System.out.println("Role after delta application:");
    System.out.println(role.debugDump());
    assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
    PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
    PrismContainer<AssignmentType> inducementContainer = role.findContainer(RoleType.F_INDUCEMENT);
    assertNotNull("No inducement", inducementContainer);
    assertEquals("Unexpected number of inducement values", 1, inducementContainer.size());
    PrismContainerValue<AssignmentType> inducementValue = inducementContainer.getValues().iterator().next();
    AssignmentType inducement = inducementValue.asContainerable();
    ActivationType activation = inducement.getActivation();
    // activation should be gone (the error is that it is empty and not gone)
    assertNull("Activation is not gone", activation);
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 23 with ActivationType

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

the class ShadowIntegrityCheckResultHandler method checkOrFixShadowActivationConsistency.

// adapted from ProvisioningUtil
public void checkOrFixShadowActivationConsistency(ShadowCheckResult checkResult, PrismObject<ShadowType> shadow, boolean fix) {
    if (shadow == null) {
        // just for sure
        return;
    }
    ActivationType activation = shadow.asObjectable().getActivation();
    if (activation == null) {
        return;
    }
    FailedOperationTypeType failedOperation = shadow.asObjectable().getFailedOperationType();
    if (failedOperation == FailedOperationTypeType.ADD) {
        // in this case it's ok to have activation present
        return;
    }
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_ADMINISTRATIVE_STATUS);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_EFFECTIVE_STATUS);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_VALID_FROM);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_VALID_TO);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_VALIDITY_STATUS);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_VALIDITY_CHANGE_TIMESTAMP);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_LOCKOUT_STATUS);
    checkOrFixActivationItem(checkResult, shadow, activation.asPrismContainerValue(), ActivationType.F_LOCKOUT_EXPIRATION_TIMESTAMP);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)

Example 24 with ActivationType

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

the class FocusProcessor method recordEffectiveStatusDelta.

private <F extends ObjectType> void recordEffectiveStatusDelta(LensFocusContext<F> focusContext, ActivationStatusType effectiveStatusNew, XMLGregorianCalendar now) throws SchemaException {
    PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition();
    // We always want explicit delta for effective status even if there is no real change
    // we want to propagate enable/disable events to all the resources, even if we are enabling
    // already enabled user (some resources may be disabled)
    // This may produce duplicate delta, but that does not matter too much. The duplicate delta
    // will be filtered out later.
    PrismPropertyDefinition<ActivationStatusType> effectiveStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_EFFECTIVE_STATUS);
    PropertyDelta<ActivationStatusType> effectiveStatusDelta = effectiveStatusDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS));
    effectiveStatusDelta.setValueToReplace(new PrismPropertyValue<ActivationStatusType>(effectiveStatusNew, OriginType.USER_POLICY, null));
    if (!focusContext.alreadyHasDelta(effectiveStatusDelta)) {
        focusContext.swallowToProjectionWaveSecondaryDelta(effectiveStatusDelta);
    }
    // It is not enough to check alreadyHasDelta(). The change may happen in previous waves
    // and the secondary delta may no longer be here. When it comes to disableTimestamp we even
    // cannot rely on natural filtering of already executed deltas as the timestamp here may
    // be off by several milliseconds. So explicitly check for the change here. 
    PrismObject<F> objectCurrent = focusContext.getObjectCurrent();
    if (objectCurrent != null) {
        PrismProperty<ActivationStatusType> effectiveStatusPropCurrent = objectCurrent.findProperty(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS);
        if (effectiveStatusPropCurrent != null && effectiveStatusNew.equals(effectiveStatusPropCurrent.getRealValue())) {
            LOGGER.trace("Skipping setting disableTimestamp because there was no change");
            return;
        }
    }
    PropertyDelta<XMLGregorianCalendar> timestampDelta = LensUtil.createActivationTimestampDelta(effectiveStatusNew, now, activationDefinition, OriginType.USER_POLICY);
    if (!focusContext.alreadyHasDelta(timestampDelta)) {
        focusContext.swallowToProjectionWaveSecondaryDelta(timestampDelta);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 25 with ActivationType

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

the class ProvisioningUtil method checkShadowActivationConsistency.

public static void checkShadowActivationConsistency(PrismObject<ShadowType> shadow) {
    if (shadow == null) {
        // just for sure
        return;
    }
    ActivationType activation = shadow.asObjectable().getActivation();
    if (activation == null) {
        return;
    }
    FailedOperationTypeType failedOperation = shadow.asObjectable().getFailedOperationType();
    if (failedOperation == FailedOperationTypeType.ADD) {
        // in this case it's ok to have activation present
        return;
    }
    if (activation.getAdministrativeStatus() != null || activation.getEffectiveStatus() != null || activation.getValidFrom() != null || activation.getValidTo() != null || activation.getValidityStatus() != null || activation.getLockoutStatus() != null || activation.getLockoutExpirationTimestamp() != null || activation.getValidityChangeTimestamp() != null) {
        String m = "Unexpected content in shadow.activation for " + ObjectTypeUtil.toShortString(shadow) + ": " + activation;
        LOGGER.warn("{}", m);
    //throw new IllegalStateException(m);		// use only for testing
    }
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)76 Test (org.testng.annotations.Test)48 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)40 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)7 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)4 QName (javax.xml.namespace.QName)4