Package org.apache.synapse.util

Examples of org.apache.synapse.util.SynapseBinaryDataSource


            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());

            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);

        } catch (IOException e) {
            handleException("Error when getting a stream from resource's content", e);
        }
View Full Code Here


            PushbackInputStream pis = detectAndMarkMessageFault(messageContext, inputStream);

            DataHandler dataHandler;
            if (synEnv != null && synEnv.getValue() != null) {
                dataHandler = new DataHandler(new SynapseBinaryDataSource(pis, contentType,
                        (SynapseEnvironment) synEnv.getValue()));
            } else {
                // add Hessian data inside a data handler
                dataHandler = new DataHandler(new SynapseBinaryDataSource(pis, contentType));
            }
            OMText textData = factory.createOMText(dataHandler, true);
            element.addChild(textData);
           
            // indicate that message faults shall be handled as http 200
View Full Code Here

     * @throws AxisFault if an error occurs writing to the output stream
     */
    private void writeHessianMessage(MessageContext msgCtxt, OutputStream out) throws AxisFault {
        OMElement omElement = msgCtxt.getEnvelope().getBody().getFirstElement();
        SynapseBinaryDataSource synapseBinaryDataSource = extractSynapseBinaryDataSource(omElement);

        if (synapseBinaryDataSource != null) {

            InputStream inputStream = null;
            try {
                inputStream = synapseBinaryDataSource.getInputStream();
                IOUtils.copy(inputStream, out);
            } catch (IOException e) {
                handleException("Couldn't get the bytes from the HessianDataSource", e);
            } finally {
                if (inputStream != null) {
View Full Code Here

     * @return the binary data source containing the Hessian message or null, if the OMElement
     *         does not contain a binary datasource.
     */
    private SynapseBinaryDataSource extractSynapseBinaryDataSource(OMElement omElement) {
       
        SynapseBinaryDataSource synapseBinaryDataSource = null;
        Iterator it = omElement.getChildren();

        while (it.hasNext() && synapseBinaryDataSource == null) {

            OMNode hessianElement = (OMNode) it.next();
View Full Code Here

            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());

            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);

        } catch (IOException e) {
            handleException("Error when getting a stream from resource's content", e);
        }
View Full Code Here

        HessianTestHelper hessianTestHelper = new HessianTestHelper();
        MessageContext msgContext = hessianTestHelper.createAxis2MessageContext(synEnv);
        OMElement element = hessianTestHelper.buildHessianTestMessage(testMessageName, msgContext);
        OMNode hessianNode = element.getFirstOMChild();
        OMText hessianTextNode = (OMText) hessianNode;
        SynapseBinaryDataSource synapseBinaryDataSource = (SynapseBinaryDataSource)
            ((DataHandler) hessianTextNode.getDataHandler()).getDataSource();
        InputStream inputStream = synapseBinaryDataSource.getInputStream();
        byte[] originalByteArray = IOUtils.toByteArray(getClass().getResourceAsStream(
                testMessageName));
        byte[] builderByteArray = IOUtils.toByteArray(inputStream);
        assertTrue(Arrays.equals(originalByteArray, builderByteArray));
View Full Code Here

            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());

            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);

        } catch (IOException e) {
            handleException("Error when getting a stream from resource's content", e);
        }
View Full Code Here

            ByteArrayInputStream inputStream = new ByteArrayInputStream(
                    (byte[]) resource.getContent());
            try {
                OMFactory omFactory = OMAbstractFactory.getOMFactory();
                return omFactory.createOMText(
                        new DataHandler(new SynapseBinaryDataSource(inputStream,
                                resource.getMediaType())), true);
            } catch (IOException e) {
                handleException("Error while getting a stream from resource content ", e);
            } finally {
                try {
View Full Code Here

            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());

            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);

        } catch (IOException e) {
            throw  new CSGException("Error when getting a stream from resource's content", e);
        }
View Full Code Here

            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());

            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);

        } catch (IOException e) {
            handleException("Error when getting a stream from resource's content", e);
        }
View Full Code Here

TOP

Related Classes of org.apache.synapse.util.SynapseBinaryDataSource

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.