com.atlassian.jira.mail.builder
Class EmailBuilder

java.lang.Object
  extended by com.atlassian.jira.mail.builder.EmailBuilder

public class EmailBuilder
extends Object

This should be used for creation of all email messages in JIRA, it allows to encapsulate the logic of rendering emails.

Since:
v6.0.8

Constructor Summary
EmailBuilder(Email email, NotificationRecipient notificationRecipient)
           
EmailBuilder(Email email, NotificationRecipient notificationRecipient, IssueEvent event)
           
EmailBuilder(Email email, String mimeType, Locale recipientLocale)
           
EmailBuilder(Email email, String mimeType, Locale recipientLocale, IssueEvent issueEvent)
           
 
Method Summary
 EmailBuilder addAttachment(javax.mail.BodyPart bodyPart)
          Specified attachment will be added to rendered e-mail unchanged.
 EmailBuilder addAttachments(Collection<javax.mail.BodyPart> bodyParts)
          Specified attachments will be added to rendered e-mail unchanged.
 EmailBuilder addParameters(Map<String,Object> templateParameters)
           
 com.atlassian.mail.queue.MailQueueItem renderLater()
          Returns a MailQueueItem which will render email message during send
 Email renderNow()
          Blocking method - renders e-mail message in current thread
 com.atlassian.mail.queue.SingleMailQueueItem renderNowAsQueueItem()
          Invokes renderNow() and wraps the result in SingleMailQueueItem
 EmailBuilder withBody(String bodyTemplate)
           
 EmailBuilder withBodyFromFile(String bodyTemplatePath)
           
 EmailBuilder withSubject(String subjectTemplate)
          Render subject with specified Velocity template This is optional
 EmailBuilder withSubjectFromFile(String subjectTemplatePath)
          Render subject with Velocity template from specified file This is optional
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailBuilder

public EmailBuilder(Email email,
                    String mimeType,
                    Locale recipientLocale,
                    IssueEvent issueEvent)

EmailBuilder

public EmailBuilder(Email email,
                    String mimeType,
                    Locale recipientLocale)

EmailBuilder

public EmailBuilder(Email email,
                    NotificationRecipient notificationRecipient,
                    IssueEvent event)

EmailBuilder

public EmailBuilder(Email email,
                    NotificationRecipient notificationRecipient)
Method Detail

addAttachment

public EmailBuilder addAttachment(javax.mail.BodyPart bodyPart)
Specified attachment will be added to rendered e-mail unchanged.

Parameters:
bodyPart -
Returns:
this builder for chain invocations

addAttachments

public EmailBuilder addAttachments(Collection<javax.mail.BodyPart> bodyParts)
Specified attachments will be added to rendered e-mail unchanged.

Parameters:
bodyParts -
Returns:
this builder for chain invocations

withSubject

public EmailBuilder withSubject(String subjectTemplate)
Render subject with specified Velocity template This is optional

Parameters:
subjectTemplate - Velocity template
Returns:
this builder for chain invocations

withSubjectFromFile

public EmailBuilder withSubjectFromFile(String subjectTemplatePath)
Render subject with Velocity template from specified file This is optional

Parameters:
subjectTemplatePath - Path to Velocity file
Returns:
this builder for chain invocations

withBody

public EmailBuilder withBody(String bodyTemplate)

withBodyFromFile

public EmailBuilder withBodyFromFile(String bodyTemplatePath)

addParameters

public EmailBuilder addParameters(Map<String,Object> templateParameters)

renderNowAsQueueItem

public com.atlassian.mail.queue.SingleMailQueueItem renderNowAsQueueItem()
                                                                  throws javax.mail.MessagingException
Invokes renderNow() and wraps the result in SingleMailQueueItem

Returns:
Throws:
javax.mail.MessagingException

renderNow

public Email renderNow()
                throws javax.mail.MessagingException
Blocking method - renders e-mail message in current thread

Returns:
Rendered email
Throws:
javax.mail.MessagingException

renderLater

public com.atlassian.mail.queue.MailQueueItem renderLater()
Returns a MailQueueItem which will render email message during send

Returns:


Copyright © 2002-2014 Atlassian. All Rights Reserved.