Class DefaultCommentService
java.lang.Object
com.atlassian.jira.bc.issue.comment.DefaultCommentService
- All Implemented Interfaces:
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, CommentService.CommentVisibility -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCommentService(CommentManager commentManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, CommentPermissionManager commentPermissionManager, IssueManager issueManager, VisibilityValidator visibilityValidator, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator, CommentsPerIssueLimitValidator commentsPerIssueLimitValidator, CommentHandler commentHandler, CommentPinManager commentPinManager, CommentPropertyService commentPropertyService) -
Method Summary
Modifier and TypeMethodDescriptioncreate(ApplicationUser applicationUser, CommentService.CommentCreateValidationResult validationResult, boolean dispatchEvent) create(ApplicationUser user, Issue issue, String body, boolean dispatchEvent, ErrorCollection errorCollection) create(ApplicationUser user, Issue issue, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent, ErrorCollection errorCollection) create(ApplicationUser user, Issue issue, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent, ErrorCollection errorCollection) voiddelete(JiraServiceContext jiraServiceContext, Comment comment, boolean dispatchEvent) Deletes a comment and updates the issue's change history and updated date.getCommentById(ApplicationUser user, Long commentId, ErrorCollection errorCollection) Will return a comment for the passed in commentId.getCommentsForUser(ApplicationUser user, Issue issue) getCommentsForUser(ApplicationUser currentUser, Issue issue, ErrorCollection errorCollection) Will return a list ofComments for the given user.getCommentsForUserSince(ApplicationUser currentUser, Issue issue, Date since) Will return a list ofComments that were created or updated since the provided date, for the given user.getMutableComment(ApplicationUser user, Long commentId, ErrorCollection errorCollection) Will return aMutableCommentfor the passed in commentId.getPinnedComments(JiraServiceContext jiraServiceContext, Issue issue) Will return a list ofPinnedComments for the given issue.booleanhasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection) Check if the given user has permission to create a comment in the current state of the issue.booleanhasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection, com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor) Check if the given user has permission to create a comment during a workflow transition for a given action description.booleanhasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection, Optional<Status> status) Check if the given user has permission to create a comment in the current state of the issue or if the issue was in the given status.booleanhasPermissionToDelete(JiraServiceContext jiraServiceContext, Long commentId) Determines whether the user can delete a comment.booleanhasPermissionToEdit(JiraServiceContext jiraServiceContext, Long commentId) Determines whether the user can edit a comment.booleanhasPermissionToEdit(ApplicationUser user, Comment comment, ErrorCollection errorCollection) Determine whether the current user has the permission to edit the comment.booleanhasPermissionToPinComments(ApplicationUser user, Issue issue, ErrorCollection errorCollection) Check if the given user has permission to pin a commentprotected booleanhasVisibility(JiraServiceContext jiraServiceContext, Comment comment) booleanReturns the flag that indicates whether group visiblity is enabledbooleanReturns the flag that indicates whether project role visibility is enabledbooleanisValidAllCommentData(ApplicationUser currentUser, Issue issue, String body, Visibility visibility, ErrorCollection errorCollection) Will call all other validate methods setting the appropriate errors in theerrorCollectionif any errors occur.booleanisValidAllCommentData(ApplicationUser currentUser, Issue issue, String body, String groupLevel, String roleLevelId, ErrorCollection errorCollection) Will call all other validate methods setting the appropriate errors in theerrorCollectionif any errors occur.booleanisValidCommentBody(String body, ErrorCollection errorCollection) Validates that the body is a valid string, if not the appropriate error is added to theerrorCollection.booleanisValidCommentBody(String body, ErrorCollection errorCollection, boolean allowEmpty) Validates that the body is a valid string, if not the appropriate error is added to theerrorCollection.booleanisValidCommentVisibility(ApplicationUser currentUser, Issue issue, Visibility visibility, ErrorCollection errorCollection) This method validates if the comment has the correct role and group levels set.voidsetPin(JiraServiceContext jiraServiceContext, Comment comment, boolean pinned) Pins a comment for given issuestreamComments(ApplicationUser user, Issue issue) Streams every comment of the given issue that is visible to the user.voidupdate(ApplicationUser user, CommentService.CommentUpdateValidationResult validationResult, boolean dispatchEvent) Updates aCommentand sets the comments updated date to be now and the updatedAuthor to be the passed in user.voidupdate(ApplicationUser user, MutableComment comment, boolean dispatchEvent, ErrorCollection errorCollection) Updates aCommentand sets the comments updated date to be now and the updatedAuthor to be the passed in user.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.validateCommentCreate(ApplicationUser user, CommentService.CommentParameters commentParameters, Optional<Status> status) Confirms the parameters to create a comment are valid and that the user has the permission to do so if the issue was in the given status.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.voidvalidateCommentUpdate(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.
-
Field Details
-
ERROR_NULL_COMMENT_ID
- See Also:
-
ERROR_NULL_COMMENT
- See Also:
-
ERROR_NULL_COMMENT_DELETE
- See Also:
-
ERROR_NULL_COMMENT_ID_DELETE
- See Also:
-
ERROR_COMMENT_EDIT_NON_EDITABLE_ISSUE
- See Also:
-
ERROR_COMMENT_DELETE_NON_EDITABLE_ISSUE
- See Also:
-
ERROR_COMMENT_DELETE_NO_PERMISSION
- See Also:
-
ERROR_BODY_TOOLONG
- See Also:
-
-
Constructor Details
-
DefaultCommentService
public DefaultCommentService(CommentManager commentManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, CommentPermissionManager commentPermissionManager, IssueManager issueManager, VisibilityValidator visibilityValidator, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator, CommentsPerIssueLimitValidator commentsPerIssueLimitValidator, CommentHandler commentHandler, CommentPinManager commentPinManager, CommentPropertyService commentPropertyService)
-
-
Method Details
-
validateCommentUpdate
public void validateCommentUpdate(ApplicationUser user, Long commentId, String body, String groupLevel, Long roleLevelId, ErrorCollection errorCollection) Description copied from interface:CommentServiceConfirms 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 callCommentService.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 theErrorCollectionwill contain the specific error message.- Specified by:
validateCommentUpdatein interfaceCommentService- Parameters:
user- TheApplicationUserwho 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:CommentServiceConfirms 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 callCommentService.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 theErrorCollectionwill contain the specific error message.- Specified by:
validateCommentUpdatein interfaceCommentService- Parameters:
user- TheApplicationUserwho 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.
-
update
public void update(ApplicationUser user, MutableComment comment, boolean dispatchEvent, ErrorCollection errorCollection) Description copied from interface:CommentServiceUpdates aCommentand sets the comments updated date to be now and the updatedAuthor to be the passed in user.- Specified by:
updatein interfaceCommentService- Parameters:
user- theUserwho must have permission to update this comment and who will be used as the updateAuthorcomment- 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:CommentServiceUpdates aCommentand sets the comments updated date to be now and the updatedAuthor to be the passed in user.- Specified by:
updatein interfaceCommentService- Parameters:
user- theApplicationUserwho must have permission to update this comment and who will be used as the updateAuthorvalidationResult- 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:CommentServiceConfirms 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 callCommentService.create(ApplicationUser, CommentCreateValidationResult, boolean)to persist the changes.If an error is encountered then the
CommentService.CommentCreateValidationResultwill contain the specific error message.- Specified by:
validateCommentCreatein interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.commentParameters- the comment parameters.- Returns:
- validation result.
-
validateCommentCreate
public CommentService.CommentCreateValidationResult validateCommentCreate(ApplicationUser user, @Nonnull CommentService.CommentParameters commentParameters, Optional<Status> status) Description copied from interface:CommentServiceConfirms the parameters to create a comment are valid and that the user has the permission to do so if the issue was in the given status. This method will validate the raw input parameters. This method only validates the parameters and will not actually persist the changes, you must callCommentService.create(ApplicationUser, CommentCreateValidationResult, boolean)to persist the changes.If an error is encountered then the
CommentService.CommentCreateValidationResultwill contain the specific error message.- Specified by:
validateCommentCreatein interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.commentParameters- the comment parameters.status- The given status to be validated against.- Returns:
- validation result.
-
create
public Comment create(ApplicationUser user, Issue issue, String body, boolean dispatchEvent, ErrorCollection errorCollection) Description copied from interface:CommentServiceCreates and persists aCommenton the givenIssueset with current date and time, visible to all - no group level or role level restriction.- Specified by:
createin interfaceCommentService- Parameters:
user- TheUserwho will be performing the operation.issue- TheIssueyou wish to associate theCommentwith. This can not be nullbody- The body of the commentdispatchEvent- whether or not you want to have an event dispatched on Comment creationerrorCollection- 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- Specified by:
createin interfaceCommentService- Parameters:
user- TheUserwho will be performing the operation.issue- TheIssueyou wish to associate theCommentwith. This can not be nullbody- The body of the commentgroupLevel- 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 creationerrorCollection- 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- Specified by:
createin interfaceCommentService- Parameters:
user- TheUserwho will be performing the operation.issue- TheIssueyou wish to associate theCommentwith. This can not be nullbody- The body of the commentgroupLevel- 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 creationdispatchEvent- whether or not you want to have an event dispatched on Comment creationerrorCollection- 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- Specified by:
createin interfaceCommentService- Parameters:
applicationUser- TheApplicationUserwho will be performing the operation.validationResult- the results ofCommentService.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:CommentServiceWill return a list ofComments for the given user.- Specified by:
getCommentsForUserin interfaceCommentService- Parameters:
currentUser- currentUserissue- the issue with associated commentserrorCollection- 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:CommentServiceWill return a list ofComments for the given user Will return a list ofComments for the given user.- Specified by:
getCommentsForUserin interfaceCommentService- Parameters:
user- the user to check permissions againstApplicationUser, 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.
-
streamComments
Description copied from interface:CommentServiceStreams every comment of the given issue that is visible to the user. Comments are streamed in the order that they were created in.- Specified by:
streamCommentsin interfaceCommentService- Parameters:
user- the user to check permissions against, or null if anonymousissue- issue for which to get comments- Returns:
- a stream of comments
-
getCommentsForUserSince
@Nonnull public List<Comment> getCommentsForUserSince(@Nullable ApplicationUser currentUser, @Nonnull Issue issue, @Nonnull Date since) Description copied from interface:CommentServiceWill return a list ofComments that were created or updated since the provided date, for the given user.- Specified by:
getCommentsForUserSincein interfaceCommentService- Parameters:
currentUser- the user to check permissions againstApplicationUser, 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.
-
isValidCommentVisibility
public boolean isValidCommentVisibility(ApplicationUser currentUser, Issue issue, Visibility visibility, ErrorCollection errorCollection) Description copied from interface:CommentServiceThis method validates if the comment has the correct role and group levels set. If there is an error during validation the passed inerrorCollectionwill contain the errors.- Specified by:
isValidCommentVisibilityin interfaceCommentService- Parameters:
currentUser- TheUserwho will be performing the operation.issue- issue to associate the comment withvisibility- comment visibility levelerrorCollection- 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
Description copied from interface:CommentServiceValidates that the body is a valid string, if not the appropriate error is added to theerrorCollection. This method was added so the CommentSystemField can validate the body and set the appropriate error message.- Specified by:
isValidCommentBodyin interfaceCommentService- Parameters:
body- comment body to validateerrorCollection- holder for any errors that can occur in process of validation- Returns:
- true is the body is valid.
-
isValidCommentBody
Description copied from interface:CommentServiceValidates that the body is a valid string, if not the appropriate error is added to theerrorCollection. This method was added so the CommentSystemField can validate the body and set the appropriate error message.- Specified by:
isValidCommentBodyin interfaceCommentService- Parameters:
body- comment body to validateerrorCollection- holder for any errors that can occur in process of validationallowEmpty- 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) Description copied from interface:CommentServiceWill call all other validate methods setting the appropriate errors in theerrorCollectionif any errors occur.- Specified by:
isValidAllCommentDatain interfaceCommentService- Parameters:
currentUser- TheUserwho will be performing the operation.issue- issue to associate the comment withbody- comment bodygroupLevel- comment group visibility levelroleLevelId- comment project role visibility level iderrorCollection- holder for any errors that can occur in process of validarion- Returns:
- true if validation passes
-
isValidAllCommentData
public boolean isValidAllCommentData(ApplicationUser currentUser, Issue issue, String body, Visibility visibility, ErrorCollection errorCollection) Description copied from interface:CommentServiceWill call all other validate methods setting the appropriate errors in theerrorCollectionif any errors occur.- Specified by:
isValidAllCommentDatain interfaceCommentService- Parameters:
currentUser- TheUserwho will be performing the operation.issue- issue to associate the comment withbody- comment bodyvisibility- visibility levelerrorCollection- holder for any errors that can occur in process of validarion- Returns:
- true if validation passes
-
isGroupVisibilityEnabled
public boolean isGroupVisibilityEnabled()Description copied from interface:CommentServiceReturns the flag that indicates whether group visiblity is enabled- Specified by:
isGroupVisibilityEnabledin interfaceCommentService- Returns:
- true if enabled, false otherwise
-
isProjectRoleVisibilityEnabled
public boolean isProjectRoleVisibilityEnabled()Description copied from interface:CommentServiceReturns the flag that indicates whether project role visibility is enabled- Specified by:
isProjectRoleVisibilityEnabledin interfaceCommentService- Returns:
- true if enabled, false otherwise
-
getCommentById
public Comment getCommentById(ApplicationUser user, Long commentId, ErrorCollection errorCollection) Description copied from interface:CommentServiceWill 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:
getCommentByIdin interfaceCommentService- Parameters:
user- who is looking up the commentcommentId- the id representing theCommentyou would like to retrieve.errorCollection- holder for any errors that can occur in process of validation- Returns:
- a
Commentor null (if the user cannot browse the comment).
-
getMutableComment
public MutableComment getMutableComment(ApplicationUser user, Long commentId, ErrorCollection errorCollection) Description copied from interface:CommentServiceWill return aMutableCommentfor the passed in commentId. This will return null if the user does not have permission to view the comment. The difference between this method andCommentService.getCommentById(com.atlassian.jira.user.ApplicationUser, java.lang.Long, com.atlassian.jira.util.ErrorCollection)is that this method returns a version of theCommentthat we can set values on.- Specified by:
getMutableCommentin interfaceCommentService- 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
Description copied from interface:CommentServiceDetermines whether the user can delete a comment. Will return true when the following are satisfied:- The user has the DELETE_COMMENT_ALL permission, or the user has the DELETE_COMMENT_OWN permission and is attempting to delete a comment they authored
- The issue is in an editable workflow state
- Specified by:
hasPermissionToDeletein interfaceCommentService- Parameters:
jiraServiceContext- jiraServiceContext containing the user who wishes to delete a comment and the errorCollection that will contain any errors encountered when calling the methodcommentId- the id of the target comment (cannot be null)- Returns:
- true if the user has permission to delete the target comment, false otherwise
-
hasVisibility
-
delete
Description copied from interface:CommentServiceDeletes a comment and updates the issue's change history and updated date. Expects thatCommentService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext, Long)is successfully called first.- Specified by:
deletein interfaceCommentService- Parameters:
jiraServiceContext- containing the user who wishes to delete a comment and the errorCollection that will contain any errors encountered when calling the methodcomment- 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.
-
setPin
Description copied from interface:CommentServicePins a comment for given issue- Specified by:
setPinin interfaceCommentService- Parameters:
jiraServiceContext- containing the user who wishes to pin a comment and the errorCollection that will contain any errors encountered when calling the methodcomment- the comment to pin (cannot be null)pinned- a flag indicating whether to pin or unpin given comment
-
getPinnedComments
Description copied from interface:CommentServiceWill return a list ofPinnedComments for the given issue.- Specified by:
getPinnedCommentsin interfaceCommentService- Parameters:
jiraServiceContext- containing the user who wishes to get pinned comments and the errorCollection that will contain any errors encountered when calling the methodissue- the issue for which pinned comments will be returned- Returns:
- list of pinned to the issue comments (max 5).
-
hasPermissionToPinComments
public boolean hasPermissionToPinComments(ApplicationUser user, Issue issue, ErrorCollection errorCollection) Description copied from interface:CommentServiceCheck if the given user has permission to pin a comment- Specified by:
hasPermissionToPinCommentsin interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.issue- The issue with associated comments.errorCollection- Holder for any errors that were thrown attempting permission checks.- Returns:
- true if the user has comment pin permissions, false otherwise.
-
hasPermissionToCreate
public boolean hasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection) Description copied from interface:CommentServiceCheck if the given user has permission to create a comment in the current state of the issue.- Specified by:
hasPermissionToCreatein interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.issue- The issue with associated comments.errorCollection- Holder for any errors that were thrown attempting permission checks.- Returns:
- true if the user has comment create permissions, false otherwise.
-
hasPermissionToCreate
public boolean hasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection, Optional<Status> status) Description copied from interface:CommentServiceCheck if the given user has permission to create a comment in the current state of the issue or if the issue was in the given status.If the state is Optional.none, we use the status in the issue param - the same as calling
CommentService.hasPermissionToCreate(ApplicationUser, Issue, ErrorCollection).- Specified by:
hasPermissionToCreatein interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.issue- The issue with associated comments.errorCollection- Holder for any errors that were thrown attempting permission checks.status- The status that should be used for the permission check. If Optional.none, will check using current status of the given issue.- Returns:
- true if the user has comment create permissions, false otherwise.
-
hasPermissionToCreate
public boolean hasPermissionToCreate(ApplicationUser user, Issue issue, ErrorCollection errorCollection, com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor) Description copied from interface:CommentServiceCheck if the given user has permission to create a comment during a workflow transition for a given action description. This checks if the user is able to create a comment in either the origin status or the target status of the workflow transition.- Specified by:
hasPermissionToCreatein interfaceCommentService- Parameters:
user- TheApplicationUserwho will be performing the operation.issue- The issue with associated comments.errorCollection- Holder for any errors that were thrown attempting permission checks.actionDescriptor- The status that should be used for the permission check. If Optional.none, will check using current status of the given issue.- Returns:
- true if the user has comment create permissions, false otherwise.
-
hasPermissionToEdit
Description copied from interface:CommentServiceDetermines whether the user can edit a comment. Will return true when the following are satisfied:- The user has the comment edit all or comment edit own permission
- The issue is in an editable workflow state
- Specified by:
hasPermissionToEditin interfaceCommentService- 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 methodcommentId- 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) Description copied from interface:CommentServiceDetermine 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:
hasPermissionToEditin interfaceCommentService- Parameters:
user- TheUserwho will be performing the operation.comment- TheCommentyou wish to edit.errorCollection- holder for any errors that were thrown attempting permission checks- Returns:
- true if the user has edit permission, false otherwise
-