Clearspace API (2.5.18) Core Javadocs

com.jivesoftware.community
Interface CommentManager

All Superinterfaces:
JiveManager

public interface CommentManager
extends JiveManager

Handles comments for a JiveObject.

Comments can be nested in a tree structure to allow for the promotions of discussions on an object. There are two options for navigating through the comments to an object:


Field Summary
static int COMMENTS_CLOSED
          Comment status for documents that may have allowed comments in the past but presently do not accept comments.
static int COMMENTS_DEFAULT
          The default comment status for a document.
static int COMMENTS_MODERATED
          Comments must be approved by the owner
static int COMMENTS_NONE
          Comment status for documents that do not accept comments.
static int COMMENTS_OPEN
          Comment status for documents that do accept comments.
 
Method Summary
 void addComment(CommentContentResource commentContentResource, Comment newComment)
          Adds a new comment (no parent) to the object.
 void addComment(CommentContentResource commentContentResource, Comment parentComment, Comment newComment)
          Adds a new comment having a parent comment to the object.
 void approve(Comment comment, AuthToken auth)
           
 Comment createComment(CommentContentResource commentContentResource, User user, Document body)
          Create a new comment.
 Comment createComment(CommentContentResource commentContentResource, User user, String body)
          Create a new comment.
 Image createImage(Comment comment, String name, String contentType, InputStream data)
           
 void deleteAllComments(CommentContentResource commentContentResource)
          Deletes all comments on the object.
 void deleteComment(CommentContentResource commentContentResource, Comment comment)
          Deletes a comment in the object.
 void deleteComment(CommentContentResource commentContentResource, Comment comment, boolean recursive)
          Deletes a comment in the object.
 void deleteImage(Comment comment, Image image)
           
 void deleteUserComments(User user)
          Deletes all comments authored by the the given user.
 Comment getComment(CommentContentResource commentContentResource, long commentID)
          Returns a comment from the object based on its id.
 Comment getComment(long commentID)
          Returns a comment from the object based on its id.
 CommentContentResource getCommentContentResource(Comment comment)
          Returns the parent CommentContentResource of the comment.
 int getCommentCount(CommentContentResource commentContentResource)
          Returns the number of comments in the object.
 int getCommentCount(CommentContentResource commentContentResource, CommentResultFilter resultFilter)
          Returns the number of comments in the object based on the specified ResultFilter.
 JiveIterator<Comment> getComments(CommentContentResource commentContentResource)
          Returns an iterable for all the comments in the object.
 JiveIterator<Comment> getComments(CommentContentResource commentContentResource, CommentResultFilter resultFilter)
          Returns an Iterable for all the comments in the object that match the criteria specified by the ResultFilter.
 Date getCommentsCreationDate(CommentContentResource commentContentResource)
          Convenience method that return the date that the first comment was created.
 Date getCommentsModificationDate(CommentContentResource commentContentResource)
          Convenience method that returns the date of the latest comment modification in the object.
 CommentTreeWalker getCommentTreeWalker(CommentContentResource commentContentResource)
          Returns a CommentTreeWalker for the comments in the object.
 int getUserContentCommentCount(User user)
          Returns a count of all the comments in all content which has been authored by the supplied user.
 int getUserContentCommentCount(User user, UserContentCommentResultFilter resultFilter)
          Returns a count of all the comments in all content which has been authored by the supplied user that match the criteria specified by the ResultFilter.
 JiveIterator<Comment> getUserContentComments(User user)
          Returns a JiveIterator for all the comments in all content which has been authored by the supplied user.
 JiveIterator<Comment> getUserContentComments(User user, UserContentCommentResultFilter resultFilter)
          Returns a JiveIterator for all the comments in all content which has been authored by the supplied user that match the criteria specified by the ResultFilter.
 void setBody(Comment comment, String body)
           
 void setModerated(Comment comment, boolean moderated)
           
 void update(Comment comment)
          Updates an existing comment.
 void updateComment(CommentContentResource commentContentResource, Comment comment)
          Updates an existing comment.
 
Methods inherited from interface com.jivesoftware.community.JiveManager
destroy
 

Field Detail

COMMENTS_NONE

static final int COMMENTS_NONE
Comment status for documents that do not accept comments.

See Also:
Constant Field Values

COMMENTS_OPEN

static final int COMMENTS_OPEN
Comment status for documents that do accept comments.

See Also:
Constant Field Values

COMMENTS_CLOSED

static final int COMMENTS_CLOSED
Comment status for documents that may have allowed comments in the past but presently do not accept comments.

See Also:
Constant Field Values

COMMENTS_MODERATED

static final int COMMENTS_MODERATED
Comments must be approved by the owner

See Also:
Constant Field Values

