use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class PrismSerializerImpl method serializeAnyData.
@Override
public T serializeAnyData(Object value) throws SchemaException {
RootXNode xnode = getMarshaller().marshalAnyData(value, itemName, itemDefinition, context);
// TODO find better way
checkPostconditions(xnode);
return target.write(xnode, context);
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class AbstractLexicalProcessorTest method testParseUserToPrism.
@Test
public void testParseUserToPrism() throws Exception {
final String TEST_NAME = "testParseUserToPrism";
displayTestTitle(TEST_NAME);
// GIVEN
LexicalProcessor lexicalProcessor = createParser();
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN (parse to xnode)
RootXNode xnode = lexicalProcessor.read(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());
// WHEN (parse to prism)
PrismObject<UserType> user = prismContext.parserFor(xnode).parse();
// THEN
System.out.println("Parsed user:");
System.out.println(user.debugDump());
assertUserJackXNodeOrdering("serialized xnode", xnode);
assertUserJack(user, true);
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class LexicalUtils method createRootXNode.
@NotNull
public static RootXNode createRootXNode(XNode xnode, QName rootElementName) {
if (xnode instanceof RootXNode) {
return (RootXNode) xnode;
} else {
RootXNode xroot = new RootXNode(rootElementName);
xroot.setSubnode(xnode);
return xroot;
}
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class StaticExpressionUtil method serializeValueElements.
public static <IV extends PrismValue, ID extends ItemDefinition> List<JAXBElement<RawType>> serializeValueElements(Item<IV, ID> item, String contextDescription) throws SchemaException {
if (item == null) {
return null;
}
List<JAXBElement<RawType>> elements = new ArrayList<>(item.size());
for (PrismValue value : item.getValues()) {
RootXNode xnode = item.getPrismContext().xnodeSerializer().serialize(value);
RawType rawType = new RawType(xnode.getSubnode(), item.getPrismContext());
JAXBElement<RawType> jaxbElement = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, rawType);
elements.add(jaxbElement);
}
return elements;
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class ExpressionUtil method parseSearchFilter.
// TODO move somewhere else? generalize a bit?
public static RootXNode parseSearchFilter(String data, PrismContext context) throws SchemaException {
String xml = WebXmlUtil.wrapInElement("root", data, false);
RootXNode rootXNode = context.parserFor(xml).xml().parseToXNode();
if (rootXNode.getSubnode() instanceof MapXNode) {
MapXNode mapXNode = (MapXNode) rootXNode.getSubnode();
if (mapXNode.size() != 1) {
throw new SchemaException("Content cannot be parsed as a search filter: " + mapXNode.debugDump());
}
return mapXNode.getEntryAsRoot(mapXNode.keySet().iterator().next());
} else {
throw new SchemaException("Content cannot be parsed as a search filter: " + DebugUtil.debugDump(rootXNode.getSubnode()));
}
}
Aggregations