Search in sources :

Example 1 with CommentSender

use of com.google.gerrit.server.mail.send.CommentSender in project gerrit by GerritCodeReview.

the class EmailReviewComments method run.

@Override
public void run() {
    RequestContext old = requestContext.setContext(this);
    try {
        CommentSender cm = commentSenderFactory.create(notes.getProjectName(), notes.getChangeId());
        cm.setFrom(user.getAccountId());
        cm.setPatchSet(patchSet, patchSetInfoFactory.get(notes.getProjectName(), patchSet));
        cm.setChangeMessage(message.getMessage(), message.getWrittenOn());
        cm.setComments(comments);
        cm.setPatchSetComment(patchSetComment);
        cm.setLabels(labels);
        cm.setNotify(notify);
        cm.setAccountsToNotify(accountsToNotify);
        cm.send();
    } catch (Exception e) {
        log.error("Cannot email comments for " + patchSet.getId(), e);
    } finally {
        requestContext.setContext(old);
        if (db != null) {
            db.close();
            db = null;
        }
    }
}
Also used : RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) CommentSender(com.google.gerrit.server.mail.send.CommentSender) OrmException(com.google.gwtorm.server.OrmException) ProvisionException(com.google.inject.ProvisionException)

Aggregations

CommentSender (com.google.gerrit.server.mail.send.CommentSender)1 RequestContext (com.google.gerrit.server.util.RequestContext)1 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)1 OrmException (com.google.gwtorm.server.OrmException)1 ProvisionException (com.google.inject.ProvisionException)1