public class DefaultCommentManager extends Object implements CommentManager, GroupConfigurable
| Modifier and Type | Field and Description |
|---|---|
static String |
COMMENT_ENTITY |
EVENT_ORIGINAL_COMMENT_PARAMETER| Constructor and Description |
|---|
DefaultCommentManager(ProjectRoleManager projectRoleManager,
CommentPermissionManager commentPermissionManager,
OfBizDelegator delegator,
JiraAuthenticationContext jiraAuthenticationContext,
TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
UserManager userManager,
JsonEntityPropertyManager jsonEntityPropertyManager,
CommentPropertyHelper commentPropertyHelper,
CommentSearchManager commentSearchManager,
CommentEventPublisher commentEventPublisher,
IssueUpdater issueUpdater,
DbConnectionManager dbConnectionManager,
QueryDSLCommentFactory queryDSLCommentFactory) |
| Modifier and Type | Method and Description |
|---|---|
Comment |
convertToComment(org.ofbiz.core.entity.GenericValue gv)
This is a convenience method that can be used to convert a GenericValue representation of a comment to a comment
object.
|
Comment |
create(Issue issue,
ApplicationUser author,
ApplicationUser updateAuthor,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Date updated,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
ApplicationUser updateAuthor,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Date updated,
boolean dispatchEvent,
boolean modifyIssueUpdateDate)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
ApplicationUser updateAuthor,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Date updated,
Map<String,JSONObject> commentProperties,
boolean dispatchEvent,
boolean modifyIssueUpdateDate)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
String body,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
String body,
String groupLevel,
Long roleLevelId,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
String body,
String groupLevel,
Long roleLevelId,
Date created,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
ApplicationUser author,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Map<String,JSONObject> commentProperties,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
String author,
String body,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
String author,
String body,
String groupLevel,
Long roleLevelId,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
String author,
String body,
String groupLevel,
Long roleLevelId,
Date created,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
String author,
String updateAuthor,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Date updated,
boolean dispatchEvent)
Creates a comment and associates it with the given issue.
|
Comment |
create(Issue issue,
String author,
String updateAuthor,
String body,
String groupLevel,
Long roleLevelId,
Date created,
Date updated,
boolean dispatchEvent,
boolean modifyIssueUpdateDate)
Creates a comment and associates it with the given issue.
|
ChangeItemBean |
delete(Comment comment)
Deletes the specified comment.
|
void |
delete(Comment comment,
boolean dispatchEvent,
ApplicationUser user)
Deletes the specified comment.
|
void |
deleteCommentsForIssue(Issue issue) |
Comment |
getCommentById(Long commentId)
Will return a comment for the passed in commentId.
|
List<Comment> |
getComments(Issue issue)
This will return all comments for a given issue.
|
List<Comment> |
getCommentsForUser(Issue issue,
ApplicationUser user)
Retrieves all
Comments on the given Issue that the given ApplicationUser
has permission to see. |
List<Comment> |
getCommentsForUserSince(Issue issue,
ApplicationUser user,
Date since)
Retrieves
Comments that were created or updated after the provided date, on the given Issue that the
given ApplicationUser has permission to see. |
CommentSummary |
getCommentSummary(ApplicationUser user,
Issue issue,
Optional<Long> focusedCommentId)
Method that will return a summary of comments required to render the initial view issue page.
|
long |
getCountForCommentsRestrictedByGroup(String groupName)
Returns the count of all
Comment's that have their visibility restricted by the named group. |
long |
getCountForCommentsRestrictedByRole(Long roleId)
Returns the count of all
Comment's that have their visibility restricted by the role with the given id. |
Comment |
getLastComment(Issue issue)
|
MutableComment |
getMutableComment(Long commentId)
Retrieves comment by given id and returns it as mutable object.
|
ProjectRole |
getProjectRole(Long projectRoleId)
This is a convenience method to allow us to easily get a ProjectRole.
|
boolean |
isGroupUsed(com.atlassian.crowd.embedded.api.Group group)
Determine whether configuration exists for the specified
Group. |
boolean |
isUserCommentAuthor(ApplicationUser user,
Comment comment)
Returns true if the given user is the author of the given comment.
|
java.util.stream.Stream<Comment> |
streamComments(ApplicationUser user,
Issue issue)
Streams every comment of the given issue that is visible to the user.
|
int |
swapCommentGroupRestriction(String groupName,
String swapGroup)
Updates
Comment's such that comments that have a visibility restriction of the provided groupName will be
changed to have a visibility restriction of the provided swapGroup. |
int |
swapCommentRoleRestriction(Long roleId,
Long swapRoleId)
Updates
Comment's such that comments that have a visibility restriction of the provided role will be
changed to have a visibility restriction of the role with the provided swapRoleId. |
void |
update(Comment comment,
boolean dispatchEvent)
Persists the updated comment.
|
void |
update(Comment comment,
Map<String,JSONObject> commentProperties,
boolean dispatchEvent)
Persists the updated comment.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisGroupUsedpublic static final String COMMENT_ENTITY
public DefaultCommentManager(ProjectRoleManager projectRoleManager, CommentPermissionManager commentPermissionManager, OfBizDelegator delegator, JiraAuthenticationContext jiraAuthenticationContext, TextFieldCharacterLengthValidator textFieldCharacterLengthValidator, UserManager userManager, JsonEntityPropertyManager jsonEntityPropertyManager, CommentPropertyHelper commentPropertyHelper, CommentSearchManager commentSearchManager, CommentEventPublisher commentEventPublisher, IssueUpdater issueUpdater, DbConnectionManager dbConnectionManager, QueryDSLCommentFactory queryDSLCommentFactory)
public ProjectRole getProjectRole(Long projectRoleId)
CommentManagerProjectRole.
ProjectRole then you should be using the ProjectRoleManager.getProjectRole in interface CommentManagerprojectRoleId - the id to the ProjectRole object you would like returned.public Comment convertToComment(org.ofbiz.core.entity.GenericValue gv)
CommentManagerconvertToComment in interface CommentManagergv - is the GenericValue representation of a comment.public Comment getCommentById(Long commentId)
CommentManagergetCommentById in interface CommentManagercommentId - the id representing the Comment you would like to retrieve.Comment or null (if the user cannot browse the comment).public MutableComment getMutableComment(Long commentId)
CommentManagergetMutableComment in interface CommentManagercommentId - comment idpublic List<Comment> getCommentsForUser(Issue issue, ApplicationUser user)
CommentManagerComments on the given Issue that the given ApplicationUser
has permission to see. If the passed in user is null, only comments with no permission level set will be
returned.
getCommentsForUser in interface CommentManagerissue - the comments are associated with.user - the user whose permission level will be used to limit the comments returned.Commentspublic java.util.stream.Stream<Comment> streamComments(@Nullable ApplicationUser user, @Nonnull Issue issue)
CommentManagerstreamComments in interface CommentManageruser - the user to check permissions against, or null if anonymousissue - issue for which to get commentspublic CommentSummary getCommentSummary(@Nullable ApplicationUser user, @Nonnull Issue issue, @Nonnull Optional<Long> focusedCommentId)
CommentManagerAPKeys.COMMENT_COLLAPSING_MINIMUM_HIDDEN) then all comments will be
returned (similar to the results of calling CommentManager.getCommentsForUser(Issue, ApplicationUser).getCommentSummary in interface CommentManageruser - the user whose permission level will be used to limit the comments returned.issue - the comments are associated with.focusedCommentId - optional id of a comment to focus. If the summary doesn't contain the focusedComment, then all comments are retrievedpublic Comment getLastComment(Issue issue)
CommentManagerComment on the given Issue. For performance reasons this method does not
take into account access level of the user logged in. As a result, output of this method might not be the same as
what is presented in the application UI to users.getLastComment in interface CommentManagerissue - the comments are associated with.@Nonnull public List<Comment> getCommentsForUserSince(@Nonnull Issue issue, @Nullable ApplicationUser user, @Nonnull Date since)
CommentManagerComments that were created or updated after the provided date, on the given Issue that the
given ApplicationUser has permission to see. If the passed in user is null, only
comments with no permission level set will be returned.
getCommentsForUserSince in interface CommentManagerissue - the comments are associated with. Must not be nulluser - the user whose permission level will be used to limit the comments returned.since - only comments created or updated after this date will be returned. Must not be null.Commentspublic List<Comment> getComments(Issue issue)
CommentManagerUser
please use CommentManager.getCommentsForUser(com.atlassian.jira.issue.Issue, com.atlassian.jira.user.ApplicationUser))}getComments in interface CommentManagerissue - the comments are associated with.public Comment create(Issue issue, ApplicationUser author, String body, boolean dispatchEvent)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, String author, String body, boolean dispatchEvent)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent) throws DataAccessException
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.DataAccessExceptionpublic Comment create(Issue issue, String author, String body, String groupLevel, Long roleLevelId, boolean dispatchEvent)
CommentManagerNOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.
create in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent) throws DataAccessException
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.DataAccessExceptionpublic Comment create(Issue issue, ApplicationUser author, String body, String groupLevel, Long roleLevelId, Date created, Map<String,JSONObject> commentProperties, boolean dispatchEvent)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.commentProperties - Comment properties that should be attached to the created comment before the comment can
be considered 'created'. May be null.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, String author, String body, String groupLevel, Long roleLevelId, Date created, boolean dispatchEvent)
CommentManagerNOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.
create in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.body - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent) throws DataAccessException
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.updateAuthor - the key of the user who has updated this comment lastbody - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.updated - is the date that will be used as the comments updated date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.DataAccessExceptionpublic Comment create(Issue issue, String author, String updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent)
CommentManagerNOTE: A comment should not have both a group level and role level visibility restriction. This method will not stop this, but it does not semantically make sense.
create in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.updateAuthor - the key of the user who has updated this comment lastbody - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.updated - is the date that will be used as the comments updated date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent, boolean modifyIssueUpdateDate)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.updateAuthor - the key of the user who has updated this comment lastbody - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.updated - is the date that will be used as the comments updated date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the
given date is earlier than the current issue update date).public Comment create(Issue issue, ApplicationUser author, ApplicationUser updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, Map<String,JSONObject> commentProperties, boolean dispatchEvent, boolean modifyIssueUpdateDate)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.updateAuthor - the key of the user who has updated this comment lastbody - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.updated - is the date that will be used as the comments updated date.commentProperties - Comment properties that should be attached to the created comment before the comment can
be considered 'created'dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the
given date is earlier than the current issue update date).public Comment create(Issue issue, String author, String updateAuthor, String body, String groupLevel, Long roleLevelId, Date created, Date updated, boolean dispatchEvent, boolean modifyIssueUpdateDate)
CommentManagercreate in interface CommentManagerissue - the issue to associate the comment with.author - the key of the user who has created this comment.updateAuthor - the key of the user who has updated this comment lastbody - the text of the comment.groupLevel - is the group name to limit comment visibility to, this must be a valid group name.roleLevelId - is the id of the the ProjectRole to limit comment visibility to, this must reference a
valid project role.created - is the date that will be used as the comments creation date.updated - is the date that will be used as the comments updated date.dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.modifyIssueUpdateDate - if true the issue's "updated" date will set to the date of this comment (unless the
given date is earlier than the current issue update date).public void update(Comment comment, boolean dispatchEvent)
CommentManagerupdate in interface CommentManagercomment - to updatedispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public void update(Comment comment, Map<String,JSONObject> commentProperties, boolean dispatchEvent)
CommentManagerupdate in interface CommentManagercomment - to updatecommentProperties - Comment properties that should be attached to the created comment before the comment can
be considered 'created'dispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched.public ChangeItemBean delete(Comment comment)
CommentManagerdelete in interface CommentManagercomment - to deletepublic void delete(Comment comment, boolean dispatchEvent, ApplicationUser user)
CommentManagerdelete in interface CommentManagercomment - to deletedispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_DELETED_ID
will be dispatched and any notifications listening for that event will be triggered. If false no event will be
dispatched. Together with IssueEvent CommentDeletedEventuser - who executes this action.
will be dispatched.public void deleteCommentsForIssue(Issue issue)
deleteCommentsForIssue in interface CommentManagerpublic boolean isUserCommentAuthor(ApplicationUser user, Comment comment)
CommentManagerIf the given Comment has a null author, this represents that it was created anonymously, and no-one is the author (returns false). If the given User is null, then this represents that the current user is anonymous, and the method will always return false.
isUserCommentAuthor in interface CommentManageruser - The User. Can be null to represent current user is not logged in (anonymous).comment - The Comment. Cannot be null.public int swapCommentGroupRestriction(String groupName, String swapGroup)
CommentManagerComment's such that comments that have a visibility restriction of the provided groupName will be
changed to have a visibility restriction of the provided swapGroup.
swapCommentGroupRestriction in interface CommentManagergroupName - identifies the group the comments are restricted by, this must not be null.swapGroup - identifies the group the comments will be changed to be restricted by, this must not be null.public int swapCommentRoleRestriction(Long roleId, Long swapRoleId)
CommentManagerComment's such that comments that have a visibility restriction of the provided role will be
changed to have a visibility restriction of the role with the provided swapRoleId.
swapCommentRoleRestriction in interface CommentManagerroleId - identifies the role the comments are restricted by, this must not be null.swapRoleId - identifies the role the comments will be changed to be restricted by, this must not be null.public long getCountForCommentsRestrictedByGroup(String groupName)
CommentManagerComment's that have their visibility restricted by the named group.getCountForCommentsRestrictedByGroup in interface CommentManagergroupName - identifies the group the comments are restricted by, this must not be null.Comment's who's visibility are restricted by the passed in group name.public long getCountForCommentsRestrictedByRole(Long roleId)
CommentManagerComment's that have their visibility restricted by the role with the given id.getCountForCommentsRestrictedByRole in interface CommentManagerroleId - identifies the role the comments are restricted by, this must not be null.Comment's who's visibility are restricted by the role with the passed in role id.public boolean isGroupUsed(@Nonnull com.atlassian.crowd.embedded.api.Group group)
GroupConfigurableGroup.isGroupUsed in interface GroupConfigurablegroup - that may or may not exist.Copyright © 2002-2016 Atlassian. All Rights Reserved.