- Node<?> node = XmlTreeBuilder.buildDataTree(entityStream);
- if (node instanceof SimpleNode) {
- logger.info("Node is SimpleNode");
- throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
- .entity("XML should start with XML element that contains 1..N XML child elements.").build());
- }
- return (CompositeNode) node;
- } catch (XMLStreamException e) {
- logger.info("Error during translation of InputStream to Node\n" + e.getMessage());
- throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
- .entity(e.getMessage()).build());
+ return xmlReader.read(entityStream);
+ } catch (XMLStreamException | UnsupportedFormatException e) {
+ LOG.debug( "Error parsing json input", e );
+ throw new RestconfDocumentedException(
+ "Error parsing input: " + e.getMessage(),
+ ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE );