com.atlassian.jira.user
Class UserFilterUtils

java.lang.Object
  extended by com.atlassian.jira.user.UserFilterUtils

public class UserFilterUtils
extends Object

Some utility functions for dealing with UserFilter instances.

Since:
v6.2

Field Summary
static com.google.common.base.Function<ProjectRole,Long> GET_ROLE_ID_FUNCTION
           
 
Constructor Summary
UserFilterUtils()
           
 
Method Summary
static Set<String> filterRemovedGroups(Set<String> groups, Collection<com.atlassian.crowd.embedded.api.Group> allGroups)
           
static UserFilter fromJson(JSONObject json)
           
static UserFilter fromJsonString(String jsonString)
           
static UserFilter getFilterWithoutRemovedGroupsAndRoles(UserFilter filter, Collection<com.atlassian.crowd.embedded.api.Group> allGroups, ProjectRoleManager projectRoleManager)
           
static List<ProjectRole> getProjectRoles(ProjectRoleManager projectRoleManager, Set<Long> roleIds)
          Get the ProjectRole objects sorted by role name.
static UserFilter intersectGroups(UserFilter userFilter, Set<String> groups)
          Intersect the groups of the userFilter with groups.
static List<String> sortGroups(Collection<String> groups)
           
static JSONObject toJson(UserFilter userFilter, ProjectRoleManager projectRoleManager)
          Convert the userFilter to JSONObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_ROLE_ID_FUNCTION

public static final com.google.common.base.Function<ProjectRole,Long> GET_ROLE_ID_FUNCTION
Constructor Detail

UserFilterUtils

public UserFilterUtils()
Method Detail

intersectGroups

public static UserFilter intersectGroups(UserFilter userFilter,
                                         Set<String> groups)
Intersect the groups of the userFilter with groups.

If the filter is disabled and groups is not empty, a new filter that's enabled and with the groups will be returned.

If the filter is enabled, its groups will be intersected with the incoming one and a new filter with the intersection will be returned.

Parameters:
userFilter - the user filter to applied the intersection of groups. Will not be changed
groups - a set of groups to be intersected with the filter
Returns:
the updated filter or the original one, if no changes.

toJson

public static JSONObject toJson(UserFilter userFilter,
                                ProjectRoleManager projectRoleManager)
                         throws JSONException
Convert the userFilter to JSONObject

Parameters:
userFilter - the user filter to be converted
projectRoleManager - optional, if provided, will be used to filter invalid project roles
Throws:
JSONException

fromJson

public static UserFilter fromJson(JSONObject json)
                           throws JSONException
Throws:
JSONException

fromJsonString

public static UserFilter fromJsonString(String jsonString)
                                 throws JSONException
Throws:
JSONException

getFilterWithoutRemovedGroupsAndRoles

public static UserFilter getFilterWithoutRemovedGroupsAndRoles(UserFilter filter,
                                                               Collection<com.atlassian.crowd.embedded.api.Group> allGroups,
                                                               ProjectRoleManager projectRoleManager)

filterRemovedGroups

public static Set<String> filterRemovedGroups(Set<String> groups,
                                              Collection<com.atlassian.crowd.embedded.api.Group> allGroups)

getProjectRoles

public static List<ProjectRole> getProjectRoles(ProjectRoleManager projectRoleManager,
                                                Set<Long> roleIds)
Get the ProjectRole objects sorted by role name.


sortGroups

public static List<String> sortGroups(Collection<String> groups)


Copyright © 2002-2014 Atlassian. All Rights Reserved.