Package org.apache.cxf.io

Examples of org.apache.cxf.io.CachedWriter


    public static Reader transform(Templates xsltTemplate, Reader inReader) {
        try {
            XMLStreamReader reader = StaxUtils.createXMLStreamReader(inReader);
            Source beforeSource = new StaxSource(reader);
            CachedWriter outWriter = new CachedWriter();

            Transformer trans = xsltTemplate.newTransformer();
            trans.transform(beforeSource, new StreamResult(outWriter));

            return outWriter.getReader();
        } catch (IOException e) {
            throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
        } catch (TransformerException e) {
            throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
        }
View Full Code Here


        log(logger, formatLoggingMessage(buffer));
    }

    protected void logReader(Message message, Reader reader, LoggingMessage buffer) {
        try {
            CachedWriter writer = new CachedWriter();
            IOUtils.copyAndCloseInput(reader, writer);
            message.setContent(Reader.class, writer.getReader());
           
            if (writer.getTempFile() != null) {
                //large thing on disk...
                buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
            }
            if (writer.size() > limit) {
                buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
            }
            writer.writeCacheTo(buffer.getPayload(), limit);
        } catch (Exception e) {
            throw new Fault(e);
        }
    }
View Full Code Here

        log(logger, formatLoggingMessage(buffer));
    }

    protected void logReader(Message message, Reader reader, LoggingMessage buffer) {
        try {
            CachedWriter writer = new CachedWriter();
            IOUtils.copyAndCloseInput(reader, writer);
            message.setContent(Reader.class, writer.getReader());
           
            if (writer.getTempFile() != null) {
                //large thing on disk...
                buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
            }
            if (writer.size() > limit) {
                buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
            }
            writer.writeCacheTo(buffer.getPayload(), limit);
        } catch (Exception e) {
            throw new Fault(e);
        }
    }
View Full Code Here

        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException {
        CachedWriter cWriter = new CachedWriter();
        cWriter.holdTempFile();
        XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter);
        message.setContent(XMLStreamWriter.class, xWriter);
        outInterceptor.handleMessage(message);
        XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class);
        StaxUtils.copy(new StreamSource(messageIS), tXWriter);
        tXWriter.close();
        cWriter.releaseTempFileHold();
        Document doc = DOMUtils.readXml(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here

        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outWriterStreamTest() throws IOException, SAXException, ParserConfigurationException {
        CachedWriter cWriter = new CachedWriter();
        message.setContent(Writer.class, cWriter);
        outInterceptor.handleMessage(message);
        Writer tWriter = message.getContent(Writer.class);
        IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE);
        tWriter.close();
        Document doc = DOMUtils.readXml(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here

        log(logger, formatLoggingMessage(buffer));
    }

    protected void logReader(Message message, Reader reader, LoggingMessage buffer) {
        try {
            CachedWriter writer = new CachedWriter();
            IOUtils.copyAndCloseInput(reader, writer);
            message.setContent(Reader.class, writer.getReader());
           
            if (writer.getTempFile() != null) {
                //large thing on disk...
                buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
            }
            if (writer.size() > limit && limit != -1) {
                buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
            }
            writer.writeCacheTo(buffer.getPayload(), limit);
        } catch (Exception e) {
            throw new Fault(e);
        }
    }
View Full Code Here

        log(logger, formatLoggingMessage(buffer));
    }

    protected void logReader(Message message, Reader reader, LoggingMessage buffer) {
        try {
            CachedWriter writer = new CachedWriter();
            IOUtils.copyAndCloseInput(reader, writer);
            message.setContent(Reader.class, writer.getReader());
           
            if (writer.getTempFile() != null) {
                //large thing on disk...
                buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
            }
            if (writer.size() > limit && limit != -1) {
                buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
            }
            writer.writeCacheTo(buffer.getPayload(), limit);
        } catch (Exception e) {
            throw new Fault(e);
        }
    }
View Full Code Here

            }
        } else {
            Reader reader = message.getContent(Reader.class);
            if (reader != null) {
                try {
                    CachedWriter writer = new CachedWriter();
                    IOUtils.copyAndCloseInput(reader, writer);
                    message.setContent(Reader.class, writer.getReader());
                   
                    if (writer.getTempFile() != null) {
                        //large thing on disk...
                        buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                        buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
                    }
                    if (writer.size() > limit) {
                        buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                    }
                    writer.writeCacheTo(buffer.getPayload(), limit);
                } catch (Exception e) {
                    throw new Fault(e);
                }
            }
        }
View Full Code Here

            }
        } else {
            Reader reader = message.getContent(Reader.class);
            if (reader != null) {
                try {
                    CachedWriter writer = new CachedWriter();
                    IOUtils.copyAndCloseInput(reader, writer);
                    message.setContent(Reader.class, writer.getReader());
                   
                    if (writer.getTempFile() != null) {
                        //large thing on disk...
                        buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                        buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
                    }
                    if (writer.size() > limit) {
                        buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                    }
                    writer.writeCacheTo(buffer.getPayload(), limit);
                } catch (Exception e) {
                    throw new Fault(e);
                }
            }
        }
View Full Code Here

        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException {
        CachedWriter cWriter = new CachedWriter();
        cWriter.holdTempFile();
        XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter);
        message.setContent(XMLStreamWriter.class, xWriter);
        outInterceptor.handleMessage(message);
        XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class);
        StaxUtils.copy(new StreamSource(messageIS), tXWriter);
        tXWriter.close();
        cWriter.releaseTempFileHold();
        Document doc = StaxUtils.read(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.io.CachedWriter

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.