Search in sources :

Example 41 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test114DetermineObjectClassKindIntentObjectClass.

@Test
public void test114DetermineObjectClassKindIntentObjectClass() throws Exception {
    OperationResult result = createOperationResult();
    importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);
    Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
    display("Task", task);
    // WHEN
    ResourceObjectDefinition objectClass = ModelImplUtils.determineObjectDefinition(refinedSchema, task);
    // THEN
    displayDumpable("Object class", objectClass);
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID);
    assertRefinedObjectClass(objectClass, RESOURCE_DUMMY_PRIVILEGE_OBJECTCLASS_QNAME, ShadowKindType.ENTITLEMENT, "privilege");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 42 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test124DetermineObjectClassKindIntentObjectClassModel.

@Test
public void test124DetermineObjectClassKindIntentObjectClassModel() throws Exception {
    OperationResult result = createOperationResult();
    importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);
    Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
    display("Task", task);
    // WHEN
    ResourceObjectDefinition objectClass = ModelImplUtils.determineObjectDefinition(refinedSchemaModel, task);
    // THEN
    displayDumpable("Object class", objectClass);
    displayValue("Object class (toString)", objectClass.toString());
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID);
    assertLayerRefinedObjectClass(objectClass, RESOURCE_DUMMY_PRIVILEGE_OBJECTCLASS_QNAME, ShadowKindType.ENTITLEMENT, "privilege", LayerType.MODEL);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 43 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test112DetermineObjectClassKindIntent.

@Test
public void test112DetermineObjectClassKindIntent() throws Exception {
    OperationResult result = createOperationResult();
    importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);
    Task task = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
    display("Task", task);
    // WHEN
    ResourceObjectDefinition objectClass = ModelImplUtils.determineObjectDefinition(refinedSchema, task);
    // THEN
    displayDumpable("Object class", objectClass);
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_KIND_INTENT_OID);
    assertRefinedObjectClass(objectClass, RESOURCE_DUMMY_PRIVILEGE_OBJECTCLASS_QNAME, ShadowKindType.ENTITLEMENT, "privilege");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 44 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class ModelImplUtils method determineObjectClassInternal.

private static ResourceObjectDefinition determineObjectClassInternal(ResourceSchema resourceSchema, QName objectclass, ShadowKindType kind, String intent, Object source) throws SchemaException {
    if (kind == null && intent == null && objectclass != null) {
        // Return generic object class definition from resource schema. No kind/intent means that we want
        // to process all kinds and intents in the object class.
        ResourceObjectDefinition objectClassDefinition = resourceSchema.findDefinitionForObjectClass(objectclass);
        if (objectClassDefinition == null) {
            throw new SchemaException("No object class " + objectclass + " in the schema for " + source);
        }
        return objectClassDefinition;
    }
    ResourceObjectDefinition resourceObjectDefinition;
    if (kind != null) {
        resourceObjectDefinition = resourceSchema.findObjectDefinition(kind, intent);
        LOGGER.trace("Determined refined object class {} by using kind={}, intent={}", resourceObjectDefinition, kind, intent);
    } else if (objectclass != null) {
        resourceObjectDefinition = resourceSchema.findDefinitionForObjectClass(objectclass);
        LOGGER.trace("Determined refined object class {} by using objectClass={}", resourceObjectDefinition, objectclass);
    } else {
        resourceObjectDefinition = null;
        LOGGER.debug("No kind or objectclass specified in {}, assuming null object class", source);
    }
    return resourceObjectDefinition;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)

Example 45 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class ShadowCaretaker method applyAttributesDefinition.

public ProvisioningContext applyAttributesDefinition(ProvisioningContext ctx, PrismObject<ShadowType> shadow) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
    ProvisioningContext subctx = ctx.spawnForShadow(shadow);
    subctx.assertDefinition();
    ResourceObjectDefinition objectDefinition = subctx.getObjectDefinitionRequired();
    PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    if (attributesContainer != null) {
        if (attributesContainer instanceof ResourceAttributeContainer) {
            if (attributesContainer.getDefinition() == null) {
                attributesContainer.applyDefinition(objectDefinition.toResourceAttributeContainerDefinition());
            }
        } else {
            try {
                // We need to convert <attributes> to
                // ResourceAttributeContainer
                ResourceAttributeContainer convertedContainer = ResourceAttributeContainer.convertFromContainer(attributesContainer, objectDefinition);
                shadow.getValue().replace(attributesContainer, convertedContainer);
            } catch (SchemaException e) {
                throw new SchemaException(e.getMessage() + " in " + shadow, e);
            }
        }
    }
    // We also need to replace the entire object definition to inject
    // correct object class definition here
    // If we don't do this then the patch (delta.applyTo) will not work
    // correctly because it will not be able to
    // create the attribute container if needed.
    PrismObjectDefinition<ShadowType> prismShadowDefinition = shadow.getDefinition();
    PrismContainerDefinition<ShadowAttributesType> origAttrContainerDef = prismShadowDefinition.findContainerDefinition(ShadowType.F_ATTRIBUTES);
    if (!(origAttrContainerDef instanceof ResourceAttributeContainerDefinition)) {
        PrismObjectDefinition<ShadowType> clonedDefinition = prismShadowDefinition.cloneWithReplacedDefinition(ShadowType.F_ATTRIBUTES, objectDefinition.toResourceAttributeContainerDefinition());
        shadow.setDefinition(clonedDefinition);
        clonedDefinition.freeze();
    }
    return subctx;
}
Also used : ResourceAttributeContainerDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)

Aggregations

ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)64 QName (javax.xml.namespace.QName)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)14 ArrayList (java.util.ArrayList)14 Task (com.evolveum.midpoint.task.api.Task)12 Test (org.testng.annotations.Test)12 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)8 NotNull (org.jetbrains.annotations.NotNull)8 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)6 ResourceAssociationDefinition (com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)5 Collection (java.util.Collection)5 Nullable (org.jetbrains.annotations.Nullable)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)4 AutoCompleteQNamePanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel)3 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)2 ItemName (com.evolveum.midpoint.prism.path.ItemName)2