com.atlassian.jira.bc.issue.watcher
Class DefaultWatcherService

java.lang.Object
  extended by com.atlassian.jira.bc.issue.watcher.DefaultWatcherService
All Implemented Interfaces:
WatcherService

public class DefaultWatcherService
extends java.lang.Object
implements WatcherService

Implementation of WatcherService.

Since:
v4.2

Constructor Summary
DefaultWatcherService(ApplicationProperties applicationProperties, I18nBean i18n, PermissionManager permissionManager, WatcherManager watcherManager, UserManager userManager)
          Creates a new DefaultWatcherService with the given dependencies.
 
Method Summary
 ServiceOutcome<java.util.List<com.opensymphony.user.User>> addWatcher(Issue issue, com.opensymphony.user.User remoteUser, com.opensymphony.user.User watcher)
          Adds a watcher to an issue's list of watchers, returning the updated list of watchers.
protected  boolean canEditWatcherList(Issue issue, com.opensymphony.user.User remoteUser)
          Returns true iff the given User has permission to edit the watcher list of the issue.
protected  java.util.List<com.opensymphony.user.User> getCurrentWatchersFor(Issue issue)
          Returns a List containing the users that are currently watching an issue.
 ServiceOutcome<Pair<java.lang.Integer,java.util.List<com.opensymphony.user.User>>> getWatchers(Issue issue, com.opensymphony.user.User remoteUser)
          Returns a the total number of watchers for a given issue in the first element of the returned Pair, and the list of visible watchers in the second element of the Pair.
 boolean hasViewWatcherListPermission(Issue issue, com.opensymphony.user.User remoteUser)
          Returns true iff the given User has permission to view the watcher list of the issue.
 boolean isWatchingEnabled()
          Returns true iff watching is enabled.
 ServiceOutcome<java.util.List<com.opensymphony.user.User>> removeWatcher(Issue issue, com.opensymphony.user.User remoteUser, com.opensymphony.user.User watcher)
          Removes a watcher from an issue's list of watchers, returning the updated list of watchers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWatcherService

public DefaultWatcherService(ApplicationProperties applicationProperties,
                             I18nBean i18n,
                             PermissionManager permissionManager,
                             WatcherManager watcherManager,
                             UserManager userManager)
Creates a new DefaultWatcherService with the given dependencies.

Parameters:
applicationProperties - an ApplicationProperties
i18n - a I18nBean
permissionManager - a PermissionManager
watcherManager - a WatcherManager
userManager - a UserManager
Method Detail

getWatchers

public ServiceOutcome<Pair<java.lang.Integer,java.util.List<com.opensymphony.user.User>>> getWatchers(Issue issue,
                                                                                                      @Nullable
                                                                                                      com.opensymphony.user.User remoteUser)
                                                                                               throws WatchingDisabledException
Description copied from interface: WatcherService
Returns a the total number of watchers for a given issue in the first element of the returned Pair, and the list of visible watchers in the second element of the Pair. Note that if the remote user does not have permission to view the list of watchers, it is possible for the number of elements in the returned user list to be less than the returned number of watchers.

Specified by:
getWatchers in interface WatcherService
Parameters:
issue - the Issue to find watchers for
remoteUser - the calling User
Returns:
a ServiceOutcome containing the total number of watchers, and a list of visible watchers
Throws:
WatchingDisabledException - if watching is currently disabled

addWatcher

public ServiceOutcome<java.util.List<com.opensymphony.user.User>> addWatcher(Issue issue,
                                                                             com.opensymphony.user.User remoteUser,
                                                                             com.opensymphony.user.User watcher)
                                                                      throws WatchingDisabledException
Description copied from interface: WatcherService
Adds a watcher to an issue's list of watchers, returning the updated list of watchers.

Specified by:
addWatcher in interface WatcherService
Parameters:
issue - the issue to update
remoteUser - the remote user on behalf of which
watcher - the watcher to add
Returns:
a ServiceOutcome containing a list of User
Throws:
WatchingDisabledException - if watching is currently disabled

removeWatcher

public ServiceOutcome<java.util.List<com.opensymphony.user.User>> removeWatcher(Issue issue,
                                                                                com.opensymphony.user.User remoteUser,
                                                                                com.opensymphony.user.User watcher)
                                                                         throws WatchingDisabledException
Description copied from interface: WatcherService
Removes a watcher from an issue's list of watchers, returning the updated list of watchers.

Specified by:
removeWatcher in interface WatcherService
Parameters:
issue - the Issue to update
remoteUser - a User indicating the user on behalf of whom this operation is being performed
watcher - a User representing the User to remove from the watcher list
Returns:
a ServiceOutcome containing a list of User
Throws:
WatchingDisabledException - if watching is currently disabled

isWatchingEnabled

public boolean isWatchingEnabled()
Returns true iff watching is enabled.

Specified by:
isWatchingEnabled in interface WatcherService
Returns:
true iff watching is enabled

hasViewWatcherListPermission

public boolean hasViewWatcherListPermission(Issue issue,
                                            @Nullable
                                            com.opensymphony.user.User remoteUser)
Returns true iff the given User has permission to view the watcher list of the issue.

Specified by:
hasViewWatcherListPermission in interface WatcherService
Parameters:
issue - an Issue
remoteUser - a User
Returns:
a boolean indicating whether the user can view the watch list

getCurrentWatchersFor

protected java.util.List<com.opensymphony.user.User> getCurrentWatchersFor(Issue issue)
Returns a List containing the users that are currently watching an issue.

Parameters:
issue - the Issue to get the watcher list for
Returns:
a List of users that are watching the issue

canEditWatcherList

protected boolean canEditWatcherList(Issue issue,
                                     @Nullable
                                     com.opensymphony.user.User remoteUser)
Returns true iff the given User has permission to edit the watcher list of the issue.

Parameters:
issue - an Issue
remoteUser - a User
Returns:
a boolean indicating whether the user can edit the watch list


Copyright © 2002-2010 Atlassian. All Rights Reserved.