com.atlassian.jira.security.util
Class GroupSelectorUtils

java.lang.Object
  extended by com.atlassian.jira.security.util.GroupSelectorUtils
All Implemented Interfaces:
Startable

public class GroupSelectorUtils
extends java.lang.Object
implements Startable

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, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 java.util.List getCustomFieldsSpecifyingGroups()
          Get all custom fields that could possibly be identifying a group.
 java.lang.String getGroupDisplayName(com.opensymphony.user.Group group)
          Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.
 java.util.Set getGroups(java.lang.Object cfValue)
          Given an object (usually a custom field value) find the associated group.
 java.util.Set getGroupsFromDisplayName(java.lang.String groupDisplayName)
          Deprecated. since v3.8 this is a very short term method as it will not work with external User/Group management.
 java.util.Set getUsers(Issue issue, java.lang.String customFieldId)
          Get users from a group chosen by a Group Selector custom field, in a certain issue.
 boolean isUserInCustomFieldGroup(Issue issue, CustomField field, com.opensymphony.user.User user)
          Determines if a user is a member of a group specified by a custom field value.
 void onClearCache(ClearCacheEvent event)
           
 java.lang.String printGroups(java.util.Collection groups)
          Print a comma-separated list of groups.
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 boolean updateGroupName(com.opensymphony.user.Group group, java.lang.String oldVal, java.lang.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,
                          com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
java.lang.Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

getUsers

public java.util.Set getUsers(Issue issue,
                              java.lang.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.

getCustomFieldsSpecifyingGroups

public java.util.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.opensymphony.user.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 java.util.Set getGroups(java.lang.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 java.lang.String printGroups(java.util.Collection groups)
Print a comma-separated list of groups. Useful in debugging code.


getGroupsFromDisplayName

public java.util.Set getGroupsFromDisplayName(java.lang.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 java.lang.String getGroupDisplayName(com.opensymphony.user.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.opensymphony.user.Group group,
                               java.lang.String oldVal,
                               java.lang.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-2010 Atlassian. All Rights Reserved.