Class OutgoingEmail
- java.lang.Object
-
- com.google.gerrit.server.mail.send.OutgoingEmail
-
- Direct Known Subclasses:
AddKeySender,DeleteKeySender,HttpPasswordUpdateSender,InboundEmailRejectionSender,NotificationEmail,RegisterNewEmailSender
public abstract class OutgoingEmail extends Object
Sends an email to one or more interested parties.
-
-
Field Summary
Fields Modifier and Type Field Description protected EmailArgumentsargsprotected List<String>footersprotected Account.IdfromIdprotected StringmessageClassprotected NotifyResolver.Resultnotifyprotected Map<String,Object>soyContextprotected Map<String,Object>soyContextEmailData
-
Constructor Summary
Constructors Modifier Constructor Description protectedOutgoingEmail(EmailArguments args, String messageClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidadd(RecipientType rt, Account.Id to)Schedule delivery of this message to the given account.protected voidadd(RecipientType rt, Account.Id to, boolean override)protected voidadd(RecipientType rt, Address addr)Schedule delivery of this message to the given account.protected voidadd(RecipientType rt, Address addr, boolean override)protected voidadd(RecipientType rt, UserIdentity who)protected voidadd(RecipientType rt, UserIdentity who, boolean override)protected voidadd(RecipientType rt, Collection<Account.Id> list)Schedule this message for delivery to the listed accounts.protected voidadd(RecipientType rt, Collection<Account.Id> list, boolean override)Schedule this message for delivery to the listed accounts.protected voidaddByEmail(RecipientType rt, Collection<Address> list)Schedule this message for delivery to the listed address.protected voidaddByEmail(RecipientType rt, Collection<Address> list, boolean override)Schedule this message for delivery to the listed address.protected voidappendHtml(String html)Append html to the outgoing email body.protected voidappendText(String text)Append text to the outgoing email body.protected abstract voidformat()Format the message body by callingappendText(String).protected StringgetFromLine()StringgetGerritHost()protected StringgetNameEmailFor(Account.Id accountId)Gets the human readable name and email for an account; if neither are available, returns the Anonymous Coward name.protected StringgetNameFor(Account.Id accountId)Lookup a human readable name for an account, usually the "full name".StringgetSettingsUrl()protected StringgetUserNameEmailFor(Account.Id accountId)Gets the human readable name and email for an account; if both are unavailable, returns the username.protected voidinit()Setup the message headers and envelope (TO, CC, BCC).protected booleanisVisibleTo(Account.Id to)protected voidremoveHeader(String name)Remove a header from the outgoing message.protected voidremoveUser(Account user)voidsend()Format and enqueue the message for delivery.voidsetFrom(Account.Id id)protected voidsetHeader(String name, String value)Set a header in the outgoing message.protected voidsetHeader(String name, Date date)voidsetMessageId(MessageIdGenerator.MessageId messageId)voidsetNotify(NotifyResolver.Result notify)protected voidsetupSoyContext()protected booleanshouldSendMessage()protected StringsoyHtmlTemplate(String name)Renders a soy template of kind="html".protected StringtextTemplate(String name)Renders a soy template of kind="text".protected booleanuseHtml()
-
-
-
Field Detail
-
messageClass
protected String messageClass
-
args
protected final EmailArguments args
-
fromId
protected Account.Id fromId
-
notify
protected NotifyResolver.Result notify
-
-
Constructor Detail
-
OutgoingEmail
protected OutgoingEmail(EmailArguments args, String messageClass)
-
-
Method Detail
-
setFrom
public void setFrom(Account.Id id)
-
setNotify
public void setNotify(NotifyResolver.Result notify)
-
setMessageId
public void setMessageId(MessageIdGenerator.MessageId messageId)
-
send
public void send() throws com.google.gerrit.exceptions.EmailExceptionFormat and enqueue the message for delivery.- Throws:
com.google.gerrit.exceptions.EmailException
-
format
protected abstract void format() throws com.google.gerrit.exceptions.EmailExceptionFormat the message body by callingappendText(String).- Throws:
com.google.gerrit.exceptions.EmailException
-
init
protected void init() throws com.google.gerrit.exceptions.EmailExceptionSetup the message headers and envelope (TO, CC, BCC).- Throws:
com.google.gerrit.exceptions.EmailException- if an error occurred.
-
getFromLine
protected String getFromLine()
-
getGerritHost
public String getGerritHost()
-
getSettingsUrl
public String getSettingsUrl()
-
setHeader
protected void setHeader(String name, String value)
Set a header in the outgoing message.
-
removeHeader
protected void removeHeader(String name)
Remove a header from the outgoing message.
-
appendText
protected void appendText(String text)
Append text to the outgoing email body.
-
appendHtml
protected void appendHtml(String html)
Append html to the outgoing email body.
-
getNameFor
protected String getNameFor(Account.Id accountId)
Lookup a human readable name for an account, usually the "full name".
-
getNameEmailFor
protected String getNameEmailFor(Account.Id accountId)
Gets the human readable name and email for an account; if neither are available, returns the Anonymous Coward name.- Parameters:
accountId- user to fetch.- Returns:
- name/email of account, or Anonymous Coward if unset.
-
getUserNameEmailFor
protected String getUserNameEmailFor(Account.Id accountId)
Gets the human readable name and email for an account; if both are unavailable, returns the username. If no username is set, this function returns null.- Parameters:
accountId- user to fetch.- Returns:
- name/email of account, username, or null if unset.
-
shouldSendMessage
protected boolean shouldSendMessage()
-
add
protected void add(RecipientType rt, Collection<Account.Id> list)
Schedule this message for delivery to the listed accounts.
-
add
protected void add(RecipientType rt, Collection<Account.Id> list, boolean override)
Schedule this message for delivery to the listed accounts.
-
addByEmail
protected void addByEmail(RecipientType rt, Collection<Address> list)
Schedule this message for delivery to the listed address.
-
addByEmail
protected void addByEmail(RecipientType rt, Collection<Address> list, boolean override)
Schedule this message for delivery to the listed address.
-
add
protected void add(RecipientType rt, UserIdentity who)
-
add
protected void add(RecipientType rt, UserIdentity who, boolean override)
-
add
protected void add(RecipientType rt, Account.Id to)
Schedule delivery of this message to the given account.
-
add
protected void add(RecipientType rt, Account.Id to, boolean override)
-
isVisibleTo
protected boolean isVisibleTo(Account.Id to) throws PermissionBackendException
- Parameters:
to- account.- Returns:
- whether this email is visible to the given account.
- Throws:
PermissionBackendException
-
add
protected void add(RecipientType rt, Address addr)
Schedule delivery of this message to the given account.
-
add
protected void add(RecipientType rt, Address addr, boolean override)
-
setupSoyContext
protected void setupSoyContext()
-
soyHtmlTemplate
protected String soyHtmlTemplate(String name)
Renders a soy template of kind="html".
-
removeUser
protected void removeUser(Account user)
-
useHtml
protected final boolean useHtml()
-
-