com.atlassian.jira.bc.issue.comment
Class DefaultCommentService

java.lang.Object
  extended by com.atlassian.jira.bc.issue.comment.DefaultCommentService
All Implemented Interfaces:
CommentService

public class DefaultCommentService
extends Object
implements CommentService

Default implementation of comment service.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.issue.comment.CommentService
CommentService.CommentCreateValidationResult, CommentService.CommentParameters, CommentService.CommentUpdateValidationResult
 
Field Summary
static String ERROR_BODY_TOOLONG
           
static String ERROR_COMMENT_DELETE_ISSUE_UPDATE_FAILED
           
static String ERROR_COMMENT_DELETE_NO_PERMISSION
           
static String ERROR_COMMENT_DELETE_NON_EDITABLE_ISSUE
           
static String ERROR_COMMENT_EDIT_NON_EDITABLE_ISSUE
           
static String ERROR_NULL_COMMENT
           
static String ERROR_NULL_COMMENT_DELETE
           
static String ERROR_NULL_COMMENT_ID
           
static String ERROR_NULL_COMMENT_ID_DELETE
           
 
Constructor Summary
DefaultCommentService(CommentManager commentManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, ProjectRoleManager projectRoleManager, CommentPermissionManager commentPermissionManager, IssueUpdater issueUpdater, IssueManager issueManager, VisibilityValidator visibilityValidator, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator)
           
 
Method Summary
 Comment create(ApplicationUser applicationUser, CommentService.CommentCreateValidationResult validationResult, boolean dispatchEvent)
          Creates and persists a Comment on given Issue.
 Comment create(ApplicationUser user, Issue issue, String body, boolean dispatchEvent, ErrorCollection errorCollection)
          Creates and persists a Comment on the given Issue set with current date and time, visible to all - no group level or role level restriction.
 Comment create(ApplicationUser user, Issue issue, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent, ErrorCollection errorCollection)
          Creates and persists a Comment on the given Issue set with current date and time.
 Comment create(ApplicationUser user, Issue issue, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent, ErrorCollection errorCollection)
          Creates and persists a Comment on the given Issue.
 Comment create(com.atlassian.crowd.embedded.api.User user, Issue issue, String body, boolean dispatchEvent, ErrorCollection errorCollection)
          Creates and persists a Comment on the given Issue set with current date and time, visible to all - no group level or role level restriction.
 Comment create(com.atlassian.crowd.embedded.api.User user, Issue issue, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent, ErrorCollection errorCollection)
           
 Comment create(com.atlassian.crowd.embedded.api.User user, Issue issue, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent, ErrorCollection errorCollection)
          Creates and persists a Comment on the given Issue.
 void delete(JiraServiceContext jiraServiceContext, Comment comment, boolean dispatchEvent)
          Deletes a comment and updates the issue's change history and updated date.
protected  void doUpdateWithChangelog(Long eventTypeId, List<ChangeItemBean> changeItems, Issue issue, ApplicationUser user, boolean dispatchEvent)
          This method 'completes' the update of an issue entity.
 Comment getCommentById(ApplicationUser user, Long commentId, ErrorCollection errorCollection)
           
 Comment getCommentById(com.atlassian.crowd.embedded.api.User user, Long commentId, ErrorCollection errorCollection)
          Will return a comment for the passed in commentId.
 List<Comment> getCommentsForUser(ApplicationUser user, Issue issue)
          Will return a list of Comments for the given user Will return a list of Comments for the given user.
 List<Comment> getCommentsForUser(ApplicationUser currentUser, Issue issue, ErrorCollection errorCollection)
          Will return a list of Comments for the given user.
 List<Comment> getCommentsForUser(com.atlassian.crowd.embedded.api.User currentUser, Issue issue, ErrorCollection errorCollection)
          Will return a list of Comments for the given user.
 List<Comment> getCommentsForUserSince(ApplicationUser currentUser, Issue issue, Date since)
          Will return a list of Comments that were created or updated since the provided date, for the given user.
 MutableComment getMutableComment(ApplicationUser user, Long commentId, ErrorCollection errorCollection)
           
 MutableComment getMutableComment(com.atlassian.crowd.embedded.api.User user, Long commentId, ErrorCollection errorCollection)
          Will return a MutableComment for the passed in commentId.
 boolean hasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection)
           
 boolean hasPermissionToCreate(com.atlassian.crowd.embedded.api.User user, Issue issue, ErrorCollection errorCollection)
          Has the correct permission to create a comment for the given issue.
 boolean hasPermissionToDelete(JiraServiceContext jiraServiceContext, Long commentId)
          Determines whether the user can delete a comment.
 boolean hasPermissionToEdit(ApplicationUser user, Comment comment, ErrorCollection errorCollection)
           
 boolean hasPermissionToEdit(JiraServiceContext jiraServiceContext, Long commentId)
          Determines whether the user can edit a comment.
 boolean hasPermissionToEdit(com.atlassian.crowd.embedded.api.User user, Comment comment, ErrorCollection errorCollection)
          Determine whether the current user has the permission to edit the comment.
