Search in sources :

Example 56 with ActivationType

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

the class TestActivation method assertEffectiveStatus.

private <F extends FocusType> void assertEffectiveStatus(PrismObject<F> focus, ActivationStatusType expected) {
    ActivationType activation = focus.asObjectable().getActivation();
    assertNotNull("No activation in " + focus, activation);
    assertEquals("Unexpected effective activation status in " + focus, expected, activation.getEffectiveStatus());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Example 57 with ActivationType

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

the class AbstractModelIntegrationTest method createAccount.

protected PrismObject<ShadowType> createAccount(PrismObject<ResourceType> resource, String name, boolean enabled) throws SchemaException {
    PrismObject<ShadowType> shadow = getShadowDefinition().instantiate();
    ShadowType shadowType = shadow.asObjectable();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    shadowType.setResourceRef(resourceRef);
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    shadowType.setObjectClass(objectClassDefinition.getTypeName());
    shadowType.setKind(ShadowKindType.ACCOUNT);
    ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition);
    RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next();
    ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate();
    icfsNameAttr.setRealValue(name);
    attrCont.add(icfsNameAttr);
    ActivationType activation = new ActivationType();
    shadowType.setActivation(activation);
    if (enabled) {
        activation.setAdministrativeStatus(ActivationStatusType.ENABLED);
    } else {
        activation.setAdministrativeStatus(ActivationStatusType.DISABLED);
    }
    return shadow;
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute)

Example 58 with ActivationType

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

the class AbstractBasicDummyTest method assertRepoShadowCacheActivation.

protected void assertRepoShadowCacheActivation(PrismObject<ShadowType> shadowRepo, ActivationStatusType expectedAdministrativeStatus) {
    ActivationType activationType = shadowRepo.asObjectable().getActivation();
    if (activationType == null) {
        return;
    }
    ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
    assertNull("Unexpected activation administrativeStatus in repo shadow " + shadowRepo + ": " + administrativeStatus, administrativeStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 59 with ActivationType

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

the class TestSchemaDelta method testDeleteUserAssignmentActivationSameNullIdApplyToObject.

@Test
public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteUserAssignmentActivationSameNullIdApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
    //Delta
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    // No container ID
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(USER_JACK_ASSIGNMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
    // WHEN
    userDelta.applyTo(user);
    // THEN
    System.out.println("User after delta application:");
    System.out.println(user.debugDump());
    assertEquals("Wrong OID", USER_JACK_OID, user.getOid());
    PrismAsserts.assertPropertyValue(user, UserType.F_NAME, PrismTestUtil.createPolyString(USER_JACK_NAME));
    PrismContainer<AssignmentType> assignmentContainer = user.findContainer(RoleType.F_ASSIGNMENT);
    assertNotNull("No assignment", assignmentContainer);
    assertEquals("Unexpected number of assignment values", 1, assignmentContainer.size());
    PrismContainerValue<AssignmentType> assignmentValue = assignmentContainer.getValues().iterator().next();
    AssignmentType assignment = assignmentValue.asContainerable();
    ActivationType assignmentActivation = assignment.getActivation();
    // activation should be gone (the error is that it is empty and not gone)
    assertNull("Assignment activation is not gone", assignmentActivation);
    ActivationType activation = user.asObjectable().getActivation();
    assertNotNull("Activation missing", activation);
    assertEquals("Wrong activation administrativeStatus", ActivationStatusType.ENABLED, activation.getAdministrativeStatus());
}
Also used : 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 60 with ActivationType

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

the class ActivationProcessor method evaluateExistenceMapping.

private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context, final LensProjectionContext accCtx, final XMLGregorianCalendar now, final boolean current, Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    final String accCtxDesc = accCtx.toHumanReadableString();
    final Boolean legal = accCtx.isLegal();
    if (legal == null) {
        throw new IllegalStateException("Null 'legal' for " + accCtxDesc);
    }
    ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
    if (resourceAccountDefType == null) {
        return legal;
    }
    ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
    if (activationType == null) {
        return legal;
    }
    ResourceBidirectionalMappingType existenceType = activationType.getExistence();
    if (existenceType == null) {
        return legal;
    }
    List<MappingType> outbound = existenceType.getOutbound();
    if (outbound == null || outbound.isEmpty()) {
        // "default mapping"
        return legal;
    }
    MappingEvaluatorParams<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>, ShadowType, F> params = new MappingEvaluatorParams<>();
    params.setMappingTypes(outbound);
    params.setMappingDesc("outbound existence mapping in projection " + accCtxDesc);
    params.setNow(now);
    params.setAPrioriTargetObject(accCtx.getObjectOld());
    params.setEvaluateCurrent(current);
    params.setTargetContext(accCtx);
    params.setFixTarget(true);
    params.setContext(context);
    params.setInitializer(builder -> {
        ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSourceIdi = getLegalIdi(accCtx);
        Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSource = new Source<>(legalSourceIdi, ExpressionConstants.VAR_LEGAL);
        builder.defaultSource(legalSource);
        ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedIdi = getAssignedIdi(accCtx);
        Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedSource = new Source<>(assignedIdi, ExpressionConstants.VAR_ASSIGNED);
        builder.addSource(assignedSource);
        ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext());
        Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSource = new Source<>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS);
        builder.addSource(focusExistsSource);
        builder.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject());
        builder.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject());
        builder.addVariableDefinition(ExpressionConstants.VAR_SHADOW, accCtx.getObjectDeltaObject());
        builder.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource());
        builder.originType(OriginType.OUTBOUND);
        builder.originObject(accCtx.getResource());
        return builder;
    });
    final MutableBoolean output = new MutableBoolean(false);
    params.setProcessor((mappingOutputPath, outputStruct) -> {
        PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = outputStruct.getOutputTriple();
        if (outputTriple == null) {
            // The "default existence mapping"
            output.setValue(legal);
            return false;
        }
        Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues();
        // (e.g. because the condition is false). This should be fixed.
        if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
            throw new ExpressionEvaluationException("Activation existence expression resulted in null or empty value for projection " + accCtxDesc);
        }
        if (nonNegativeValues.size() > 1) {
            throw new ExpressionEvaluationException("Activation existence expression resulted in too many values (" + nonNegativeValues.size() + ") for projection " + accCtxDesc);
        }
        output.setValue(nonNegativeValues.iterator().next().getValue());
        return false;
    });
    PrismPropertyDefinitionImpl<Boolean> shadowExistsDef = new PrismPropertyDefinitionImpl<>(SHADOW_EXISTS_PROPERTY_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
    shadowExistsDef.setMinOccurs(1);
    shadowExistsDef.setMaxOccurs(1);
    params.setTargetItemDefinition(shadowExistsDef);
    mappingEvaluator.evaluateMappingSetProjection(params, task, result);
    return (boolean) output.getValue();
}
Also used : ResourceBidirectionalMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType) MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) Source(com.evolveum.midpoint.repo.common.expression.Source) ResourceActivationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ResourceBidirectionalMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)59 Test (org.testng.annotations.Test)34 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)22 Task (com.evolveum.midpoint.task.api.Task)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)12 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)9 ObjectWrapperFactory (com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory)5 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)5 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)4 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)4 QName (javax.xml.namespace.QName)4 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)3 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)3 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)3