List of usage examples for javax.activation DataSource getName
public String getName();
From source file:org.wf.dp.dniprorada.util.Mail.java
public Mail _Attach(URL oURL, String sName) { try {//ww w. j a va 2 s.co m MimeBodyPart oMimeBodyPart = new MimeBodyPart();//javax.activation oMimeBodyPart.setHeader("Content-Type", "multipart/mixed"); DataSource oDataSource = new URLDataSource(oURL); oMimeBodyPart.setDataHandler(new DataHandler(oDataSource)); //oPart.setFileName(MimeUtility.encodeText(source.getName())); oMimeBodyPart.setFileName( MimeUtility.encodeText(sName == null || "".equals(sName) ? oDataSource.getName() : sName)); oMultiparts.addBodyPart(oMimeBodyPart); log.info("[_Attach:oURL]:sName=" + sName); } catch (Exception oException) { log.error("[_Attach:oURL]:sName=" + sName, oException); } return this; }
From source file:org.xwiki.mail.internal.AttachmentMimeBodyPartFactory.java
@Override public MimeBodyPart create(Attachment attachment, Map<String, Object> parameters) throws MessagingException { // Create the attachment part of the email MimeBodyPart attachmentPart = new MimeBodyPart(); // Save the attachment to a temporary file on the file system and wrap it in a Java Mail Data Source. DataSource source = createTemporaryAttachmentDataSource(attachment); attachmentPart.setDataHandler(new DataHandler(source)); attachmentPart.setHeader("Content-Type", attachment.getMimeType()); // Add a content-id so that we can uniquely reference this attachment. This is used for example to // display the attachment inline in some mail HTML content. // Note: According to http://tools.ietf.org/html/rfc2392 the id must be enclosed in angle brackets. attachmentPart.setHeader("Content-ID", "<" + attachment.getFilename() + ">"); attachmentPart.setFileName(source.getName()); // Handle headers passed as parameter addHeaders(attachmentPart, parameters); return attachmentPart; }
From source file:org.znerd.yaff.activation.XMLDataSource.java
/** * Constructs a new <code>XMLDataSource</code> from an existing * <code>DataSource</code> object. * * @param dataSource//from w w w.j a va2 s . c o m * the {@link DataSource}, cannot be <code>null</code>. * * @throws IllegalArgumentException * if <code>dataSource == null</code>. * * @throws IOException * if there was an I/O error while reading from the input stream of the * data source. * * @throws ParseException * if there was a parsing error while parsing the content as XML. */ public XMLDataSource(DataSource dataSource) throws IllegalArgumentException, IOException, ParseException { // Check preconditions MandatoryArgumentChecker.check("dataSource", dataSource); // The DataSource could be an XDataSource instance XDataSource xds = (dataSource instanceof XDataSource) ? (XDataSource) dataSource : null; // Populate fields _file = (xds != null) ? xds.getFile() : null; _name = dataSource.getName(); _lastModified = (xds != null) ? xds.lastModified() : System.currentTimeMillis(); _xml = new ElementParser().parse(dataSource.getInputStream()); }