protected  boolean hasVisibility(JiraServiceContext jiraServiceContext, Comment comment)
           
 boolean isGroupVisiblityEnabled()
          Returns the flag that indicates whether group visiblity is enabled
 boolean isProjectRoleVisiblityEnabled()
          Returns the flag that indicates whether project role visibility is enabled
 boolean isValidAllCommentData(ApplicationUser currentUser, Issue issue, String body, String groupLevel, String roleLevelId, ErrorCollection errorCollection)
           
 boolean isValidAllCommentData(com.atlassian.crowd.embedded.api.User user, Issue issue, String body, String groupLevel, String roleLevelId, ErrorCollection errorCollection)
          Will call all other validate methods setting the appropriate errors in the errorCollection if any errors occur.
 boolean isValidCommentBody(String body, ErrorCollection errorCollection)
          Validates that the body is a valid string, if not the appropriate error is added to the errorCollection.
 boolean isValidCommentBody(String body, ErrorCollection errorCollection, boolean allowEmpty)
          Validates that the body is a valid string, if not the appropriate error is added to the errorCollection.
 boolean isValidCommentData(ApplicationUser currentUser, Issue issue, String groupLevel, String roleLevelId, ErrorCollection errorCollection)
           
 boolean isValidCommentData(com.atlassian.crowd.embedded.api.User user, Issue issue, String groupLevel, String roleLevelId, ErrorCollection errorCollection)
          This method validates if the comment has the correct role and group levels set.
 void update(ApplicationUser user, CommentService.CommentUpdateValidationResult validationResult, boolean dispatchEvent)
          Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.
 void update(ApplicationUser user, MutableComment comment, boolean dispatchEvent, ErrorCollection errorCollection)
          Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.
 void update(com.atlassian.crowd.embedded.api.User user, MutableComment comment, boolean dispatchEvent, ErrorCollection errorCollection)
          Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.
 CommentService.CommentCreateValidationResult validateCommentCreate(ApplicationUser user, CommentService.CommentParameters commentParameters)
          Confirms the parameters to create a comment are valid and that the user has the permission to do so.
 CommentService.CommentUpdateValidationResult validateCommentUpdate(ApplicationUser user, Long commentId, CommentService.CommentParameters commentParameters)
          Confirms the parameters to update a comment are valid and that the updating user has the permission to do so.
 void validateCommentUpdate(ApplicationUser user, Long commentId, String body, String groupLevel, Long roleLevelId, ErrorCollection errorCollection)
          Confirms the parameters to update a comment are valid and that the updating user has the permission to do so.
 void validateCommentUpdate(com.atlassian.crowd.embedded.api.User user, Long commentId, String body, String groupLevel, Long roleLevelId, ErrorCollection errorCollection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_NULL_COMMENT_ID

public static final String ERROR_NULL_COMMENT_ID
See Also:
Constant Field Values

ERROR_NULL_COMMENT

public static final String ERROR_NULL_COMMENT
See Also:
Constant Field Values

ERROR_NULL_COMMENT_DELETE

public static final String ERROR_NULL_COMMENT_DELETE
See Also:
Constant Field Values

ERROR_NULL_COMMENT_ID_DELETE

public static final String ERROR_NULL_COMMENT_ID_DELETE
See Also:
Constant Field Values

ERROR_COMMENT_DELETE_ISSUE_UPDATE_FAILED

public static final String ERROR_COMMENT_DELETE_ISSUE_UPDATE_FAILED
See Also:
Constant Field Values

ERROR_COMMENT_EDIT_NON_EDITABLE_ISSUE

public static final String ERROR_COMMENT_EDIT_NON_EDITABLE_ISSUE
See Also:
Constant Field Values

ERROR_COMMENT_DELETE_NON_EDITABLE_ISSUE

public static final String ERROR_COMMENT_DELETE_NON_EDITABLE_ISSUE
See Also:
Constant Field Values

ERROR_COMMENT_DELETE_NO_PERMISSION

public static final String ERROR_COMMENT_DELETE_NO_PERMISSION
See Also:
Constant Field Values

ERROR_BODY_TOOLONG

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

DefaultCommentService

public DefaultCommentService(CommentManager commentManager,
                             PermissionManager permissionManager,
                             JiraAuthenticationContext jiraAuthenticationContext,
                             ProjectRoleManager projectRoleManager,
                             CommentPermissionManager commentPermissionManager,
                             IssueUpdater issueUpdater,
                             IssueManager issueManager,
                             VisibilityValidator visibilityValidator,
                             TextFieldCharacterLengthValidator textFieldCharacterLengthValidator)
Method Detail

validateCommentUpdate

public void validateCommentUpdate(ApplicationUser user,
                                  Long commentId,
                                  String body,
                                  String groupLevel,
                                  Long roleLevelId,
                                  ErrorCollection errorCollection)
Description copied from interface: CommentService
Confirms the parameters to update a comment are valid and that the updating user has the permission to do so. This method will validate the raw input parameters. This method only validates the parameters and will not actually persist the changes, you must call CommentService.update(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.issue.comments.MutableComment, boolean, com.atlassian.jira.util.ErrorCollection) to persist the changes. If an error is encountered then the ErrorCollection will contain the specific error message.

Specified by:
validateCommentUpdate in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation and who will be the updatedAuthor.
commentId - The id of the comment to be updated. Permissions will be checked to ensure that the user has the right to update this comment. If the comment does not exist an error will be reported.
body - The body of the comment to be updated.
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
errorCollection - holder for any errors that were thrown attempting to update a comment

validateCommentUpdate

public CommentService.CommentUpdateValidationResult validateCommentUpdate(ApplicationUser user,
                                                                          Long commentId,
                                                                          CommentService.CommentParameters commentParameters)
Description copied from interface: CommentService
Confirms the parameters to update a comment are valid and that the updating user has the permission to do so. This method will validate the raw input parameters. This method only validates the parameters and will not actually persist the changes, you must call CommentService.update(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.issue.comments.MutableComment, boolean, com.atlassian.jira.util.ErrorCollection) to persist the changes. If an error is encountered then the ErrorCollection will contain the specific error message.

Specified by:
validateCommentUpdate in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation and who will be the updatedAuthor.
commentId - The id of the comment to be updated. Permissions will be checked to ensure that the user has the right to update this comment. If the comment does not exist an error will be reported.
commentParameters - the comment parameters.

validateCommentUpdate

public void validateCommentUpdate(com.atlassian.crowd.embedded.api.User user,
                                  Long commentId,
                                  String body,
                                  String groupLevel,
                                  Long roleLevelId,
                                  ErrorCollection errorCollection)
Specified by:
validateCommentUpdate in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation and who will be the updatedAuthor.
commentId - The id of the comment to be updated. Permissions will be checked to ensure that the user has the right to update this comment. If the comment does not exist an error will be reported.
body - The body of the comment to be updated.
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
errorCollection - holder for any errors that were thrown attempting to update a comment

update

public void update(com.atlassian.crowd.embedded.api.User user,
                   MutableComment comment,
                   boolean dispatchEvent,
                   ErrorCollection errorCollection)
Description copied from interface: CommentService
Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.

Specified by:
update in interface CommentService
Parameters:
user - the User who must have permission to update this comment and who will be used as the updateAuthor
comment - the object that contains the changes to the comment to persist.
dispatchEvent - whether or not you want to have an event dispatched on Comment update. If false then the issue will not be reindexed.
errorCollection - holder for any errors that were thrown attempting to update a comment

update

public void update(ApplicationUser user,
                   MutableComment comment,
                   boolean dispatchEvent,
                   ErrorCollection errorCollection)
Description copied from interface: CommentService
Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.

Specified by:
update in interface CommentService
Parameters:
user - the ApplicationUser who must have permission to update this comment and who will be used as the updateAuthor
comment - the object that contains the changes to the comment to persist.
dispatchEvent - whether or not you want to have an event dispatched on Comment update. If false then the issue will not be reindexed.
errorCollection - holder for any errors that were thrown attempting to update a comment

update

public void update(ApplicationUser user,
                   CommentService.CommentUpdateValidationResult validationResult,
                   boolean dispatchEvent)
Description copied from interface: CommentService
Updates a Comment and sets the comments updated date to be now and the updatedAuthor to be the passed in user.

Specified by:
update in interface CommentService
Parameters:
user - the ApplicationUser who must have permission to update this comment and who will be used as the updateAuthor
validationResult - the comment parameters.
dispatchEvent - whether or not you want to have an event dispatched on Comment update. If false then the issue will not be reindexed.

validateCommentCreate

public CommentService.CommentCreateValidationResult validateCommentCreate(ApplicationUser user,
                                                                          @Nonnull
                                                                          CommentService.CommentParameters commentParameters)
Description copied from interface: CommentService
Confirms the parameters to create a comment are valid and that the user has the permission to do so. This method will validate the raw input parameters. This method only validates the parameters and will not actually persist the changes, you must call CommentService.create(ApplicationUser, com.atlassian.jira.bc.issue.comment.CommentService.CommentCreateValidationResult, boolean) to persist the changes. If an error is encountered then the CommentService.CommentCreateValidationResult will contain the specific error message.

Specified by:
validateCommentCreate in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation.
commentParameters - the comment parameters.
Returns:
validation result.

create

public Comment create(com.atlassian.crowd.embedded.api.User user,
                      Issue issue,
                      String body,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Description copied from interface: CommentService
Creates and persists a Comment on the given Issue set with current date and time, visible to all - no group level or role level restriction.

Specified by:
create in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(ApplicationUser user,
                      Issue issue,
                      String body,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Description copied from interface: CommentService
Creates and persists a Comment on the given Issue set with current date and time, visible to all - no group level or role level restriction.

Specified by:
create in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(com.atlassian.crowd.embedded.api.User user,
                      Issue issue,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Specified by:
create in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(ApplicationUser user,
                      Issue issue,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Description copied from interface: CommentService
Creates and persists a Comment on the given Issue set with current date and time.

Specified by:
create in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(com.atlassian.crowd.embedded.api.User user,
                      Issue issue,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Description copied from interface: CommentService
Creates and persists a Comment on the given Issue.

Specified by:
create in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
created - The date of comment creation
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(ApplicationUser user,
                      Issue issue,
                      String body,
                      String groupLevel,
                      Long roleLevelId,
                      Date created,
                      boolean dispatchEvent,
                      ErrorCollection errorCollection)
Description copied from interface: CommentService
Creates and persists a Comment on the given Issue.

Specified by:
create in interface CommentService
Parameters:
user - The ApplicationUser who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null
body - The body of the comment
groupLevel - The group level visibility of the comment (null if roleLevelId specified)
roleLevelId - The role level visibility id of the comment (null if groupLevel specified)
created - The date of comment creation
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
errorCollection - holder for any errors that were thrown attempting to create a comment
Returns:
the created Comment object, or null if no object created.

create

public Comment create(ApplicationUser applicationUser,
                      CommentService.CommentCreateValidationResult validationResult,
                      boolean dispatchEvent)
Description copied from interface: CommentService
Creates and persists a Comment on given Issue.

Specified by:
create in interface CommentService
Parameters:
applicationUser - The ApplicationUser who will be performing the operation.
validationResult - the results of CommentService.validateCommentCreate(ApplicationUser, com.atlassian.jira.bc.issue.comment.CommentService.CommentParameters).
dispatchEvent - whether or not you want to have an event dispatched on Comment creation
Returns:
the created Comment object, or null if no object created.

getCommentsForUser

public List<Comment> getCommentsForUser(ApplicationUser currentUser,
                                        Issue issue,
                                        ErrorCollection errorCollection)
Description copied from interface: CommentService
Will return a list of Comments for the given user.

Specified by:
getCommentsForUser in interface CommentService
Parameters:
currentUser - current ApplicationUser
issue - the issue with associated comments
errorCollection - holder for any errors that were thrown attempting to retrieve comments
Returns:
a List of comments

getCommentsForUser

public List<Comment> getCommentsForUser(com.atlassian.crowd.embedded.api.User currentUser,
                                        Issue issue,
                                        ErrorCollection errorCollection)
Description copied from interface: CommentService
Will return a list of Comments for the given user.

Specified by:
getCommentsForUser in interface CommentService
Parameters:
currentUser - current User
issue - the issue with associated comments
errorCollection - holder for any errors that were thrown attempting to retrieve comments
Returns:
a List of comments

getCommentsForUser

@Nonnull
public List<Comment> getCommentsForUser(@Nullable
                                                ApplicationUser user,
                                                @Nonnull
                                                Issue issue)
Description copied from interface: CommentService
Will return a list of Comments for the given user Will return a list of Comments for the given user.

Specified by:
getCommentsForUser in interface CommentService
Parameters:
user - the user to check permissions against ApplicationUser, or anonymous if null.
issue - the issue with associated comments. Must not be null.
Returns:
a possibly empty List of comments - will not be null.

getCommentsForUserSince

@Nonnull
public List<Comment> getCommentsForUserSince(@Nullable
                                                     ApplicationUser currentUser,
                                                     @Nonnull
                                                     Issue issue,
                                                     @Nonnull
                                                     Date since)
Description copied from interface: CommentService
Will return a list of Comments that were created or updated since the provided date, for the given user.

Specified by:
getCommentsForUserSince in interface CommentService
Parameters:
currentUser - the user to check permissions against ApplicationUser, or anonymous if null.
issue - the issue with associated comments. Must not be null.
since - only comments created or updated after this date will be returned. Must not be null.
Returns:
a possibly empty List of comments - will not be null.

isValidCommentData

public boolean isValidCommentData(ApplicationUser currentUser,
                                  Issue issue,
                                  String groupLevel,
                                  String roleLevelId,
                                  ErrorCollection errorCollection)
Specified by:
isValidCommentData in interface CommentService

isValidCommentData

public boolean isValidCommentData(com.atlassian.crowd.embedded.api.User user,
                                  Issue issue,
                                  String groupLevel,
                                  String roleLevelId,
                                  ErrorCollection errorCollection)
Description copied from interface: CommentService
This method validates if the comment has the correct role and group levels set. If there is an error during validation the passed in errorCollection will contain the errors.

Specified by:
isValidCommentData in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - issue to associate the comment with
groupLevel - comment group visibility level
roleLevelId - comment project role visibility level id
errorCollection - holder for any errors that can occur in process of validation
Returns:
true if the role and group level information has been set correctly for a comment

isValidCommentBody

public boolean isValidCommentBody(String body,
                                  ErrorCollection errorCollection)
Description copied from interface: CommentService
Validates that the body is a valid string, if not the appropriate error is added to the errorCollection. This method was added so the CommentSystemField can validate the body and set the appropriate error message.

Specified by:
isValidCommentBody in interface CommentService
Parameters:
body - comment body to validate
errorCollection - holder for any errors that can occur in process of validation
Returns:
true is the body is valid.

isValidCommentBody

public boolean isValidCommentBody(String body,
                                  ErrorCollection errorCollection,
                                  boolean allowEmpty)
Description copied from interface: CommentService
Validates that the body is a valid string, if not the appropriate error is added to the errorCollection. This method was added so the CommentSystemField can validate the body and set the appropriate error message.

Specified by:
isValidCommentBody in interface CommentService
Parameters:
body - comment body to validate
errorCollection - holder for any errors that can occur in process of validation
allowEmpty - indicates whether empty body is allowed
Returns:
true is the body is valid.

isValidAllCommentData

public boolean isValidAllCommentData(ApplicationUser currentUser,
                                     Issue issue,
                                     String body,
                                     String groupLevel,
                                     String roleLevelId,
                                     ErrorCollection errorCollection)
Specified by:
isValidAllCommentData in interface CommentService

isValidAllCommentData

public boolean isValidAllCommentData(com.atlassian.crowd.embedded.api.User user,
                                     Issue issue,
                                     String body,
                                     String groupLevel,
                                     String roleLevelId,
                                     ErrorCollection errorCollection)
Description copied from interface: CommentService
Will call all other validate methods setting the appropriate errors in the errorCollection if any errors occur.

Specified by:
isValidAllCommentData in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - issue to associate the comment with
body - comment body
groupLevel - comment group visibility level
roleLevelId - comment project role visibility level id
errorCollection - holder for any errors that can occur in process of validarion
Returns:
true if validation passes

isGroupVisiblityEnabled

public boolean isGroupVisiblityEnabled()
Description copied from interface: CommentService
Returns the flag that indicates whether group visiblity is enabled

Specified by:
isGroupVisiblityEnabled in interface CommentService
Returns:
true if enabled, false otherwise

isProjectRoleVisiblityEnabled

public boolean isProjectRoleVisiblityEnabled()
Description copied from interface: CommentService
Returns the flag that indicates whether project role visibility is enabled

Specified by:
isProjectRoleVisiblityEnabled in interface CommentService
Returns:
true if enabled, false otherwise

getCommentById

public Comment getCommentById(ApplicationUser user,
                              Long commentId,
                              ErrorCollection errorCollection)
Specified by:
getCommentById in interface CommentService

getCommentById

public Comment getCommentById(com.atlassian.crowd.embedded.api.User user,
                              Long commentId,
                              ErrorCollection errorCollection)
Description copied from interface: CommentService
Will return a comment for the passed in commentId. This will return null if the user does not have permission to view the comment

Specified by:
getCommentById in interface CommentService
Parameters:
user - who is looking up the comment
commentId - the id representing the Comment you would like to retrieve.
errorCollection - holder for any errors that can occur in process of validation
Returns:
a Comment or null (if the user cannot browse the comment).

getMutableComment

public MutableComment getMutableComment(ApplicationUser user,
                                        Long commentId,
                                        ErrorCollection errorCollection)
Specified by:
getMutableComment in interface CommentService

getMutableComment

public MutableComment getMutableComment(com.atlassian.crowd.embedded.api.User user,
                                        Long commentId,
                                        ErrorCollection errorCollection)
Description copied from interface: CommentService
Will return a MutableComment for the passed in commentId. This will return null if the user does not have permission to view the comment. The difference between this method and CommentService.getCommentById(User,Long,ErrorCollection) is that this method returns a version of the Comment that we can set values on.

Specified by:
getMutableComment in interface CommentService
Parameters:
user - the current user.
commentId - the id that we use to find the comment object.
errorCollection - holder for any errors that can occur in process of validation
Returns:
the comment that is identified by the commentId.

hasPermissionToDelete

public boolean hasPermissionToDelete(JiraServiceContext jiraServiceContext,
                                     Long commentId)
Description copied from interface: CommentService
Determines whether the user can delete a comment. Will return true when the following are satisfied:

Specified by:
hasPermissionToDelete in interface CommentService
Parameters:
jiraServiceContext - jiraServiceContext containing the user who wishes to delete a comment and the errorCollection that will contain any errors encountered when calling the method
commentId - the id of the target comment (cannot be null)
Returns:
true if the user has permission to delete the target comment, false otherwise

hasVisibility

protected boolean hasVisibility(JiraServiceContext jiraServiceContext,
                                Comment comment)

delete

public void delete(JiraServiceContext jiraServiceContext,
                   Comment comment,
                   boolean dispatchEvent)
Description copied from interface: CommentService
Deletes a comment and updates the issue's change history and updated date. Expects that CommentService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,Long) is successfully called first.

Specified by:
delete in interface CommentService
Parameters:
jiraServiceContext - containing the user who wishes to delete a comment and the errorCollection that will contain any errors encountered when calling the method
comment - the comment to delete (cannot be null)
dispatchEvent - a flag indicating whether to dispatch an issue updated event. If this flag is false then the issue will not be reindexed.

hasPermissionToCreate

public boolean hasPermissionToCreate(ApplicationUser user,
                                     Issue issue,
                                     ErrorCollection errorCollection)
Specified by:
hasPermissionToCreate in interface CommentService

hasPermissionToCreate

public boolean hasPermissionToCreate(com.atlassian.crowd.embedded.api.User user,
                                     Issue issue,
                                     ErrorCollection errorCollection)
Description copied from interface: CommentService
Has the correct permission to create a comment for the given issue.

Specified by:
hasPermissionToCreate in interface CommentService
Parameters:
user - The User who will be performing the operation.
issue - The Issue you wish to associate the Comment with. This can not be null.
errorCollection - holder for any errors that were thrown attempting permission checks
Returns:
true if permission check passes.

hasPermissionToEdit

public boolean hasPermissionToEdit(JiraServiceContext jiraServiceContext,
                                   Long commentId)
Description copied from interface: CommentService
Determines whether the user can edit a comment. Will return true when the following are satisfied:

Specified by:
hasPermissionToEdit in interface CommentService
Parameters:
jiraServiceContext - JIRA service context containing the user who wishes to edit a comment and the errorCollection that will contain any errors encountered when calling the method
commentId - the id of the target comment (cannot be null)
Returns:
true if the user has permission to edit the comment, false otherwise

hasPermissionToEdit

public boolean hasPermissionToEdit(ApplicationUser user,
                                   Comment comment,
                                   ErrorCollection errorCollection)
Specified by:
hasPermissionToEdit in interface CommentService

hasPermissionToEdit

public boolean hasPermissionToEdit(com.atlassian.crowd.embedded.api.User user,
                                   Comment comment,
                                   ErrorCollection errorCollection)
Description copied from interface: CommentService
Determine whether the current user has the permission to edit the comment. In case of errors, add error messages to the error collection.

Passing in null comment or a comment with null ID will return false and an error message will be added to the error collection.

Passing in null error collection will throw NPE.

Specified by:
hasPermissionToEdit in interface CommentService
Parameters:
user - The User who will be performing the operation.
comment - The Comment you wish to edit.
errorCollection - holder for any errors that were thrown attempting permission checks
Returns:
true if the user has edit permission, false otherwise

doUpdateWithChangelog

protected void doUpdateWithChangelog(Long eventTypeId,
                                     List<ChangeItemBean> changeItems,
                                     Issue issue,
                                     ApplicationUser user,
                                     boolean dispatchEvent)
This method 'completes' the update of an issue entity.

It sets the update timestamp, stores the issue, updated the cache if needed, creates the changelog and dispatches the event (if desired).

This method will ALWAYS generate an update - see also doUpdateIfNeeded.

Parameters:
eventTypeId - event type id
changeItems - list of change items
issue - issue to update
user - user performing this operation
dispatchEvent - dispatch event flag
Throws:
JiraException - if update fails


Copyright © 2002-2014 Atlassian. All Rights Reserved.