use of com.evolveum.midpoint.prism.SerializationOptions in project midpoint by Evolveum.
the class AbstractJsonLexicalProcessor method generateNsDeclarationIfNeeded.
private void generateNsDeclarationIfNeeded(MapXNode map, JsonSerializationContext ctx) throws IOException {
SerializationOptions opts = ctx.prismSerializationContext.getOptions();
if (!SerializationOptions.isUseNsProperty(opts) || map.isEmpty()) {
return;
}
String namespace = determineNewCurrentNamespace(map, ctx);
if (namespace != null && !StringUtils.equals(namespace, ctx.currentNamespace)) {
ctx.currentNamespace = namespace;
ctx.generator.writeFieldName(PROP_NAMESPACE);
ctx.generator.writeString(namespace);
}
}
use of com.evolveum.midpoint.prism.SerializationOptions in project midpoint by Evolveum.
the class ShadowAttributeIdSyncStoreReadTest method test100ImportIdItemFromResourceReadFromRepository.
@Test
public void test100ImportIdItemFromResourceReadFromRepository() throws Exception {
login(userAdministrator);
OperationResult result = new OperationResult(ShadowAttributeIdSyncStoreReadTest.class.getName() + ".test100");
// modelService.importFromResource(RESOURCE_DUMMY_FOR_CHECKER_OID, new QName(RI, "account1"),initTask, initResult);
Task importTask = createTask();
importTask.setOwner(userAdministrator);
modelService.importFromResource(RESOURCE_ID, dummy.getAccountObjectClass(), importTask, result.createSubresult("import"));
waitForTaskFinish(importTask, false);
List<PrismObject<ShadowType>> shadows = repositoryService.searchObjects(ShadowType.class, null, null, result);
PrismObject<ShadowType> object = shadows.get(0);
@NotNull Collection<SelectorOptions<GetOperationOptions>> options = schemaService.getOperationOptionsBuilder().raw().build();
PrismObject<ShadowType> raw = repositoryService.getObject(ShadowType.class, object.getOid(), options, result);
PrismObject<ShadowType> provisioning = provisioningService.getObject(ShadowType.class, object.getOid(), null, null, result);
PrismContainerValue<?> dbAttributes = object.getAnyValue().getValue().getAttributes().asPrismContainerValue();
PrismContainerValue<?> provisioningAttributes = provisioning.getAnyValue().getValue().getAttributes().asPrismContainerValue();
SerializationOptions opt2 = SerializationOptions.createSerializeForExport();
String serializedXml = prismContext.xmlSerializer().options(opt2).serialize(object);
String serializedRaw = prismContext.xmlSerializer().options(opt2).serialize(raw);
String serializedJson = prismContext.jsonSerializer().serialize(object);
// WHEN
when();
repositoryService.deleteObject(ShadowType.class, object.getOid(), result);
PrismObject<ShadowType> deserializedDb = prismContext.parseObject(serializedRaw);
repositoryService.addObject(deserializedDb, null, result);
// THEN
then();
verifyHasId(provisioning.getAnyValue());
verifyHasId(object.getAnyValue());
}
Aggregations