Class MimeBodyPartDataSource

java.lang.Object
com.atlassian.confluence.mail.embed.MimeBodyPartDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class MimeBodyPartDataSource extends Object implements javax.activation.DataSource
DataSource decorator that custom-URL-encodes the name for use with a MimeBodyPart.
  • Constructor Details

    • MimeBodyPartDataSource

      public MimeBodyPartDataSource(javax.activation.DataSource source)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface javax.activation.DataSource
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface javax.activation.DataSource
      Throws:
      IOException
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Specified by:
      getOutputStream in interface javax.activation.DataSource
      Throws:
      IOException
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface javax.activation.DataSource
    • getWrappedSource

      public javax.activation.DataSource getWrappedSource()
    • encode

      public static String encode(String str)
      Plugin datasources often include : as a separator, e.g. plugin.name:module.key:resource.key. These strings need escaping before they can be used in MIME part headers. 1. However, plugin keys may include other characters not permitted in URLs, so we must do a URL encode. 2. However, per a few RFCs out there, escaped URLs are not expected in Content-Disposition and Content-Type filenames and names (resp.) so we replace the encoded bits and assume that nothing will conflict.