Search in sources :

Example 36 with ObjectClassComplexTypeDefinition

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

the class ConsistencyTest method checkOpenDjSchema.

private void checkOpenDjSchema(ResourceType resource, String source) throws SchemaException {
    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition accountDefinition = schema.findObjectClassDefinition(RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    assertNotNull("Schema does not define any account (resource from " + source + ")", accountDefinition);
    Collection<? extends ResourceAttributeDefinition> identifiers = accountDefinition.getPrimaryIdentifiers();
    assertFalse("No account identifiers (resource from " + source + ")", identifiers == null || identifiers.isEmpty());
    // TODO: check for naming attributes and display names, etc
    ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    if (capActivation != null && capActivation.getStatus() != null && capActivation.getStatus().getAttribute() != null) {
        // There is simulated activation capability, check if the attribute is in schema.
        QName enableAttrName = capActivation.getStatus().getAttribute();
        ResourceAttributeDefinition enableAttrDef = accountDefinition.findAttributeDefinition(enableAttrName);
        display("Simulated activation attribute definition", enableAttrDef);
        assertNotNull("No definition for enable attribute " + enableAttrName + " in account (resource from " + source + ")", enableAttrDef);
        assertTrue("Enable attribute " + enableAttrName + " is not ignored (resource from " + source + ")", enableAttrDef.isIgnored());
    }
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 37 with ObjectClassComplexTypeDefinition

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

the class TestSanityLegacy method checkOpenDjSchema.

private void checkOpenDjSchema(ResourceType resource, String source) throws SchemaException {
    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition accountDefinition = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    assertNotNull("Schema does not define any account (resource from " + source + ")", accountDefinition);
    Collection<? extends ResourceAttributeDefinition> identifiers = accountDefinition.getPrimaryIdentifiers();
    assertFalse("No account identifiers (resource from " + source + ")", identifiers == null || identifiers.isEmpty());
    // TODO: check for naming attributes and display names, etc
    ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    if (capActivation != null && capActivation.getStatus() != null && capActivation.getStatus().getAttribute() != null) {
        // There is simulated activation capability, check if the attribute is in schema.
        QName enableAttrName = capActivation.getStatus().getAttribute();
        ResourceAttributeDefinition enableAttrDef = accountDefinition.findAttributeDefinition(enableAttrName);
        display("Simulated activation attribute definition", enableAttrDef);
        assertNotNull("No definition for enable attribute " + enableAttrName + " in account (resource from " + source + ")", enableAttrDef);
        assertTrue("Enable attribute " + enableAttrName + " is not ignored (resource from " + source + ")", enableAttrDef.isIgnored());
    }
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 38 with ObjectClassComplexTypeDefinition

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

the class TestUnix method test010Schema.

@Test
public void test010Schema() throws Exception {
    final String TEST_NAME = "test010Schema";
    TestUtil.displayTestTile(this, TEST_NAME);
    resourceOpenDj = getObject(ResourceType.class, RESOURCE_OPENDJ_OID);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    IntegrationTestTools.displayXml("Initialized resource", resourceOpenDj);
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resourceOpenDj, prismContext);
    display("OpenDJ schema (resource)", resourceSchema);
    ObjectClassComplexTypeDefinition ocDefPosixAccount = resourceSchema.findObjectClassDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixAccount);
    assertTrue("Objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixAccount.isAuxiliary());
    ObjectClassComplexTypeDefinition ocDefPosixGroup = resourceSchema.findObjectClassDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixGroup);
    assertTrue("Objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixGroup.isAuxiliary());
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resourceOpenDj);
    display("OpenDJ schema (refined)", refinedSchema);
    RefinedObjectClassDefinition rOcDefPosixAccount = refinedSchema.getRefinedDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixAccount);
    assertTrue("Refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixAccount.isAuxiliary());
    RefinedObjectClassDefinition rOcDefPosixGroup = refinedSchema.getRefinedDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixGroup);
    assertTrue("Refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixGroup.isAuxiliary());
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

Example 39 with ObjectClassComplexTypeDefinition

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

the class RefinedResourceSchemaImpl method parseObjectTypesFromSchema.

private static void parseObjectTypesFromSchema(RefinedResourceSchemaImpl rSchema, ResourceType resourceType, PrismContext prismContext, String contextDescription) throws SchemaException {
    RefinedObjectClassDefinition rAccountDefDefault = null;
    for (ObjectClassComplexTypeDefinition objectClassDef : rSchema.getOriginalResourceSchema().getObjectClassDefinitions()) {
        QName objectClassname = objectClassDef.getTypeName();
        if (rSchema.getRefinedDefinition(objectClassname) != null) {
            continue;
        }
        RefinedObjectClassDefinition rOcDef = RefinedObjectClassDefinitionImpl.parseFromSchema(objectClassDef, resourceType, rSchema, prismContext, "object class " + objectClassname + ", in " + contextDescription);
        if (objectClassDef.getKind() == ShadowKindType.ACCOUNT && rOcDef.isDefault()) {
            if (rAccountDefDefault == null) {
                rAccountDefDefault = rOcDef;
            } else {
                throw new SchemaException("More than one default account definitions (" + rAccountDefDefault + ", " + rOcDef + ") in " + contextDescription);
            }
        }
        rSchema.add(rOcDef);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 40 with ObjectClassComplexTypeDefinition

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

the class Utils method determineObjectClassInternal.

private static ObjectClassComplexTypeDefinition determineObjectClassInternal(RefinedResourceSchema refinedSchema, 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.
        ObjectClassComplexTypeDefinition objectClassDefinition = refinedSchema.findObjectClassDefinition(objectclass);
        if (objectClassDefinition == null) {
            throw new SchemaException("No object class " + objectclass + " in the schema for " + source);
        }
        return objectClassDefinition;
    }
    RefinedObjectClassDefinition refinedObjectClassDefinition;
    if (kind != null) {
        refinedObjectClassDefinition = refinedSchema.getRefinedDefinition(kind, intent);
        LOGGER.trace("Determined refined object class {} by using kind={}, intent={}", new Object[] { refinedObjectClassDefinition, kind, intent });
    } else if (objectclass != null) {
        refinedObjectClassDefinition = refinedSchema.getRefinedDefinition(objectclass);
        LOGGER.trace("Determined refined object class {} by using objectClass={}", new Object[] { refinedObjectClassDefinition, objectclass });
    } else {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.debug("No kind or objectclass specified in {}, assuming null object class", source);
        }
        refinedObjectClassDefinition = null;
    }
    return refinedObjectClassDefinition;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Aggregations

ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)53 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)18 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)17 Test (org.testng.annotations.Test)17 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)16 QName (javax.xml.namespace.QName)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ArrayList (java.util.ArrayList)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)5 Containerable (com.evolveum.midpoint.prism.Containerable)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3