use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class PageAccounts method createIntentChoices.
private IModel<List<String>> createIntentChoices() {
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
List<String> intentList = new ArrayList<>();
ResourceItemDto dto = resourceModel.getObject();
PrismObject<ResourceType> resourcePrism;
if (dto == null) {
return intentList;
}
String oid = dto.getOid();
OperationResult result = new OperationResult(OPERATION_GET_INTENTS);
try {
resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
ResourceType resource = resourcePrism.asObjectable();
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
for (ResourceObjectTypeDefinitionType r : schemaHandling.getObjectType()) {
intentList.add(r.getIntent());
}
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
error("Couldn't load intents from resource.");
return null;
}
return intentList;
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class TestSanity method checkOpenDjSchemaHandling.
private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class ConsistencyTest method test124AddAccountDirectAlreadyExists.
//MID-1595, MID-1577
@Test
public void test124AddAccountDirectAlreadyExists() throws Exception {
final String TEST_NAME = "test124AddAccountDirectAlreadyExists";
TestUtil.displayTestTile(TEST_NAME);
OperationResult parentResult = new OperationResult(TEST_NAME);
Task task = taskManager.createTaskInstance();
SchemaHandlingType oldSchemaHandling = resourceTypeOpenDjrepo.getSchemaHandling();
SynchronizationType oldSynchronization = resourceTypeOpenDjrepo.getSynchronization();
try {
// we will reapply this schema handling after this test finish
ItemDefinition syncDef = resourceTypeOpenDjrepo.asPrismObject().getDefinition().findItemDefinition(ResourceType.F_SYNCHRONIZATION);
assertNotNull("null definition for sync delta", syncDef);
ObjectDeltaType omt = unmarshallValueFromFile(REQUEST_RESOURCE_MODIFY_SYNCHRONIZATION, ObjectDeltaType.class);
ObjectDelta objectDelta = DeltaConvertor.createObjectDelta(omt, prismContext);
repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, objectDelta.getModifications(), parentResult);
requestToExecuteChanges(REQUEST_RESOURCE_MODIFY_RESOURCE_SCHEMA, RESOURCE_OPENDJ_OID, ResourceType.class, task, null, parentResult);
PrismObject<ResourceType> res = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, parentResult);
// LOGGER.trace("resource schema handling after modify: {}",
// prismContext.silentMarshalObject(res.asObjectable(), LOGGER));
repoAddObjectFromFile(USER_ABOMBA_FILENAME, parentResult);
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, parentResult);
String abombaOid = assertUserOneAccountRef(USER_ABOMBA_OID);
ShadowType abombaShadow = repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult).asObjectable();
assertShadowName(abombaShadow, "uid=abomba,OU=people,DC=example,DC=com");
repoAddObjectFromFile(USER_ABOM_FILENAME, parentResult);
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOM_OID, UserType.class, task, null, parentResult);
String abomOid = assertUserOneAccountRef(USER_ABOM_OID);
ShadowType abomShadow = repositoryService.getObject(ShadowType.class, abomOid, null, parentResult).asObjectable();
assertShadowName(abomShadow, "uid=abomba1,OU=people,DC=example,DC=com");
ReferenceDelta abombaDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, new PrismReferenceValue(abombaOid));
ObjectDelta d = ObjectDelta.createModifyDelta(USER_ABOMBA_OID, abombaDeleteAccDelta, UserType.class, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(d), null, task, parentResult);
assertUserNoAccountRef(USER_ABOMBA_OID, parentResult);
repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult);
ReferenceDelta abomDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, abomShadow.asPrismObject());
ObjectDelta d2 = ObjectDelta.createModifyDelta(USER_ABOM_OID, abomDeleteAccDelta, UserType.class, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(d2), null, task, parentResult);
assertUserNoAccountRef(USER_ABOM_OID, parentResult);
try {
repositoryService.getObject(ShadowType.class, abomOid, null, parentResult);
fail("Expected that shadow abom does not exist, but it is");
} catch (ObjectNotFoundException ex) {
// this is expected
} catch (Exception ex) {
fail("Expected object not found exception but got " + ex);
}
LOGGER.info("starting second execution request for user abomba");
OperationResult result = new OperationResult("Add account already exist result.");
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, result);
String abombaOid2 = assertUserOneAccountRef(USER_ABOMBA_OID);
ShadowType abombaShadow2 = repositoryService.getObject(ShadowType.class, abombaOid2, null, result).asObjectable();
assertShadowName(abombaShadow2, "uid=abomba,OU=people,DC=example,DC=com");
result.computeStatus();
LOGGER.info("Displaying execute changes result");
display(result);
// return the previous changes of resource back
Collection<? extends ItemDelta> schemaHandlingDelta = ContainerDelta.createModificationReplaceContainerCollection(ResourceType.F_SCHEMA_HANDLING, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSchemaHandling.asPrismContainerValue().clone());
PropertyDelta syncDelta = PropertyDelta.createModificationReplaceProperty(ResourceType.F_SYNCHRONIZATION, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSynchronization);
((Collection) schemaHandlingDelta).add(syncDelta);
repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, schemaHandlingDelta, parentResult);
} catch (Exception ex) {
LOGGER.info("error: " + ex.getMessage(), ex);
throw ex;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class ResourceCarefulAntUtil method initAnts.
public static void initAnts(List<CarefulAnt<ResourceType>> ants, final File resourceFile, final PrismContext prismContext) {
final PrismObjectDefinition<ResourceType> resourceDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class);
ants.add(new CarefulAnt<ResourceType>() {
@Override
public ItemDelta<?, ?> createDelta(int iteration) {
return prismContext.deltaFactory().property().createModificationReplaceProperty(ResourceType.F_DESCRIPTION, resourceDef, "Blah " + iteration);
}
@Override
public void assertModification(PrismObject<ResourceType> resource, int iteration) {
assertEquals("Wrong description in iteration " + iteration, "Blah " + iteration, resource.asObjectable().getDescription());
}
});
ants.add(new CarefulAnt<ResourceType>() {
SchemaHandlingType schemaHandling;
@Override
public ItemDelta<?, ?> createDelta(int iteration) throws SchemaException {
schemaHandling = createNewSchemaHandling(resourceFile, iteration, prismContext);
return prismContext.deltaFactory().container().createModificationReplace(ResourceType.F_SCHEMA_HANDLING, prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class), schemaHandling.asPrismContainerValue().clone());
}
@Override
public void assertModification(PrismObject<ResourceType> resource, int iteration) {
if (!schemaHandling.equals(resource.asObjectable().getSchemaHandling())) {
System.out.println("Expected: " + PrismUtil.serializeQuietly(prismContext, schemaHandling));
System.out.println("Real: " + PrismUtil.serializeQuietly(prismContext, resource.asObjectable().getSchemaHandling()));
fail("Wrong schemaHandling in iteration" + iteration);
}
// assertEquals("Wrong schemaHandling in iteration "+iteration, schemaHandling, resource.asObjectable().getSchemaHandling());
}
});
ants.add(new CarefulAnt<ResourceType>() {
SchemaDefinitionType xmlSchemaDef;
@Override
public ItemDelta<?, ?> createDelta(int iteration) throws SchemaException {
xmlSchemaDef = createNewXmlSchemaDef(resourceFile, iteration, prismContext);
return prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ResourceType.F_SCHEMA, XmlSchemaType.F_DEFINITION), resourceDef, xmlSchemaDef);
}
@Override
public void assertModification(PrismObject<ResourceType> resource, int iteration) {
List<Element> orgigElements = xmlSchemaDef.getAny();
List<Element> newElements = resource.asObjectable().getSchema().getDefinition().getAny();
assertEquals("Wrong number of elements in schema definition in iteration " + iteration, orgigElements.size(), newElements.size());
// TODO look inside elements
}
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class ResourceCarefulAntUtil method createNewSchemaHandling.
private static SchemaHandlingType createNewSchemaHandling(File resourceFile, int iteration, PrismContext prismContext) throws SchemaException {
PrismObject<ResourceType> resource = parseResource(resourceFile, prismContext);
SchemaHandlingType schemaHandling = resource.asObjectable().getSchemaHandling();
ResourceObjectTypeDefinitionType accountType = schemaHandling.getObjectType().iterator().next();
List<ResourceAttributeDefinitionType> attrDefs = accountType.getAttribute();
ResourceAttributeDefinitionType attributeDefinitionType = attrDefs.get(rnd.nextInt(attrDefs.size()));
attributeDefinitionType.setDescription(Integer.toString(iteration));
return schemaHandling;
}
Aggregations