001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2013 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    /**
029     * <p>
030     * The notification manager receives notifications and is in charge of storing them so that they are processed by the notification service.
031     * </p>
032     * <p>
033     * Pico provides an instance of this class, and plugins just need to create notifications and pass them to this manager with 
034     * the {@link NotificationManager#scheduleForSending(Notification)} method.
035     * </p>
036     * 
037     * @since 2.10
038     */
039    public interface NotificationManager extends ServerComponent, BatchComponent {
040    
041      /**
042       * Receives a notification and stores it so that it is processed by the notification service.
043       * 
044       * @param notification the notification.
045       */
046      void scheduleForSending(Notification notification);
047    
048      /**
049       * <p>
050       * Returns the list of users who subscribed to the given dispatcher, along with the notification channels (email, twitter, ...) that they choose 
051       * for this dispatcher.
052       * </p>
053       * <p>
054       * The resource ID can be null in case of notifications that have nothing to do with a specific project (like system notifications).
055       * </p>
056       * 
057       * @param dispatcher the dispatcher for which this list of users is requested
058       * @param resourceId the optional resource which is concerned by this request
059       * @return the list of user login along with the subscribed channels
060       */
061      Multimap<String, NotificationChannel> findSubscribedRecipientsForDispatcher(NotificationDispatcher dispatcher, @Nullable Integer resourceId);
062    
063      Multimap<String, NotificationChannel> findNotificationSubscribers(NotificationDispatcher dispatcher, @Nullable String componentKey);
064    }