|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.atlassian.mail.MailUtils
This class contains a bunch of static helper methods that make life a bit easier particularly with the processing of Parts.
| Nested Class Summary | |
static class |
MailUtils.Attachment
Very simple representation of a mail attachment after it has been extracted from a message. |
| Constructor Summary | |
MailUtils()
|
|
| Method Summary | |
static javax.mail.internet.MimeBodyPart |
createAttachmentMimeBodyPart(java.lang.String path)
Produces a mimebodypart object from an attachment file path. |
static javax.mail.internet.MimeBodyPart |
createZippedAttachmentMimeBodyPart(java.lang.String path)
|
static java.lang.String |
fixMimeEncodedFilename(java.lang.String filename)
This method may be used to fix any mime encoded filenames that have been returned by javamail. |
static MailUtils.Attachment[] |
getAttachments(javax.mail.Message message)
Gets all parts of a message that are attachments rather than alternative inline bits. |
static com.opensymphony.user.User |
getAuthorFromSender(javax.mail.Message message)
Deprecated. Now incorporated into JIRA due to app-specific logic, will be removed in a future release. (complain to chris@atlassian.com) |
static java.lang.String |
getBody(javax.mail.Message message)
Get the body of the message as a String. |
static java.lang.String |
getContentType(javax.mail.Part part)
Helper which returns the pure mime/subMime content type less any other extra parameters which may accompany the header value. |
static java.lang.String |
getContentType(java.lang.String headerValue)
Helper which extracts the content type from a header value removing parameters and so on. |
static com.opensymphony.user.User |
getFirstValidUser(javax.mail.Address[] addresses)
Deprecated. Now incorporated into JIRA due to app-specific logic, will be removed in a future release. (complain to chris@atlassian.com) |
static java.util.List |
getSenders(javax.mail.Message message)
Returns a List |
static boolean |
hasRecipient(java.lang.String matchEmail,
javax.mail.Message message)
|
static boolean |
isContentEmpty(javax.mail.Part part)
Tests if the content of the part content is empty. |
static boolean |
isPartAttachment(javax.mail.Part part)
Tests if the provided part is an attachment. |
static boolean |
isPartHtml(javax.mail.Part part)
Tests if a particular part content type is text/html. |
static boolean |
isPartInline(javax.mail.Part part)
This method uses a number of checks to determine if the given part actually represents an inline (typically image) part. |
static boolean |
isPartMessageType(javax.mail.Part part)
Tests if the provided part's content type is message/rfc822 |
static boolean |
isPartPlainText(javax.mail.Part part)
Tests if the provided part content type is text/plain. |
static boolean |
isPartRelated(javax.mail.Part part)
Tests if the provided part's content type is multipart/related |
static boolean |
isPartSignaturePKCS7(javax.mail.Part part)
Tests if a part is actually a signature. |
static javax.mail.internet.InternetAddress[] |
parseAddresses(java.lang.String addresses)
Parse addresses from a comma (and space) separated string into the proper array |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MailUtils()
| Method Detail |
public static javax.mail.internet.InternetAddress[] parseAddresses(java.lang.String addresses)
throws javax.mail.internet.AddressException
javax.mail.internet.AddressException
public static java.lang.String getBody(javax.mail.Message message)
throws javax.mail.MessagingException
Note: If the message contains nested multipart parts, an HTML part nested at a higher level will take precedence over a text part nested deeper.
message - The message to retrieve the body from
javax.mail.MessagingException - If there was an error getting the content from the message
public static MailUtils.Attachment[] getAttachments(javax.mail.Message message)
throws javax.mail.MessagingException,
java.io.IOException
message - the message from which to extract the attachments
javax.mail.MessagingException
java.io.IOException
public static com.opensymphony.user.User getAuthorFromSender(javax.mail.Message message)
throws javax.mail.MessagingException
message - The message to get the author from.
javax.mail.MessagingException - If an error occurred getting the message authorpublic static com.opensymphony.user.User getFirstValidUser(javax.mail.Address[] addresses)
addresses - addresses to be used to search for a User.
public static boolean hasRecipient(java.lang.String matchEmail,
javax.mail.Message message)
throws javax.mail.MessagingException
javax.mail.MessagingException
public static java.util.List getSenders(javax.mail.Message message)
throws javax.mail.MessagingException
message - the message from which to get senders.
javax.mail.MessagingException - if the senders can't be retrieved from message.
public static javax.mail.internet.MimeBodyPart createAttachmentMimeBodyPart(java.lang.String path)
throws javax.mail.MessagingException
path -
javax.mail.MessagingException
public static javax.mail.internet.MimeBodyPart createZippedAttachmentMimeBodyPart(java.lang.String path)
throws javax.mail.MessagingException
javax.mail.MessagingException
public static boolean isPartHtml(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - if javamail complains
public static boolean isPartPlainText(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - if javamail complains
public static boolean isPartMessageType(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - if javamail complains
public static boolean isPartRelated(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - if javamail complains
public static java.lang.String getContentType(javax.mail.Part part)
throws javax.mail.MessagingException
part - the mail part to extract the content-type from.
javax.mail.MessagingException - if retrieving the part's Content-Type header failspublic static java.lang.String getContentType(java.lang.String headerValue)
headerValue - The header value.
public static boolean isContentEmpty(javax.mail.Part part)
throws javax.mail.MessagingException,
java.io.IOException
part - a mail part - may or may not have content.
javax.mail.MessagingException - if retrieving content fails.
java.io.IOException - if retrieving content fails or reading content input stream fails.
public static boolean isPartInline(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - as thrown by java mail
public static boolean isPartAttachment(javax.mail.Part part)
throws javax.mail.MessagingException
part - The part being tested.
javax.mail.MessagingException - if javamail complains
public static java.lang.String fixMimeEncodedFilename(java.lang.String filename)
throws java.io.IOException
filename -
java.io.IOException - MimeUtility.decodeText(java.lang.String)
public static boolean isPartSignaturePKCS7(javax.mail.Part part)
throws javax.mail.MessagingException
part - a mail part. The part is assumed to have a content-type header.
javax.mail.MessagingException - if retrieving the Content-Type from the part fails.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||