com.atlassian.jira.issue.comments
Class DefaultCommentManager

java.lang.Object
  extended by com.atlassian.jira.issue.comments.DefaultCommentManager
All Implemented Interfaces:
CommentManager

public class DefaultCommentManager
extends Object
implements CommentManager


Field Summary
static String COMMENT_ENTITY
           
 
Fields inherited from interface com.atlassian.jira.issue.comments.CommentManager
EVENT_ORIGINAL_COMMENT_PARAMETER
 
Constructor Summary
DefaultCommentManager(IssueManager issueManager, ProjectRoleManager projectRoleManager, CommentPermissionManager commentPermissionManager, OfBizDelegator delegator, JiraAuthenticationContext jiraAuthenticationContext, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator, UserManager userManager)
           
DefaultCommentManager(IssueManager issueManager, ProjectRoleManager projectRoleManager, CommentPermissionManager commentPermissionManager, OfBizDelegator delegator, JiraAuthenticationContext jiraAuthenticationContext, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator, UserManager userManager, JsonEntityPropertyManager jsonEntityPropertyManager, CommentPropertyHelper commentPropertyHelper, CommentSearchManager commentSearchManager)
           
 
Method Summary
 Comment convertToComment(org.ofbiz.core.entity.GenericValue gv)
          This is a convenience method that can be used to convert a GenericValue representation of a comment to a comment object.
 Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent)
           
 Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent, boolean modifyIssueUpdateDate)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, Map<String,JSONObject> commentProperties, boolean dispatchEvent, boolean modifyIssueUpdateDate)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, ApplicationUser author, String body, boolean dispatchEvent)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, Date created, Map<String,JSONObject> commentProperties, boolean dispatchEvent)
          Creates a comment and associates it with the given issue.
 Comment create(Issue issue, String author, String body, boolean dispatchEvent)
           
 Comment create(Issue issue, String author, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent)
           
 Comment create(Issue issue, String author, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent)
           
 Comment create(Issue issue, String author, String updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent)
           
 Comment create(Issue issue, String author, String updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent, boolean modifyIssueUpdateDate)
           
 ChangeItemBean delete(Comment comment)
          Deletes the specified comment.
 Comment getCommentById(Long commentId)
          Will return a comment for the passed in commentId.
 List<Comment> getComments(Issue issue)
          This will return all comments for a given issue.
 List<Comment> getCommentsForUser(Issue issue, ApplicationUser user)
          Retrieves all Comments on the given Issue that the given ApplicationUser has permission to see.
 List<Comment> getCommentsForUser(Issue issue, com.atlassian.crowd.embedded.api.User user)
           
 long getCountForCommentsRestrictedByGroup(String groupName)
          Returns the count of all Comment's that have their visibility restricted by the named group.
 MutableComment getMutableComment(Long commentId)
          Retrieves comment by given id and returns it as mutable object.
 ProjectRole getProjectRole(Long projectRoleId)
          This is a convenience method to allow us to easily get a ProjectRole.
 boolean isUserCommentAuthor(ApplicationUser user, Comment comment)
          Returns true if the given user is the author of the given comment.
 boolean isUserCommentAuthor(com.atlassian.crowd.embedded.api.User user, Comment comment)
           
 int swapCommentGroupRestriction(String groupName, String swapGroup)
          Updates Comment's such that comments that have a visibility restriction of the provided groupName will be changed to have a visibility restriction of the provided swapGroup.
 void update(Comment comment, boolean dispatchEvent)
          Persists the updated comment.
 void update(Comment comment, Map<String,JSONObject> commentProperties, boolean dispatchEvent)
          Persists the updated comment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMENT_ENTITY

public static final String COMMENT_ENTITY
See Also:
Constant Field Values
Constructor Detail

DefaultCommentManager

public DefaultCommentManager(IssueManager issueManager,
                             ProjectRoleManager projectRoleManager,
                             CommentPermissionManager commentPermissionManager,
                             OfBizDelegator delegator,
                             JiraAuthenticationContext jiraAuthenticationContext,
                             TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
                             UserManager userManager)

DefaultCommentManager

public DefaultCommentManager(IssueManager issueManager,
                             ProjectRoleManager projectRoleManager,
                             CommentPermissionManager commentPermissionManager,
                             OfBizDelegator delegator,
                             JiraAuthenticationContext jiraAuthenticationContext,
                             TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
                             UserManager userManager,
                             JsonEntityPropertyManager jsonEntityPropertyManager,
                             CommentPropertyHelper commentPropertyHelper,
                             CommentSearchManager commentSearchManager)
Method Detail

getProjectRole

public ProjectRole getProjectRole(Long projectRoleId)
Description copied from interface: CommentManager
This is a convenience method to allow us to easily get a ProjectRole. This is being used by the CommentImpl to get a ProjectRole.

NOTE: If you are trying to retrieve a ProjectRole then you should be using the ProjectRoleManager.

