@PublicApi @ParametersAreNonnullByDefault public interface

WatcherManager

com.atlassian.jira.issue.watchers.WatcherManager
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Allows watching of issues. I.e.: Users watching an issue will receive notifications for every update of the issue.

Summary

Public Methods
List<String> getCurrentWatcherUsernames(Issue issue)
Retrieve the list of usernames of users watching the given issue
int getWatcherCount(Issue issue)
Returns the number of users watching this issue.
Collection<String> getWatcherUserKeys(Issue issue)
Retrieve list of users that are currently watching this issue (including the current user).
List<ApplicationUser> getWatchers(Issue issue, Locale userLocale)
Retrieve list of users that are currently watching this issue (including the current user).
boolean isWatching(ApplicationUser user, Issue issue)
Determine whether the current user is already watching the issue or not
boolean isWatchingEnabled()
void removeAllWatchesForUser(ApplicationUser user)
Remove all watches for a given user
@Nonnull Collection<Issue> startWatching(ApplicationUser user, Collection<Issue> issues, Context taskContext)
Enable watching of a list of issues for the user supplied.
@Nonnull Issue startWatching(ApplicationUser user, Issue issue)
Enable watching of a particular issue for the user supplied.
@Nonnull Issue stopWatching(ApplicationUser user, Issue issue)
Disable watching of a particular issue for the user supplied.
@Nonnull Collection<Issue> stopWatching(ApplicationUser user, Collection<Issue> issues, Context taskContext)
Disable watching of a list of issues for the user supplied.

Public Methods

public List<String> getCurrentWatcherUsernames (Issue issue)

Retrieve the list of usernames of users watching the given issue

Parameters
issue issue being watched
Returns
  • the list of usernames of users watching the given issue
Throws
DataAccessException if cannot retrieve watchers

public int getWatcherCount (Issue issue)

Returns the number of users watching this issue.

Parameters
issue issue being watched
Returns
  • the number of users watching this issue.

public Collection<String> getWatcherUserKeys (Issue issue)

Retrieve list of users that are currently watching this issue (including the current user).

Parameters
issue issue being watched
Returns
  • list of users that are currently watching this issue (including the current user)

public List<ApplicationUser> getWatchers (Issue issue, Locale userLocale)

Retrieve list of users that are currently watching this issue (including the current user).

Parameters
issue issue being watched
userLocale the locale of the user making this call, this is used for sorting the list values.
Returns
  • list of users that are currently watching this issue (including the current user)

public boolean isWatching (ApplicationUser user, Issue issue)

Determine whether the current user is already watching the issue or not

Parameters
user user
issue issue being watched
Returns
  • True if a user is watching the issue specified.

public boolean isWatchingEnabled ()

public void removeAllWatchesForUser (ApplicationUser user)

Remove all watches for a given user

Parameters
user The user that has most probably been deleted

@Nonnull public Collection<Issue> startWatching (ApplicationUser user, Collection<Issue> issues, Context taskContext)

Enable watching of a list of issues for the user supplied.

This means the user will receive updates for any modifications to the issues. Note, that this will not check if a user has the BROWSE_ISSUE permission. Notifications will however only be sent to users who have the appropriate permissions. Adding a permission check here would complicate updating permission schemes a lot, as it would have to update issues' watchers lists.

This bulk method is more performant than calling the single version multiple times, as it indexes the issues in bulk rather than one at a time.

Parameters
user user that starts watching the given issues
issues the list of issues to watch
taskContext a context through which progress can be reported back
Returns
  • the same list of issues (the same order) updated or not

@Nonnull public Issue startWatching (ApplicationUser user, Issue issue)

Enable watching of a particular issue for the user supplied.

This means the user will receive updates for any modifications to the issue. Note, that this will not check if a user has the BROWSE_ISSUE permission. Notifications will however only be sent to users who have the appropriate permissions. Adding a permission check here would complicate updating permission schemes a lot, as it would have to update issue's watchers lists.

Parameters
user user that starts watching the given issue
issue issue being watched
Returns
  • updated issue

@Nonnull public Issue stopWatching (ApplicationUser user, Issue issue)

Disable watching of a particular issue for the user supplied.

Parameters
user user that stops watching the given issue
issue issue being watched

@Nonnull public Collection<Issue> stopWatching (ApplicationUser user, Collection<Issue> issues, Context taskContext)

Disable watching of a list of issues for the user supplied.

This bulk method is more performant than calling the single version multiple times, as it indexes the issues in bulk rather than one at a time.

Parameters
user user that stops watching the given issues
issues list of issues being watched
taskContext a context through which progress can be reported back