use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class PageRegistrationConfirmation method assignDefaultRoles.
private void assignDefaultRoles(String userOid, PrismObject<UserType> administrator, OperationResult parentResult) throws CommonException {
List<ObjectReferenceType> rolesToAssign = getSelfRegistrationConfiguration().getDefaultRoles();
if (CollectionUtils.isEmpty(rolesToAssign)) {
return;
}
OperationResult result = parentResult.createSubresult(OPERATION_ASSIGN_DEFAULT_ROLES);
try {
PrismContext prismContext = getPrismContext();
List<AssignmentType> assignmentsToCreate = rolesToAssign.stream().map(ref -> ObjectTypeUtil.createAssignmentTo(ref, prismContext)).collect(Collectors.toList());
ObjectDelta<Objectable> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).addRealValues(assignmentsToCreate).asObjectDelta(userOid);
runAsChecked(() -> {
Task task = createSimpleTask(OPERATION_ASSIGN_DEFAULT_ROLES);
WebModelServiceUtils.save(delta, result, task, PageRegistrationConfirmation.this);
return null;
}, administrator);
} catch (CommonException | RuntimeException e) {
result.recordFatalError(getString("PageRegistrationConfirmation.message.assignDefaultRoles.fatalError"), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class SearchShadowOwnerTest method initSystem.
@Override
public void initSystem() throws Exception {
super.initSystem();
OperationResult result = new OperationResult("Add sample data");
// insert sample data
final File OBJECTS_FILE = new File(FOLDER_BASIC, "objects.xml");
List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(OBJECTS_FILE).parseObjects();
for (int i = 0; i < elements.size(); i++) {
PrismObject object = elements.get(i);
repositoryService.addObject(object, null, result);
}
result.computeStatus();
AssertJUnit.assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class TestTextFormatter method test050FormatDeltaWithOperAndAuxItems.
@Test
public void test050FormatDeltaWithOperAndAuxItems() throws Exception {
given();
PrismObject<UserType> jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE));
displayValue("jack", jack.debugDump());
// @formatter:off
ObjectDelta<Objectable> delta = prismContext.deltaFor(UserType.class).item(UserType.F_LINK_REF).add(ObjectTypeUtil.createObjectRef("aecfb587-cc61-41aa-aeeb-962d4369de86", ObjectTypes.SHADOW)).item(UserType.F_METADATA, MetadataType.F_MODIFY_TIMESTAMP).replace(XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis())).asObjectDelta("some-user-oid");
// @formatter:on
displayValue("delta", delta.debugDump());
when();
String deltaFormattedHideNone = textFormatter.formatObjectModificationDelta(delta, null, true, jack, null);
System.out.println("no hidden paths + show operational attributes:\n" + deltaFormattedHideNone);
String deltaFormattedHideOper = textFormatter.formatObjectModificationDelta(delta, null, false, jack, null);
System.out.println("no hidden paths + hide operational attributes:\n" + deltaFormattedHideOper);
String deltaFormattedHideAux = textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, true, jack, null);
System.out.println("hide auxiliary paths + show operational attributes:\n" + deltaFormattedHideAux);
String deltaFormattedHideAuxAndOper = textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, false, jack, null);
System.out.println("hide auxiliary paths + hide operational attributes:\n" + deltaFormattedHideAuxAndOper);
then();
// TODO create some asserts here
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class TestXmlJsonRoundtrip method doubleSerialization.
@NotNull
private PrismObject<Objectable> doubleSerialization(File name) throws SchemaException, IOException {
PrismContext context = getPrismContext();
PrismObject<Objectable> xmlObject = context.parserFor(name).language("xml").parse();
assertNotNull(xmlObject);
String jsonString = context.jsonSerializer().serialize(xmlObject);
display(jsonString);
@NotNull PrismObject<Objectable> jsonObject = context.parserFor(jsonString).language("json").parse();
assertObjectEquals(jsonObject, xmlObject);
String json2String = context.jsonSerializer().serialize(jsonObject);
var json2Object = context.parserFor(json2String).language("json").parse();
assertObjectEquals(jsonObject, json2Object);
return json2Object;
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class DeleteTest method test100DeleteObjects.
@Test
public void test100DeleteObjects() throws Exception {
List<PrismObject<? extends Objectable>> objects = prismContext.parserFor(new File(FOLDER_BASIC, "objects.xml")).parseObjects();
OperationResult result = new OperationResult("add objects");
List<String> oids = new ArrayList<>();
for (PrismObject object : objects) {
oids.add(repositoryService.addObject(object, null, result));
}
result.recomputeStatus();
AssertJUnit.assertTrue(result.isSuccess());
for (int i = 0; i < objects.size(); i++) {
repositoryService.deleteObject((Class) objects.get(i).getCompileTimeClass(), oids.get(i), result);
}
result.recomputeStatus();
AssertJUnit.assertTrue(result.isSuccess());
}
Aggregations