Search in sources :

Example 76 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)

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