com.atlassian.jira.notification.type
Class ProjectRoleSecurityAndNotificationType

java.lang.Object
  extended by com.atlassian.jira.security.type.AbstractSecurityType
      extended by com.atlassian.jira.security.type.AbstractProjectsSecurityType
          extended by com.atlassian.jira.notification.type.ProjectRoleSecurityAndNotificationType
All Implemented Interfaces:
NotificationType, SchemeType, SecurityType

public class ProjectRoleSecurityAndNotificationType
extends AbstractProjectsSecurityType
implements NotificationType, SecurityType


Field Summary
static String PROJECT_ROLE
           
 
Constructor Summary
ProjectRoleSecurityAndNotificationType(JiraAuthenticationContext jiraAuthenticationContext, ProjectRoleManager projectRoleManager, ProjectFactory projectFactory)
           
 
Method Summary
 boolean doValidation(String key, Map parameters)
          Validate the configuration (the argument in NotificationType.getRecipients(com.atlassian.jira.event.issue.IssueEvent, String)) when it is entered in the "Add Notification" page.
 void doValidation(String key, Map parameters, JiraServiceContext jiraServiceContext)
           
 String getArgumentDisplay(String roleTypeId)
          Obtains the user-friendly display for the argument.
 String getArgumentValue(String roleTypeId)
          Obtains the raw parameter value to save for the given user entry user-friendly display value.
 String getDisplayName()
          Text to display for this type, on the "Add Notification" page.
 Collection<ProjectRole> getProjectRoles()
           
 org.apache.lucene.search.Query getQuery(com.atlassian.crowd.embedded.api.User searcher, Project project, IssueSecurityLevel securityLevel, String parameter)
          Returns a query based on security level and the project passed in.
 List<NotificationRecipient> getRecipients(IssueEvent event, String roleId)
          Who is to be notified of an event.
 String getType()
          Type identifier (currently unused).
 Set<com.atlassian.crowd.embedded.api.User> getUsers(PermissionContext permissionContext, String roleId)
          Returns a list of Users represented by a security type instance.
protected  Set<com.atlassian.crowd.embedded.api.User> getUsersFromRole(Project project, String roleId)
          Get all the users that satisfy this particular role.
 boolean hasPermission(org.ofbiz.core.entity.GenericValue entity, String argument)
          Interface for determining if a permission type has the permission.
 boolean hasPermission(org.ofbiz.core.entity.GenericValue entity, String argument, com.atlassian.crowd.embedded.api.User user, boolean issueCreation)
          Interface for determining if a permission type has the permission
 boolean hasPermission(Issue issue, String parameter)
          Determines if this permission type is satisfied for anonymous access.
 boolean hasPermission(Issue issue, String parameter, com.atlassian.crowd.embedded.api.User user, boolean issueCreation)
          Determines if this permission type is satisfied.
 boolean hasPermission(Project project, String argument)
          Determines if this permission type is satisfied for anonymous access.
 boolean hasPermission(Project project, String argument, com.atlassian.crowd.embedded.api.User user, boolean issueCreation)
          Determines if this permission type is satisfied.
 
Methods inherited from class com.atlassian.jira.security.type.AbstractProjectsSecurityType
getQuery, getQuery
 
Methods inherited from class com.atlassian.jira.security.type.AbstractSecurityType
isValidForPermission
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.security.type.SecurityType
getQuery
 
Methods inherited from interface com.atlassian.jira.scheme.SchemeType
isValidForPermission
 

Field Detail

PROJECT_ROLE

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

ProjectRoleSecurityAndNotificationType

public ProjectRoleSecurityAndNotificationType(JiraAuthenticationContext jiraAuthenticationContext,
                                              ProjectRoleManager projectRoleManager,
                                              ProjectFactory projectFactory)
Method Detail

getQuery

public org.apache.lucene.search.Query getQuery(com.atlassian.crowd.embedded.api.User searcher,
                                               Project project,
                                               IssueSecurityLevel securityLevel,
                                               String parameter)
Description copied from interface: SecurityType
Returns a query based on security level and the project passed in. This may be required in particular for role based issue security levels. (see JRA-12739)

Specified by:
getQuery in interface SecurityType
Overrides:
getQuery in class AbstractProjectsSecurityType
Parameters:
searcher - The searcher conducting the search
project - The project for which we're constructing a query
securityLevel - The security level for which we are constructing the query
parameter - Parameter identifying user related field (reporter, assignee, etc)
Returns:
A lucene permissions query

getProjectRoles

public Collection<ProjectRole> getProjectRoles()

getDisplayName

public String getDisplayName()
Description copied from interface: NotificationType
Text to display for this type, on the "Add Notification" page.

Specified by:
getDisplayName in interface NotificationType
Specified by:
getDisplayName in interface SchemeType
Returns:
(Internationalized) text to display, eg. "Group".

getType

public String getType()
Description copied from interface: NotificationType
Type identifier (currently unused).

Specified by:
getType in interface NotificationType
Specified by:
getType in interface SchemeType
Returns:
Eg. "group"

doValidation

public void doValidation(String key,
                         Map parameters,
                         JiraServiceContext jiraServiceContext)
Specified by:
doValidation in interface SchemeType

doValidation

public boolean doValidation(String key,
                            Map parameters)
