com.atlassian.jira.issue.comments
Class DefaultCommentPermissionManager

java.lang.Object
  extended by com.atlassian.jira.issue.comments.DefaultCommentPermissionManager
All Implemented Interfaces:
CommentPermissionManager

public class DefaultCommentPermissionManager
extends Object
implements CommentPermissionManager

Used to check user commenting permissions


Constructor Summary
DefaultCommentPermissionManager(ProjectRoleManager projectRoleManager, PermissionManager permissionManager, GroupManager groupManager)
           
 
Method Summary
 boolean hasBrowsePermission(ApplicationUser user, Comment comment)
          Determines whether the user can see given comment, or is prevented by restrictions on the visibility of the comment (either group- or Project Role-based)

The User can always see the comment if the comment does not have restricted visibility, otherwise only if the user is in either comments group or project role visibility level.

 boolean hasBrowsePermission(com.atlassian.crowd.embedded.api.User user, Comment comment)
           
 boolean hasDeleteAllPermission(ApplicationUser user, Issue issue)
          Returns true if the given User can delete all comments for the given Issue.
 boolean hasDeleteAllPermission(com.atlassian.crowd.embedded.api.User user, Issue issue)
           
 boolean hasDeleteOwnPermission(ApplicationUser user, Issue issue)
          Returns true if the given User can delete her own comments in the given Issue.
 boolean hasDeleteOwnPermission(com.atlassian.crowd.embedded.api.User user, Issue issue)
           
 boolean hasEditAllPermission(ApplicationUser user, Issue issue)
          Returns true if user has permission to edit all comments in the given Issue.
 boolean hasEditAllPermission(com.atlassian.crowd.embedded.api.User user, Issue issue)
           
 boolean hasEditOwnPermission(ApplicationUser user, Issue issue)
          Returns true if user has permission to edit her own comments in the given Issue.
 boolean hasEditOwnPermission(com.atlassian.crowd.embedded.api.User user, Issue issue)
           
 boolean hasEditPermission(ApplicationUser user, Comment comment)
          Determines whether the user can edit given comment.
 boolean hasEditPermission(com.atlassian.crowd.embedded.api.User user, Comment comment)
           
 boolean isUserCommentAuthor(ApplicationUser user, Comment comment)
          Returns true if the given user is the author of the given comment.
 boolean isUserCommentAuthor(com.atlassian.crowd.embedded.api.User user, Comment comment)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCommentPermissionManager

public DefaultCommentPermissionManager(ProjectRoleManager projectRoleManager,
                                       PermissionManager permissionManager,
                                       GroupManager groupManager)
Method Detail

hasBrowsePermission

public boolean hasBrowsePermission(ApplicationUser user,
                                   Comment comment)
Determines whether the user can see given comment, or is prevented by restrictions on the visibility of the comment (either group- or Project Role-based)

The User can always see the comment if the comment does not have restricted visibility, otherwise only if the user is in either comments group or project role visibility level.

Specified by:
hasBrowsePermission in interface CommentPermissionManager
Parameters:
user - application user
comment - comment
Returns:
true if user can see the comment, false otherwise

hasBrowsePermission

public boolean hasBrowsePermission(com.atlassian.crowd.embedded.api.User user,
                                   Comment comment)
Specified by:
hasBrowsePermission in interface CommentPermissionManager
Parameters:
user - user
comment - comment
Returns:
true if permission is granted, false otherwise

hasEditPermission

public boolean hasEditPermission(ApplicationUser user,
                                 Comment comment)
Determines whether the user can edit given comment.

The User can edit the given comment if he or she can edit all comments for the issue, or is the author and has "edit own comments" permission.

Specified by:
hasEditPermission in interface CommentPermissionManager
Parameters:
user - user
comment - comment to edit
Returns:
true if user can edit the given comment, false otherwise

hasEditPermission

public boolean hasEditPermission(com.atlassian.crowd.embedded.api.User user,
                                 Comment comment)
Specified by:
hasEditPermission in interface CommentPermissionManager
Parameters:
user - user
comment - comment
Returns:
true if permission is granted, false otherwise

isUserCommentAuthor

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

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

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

isUserCommentAuthor

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

hasEditAllPermission

public boolean hasEditAllPermission(ApplicationUser user,
                                    Issue issue)
Description copied from interface: CommentPermissionManager
Returns true if user has permission to edit all comments in the given Issue.

NOTE: This method does not check whether the Issue the comment belongs to is in an editable workflow state.

Specified by:
hasEditAllPermission in interface CommentPermissionManager
Parameters:
user - ApplicationUser. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to edit all comments in the given Issue.

hasEditAllPermission

public boolean hasEditAllPermission(com.atlassian.crowd.embedded.api.User user,
                                    Issue issue)
Specified by:
hasEditAllPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to edit all comments in the given Issue.

hasEditOwnPermission

public boolean hasEditOwnPermission(ApplicationUser user,
                                    Issue issue)
Description copied from interface: CommentPermissionManager
Returns true if user has permission to edit her own comments in the given Issue.

NOTE: This method does not check whether the Issue the comment belongs to is in an editable workflow state.

Specified by:
hasEditOwnPermission in interface CommentPermissionManager
Parameters:
user - ApplicationUser. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to edit all comments in the given Issue.

hasEditOwnPermission

public boolean hasEditOwnPermission(com.atlassian.crowd.embedded.api.User user,
                                    Issue issue)
Specified by:
hasEditOwnPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to edit all comments in the given Issue.

hasDeleteAllPermission

public boolean hasDeleteAllPermission(ApplicationUser user,
                                      Issue issue)
Description copied from interface: CommentPermissionManager
Returns true if the given User can delete all comments for the given Issue.

NOTE: This method does not check whether the Issue the comment belongs to is in an editable workflow state.

Specified by:
hasDeleteAllPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to delete all comments in the given Issue.

hasDeleteAllPermission

public boolean hasDeleteAllPermission(com.atlassian.crowd.embedded.api.User user,
                                      Issue issue)
Specified by:
hasDeleteAllPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if user has permission to delete all comments in the given Issue.

hasDeleteOwnPermission

public boolean hasDeleteOwnPermission(ApplicationUser user,
                                      Issue issue)
Description copied from interface: CommentPermissionManager
Returns true if the given User can delete her own comments in the given Issue.

NOTE: This method does not check whether the Issue the comment belongs to is in an editable workflow state.

Specified by:
hasDeleteOwnPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if the given User can delete her own comments in the given Issue.

hasDeleteOwnPermission

public boolean hasDeleteOwnPermission(com.atlassian.crowd.embedded.api.User user,
                                      Issue issue)
Specified by:
hasDeleteOwnPermission in interface CommentPermissionManager
Parameters:
user - User. A null value represents an anonymous User.
issue - Issue. Must not be null.
Returns:
true if the given User can delete her own comments in the given Issue.


Copyright © 2002-2013 Atlassian. All Rights Reserved.