GerritEvent: Add notify setting
Add a notify setting so that listeners can respect the setting that was requested in the operation that caused the event. There are currently no listeners that use it, so for now, for the events that are likely to need it in future, just return "ALL". These events will be adjusted in later commits to return the correct values. For classes that are not likely to care about this setting, inherit from a new intermediate class that always returns "NONE". Change-Id: I23c36b54d0d9730bfa47b1ebba7522048eee796f
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
|
||||
package com.google.gerrit.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
|
||||
/** Base interface to be extended by Events. */
|
||||
public interface GerritEvent {
|
||||
NotifyHandling getNotify();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.events.ChangeEvent;
|
||||
@@ -24,12 +25,14 @@ public abstract class AbstractChangeEvent implements ChangeEvent {
|
||||
private final ChangeInfo changeInfo;
|
||||
private final AccountInfo who;
|
||||
private final Timestamp when;
|
||||
private final NotifyHandling notify;
|
||||
|
||||
protected AbstractChangeEvent(ChangeInfo change, AccountInfo who,
|
||||
Timestamp when) {
|
||||
Timestamp when, NotifyHandling notify) {
|
||||
this.changeInfo = change;
|
||||
this.who = who;
|
||||
this.when = when;
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,4 +49,9 @@ public abstract class AbstractChangeEvent implements ChangeEvent {
|
||||
public Timestamp getWhen() {
|
||||
return when;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotifyHandling getNotify() {
|
||||
return notify;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2016 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.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.events.GerritEvent;
|
||||
|
||||
/** Intermediate class for events that do not support notification type. */
|
||||
public abstract class AbstractNoNotifyEvent implements GerritEvent {
|
||||
@Override
|
||||
public NotifyHandling getNotify() {
|
||||
return NotifyHandling.NONE;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -27,8 +28,8 @@ public abstract class AbstractRevisionEvent extends AbstractChangeEvent
|
||||
private final RevisionInfo revisionInfo;
|
||||
|
||||
protected AbstractRevisionEvent(ChangeInfo change, RevisionInfo revision,
|
||||
AccountInfo who, Timestamp when) {
|
||||
super(change, who, when);
|
||||
AccountInfo who, Timestamp when, NotifyHandling notify) {
|
||||
super(change, who, when, notify);
|
||||
revisionInfo = revision;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ public class AgreementSignup {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Event implements AgreementSignupListener.Event {
|
||||
private static class Event extends AbstractNoNotifyEvent
|
||||
implements AgreementSignupListener.Event {
|
||||
private final AccountInfo account;
|
||||
private final String agreementName;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -85,7 +86,7 @@ public class ChangeAbandoned {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo abandoner,
|
||||
String reason, Timestamp when) {
|
||||
super(change, revision, abandoner, when);
|
||||
super(change, revision, abandoner, when, NotifyHandling.ALL);
|
||||
this.abandoner = abandoner;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -85,7 +86,7 @@ public class ChangeMerged {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo merger,
|
||||
String newRevisionId, Timestamp when) {
|
||||
super(change, revision, merger, when);
|
||||
super(change, revision, merger, when, NotifyHandling.ALL);
|
||||
this.merger = merger;
|
||||
this.newRevisionId = newRevisionId;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -86,7 +87,7 @@ public class ChangeRestored {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo restorer,
|
||||
String reason, Timestamp when) {
|
||||
super(change, revision, restorer, when);
|
||||
super(change, revision, restorer, when, NotifyHandling.ALL);
|
||||
this.restorer = restorer;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.events.ChangeRevertedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -71,7 +72,7 @@ public class ChangeReverted {
|
||||
private final ChangeInfo revertChange;
|
||||
|
||||
Event(ChangeInfo change, ChangeInfo revertChange, Timestamp when) {
|
||||
super(change, revertChange.owner, when);
|
||||
super(change, revertChange.owner, when, NotifyHandling.ALL);
|
||||
this.revertChange = revertChange;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -97,7 +98,7 @@ public class CommentAdded {
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo author,
|
||||
String comment, Map<String, ApprovalInfo> approvals,
|
||||
Map<String, ApprovalInfo> oldApprovals, Timestamp when) {
|
||||
super(change, revision, author, when);
|
||||
super(change, revision, author, when, NotifyHandling.ALL);
|
||||
this.author = author;
|
||||
this.comment = comment;
|
||||
this.approvals = approvals;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -81,7 +82,7 @@ public class DraftPublished {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo publisher,
|
||||
Timestamp when) {
|
||||
super(change, revision, publisher, when);
|
||||
super(change, revision, publisher, when, NotifyHandling.ALL);
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -213,5 +214,10 @@ public class GitReferenceUpdated {
|
||||
return String.format("%s[%s,%s: %s -> %s]", getClass().getSimpleName(),
|
||||
projectName, ref, oldObjectId, newObjectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotifyHandling getNotify() {
|
||||
return NotifyHandling.ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.events.HashtagsEditedListener;
|
||||
@@ -87,7 +88,7 @@ public class HashtagsEdited {
|
||||
|
||||
Event(ChangeInfo change, AccountInfo editor, Collection<String> updated,
|
||||
Collection<String> added, Collection<String> removed, Timestamp when) {
|
||||
super(change, editor, when);
|
||||
super(change, editor, when, NotifyHandling.ALL);
|
||||
this.editor = editor;
|
||||
this.updatedHashtags = updated;
|
||||
this.addedHashtags = added;
|
||||
|
||||
@@ -36,7 +36,8 @@ public class PluginEvent {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Event implements PluginEventListener.Event {
|
||||
private static class Event extends AbstractNoNotifyEvent
|
||||
implements PluginEventListener.Event {
|
||||
private final String pluginName;
|
||||
private final String type;
|
||||
private final String data;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -85,7 +86,7 @@ public class ReviewerAdded {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo reviewer,
|
||||
AccountInfo adder, Timestamp when) {
|
||||
super(change, revision, adder, when);
|
||||
super(change, revision, adder, when, NotifyHandling.ALL);
|
||||
this.reviewer = reviewer;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -101,7 +102,7 @@ public class ReviewerDeleted {
|
||||
AccountInfo remover, String comment,
|
||||
Map<String, ApprovalInfo> newApprovals,
|
||||
Map<String, ApprovalInfo> oldApprovals, Timestamp when) {
|
||||
super(change, revision, remover, when);
|
||||
super(change, revision, remover, when, NotifyHandling.ALL);
|
||||
this.reviewer = reviewer;
|
||||
this.comment = comment;
|
||||
this.newApprovals = newApprovals;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
@@ -84,7 +85,7 @@ public class RevisionCreated {
|
||||
|
||||
Event(ChangeInfo change, RevisionInfo revision, AccountInfo uploader,
|
||||
Timestamp when) {
|
||||
super(change, revision, uploader, when);
|
||||
super(change, revision, uploader, when, NotifyHandling.ALL);
|
||||
this.uploader = uploader;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.events.TopicEditedListener;
|
||||
@@ -79,7 +80,7 @@ public class TopicEdited {
|
||||
|
||||
Event(ChangeInfo change, AccountInfo editor, String oldTopic,
|
||||
Timestamp when) {
|
||||
super(change, editor, when);
|
||||
super(change, editor, when, NotifyHandling.ALL);
|
||||
this.editor = editor;
|
||||
this.oldTopic = oldTopic;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.events.GarbageCollectorListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.config.GcConfig;
|
||||
import com.google.gerrit.server.extensions.events.AbstractNoNotifyEvent;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.api.GarbageCollectCommand;
|
||||
@@ -197,7 +198,8 @@ public class GarbageCollection {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Event implements GarbageCollectorListener.Event {
|
||||
private static class Event extends AbstractNoNotifyEvent
|
||||
implements GarbageCollectorListener.Event {
|
||||
private final Project.NameKey p;
|
||||
private final Properties statistics;
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.google.gerrit.server.account.GroupBackend;
|
||||
import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.config.ProjectOwnerGroupsProvider;
|
||||
import com.google.gerrit.server.config.RepositoryConfig;
|
||||
import com.google.gerrit.server.extensions.events.AbstractNoNotifyEvent;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
@@ -394,7 +395,8 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
||||
}
|
||||
}
|
||||
|
||||
static class Event implements NewProjectCreatedListener.Event {
|
||||
static class Event extends AbstractNoNotifyEvent
|
||||
implements NewProjectCreatedListener.Event {
|
||||
private final Project.NameKey name;
|
||||
private final String head;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.extensions.events.AbstractNoNotifyEvent;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.project.SetHead.Input;
|
||||
import com.google.inject.Inject;
|
||||
@@ -129,7 +130,8 @@ public class SetHead implements RestModifyView<ProjectResource, Input> {
|
||||
}
|
||||
}
|
||||
|
||||
static class Event implements HeadUpdatedListener.Event {
|
||||
static class Event extends AbstractNoNotifyEvent
|
||||
implements HeadUpdatedListener.Event {
|
||||
private final Project.NameKey nameKey;
|
||||
private final String oldHead;
|
||||
private final String newHead;
|
||||
|
||||
Reference in New Issue
Block a user