Description copied from interface: NotificationType
Validate the configuration (the argument in NotificationType.getRecipients(com.atlassian.jira.event.issue.IssueEvent, String)) when it is entered in the "Add Notification" page. For instance, a group notification type might check if the entered group exists.

Specified by:
doValidation in interface NotificationType
Parameters:
key - Key of relevant value in parameters
parameters - HTML form parameters (only the keyed entry is relevant).
Returns:
Whether the entered value is valid for this type.

getArgumentDisplay

public String getArgumentDisplay(String roleTypeId)
Description copied from interface: NotificationType
Obtains the user-friendly display for the argument. For example, returns a username for a key.

Specified by:
getArgumentDisplay in interface NotificationType
Specified by:
getArgumentDisplay in interface SecurityType
Overrides:
getArgumentDisplay in class AbstractSecurityType
Parameters:
roleTypeId - Raw configuration value
Returns:
Formatted configuration value.

getArgumentValue

public String getArgumentValue(String roleTypeId)
Description copied from interface: NotificationType
Obtains the raw parameter value to save for the given user entry user-friendly display value. For example, the user picker displays a username, but this needs to be stored in the configuration parameter as the user's key, instead.

Specified by:
getArgumentValue in interface NotificationType
Parameters:
roleTypeId - Value entered into the form (username, for example)
Returns:
raw configuration value.

getUsers

public Set<com.atlassian.crowd.embedded.api.User> getUsers(PermissionContext permissionContext,
                                                           String roleId)
Description copied from interface: SecurityType
Returns a list of Users represented by a security type instance. The collection must not contain any nulls.

Specified by:
getUsers in interface SecurityType
Parameters:
permissionContext - The current issue and project
roleId - Instance value, eg. a group name, user name, custom field id
Returns:
A set of Users.

hasPermission

public boolean hasPermission(org.ofbiz.core.entity.GenericValue entity,
                             String argument)
Description copied from interface: SchemeType
Interface for determining if a permission type has the permission.

This method is called if there is no Remote User (ie anonymous)

Specified by:
hasPermission in interface SchemeType
Parameters:
entity - This is the issue or the project that the security is being checked for
argument - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
Returns:
true if anonymous Users have this permission.

hasPermission

public boolean hasPermission(Project project,
                             String argument)
Description copied from interface: SchemeType
Determines if this permission type is satisfied for anonymous access.

Specified by:
hasPermission in interface SchemeType
Parameters:
project - This is the project that the security is being checked for
argument - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
Returns:
true if anonymous Users have this permission.

hasPermission

public boolean hasPermission(Issue issue,
                             String parameter)
Description copied from interface: SchemeType
Determines if this permission type is satisfied for anonymous access.

Specified by:
hasPermission in interface SchemeType
Parameters:
issue - This is the issue that the security is being checked for
parameter - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
Returns:
true if anonymous Users have this permission.

hasPermission

public boolean hasPermission(org.ofbiz.core.entity.GenericValue entity,
                             String argument,
                             com.atlassian.crowd.embedded.api.User user,
                             boolean issueCreation)
Description copied from interface: SchemeType
Interface for determining if a permission type has the permission

Specified by:
hasPermission in interface SchemeType
Parameters:
entity - This is the issue or the project that the security is being checked for
argument - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
user - The user for whom the permission is being checked
issueCreation - Whether this permission is being checked during issue creation
Returns:
true if the given User has this permission.

hasPermission

public boolean hasPermission(Project project,
                             String argument,
                             com.atlassian.crowd.embedded.api.User user,
                             boolean issueCreation)
Description copied from interface: SchemeType
Determines if this permission type is satisfied.

Specified by:
hasPermission in interface SchemeType
Parameters:
project - This is the project that the security is being checked for
argument - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
user - The user for whom the permission is being checked
issueCreation - Whether this permission is being checked during issue creation
Returns:
true if the given User has this permission.

hasPermission

public boolean hasPermission(Issue issue,
                             String parameter,
                             com.atlassian.crowd.embedded.api.User user,
                             boolean issueCreation)
Description copied from interface: SchemeType
Determines if this permission type is satisfied.

Specified by:
hasPermission in interface SchemeType
Parameters:
issue - This is the issue that the security is being checked for
parameter - If this particular SchemeType has been configured with a parameter, then this parameter is passed (eg. Group Name for GroupDropdown)
user - The user for whom the permission is being checked
issueCreation - Whether this permission is being checked during issue creation
Returns:
true if the given User has this permission.

getRecipients

public List<NotificationRecipient> getRecipients(IssueEvent event,
                                                 String roleId)
Description copied from interface: NotificationType
Who is to be notified of an event.

Specified by:
getRecipients in interface NotificationType
Parameters:
event - The event, eg. issue created
roleId - Configuration from notification scheme, eg. group name, custom field id.
Returns:
A list of NotificationRecipients.

getUsersFromRole

protected Set<com.atlassian.crowd.embedded.api.User> getUsersFromRole(Project project,
                                                                      String roleId)
Get all the users that satisfy this particular role.

Protected access so it can be directly called from unittests

Parameters:
project - the project you to find want users for
roleId - the specific role you want to find users for
Returns:
A collection of User objects


Copyright © 2002-2013 Atlassian. All Rights Reserved.