James Moger
2014-01-28 7ab32b65fcb20ca68d7afc357befb3a34de662bf
src/main/java/com/gitblit/manager/NotificationManager.java
@@ -32,7 +32,7 @@
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.MailExecutor;
import com.gitblit.service.MailService;
/**
 * The notification manager dispatches notifications.  Currently, email is the
@@ -50,26 +50,27 @@
   private final IStoredSettings settings;
   private final MailExecutor mailExecutor;
   private final MailService mailExecutor;
   public NotificationManager(IStoredSettings settings) {
      this.settings = settings;
      this.mailExecutor = new MailExecutor(settings);
      this.mailExecutor = new MailService(settings);
   }
   @Override
   public IManager setup() {
   public NotificationManager start() {
      if (mailExecutor.isReady()) {
         logger.info("Mail executor is scheduled to process the message queue every 2 minutes.");
         scheduledExecutor.scheduleAtFixedRate(mailExecutor, 1, 2, TimeUnit.MINUTES);
         int period = 2;
         logger.info("Mail service will process the queue every {} minutes.", period);
         scheduledExecutor.scheduleAtFixedRate(mailExecutor, 1, period, TimeUnit.MINUTES);
      } else {
         logger.warn("Mail server is not properly configured.  Mail services disabled.");
         logger.warn("Mail service disabled.");
      }
      return this;
   }
   @Override
   public IManager stop() {
   public NotificationManager stop() {
      scheduledExecutor.shutdownNow();
      return this;
   }
@@ -141,7 +142,20 @@
    */
   @Override
   public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) {
      this.sendHtmlMail(subject, message, toAddresses.toArray(new String[0]));
      this.sendHtmlMail(null, subject, message, toAddresses.toArray(new String[0]));
   }
   /**
    * Notify users by email of something.
    *
    * @param from
    * @param subject
    * @param message
    * @param toAddresses
    */
   @Override
   public void sendHtmlMail(String from, String subject, String message, Collection<String> toAddresses) {
      this.sendHtmlMail(from, subject, message, toAddresses.toArray(new String[0]));
   }
   /**
@@ -153,12 +167,25 @@
    */
   @Override
   public void sendHtmlMail(String subject, String message, String... toAddresses) {
      this.sendHtmlMail(null, message, toAddresses);
   }
   /**
    * Notify users by email of something.
    *
    * @param from
    * @param subject
    * @param message
    * @param toAddresses
    */
   @Override
   public void sendHtmlMail(String from, String subject, String message, String... toAddresses) {
      if (toAddresses == null || toAddresses.length == 0) {
         logger.debug(MessageFormat.format("Dropping message {0} because there are no recipients", subject));
         logger.debug("Dropping message {} because there are no recipients", subject);
         return;
      }
      try {
         Message mail = mailExecutor.createMessage(toAddresses);
         Message mail = mailExecutor.createMessage(from, toAddresses);
         if (mail != null) {
            mail.setSubject(subject);