Class ChangeEmailImpl
java.lang.Object
com.google.gerrit.server.mail.send.ChangeEmailImpl
- All Implemented Interfaces:
ChangeEmail
,OutgoingEmail.EmailDecorator
Populates an email for change related notifications.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.gerrit.server.mail.send.ChangeEmail
ChangeEmail.ChangeEmailDecorator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EmailArguments
protected final BranchNameKey
protected final Change
protected final ChangeData
protected final ChangeEmail.ChangeEmailDecorator
protected final Set<Account.Id>
protected OutgoingEmail
protected PatchSet
protected PatchSetInfo
-
Constructor Summary
ConstructorsConstructorDescriptionChangeEmailImpl
(EmailArguments args, Project.NameKey project, Change.Id changeId, ChangeEmail.ChangeEmailDecorator changeEmailDecorator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
TO or CC all vested parties (change owner, patch set uploader, author).void
BCC any user who has starred this change.void
Any user who has published comments on this change.void
Users who were added as reviewers to this change.Get change for which the email is being sent.Get ChangeData for the change corresponding to the email.protected String
Create the change message and the affected file list.protected String
Get a link to the change; null if the server doesn't know its own address or if the address is malformed.Get the text of the "cover letter".int
Get the number of deleted lines in a change.protected boolean
int
Get the number of added lines in a change.Get PatchSet if provided.Get the project entity the change is in; null if its been deleted.Get Timestamp of the event causing the email.Show patch set as unified difference.void
Include users and groups that want notification of events.void
includeWatchers
(NotifyConfig.NotifyType type, boolean includeWatchersFromNotifyConfig) Include users and groups that want notification of events.void
init
(OutgoingEmail email) Stores the reference to the email for the subsequent calls.boolean
Evaluates whether account can be added to the list of recipients.boolean
isRecipientAllowed
(Address addr) Evaluates whether email can be added to the list of recipients.Get the patch list corresponding to this patch set.listModifiedFiles
(int patchSetId) Get the patch list corresponding to patch set patchSetId of this change.void
Mark the email as non-first in the thread to ensure correct headers will be setvoid
Populate headers, recipients and body of the email.void
setChangeMessage
(String cm, Instant t) Specify the summary of what happened to the change.protected void
void
setEmailOnlyAttentionSetIfEnabled
(boolean value) Specify if the email should only be sent to attention set.void
setPatchSet
(PatchSet ps) Specify PatchSet with which the notification is associated with.void
setPatchSet
(PatchSet ps, PatchSetInfo psi) Specify PatchSet along with additional data.protected void
Sets headers for conversation groupingprotected static String
shortenSubject
(String subject) A shortened subject is the subject limited to 72 characters, with an ellipsis if it exceeds that limit.boolean
If returns false email is not sent to any recipients.
-
Field Details
-
args
-
currentAttentionSet
-
change
-
changeData
-
branch
-
changeEmailDecorator
-
email
-
patchSet
-
patchSetInfo
-
-
Constructor Details
-
ChangeEmailImpl
public ChangeEmailImpl(EmailArguments args, Project.NameKey project, Change.Id changeId, ChangeEmail.ChangeEmailDecorator changeEmailDecorator)
-
-
Method Details
-
markAsReply
public void markAsReply()Description copied from interface:ChangeEmail
Mark the email as non-first in the thread to ensure correct headers will be set- Specified by:
markAsReply
in interfaceChangeEmail
-
getChange
Description copied from interface:ChangeEmail
Get change for which the email is being sent.- Specified by:
getChange
in interfaceChangeEmail
-
getChangeData
Description copied from interface:ChangeEmail
Get ChangeData for the change corresponding to the email.- Specified by:
getChangeData
in interfaceChangeEmail
-
getTimestamp
Description copied from interface:ChangeEmail
Get Timestamp of the event causing the email.Provided by
ChangeEmail.setChangeMessage(String, Instant)
.- Specified by:
getTimestamp
in interfaceChangeEmail
-
setPatchSet
Description copied from interface:ChangeEmail
Specify PatchSet with which the notification is associated with.- Specified by:
setPatchSet
in interfaceChangeEmail
-
getPatchSet
Description copied from interface:ChangeEmail
Get PatchSet if provided.- Specified by:
getPatchSet
in interfaceChangeEmail
-
setPatchSet
Description copied from interface:ChangeEmail
Specify PatchSet along with additional data.- Specified by:
setPatchSet
in interfaceChangeEmail
-
setChangeMessage
Description copied from interface:ChangeEmail
Specify the summary of what happened to the change.- Specified by:
setChangeMessage
in interfaceChangeEmail
-
setEmailOnlyAttentionSetIfEnabled
public void setEmailOnlyAttentionSetIfEnabled(boolean value) Description copied from interface:ChangeEmail
Specify if the email should only be sent to attention set.Only affects users who have corresponding option enabled in the settings.
- Specified by:
setEmailOnlyAttentionSetIfEnabled
in interfaceChangeEmail
-
shouldSendMessage
public boolean shouldSendMessage()Description copied from interface:OutgoingEmail.EmailDecorator
If returns false email is not sent to any recipients.- Specified by:
shouldSendMessage
in interfaceOutgoingEmail.EmailDecorator
-
init
Description copied from interface:OutgoingEmail.EmailDecorator
Stores the reference to the email for the subsequent calls.Both init and populateEmailContent can be called multiply times in case of retries. Init is therefore responsible for clearing up any changes which are not idempotent and initializing data for use in populateEmailContent.
Can be used to adjust any of the behaviour of the
OutgoingEmail.populateEmailContent()
.- Specified by:
init
in interfaceOutgoingEmail.EmailDecorator
- Throws:
com.google.gerrit.exceptions.EmailException
-
setChangeSubjectHeader
protected void setChangeSubjectHeader() -
getInsertionsCount
public int getInsertionsCount()Description copied from interface:ChangeEmail
Get the number of added lines in a change.- Specified by:
getInsertionsCount
in interfaceChangeEmail
-
getDeletionsCount
public int getDeletionsCount()Description copied from interface:ChangeEmail
Get the number of deleted lines in a change.- Specified by:
getDeletionsCount
in interfaceChangeEmail
-
getChangeUrl
Get a link to the change; null if the server doesn't know its own address or if the address is malformed. The link will contain a usp parameter set to "email" to inform the frontend on clickthroughs where the link came from. -
setThreadHeaders
protected void setThreadHeaders()Sets headers for conversation grouping -
getCoverLetter
Get the text of the "cover letter".- Specified by:
getCoverLetter
in interfaceChangeEmail
-
getChangeDetail
Create the change message and the affected file list. -
listModifiedFiles
Get the patch list corresponding to patch set patchSetId of this change.- Specified by:
listModifiedFiles
in interfaceChangeEmail
-
listModifiedFiles
Get the patch list corresponding to this patch set.- Specified by:
listModifiedFiles
in interfaceChangeEmail
-
getProjectState
Get the project entity the change is in; null if its been deleted.- Specified by:
getProjectState
in interfaceChangeEmail
-
addAuthors
TO or CC all vested parties (change owner, patch set uploader, author).- Specified by:
addAuthors
in interfaceChangeEmail
-
bccStarredBy
public void bccStarredBy()BCC any user who has starred this change.- Specified by:
bccStarredBy
in interfaceChangeEmail
-
includeWatchers
Include users and groups that want notification of events.- Specified by:
includeWatchers
in interfaceChangeEmail
-
includeWatchers
Include users and groups that want notification of events.- Specified by:
includeWatchers
in interfaceChangeEmail
-
ccAllApprovals
public void ccAllApprovals()Any user who has published comments on this change.- Specified by:
ccAllApprovals
in interfaceChangeEmail
-
ccExistingReviewers
public void ccExistingReviewers()Users who were added as reviewers to this change.- Specified by:
ccExistingReviewers
in interfaceChangeEmail
-
isRecipientAllowed
Description copied from interface:OutgoingEmail.EmailDecorator
Evaluates whether email can be added to the list of recipients.- Specified by:
isRecipientAllowed
in interfaceOutgoingEmail.EmailDecorator
- Parameters:
addr
- the recipient for which it should be checker whether it can be added to the list of recipients- Throws:
PermissionBackendException
- thrown if checking permissions fails
-
isRecipientAllowed
Description copied from interface:OutgoingEmail.EmailDecorator
Evaluates whether account can be added to the list of recipients.- Specified by:
isRecipientAllowed
in interfaceOutgoingEmail.EmailDecorator
- Parameters:
to
- the recipient for which it should be checker whether it can be added to the list of recipients- Throws:
PermissionBackendException
- thrown if checking permissions fails
-
populateEmailContent
public void populateEmailContent() throws com.google.gerrit.exceptions.EmailExceptionDescription copied from interface:OutgoingEmail.EmailDecorator
Populate headers, recipients and body of the email.Method operates on the email provided in the init method.
By default, all the contents and parameters of the email should be set in this method.
- Specified by:
populateEmailContent
in interfaceOutgoingEmail.EmailDecorator
- Throws:
com.google.gerrit.exceptions.EmailException
-
shortenSubject
A shortened subject is the subject limited to 72 characters, with an ellipsis if it exceeds that limit. -
getEmailsByState
-
getIncludeDiff
protected boolean getIncludeDiff() -
getUnifiedDiff
Show patch set as unified difference.- Specified by:
getUnifiedDiff
in interfaceChangeEmail
-