Search in sources :

Example 11 with ResourceObjectTypeDefinitionType

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

the class ResourceDetailsTabPanel method createResourceConfigList.

private List<ResourceConfigurationDto> createResourceConfigList(ResourceType resource) {
    OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, parentPage.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resource.getOid()).build(), result, parentPage);
    List<ResourceConfigurationDto> configs = new ArrayList<>();
    if (resource.getSchemaHandling() == null) {
        return configs;
    }
    List<ResourceObjectTypeDefinitionType> objectTypes = resource.getSchemaHandling().getObjectType();
    if (objectTypes == null) {
        return configs;
    }
    try {
        for (ResourceObjectTypeDefinitionType objectType : objectTypes) {
            ObjectSynchronizationType obejctSynchronization = null;
            if (resource.getSynchronization() != null && resource.getSynchronization().getObjectSynchronization() != null) {
                obejctSynchronization = getSynchronizationFor(objectType, resource.getSynchronization().getObjectSynchronization(), resource.asPrismObject());
            }
            List<TaskType> syncTask = new ArrayList<>();
            if (obejctSynchronization != null) {
                syncTask = getTaskFor(tasks, obejctSynchronization, resource.asPrismObject());
            }
            ResourceConfigurationDto resourceConfig = new ResourceConfigurationDto(objectType, obejctSynchronization != null, syncTask);
            configs.add(resourceConfig);
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Could not determine resource configuration", ex);
    }
    return configs;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto)

Example 12 with ResourceObjectTypeDefinitionType

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

the class TestSanityLegacy method checkOpenDjSchemaHandling.

private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
    SchemaHandlingType schemaHandling = resource.getSchemaHandling();
    for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
        if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
            assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
        if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
            assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
    }
}
Also used : SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)

Example 13 with ResourceObjectTypeDefinitionType

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

the class ActivationProcessor method processLifecycleFocus.

private <F extends FocusType> void processLifecycleFocus(LensContext<F> context, LensProjectionContext projCtx, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException, SecurityViolationException {
    LensFocusContext<F> focusContext = context.getFocusContext();
    if (focusContext == null) {
        LOGGER.trace("Skipping lifecycle evaluation because there is no focus");
        return;
    }
    ResourceObjectLifecycleDefinitionType lifecycleDef = null;
    ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
    if (resourceAccountDefType != null) {
        lifecycleDef = resourceAccountDefType.getLifecycle();
    }
    ResourceBidirectionalMappingType lifecycleStateMappingType = null;
    if (lifecycleDef != null) {
        lifecycleStateMappingType = lifecycleDef.getLifecycleState();
    }
    if (lifecycleStateMappingType == null || lifecycleStateMappingType.getOutbound() == null) {
        if (!projCtx.isAdd()) {
            LOGGER.trace("Skipping lifecycle evaluation because this is not add operation (default expression)");
            return;
        }
        PrismObject<F> focusNew = focusContext.getObjectNew();
        if (focusNew == null) {
            LOGGER.trace("Skipping lifecycle evaluation because there is no new focus (default expression)");
            return;
        }
        PrismObject<ShadowType> projectionNew = projCtx.getObjectNew();
        if (projectionNew == null) {
            LOGGER.trace("Skipping lifecycle evaluation because there is no new projection (default expression)");
            return;
        }
        String lifecycle = midpointFunctions.computeProjectionLifecycle(focusNew.asObjectable(), projectionNew.asObjectable(), projCtx.getResource());
        LOGGER.trace("Computed projection lifecycle (default expression): {}", lifecycle);
        if (lifecycle != null) {
            PrismPropertyDefinition<String> propDef = projCtx.getObjectDefinition().findPropertyDefinition(SchemaConstants.PATH_LIFECYCLE_STATE);
            PropertyDelta<String> lifeCycleDelta = propDef.createEmptyDelta(SchemaConstants.PATH_LIFECYCLE_STATE);
            PrismPropertyValue<String> pval = new PrismPropertyValue<String>(lifecycle);
            pval.setOriginType(OriginType.OUTBOUND);
            lifeCycleDelta.setValuesToReplace(pval);
            projCtx.swallowToSecondaryDelta(lifeCycleDelta);
        }
    } else {
        LOGGER.trace("Computing projection lifecycle (mapping): {}", lifecycleStateMappingType);
        evaluateActivationMapping(context, projCtx, lifecycleStateMappingType, SchemaConstants.PATH_LIFECYCLE_STATE, SchemaConstants.PATH_LIFECYCLE_STATE, null, now, true, ObjectType.F_LIFECYCLE_STATE.getLocalPart(), task, result);
    }
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ResourceBidirectionalMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType) ResourceObjectLifecycleDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectLifecycleDefinitionType)

Example 14 with ResourceObjectTypeDefinitionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType 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)

Example 15 with ResourceObjectTypeDefinitionType

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

the class ProjectionValuesProcessor method evaluateIterationCondition.

private <F extends ObjectType> boolean evaluateIterationCondition(LensContext<F> context, LensProjectionContext accountContext, int iteration, String iterationToken, boolean beforeIteration, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
    ResourceObjectTypeDefinitionType accDef = accountContext.getResourceObjectTypeDefinitionType();
    if (accDef == null) {
        return true;
    }
    IterationSpecificationType iterationType = accDef.getIteration();
    ExpressionVariables variables = createExpressionVariables(context, accountContext);
    return LensUtil.evaluateIterationCondition(context, accountContext, iterationType, iteration, iterationToken, beforeIteration, expressionFactory, variables, task, result);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) IterationSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.IterationSpecificationType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)

Aggregations

ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)15 ResourceActivationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType)4 SchemaHandlingType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType)4 IterationSpecificationType (com.evolveum.midpoint.xml.ns._public.common.common_3.IterationSpecificationType)3 ResourceBidirectionalMappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType)3 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)2 SynchronizationIntent (com.evolveum.midpoint.model.impl.lens.SynchronizationIntent)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ResourceAttributeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)2 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)2 ActivationValidityCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType)2 ArrayList (java.util.ArrayList)2 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1