COMMENTS_DEFAULT

static final int COMMENTS_DEFAULT
The default comment status for a document.

See Also:
Constant Field Values
Method Detail

getCommentCount

int getCommentCount(CommentContentResource commentContentResource)
Returns the number of comments in the object.

Parameters:
commentContentResource - the CommentContentResource to get a comment count for.
Returns:
the number of comments in the object.

getCommentCount

int getCommentCount(CommentContentResource commentContentResource,
                    CommentResultFilter resultFilter)
Returns the number of comments in the object based on the specified ResultFilter. This is useful for determining such things as the number of comments in a date range, etc.

Parameters:
commentContentResource - the CommentContentResource to get a comment count for.
resultFilter - a resultFilter to limit the query on.
Returns:
the number of comments in the object based on the filter.

getComments

JiveIterator<Comment> getComments(CommentContentResource commentContentResource)
Returns an iterable for all the comments in the object.

Parameters:
commentContentResource - the CommentContentResource to get comments for.
Returns:
an iterable for the comments in the object.

getComments

JiveIterator<Comment> getComments(CommentContentResource commentContentResource,
                                  CommentResultFilter resultFilter)
Returns an Iterable for all the comments in the object that match the criteria specified by the ResultFilter.

Parameters:
commentContentResource - the CommentContentResource to get comments for.
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterable for the comments in the object that match the ResultFilter.

getCommentTreeWalker

CommentTreeWalker getCommentTreeWalker(CommentContentResource commentContentResource)
Returns a CommentTreeWalker for the comments in the object. A CommentTreeWalker is used to navigate through the tree of comments in a hierarchical manner.

Parameters:
commentContentResource - the CommentContentResource to get a tree walker for.
Returns:
a CommentTreeWalker for the comments in the object.

getCommentsCreationDate

Date getCommentsCreationDate(CommentContentResource commentContentResource)
Convenience method that return the date that the first comment was created.

Parameters:
commentContentResource - the CommentContentResource to get creation date for.
Returns:
the date that the first comment was created.

getCommentsModificationDate

Date getCommentsModificationDate(CommentContentResource commentContentResource)
Convenience method that returns the date of the latest comment modification in the object.

Parameters:
commentContentResource - the CommentContentResource to get a modification date for.
Returns:
the date of the latest comment modification in the object.

getComment

Comment getComment(long commentID)
                   throws CommentNotFoundException
Returns a comment from the object based on its id.

Parameters:
commentID - the ID of the comment to get from the object.
Returns:
a comment from the object based on its id.
Throws:
CommentNotFoundException - if the commentID can't be found and/or doesn't belong to the object.
UnauthorizedException - if the user doesn't have permissions to view the comment.

getCommentContentResource

CommentContentResource getCommentContentResource(Comment comment)
Returns the parent CommentContentResource of the comment.

Returns:
the parent CommentContentResource which contains the comment.

getComment

Comment getComment(CommentContentResource commentContentResource,
                   long commentID)
                   throws CommentNotFoundException,
                          UnauthorizedException
Returns a comment from the object based on its id.

Parameters:
commentContentResource - the CommentContentResource to get the comment for.
commentID - the ID of the comment to get from the object.
Returns:
a comment from the object based on its id.
Throws:
CommentNotFoundException - if the commentID can't be found and/or doesn't belong to the object.
UnauthorizedException - if the user doesn't have permissions to view the comment.

addComment

void addComment(CommentContentResource commentContentResource,
                Comment newComment)
                throws RejectedException,
                       UnauthorizedException
Adds a new comment (no parent) to the object.

Parameters:
commentContentResource - the CommentContentResource to add the comment to.
newComment - comment to add to the object.
Throws:
RejectedException - if one of the installed interceptors prevents the comment from being posted.
UnauthorizedException - if user does not have CREATE_COMMENT permissions.
IllegalStateException - if the object hasn't yet been added to a community.

addComment

void addComment(CommentContentResource commentContentResource,
                Comment parentComment,
                Comment newComment)
                throws RejectedException,
                       UnauthorizedException
Adds a new comment having a parent comment to the object.

Parameters:
commentContentResource - the CommentContentResource to add the comment to.
parentComment - the comment in the object that will be the parent to the new comment.
newComment - comment to add to the object under the parent.
Throws:
RejectedException - if one of the installed interceptors prevents the comment from being posted.
UnauthorizedException - if user does not have CREATE_COMMENT permissions.
IllegalStateException - if the object hasn't yet been added to a community.

createComment

Comment createComment(CommentContentResource commentContentResource,
                      User user,
                      String body)
                      throws UnauthorizedException,
                             RejectedException
Create a new comment. If the user is null the comment will be anonymous.

