001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.api.notifications;
021
022 import com.google.common.collect.Multimap;
023 import org.sonar.api.BatchComponent;
024 import org.sonar.api.ServerComponent;
025
026 import javax.annotation.Nullable;
027
028 import java.util.List;
029
030 /**
031 * <p>
032 * The notification manager receives notifications and is in charge of storing them so that they are processed by the notification service.
033 * </p>
034 * <p>
035 * Pico provides an instance of this class, and plugins just need to create notifications and pass them to this manager with
036 * the {@link NotificationManager#scheduleForSending(Notification)} method.
037 * </p>
038 *
039 * @since 2.10
040 */
041 public interface NotificationManager extends ServerComponent, BatchComponent {
042
043 /**
044 * Receives a notification and stores it so that it is processed by the notification service.
045 *
046 * @param notification the notification.
047 */
048 void scheduleForSending(Notification notification);
049
050 /**
051 * Receives notifications and stores them so that they are processed by the notification service.
052 *
053 * @param notifications the notifications.
054 * @since 3.7.1
055 */
056 void scheduleForSending(List<Notification> notifications);
057
058 /**
059 * <p>
060 * Returns the list of users who subscribed to the given dispatcher, along with the notification channels (email, twitter, ...) that they choose
061 * for this dispatcher.
062 * </p>
063 * <p>
064 * The resource ID can be null in case of notifications that have nothing to do with a specific project (like system notifications).
065 * </p>
066 *
067 * @param dispatcher the dispatcher for which this list of users is requested
068 * @param resourceId the optional resource which is concerned by this request
069 * @return the list of user login along with the subscribed channels
070 */
071 Multimap<String, NotificationChannel> findSubscribedRecipientsForDispatcher(NotificationDispatcher dispatcher, @Nullable Integer resourceId);
072
073 Multimap<String, NotificationChannel> findNotificationSubscribers(NotificationDispatcher dispatcher, @Nullable String componentKey);
074 }