com.atlassian.jira.user.util
Interface UserUtil

All Known Implementing Classes:
UserUtilImpl

public interface UserUtil

This is a backend service level interface that defines an api for user level operations.


Field Summary
static String META_PROPERTY_PREFIX
           
 
Method Summary
 void addToJiraUsePermission(User user)
          Takes the given user and adds him/her to all the groups that grant a user the global JIRA use permission.
 void addUserToGroup(Group group, User userToAdd)
          This is used to add a specified user to a specified group.
 void addUserToGroups(Collection groups, User userToAdd)
          This is used to add a user to many groups at once.
 boolean canActivateNumberOfUsers(int numUsers)
          Returns true if, after adding the specified number of users, the number of active users in JIRA does not exceed the user limit allowed by the license.
 boolean canActivateUsers(Collection userNames)
          Returns true if, after adding the specified users, the number of active users in JIRA does not exceed the user limit allowed by the license.
 void clearActiveUserCount()
          Clears the cache of the active user count so that it can be recalculated.
 User createJiraUser(String username, String password, String email, String fullname)
          Create a JIRA user.
 User createJiraUserPreserveCase(String username, String password, String email, String fullname)
          Create a JIRA user.
 int getActiveUserCount()
          Returns the number of users that are currently 'active'.
 Collection getAdministrators()
          Returns a list of JIRA admin Users.
 String getDisplayableNameSafely(User user)
          Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.
 Collection getSystemAdministrators()
          Returns a list of JIRA system admin Users.
 User getUser(String userName)
          Returns a user based on user name.
 boolean hasExceededUserLimit()
          Returns true if this JIRA instance has more active users, than allowed by the license.
 void removeUser(User user)
          Deletes the user and removes the user from all the groups.
 void removeUserFromGroup(Group group, User userToRemove)
          This is used to remove a specified user from a specified group.
 void removeUserFromGroups(Collection groups, User userToRemove)
          This is used to remove a user from many groups at once.
 boolean userExists(String userName)
          Returns true if the a user exists with the specified userName
 

Field Detail

META_PROPERTY_PREFIX

static final String META_PROPERTY_PREFIX
See Also:
Constant Field Values
Method Detail

addUserToGroup

void addUserToGroup(Group group,
                    User userToAdd)
This is used to add a specified user to a specified group. The user will be added to the group if the user is not already a member of the group.

Parameters:
group - the group to add the user to.
userToAdd - the user to add to the group.

addUserToGroups

void addUserToGroups(Collection groups,
                     User userToAdd)
This is used to add a user to many groups at once.

Parameters:
groups - a list containing the groups to add the user to.
userToAdd - the user to add to the group.

removeUserFromGroup

void removeUserFromGroup(Group group,
                         User userToRemove)
This is used to remove a specified user from a specified group. The user will be removed from the group only if the user is already a member of the group.

Parameters:
group - the group to add the user to.
userToRemove - the user to add to the group.

removeUserFromGroups

void removeUserFromGroups(Collection groups,
                          User userToRemove)
This is used to remove a user from many groups at once.

Parameters:
groups - a list containing the groups to add the user to.
userToRemove - the user to add to the group.

getActiveUserCount

int getActiveUserCount()
Returns the number of users that are currently 'active'. For a user to be active, means that it must belong to a group that has either the JIRA-users, JIRA-administrators or JIRA-Systemadministartors global permission. Implementations of this method should take performance into consideration, and ensure that the value is cached. Use clearActiveUserCount() to clear the cache.

Please note that the calculation will be run if the license does not specify a user limit.

Returns:
the active user count
Since:
v3.13
See Also:
Permissions

clearActiveUserCount

void clearActiveUserCount()
Clears the cache of the active user count so that it can be recalculated. This method should be used when performing operations that will modify the number of active users in the system.

Since:
v3.13

hasExceededUserLimit

boolean hasExceededUserLimit()
Returns true if this JIRA instance has more active users, than allowed by the license. If the license does not require a user limit, this method will return false immediately.

Returns:
True if the number of active users is greater than the limit enforced by the license. False otherwise.
Since:
v3.13

