@PublicApi public interface

VoteService

com.atlassian.jira.bc.issue.vote.VoteService
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

Vote Service used to add and remove votes from a particular issue. This service's methods will make sure that when voting, all of JIRA's business rules are enforced. This means that permissions and data validation will be checked.

Summary

Nested Classes
class VoteService.VoteValidationResult A simple validation result that holds the user trying to vote, and the issue being voted on. 
Public Methods
int addVote(ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult)
Adds a new vote using the specified validation result.
ServiceOutcome<List<VoteHistoryEntry>> getVoterHistory(Issue issue, ApplicationUser remoteUser)
Get the list of vote history for an issue.
boolean hasVoted(Issue issue, ApplicationUser user)
Find if the specified user has voted on an issue
boolean isVotingEnabled()
Retrieves the 'jira.option.voting' property
int removeVote(ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult)
Removes a new vote using the specified validation result.
VoteService.VoteValidationResult validateAddVote(ApplicationUser remoteUser, ApplicationUser user, Issue issue)
Validates if the user currently logged in may add a vote by the user supplied for the issue provided.
VoteService.VoteValidationResult validateRemoveVote(ApplicationUser remoteUser, ApplicationUser user, Issue issue)
Validates if the user currently logged in may remove a vote for the user supplied for the issue provided.
ServiceOutcome<Collection<ApplicationUser>> viewVoters(Issue issue, ApplicationUser remoteUser)
Get the list of all users who have voted on an issue.

Public Methods

public int addVote (ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult)

Adds a new vote using the specified validation result. The vote will not be added if the user already voted for the issue.

Parameters
remoteUser The currently logged in user
validationResult Validation result for adding a new vote
Returns
  • The updated number of votes for the issue being voted for

public ServiceOutcome<List<VoteHistoryEntry>> getVoterHistory (Issue issue, ApplicationUser remoteUser)

Get the list of vote history for an issue. The history will be in time sequence.

Parameters
issue the issue to view
remoteUser the user who wants to know
Returns
  • a service outcome. if valid you can obtain the users that have voted on the.

public boolean hasVoted (Issue issue, ApplicationUser user)

Find if the specified user has voted on an issue

Parameters
issue the issue to check
user the user to check
Returns
  • true if the user has voted on the issue

public boolean isVotingEnabled ()

Retrieves the 'jira.option.voting' property

Returns
  • True if voting is enabled

public int removeVote (ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult)

Removes a new vote using the specified validation result. The vote will not be removed if the user didn't voted for the issue.

Parameters
remoteUser The currently logged in user
validationResult Validation result for removing a new vote
Returns
  • The updated number of votes for the issue being voted for

public VoteService.VoteValidationResult validateAddVote (ApplicationUser remoteUser, ApplicationUser user, Issue issue)

Validates if the user currently logged in may add a vote by the user supplied for the issue provided. The remoteUser and user arguments may be the same if the current user is voting him/herself. The VoteService.VoteValidationResult produced by this method should be used in conjunction with the addVote(ApplicationUser, VoteValidationResult) method. The following conditions will fail validation:

  • remoteUser is null (i.e. not logged in)
  • the user is the reporter of the issue
  • the issue has already been resolved
  • voting has been disabled system wide
  • the user doesn't have permission to browse the issue

Parameters
remoteUser The currently logged in user
user The user for whom a vote is being added
issue The issue being voted on
Returns
  • A validation result containing all errors, as well as the user and issue being voted on

public VoteService.VoteValidationResult validateRemoveVote (ApplicationUser remoteUser, ApplicationUser user, Issue issue)

Validates if the user currently logged in may remove a vote for the user supplied for the issue provided. The remoteUser and user arguments may be the same if the current user is voting him/herself. The VoteService.VoteValidationResult produced by this method should be used in conjunction with the removeVote(ApplicationUser, VoteValidationResult) method. The following conditions will fail validation:

  • remoteUser is null (i.e. not logged in)
  • the user is the reporter of the issue
  • the issue has already been resolved
  • voting has been disabled system wide
  • the user doesn't have permission to browse the issue

Parameters
remoteUser The currently logged in user
user The user for whom a vote is being removed
issue The issue being voted on
Returns
  • A validation result containing all errors, as well as the user and issue being voted on

public ServiceOutcome<Collection<ApplicationUser>> viewVoters (Issue issue, ApplicationUser remoteUser)

Get the list of all users who have voted on an issue.

Parameters
issue the issue to view
remoteUser the user who wants to know
Returns
  • a service outcome. if valid you can obtain the users that have voted on the.