Move project and branch info to new base class NotificationEmail
Class NotificationEmail holds data about project and branch, and let the class ChangeEmail only hold change and patchset info, then for emails that are not related to change and patchset, such as direct pushed email, they can use class NotificationEmail as base class. Change-Id: I57c71c8a10857f7c03c6ed476c79401018e6d343
This commit is contained in:
committed by
David Pursehouse
parent
a7ee130b7d
commit
0ff7fd2338
@@ -65,7 +65,7 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/** Sends an email to one or more interested parties. */
|
||||
public abstract class ChangeEmail extends OutgoingEmail {
|
||||
public abstract class ChangeEmail extends NotificationEmail {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeEmail.class);
|
||||
|
||||
protected final Change change;
|
||||
@@ -80,7 +80,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
||||
|
||||
protected ChangeEmail(EmailArguments ea, final String anonymousCowardName,
|
||||
final Change c, final String mc) {
|
||||
super(ea, anonymousCowardName, mc);
|
||||
super(ea, anonymousCowardName, mc, c.getProject(), c.getDest());
|
||||
change = c;
|
||||
changeData = new ChangeData(change);
|
||||
emailOnlyAuthors = false;
|
||||
@@ -571,10 +571,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
||||
velocityContext.put("change", change);
|
||||
velocityContext.put("changeId", change.getKey());
|
||||
velocityContext.put("coverLetter", getCoverLetter());
|
||||
velocityContext.put("branch", change.getDest());
|
||||
velocityContext.put("fromName", getNameFor(fromId));
|
||||
velocityContext.put("projectName", //
|
||||
projectState != null ? projectState.getProject().getName() : null);
|
||||
velocityContext.put("patchSet", patchSet);
|
||||
velocityContext.put("patchSetInfo", patchSetInfo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
|
||||
/**
|
||||
* Common class for notifications that are related to a project and branch
|
||||
*/
|
||||
public abstract class NotificationEmail extends OutgoingEmail {
|
||||
protected Project.NameKey project;
|
||||
protected Branch.NameKey branch;
|
||||
|
||||
protected NotificationEmail(EmailArguments ea, String anonymousCowardName,
|
||||
String mc, Project.NameKey project, Branch.NameKey branch) {
|
||||
super(ea, anonymousCowardName, mc);
|
||||
|
||||
this.project = project;
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupVelocityContext() {
|
||||
super.setupVelocityContext();
|
||||
velocityContext.put("projectName", project.get());
|
||||
velocityContext.put("branch", branch);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user