Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.proxy
Class RatingManagerProxy

java.lang.Object
  extended by com.jivesoftware.forum.proxy.RatingManagerProxy
All Implemented Interfaces:
RatingManager

public class RatingManagerProxy
extends java.lang.Object
implements RatingManager

A protection proxy for the RatingManager. A proxy has a set of permissions that are specified at creation time of the proxy. Subsequently, those permissions are use to restrict access to protected methods. If a user does not have the right to execute a particular method, an UnauthorizedException is thrown.

See Also:
RatingManager, Permissions, UnauthorizedException

Constructor Summary
RatingManagerProxy(RatingManager ratingManager, Permissions permissions)
          Creates a new RatingManagerProxy object.
 
Method Summary
 void addRating(User user, ForumMessage message, Rating rating)
          Add a rating to the forum message.
 void addRating(User user, ForumThread thread, Rating rating)
          Add a rating to the forum thread.
 Rating createRating(int score, java.lang.String description)
          Create a new rating with the specified attributes.
 int getAvailableRatingCount()
          Returns the count of currently available ratings.
 java.util.Iterator getAvailableRatings()
          Returns an iterator of Rating objects that list all the available ratings.
 double getMeanRating(ForumMessage message)
          A convenience method which returns a geometric mean average of all the ratings given to the forum message.
 double getMeanRating(ForumThread thread)
          A convenience method which returns a geometric mean average of all the ratings given to the forum thread.
 double getMeanRating(long messageID)
          A convenience method which returns a geometric mean average of all the ratings given to the forum message.
 Rating getRating(User user, ForumMessage message)
          Returns the rating associated with the user, or null if this user hasn't rated the forum message.
 Rating getRating(User user, ForumThread thread)
          Returns the rating associated with the user, or null if this user hasn't rated the forum thread.
 int getRatingCount(ForumMessage message)
          Returns the total number of ratings given to the forum message.
 int getRatingCount(ForumThread thread)
          Returns the total number of ratings given to the forum thread.
 Rating getRatingFromScore(int score)
          Retrieve the rating with the specified score.
 java.util.Iterator getRatings(ForumMessage message)
          Returns an Iterator of all the ratings given to the forum message.
 java.util.Iterator getRatings(ForumThread thread)
          Returns an Iterator of all the ratings given to the forum thread.
 boolean hasRated(User user, ForumMessage message)
          Returns whether the user has rated the forum message or not.
 boolean hasRated(User user, ForumThread thread)
          Returns whether the user has rated the forum thread or not.
 boolean isRatingsEnabled()
          Returns true if the rating feature is turned on.
 void removeRating(Rating rating)
          Remove the specified rating from the list of currently available ratings.
 void setRatingsEnabled(boolean ratingsEnabled)
          Enables or disables the ratings feature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RatingManagerProxy

public RatingManagerProxy(RatingManager ratingManager,
                          Permissions permissions)
Creates a new RatingManagerProxy object.

Parameters:
ratingManager - the ratingManager to protect by proxy
permissions - the permissions to use with this proxy
Method Detail

isRatingsEnabled

public boolean isRatingsEnabled()
Description copied from interface: RatingManager
Returns true if the rating feature is turned on. When ratings are disabled, other methods serve as no-ops.

Specified by:
isRatingsEnabled in interface RatingManager
Returns:
true if the ratings are enabled

setRatingsEnabled

public void setRatingsEnabled(boolean ratingsEnabled)
                       throws UnauthorizedException
Description copied from interface: RatingManager
Enables or disables the ratings feature. When ratings are disabled, other methods serve as no-ops.

Specified by:
setRatingsEnabled in interface RatingManager
Parameters:
ratingsEnabled - true to enable the rating feature, false to disable
Throws:
UnauthorizedException - if not a system administrator

getAvailableRatings

public java.util.Iterator getAvailableRatings()
Description copied from interface: RatingManager
Returns an iterator of Rating objects that list all the available ratings. The returned list will be sorted from lowest rating to high rating.

Specified by:
getAvailableRatings in interface RatingManager
Returns:
an iterator of all available ratings

getAvailableRatingCount

public int getAvailableRatingCount()
Description copied from interface: RatingManager
Returns the count of currently available ratings.

Specified by:
getAvailableRatingCount in interface RatingManager
Returns:
a count of currently available ratings

getRatingFromScore

public Rating getRatingFromScore(int score)
Description copied from interface: RatingManager
Retrieve the rating with the specified score.

Specified by:
getRatingFromScore in interface RatingManager
Parameters:
score - the score of the rating to retrieve
Returns:
the corresponding rating, or null if no rating matches

createRating

public Rating createRating(int score,
                           java.lang.String description)
                    throws UnauthorizedException
Description copied from interface: RatingManager
Create a new rating with the specified attributes. Only positive integers are allowed for the score, 0 or negative integers will cause an IllegalArgumentException to be thrown. If the score is already taken an IllegalArgumentException will be thrown.

Specified by:
createRating in interface RatingManager
Parameters:
score - the score or rating level for the new rating
description - the description of the new rating
Returns:
a new Rating object
Throws:
UnauthorizedException - if not a system administrator

removeRating

public void removeRating(Rating rating)
                  throws UnauthorizedException
Description copied from interface: RatingManager
Remove the specified rating from the list of currently available ratings.

