Package org.apache.axis2.attachments

Examples of org.apache.axis2.attachments.MIMEHelper


            parameter = msgContext
                    .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
            attachmentSizeThreshold = parameter==null?"":parameter.getValue().toString();
        }

        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
                fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);

        String charSetEncoding = getCharSetEncoding(mimeHelper.getSOAPPartContentType());
        XMLStreamReader reader;
        if(charSetEncoding == null || "null".equalsIgnoreCase(charSetEncoding)){
             reader = XMLInputFactory.newInstance()
                .createXMLStreamReader(
                        new BufferedReader(new InputStreamReader(mimeHelper
                                .getSOAPPartInputStream(),
                                charSetEncoding)));
            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, charSetEncoding);

        }else {
            reader = XMLInputFactory.newInstance()
                .createXMLStreamReader(
                        new BufferedReader(new InputStreamReader(mimeHelper
                                .getSOAPPartInputStream())));
            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, MessageContext.UTF_8);

        }


        /*
     * put a reference to Attachments in to the message context
     */
        msgContext.setProperty(MTOMConstants.ATTACHMENTS, mimeHelper);
        if (mimeHelper.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
            /*
             * Creates the MTOM specific MTOMStAXSOAPModelBuilder
             */
            builder =
                new MTOMStAXSOAPModelBuilder(
                    reader,
                    mimeHelper,
                    null);
        } else if (
            mimeHelper.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
            builder =
                new StAXSOAPModelBuilder(
                    reader,
                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        }
View Full Code Here


    protected void setUp() throws Exception {
        super.setUp();
        inFileName = "mtom/MTOMBuilderTestIn.txt";
        InputStream inStream = new FileInputStream(getTestResourceFile(inFileName));
        mimeHelper = new MIMEHelper(inStream, contentTypeString);
        XMLStreamReader reader = XMLInputFactory.newInstance()
                .createXMLStreamReader(new BufferedReader(new InputStreamReader(mimeHelper
                .getSOAPPartInputStream())));
        builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    }
View Full Code Here

    public OMElement echoAttachment(OMElement omEle) {
        OMElement child  = (OMElement)omEle.getFirstOMChild();
        OMAttribute attr = child.getFirstAttribute(new QName("href"));
        String contentID = attr.getAttributeValue();
        MIMEHelper attachment = (MIMEHelper)msgcts.getProperty(MTOMConstants.ATTACHMENTS);
        contentID = contentID.trim();

        if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
            contentID = contentID.substring(4);
        }
        DataHandler dataHandler = attachment.getDataHandler(contentID);
        OMText textNode = new OMTextImpl(dataHandler);
        omEle.build();
        child.detach();
        omEle.addChild(textNode);
        return omEle;
View Full Code Here

    if (fileCacheForAttachments)
    {
      attachmentRepoDir = (String)msgContext.getProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR);
    }
     
    MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,fileCacheForAttachments,attachmentRepoDir);
    XMLStreamReader reader = XMLInputFactory.newInstance()
        .createXMLStreamReader(
            new BufferedReader(new InputStreamReader(mimeHelper
                .getSOAPPartInputStream())));
    /*
     * put a reference to Attachments in to the message context
     */
    msgContext.setProperty("Attachments", mimeHelper);
    if (mimeHelper.getAttachmentSpecType().equals(MIMEHelper.MTOM_TYPE)) {
      /*
       * Creates the MTOM specific MTOMStAXSOAPModelBuilder
       */
      builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper);
    } else if (mimeHelper.getAttachmentSpecType().equals(
        MIMEHelper.SWA_TYPE)) {
      builder = new StAXSOAPModelBuilder(reader);
    }
    return builder;
  }
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();
    inFileName = "mtom/MTOMBuilderTestIn.txt";
    InputStream inStream = new FileInputStream(
        getTestResourceFile(inFileName));
    mimeHelper = new MIMEHelper(inStream, contentTypeString);
    XMLStreamReader reader = XMLInputFactory.newInstance()
    .createXMLStreamReader(
        new BufferedReader(new InputStreamReader(mimeHelper
            .getSOAPPartInputStream())));
    builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper);
