Search in sources :

Example 11 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AbstractIntegrationTest method getAttributeDefinition.

// objectClassName may be null
protected RefinedAttributeDefinition getAttributeDefinition(ResourceType resourceType, ShadowKindType kind, QName objectClassName, String attributeLocalName) throws SchemaException {
    RefinedResourceSchema refinedResourceSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    RefinedObjectClassDefinition refinedObjectClassDefinition = refinedResourceSchema.findRefinedDefinitionByObjectClassQName(kind, objectClassName);
    return refinedObjectClassDefinition.findAttributeDefinition(attributeLocalName);
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 12 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class TestSanityLegacy method test016ProvisioningSearchAccountsIterative.

@Test
public void test016ProvisioningSearchAccountsIterative() throws Exception {
    TestUtil.displayTestTile("test016ProvisioningSearchAccountsIterative");
    // GIVEN
    OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + ".test016ProvisioningSearchAccountsIterative");
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceTypeOpenDjrepo, prismContext);
    final RefinedObjectClassDefinition refinedAccountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    QName objectClass = refinedAccountDefinition.getObjectClassDefinition().getTypeName();
    ObjectQuery q = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceTypeOpenDjrepo.getOid(), objectClass, prismContext);
    //        ObjectQuery q = QueryConvertor.createObjectQuery(ResourceObjectShadowType.class, query, prismContext);
    final Collection<ObjectType> objects = new HashSet<>();
    final MatchingRule caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    ResultHandler handler = new ResultHandler<ObjectType>() {

        @Override
        public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
            ObjectType objectType = prismObject.asObjectable();
            objects.add(objectType);
            display("Found object", objectType);
            assertTrue(objectType instanceof ShadowType);
            ShadowType shadow = (ShadowType) objectType;
            assertNotNull(shadow.getOid());
            assertNotNull(shadow.getName());
            assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "AccountObjectClass"), shadow.getObjectClass());
            assertEquals(RESOURCE_OPENDJ_OID, shadow.getResourceRef().getOid());
            String icfUid = getAttributeValue(shadow, SchemaConstants.ICFS_UID);
            assertNotNull("No ICF UID", icfUid);
            String icfName = getNormalizedAttributeValue(shadow, refinedAccountDefinition, SchemaConstants.ICFS_NAME);
            assertNotNull("No ICF NAME", icfName);
            try {
                PrismAsserts.assertEquals("Wrong shadow name", caseIgnoreMatchingRule, shadow.getName().getOrig(), icfName);
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "uid")));
            assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "cn")));
            assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "sn")));
            assertNotNull("Missing activation", shadow.getActivation());
            assertNotNull("Missing activation status", shadow.getActivation().getAdministrativeStatus());
            return true;
        }
    };
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, q, null, handler, null, result);
    // THEN
    display("Count", objects.size());
}
Also used : QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) StringIgnoreCaseMatchingRule(com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 13 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class RefinedObjectTypeChoicePanel method createChoiceModel.

private static IModel<? extends List<? extends RefinedObjectClassDefinition>> createChoiceModel(final IModel<PrismObject<ResourceType>> resourceModel) {
    return new IModel<List<? extends RefinedObjectClassDefinition>>() {

        @Override
        public List<? extends RefinedObjectClassDefinition> getObject() {
            RefinedResourceSchema refinedSchema;
            try {
                refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceModel.getObject());
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            List<? extends RefinedObjectClassDefinition> refinedDefinitions = refinedSchema.getRefinedDefinitions();
            List<? extends RefinedObjectClassDefinition> defs = new ArrayList<>();
            for (RefinedObjectClassDefinition rdef : refinedDefinitions) {
                if (rdef.getKind() != null) {
                    ((List) defs).add(rdef);
                }
            }
            return defs;
        }

        @Override
        public void detach() {
        }

        @Override
        public void setObject(List<? extends RefinedObjectClassDefinition> object) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 14 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class ResourceContentTabPanel method createObjectClassChoices.

private List<QName> createObjectClassChoices(IModel<PrismObject<ResourceType>> model) {
    RefinedResourceSchema refinedSchema;
    try {
        refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(model.getObject(), parentPage.getPrismContext());
    } catch (SchemaException e) {
        warn("Could not determine defined obejct classes for resource");
        return new ArrayList<QName>();
    }
    Collection<ObjectClassComplexTypeDefinition> defs = refinedSchema.getObjectClassDefinitions();
    List<QName> objectClasses = new ArrayList<QName>(defs.size());
    for (ObjectClassComplexTypeDefinition def : defs) {
        objectClasses.add(def.getTypeName());
    }
    return objectClasses;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 15 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AbstractAdTest method test020Schema.

@Test
public void test020Schema() throws Exception {
    final String TEST_NAME = "test020Schema";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN        
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext);
    display("Resource schema", resourceSchema);
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
    display("Refined schema", refinedSchema);
    accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass());
    assertNotNull("No definition for object class " + getAccountObjectClass(), accountObjectClassDefinition);
    display("Account object class def", accountObjectClassDefinition);
    ResourceAttributeDefinition<String> cnDef = accountObjectClassDefinition.findAttributeDefinition("cn");
    PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 0, 1);
    assertTrue("cn read", cnDef.canRead());
    assertFalse("cn modify", cnDef.canModify());
    assertFalse("cn add", cnDef.canAdd());
    ResourceAttributeDefinition<String> userPrincipalNameDef = accountObjectClassDefinition.findAttributeDefinition("userPrincipalName");
    PrismAsserts.assertDefinition(userPrincipalNameDef, new QName(MidPointConstants.NS_RI, "userPrincipalName"), DOMUtil.XSD_STRING, 0, 1);
    assertTrue("o read", userPrincipalNameDef.canRead());
    assertTrue("o modify", userPrincipalNameDef.canModify());
    assertTrue("o add", userPrincipalNameDef.canAdd());
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

Aggregations

RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 QName (javax.xml.namespace.QName)10 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 Test (org.testng.annotations.Test)4 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 Containerable (com.evolveum.midpoint.prism.Containerable)2 MatchingRule (com.evolveum.midpoint.prism.match.MatchingRule)2