Search in sources :

Example 71 with ByteArrayDataSource

use of javax.mail.util.ByteArrayDataSource in project cxf by apache.

the class SAAJInInterceptorTest method prepareSoapMessage.

private void prepareSoapMessage(String message) throws IOException {
    soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
    ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass().getResourceAsStream(message), "text/xml");
    soapMessage.setContent(InputStream.class, bads.getInputStream());
}
Also used : ByteArrayDataSource(javax.mail.util.ByteArrayDataSource)

Example 72 with ByteArrayDataSource

use of javax.mail.util.ByteArrayDataSource in project cxf by apache.

the class DataSourceProviderTest method readAttachmentParts.

public static MimeMultipart readAttachmentParts(String contentType, InputStream bais) throws MessagingException, IOException {
    DataSource source = new ByteArrayDataSource(bais, contentType);
    MimeMultipart mpart = new MimeMultipart(source);
    Session session = Session.getDefaultInstance(new Properties());
    MimeMessage mm = new MimeMessage(session);
    mm.setContent(mpart);
    mm.addHeaderLine("Content-Type:" + contentType);
    return (MimeMultipart) mm.getContent();
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) MimeMessage(javax.mail.internet.MimeMessage) Properties(java.util.Properties) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) DataSource(javax.activation.DataSource) Session(javax.mail.Session)

Example 73 with ByteArrayDataSource

use of javax.mail.util.ByteArrayDataSource in project cxf by apache.

the class SwANoMimeServiceImpl method echoDataRef.

public void echoDataRef(Holder<DataStruct> data) {
    try {
        InputStream bis = null;
        bis = data.value.getDataRef().getDataSource().getInputStream();
        byte[] b = new byte[6];
        bis.read(b, 0, 6);
        String string = IOUtils.newStringFromBytes(b);
        ByteArrayDataSource source = new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
        data.value.setDataRef(new DataHandler(source));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InputStream(java.io.InputStream) DataHandler(javax.activation.DataHandler) IOException(java.io.IOException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource)

Example 74 with ByteArrayDataSource

use of javax.mail.util.ByteArrayDataSource in project cxf by apache.

the class SwAServiceImpl method echoDataRef.

public void echoDataRef(Holder<DataStruct> data) {
    try {
        InputStream bis = null;
        bis = data.value.getDataRef().getDataSource().getInputStream();
        byte[] b = new byte[6];
        bis.read(b, 0, 6);
        String string = IOUtils.newStringFromBytes(b);
        ByteArrayDataSource source = new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
        data.value.setDataRef(new DataHandler(source));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InputStream(java.io.InputStream) DataHandler(javax.activation.DataHandler) IOException(java.io.IOException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource)

Example 75 with ByteArrayDataSource

use of javax.mail.util.ByteArrayDataSource in project cxf by apache.

the class SwAServiceImpl method echoData.

public void echoData(Holder<String> text, Holder<DataHandler> data) {
    try {
        InputStream bis = null;
        bis = data.value.getDataSource().getInputStream();
        byte[] b = new byte[6];
        bis.read(b, 0, 6);
        String string = IOUtils.newStringFromBytes(b);
        ByteArrayDataSource source = new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
        data.value = new DataHandler(source);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InputStream(java.io.InputStream) DataHandler(javax.activation.DataHandler) IOException(java.io.IOException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource)

Aggregations

ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)76 DataHandler (javax.activation.DataHandler)58 InputStream (java.io.InputStream)33 IOException (java.io.IOException)25 MimeMultipart (javax.mail.internet.MimeMultipart)23 Test (org.junit.Test)19 DataSource (javax.activation.DataSource)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)17 MimeBodyPart (javax.mail.internet.MimeBodyPart)16 ByteArrayInputStream (java.io.ByteArrayInputStream)14 ArrayList (java.util.ArrayList)14 MessagingException (javax.mail.MessagingException)14 MimeMessage (javax.mail.internet.MimeMessage)12 Holder (javax.xml.ws.Holder)7 List (java.util.List)6 AttachmentImpl (org.apache.cxf.attachment.AttachmentImpl)6 Attachment (org.apache.cxf.message.Attachment)6 Date (java.util.Date)5 HashMap (java.util.HashMap)5 ContentDisposition (com.zimbra.common.mime.ContentDisposition)4