Exemplo n.º 1
0
 public void copySubscribers(AEntity from, AEntity to) {
   Subscription fromSubscription = subscriptionDao.getSubscriptionBySubject(from);
   if (fromSubscription == null || fromSubscription.isSubscribersEmailsEmpty()) return;
   Subscription toSubscription = subscriptionDao.getSubscriptionBySubject(to);
   if (toSubscription == null) toSubscription = subscriptionDao.postSubscription(to);
   toSubscription.addSubscribersEmails(fromSubscription.getSubscribersEmails());
 }
Exemplo n.º 2
0
  public void notifySubscribers(
      AEntity subject, String message, Project project, String exceptionEmail) {
    Subscription subscription = subscriptionDao.getSubscriptionBySubject(subject);
    if (subscription == null || subscription.isSubscribersEmailsEmpty()) {
      log.debug("No subscribers for", subject);
      return;
    }

    Set<String> subscribersEmails = subscription.getSubscribersEmails();
    if (exceptionEmail != null) subscribersEmails.remove(exceptionEmail.toLowerCase());
    if (subscribersEmails.isEmpty()) {
      log.debug("No subscribers for", subject);
      return;
    }

    synchronized (notifications) {
      for (Notification notification : notifications) {
        if (!notification.subject.equals(subject)) continue;
        notification.merge(message, subscribersEmails);
        return;
      }
      notifications.add(new Notification(subject, message, project, subscribersEmails));
    }
  }