Class ProjectRoleSecurityAndNotificationType

All Implemented Interfaces:
NotificationType, SchemeType, SecurityType

public class ProjectRoleSecurityAndNotificationType extends AbstractProjectsSecurityType implements NotificationType, SecurityType
  • Field Details

  • Constructor Details

  • Method Details

    • isTopLevelIssueSecurityPermission

      public boolean isTopLevelIssueSecurityPermission()
      Description copied from interface: SecurityType
      Returns true if this permission depends only on a issue security level value and not on project or any field value. Used for optimisation.
      Specified by:
      isTopLevelIssueSecurityPermission in interface SecurityType
      Overrides:
      isTopLevelIssueSecurityPermission in class AbstractProjectsSecurityType
    • getPermissionFieldContents

      public Set<org.apache.lucene.util.BytesRef> getPermissionFieldContents(ApplicationUser searcher, Project project, IssueSecurityLevel securityLevel, String parameter)
      Description copied from interface: SecurityType
      Returns a set of (issue level permission field) contents based on the security level, the project and optionally the parameter (for role-based queries). This is needed to build issue security level query.
      Specified by:
      getPermissionFieldContents in interface SecurityType
      Overrides:
      getPermissionFieldContents 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 permissions field contents
      parameter - Parameter identifying user related field (reporter, assignee, etc)
      Returns:
      A set of Lucene permissions field tuples
      See Also:
    • 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<ApplicationUser> getUsers(PermissionContext permissionContext, String roleId)
      Description copied from interface: SecurityType
      Returns a set of ApplicationUsers 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 ApplicationUsers.
    • 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(Project project, String argument, ApplicationUser 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, ApplicationUser 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<ApplicationUser> 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