Parameters:
commentContentResource - the CommentContentResource to create a comment for.
user - the author of the comment.
body - the body of the comment.
Returns:
a Comment object.
Throws:
UnauthorizedException - if user does not have permissions.
RejectedException - if the comment status for this object is not COMMENTS_OPEN

createComment

Comment createComment(CommentContentResource commentContentResource,
                      User user,
                      Document body)
                      throws UnauthorizedException,
                             RejectedException
Create a new comment. If the user is null the comment will be anonymous.

Parameters:
commentContentResource - the CommentContentResource to create a comment for.
user - the author of the comment.
body - the body of the comment.
Returns:
a Comment object.
Throws:
UnauthorizedException - if user does not have permissions.
RejectedException - if the comment status for this object is not COMMENTS_OPEN

updateComment

void updateComment(CommentContentResource commentContentResource,
                   Comment comment)
                   throws UnauthorizedException
Updates an existing comment.

Parameters:
commentContentResource - the CommentContentResource to which the comment belongs.
comment - the updated comment
Throws:
UnauthorizedException - if the user does not have permissions

update

void update(Comment comment)
            throws UnauthorizedException
Updates an existing comment.

Parameters:
comment - the updated comment
Throws:
UnauthorizedException - if the user does not have permissions

setBody

void setBody(Comment comment,
             String body)

setModerated

void setModerated(Comment comment,
                  boolean moderated)

approve

void approve(Comment comment,
             AuthToken auth)
             throws UnauthorizedException
Throws:
UnauthorizedException

deleteComment

void deleteComment(CommentContentResource commentContentResource,
                   Comment comment)
                   throws UnauthorizedException
Deletes a comment in the object. Deleting a comment also deletes all of its children comments. The search index and other resources that referenced the comment and its children will also be updated appropriately.

Parameters:
commentContentResource - the CommentContentResource to which the comment belongs.
comment - the comment to delete
Throws:
IllegalArgumentException - if the comment does not belong to the object.
UnauthorizedException - if user does not have administrator permissions.

deleteComment

void deleteComment(CommentContentResource commentContentResource,
                   Comment comment,
                   boolean recursive)
                   throws UnauthorizedException
Deletes a comment in the object. The search index and other resources that referenced the comment will also be updated appropriately.

Parameters:
commentContentResource - the CommentContentResource to which the comment belongs.
comment - the comment to delete
recursive - true to delete all the child comments, false to leave the children.
Throws:
IllegalArgumentException - if the comment does not belong to the object.
UnauthorizedException - if user does not have administrator permissions.

deleteAllComments

void deleteAllComments(CommentContentResource commentContentResource)
                       throws UnauthorizedException
Deletes all comments on the object.

Parameters:
commentContentResource - the CommentContentResource to delete all comments for.
Throws:
UnauthorizedException - if user does not have administrator permissions.

deleteUserComments

void deleteUserComments(User user)
                        throws UnauthorizedException
Deletes all comments authored by the the given user.

Parameters:
user - the user to delete all comments for.
Throws:
UnauthorizedException - if user does not have system administrator or user administrator permissions.

getUserContentCommentCount

int getUserContentCommentCount(User user)
Returns a count of all the comments in all content which has been authored by the supplied user.

Parameters:
user - the User whose content will be searched for comments.
Returns:
a count of comments.

getUserContentCommentCount

int getUserContentCommentCount(User user,
                               UserContentCommentResultFilter resultFilter)
Returns a count of all the comments in all content which has been authored by the supplied user that match the criteria specified by the ResultFilter.

Parameters:
user - the User whose content will be searched for comments.
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
a count of the comments that match the ResultFilter.

getUserContentComments

JiveIterator<Comment> getUserContentComments(User user)
Returns a JiveIterator for all the comments in all content which has been authored by the supplied user.

Parameters:
user - the User whose content will be searched for comments.
Returns:
a JiveIterator for the comments in the object that match the ResultFilter.

getUserContentComments

JiveIterator<Comment> getUserContentComments(User user,
                                             UserContentCommentResultFilter resultFilter)
Returns a JiveIterator for all the comments in all content which has been authored by the supplied user that match the criteria specified by the ResultFilter.

Parameters:
user - the User whose content will be searched for comments.
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
a JiveIterator for the comments in the object that match the ResultFilter.

createImage

Image createImage(Comment comment,
                  String name,
                  String contentType,
                  InputStream data)
                  throws IllegalStateException,
                         ImageException
Throws:
IllegalStateException
ImageException

deleteImage

void deleteImage(Comment comment,
                 Image image)
                 throws ImageException
Throws:
ImageException

Clearspace Project Page

Copyright © 1999-2007 Jive Software.