Search in sources :

Example 1 with MergedSender

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

the class MergedByPushOp method postUpdate.

@Override
public void postUpdate(final Context ctx) {
    if (!correctBranch) {
        return;
    }
    // Runnable already handles errors
    @SuppressWarnings("unused") Future<?> possiblyIgnoredError = sendEmailExecutor.submit(requestScopePropagator.wrap(new Runnable() {

        @Override
        public void run() {
            try {
                MergedSender cm = mergedSenderFactory.create(ctx.getProject(), psId.getParentKey());
                cm.setFrom(ctx.getAccountId());
                cm.setPatchSet(patchSet, info);
                cm.send();
            } catch (Exception e) {
                log.error("Cannot send email for submitted patch set " + psId, e);
            }
        }

        @Override
        public String toString() {
            return "send-email merged";
        }
    }));
    changeMerged.fire(change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen());
}
Also used : MergedSender(com.google.gerrit.server.mail.send.MergedSender) OrmException(com.google.gwtorm.server.OrmException) IOException(java.io.IOException)

Example 2 with MergedSender

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

the class EmailMerge method run.

@Override
public void run() {
    RequestContext old = requestContext.setContext(this);
    try {
        MergedSender cm = mergedSenderFactory.create(project, changeId);
        if (submitter != null) {
            cm.setFrom(submitter);
        }
        cm.setNotify(notifyHandling);
        cm.setAccountsToNotify(accountsToNotify);
        cm.send();
    } catch (Exception e) {
        log.error("Cannot email merged notification for " + changeId, e);
    } finally {
        requestContext.setContext(old);
        if (db != null) {
            db.close();
            db = null;
        }
    }
}
Also used : MergedSender(com.google.gerrit.server.mail.send.MergedSender) RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) OrmException(com.google.gwtorm.server.OrmException) OutOfScopeException(com.google.inject.OutOfScopeException) ProvisionException(com.google.inject.ProvisionException)

Aggregations

MergedSender (com.google.gerrit.server.mail.send.MergedSender)2 OrmException (com.google.gwtorm.server.OrmException)2 RequestContext (com.google.gerrit.server.util.RequestContext)1 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)1 OutOfScopeException (com.google.inject.OutOfScopeException)1 ProvisionException (com.google.inject.ProvisionException)1 IOException (java.io.IOException)1