Specified by:
removeRating in interface RatingManager
Parameters:
rating - the Rating to remove
Throws:
UnauthorizedException - if not a system administrator

getRatings

public java.util.Iterator getRatings(ForumMessage message)
Description copied from interface: RatingManager
Returns an Iterator of all the ratings given to the forum message.

Specified by:
getRatings in interface RatingManager
Parameters:
message - the forum message to return ratings for
Returns:
an Iterator of all the ratings given to the forum message

getRatings

public java.util.Iterator getRatings(ForumThread thread)
Description copied from interface: RatingManager
Returns an Iterator of all the ratings given to the forum thread. The ratings returned only apply to the thread itself - they do not include ratings for individual messages in the thread.

Specified by:
getRatings in interface RatingManager
Parameters:
thread - the forum thread to return ratings for
Returns:
an Iterator of all the ratings given to the forum thread

getRatingCount

public int getRatingCount(ForumMessage message)
Description copied from interface: RatingManager
Returns the total number of ratings given to the forum message.

Specified by:
getRatingCount in interface RatingManager
Parameters:
message - the forum message to return a rating count for
Returns:
the total number of ratings given to the forum message.

getRatingCount

public int getRatingCount(ForumThread thread)
Description copied from interface: RatingManager
Returns the total number of ratings given to the forum thread. The count returned returned only applies to the thread itself - it does not include ratings for individual messages in the thread.

Specified by:
getRatingCount in interface RatingManager
Parameters:
thread - the forum thread to return a rating count for
Returns:
the total number of ratings given to the forum thread.

getMeanRating

public double getMeanRating(long messageID)
Description copied from interface: RatingManager
A convenience method which returns a geometric mean average of all the ratings given to the forum message.

Specified by:
getMeanRating in interface RatingManager
Returns:
a geometric mean average of all the ratings given to the forum message.

getMeanRating

public double getMeanRating(ForumMessage message)
Description copied from interface: RatingManager
A convenience method which returns a geometric mean average of all the ratings given to the forum message.

Specified by:
getMeanRating in interface RatingManager
Returns:
a geometric mean average of all the ratings given to the forum message.

getMeanRating

public double getMeanRating(ForumThread thread)
Description copied from interface: RatingManager
A convenience method which returns a geometric mean average of all the ratings given to the forum thread. The mean average returned returned only applies to the thread itself - it does not include ratings for individual messages in the thread.

Specified by:
getMeanRating in interface RatingManager
Returns:
a geometric mean average of all the ratings given to the forum thread.

hasRated

public boolean hasRated(User user,
                        ForumMessage message)
Description copied from interface: RatingManager
Returns whether the user has rated the forum message or not. This method will always return false if the user is anonymous.

Specified by:
hasRated in interface RatingManager
Parameters:
user - the user to check
message - the forum message to check
Returns:
true is the user associated with the user has rated the forum message, false otherwise. If the user is anonymous (null) this method will always return false.

hasRated

public boolean hasRated(User user,
                        ForumThread thread)
Description copied from interface: RatingManager
Returns whether the user has rated the forum thread or not. This method will always return false if the user is anonymous.

Specified by:
hasRated in interface RatingManager
Parameters:
user - the user to check
thread - the forum thread to check
Returns:
true is the user associated with the user has rated the forum thread, false otherwise. If the user is anonymous (null) this method will always return false.

getRating

public Rating getRating(User user,
                        ForumMessage message)
Description copied from interface: RatingManager
Returns the rating associated with the user, or null if this user hasn't rated the forum message. If the user is null (anonymous) this method will return null.

Specified by:
getRating in interface RatingManager
Parameters:
user - the user to check
message - the forum message to check
Returns:
the rating the user has given the forum message, or null if the user has not rated the forum message or the user is anonymous.

getRating

public Rating getRating(User user,
                        ForumThread thread)
Description copied from interface: RatingManager
Returns the rating associated with the user, or null if this user hasn't rated the forum thread. If the user is null (anonymous) this method will return null.

Specified by:
getRating in interface RatingManager
Parameters:
user - the user to check
thread - the forum thread to check
Returns:
the rating the user has given the forum thread, or null if the user has not rated the forum thread or the user is anonymous.

addRating

public void addRating(User user,
                      ForumMessage message,
                      Rating rating)
               throws UnauthorizedException
Description copied from interface: RatingManager
Add a rating to the forum message. If the user has already rated, this rating will replace the previous rating. If the user is null (anonymous) this rating will be added to the ratings for the forum message.

The author of the forum message cannot rate their own message.

Specified by:
addRating in interface RatingManager
Parameters:
user - the user rating the forum message
message - the forum message to add the rating to
rating - the rating the user wants to give to the forum message
Throws:
UnauthorizedException - if user does not have permissions

addRating

public void addRating(User user,
                      ForumThread thread,
                      Rating rating)
               throws UnauthorizedException
Description copied from interface: RatingManager
Add a rating to the forum thread. If the user has already rated, this rating will replace the previous rating. If the user is null (anonymous) this rating will be added to the ratings for the forum thread.

Specified by:
addRating in interface RatingManager
Parameters:
user - the user rating the forum thread
thread - the forum thread to add the rating to
rating - the rating the user wants to give to the forum thread
Throws:
UnauthorizedException - if user does not have permissions

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.