Examples of OMMultipartWriter


Examples of org.apache.axiom.om.impl.OMMultipartWriter

        else {
            envelope.serializeAndConsume(writer, format);
        }

      try {
        OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format);

        Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(),
            format.getCharSetEncoding());
        rootPartWriter.write(writer.toString());
        rootPartWriter.close();

        // Get the collection of ids associated with the attachments
        for (String id: attachments.getAllContentIDs()) {
          mpw.writePart(attachments.getDataHandler(id), id);
        }

        mpw.complete();
      }
      catch (IOException ex) {
        throw new OMException("Error writing SwA message", ex);
      }
    }
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

                try {
                    busObject = (DataSource)((DataSourceBlock)((OMSourcedElement) omElement).getDataSource()).getBusinessObject(true);
                } catch (XMLStreamException e) {
                    throw AxisFault.makeFault(e);
                }
                OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format);
                DataHandler rootDataHandler = new DataHandler(busObject);
                if (!rootDataHandler.getContentType().equals(contentType)) {
                    rootDataHandler = new WrappedDataHandler(rootDataHandler, contentType);
                }
                try {
                    mpw.writePart(rootDataHandler, format.getRootContentId());
                    for (String cid : attachments.keySet()) {
                        mpw.writePart(attachments.get(cid), cid);
                    }
                    mpw.complete();
                    outputStream.flush();
                } catch (IOException ex) {
                    throw AxisFault.makeFault(ex);
                }
            } else {
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

                format.setSOAP11(((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMFactory() instanceof SOAP11Factory);
               
                //Double save the content-type in case anything is updated
                mimeHeaders.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType.toString());

                OMMultipartWriter mpw = new OMMultipartWriter(out, format);
                OutputStream rootPartOutputStream = mpw.writeRootPart();
                envelope.serialize(rootPartOutputStream);
                rootPartOutputStream.close();
                for (AttachmentPart ap : attachmentParts) {
                    mpw.writePart(ap.getDataHandler(), ap.getContentId());
                }
                mpw.complete();
            }

            saveRequired = true;
        } catch (Exception e) {
            throw new SOAPException(e);
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

        if (property != null) {
            MM7CompatMode = JavaUtils.isTrueExplicitly(property);
        }
       
        try {
            OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format);
           
            OutputStream rootPartOutputStream = mpw.writeRootPart();
            OMElement element = msgCtxt.getEnvelope();
            if (preserve) {
                element.serialize(rootPartOutputStream, format);
            } else {
                element.serializeAndConsume(rootPartOutputStream, format);
            }
            rootPartOutputStream.close();
           
            OMMultipartWriter attachmentsWriter;
            OutputStream innerOutputStream;
            if (!MM7CompatMode) {
                attachmentsWriter = mpw;
                innerOutputStream = null;
            } else {
                String innerBoundary;
                String partCID;
                Object innerBoundaryProperty = msgCtxt
                        .getProperty(Constants.Configuration.MM7_INNER_BOUNDARY);
                if (innerBoundaryProperty != null) {
                    innerBoundary = (String) innerBoundaryProperty;
                } else {
                    innerBoundary = "innerBoundary"
                            + UIDGenerator.generateMimeBoundary();
                }
                Object partCIDProperty = msgCtxt
                        .getProperty(Constants.Configuration.MM7_PART_CID);
                if (partCIDProperty != null) {
                    partCID = (String) partCIDProperty;
                } else {
                    partCID = "innerCID"
                            + UIDGenerator.generateContentId();
                }
                OMOutputFormat innerFormat = new OMOutputFormat(format);
                innerFormat.setMimeBoundary(innerBoundary);
                innerOutputStream = mpw.writePart("multipart/related; boundary=\"" + innerBoundary + "\"", partCID);
                attachmentsWriter = new OMMultipartWriter(innerOutputStream, innerFormat);
            }
           
            Attachments attachments = msgCtxt.getAttachmentMap();
            for (String contentID : attachments.getAllContentIDs()) {
                attachmentsWriter.writePart(attachments.getDataHandler(contentID), contentID);
            }
           
            if (MM7CompatMode) {
                attachmentsWriter.complete();
                innerOutputStream.close();
            }
           
            mpw.complete();
        } catch (IOException ex) {
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

            if (attachmentParts.isEmpty()) {
                envelope.serialize(out, format);
            } else {
                format.setSOAP11(((SOAPEnvelopeImpl)soapPart.getEnvelope()).getOMFactory()
                        instanceof SOAP11Factory);
                OMMultipartWriter mpw = new OMMultipartWriter(out, format);
                OutputStream rootPartOutputStream = mpw.writeRootPart();
                envelope.serialize(rootPartOutputStream);
                rootPartOutputStream.close();
                for (AttachmentPart ap : attachmentParts) {
                    mpw.writePart(ap.getDataHandler(), ap.getContentId());
                }
                mpw.complete();
            }
            saveChanges();
        } catch (Exception e) {
            throw new SOAPException(e);
        }
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

                format.setSOAP11(((SOAPFactory)((SOAPEnvelopeImpl) soapPart.getEnvelope()).omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton());
               
                //Double save the content-type in case anything is updated
                mimeHeaders.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType.toString());

                OMMultipartWriter mpw = new OMMultipartWriter(out, format);
                OutputStream rootPartOutputStream = mpw.writeRootPart();
                envelope.serialize(rootPartOutputStream);
                rootPartOutputStream.close();
                for (AttachmentPart ap : attachmentParts) {
                    mpw.writePart(ap.getDataHandler(), ap.getContentId());
                }
                mpw.complete();
            }

            saveRequired = true;
        } catch (Exception e) {
            throw new SOAPException(e);
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

                format.setSOAP11(((SOAPFactory)((SOAPEnvelopeImpl) soapPart.getEnvelope()).omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton());
               
                //Double save the content-type in case anything is updated
                mimeHeaders.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType.toString());

                OMMultipartWriter mpw = new OMMultipartWriter(out, format);
                OutputStream rootPartOutputStream = mpw.writeRootPart();
                envelope.serialize(rootPartOutputStream);
                rootPartOutputStream.close();
                for (AttachmentPart ap : attachmentParts) {
                    mpw.writePart(ap.getDataHandler(), ap.getContentId());
                }
                mpw.complete();
            }

            saveRequired = true;
        } catch (Exception e) {
            throw new SOAPException(e);
View Full Code Here

Examples of org.apache.axiom.om.impl.OMMultipartWriter

    private void createMultipatFormDataRequest(OMElement dataOut, ByteArrayOutputStream bytesOut,
            OMOutputFormat format) throws IOException {
        if (dataOut != null) {
            Iterator iter1 = dataOut.getChildElements();
            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            OMMultipartWriter writer = new OMMultipartWriter(bytesOut, format);
            while (iter1.hasNext()) {              
                OMElement ele = (OMElement) iter1.next();
                Iterator iter2 = ele.getChildElements();
                // check whether the element is a complex type
                if (iter2.hasNext()) {
                    OMElement omElement =
                            omFactory.createOMElement(ele.getQName().getLocalPart(), null);
                    omElement.addChild(
                            processComplexType(omElement, ele.getChildElements(), omFactory));                  
                    OutputStream partOutputStream = writer.writePart(DEFAULT_CONTENT_TYPE, null,
                            Collections.singletonList(new Header("Content-Disposition",
                                    DISPOSITION_TYPE + "; name=\"" + omElement.getLocalName() + "\"")));
                    partOutputStream.write(omElement.toString().getBytes());
                    partOutputStream.close();
                } else {
                    OutputStream partOutputStream = writer.writePart(DEFAULT_CONTENT_TYPE, null,
                            Collections.singletonList(new Header("Content-Disposition",
                                    DISPOSITION_TYPE + "; name=\"" + ele.getLocalName() + "\"")));
                    partOutputStream.write(ele.getText().getBytes());
                    partOutputStream.close();
                }
            }
            writer.complete();           
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.