Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.user
Class UserManager

java.lang.Object
  extended by org.jivesoftware.wildfire.user.UserManager
All Implemented Interfaces:
IQResultListener

public class UserManager
extends Object
implements IQResultListener

Manages users, including loading, creating and deleting.

Author:
Matt Tucker
See Also:
User

Method Summary
 User createUser(String username, String password, String name, String email)
          Creates a new User.
 void deleteUser(User user)
          Deletes a user (optional operation).
 Collection<User> findUsers(Set<String> fields, String query)
          Searches for users based on a set of fields and a query string.
static UserManager getInstance()
          Returns a singleton UserManager instance.
 Set<String> getSearchFields()
          Returns the set of fields that can be used for searching for users.
 User getUser(String username)
          Returns the User specified by username.
 int getUserCount()
          Returns the total number of users in the system.
 Collection<String> getUsernames()
          Returns an unmodifiable Collection of usernames of all users in the system.
static UserProvider getUserProvider()
          Returns the currently-installed UserProvider.
 Collection<User> getUsers()
          Returns an unmodifiable Collection of all users in the system.
 Collection<User> getUsers(int startIndex, int numResults)
          Returns an unmodifiable Collection of all users starting at startIndex with the given number of results.
 boolean isRegisteredUser(JID user)
          Returns true if the specified JID belongs to a local or remote registered user.
 boolean isRegisteredUser(String username)
          Returns true if the specified local username belongs to a registered local user.
 void receivedAnswer(IQ packet)
          Notification method indicating that a previously sent IQ packet has been answered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUserProvider

public static UserProvider getUserProvider()
Returns the currently-installed UserProvider. Warning: in virtually all cases the user provider should not be used directly. Instead, the appropriate methods in UserManager should be called. Direct access to the user provider is only provided for special-case logic.

Returns:
the current UserProvider.

getInstance

public static UserManager getInstance()
Returns a singleton UserManager instance.

Returns:
a UserManager instance.

createUser

public User createUser(String username,
                       String password,
                       String name,
                       String email)
                throws UserAlreadyExistsException
Creates a new User. Required values are username and password. The email address can optionally be null.

Parameters:
username - the new and unique username for the account.
password - the password for the account (plain text).
name - the name of the user.
email - the email address to associate with the new account, which can be null.
Returns:
a new User.
Throws:
UserAlreadyExistsException - if the username already exists in the system.
UnsupportedOperationException - if the provider does not support the operation.

deleteUser

public void deleteUser(User user)
Deletes a user (optional operation).

Parameters:
user - the user to delete.

getUser

public User getUser(String username)
             throws UserNotFoundException
Returns the User specified by username.

Parameters:
username - the username of the user.
Returns:
the User that matches username.
Throws:
UserNotFoundException - if the user does not exist.

getUserCount

public int getUserCount()
Returns the total number of users in the system.

Returns:
the total number of users.

getUsers

public Collection<User> getUsers()
Returns an unmodifiable Collection of all users in the system.

Returns:
an unmodifiable Collection of all users.

getUsernames

public Collection<String> getUsernames()
Returns an unmodifiable Collection of usernames of all users in the system.

Returns:
an unmodifiable Collection of all usernames in the system.

getUsers

public Collection<User> getUsers(int startIndex,
                                 int numResults)
Returns an unmodifiable Collection of all users starting at startIndex with the given number of results. This is useful to support pagination in a GUI where you may only want to display a certain number of results per page. It is possible that the number of results returned will be less than that specified by numResults if numResults is greater than the number of records left to display.

Parameters:
startIndex - the beginning index to start the results at.
numResults - the total number of results to return.
Returns:
a Collection of users in the specified range.

getSearchFields

public Set<String> getSearchFields()
                            throws UnsupportedOperationException
Returns the set of fields that can be used for searching for users. Each field returned must support wild-card and keyword searching. For example, an implementation might send back the set {"Username", "Name", "Email"}. Any of those three fields can then be used in a search with the findUsers(Set,String) method.

This method should throw an UnsupportedOperationException if this operation is not supported by the backend user store.

Returns:
the valid search fields.
Throws:
UnsupportedOperationException - if the provider does not support the operation (this is an optional operation).

findUsers

public Collection<User> findUsers(Set<String> fields,
                                  String query)
                           throws UnsupportedOperationException
Searches for users based on a set of fields and a query string. The fields must be taken from the values returned by getSearchFields(). The query can include wildcards. For example, a search on the field "Name" with a query of "Ma*" might return user's with the name "Matt", "Martha" and "Madeline".

This method throws an UnsupportedOperationException if this operation is not supported by the user provider.

Parameters:
fields - the fields to search on.
query - the query string.
Returns:
a Collection of users that match the search.
Throws:
UnsupportedOperationException - if the provider does not support the operation (this is an optional operation).

isRegisteredUser

public boolean isRegisteredUser(String username)
Returns true if the specified local username belongs to a registered local user.

Parameters:
username - to username of the user to check it it's a registered user.
Returns:
true if the specified JID belongs to a local registered user.

isRegisteredUser

public boolean isRegisteredUser(JID user)
Returns true if the specified JID belongs to a local or remote registered user. For remote users (i.e. domain does not match local domain) a disco#info request is going to be sent to the bare JID of the user.

Parameters:
user - to JID of the user to check it it's a registered user.
Returns:
true if the specified JID belongs to a local or remote registered user.

receivedAnswer

public void receivedAnswer(IQ packet)
Description copied from interface: IQResultListener
Notification method indicating that a previously sent IQ packet has been answered. The received IQ packet might be of type ERROR or RESULT.

Specified by:
receivedAnswer in interface IQResultListener
Parameters:
packet - the IQ packet answering a previously sent IQ packet.

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.