use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.
the class TestRefinedSchema method test114DetermineObjectClassKindIntentObjectClass.
@Test
public void test114DetermineObjectClassKindIntentObjectClass() throws Exception {
final String TEST_NAME = "test114DetermineObjectClassKindIntentObjectClass";
TestUtil.displayTestTile(this, TEST_NAME);
OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE);
Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_OID, result);
display("Task", task);
// WHEN
ObjectClassComplexTypeDefinition objectClass = Utils.determineObjectClass(refinedSchema, task);
// THEN
display("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.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.
the class ImportAccountsFromResourceTaskHandler method createHandler.
// shadowToImport - it is used to derive objectClass/intent/kind when importing a single shadow
private SynchronizeAccountResultHandler createHandler(ResourceType resource, PrismObject<ShadowType> shadowToImport, TaskRunResult runResult, Task coordinatorTask, OperationResult opResult) {
RefinedResourceSchema refinedSchema;
ObjectClassComplexTypeDefinition objectClass;
try {
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined schema:\n{}", refinedSchema.debugDump());
}
if (shadowToImport != null) {
objectClass = Utils.determineObjectClass(refinedSchema, shadowToImport);
} else {
objectClass = Utils.determineObjectClass(refinedSchema, coordinatorTask);
}
if (objectClass == null) {
LOGGER.error("Import: No objectclass specified and no default can be determined.");
opResult.recordFatalError("No objectclass specified and no default can be determined");
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
return null;
}
} catch (SchemaException e) {
LOGGER.error("Import: Schema error during processing account definition: {}", e.getMessage());
opResult.recordFatalError("Schema error during processing account definition: " + e.getMessage(), e);
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
return null;
}
LOGGER.info("Start executing import from resource {}, importing object class {}", resource, objectClass.getTypeName());
SynchronizeAccountResultHandler handler = new SynchronizeAccountResultHandler(resource, objectClass, "import", coordinatorTask, changeNotificationDispatcher, taskManager);
handler.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_IMPORT);
handler.setForceAdd(true);
handler.setStopOnError(false);
handler.setContextDesc("from " + resource);
handler.setLogObjectProgress(true);
return handler;
}
use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.
the class TestEntitlements method getGroupShadow.
private PrismObject<ShadowType> getGroupShadow(DummyResourceContoller dummyResourceCtl, QName objectClass, String name, Task task, OperationResult result) throws Exception {
PrismObject<ResourceType> resource = dummyResourceCtl.getResource();
ObjectClassComplexTypeDefinition groupDef = RefinedResourceSchema.getRefinedSchema(resource).findObjectClassDefinition(dummyResourceCtl.getGroupObjectClass());
ResourceAttributeDefinition<Object> nameDef = groupDef.findAttributeDefinition(SchemaConstants.ICFS_NAME);
assertNotNull("No icfs:name definition", nameDef);
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassFilterPrefix(resource.getOid(), objectClass, prismContext).and().item(new ItemPath(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME), nameDef).eq(name).build();
SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
assertEquals("Wrong # of results for " + name + " of " + objectClass + " at " + resource, 1, shadows.size());
return shadows.get(0);
}
use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.
the class TestDummy method createOnOffQuery.
private ObjectQuery createOnOffQuery() throws SchemaException {
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME);
ResourceAttributeDefinition<String> attrDef = objectClassDef.findAttributeDefinition(dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME));
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext).item(ShadowType.F_RESOURCE_REF).ref(RESOURCE_DUMMY_OID).and().item(ShadowType.F_OBJECT_CLASS).eq(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME)).and().itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getName()).eq("Sea Monkey").and().item(ShadowType.F_DEAD).eq(true).build();
display("Query", query);
return query;
}
use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.
the class TestDummy method test502ModifyProtectedAccountShadowAttributes.
/**
* Attribute modification should fail.
*/
@Test
public void test502ModifyProtectedAccountShadowAttributes() throws Exception {
final String TEST_NAME = "test502ModifyProtectedAccountShadowAttributes";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
Collection<? extends ItemDelta> modifications = new ArrayList<ItemDelta>(1);
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
ResourceAttributeDefinition fullnameAttrDef = defaultAccountDefinition.findAttributeDefinition("fullname");
ResourceAttribute fullnameAttr = fullnameAttrDef.instantiate();
PropertyDelta fullnameDelta = fullnameAttr.createDelta(new ItemPath(ShadowType.F_ATTRIBUTES, fullnameAttrDef.getName()));
fullnameDelta.setValueToReplace(new PrismPropertyValue<String>("Good Daemon"));
((Collection) modifications).add(fullnameDelta);
// WHEN
try {
provisioningService.modifyObject(ShadowType.class, ACCOUNT_DAEMON_OID, modifications, null, null, task, result);
AssertJUnit.fail("Expected security exception while modifying 'daemon' account");
} catch (SecurityViolationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
display("modifyObject result (expected failure)", result);
TestUtil.assertFailure(result);
syncServiceMock.assertNotifyFailureOnly();
// checkConsistency();
assertSteadyResource();
}
Aggregations