Package javax.activation

Examples of javax.activation.DataSource


         message.setSubject(subject, encoding);

         // MimeBodyPart mbp1 = new MimeBodyPart(attachment);
         MimeBodyPart mbp1 = new MimeBodyPart(); // "application/x-any"
         // "application/xmlBlaster-xbformat"
         DataSource ds = new ByteArrayDataSource(attachment,
               "application/xmlBlaster-xbformat");
         mbp1.setDataHandler(new DataHandler(ds));
         mbp1.setFileName(attachmentName);
         // mbp1.getContentType(); "application/octet-stream"
View Full Code Here


                  }
                  mbp.setText(contentStr, Constants.UTF8_ENCODING);
               }
               else {
                  // "application/xmlBlaster-xbformat"
                  DataSource ds = new ByteArrayDataSource(
                        content,
                        holder[i].getContentType());
                  mbp.setDataHandler(new DataHandler(ds));
               }
               multi.addBodyPart(mbp);
View Full Code Here

            Tracing.logError("Tried to send mail wit attachment that does not exist::"
                + (attachmentFile == null ? null : attachmentFile.getAbsolutePath()), MailHelper.class);
            return msg;
          }
          messageBodyPart = new MimeBodyPart();
          DataSource source = new FileDataSource(attachmentFile);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(attachmentFile.getName());
          multipart.addBodyPart(messageBodyPart);
        }
        // Put parts in message
View Full Code Here

            for (FileItem item : files) {
              MimeBodyPart attachment = new MimeBodyPart();
                attachment.setFileName(item.getFilename());
                String mimeType = MimeType.getContentTypeByExt(
                    FolderUtil.getFileExt(item.getFilename()));
                DataSource ds = new ByteArrayDataSource(item.getData(), mimeType);
                attachment.setDataHandler(new DataHandler(ds));
                mp.addBodyPart(attachment);
            }
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(fromAddress, fromText));
View Full Code Here

        if( !att.getFile().exists() )  throw new Exception( "Datei "+ att.getFile().getAbsolutePath() + " fehlt" );
       
       
        MimeBodyPart attachment = new MimeBodyPart();

        DataSource  data_source  = new File_data_source( att.getFile(), att.getContentType() );
        DataHandler data_handler = new DataHandler( data_source );

        attachment.setDataHandler( data_handler );
        attachment.setFileName   ( att.getFile().getName() );
View Full Code Here

                    retVal = dom == null ? read(input).getNode() : dom;
                } else if (Document.class.isAssignableFrom(type)) {
                    retVal = dom == null ? read(input).getNode() : dom;
                } else if (DataSource.class.isAssignableFrom(type)) {
                    final InputStream ins = getInputStream(input);
                    retVal = new DataSource() {
                        public String getContentType() {
                            return "text/xml";
                        }
                        public InputStream getInputStream() throws IOException {
                            return ins;
View Full Code Here

            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
            if (!StringUtils.isEmpty(fileName)) {
                ((AttachmentDataSource)source).setName(fileName);
            }
            att.setDataHandler(new DataHandler(source));
        } else {
            DataSource source = new AttachmentDataSource(ct, stream);
            if (!StringUtils.isEmpty(fileName)) {
                ((AttachmentDataSource)source).setName(fileName);
            }
            att.setDataHandler(new DataHandler(source));
        }
View Full Code Here

        }       

        // The following is just wrong. Even if the DataHandler has a stream, we should still
        // apply the threshold.
        try {
            DataSource ds = handler.getDataSource();
            if (ds instanceof FileDataSource) {
                FileDataSource fds = (FileDataSource)ds;
                File file = fds.getFile();
                if (file.length() < threshold) {
                    return null;
                }
            } else if (ds.getClass().getName().endsWith("ObjectDataSource")) {
                Object o = handler.getContent();
                if (o instanceof String
                    && ((String)o).length() < threshold) {
                    return null;
                } else if (o instanceof byte[] && ((byte[])o).length < threshold) {
View Full Code Here

        OMNamespace dataName = fac.createOMNamespace(
                "http://www.example.org/stuff", "m");
        OMElement data = fac.createOMElement("data", dataName);

        DataSource dataSource = getTestResourceDataSource(imageInFileName);
        expectedDH = new DataHandler(dataSource);
        OMText binaryNode = fac.createOMText(expectedDH, true);

        envelope.addChild(body);
        body.addChild(data);
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        DataSource ds = new RandomDataSource(654321, 64, 128, 20000000);
        Vector/*<InputStream>*/ v = new Vector/*<InputStream>*/();
        v.add(new ByteArrayInputStream("<a>".getBytes("ascii")));
        v.add(ds.getInputStream());
        v.add(new ByteArrayInputStream("</a>".getBytes("ascii")));
        OMElement element = OMXMLBuilderFactory.createOMBuilder(factory,
                StAXParserConfiguration.NON_COALESCING,
                new SequenceInputStream(v.elements()), "ascii").getDocumentElement();
        Reader in = element.getTextAsStream(false);
        IOTestUtils.compareStreams(new InputStreamReader(ds.getInputStream(), "ascii"), in);
    }
View Full Code Here

TOP

Related Classes of javax.activation.DataSource

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.