@Override protected PrismSerializer<String> getSerializer() { return prismContext.xmlSerializer(); }
public static String toObjectTreeDeltasTypeXml(ObjectTreeDeltasType objectTreeDeltasType, PrismContext prismContext) throws SchemaException { if (objectTreeDeltasType != null) { return prismContext.xmlSerializer().serializeRealValue(objectTreeDeltasType, SchemaConstantsGenerated.C_OBJECT_TREE_DELTAS); } else { return null; } }
public String toObjectTreeDeltasTypeXml() throws SchemaException { ObjectTreeDeltasType jaxb = toObjectTreeDeltasType(); return prismContext.xmlSerializer().serializeRealValue(jaxb, SchemaConstantsGenerated.C_OBJECT_TREE_DELTAS); }
public static String serializeAtomicValue(Object object, QName elementName) throws SchemaException { return getPrismContext().xmlSerializer().serializeRealValue(object, elementName); }
public static String serializeAnyData(Object o, QName defaultRootElementName) throws SchemaException { return getPrismContext().xmlSerializer().serializeAnyData(o, defaultRootElementName); }
@Override protected void init() { serializer = context.getPrismContext() .xmlSerializer() .options(SerializationOptions.createSerializeForExport()); }
public static void displaySearchFilterType(SearchFilterType filterType) throws SchemaException { MapXNode mapXNode = filterType.getFilterClauseXNode(); String dumpX = mapXNode.debugDump(); LOGGER.info(dumpX); System.out.println("filter clause xnode:\n" + dumpX + "\n"); String dumpXml = prismContext.xmlSerializer().serialize( prismContext.xnodeFactory().root(new QName("filterClauseXNode"), mapXNode)); System.out.println("filter clause xnode serialized:\n" + dumpXml + "\n"); }
@Test public void testSerializeMessage() throws Exception { System.out.println("===[ testSerializeMessage ]==="); PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage); QName fakeQName = new QName(PrismConstants.NS_TYPES, "object"); String xml = prismContext.xmlSerializer().serializeAnyData(localizableMessageBean, fakeQName); System.out.println(xml); }
public static String serializeContainerableToXml(Containerable containerable, PrismContext prismContext) { try { PrismContainerValue value = containerable.asPrismContainerValue(); return prismContext.xmlSerializer().serialize(value, value.getContainer().getElementName()); } catch (SchemaException e) { throw new SystemException("Couldn't serialize a Containerable " + containerable + " into XML", e); } }
private String toXml(QueryType q1jaxb) throws SchemaException { return getPrismContext().xmlSerializer().serializeRealValue(q1jaxb, SchemaConstantsGenerated.Q_QUERY); }
public static String toObjectDeltaTypeXml(ObjectDelta<? extends ObjectType> delta, DeltaConversionOptions options) throws SchemaException, JAXBException { Validate.notNull(delta.getPrismContext(), "ObjectDelta without prismContext cannot be converted to XML"); ObjectDeltaType objectDeltaType = toObjectDeltaType(delta, options); SerializationOptions serializationOptions = new SerializationOptions(); serializationOptions.setSerializeReferenceNames(DeltaConversionOptions.isSerializeReferenceNames(options)); return delta.getPrismContext().xmlSerializer().options(serializationOptions).serializeRealValue(objectDeltaType, SchemaConstants.T_OBJECT_DELTA); }
@Test public void test350SerializeToXml() throws Exception { System.out.println("===[ test350SerializeToXml ]==="); PrismObject<UserType> jack = getJack(); measure("serialize to XML", () -> getPrismContext().xmlSerializer().serialize(jack)); }
@Test public void testSerializeExecuteCredentialResetResponseType() throws Exception { System.out.println("===[ testSerializeExecuteCredentialResetResponseType ]==="); PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage); ExecuteCredentialResetResponseType response = new ExecuteCredentialResetResponseType(); response.setMessage(localizableMessageBean); QName fakeQName = new QName(PrismConstants.NS_TYPES, "object"); prismContext.adopt(response); String xml = prismContext.xmlSerializer().serializeAnyData(response, fakeQName); System.out.println(xml); }
@Test public void testParseToXNode() throws Exception { PrismContext prismContext = PrismTestUtil.getPrismContext(); RootXNode node = prismContext.parserFor(getFile()).parseToXNode(); System.out.println("Parsed to XNode:"); System.out.println(node.debugDump()); System.out.println("XML -> XNode -> XML:\n" + prismContext.xmlSerializer().serialize(node)); System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node)); System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node)); }
@Test public void testParseToXNode() throws Exception { PrismContext prismContext = PrismTestUtil.getPrismContext(); RootXNode node = prismContext.parserFor(getFile()).parseToXNode(); System.out.println("Parsed to XNode:"); System.out.println(node.debugDump()); System.out.println("XML -> XNode -> XML:\n" + prismContext.xmlSerializer().serialize(node)); System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node)); System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node)); }
@Test public void testNamespaces() throws Exception { String file = MiscUtil.readFile(getFile()); RootXNode xnode = getPrismContext().parserFor(file).parseToXNode(); System.out.println("XNode:\n" + xnode.debugDump()); String serialized = getPrismContext().xmlSerializer().serialize(xnode); System.out.println("XML: " + serialized); final String common_3 = "http://midpoint.evolveum.com/xml/ns/public/common/common-3"; int count = StringUtils.countMatches(serialized, common_3); assertEquals("Wrong # of occurrences of '" + common_3 + "' in serialized form", 2, count); }
@Test public void testParseToXNode() throws Exception { displayTestTitle("testParseToXNode"); System.out.println("\n\n-----------------------------------\n"); String file = MiscUtil.readFile(getFile()); System.out.println("Original text:\n" + file); RootXNode xnode = getPrismContext().parserFor(file).parseToXNode(); System.out.println("XNode:\n" + xnode.debugDump()); System.out.println("source -> XNode -> JSON:\n" + getPrismContext().jsonSerializer().serialize(xnode)); System.out.println("source -> XNode -> YAML:\n" + getPrismContext().yamlSerializer().serialize(xnode)); System.out.println("source -> XNode -> XML:\n" + getPrismContext().xmlSerializer().serialize(xnode)); }
@Test public void test310ParseXml() throws Exception { System.out.println("===[ test310ParseXml ]==="); PrismObject<UserType> jack = getJack(); String string = getPrismContext().xmlSerializer().serialize(jack); measure("parse XML (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).xml().parse()); measure("parse XML to XNode (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).xml().parseToXNode()); }
@Test public void testEmptyItemsOnParse() throws Exception { System.out.println("===[ testEmptyItemsOnParse ]==="); // GIVEN UserType user = new UserType(getPrismContext()); user.setName(PolyStringType.fromOrig("jack")); System.out.println("User before:\n" + user.asPrismObject().debugDump()); assertEquals("Wrong # of user sub-items before serialization/reparsing", 1, CollectionUtils.emptyIfNull(user.asPrismContainerValue().getItems()).size()); // WHEN String xml = getPrismContext().xmlSerializer().serialize(user.asPrismObject()); user = (UserType) getPrismContext().parserFor(xml).parse().asObjectable(); // THEN System.out.println("User after:\n" + user.asPrismObject().debugDump()); assertEquals("Wrong # of user sub-items after serialization/reparsing", 1, CollectionUtils.emptyIfNull(user.asPrismContainerValue().getItems()).size()); }
private void dumpOutput(ExecutionContext output, OperationResult result) throws JAXBException, SchemaException { display("output", output.getFinalOutput()); display("stdout", output.getConsoleOutput()); display(result); if (output.getFinalOutput() != null) { PipelineDataType bean = ModelWebService.prepareXmlData(output.getFinalOutput().getData(), null); display("output in XML", prismContext.xmlSerializer().root(new QName("output")).serializeRealValue(bean)); } }