001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018 */ 019package org.apache.wiki.notification; 020 021import org.apache.wiki.api.exceptions.WikiException; 022 023import java.util.Set; 024 025/** 026 * Keeps track of the pages that users want to be notified about by e-mail when they change. 027 * <p> 028 * The subscriptions of a user are kept in the attributes of the user profile, so they are stored by the configured 029 * {@link org.apache.wiki.auth.user.UserDatabase} and need no additional storage. 030 * 031 * @since 3.0.1 032 */ 033public interface SubscriptionManager { 034 035 /** Name of the user profile attribute that holds the subscribed page names. Value is <tt>{@value}</tt>. */ 036 String PROFILE_ATTR_SUBSCRIPTIONS = "subscriptions"; 037 038 /** 039 * Subscribes a user to the changes of a page. Subscribing twice has no effect. 040 * 041 * @param loginName login name of the user. 042 * @param pageName name of the page. 043 * @throws WikiException if the user does not exist or the profile cannot be saved. 044 */ 045 void subscribe( String loginName, String pageName ) throws WikiException; 046 047 /** 048 * Removes the subscription of a user to a page. Removing a subscription that does not exist has no effect. 049 * 050 * @param loginName login name of the user. 051 * @param pageName name of the page. 052 * @throws WikiException if the user does not exist or the profile cannot be saved. 053 */ 054 void unsubscribe( String loginName, String pageName ) throws WikiException; 055 056 /** 057 * Tells whether a user is subscribed to a page. 058 * 059 * @param loginName login name of the user. 060 * @param pageName name of the page. 061 * @return {@code true} if the user is subscribed to the page, {@code false} otherwise, also for an unknown user. 062 */ 063 boolean isSubscribed( String loginName, String pageName ); 064 065 /** 066 * Returns the names of the pages a user is subscribed to. 067 * 068 * @param loginName login name of the user. 069 * @return an unmodifiable set of page names, empty for an unknown user. 070 */ 071 Set< String > getSubscriptions( String loginName ); 072 073}