Merge changes from topic 'event-who-when'
* changes: ChangeEvent: Add 'who' and 'when' fields and methods ChangeEmail: Deprecate setChangeMessage(ChangeMessage)
This commit is contained in:
		| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface ChangeAbandonedListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getAbandoner(); | ||||
|     String getReason(); | ||||
|   } | ||||
|   | ||||
| @@ -14,10 +14,14 @@ | ||||
|  | ||||
| package com.google.gerrit.extensions.events; | ||||
|  | ||||
| import com.google.gerrit.extensions.common.AccountInfo; | ||||
| import com.google.gerrit.extensions.common.ChangeInfo; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| /** Interface to be extended by Events with a Change. */ | ||||
| public interface ChangeEvent extends GerritEvent { | ||||
|   ChangeInfo getChange(); | ||||
|   AccountInfo getWho(); | ||||
|   Timestamp getWhen(); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface ChangeMergedListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getMerger(); | ||||
|     /** | ||||
|      * Represents the merged Revision when the submit strategy is cherry-pick or | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface ChangeRestoredListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getRestorer(); | ||||
|     String getReason(); | ||||
|   } | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import java.util.Map; | ||||
| @ExtensionPoint | ||||
| public interface CommentAddedListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getAuthor(); | ||||
|     String getComment(); | ||||
|     Map<String, ApprovalInfo> getApprovals(); | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface DraftPublishedListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getPublisher(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import java.util.Collection; | ||||
| @ExtensionPoint | ||||
| public interface HashtagsEditedListener { | ||||
|   interface Event extends ChangeEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getEditor(); | ||||
|     Collection<String> getHashtags(); | ||||
|     Collection<String> getAddedHashtags(); | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface RevisionCreatedListener { | ||||
|   interface Event extends RevisionEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getUploader(); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.common.AccountInfo; | ||||
| @ExtensionPoint | ||||
| public interface TopicEditedListener { | ||||
|   interface Event extends ChangeEvent { | ||||
|     @Deprecated | ||||
|     AccountInfo getEditor(); | ||||
|     String getOldTopic(); | ||||
|   } | ||||
|   | ||||
| @@ -166,12 +166,12 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>, | ||||
|         if (account != null) { | ||||
|           cm.setFrom(account.getId()); | ||||
|         } | ||||
|         cm.setChangeMessage(message); | ||||
|         cm.setChangeMessage(message.getMessage(), ctx.getWhen()); | ||||
|         cm.send(); | ||||
|       } catch (Exception e) { | ||||
|         log.error("Cannot email update for change " + change.getId(), e); | ||||
|       } | ||||
|       changeAbandoned.fire(change, patchSet, account, msgTxt); | ||||
|       changeAbandoned.fire(change, patchSet, account, msgTxt, ctx.getWhen()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -401,7 +401,8 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp { | ||||
|      * show a transition from an oldValue of 0 to the new value. | ||||
|      */ | ||||
|     if (fireRevisionCreated) { | ||||
|       revisionCreated.fire(change, patchSet, ctx.getUser().getAccountId()); | ||||
|       revisionCreated.fire(change, patchSet, ctx.getUser().getAccountId(), | ||||
|           ctx.getWhen()); | ||||
|       if (approvals != null && !approvals.isEmpty()) { | ||||
|         ChangeControl changeControl = changeControlFactory.controlFor( | ||||
|             ctx.getDb(), change, ctx.getUser()); | ||||
|   | ||||
| @@ -199,6 +199,7 @@ public class DeleteReviewer implements RestModifyView<ReviewerResource, Input> { | ||||
|  | ||||
|       emailReviewers(ctx.getProject(), currChange, del, changeMessage); | ||||
|       reviewerDeleted.fire(currChange, currPs, reviewer, | ||||
|           ctx.getUser().asIdentifiedUser().getAccount(), | ||||
|           changeMessage.getMessage(), | ||||
|           newApprovals, oldApprovals, | ||||
|           ctx.getWhen()); | ||||
| @@ -241,7 +242,8 @@ public class DeleteReviewer implements RestModifyView<ReviewerResource, Input> { | ||||
|             deleteReviewerSenderFactory.create(projectName, change.getId()); | ||||
|         cm.setFrom(userId); | ||||
|         cm.addReviewers(toMail); | ||||
|         cm.setChangeMessage(changeMessage); | ||||
|         cm.setChangeMessage(changeMessage.getMessage(), | ||||
|             changeMessage.getWrittenOn()); | ||||
|         cm.send(); | ||||
|       } catch (Exception err) { | ||||
|         log.error("Cannot email update for change " + change.getId(), err); | ||||
|   | ||||
| @@ -207,7 +207,7 @@ public class DeleteVote | ||||
|           ReplyToChangeSender cm = deleteVoteSenderFactory.create( | ||||
|               ctx.getProject(), change.getId()); | ||||
|           cm.setFrom(user.getAccountId()); | ||||
|           cm.setChangeMessage(changeMessage); | ||||
|           cm.setChangeMessage(changeMessage.getMessage(), ctx.getWhen()); | ||||
|           cm.setNotify(input.notify); | ||||
|           cm.send(); | ||||
|         } catch (Exception e) { | ||||
|   | ||||
| @@ -109,7 +109,7 @@ public class EmailReviewComments implements Runnable, RequestContext { | ||||
|       cm.setFrom(user.getAccountId()); | ||||
|       cm.setPatchSet(patchSet, | ||||
|           patchSetInfoFactory.get(notes.getProjectName(), patchSet)); | ||||
|       cm.setChangeMessage(message); | ||||
|       cm.setChangeMessage(message.getMessage(), message.getWrittenOn()); | ||||
|       cm.setPatchLineComments(comments); | ||||
|       cm.setNotify(notify); | ||||
|       cm.send(); | ||||
|   | ||||
| @@ -263,7 +263,7 @@ public class PatchSetInserter extends BatchUpdate.Op { | ||||
|             ctx.getProject(), change.getId()); | ||||
|         cm.setFrom(ctx.getUser().getAccountId()); | ||||
|         cm.setPatchSet(patchSet, patchSetInfo); | ||||
|         cm.setChangeMessage(changeMessage); | ||||
|         cm.setChangeMessage(changeMessage.getMessage(), ctx.getWhen()); | ||||
|         cm.addReviewers(oldReviewers.byState(REVIEWER)); | ||||
|         cm.addExtraCC(oldReviewers.byState(CC)); | ||||
|         cm.send(); | ||||
| @@ -274,7 +274,8 @@ public class PatchSetInserter extends BatchUpdate.Op { | ||||
|     } | ||||
|  | ||||
|     if (fireRevisionCreated) { | ||||
|       revisionCreated.fire(change, patchSet, ctx.getUser().getAccountId()); | ||||
|       revisionCreated.fire(change, patchSet, ctx.getUser().getAccountId(), | ||||
|           ctx.getWhen()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -289,7 +289,9 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer | ||||
|       if (!added.isEmpty()) { | ||||
|         for (PatchSetApproval psa : added) { | ||||
|           Account account = accountCache.get(psa.getAccountId()).getAccount(); | ||||
|           reviewerAdded.fire(rsrc.getChange(), patchSet, account); | ||||
|           reviewerAdded.fire(rsrc.getChange(), patchSet, account, | ||||
|               ctx.getUser().asIdentifiedUser().getAccount(), | ||||
|               ctx.getWhen()); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   | ||||
| @@ -223,7 +223,8 @@ public class PublishDraftPatchSet implements RestModifyView<RevisionResource, In | ||||
|  | ||||
|     @Override | ||||
|     public void postUpdate(Context ctx) throws OrmException { | ||||
|       draftPublished.fire(change, patchSet, ctx.getUser().getAccountId()); | ||||
|       draftPublished.fire(change, patchSet, ctx.getUser().getAccountId(), | ||||
|           ctx.getWhen()); | ||||
|       if (patchSet.isDraft() && change.getStatus() == Change.Status.DRAFT) { | ||||
|         // Skip emails if the patch set is still a draft. | ||||
|         return; | ||||
| @@ -261,7 +262,7 @@ public class PublishDraftPatchSet implements RestModifyView<RevisionResource, In | ||||
|           replacePatchSetFactory.create(ctx.getProject(), change.getId()); | ||||
|       cm.setFrom(accountId); | ||||
|       cm.setPatchSet(patchSet, patchSetInfo); | ||||
|       cm.setChangeMessage(msg); | ||||
|       cm.setChangeMessage(msg.getMessage(), ctx.getWhen()); | ||||
|       cm.addReviewers(recipients.getReviewers()); | ||||
|       cm.addExtraCC(recipients.getCcOnly()); | ||||
|       cm.send(); | ||||
|   | ||||
| @@ -131,7 +131,8 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>, | ||||
|       if (change != null) { | ||||
|         topicEdited.fire(change, | ||||
|             ctx.getUser().asIdentifiedUser().getAccount(), | ||||
|             oldTopicName); | ||||
|             oldTopicName, | ||||
|             ctx.getWhen()); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -149,14 +149,15 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>, | ||||
|         ReplyToChangeSender cm = | ||||
|             restoredSenderFactory.create(ctx.getProject(), change.getId()); | ||||
|         cm.setFrom(ctx.getUser().getAccountId()); | ||||
|         cm.setChangeMessage(message); | ||||
|         cm.setChangeMessage(message.getMessage(), ctx.getWhen()); | ||||
|         cm.send(); | ||||
|       } catch (Exception e) { | ||||
|         log.error("Cannot email update for change " + change.getId(), e); | ||||
|       } | ||||
|       changeRestored.fire(change, patchSet, | ||||
|           ctx.getUser().asIdentifiedUser().getAccount(), | ||||
|           Strings.emptyToNull(input.message)); | ||||
|           Strings.emptyToNull(input.message), | ||||
|           ctx.getWhen()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -240,13 +240,13 @@ public class Revert implements RestModifyView<ChangeResource, RevertInput>, | ||||
|  | ||||
|     @Override | ||||
|     public void postUpdate(Context ctx) throws Exception { | ||||
|       changeReverted.fire(change, ins.getChange()); | ||||
|       changeReverted.fire(change, ins.getChange(), ctx.getWhen()); | ||||
|       Change.Id changeId = ins.getChange().getId(); | ||||
|       try { | ||||
|         RevertedSender cm = | ||||
|             revertedSenderFactory.create(ctx.getProject(), changeId); | ||||
|         cm.setFrom(ctx.getUser().getAccountId()); | ||||
|         cm.setChangeMessage(ins.getChangeMessage()); | ||||
|         cm.setChangeMessage(ins.getChangeMessage().getMessage(), ctx.getWhen()); | ||||
|         cm.send(); | ||||
|       } catch (Exception err) { | ||||
|         log.error("Cannot send email for revert change " + changeId, err); | ||||
|   | ||||
| @@ -167,7 +167,7 @@ public class SetHashtagsOp extends BatchUpdate.Op { | ||||
|   public void postUpdate(Context ctx) throws OrmException { | ||||
|     if (updated() && fireEvent) { | ||||
|       hashtagsEdited.fire(change, ctx.getUser().getAccountId(), updatedHashtags, | ||||
|           toAdd, toRemove); | ||||
|           toAdd, toRemove, ctx.getWhen()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -272,7 +272,7 @@ public class StreamEventsApiListener implements | ||||
|       TopicChangedEvent event = new TopicChangedEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.changer = accountAttributeSupplier(ev.getEditor()); | ||||
|       event.changer = accountAttributeSupplier(ev.getWho()); | ||||
|       event.oldTopic = ev.getOldTopic(); | ||||
|  | ||||
|       dispatcher.get().postEvent(change, event); | ||||
| @@ -291,7 +291,7 @@ public class StreamEventsApiListener implements | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, patchSet); | ||||
|       event.uploader = accountAttributeSupplier(ev.getUploader()); | ||||
|       event.uploader = accountAttributeSupplier(ev.getWho()); | ||||
|  | ||||
|       dispatcher.get().postEvent(change, event); | ||||
|     } catch (OrmException e) { | ||||
| @@ -354,7 +354,7 @@ public class StreamEventsApiListener implements | ||||
|       HashtagsChangedEvent event = new HashtagsChangedEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.editor = accountAttributeSupplier(ev.getEditor()); | ||||
|       event.editor = accountAttributeSupplier(ev.getWho()); | ||||
|       event.hashtags = hashtagArray(ev.getHashtags()); | ||||
|       event.added = hashtagArray(ev.getAddedHashtags()); | ||||
|       event.removed = hashtagArray(ev.getRemovedHashtags()); | ||||
| @@ -396,7 +396,7 @@ public class StreamEventsApiListener implements | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, ps); | ||||
|       event.uploader = accountAttributeSupplier(ev.getPublisher()); | ||||
|       event.uploader = accountAttributeSupplier(ev.getWho()); | ||||
|  | ||||
|       dispatcher.get().postEvent(change, event); | ||||
|     } catch (OrmException e) { | ||||
| @@ -413,7 +413,7 @@ public class StreamEventsApiListener implements | ||||
|       CommentAddedEvent event = new CommentAddedEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.author =  accountAttributeSupplier(ev.getAuthor()); | ||||
|       event.author =  accountAttributeSupplier(ev.getWho()); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, ps); | ||||
|       event.comment = ev.getComment(); | ||||
|       event.approvals = approvalsAttributeSupplier( | ||||
| @@ -433,7 +433,7 @@ public class StreamEventsApiListener implements | ||||
|       ChangeRestoredEvent event = new ChangeRestoredEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.restorer = accountAttributeSupplier(ev.getRestorer()); | ||||
|       event.restorer = accountAttributeSupplier(ev.getWho()); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, | ||||
|           psUtil.current(db.get(), notes)); | ||||
|       event.reason = ev.getReason(); | ||||
| @@ -452,7 +452,7 @@ public class StreamEventsApiListener implements | ||||
|       ChangeMergedEvent event = new ChangeMergedEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.submitter = accountAttributeSupplier(ev.getMerger()); | ||||
|       event.submitter = accountAttributeSupplier(ev.getWho()); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, | ||||
|           psUtil.current(db.get(), notes)); | ||||
|       event.newRev = ev.getNewRevisionId(); | ||||
| @@ -471,7 +471,7 @@ public class StreamEventsApiListener implements | ||||
|       ChangeAbandonedEvent event = new ChangeAbandonedEvent(change); | ||||
|  | ||||
|       event.change = changeAttributeSupplier(change); | ||||
|       event.abandoner = accountAttributeSupplier(ev.getAbandoner()); | ||||
|       event.abandoner = accountAttributeSupplier(ev.getWho()); | ||||
|       event.patchSet = patchSetAttributeSupplier(change, | ||||
|           psUtil.current(db.get(), notes)); | ||||
|       event.reason = ev.getReason(); | ||||
|   | ||||
| @@ -14,18 +14,36 @@ | ||||
|  | ||||
| package com.google.gerrit.server.extensions.events; | ||||
|  | ||||
| import com.google.gerrit.extensions.common.AccountInfo; | ||||
| import com.google.gerrit.extensions.common.ChangeInfo; | ||||
| import com.google.gerrit.extensions.events.ChangeEvent; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public abstract class AbstractChangeEvent implements ChangeEvent { | ||||
|   private final ChangeInfo changeInfo; | ||||
|   private final AccountInfo who; | ||||
|   private final Timestamp when; | ||||
|  | ||||
|   protected AbstractChangeEvent(ChangeInfo change) { | ||||
|   protected AbstractChangeEvent(ChangeInfo change, AccountInfo who, | ||||
|       Timestamp when) { | ||||
|     this.changeInfo = change; | ||||
|     this.who = who; | ||||
|     this.when = when; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public ChangeInfo getChange() { | ||||
|     return changeInfo; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public AccountInfo getWho() { | ||||
|     return who; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public Timestamp getWhen() { | ||||
|     return when; | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -14,17 +14,21 @@ | ||||
|  | ||||
| package com.google.gerrit.server.extensions.events; | ||||
|  | ||||
| import com.google.gerrit.extensions.common.AccountInfo; | ||||
| import com.google.gerrit.extensions.common.ChangeInfo; | ||||
| import com.google.gerrit.extensions.common.RevisionInfo; | ||||
| import com.google.gerrit.extensions.events.RevisionEvent; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public abstract class AbstractRevisionEvent extends AbstractChangeEvent | ||||
|     implements RevisionEvent { | ||||
|  | ||||
|   private final RevisionInfo revisionInfo; | ||||
|  | ||||
|   protected AbstractRevisionEvent(ChangeInfo change, RevisionInfo revision) { | ||||
|     super(change); | ||||
|   protected AbstractRevisionEvent(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo who, Timestamp when) { | ||||
|     super(change, who, when); | ||||
|     revisionInfo = revision; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class ChangeAbandoned { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class ChangeAbandoned { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo abandoner, String reason) { | ||||
|       AccountInfo abandoner, String reason, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, abandoner, reason); | ||||
|     Event event = new Event(change, revision, abandoner, reason, when); | ||||
|     for (ChangeAbandonedListener l : listeners) { | ||||
|       try { | ||||
|         l.onChangeAbandoned(event); | ||||
| @@ -61,7 +62,8 @@ public class ChangeAbandoned { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet ps, Account abandoner, String reason) { | ||||
|   public void fire(Change change, PatchSet ps, Account abandoner, String reason, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
| @@ -69,7 +71,7 @@ public class ChangeAbandoned { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), ps), | ||||
|           util.accountInfo(abandoner), | ||||
|           reason); | ||||
|           reason, when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -82,8 +84,8 @@ public class ChangeAbandoned { | ||||
|     private final String reason; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo abandoner, | ||||
|         String reason) { | ||||
|       super(change, revision); | ||||
|         String reason, Timestamp when) { | ||||
|       super(change, revision, abandoner, when); | ||||
|       this.abandoner = abandoner; | ||||
|       this.reason = reason; | ||||
|     } | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class ChangeMerged { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class ChangeMerged { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo merger, String newRevisionId) { | ||||
|       AccountInfo merger, String newRevisionId, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, merger, newRevisionId); | ||||
|     Event event = new Event(change, revision, merger, newRevisionId, when); | ||||
|     for (ChangeMergedListener l : listeners) { | ||||
|       try { | ||||
|         l.onChangeMerged(event); | ||||
| @@ -62,7 +63,7 @@ public class ChangeMerged { | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet ps, Account merger, | ||||
|       String newRevisionId) { | ||||
|       String newRevisionId, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
| @@ -70,7 +71,7 @@ public class ChangeMerged { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), ps), | ||||
|           util.accountInfo(merger), | ||||
|           newRevisionId); | ||||
|           newRevisionId, when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -83,8 +84,8 @@ public class ChangeMerged { | ||||
|     private final String newRevisionId; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo merger, | ||||
|         String newRevisionId) { | ||||
|       super(change, revision); | ||||
|         String newRevisionId, Timestamp when) { | ||||
|       super(change, revision, merger, when); | ||||
|       this.merger = merger; | ||||
|       this.newRevisionId = newRevisionId; | ||||
|     } | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class ChangeRestored { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class ChangeRestored { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo restorer, String reason) { | ||||
|       AccountInfo restorer, String reason, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, restorer, reason); | ||||
|     Event event = new Event(change, revision, restorer, reason, when); | ||||
|     for (ChangeRestoredListener l : listeners) { | ||||
|       try { | ||||
|         l.onChangeRestored(event); | ||||
| @@ -61,7 +62,8 @@ public class ChangeRestored { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet ps, Account restorer, String reason) { | ||||
|   public void fire(Change change, PatchSet ps, Account restorer, String reason, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
| @@ -69,7 +71,7 @@ public class ChangeRestored { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), ps), | ||||
|           util.accountInfo(restorer), | ||||
|           reason); | ||||
|           reason, when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -83,8 +85,8 @@ public class ChangeRestored { | ||||
|     private String reason; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo restorer, | ||||
|         String reason) { | ||||
|       super(change, revision); | ||||
|         String reason, Timestamp when) { | ||||
|       super(change, revision, restorer, when); | ||||
|       this.restorer = restorer; | ||||
|       this.reason = reason; | ||||
|     } | ||||
|   | ||||
| @@ -24,6 +24,8 @@ import com.google.inject.Inject; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class ChangeReverted { | ||||
|   private static final Logger log = | ||||
|       LoggerFactory.getLogger(ChangeReverted.class); | ||||
| @@ -38,22 +40,23 @@ public class ChangeReverted { | ||||
|     this.util = util; | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, Change revertChange) { | ||||
|   public void fire(Change change, Change revertChange, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     try { | ||||
|       fire(util.changeInfo(change), util.changeInfo(revertChange)); | ||||
|       fire(util.changeInfo(change), util.changeInfo(revertChange), when); | ||||
|     } catch (OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire (ChangeInfo change, ChangeInfo revertChange) { | ||||
|   public void fire (ChangeInfo change, ChangeInfo revertChange, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revertChange); | ||||
|     Event event = new Event(change, revertChange, when); | ||||
|     for (ChangeRevertedListener l : listeners) { | ||||
|       try { | ||||
|         l.onChangeReverted(event); | ||||
| @@ -67,8 +70,8 @@ public class ChangeReverted { | ||||
|       implements ChangeRevertedListener.Event { | ||||
|     private final ChangeInfo revertChange; | ||||
|  | ||||
|     Event(ChangeInfo change, ChangeInfo revertChange) { | ||||
|       super(change); | ||||
|     Event(ChangeInfo change, ChangeInfo revertChange, Timestamp when) { | ||||
|       super(change, revertChange.owner, when); | ||||
|       this.revertChange = revertChange; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -51,12 +51,12 @@ public class CommentAdded { | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, AccountInfo author, | ||||
|       String comment, Map<String, ApprovalInfo> approvals, | ||||
|       Map<String, ApprovalInfo> oldApprovals) { | ||||
|       Map<String, ApprovalInfo> oldApprovals, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event( | ||||
|         change, revision, author, comment, approvals, oldApprovals); | ||||
|         change, revision, author, comment, approvals, oldApprovals, when); | ||||
|     for (CommentAddedListener l : listeners) { | ||||
|       try { | ||||
|         l.onCommentAdded(event); | ||||
| @@ -68,7 +68,7 @@ public class CommentAdded { | ||||
|  | ||||
|   public void fire(Change change, PatchSet ps, Account author, | ||||
|       String comment, Map<String, Short> approvals, | ||||
|       Map<String, Short> oldApprovals, Timestamp ts) { | ||||
|       Map<String, Short> oldApprovals, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
| @@ -77,8 +77,9 @@ public class CommentAdded { | ||||
|           util.revisionInfo(change.getProject(), ps), | ||||
|           util.accountInfo(author), | ||||
|           comment, | ||||
|           util.approvals(author, approvals, ts), | ||||
|           util.approvals(author, oldApprovals, ts)); | ||||
|           util.approvals(author, approvals, when), | ||||
|           util.approvals(author, oldApprovals, when), | ||||
|           when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -95,8 +96,8 @@ public class CommentAdded { | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo author, | ||||
|         String comment, Map<String, ApprovalInfo> approvals, | ||||
|         Map<String, ApprovalInfo> oldApprovals) { | ||||
|       super(change, revision); | ||||
|         Map<String, ApprovalInfo> oldApprovals, Timestamp when) { | ||||
|       super(change, revision, author, when); | ||||
|       this.author = author; | ||||
|       this.comment = comment; | ||||
|       this.approvals = approvals; | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class DraftPublished { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class DraftPublished { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo publisher) { | ||||
|       AccountInfo publisher, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, publisher); | ||||
|     Event event = new Event(change, revision, publisher, when); | ||||
|     for (DraftPublishedListener l : listeners) { | ||||
|       try { | ||||
|         l.onDraftPublished(event); | ||||
| @@ -61,11 +62,13 @@ public class DraftPublished { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet patchSet, Account.Id accountId) { | ||||
|   public void fire(Change change, PatchSet patchSet, Account.Id accountId, | ||||
|       Timestamp when) { | ||||
|     try { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), patchSet), | ||||
|           util.accountInfo(accountId)); | ||||
|           util.accountInfo(accountId), | ||||
|           when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -76,8 +79,9 @@ public class DraftPublished { | ||||
|       implements DraftPublishedListener.Event { | ||||
|     private final AccountInfo publisher; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo publisher) { | ||||
|       super(change, revision); | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo publisher, | ||||
|         Timestamp when) { | ||||
|       super(change, revision, publisher, when); | ||||
|       this.publisher = publisher; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import com.google.inject.Inject; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
| import java.util.Collection; | ||||
| import java.util.Set; | ||||
|  | ||||
| @@ -44,12 +45,13 @@ public class HashtagsEdited { | ||||
|     this.util = util; | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, AccountInfo editor, Collection<String> hashtags, | ||||
|       Collection<String> added, Collection<String> removed) { | ||||
|   public void fire(ChangeInfo change, AccountInfo editor, | ||||
|       Collection<String> hashtags, Collection<String> added, | ||||
|       Collection<String> removed, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, editor, hashtags, added, removed); | ||||
|     Event event = new Event(change, editor, hashtags, added, removed, when); | ||||
|     for (HashtagsEditedListener l : listeners) { | ||||
|       try { | ||||
|         l.onHashtagsEdited(event); | ||||
| @@ -60,15 +62,16 @@ public class HashtagsEdited { | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, Id accountId, | ||||
|       ImmutableSortedSet<String> updatedHashtags, Set<String> toAdd, | ||||
|       Set<String> toRemove) { | ||||
|       ImmutableSortedSet<String> hashtags, Set<String> added, | ||||
|       Set<String> removed, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     try { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.accountInfo(accountId), | ||||
|           updatedHashtags, toAdd, toRemove); | ||||
|           hashtags, added, removed, | ||||
|           when); | ||||
|     } catch (OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
|     } | ||||
| @@ -83,8 +86,8 @@ public class HashtagsEdited { | ||||
|     private Collection<String> removedHashtags; | ||||
|  | ||||
|     Event(ChangeInfo change, AccountInfo editor, Collection<String> updated, | ||||
|         Collection<String> added, Collection<String> removed) { | ||||
|       super(change); | ||||
|         Collection<String> added, Collection<String> removed, Timestamp when) { | ||||
|       super(change, editor, when); | ||||
|       this.editor = editor; | ||||
|       this.updatedHashtags = updated; | ||||
|       this.addedHashtags = added; | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class ReviewerAdded { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class ReviewerAdded { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo reviewer) { | ||||
|       AccountInfo reviewer, AccountInfo adder, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, reviewer); | ||||
|     Event event = new Event(change, revision, reviewer, adder, when); | ||||
|     for (ReviewerAddedListener l : listeners) { | ||||
|       try { | ||||
|         l.onReviewerAdded(event); | ||||
| @@ -61,14 +62,17 @@ public class ReviewerAdded { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet patchSet, Account account) { | ||||
|   public void fire(Change change, PatchSet patchSet, Account account, | ||||
|       Account adder, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     try { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), patchSet), | ||||
|           util.accountInfo(account)); | ||||
|           util.accountInfo(account), | ||||
|           util.accountInfo(adder), | ||||
|           when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -79,8 +83,9 @@ public class ReviewerAdded { | ||||
|       implements ReviewerAddedListener.Event { | ||||
|     private final AccountInfo reviewer; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo reviewer) { | ||||
|       super(change, revision); | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo reviewer, | ||||
|         AccountInfo adder, Timestamp when) { | ||||
|       super(change, revision, adder, when); | ||||
|       this.reviewer = reviewer; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -50,14 +50,14 @@ public class ReviewerDeleted { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo reviewer, String message, | ||||
|       AccountInfo reviewer, AccountInfo remover, String message, | ||||
|       Map<String, ApprovalInfo> newApprovals, | ||||
|       Map<String, ApprovalInfo> oldApprovals) { | ||||
|       Map<String, ApprovalInfo> oldApprovals, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, reviewer, message, | ||||
|         newApprovals, oldApprovals); | ||||
|     Event event = new Event(change, revision, reviewer, remover, message, | ||||
|         newApprovals, oldApprovals, when); | ||||
|     for (ReviewerDeletedListener listener : listeners) { | ||||
|       try { | ||||
|         listener.onReviewerDeleted(event); | ||||
| @@ -68,9 +68,9 @@ public class ReviewerDeleted { | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet patchSet, Account reviewer, | ||||
|       String message, | ||||
|       Account remover, String message, | ||||
|       Map<String, Short> newApprovals, | ||||
|       Map<String, Short> oldApprovals, Timestamp ts) { | ||||
|       Map<String, Short> oldApprovals, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
| @@ -78,9 +78,11 @@ public class ReviewerDeleted { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), patchSet), | ||||
|           util.accountInfo(reviewer), | ||||
|           util.accountInfo(remover), | ||||
|           message, | ||||
|           util.approvals(reviewer, newApprovals, ts), | ||||
|           util.approvals(reviewer, oldApprovals, ts)); | ||||
|           util.approvals(reviewer, newApprovals, when), | ||||
|           util.approvals(reviewer, oldApprovals, when), | ||||
|           when); | ||||
|     } catch (PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -96,9 +98,10 @@ public class ReviewerDeleted { | ||||
|     private final Map<String, ApprovalInfo> oldApprovals; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo reviewer, | ||||
|         String comment, Map<String, ApprovalInfo> newApprovals, | ||||
|         Map<String, ApprovalInfo> oldApprovals) { | ||||
|       super(change, revision); | ||||
|         AccountInfo remover, String comment, | ||||
|         Map<String, ApprovalInfo> newApprovals, | ||||
|         Map<String, ApprovalInfo> oldApprovals, Timestamp when) { | ||||
|       super(change, revision, remover, when); | ||||
|       this.reviewer = reviewer; | ||||
|       this.comment = comment; | ||||
|       this.newApprovals = newApprovals; | ||||
|   | ||||
| @@ -31,6 +31,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class RevisionCreated { | ||||
|   private static final Logger log = | ||||
| @@ -47,11 +48,11 @@ public class RevisionCreated { | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, RevisionInfo revision, | ||||
|       AccountInfo uploader) { | ||||
|       AccountInfo uploader, Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, revision, uploader); | ||||
|     Event event = new Event(change, revision, uploader, when); | ||||
|     for (RevisionCreatedListener l : listeners) { | ||||
|       try { | ||||
|         l.onRevisionCreated(event); | ||||
| @@ -61,14 +62,16 @@ public class RevisionCreated { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, PatchSet patchSet, Account.Id uploader) { | ||||
|   public void fire(Change change, PatchSet patchSet, Account.Id uploader, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     try { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.revisionInfo(change.getProject(), patchSet), | ||||
|           util.accountInfo(uploader)); | ||||
|           util.accountInfo(uploader), | ||||
|           when); | ||||
|     } catch ( PatchListNotAvailableException | GpgException | IOException | ||||
|         | OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
| @@ -79,8 +82,9 @@ public class RevisionCreated { | ||||
|       implements RevisionCreatedListener.Event { | ||||
|     private final AccountInfo uploader; | ||||
|  | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo uploader) { | ||||
|       super(change, revision); | ||||
|     Event(ChangeInfo change, RevisionInfo revision, AccountInfo uploader, | ||||
|         Timestamp when) { | ||||
|       super(change, revision, uploader, when); | ||||
|       this.uploader = uploader; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -26,6 +26,8 @@ import com.google.inject.Inject; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
|  | ||||
| public class TopicEdited { | ||||
|   private static final Logger log = | ||||
|       LoggerFactory.getLogger(TopicEdited.class); | ||||
| @@ -40,11 +42,12 @@ public class TopicEdited { | ||||
|     this.util = util; | ||||
|   } | ||||
|  | ||||
|   public void fire(ChangeInfo change, AccountInfo editor, String oldTopic) { | ||||
|   public void fire(ChangeInfo change, AccountInfo editor, String oldTopic, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     Event event = new Event(change, editor, oldTopic); | ||||
|     Event event = new Event(change, editor, oldTopic, when); | ||||
|     for (TopicEditedListener l : listeners) { | ||||
|       try { | ||||
|         l.onTopicEdited(event); | ||||
| @@ -54,14 +57,16 @@ public class TopicEdited { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public void fire(Change change, Account account, String oldTopicName) { | ||||
|   public void fire(Change change, Account account, String oldTopicName, | ||||
|       Timestamp when) { | ||||
|     if (!listeners.iterator().hasNext()) { | ||||
|       return; | ||||
|     } | ||||
|     try { | ||||
|       fire(util.changeInfo(change), | ||||
|           util.accountInfo(account), | ||||
|           oldTopicName); | ||||
|           oldTopicName, | ||||
|           when); | ||||
|     } catch (OrmException e) { | ||||
|       log.error("Couldn't fire event", e); | ||||
|     } | ||||
| @@ -72,8 +77,9 @@ public class TopicEdited { | ||||
|     private final AccountInfo editor; | ||||
|     private final String oldTopic; | ||||
|  | ||||
|     Event(ChangeInfo change, AccountInfo editor, String oldTopic) { | ||||
|       super(change); | ||||
|     Event(ChangeInfo change, AccountInfo editor, String oldTopic, | ||||
|         Timestamp when) { | ||||
|       super(change, editor, when); | ||||
|       this.editor = editor; | ||||
|       this.oldTopic = oldTopic; | ||||
|     } | ||||
|   | ||||
| @@ -196,7 +196,8 @@ public class MergedByPushOp extends BatchUpdate.Op { | ||||
|  | ||||
|     changeMerged.fire(change, patchSet, | ||||
|         ctx.getUser().asIdentifiedUser().getAccount(), | ||||
|         patchSet.getRevision().get()); | ||||
|         patchSet.getRevision().get(), | ||||
|         ctx.getWhen()); | ||||
|   } | ||||
|  | ||||
|   private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException { | ||||
|   | ||||
| @@ -373,7 +373,7 @@ public class ReplaceOp extends BatchUpdate.Op { | ||||
|                 projectControl.getProject().getNameKey(), change.getId()); | ||||
|             cm.setFrom(ctx.getUser().getAccountId()); | ||||
|             cm.setPatchSet(newPatchSet, info); | ||||
|             cm.setChangeMessage(msg); | ||||
|             cm.setChangeMessage(msg.getMessage(), ctx.getWhen()); | ||||
|             if (magicBranch != null && magicBranch.notify != null) { | ||||
|               cm.setNotify(magicBranch.notify); | ||||
|             } | ||||
| @@ -398,7 +398,8 @@ public class ReplaceOp extends BatchUpdate.Op { | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     revisionCreated.fire(change, newPatchSet, ctx.getUser().getAccountId()); | ||||
|     revisionCreated.fire(change, newPatchSet, ctx.getUser().getAccountId(), | ||||
|         ctx.getWhen()); | ||||
|     try { | ||||
|       fireCommentAddedEvent(ctx); | ||||
|     } catch (Exception e) { | ||||
|   | ||||
| @@ -527,7 +527,8 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op { | ||||
|           updatedChange, | ||||
|           mergedPatchSet, | ||||
|           args.accountCache.get(submitter.getAccountId()).getAccount(), | ||||
|           args.mergeTip.getCurrentTip().name()); | ||||
|           args.mergeTip.getCurrentTip().name(), | ||||
|           ctx.getWhen()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -50,6 +50,7 @@ import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.sql.Timestamp; | ||||
| import java.text.MessageFormat; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| @@ -72,7 +73,8 @@ public abstract class ChangeEmail extends NotificationEmail { | ||||
|   protected final ChangeData changeData; | ||||
|   protected PatchSet patchSet; | ||||
|   protected PatchSetInfo patchSetInfo; | ||||
|   protected ChangeMessage changeMessage; | ||||
|   protected String changeMessage; | ||||
|   protected Timestamp timestamp; | ||||
|  | ||||
|   protected ProjectState projectState; | ||||
|   protected Set<Account.Id> authors; | ||||
| @@ -104,8 +106,14 @@ public abstract class ChangeEmail extends NotificationEmail { | ||||
|     patchSetInfo = psi; | ||||
|   } | ||||
|  | ||||
|   @Deprecated | ||||
|   public void setChangeMessage(final ChangeMessage cm) { | ||||
|     setChangeMessage(cm.getMessage(), cm.getWrittenOn()); | ||||
|   } | ||||
|  | ||||
|   public void setChangeMessage(String cm, Timestamp t) { | ||||
|     changeMessage = cm; | ||||
|     timestamp = t; | ||||
|   } | ||||
|  | ||||
|   /** Format the message body by calling {@link #appendText(String)}. */ | ||||
| @@ -166,9 +174,8 @@ public abstract class ChangeEmail extends NotificationEmail { | ||||
|     authors = getAuthors(); | ||||
|  | ||||
|     super.init(); | ||||
|  | ||||
|     if (changeMessage != null && changeMessage.getWrittenOn() != null) { | ||||
|       setHeader("Date", new Date(changeMessage.getWrittenOn().getTime())); | ||||
|     if (timestamp != null) { | ||||
|       setHeader("Date", new Date(timestamp.getTime())); | ||||
|     } | ||||
|     setChangeSubjectHeader(); | ||||
|     setHeader("X-Gerrit-Change-Id", "" + change.getKey().get()); | ||||
| @@ -220,13 +227,10 @@ public abstract class ChangeEmail extends NotificationEmail { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** Get the text of the "cover letter", from {@link ChangeMessage}. */ | ||||
|   /** Get the text of the "cover letter". */ | ||||
|   public String getCoverLetter() { | ||||
|     if (changeMessage != null) { | ||||
|       final String txt = changeMessage.getMessage(); | ||||
|       if (txt != null) { | ||||
|         return txt.trim(); | ||||
|       } | ||||
|       return changeMessage.trim(); | ||||
|     } | ||||
|     return ""; | ||||
|   } | ||||
|   | ||||
 Submodule plugins/hooks updated: ac06f40436...3acc14d10d
									
								
							
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse