Search in sources :

Example 1 with OMAttachmentAccessor

use of org.apache.axiom.om.OMAttachmentAccessor 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();
        }
    });
}
Also used : OMAttachmentAccessor(org.apache.axiom.om.OMAttachmentAccessor) Detachable(org.apache.axiom.om.impl.common.builder.Detachable) InputSource(org.xml.sax.InputSource) Part(org.apache.axiom.mime.Part) DataHandler(javax.activation.DataHandler) FilteredXmlInput(org.apache.axiom.core.stream.FilteredXmlInput) XOPDecodingFilter(org.apache.axiom.om.impl.stream.xop.XOPDecodingFilter)

Aggregations

DataHandler (javax.activation.DataHandler)1 FilteredXmlInput (org.apache.axiom.core.stream.FilteredXmlInput)1 Part (org.apache.axiom.mime.Part)1 OMAttachmentAccessor (org.apache.axiom.om.OMAttachmentAccessor)1 Detachable (org.apache.axiom.om.impl.common.builder.Detachable)1 XOPDecodingFilter (org.apache.axiom.om.impl.stream.xop.XOPDecodingFilter)1 InputSource (org.xml.sax.InputSource)1