|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.jira.bc.issue.comment.DefaultCommentService
public class DefaultCommentService
Default implementation of comment service.
| Field Summary | |
|---|---|
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)
|
|
| Method Summary | |
|---|---|
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(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)
Creates and persists a Comment on the given Issue set with current date and time. |
Comment |
create(User 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(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. |
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 changeItems,
Issue issue,
com.atlassian.crowd.embedded.api.User user,
boolean dispatchEvent)
This method 'completes' the update of an issue entity. |
Comment |
getCommentById(User user,
Long commentId,
ErrorCollection errorCollection)
Will return a comment for the passed in commentId. |
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(User 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 |
MutableComment |
getMutableComment(User user,
Long commentId,
ErrorCollection errorCollection)
Will return a MutableComment for the passed in commentId. |
MutableComment |
getMutableComment(com.atlassian.crowd.embedded.api.User user,
Long commentId,
ErrorCollection errorCollection)
Will return a MutableComment for the passed in commentId. |
boolean |
hasPermissionToCreate(User user,
Issue issue,
ErrorCollection errorCollection)
Has the correct permission to create a comment for the given issue. |
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(JiraServiceContext jiraServiceContext,
Long commentId)
Determines whether the user can edit a comment. |
boolean |
hasPermissionToEdit(User user,
Comment comment,
ErrorCollection errorCollection)
Determine whether the current user has the permission to edit the 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(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 |
isValidAllCommentData(com.atlassian.crowd.embedded.api.User currentUser,
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 |
isValidCommentData(com.atlassian.crowd.embedded.api.User currentUser,
Issue issue,
String groupLevel,
String roleLevelId,
ErrorCollection errorCollection)
This method validates if the comment has the correct role and group levels set. |
boolean |
isValidCommentData(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(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. |
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. |
void |
validateCommentUpdate(User 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)
Confirms the parameters to update a comment are valid and that the updating user has the permission to do so. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ERROR_NULL_COMMENT_ID
public static final String ERROR_NULL_COMMENT
public static final String ERROR_NULL_COMMENT_DELETE
public static final String ERROR_NULL_COMMENT_ID_DELETE
public static final String ERROR_COMMENT_DELETE_ISSUE_UPDATE_FAILED
public static final String ERROR_COMMENT_EDIT_NON_EDITABLE_ISSUE
public static final String ERROR_COMMENT_DELETE_NON_EDITABLE_ISSUE
public static final String ERROR_COMMENT_DELETE_NO_PERMISSION
| Constructor Detail |
|---|
public DefaultCommentService(CommentManager commentManager,
PermissionManager permissionManager,
JiraAuthenticationContext jiraAuthenticationContext,
ProjectRoleManager projectRoleManager,
CommentPermissionManager commentPermissionManager,
IssueUpdater issueUpdater,
IssueManager issueManager,
VisibilityValidator visibilityValidator)
| Method Detail |
|---|
public Comment create(com.atlassian.crowd.embedded.api.User user,
Issue issue,
String body,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue set with current date and time, visible to all
- no group level or role level restriction.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public void validateCommentUpdate(User user,
Long commentId,
String body,
String groupLevel,
Long roleLevelId,
ErrorCollection errorCollection)
CommentServiceCommentService.update(com.opensymphony.user.User, 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.
validateCommentUpdate in interface CommentServiceuser - The User 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 insure 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
public void validateCommentUpdate(com.atlassian.crowd.embedded.api.User user,
Long commentId,
String body,
String groupLevel,
Long roleLevelId,
ErrorCollection errorCollection)
CommentServiceCommentService.update(com.opensymphony.user.User, 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.
validateCommentUpdate in interface CommentServiceuser - The User 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 insure 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
public void update(User user,
MutableComment comment,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment and sets the comments updated date to be now and the updatedAuthor to be the
passed in user.
update in interface CommentServiceuser - the user who must have permission to update this comment and who will be used as the udpateAuthorcomment - 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
public void update(com.atlassian.crowd.embedded.api.User user,
MutableComment comment,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment and sets the comments updated date to be now and the updatedAuthor to be the
passed in user.
update in interface CommentServiceuser - the user who must have permission to update this comment and who will be used as the udpateAuthorcomment - 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
public List<Comment> getCommentsForUser(User currentUser,
Issue issue,
ErrorCollection errorCollection)
CommentServiceComments for the given user
getCommentsForUser in interface CommentServicecurrentUser - current userissue - the issue with associated commentserrorCollection - holder for any errors that were thrown attempting to update a comment
public Comment create(com.atlassian.crowd.embedded.api.User user,
Issue issue,
String body,
String groupLevel,
Long roleLevelId,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue set with current date and time.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public Comment create(User user,
Issue issue,
String body,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue set with current date and time, visible to all
- no group level or role level restriction.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public Comment create(User user,
Issue issue,
String body,
String groupLevel,
Long roleLevelId,
Date created,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public Comment create(com.atlassian.crowd.embedded.api.User user,
Issue issue,
String body,
String groupLevel,
Long roleLevelId,
Date created,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public Comment create(User user,
Issue issue,
String body,
String groupLevel,
Long roleLevelId,
boolean dispatchEvent,
ErrorCollection errorCollection)
CommentServiceComment on the given Issue set with current date and time.
create in interface CommentServiceuser - The User who will be performing the operation.issue - The Issue you wish to associate the Comment with. 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
public List<Comment> getCommentsForUser(com.atlassian.crowd.embedded.api.User currentUser,
Issue issue,
ErrorCollection errorCollection)
CommentServiceComments for the given user
getCommentsForUser in interface CommentServicecurrentUser - current userissue - the issue with associated commentserrorCollection - holder for any errors that were thrown attempting to update a comment
public boolean hasPermissionToCreate(User user,
Issue issue,
ErrorCollection errorCollection)
CommentService
hasPermissionToCreate in interface CommentServiceuser - 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
public boolean isValidCommentData(com.atlassian.crowd.embedded.api.User currentUser,
Issue issue,
String groupLevel,
String roleLevelId,
ErrorCollection errorCollection)
CommentServiceerrorCollection will contain the errors.
isValidCommentData in interface CommentServicecurrentUser - The User who will be performing the operation.issue - issue to associate the comment withgroupLevel - comment group visibility levelroleLevelId - comment project role visibility level iderrorCollection - holder for any errors that can occur in process of validation
public boolean isValidAllCommentData(User user,
Issue issue,
String body,
String groupLevel,
String roleLevelId,
ErrorCollection errorCollection)
CommentServiceerrorCollection if any errors occur.
isValidAllCommentData in interface CommentServiceuser - The User who 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
public boolean isValidCommentBody(String body,
ErrorCollection errorCollection)
CommentServiceerrorCollection. This method was added so
the CommentSystemField can validate the body and set the appropriate error message.
isValidCommentBody in interface CommentServicebody - comment body to validateerrorCollection - holder for any errors that can occur in process of validation
public boolean isValidCommentData(User user,
Issue issue,
String groupLevel,
String roleLevelId,
ErrorCollection errorCollection)
CommentServiceerrorCollection will contain the errors.
isValidCommentData in interface CommentServiceuser - The User who will be performing the operation.issue - issue to associate the comment withgroupLevel - comment group visibility levelroleLevelId - comment project role visibility level iderrorCollection - holder for any errors that can occur in process of validation
public boolean isValidAllCommentData(com.atlassian.crowd.embedded.api.User currentUser,
Issue issue,
String body,
String groupLevel,
String roleLevelId,
ErrorCollection errorCollection)
CommentServiceerrorCollection if any errors occur.
isValidAllCommentData in interface CommentServicecurrentUser - The User who 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
public boolean isGroupVisiblityEnabled()
CommentService
isGroupVisiblityEnabled in interface CommentServicepublic boolean isProjectRoleVisiblityEnabled()
CommentService
isProjectRoleVisiblityEnabled in interface CommentService
public Comment getCommentById(User user,
Long commentId,
ErrorCollection errorCollection)
CommentService
getCommentById in interface CommentServiceuser - who is looking up the commentcommentId - the id representing the Comment you would like to retrieve.errorCollection - holder for any errors that can occur in process of validation
Comment or null (if the user cannot browse the comment).
public Comment getCommentById(com.atlassian.crowd.embedded.api.User user,
Long commentId,
ErrorCollection errorCollection)
CommentService
getCommentById in interface CommentServiceuser - who is looking up the commentcommentId - the id representing the Comment you would like to retrieve.errorCollection - holder for any errors that can occur in process of validation
Comment or null (if the user cannot browse the comment).
public MutableComment getMutableComment(User user,
Long commentId,
ErrorCollection errorCollection)
CommentServiceMutableComment 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(com.opensymphony.user.User,Long,ErrorCollection) is that this method
returns a version of the Comment that we can set values on.
getMutableComment in interface CommentServiceuser - 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
public MutableComment getMutableComment(com.atlassian.crowd.embedded.api.User user,
Long commentId,
ErrorCollection errorCollection)
CommentServiceMutableComment 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.
getMutableComment in interface CommentServiceuser - 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
public boolean hasPermissionToDelete(JiraServiceContext jiraServiceContext,
Long commentId)
CommentService
hasPermissionToDelete in interface CommentServicejiraServiceContext - 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)
protected boolean hasVisibility(JiraServiceContext jiraServiceContext,
Comment comment)
public void delete(JiraServiceContext jiraServiceContext,
Comment comment,
boolean dispatchEvent)
CommentServiceCommentService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,Long) is successfully called first.
delete in interface CommentServicejiraServiceContext - 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.
public boolean hasPermissionToCreate(com.atlassian.crowd.embedded.api.User user,
Issue issue,
ErrorCollection errorCollection)
CommentService
hasPermissionToCreate in interface CommentServiceuser - 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
public boolean hasPermissionToEdit(User user,
Comment comment,
ErrorCollection errorCollection)
CommentService
hasPermissionToEdit in interface CommentServiceuser - 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
public boolean hasPermissionToEdit(JiraServiceContext jiraServiceContext,
Long commentId)
CommentService
hasPermissionToEdit in interface CommentServicejiraServiceContext - 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)
public boolean hasPermissionToEdit(com.atlassian.crowd.embedded.api.User user,
Comment comment,
ErrorCollection errorCollection)
CommentService
hasPermissionToEdit in interface CommentServiceuser - 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
protected void doUpdateWithChangelog(Long eventTypeId,
List changeItems,
Issue issue,
com.atlassian.crowd.embedded.api.User user,
boolean dispatchEvent)
throws JiraException
eventTypeId - event type idchangeItems - list of change itemsissue - issue to updateuser - user performing this operationdispatchEvent - dispatch event flag
JiraException - if update fails
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||