@Test public void readsContentOfEntityStreamAsDOMSource() throws Exception { DOMSource domSource = domSourceEntityProvider.readFrom(DOMSource.class, null, null, APPLICATION_XML_TYPE, new MultivaluedMapImpl(), new ByteArrayInputStream(TEST_XML_CONTENT_BYTES)); Node document = domSource.getNode(); assertThatXmlDocumentContainsAllExpectedNodes(document); }
@Override public DOMSource readFrom(Class<DOMSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { DocumentBuilderFactory factory = createFeaturedDocumentBuilderFactory(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().parse(entityStream); return new DOMSource(d); } catch (SAXParseException saxpe) { LOG.debug(saxpe.getMessage(), saxpe); return null; } catch (SAXException | ParserConfigurationException saxe) { throw new IOException(String.format("Can't read from input stream, %s", saxe)); } }
DOMSourceEntityProvider implements EntityProvider<DOMSource> { @Override public DOMSource readFrom(Class<DOMSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { DocumentBuilderFactory factory = createFeaturedDocumentBuilderFactory(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().parse(entityStream); return new DOMSource(d); } catch (SAXParseException saxpe) { LOG.debug(saxpe.getMessage(), saxpe); return null; } catch (SAXException | ParserConfigurationException saxe) { throw new IOException(String.format("Can't read from input stream, %s", saxe)); } } }
DOMSourceEntityProvider implements EntityProvider<DOMSource> { @Override public DOMSource readFrom(Class<DOMSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { DocumentBuilderFactory factory = createFeaturedDocumentBuilderFactory(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().parse(entityStream); return new DOMSource(d); } catch (SAXParseException saxpe) { LOG.debug(saxpe.getMessage(), saxpe); return null; } catch (SAXException | ParserConfigurationException saxe) { throw new IOException(String.format("Can't read from input stream, %s", saxe)); } }  }
DOMSourceEntityProvider implements EntityProvider<DOMSource> { @Override public DOMSource readFrom(Class<DOMSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { DocumentBuilderFactory factory = createFeaturedDocumentBuilderFactory(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().parse(entityStream); return new DOMSource(d); } catch (SAXParseException saxpe) { LOG.debug(saxpe.getMessage(), saxpe); return null; } catch (SAXException | ParserConfigurationException saxe) { throw new IOException(String.format("Can't read from input stream, %s", saxe)); } }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override DOMSource readFrom(Class<DOMSource> type,
                              Type genericType,
                              Annotation[] annotations,
                              MediaType mediaType,
                              MultivaluedMap<String, String> httpHeaders,
                              InputStream entityStream); @Override long getSize(DOMSource t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(DOMSource domSource,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream); }
DOMSourceEntityProvider implements EntityProvider<DOMSource> { @Override public DOMSource readFrom(Class<DOMSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { DocumentBuilderFactory factory = createFeaturedDocumentBuilderFactory(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().parse(entityStream); return new DOMSource(d); } catch (SAXParseException saxpe) { LOG.debug(saxpe.getMessage(), saxpe); return null; } catch (SAXException | ParserConfigurationException saxe) { throw new IOException(String.format("Can't read from input stream, %s", saxe)); } }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override DOMSource readFrom(Class<DOMSource> type,
                              Type genericType,
                              Annotation[] annotations,
                              MediaType mediaType,
                              MultivaluedMap<String, String> httpHeaders,
                              InputStream entityStream); @Override long getSize(DOMSource t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(DOMSource domSource,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }