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.


Nested Class Summary
static interface UserUtil.PasswordResetToken
           
static interface UserUtil.PasswordResetTokenValidation
           
 
Field Summary
static java.lang.String META_PROPERTY_PREFIX
           
 
Method Summary
 void addToJiraUsePermission(com.opensymphony.user.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(com.opensymphony.user.Group group, com.opensymphony.user.User userToAdd)
          This is used to add a specified user to a specified group.
 void addUserToGroups(java.util.Collection<com.opensymphony.user.Group> groups, com.opensymphony.user.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(java.util.Collection<java.lang.String> 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 changePassword(com.opensymphony.user.User user, java.lang.String newPassword)
          Can be called to set the password for a user.
 void clearActiveUserCount()
          Clears the cache of the active user count so that it can be recalculated.
 com.opensymphony.user.User createUserNoEvent(java.lang.String username, java.lang.String password, java.lang.String email, java.lang.String fullname)
          Given a valid validation result, this will create the user using the details provided in the validation result.
 com.opensymphony.user.User createUserWithEvent(java.lang.String username, java.lang.String password, java.lang.String email, java.lang.String fullname, int userEventType)
          Given a valid validation result, this will create the user using the details provided in the validation result.
 UserUtil.PasswordResetToken generatePasswordResetToken(com.opensymphony.user.User user)
          This is used to generate a reset password token that last a certain time and allows a person to access a page anonymously so they can reset their password.
 int getActiveUserCount()
          Returns the number of users that are currently 'active'.
 java.util.Collection<com.opensymphony.user.User> getAdministrators()
          Returns a list of JIRA admin Users.
 java.util.Set<com.opensymphony.user.User> getAllUsers()
          Returns the all user-names defined in JIRA, regardless of whether they are active or not.
 java.util.Collection<ProjectComponent> getComponentsUserLeads(com.opensymphony.user.User user)
          Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.
 java.lang.String getDisplayableNameSafely(com.opensymphony.user.User user)
          Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.
 com.opensymphony.user.Group getGroup(java.lang.String groupName)
          Returns a Group based on user name.
 long getNumberOfAssignedIssuesIgnoreSecurity(com.opensymphony.user.User loggedInUser, com.opensymphony.user.User user)
          Returns number of issues assigned to user
 long getNumberOfReportedIssuesIgnoreSecurity(com.opensymphony.user.User loggedInUser, com.opensymphony.user.User user)
          Returns number of issues reported by user
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsUserLeads(com.opensymphony.user.User user)
          Returns all the projects that leadUser is the project lead for.
 java.util.Collection<com.opensymphony.user.User> getSystemAdministrators()
          Returns a list of JIRA system admin Users.
 int getTotalUserCount()
          Returns the total number of users defined in JIRA, regardless of whether they are active or not.
 com.opensymphony.user.User getUser(java.lang.String userName)
          Returns a user based on user name.
 java.util.SortedSet<com.opensymphony.user.User> getUsersInGroupNames(java.util.Collection<java.lang.String> groupNames)
          Returns a collection of User objects that are found within the passed in collection of group names.
 java.util.SortedSet<com.opensymphony.user.User> getUsersInGroups(java.util.Collection<com.opensymphony.user.Group> groups)
          Returns a collection of User objects that are found within the passed in collection of Group objects.
 boolean hasExceededUserLimit()
          Returns true if this JIRA instance has more active users, than allowed by the license.
 boolean isNonSysAdminAttemptingToDeleteSysAdmin(com.opensymphony.user.User loggedInUser, com.opensymphony.user.User user)
          Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.
 void removeUser(com.opensymphony.user.User loggedInUser, com.opensymphony.user.User user, I18nHelper i18nBean)
          Given a valid validation result, this will remove the user and removes the user from all the groups.
 void removeUserFromGroup(com.opensymphony.user.Group group, com.opensymphony.user.User userToRemove)
          This is used to remove a specified user from a specified group.
 void removeUserFromGroups(java.util.Collection<com.opensymphony.user.Group> groups, com.opensymphony.user.User userToRemove)
          This is used to remove a user from many groups at once.
 boolean userExists(java.lang.String userName)
          Returns true if the a user exists with the specified userName
 UserUtil.PasswordResetTokenValidation validatePasswordResetToken(com.opensymphony.user.User user, java.lang.String token)
          This can be called to validate a token against the user.
 

Field Detail

META_PROPERTY_PREFIX

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

getTotalUserCount

int getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not.

Returns:
the total number of users defined in JIRA
Since:
v4.0

getAllUsers

@NotNull
java.util.Set<com.opensymphony.user.User> getAllUsers()
Returns the all user-names defined in JIRA, regardless of whether they are active or not.

Returns:
the set of all user names defined in JIRA
Since:
v4.0

getGroup

com.opensymphony.user.Group getGroup(@Nullable
                                     java.lang.String groupName)
Returns a Group based on user name.

Parameters:
groupName - the user name of the group
Returns:
the Group object, or null if the user cannot be found including null groupName.
Since:
v4.0

createUserWithEvent

com.opensymphony.user.User createUserWithEvent(java.lang.String username,
                                               java.lang.String password,
                                               java.lang.String email,
                                               java.lang.String fullname,
                                               int userEventType)
                                               throws com.opensymphony.user.ImmutableException,
                                                      com.opensymphony.user.DuplicateEntityException
Given a valid validation result, this will create the user using the details provided in the validation result. Email notification will be send to created user.

Parameters:
username - The username of the new user. Needs to be lowercase and unique.
password - The password for the new user.
email - The email for the new user. Needs to be a valid email address.
fullname - The full name for the new user
userEventType - The event type dispatched on user creation
Returns:
The new user object that was created
Throws:
com.opensymphony.user.ImmutableException - Generic exception ocurred when creating the user
com.opensymphony.user.DuplicateEntityException - User with this username alread exists
Since:
4.0

createUserNoEvent

com.opensymphony.user.User createUserNoEvent(java.lang.String username,
                                             java.lang.String password,
                                             java.lang.String email,
                                             java.lang.String fullname)
                                             throws com.opensymphony.user.ImmutableException,
                                                    com.opensymphony.user.DuplicateEntityException
Given a valid validation result, this will create the user using the details provided in the validation result. No email notification will be send to created user.

Parameters:
username - The username of the new user. Needs to be lowercase and unique.
password - The password for the new user.
email - The email for the new user. Needs to be a valid email address.
fullname - The full name for the new user
Returns:
The new user object that was created
Throws:
com.opensymphony.user.ImmutableException - Generic exception ocurred when creating the user
com.opensymphony.user.DuplicateEntityException - User with this username alread exists
Since:
4.0

removeUser

void removeUser(com.opensymphony.user.User loggedInUser,
                com.opensymphony.user.User user,
                I18nHelper i18nBean)
Given a valid validation result, this will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Parameters:
loggedInUser - username of the user performing operation
user - the user to delete
i18nBean - unused may as well be null

addUserToGroup

void addUserToGroup(com.opensymphony.user.Group group,
                    com.opensymphony.user.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(java.util.Collection<com.opensymphony.user.Group> groups,
                     com.opensymphony.user.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(com.opensymphony.user.Group group,
                         com.opensymphony.user.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(java.util.Collection<com.opensymphony.user.Group> groups,
                          com.opensymphony.user.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.

generatePasswordResetToken

UserUtil.PasswordResetToken generatePasswordResetToken(com.opensymphony.user.User user)
This is used to generate a reset password token that last a certain time and allows a person to access a page anonymously so they can reset their password.

The generated token will be associated with the named user so that that this information can be verified at a later time.

Parameters:
user - the user in question. This MUST not be null
Returns:
a newly generated token that will live for a certain time

validatePasswordResetToken

UserUtil.PasswordResetTokenValidation validatePasswordResetToken(com.opensymphony.user.User user,
                                                                 java.lang.String token)
This can be called to validate a token against the user.

Parameters:
user - the user in play
token - the token they provided
Returns:
a Validation object that describes how the option went

changePassword

void changePassword(com.opensymphony.user.User user,
                    java.lang.String newPassword)
                    throws com.opensymphony.user.ImmutableException
Can be called to set the password for a user. This will delete any password request tokens associated with that user

Parameters:
user - the user in play
newPassword - their new password
Throws:
com.opensymphony.user.ImmutableException - because the underlying user provider does not allow password change

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(java.util.Collection<java.lang.String> 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

com.opensymphony.user.User getUser(java.lang.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(java.lang.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

java.util.Collection<com.opensymphony.user.User> getAdministrators()
Returns a list of JIRA admin Users.

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

getSystemAdministrators

java.util.Collection<com.opensymphony.user.User> 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

addToJiraUsePermission

void addToJiraUsePermission(com.opensymphony.user.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

getComponentsUserLeads

java.util.Collection<ProjectComponent> getComponentsUserLeads(com.opensymphony.user.User user)
Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.

Parameters:
user - User leading components
Returns:
Collection of project components

getProjectsUserLeads

java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsUserLeads(com.opensymphony.user.User user)
Returns all the projects that leadUser is the project lead for.

Parameters:
user - the user in play
Returns:
A collection of project GenericValues

isNonSysAdminAttemptingToDeleteSysAdmin

boolean isNonSysAdminAttemptingToDeleteSysAdmin(com.opensymphony.user.User loggedInUser,
                                                com.opensymphony.user.User user)
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.

Parameters:
loggedInUser - User performing operation
user - User for remove
Returns:
true if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights

getNumberOfReportedIssuesIgnoreSecurity

long getNumberOfReportedIssuesIgnoreSecurity(com.opensymphony.user.User loggedInUser,
                                             com.opensymphony.user.User user)
                                             throws SearchException
Returns number of issues reported by user

Parameters:
loggedInUser - the logged in user
user - the user to find the issue count for
Returns:
number of issues reported by user
Throws:
SearchException - if something goes wrong

getNumberOfAssignedIssuesIgnoreSecurity

long getNumberOfAssignedIssuesIgnoreSecurity(com.opensymphony.user.User loggedInUser,
                                             com.opensymphony.user.User user)
                                             throws SearchException
Returns number of issues assigned to user

Parameters:
loggedInUser - the logged in user
user - the user to find the issue count for
Returns:
number of issues assigned to user
Throws:
SearchException - if something goes wrong

getDisplayableNameSafely

java.lang.String getDisplayableNameSafely(com.opensymphony.user.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.

getUsersInGroupNames

java.util.SortedSet<com.opensymphony.user.User> getUsersInGroupNames(java.util.Collection<java.lang.String> groupNames)
Returns a collection of User objects that are found within the passed in collection of group names. Null users are excluded even if they exist in the underlying data.

Parameters:
groupNames - a collection of group name strings
Returns:
the set of users that are in the named groups, sorted in BestNameComparator order

getUsersInGroups

java.util.SortedSet<com.opensymphony.user.User> getUsersInGroups(java.util.Collection<com.opensymphony.user.Group> groups)
Returns a collection of User objects that are found within the passed in collection of Group objects. Null users are excluded even if they exist in the underlying data.

Parameters:
groups - a collection of Group objects
Returns:
the set of users that are in the groups, sorted in BestNameComparator order


Copyright © 2002-2010 Atlassian. All Rights Reserved.