canActivateNumberOfUsers

boolean canActivateNumberOfUsers(int numUsers)
Returns true if, after adding the specified number of users, the number of active users in JIRA does not exceed the user limit allowed by the license. If the license does not require a user limit, this method will return true immediately.

Parameters:
numUsers - the number of users to add to the JIRA instance. If 0, all things being equal, this method will return true. Must not be negative!
Returns:
False if the number of active users + the number of users to add is greater than the limit enforced by the license. True otherwise.
Since:
v3.13

canActivateUsers

boolean canActivateUsers(Collection userNames)
Returns true if, after adding the specified users, the number of active users in JIRA does not exceed the user limit allowed by the license. If a user specified is already active, or cannot be found, they are not counted towards the user limit. If the limit has already been exceeded, but none of the users specified are inactive, the result will still be true, as these users are already active and thus nothing changes. If the license does not require a user limit, this method will return true immediately.

Parameters:
userNames - the names of the users to add to the JIRA instance. Must not be null!
Returns:
False if the number of active users + the number of users to add is greater than the limit enforced by the license. True otherwise.
Since:
v3.13

getUser

User getUser(String userName)
Returns a user based on user name.

Parameters:
userName - the user name of the user
Returns:
the User object, or null if the user cannot be found including null userName.
Since:
v3.13

userExists

boolean userExists(String userName)
Returns true if the a user exists with the specified userName

Parameters:
userName - the name of the user
Returns:
true if t a user exists with the specified name or false if not

getAdministrators

Collection getAdministrators()
Returns a list of JIRA admin Users.

Returns:
a list of JIRA admin Users.
Since:
v3.13

getSystemAdministrators

Collection getSystemAdministrators()
Returns a list of JIRA system admin Users.

Returns:
a collection of Group's that are associated with the Permissions.SYSTEM_ADMIN permission.
Since:
v3.13

createJiraUser

User createJiraUser(String username,
                    String password,
                    String email,
                    String fullname)
                    throws DuplicateEntityException,
                           ImmutableException
Create a JIRA user. This user will be added to all groups with the USE permission.

Note that the username will be converted to lower case.

If password is specified as null, a new password will be generated for the user.

NOTE: This method does not fire any user events, you will need to fire them yourself if you want to.

Parameters:
username - the user name for the user
password - the password. This may be null to generate a new password
email - the email address of the user
fullname - the user's full name
Returns:
the user object created
Throws:
DuplicateEntityException - If the user already exists
ImmutableException - If osuser has been misconfigured
Since:
v3.13
See Also:
createJiraUserPreserveCase(String, String, String, String)

createJiraUserPreserveCase

User createJiraUserPreserveCase(String username,
                                String password,
                                String email,
                                String fullname)
                                throws DuplicateEntityException,
                                       ImmutableException
Create a JIRA user. This user will be added to all groups with the USE permission.

Any upper case in the username is preserved.

If password is specified as null, a new password will be generated for the user.

NOTE: This method does not fire any user events, you will need to fire them yourself if you want to.

Parameters:
username - the user name for the user
password - the password. This may be null to generate a new password
email - the email address of the user
fullname - the user's full name
Returns:
the user object created
Throws:
DuplicateEntityException - If the user already exists
ImmutableException - If osuser has been misconfigured
Since:
v3.13
See Also:
createJiraUser(String, String, String, String)

removeUser

void removeUser(User user)
Deletes the user and removes the user from all the groups.

Parameters:
user - the user to delete

addToJiraUsePermission

void addToJiraUsePermission(User user)
Takes the given user and adds him/her to all the groups that grant a user the global JIRA use permission. (see Permissions.USE) Note: operation is only performed if by doing so we will not exceed the user limit (if the current license happens to specify a limit)

Parameters:
user - The user to be added to the USE permission
Since:
v3.13

getDisplayableNameSafely

String getDisplayableNameSafely(User user)
Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.

Parameters:
user - the user. May be null.
Returns:
The user's full name if present and not blank, the username if present, or null otherwise.


Copyright © 2002-2009 Atlassian. All Rights Reserved.