Specified by:
getProjectRole in interface CommentManager
Parameters:
projectRoleId - the id to the ProjectRole object you would like returned.
Returns:
will return a ProjectRole based on the passed in projectRoleId.

convertToComment

public Comment convertToComment(org.ofbiz.core.entity.GenericValue gv)
Description copied from interface: CommentManager
This is a convenience method that can be used to convert a GenericValue representation of a comment to a comment object.

Specified by:
convertToComment in interface CommentManager
Parameters:
gv - is the GenericValue representation of a comment.
Returns:
Comment object.

getCommentById

public Comment getCommentById(Long commentId)
Description copied from interface: CommentManager
Will return a comment for the passed in commentId.

Specified by:
getCommentById in interface CommentManager
Parameters:
commentId - the id representing the Comment you would like to retrieve.
Returns:
a Comment or null (if the user cannot browse the comment).

getMutableComment

public MutableComment getMutableComment(Long commentId)
Description copied from interface: CommentManager
Retrieves comment by given id and returns it as mutable object.

Specified by:
getMutableComment in interface CommentManager
Parameters:
commentId - comment id
Returns:
mutable comment or null if comment with given id not found

getCommentsForUser

public List<Comment> getCommentsForUser(Issue issue,
                                        ApplicationUser user)
Description copied from interface: CommentManager
Retrieves all Comments on the given Issue that the given ApplicationUser has permission to see. If the passed in user is null, only comments with no permission level set will be returned.

NOTE: keep in mind null user represents an anonymous i.e. non-logged in user.

Specified by:
getCommentsForUser in interface CommentManager
Parameters:
issue - the comments are associated with.
user - the user whose permission level will be used to limit the comments returned.
Returns:
Possibly empty List of Comments

getCommentsForUser

public List<Comment> getCommentsForUser(Issue issue,
                                        com.atlassian.crowd.embedded.api.User user)
Specified by:
getCommentsForUser in interface CommentManager
Parameters:
issue - the comments are associated with.
user - the user whose permission level will be used to limit the comments returned.
Returns:
Possibly empty List of Comments

getComments

public List<Comment> getComments(Issue issue)
Description copied from interface: CommentManager
This will return all comments for a given issue. Please note that this method does not perform any permission checks on the returned comments. If you are returning comments to the UI or service for a given User please use CommentManager.getCommentsForUser(com.atlassian.jira.issue.Issue, com.atlassian.jira.user.ApplicationUser))}

Specified by:
getComments in interface CommentManager
Parameters:
issue - the comments are associated with.
Returns:
a List of comments, will return an empty list if none found.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      String body,
                      boolean dispatchEvent)
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the current date/time and with no visibility restrictions.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      String author,
                      String body,
                      boolean dispatchEvent)
Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      boolean dispatchEvent)
               throws DataAccessException
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the current time. If you have provided a groupLevel then the comment visibility will be restricted to the provided group, it is assumed that validation to ensure that the group actually exists has been performed outside of this method. If you have provided a roleLevelId then the comment visibility will be restricted to the provided role, it is assumed that validation to ensure that the role actually exists has been performed outside of this method.

NOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.
Throws:
DataAccessException

create

public Comment create(Issue issue,
                      String author,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      boolean dispatchEvent)
Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      boolean dispatchEvent)
               throws DataAccessException
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the specified date. This method should be used if you are trying to preserve existing information and it is important to retain the original created date. If you have provided a groupLevel then the comment visibility will be restricted to the provided group, it is assumed that validation to ensure that the group actually exists has been performed outside of this method. If you have provided a roleLevelId then the comment visibility will be restricted to the provided role, it is assumed that validation to ensure that the role actually exists has been performed outside of this method.

NOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.
Throws:
DataAccessException

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Map<String,JSONObject> commentProperties,
                      boolean dispatchEvent)
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the specified date. This method should be used if you are trying to preserve existing information and it is important to retain the original created date. If you have provided a groupLevel then the comment visibility will be restricted to the provided group, it is assumed that validation to ensure that the group actually exists has been performed outside of this method. If you have provided a roleLevelId then the comment visibility will be restricted to the provided role, it is assumed that validation to ensure that the role actually exists has been performed outside of this method.

NOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
commentProperties - Comment properties that should be attached to the created comment before the comment can be considered 'created'. May be null.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      String author,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      boolean dispatchEvent)
Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      ApplicationUser updateAuthor,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Date updated,
                      boolean dispatchEvent)
               throws DataAccessException
Specified by:
create in interface CommentManager
Throws:
DataAccessException

create

public Comment create(Issue issue,
                      String author,
                      String updateAuthor,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Date updated,
                      boolean dispatchEvent)
Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
updateAuthor - the key of the user who has updated this comment last
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
updated - is the date that will be used as the comments updated date.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      ApplicationUser updateAuthor,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Date updated,
                      boolean dispatchEvent,
                      boolean modifyIssueUpdateDate)
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the specified date. This method should be used if you are trying to preserve existing information and it is important to retain the original created date. If you have provided a groupLevel then the comment visibility will be restricted to the provided group, it is assumed that validation to ensure that the group actually exists has been performed outside of this method. If you have provided a roleLevelId then the comment visibility will be restricted to the provided role, it is assumed that validation to ensure that the role actually exists has been performed outside of this method.

NOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
updateAuthor - the key of the user who has updated this comment last
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
updated - is the date that will be used as the comments updated date.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the given date is earlier than the current issue update date).
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      ApplicationUser author,
                      ApplicationUser updateAuthor,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Date updated,
                      Map<String,JSONObject> commentProperties,
                      boolean dispatchEvent,
                      boolean modifyIssueUpdateDate)
Description copied from interface: CommentManager
Creates a comment and associates it with the given issue. Using this method the comment will be created with a createdDate of the specified date. This method should be used if you are trying to preserve existing information and it is important to retain the original created date. If you have provided a groupLevel then the comment visibility will be restricted to the provided group, it is assumed that validation to ensure that the group actually exists has been performed outside of this method. If you have provided a roleLevelId then the comment visibility will be restricted to the provided role, it is assumed that validation to ensure that the role actually exists has been performed outside of this method.

NOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.

Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
updateAuthor - the key of the user who has updated this comment last
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
updated - is the date that will be used as the comments updated date.
commentProperties - Comment properties that should be attached to the created comment before the comment can be considered 'created'
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the given date is earlier than the current issue update date).
Returns:
the object representation of the newly created comment.

create

public Comment create(Issue issue,
                      String author,
                      String updateAuthor,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      Date updated,
                      boolean dispatchEvent,
                      boolean modifyIssueUpdateDate)
Specified by:
create in interface CommentManager
Parameters:
issue - the issue to associate the comment with.
author - the key of the user who has created this comment.
updateAuthor - the key of the user who has updated this comment last
body - the text of the comment.
groupLevel - is the group name to limit comment visibility to, this must be a valid group name.
roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a valid project role.
created - is the date that will be used as the comments creation date.
updated - is the date that will be used as the comments updated date.
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the given date is earlier than the current issue update date).
Returns:
the object representation of the newly created comment.

update

public void update(Comment comment,
                   boolean dispatchEvent)
Description copied from interface: CommentManager
Persists the updated comment.

Specified by:
update in interface CommentManager
Parameters:
comment - to update
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.

update

public void update(Comment comment,
                   Map<String,JSONObject> commentProperties,
                   boolean dispatchEvent)
Description copied from interface: CommentManager
Persists the updated comment.

Specified by:
update in interface CommentManager
Parameters:
comment - to update
commentProperties - Comment properties that should be attached to the created comment before the comment can be considered 'created'
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.

delete

public ChangeItemBean delete(Comment comment)
Description copied from interface: CommentManager
Deletes the specified comment.

Specified by:
delete in interface CommentManager
Parameters:
comment - to delete
Returns:
a change item that represents the change of deleting the comment

isUserCommentAuthor

public boolean isUserCommentAuthor(ApplicationUser user,
                                   Comment comment)
Description copied from interface: CommentManager
Returns true if the given user is the author of the given comment.

If the given Comment has a null author, this represents that it was created anonymously, and no-one is the author (returns false). If the given User is null, then this represents that the current user is anonymous, and the method will always return false.

Specified by:
isUserCommentAuthor in interface CommentManager
Parameters:
user - The User. Can be null to represent current user is not logged in (anonymous).
comment - The Comment. Cannot be null.
Returns:
true if the given user is the author of the given comment.

isUserCommentAuthor

public boolean isUserCommentAuthor(com.atlassian.crowd.embedded.api.User user,
                                   Comment comment)
Specified by:
isUserCommentAuthor in interface CommentManager
Parameters:
user - The User. Can be null to represent current user is not logged in (anonymous).
comment - The Comment. Cannot be null.
Returns:
true if the given user is the author of the given comment.

swapCommentGroupRestriction

public int swapCommentGroupRestriction(String groupName,
                                       String swapGroup)
Description copied from interface: CommentManager
Updates Comment's such that comments that have a visibility restriction of the provided groupName will be changed to have a visibility restriction of the provided swapGroup. Note: There is no validation performed by this method to determine if the provided swapGroup is a valid group with JIRA. This validation must be done by the caller.

Specified by:
swapCommentGroupRestriction in interface CommentManager
Parameters:
groupName - identifies the group the comments are restricted by, this must not be null.
swapGroup - identifies the group the comments will be changed to be restricted by, this must not be null.
Returns:
tbe number of comments affected by the update.

getCountForCommentsRestrictedByGroup

public long getCountForCommentsRestrictedByGroup(String groupName)
Description copied from interface: CommentManager
Returns the count of all Comment's that have their visibility restricted by the named group.

Specified by:
getCountForCommentsRestrictedByGroup in interface CommentManager
Parameters:
groupName - identifies the group the comments are restricted by, this must not be null.
Returns:
a count of Comment's who's visibility are restricted by the passed in group name.


Copyright © 2002-2014 Atlassian. All Rights Reserved.