Package javax.mail.util

Examples of javax.mail.util.ByteArrayDataSource


        XopType xop = new XopType();
        xop.setName("xopName");
        InputStream is =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
        byte[] data = IOUtils.readBytesFromStream(is);
        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
       
        String bookXsd = IOUtils.readStringFromStream(getClass().getResourceAsStream(
            "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
        xop.setAttachinfo2(bookXsd.getBytes());
    
View Full Code Here


         
      URL url = new URL(attachmentURL);
      URLConnection connection = url.openConnection();
      connection.setRequestProperty( "User-Agent","OpenForum");
         
          ByteArrayDataSource ds = new ByteArrayDataSource(connection.getInputStream(), attachmentMimeType);
          filePart.setDataHandler(new DataHandler(ds));
          multipart.addBodyPart(filePart);
        }
       
        MimeBodyPart textPart = new MimeBodyPart();
View Full Code Here

            out.write(footer);
        }
    }

    protected String getEncoding(final byte[] rawBytes, final String contentType) {
        final DataSource dataSource = new ByteArrayDataSource(rawBytes, contentType);
        return MimeUtility.getEncoding(dataSource);
    }
View Full Code Here

                elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.REQ_MESSAGE)).getDocumentElement()));
                CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
                    elements, null);
                exchange.getIn().setBody(body);
                exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID,
                    new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));

                exchange.getIn().addAttachment(MtomTestHelper.REQ_IMAGE_CID,
                    new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));

            }
           
        });
       
View Full Code Here

         multipPartRoot.addBodyPart(contentPartRoot);
         for (Attachment att : attachment)
         {
            InputStream is = att.getInputStream();
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
            ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(is, att.getMimeType());
            mimeBodyPart.setDataHandler(new DataHandler(byteArrayDataSource));

            mimeBodyPart.setDisposition(Part.ATTACHMENT);
            if (att.getName() != null)
               mimeBodyPart.setFileName(MimeUtility.encodeText(att.getName(), "utf-8", null));
View Full Code Here

         multipPartRoot.addBodyPart(contentPartRoot);
         for (Attachment att : attachment)
         {
            InputStream is = att.getInputStream();
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
            ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(is, att.getMimeType());
            mimeBodyPart.setDataHandler(new DataHandler(byteArrayDataSource));

            mimeBodyPart.setDisposition(Part.ATTACHMENT);
            if (att.getName() != null)
               mimeBodyPart.setFileName(MimeUtility.encodeText(att.getName(), "utf-8", null));
View Full Code Here

        XopType xop = new XopType();
        xop.setName("xopName");
        InputStream is =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
        byte[] data = IOUtils.readBytesFromStream(is);
        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
        xop.setAttachInfoRef(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
        xop.setAttachinfo2(bookXsd.getBytes());
    
        if (Boolean.getBoolean("java.awt.headless")) {
            System.out.println("Running headless. Ignoring an Image property.");
        } else {
View Full Code Here

        XopType xop = new XopType();
        xop.setName("xopName");
        InputStream is =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
        byte[] data = IOUtils.readBytesFromStream(is);
        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
        xop.setAttachInfoRef(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
       
        String bookXsd = IOUtils.readStringFromStream(getClass().getResourceAsStream(
            "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
        xop.setAttachinfo2(bookXsd.getBytes());
    
View Full Code Here

        if (exchange.getIn().hasAttachments()) {
            appendAttachmentsFromCamel(mimeMessage, exchange.getIn(), endpoint.getConfiguration());
        } else {
            if ("text/html".equals(endpoint.getConfiguration().getContentType())) {
                DataSource ds = new ByteArrayDataSource(exchange.getIn().getBody(String.class), "text/html");
                mimeMessage.setDataHandler(new DataHandler(ds));
            } else {
                // its just text/plain
                mimeMessage.setText(exchange.getIn().getBody(String.class));
            }
View Full Code Here

            byte b[] = new byte[6];
            bis.read(b, 0, 6);
            String attachContent = new String(b);
            name.value = name.value + attachContent;
           
            ByteArrayDataSource source =
                new ByteArrayDataSource(("test" + attachContent).getBytes(), "application/octet-stream");
            attachinfo.value = new DataHandler(source);
        } catch (IOException e) {
            e.printStackTrace();
        }
       
View Full Code Here

TOP

Related Classes of javax.mail.util.ByteArrayDataSource

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.