Package javax.mail.util

Examples of javax.mail.util.ByteArrayDataSource


        }

        // store content in a byte array data store
        DataSource ds;
        try {
            ds = new ByteArrayDataSource(camelMessage.getBody(String.class), contentType);
        } catch (IOException e) {
            throw new MessagingException("Cannot create DataSource", e);
        }
        bodyMessage.setDataHandler(new DataHandler(ds));
        bodyMessage.setHeader("Content-Type", contentType);
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());
    
        xop.setImage(ImageIO.read(getClass().getResource(
                "/org/apache/cxf/systest/jaxrs/resources/java.jpg")));
        return xop;
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

        // Byte array
        String response = ws.stringFromBytes(request.getBytes());
        assertEquals(request, response);

        // Data Source
        DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");

        // not yet supported !
//        response = ws.stringFromDataSource(source);
//        assertEquals(request, response);
View Full Code Here

        JPEGTranscoder transcoder = new JPEGTranscoder();
        transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(
                Math.max(0, Math.min(quality, 100)) / 100.0f));
        transcoder.writeImage(thumb, new TranscoderOutput(output));

        DataSource dataSource= new ByteArrayDataSource(output.toByteArray(), "application/octet-stream");
        return new DataHandler(dataSource);
    }
View Full Code Here

        }
        BodyPart messageBodyPart = new MimeBodyPart();
        DataHandler dataHandler = null;
        try {
            dataHandler = new DataHandler(
                    new ByteArrayDataSource(this.html, "text/html"));
            messageBodyPart.setDataHandler(dataHandler);
            multipart.addBodyPart(messageBodyPart);
        } catch (IOException e) {
            throw new CarbonException(e);
        } catch (MessagingException e) {
View Full Code Here

        uiPermissionNode.setNodeList(children);
        return uiPermissionNode;
    }
   
    public static DataHandler buildDataHandler(byte[] content) {  
        DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(content,
                "application/octet-stream"));
        return dataHandler;
    }
View Full Code Here

      for (Attachment attachment : attachments) {
        if (attachment.data.length > attachmentSize) {
          throw new AttachmentTooLargeException();
        }
        bodyPart = new MimeBodyPart();
        bodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
            attachment.data, encoding)));
        // 设置附件名称
        bodyPart.setFileName(attachment.name);
        multiPart.addBodyPart(bodyPart);
      }
View Full Code Here

    public Multipart readFrom(Class<Multipart> type, Type genericType,
            Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpResponseHeaders,
            InputStream entityStream) throws IOException {
        final String contentType = "multipart/form-data";
        final DataSource ds = new ByteArrayDataSource(entityStream, contentType);
        try {
            return new MimeMultipart(ds);
        } catch (MessagingException e) {
            if (e.getCause() instanceof IOException) {
                throw (IOException) e.getCause();
View Full Code Here

    @Override
    public DataSource readFrom(Class<DataSource> type, Type genericType,
            Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
            throws IOException {
        return new ByteArrayDataSource(entityStream, mediaType.toString());
    }
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.