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