Search in sources :

Example 1 with SerializationOptions

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);
    }
}
Also used : SerializationOptions(com.evolveum.midpoint.prism.SerializationOptions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with SerializationOptions

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SerializationOptions(com.evolveum.midpoint.prism.SerializationOptions) Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NotNull(org.jetbrains.annotations.NotNull) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

SerializationOptions (com.evolveum.midpoint.prism.SerializationOptions)2 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.testng.annotations.Test)1