Search in sources :

Example 16 with CachedOutputStream

use of org.apache.cxf.io.CachedOutputStream in project carbon-business-process by wso2.

the class AttachmentDataHolder method printDebug.

public void printDebug() {
    boolean debugLogEnabled = log.isDebugEnabled();
    if (log.isDebugEnabled()) {
        log.debug("name:" + name);
        log.debug("description:" + description);
        log.debug("type:" + type);
        log.debug("contentType:" + type);
        log.debug("scope:" + scope);
        CachedOutputStream bos = new CachedOutputStream();
        try {
            String fileName = bos.getOut().toString();
            log.debug("fileName:" + fileName);
            bos.close();
        } catch (IOException e) {
            log.error("Exception occured during reading the file name", e);
        }
        log.debug("Stream String:" + new String(attachmentArray));
    }
}
Also used : IOException(java.io.IOException) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 17 with CachedOutputStream

use of org.apache.cxf.io.CachedOutputStream in project tomee by apache.

the class AttachmentDeserializer method cache.

private void cache(DelegatingInputStream input) throws IOException {
    if (loaded.contains(input)) {
        return;
    }
    loaded.add(input);
    InputStream origIn = input.getInputStream();
    try (CachedOutputStream out = new CachedOutputStream()) {
        AttachmentUtil.setStreamedAttachmentProperties(message, out);
        IOUtils.copy(input, out);
        input.setInputStream(out.getInputStream());
        origIn.close();
    }
}
Also used : PushbackInputStream(java.io.PushbackInputStream) InputStream(java.io.InputStream) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 18 with CachedOutputStream

use of org.apache.cxf.io.CachedOutputStream in project tomee by apache.

the class FormUtils method restoreForm.

public static void restoreForm(FormEncodingProvider<Form> provider, Form form, Message message) throws Exception {
    CachedOutputStream os = new CachedOutputStream();
    writeForm(provider, form, os);
    message.setContent(InputStream.class, os.getInputStream());
}
Also used : CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 19 with CachedOutputStream

use of org.apache.cxf.io.CachedOutputStream in project tomee by apache.

the class XSLTOutInterceptor method transformOS.

protected void transformOS(Message message, OutputStream out) {
    CachedOutputStream wrapper = new CachedOutputStream();
    CachedOutputStreamCallback callback = new XSLTCachedOutputStreamCallback(getXSLTTemplate(), out);
    wrapper.registerCallback(callback);
    message.setContent(OutputStream.class, wrapper);
}
Also used : CachedOutputStreamCallback(org.apache.cxf.io.CachedOutputStreamCallback) CachedOutputStream(org.apache.cxf.io.CachedOutputStream)

Example 20 with CachedOutputStream

use of org.apache.cxf.io.CachedOutputStream in project cxf by apache.

the class AttachmentUtilTest method integerAsAttachmentMaxSize.

@Test
public void integerAsAttachmentMaxSize() throws IOException {
    CachedOutputStream cos = createMock(CachedOutputStream.class);
    cos = testSetStreamedAttachmentProperties(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, Integer.MAX_VALUE, cos);
    replay(cos);
    cos.setMaxSize(Integer.MAX_VALUE);
    cos.setThreshold(102400L);
    verify(cos);
}
Also used : CachedOutputStream(org.apache.cxf.io.CachedOutputStream) Test(org.junit.Test)

Aggregations

CachedOutputStream (org.apache.cxf.io.CachedOutputStream)105 InputStream (java.io.InputStream)38 IOException (java.io.IOException)35 Test (org.junit.Test)24 Message (org.apache.cxf.message.Message)22 OutputStream (java.io.OutputStream)18 Fault (org.apache.cxf.interceptor.Fault)18 MessageImpl (org.apache.cxf.message.MessageImpl)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 XMLStreamException (javax.xml.stream.XMLStreamException)10 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)10 PrintWriter (java.io.PrintWriter)8 XMLStreamReader (javax.xml.stream.XMLStreamReader)6 StreamSource (javax.xml.transform.stream.StreamSource)6 Endpoint (org.apache.cxf.endpoint.Endpoint)6 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)6 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Source (javax.xml.transform.Source)5 ArrayList (java.util.ArrayList)4