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