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);
}
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());
}
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();
}
};
}
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;
}
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());
}
Aggregations