View Full Code Here

    public OMElement echoAttachment(OMElement omEle) {
        OMElement child  = (OMElement)omEle.getFirstChild();
        OMAttribute attr = child.getFirstAttribute(new QName("href"));
        String contentID = attr.getValue();
        MIMEHelper attachment = (MIMEHelper)msgcts.getProperty(MTOMConstants.ATTACHMENTS);
        contentID = contentID.trim();

        if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
            contentID = contentID.substring(4);
        }
        DataHandler dataHandler = attachment.getDataHandler(contentID);
        OMText textNode = new OMTextImpl(dataHandler);
        omEle.build();
        child.detach();
        omEle.addChild(textNode);
        return omEle;
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        inFileName = "mtom/MTOMBuilderTestIn.txt";
        InputStream inStream = new FileInputStream(getTestResourceFile(inFileName));
        mimeHelper = new MIMEHelper(inStream, contentTypeString);
        XMLStreamReader reader = XMLInputFactory.newInstance()
                .createXMLStreamReader(new BufferedReader(new InputStreamReader(mimeHelper
                .getSOAPPartInputStream())));
        builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    }
View Full Code Here

//            }
            attachmentSizeThreshold = (String) msgContext
            .getProperty(Constants.Configuration.FILE_SIZE_THRESHOLD);
        }

        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
                fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);

        XMLStreamReader reader = XMLInputFactory.newInstance()
                .createXMLStreamReader(
                        new BufferedReader(new InputStreamReader(mimeHelper
                                .getSOAPPartInputStream(),
                                getCharSetEncoding(mimeHelper
                                        .getSOAPPartContentType()))));

        /*
     * put a reference to Attachments in to the message context
     */
        msgContext.setProperty(MTOMConstants.ATTACHMENTS, mimeHelper);
        if (mimeHelper.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
            /*
             * Creates the MTOM specific MTOMStAXSOAPModelBuilder
             */
            builder =
                new MTOMStAXSOAPModelBuilder(
                    reader,
                    mimeHelper,
                    null);
        } else if (
            mimeHelper.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
            builder =
                new StAXSOAPModelBuilder(
                    reader,
                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        }
View Full Code Here

                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                        new VFSOutTransportInfo(replyFileURI, entry.isFileLockingEnabled()));
            }

            // Determine the message builder to use
            Builder builder;
            if (contentType == null) {
                log.debug("No content type specified. Using SOAP builder.");
                builder = new SOAPBuilder();
            } else {
                int index = contentType.indexOf(';');
                String type = index > 0 ? contentType.substring(0, index) : contentType;
                builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
                if (builder == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("No message builder found for type '" + type +
                                "'. Falling back to SOAP.");
                    }
                    builder = new SOAPBuilder();
                }
            }

            // set the message payload to the message context
            InputStream in;
            ManagedDataSource dataSource;
            if (builder instanceof DataSourceMessageBuilder && entry.isStreaming()) {
                in = null;
                dataSource = ManagedDataSourceFactory.create(
                        new FileObjectDataSource(file, contentType));
            } else {
                in = content.getInputStream();
                dataSource = null;
            }
           
            try {
                OMElement documentElement;
                if (in != null) {
                    documentElement = builder.processDocument(in, contentType, msgContext);
                } else {
                    documentElement = ((DataSourceMessageBuilder)builder).processDocument(
                            dataSource, contentType, msgContext);
                }
                msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
View Full Code Here

                    eprFound = true;
                    String type = TransportUtils.getContentType(contentTypeStr, msgContext);
                    msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type);
                    epr.setParameters(msgContext);

                    Builder builder = epr.getBuilder(type);
                    if (HTTPTransportUtils.isRESTRequest(contentTypeStr)) {
                        RESTUtil.processPOSTRequest(msgContext, is, os,
                                request.getRequestLine().getUri(), contentType, builder, isRestDispatching);
                    } else {
View Full Code Here

TOP

Related Classes of org.apache.axis2.attachments.MIMEHelper

Copyright © 2018 www.massapicom. 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.