use of org.apache.axiom.core.stream.FilteredXmlInput in project webservices-axiom by apache.
the class BuilderSpec method from.
static BuilderSpec from(StAXParserConfiguration configuration, Source source) {
if (source instanceof SAXSource) {
return from((SAXSource) source, true);
} else if (source instanceof DOMSource) {
return from(((DOMSource) source).getNode(), true);
} else if (source instanceof StreamSource) {
StreamSource streamSource = (StreamSource) source;
InputSource is = new InputSource();
is.setByteStream(streamSource.getInputStream());
is.setCharacterStream(streamSource.getReader());
is.setPublicId(streamSource.getPublicId());
is.setSystemId(streamSource.getSystemId());
return from(configuration, is);
} else if (source instanceof StAXSource) {
return from(((StAXSource) source).getXMLStreamReader());
} else {
try {
return new BuilderSpec(new FilteredXmlInput(new StAXPullInput(StAXUtils.getXMLInputFactory().createXMLStreamReader(source), true, null), NamespaceRepairingFilter.DEFAULT), null);
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
}
}
use of org.apache.axiom.core.stream.FilteredXmlInput in project webservices-axiom by apache.
the class BuilderSpec method from.
static BuilderSpec from(StAXParserConfiguration configuration, final MultipartBody message) {
Part rootPart = message.getRootPart();
InputSource is = new InputSource(rootPart.getInputStream(false));
is.setEncoding(rootPart.getContentType().getParameter("charset"));
BuilderSpec spec = create(configuration, is, false);
return new BuilderSpec(new FilteredXmlInput(spec.getInput(), new XOPDecodingFilter(new OMAttachmentAccessor() {
@Override
public DataHandler getDataHandler(String contentID) {
Part part = message.getPart(contentID);
return part == null ? null : part.getDataHandler();
}
})), new Detachable() {
@Override
public void detach() {
message.detach();
}
});
}
Aggregations