com.atlassian.jira.security.util
Class GroupSelectorUtils

java.lang.Object
  extended by com.atlassian.jira.security.util.GroupSelectorUtils

public class GroupSelectorUtils
extends Object

Hacky methods to support mapping a display name to a group name. A "display" name is a user-friendly equivalent of a regular group name, eg. "JIRA Developers" instead of "jira-developers". In addition, a group name ("Admins") may resolve to multiple groups ("jira-admins, qa-admins" etc).

This code is used in groupnames.jsp, GroupCF and InGroupCFCondition


Constructor Summary
GroupSelectorUtils(org.ofbiz.core.entity.GenericDelegator genericDelegator, FieldManager fieldManager, UserUtil userUtil, GroupManager groupManager)
           
 
Method Summary
 List getCustomFieldsSpecifyingGroups()
          Get all custom fields that could possibly be identifying a group.
 String getGroupDisplayName(com.atlassian.crowd.embedded.api.Group group)
          Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.
 Set<com.atlassian.crowd.embedded.api.Group> getGroups(Object cfValue)
          Given an object (usually a custom field value) find the associated group.
 Set getGroupsFromDisplayName(String groupDisplayName)
          Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.
 Set getUsers(Issue issue, String customFieldId)
          Get users from a group chosen by a Group Selector custom field, in a certain issue.
 Set<com.atlassian.crowd.embedded.api.User> getUsers(Object groupCustomFieldRawValue)
           
 boolean isUserInCustomFieldGroup(Issue issue, CustomField field, com.atlassian.crowd.embedded.api.User user)
          Determines if a user is a member of a group specified by a custom field value.
 void onClearCache(ClearCacheEvent event)
           
 String printGroups(Collection groups)
          Deprecated. Create your own method if you really want a comma-separated list of groups. Since v4.4.
 boolean updateGroupName(com.atlassian.crowd.embedded.api.Group group, String oldVal, String newVal)
          Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupSelectorUtils

public GroupSelectorUtils(org.ofbiz.core.entity.GenericDelegator genericDelegator,
                          FieldManager fieldManager,
                          UserUtil userUtil,
                          GroupManager groupManager)
Method Detail

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

getUsers

public Set getUsers(Issue issue,
                    String customFieldId)
Get users from a group chosen by a Group Selector custom field, in a certain issue.

Parameters:
issue -
customFieldId - Id of GroupSelectorField.
Returns:
Set of Users.

getUsers

public Set<com.atlassian.crowd.embedded.api.User> getUsers(Object groupCustomFieldRawValue)

getCustomFieldsSpecifyingGroups

public List getCustomFieldsSpecifyingGroups()
Get all custom fields that could possibly be identifying a group. For example, select-lists, text fields.

Returns:
list of Field objects, never null

isUserInCustomFieldGroup

public boolean isUserInCustomFieldGroup(Issue issue,
                                        CustomField field,
                                        com.atlassian.crowd.embedded.api.User user)
Determines if a user is a member of a group specified by a custom field value.

Parameters:
issue - The current issue
field - The custom field specifying the group(s). Eg. a select-list.
user - The user we wish to check for
Returns:
If user is in one of the groups specified by the custom field.

getGroups

public Set<com.atlassian.crowd.embedded.api.Group> getGroups(Object cfValue)
Given an object (usually a custom field value) find the associated group.

Parameters:
cfValue - A String (eg. "JIRA Developers" or "jira-developers") Group or Collection of Strings or Groups.
Returns:
A Set of Groups.

printGroups

public String printGroups(Collection groups)
Deprecated. Create your own method if you really want a comma-separated list of groups. Since v4.4.

Print a comma-separated list of groups. Useful in debugging code.


getGroupsFromDisplayName

public Set getGroupsFromDisplayName(String groupDisplayName)
                             throws org.ofbiz.core.entity.GenericEntityException
Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.

Given a display name, return a group name if one is mapped.

Parameters:
groupDisplayName - Eg. "JIRA Developers"
Returns:
A set of Groups, eg. [jira-developers], or null if none exists for the given display name.
Throws:
org.ofbiz.core.entity.GenericEntityException

getGroupDisplayName

public final String getGroupDisplayName(com.atlassian.crowd.embedded.api.Group group)
                                 throws org.ofbiz.core.entity.GenericEntityException
Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.

Get a group's display name.

Returns:
The display name, or null if not set.
Throws:
org.ofbiz.core.entity.GenericEntityException

updateGroupName

public boolean updateGroupName(com.atlassian.crowd.embedded.api.Group group,
                               String oldVal,
                               String newVal)
                        throws org.ofbiz.core.entity.GenericEntityException
Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.

Update a group's display name.

Parameters:
group - Group to update
oldVal - The old value, if any (can be null)
newVal - New display name
Returns:
true if the display name was updated.
Throws:
org.ofbiz.core.entity.GenericEntityException


Copyright © 2002-2012 Atlassian. All Rights Reserved.