use of com.evolveum.midpoint.schema.processor.ResourceSchema 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());
}
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class TestVillage method test022ResourceOpenDjRefinedSchema.
/**
* MID-3424
*/
@Test
public void test022ResourceOpenDjRefinedSchema() throws Exception {
final String TEST_NAME = "test022ResourceOpenDjRefinedSchema";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ResourceType> resourceBefore = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
ResourceSchema resourceSchemaBefore = RefinedResourceSchema.getResourceSchema(resourceBefore, prismContext);
RefinedResourceSchema refinedSchemaBefore = RefinedResourceSchema.getRefinedSchema(resourceBefore);
rememberResourceSchemaFetchCount();
rememberResourceSchemaParseCount();
rememberConnectorCapabilitiesFetchCount();
rememberConnectorInitializationCount();
rememberConnectorSchemaParseCount();
rememberPrismObjectCloneCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
long t0 = System.currentTimeMillis();
PrismObject<ResourceType> resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
long t1 = System.currentTimeMillis();
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
long t2 = System.currentTimeMillis();
ResourceSchema resourceSchemaAfter = RefinedResourceSchema.getResourceSchema(resourceAfter, prismContext);
long t3 = System.currentTimeMillis();
RefinedResourceSchema refinedSchemaAfter = RefinedResourceSchema.getRefinedSchema(resourceAfter);
long t4 = System.currentTimeMillis();
display("Times", "getObject(RESOURCE_OPENDJ_OID): " + (t1 - t0) + "ms\ngetResourceSchema: " + (t3 - t2) + "ms\ngetRefinedSchema: " + (t4 - t3) + "ms");
// variable number of clones: 1 or 2 because of trigger scanner task
assertPrismObjectCloneIncrement(1, 2);
assertResourceSchemaFetchIncrement(0);
assertResourceSchemaParseCountIncrement(0);
assertConnectorCapabilitiesFetchIncrement(0);
assertConnectorInitializationCountIncrement(0);
assertConnectorSchemaParseIncrement(0);
assertTrue("Resource schema has changed", resourceSchemaBefore == resourceSchemaAfter);
assertTrue("Refined schema has changed", refinedSchemaBefore == refinedSchemaAfter);
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema 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());
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class RefinedResourceSchemaImpl method parse.
public static RefinedResourceSchema parse(ResourceType resourceType, PrismContext prismContext) throws SchemaException {
ResourceSchema originalResourceSchema = getResourceSchema(resourceType, prismContext);
if (originalResourceSchema == null) {
return null;
}
String contextDescription = "definition of " + resourceType;
RefinedResourceSchemaImpl rSchema = new RefinedResourceSchemaImpl(originalResourceSchema);
SchemaHandlingType schemaHandling = resourceType.getSchemaHandling();
if (schemaHandling != null) {
parseObjectTypeDefsFromSchemaHandling(rSchema, resourceType, schemaHandling, schemaHandling.getObjectType(), null, prismContext, contextDescription);
}
parseObjectTypesFromSchema(rSchema, resourceType, prismContext, contextDescription);
// targets
for (RefinedObjectClassDefinition rOcDef : rSchema.getRefinedDefinitions()) {
((RefinedObjectClassDefinitionImpl) rOcDef).parseAssociations(rSchema);
((RefinedObjectClassDefinitionImpl) rOcDef).parseAuxiliaryObjectClasses(rSchema);
}
// We can parse attributes only after we have all the object class info parsed (including auxiliary object classes)
for (RefinedObjectClassDefinition rOcDef : rSchema.getRefinedDefinitions()) {
((RefinedObjectClassDefinitionImpl) rOcDef).parseAttributes(rSchema, contextDescription);
}
return rSchema;
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class ResourceValidatorImpl method validate.
@NotNull
@Override
public ValidationResult validate(@NotNull PrismObject<ResourceType> resourceObject, @NotNull Scope scope, @Nullable Locale locale, @NotNull Task task, @NotNull OperationResult result) {
final ResourceType resource = resourceObject.asObjectable();
final ValidationResult vr = new ValidationResult();
ResourceBundle bundle = ResourceBundle.getBundle(SchemaConstants.SCHEMA_LOCALIZATION_PROPERTIES_RESOURCE_BASE_PATH, locale != null ? locale : Locale.getDefault());
ResourceSchema resourceSchema = null;
try {
resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceObject, prismContext);
} catch (Throwable t) {
vr.add(Issue.Severity.WARNING, CAT_SCHEMA, C_NO_SCHEMA, getString(bundle, CLASS_DOT + C_NO_SCHEMA, t.getMessage()), ObjectTypeUtil.createObjectRef(resourceObject), ItemPath.EMPTY_PATH);
}
ResourceValidationContext ctx = new ResourceValidationContext(resourceObject, scope, task, vr, resourceSchema, bundle);
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
if (schemaHandling != null) {
checkSchemaHandlingDuplicateObjectTypes(ctx, schemaHandling);
checkSchemaHandlingDefaults(ctx, schemaHandling);
checkSchemaHandlingObjectTypes(ctx, schemaHandling);
}
SynchronizationType synchronization = resource.getSynchronization();
if (synchronization != null) {
checkSynchronizationDuplicateObjectTypes(ctx, synchronization);
int i = 1;
for (ObjectSynchronizationType objectSync : resource.getSynchronization().getObjectSynchronization()) {
checkObjectSynchronization(ctx, new ItemPath(ResourceType.F_SYNCHRONIZATION, SynchronizationType.F_OBJECT_SYNCHRONIZATION, i), objectSync);
i++;
}
}
checkSynchronizationExistenceForSchemaHandlingObjectTypes(ctx);
checkSchemaHandlingExistenceForSynchronizationObjectTypes(ctx);
return ctx.validationResult;
}
Aggregations