Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.database
Class DbUserManager

java.lang.Object
  extended by com.jivesoftware.base.UserManagerAdapter
      extended by com.jivesoftware.base.database.DbUserManager
All Implemented Interfaces:
AdvancedUserManager, IntrospectiveUserManager, UserManager

public class DbUserManager
extends UserManagerAdapter
implements AdvancedUserManager

Database implementation of the UserManager interface. It uses the DbUser class along with the jiveUser database table to store and manipulate user information.

This UserManager implementation uses two global caches to vastly improve speed:

If making your own UserManager implementation, it's highly recommended that you also use these caches.


Field Summary
static Cache userEmailCache
           
 
Constructor Summary
DbUserManager()
           
 
Method Summary
 User createUser(long id, java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String email, boolean nameVisible, boolean emailVisible, java.util.Map properties)
          This method is only designed to be used for mass importing users via the xml export/import utility.
 User createUser(java.lang.String username, java.lang.String password, java.lang.String email)
          Factory method for creating a new User with all required values: a password, email address, and unique username.
 User createUser(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String email, boolean nameVisible, boolean emailVisible, java.util.Map properties)
          Factory method for creating a new User with all required AND optional values.
 void deleteUser(User user)
          Deletes a user.
 int getUserCount()
          Returns the number of users in the system.
 User getUserFromEmailAddress(java.lang.String email)
          Returns a user object corresponding to the email address given.
 java.util.Iterator getUsersFromEmailAddress(java.lang.String email)
          Returns an iterator of user objects corresponding to the email address given.
 boolean isCreateUserSupported()
          Indicates whether user creation (createUser(String username, String password, String email)) is supported.
 boolean isDeleteUserSupported()
          Indicates whether user deletion (deleteUser(User user)) is supported.
 boolean isGetUserCountSupported()
          Indicates whether getting a count of all users (getUserCount()) is supported.
 boolean isGetUserFromEmailAddressSupported()
          Indicates whether retrieving a user for an email address (getUserFromEmailAddress(String emailAddr)) is supported.
 boolean isUserListSupported()
          Indicates whether getting an Iterator of all users (users()) is supported.
protected  User lookupUser(long userID)
          Returns a User with a given user ID.
protected  User lookupUser(java.lang.String username)
          Returns a User with a given username.
 java.util.Iterator users()
          Returns an iterator for all users in the system.
 java.util.Iterator users(int startIndex, int numResults)
          Returns an iterator for all users starting at startIndex with the given number of results.
 
Methods inherited from class com.jivesoftware.base.UserManagerAdapter
getUser, getUser, getUserID, isReadOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userEmailCache

public static Cache userEmailCache
Constructor Detail

DbUserManager

public DbUserManager()
Method Detail

createUser

public User createUser(java.lang.String username,
                       java.lang.String password,
                       java.lang.String email)
                throws UserAlreadyExistsException
Description copied from interface: UserManager
Factory method for creating a new User with all required values: a password, email address, and unique username.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
createUser in interface UserManager
Overrides:
createUser in class UserManagerAdapter
Parameters:
username - the new and unique username for the account.
password - the password for the account as plain text.
email - the email address for the account.
Returns:
a new User.
Throws:
UserAlreadyExistsException - if the username already exists in the system.

createUser

public User createUser(java.lang.String username,
                       java.lang.String password,
                       java.lang.String name,
                       java.lang.String email,
                       boolean nameVisible,
                       boolean emailVisible,
                       java.util.Map properties)
                throws UserAlreadyExistsException
Description copied from interface: UserManager
Factory method for creating a new User with all required AND optional values.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
createUser in interface UserManager
Overrides:
createUser in class UserManagerAdapter
Parameters:
username - the new and unique username for the account.
password - the password for the account as plain text.
name - the name for the account.
email - the email address for the account.
nameVisible - true if the user's name should be visible to others.
emailVisible - true if the user's email address should be visible to others.
properties - the user's extended properties.
Returns:
a new User.
Throws:
UserAlreadyExistsException - if the username already exists in the system.

createUser

public User createUser(long id,
                       java.lang.String username,
                       java.lang.String password,
                       java.lang.String name,
                       java.lang.String email,
                       boolean nameVisible,
                       boolean emailVisible,
                       java.util.Map properties)
                throws UserAlreadyExistsException
This method is only designed to be used for mass importing users via the xml export/import utility.

Throws:
UserAlreadyExistsException

lookupUser

protected User lookupUser(long userID)
                   throws UserNotFoundException
Description copied from class: UserManagerAdapter
Returns a User with a given user ID. This method does not cache -- it checks the underlying User directory or data store.

Specified by:
lookupUser in class UserManagerAdapter
Throws:
UserNotFoundException

lookupUser

protected User lookupUser(java.lang.String username)
                   throws UserNotFoundException
Description copied from class: UserManagerAdapter
Returns a User with a given username. This method does not cache -- it checks the underlying User directory or data store.

Specified by:
lookupUser in class UserManagerAdapter
Throws:
UserNotFoundException

deleteUser

public void deleteUser(User user)
                throws UnauthorizedException
Description copied from interface: UserManager
Deletes a user. To maintain data consistency, deleting a user will cause all messages created by the user to switch to being from an anonymous author.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
deleteUser in interface UserManager
Overrides:
deleteUser in class UserManagerAdapter
Parameters:
user - the user to delete.
Throws:
UnauthorizedException

getUserCount

public int getUserCount()
Description copied from interface: UserManager
Returns the number of users in the system.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
getUserCount in interface UserManager
Overrides:
getUserCount in class UserManagerAdapter
Returns:
the total number of users.

users

public java.util.Iterator users()
Description copied from interface: UserManager
Returns an iterator for all users in the system.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
users in interface UserManager
Overrides:
users in class UserManagerAdapter
Returns:
an Iterator for all users.

users

public java.util.Iterator users(int startIndex,
                                int numResults)
Description copied from interface: UserManager
Returns an iterator for 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 in the system to display.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
users in interface UserManager
Overrides:
users in class UserManagerAdapter
Parameters:
startIndex - the beginning index to start the results at.
numResults - the total number of results to return.
Returns:
an Iterator for all users in the specified range.

getUserFromEmailAddress

public User getUserFromEmailAddress(java.lang.String email)
Description copied from interface: AdvancedUserManager
Returns a user object corresponding to the email address given. If no user is found which corresponds to the given email address null should be returned. If more than one user corresponds to the given email address it is up to the implementation to decide what to do (i.e. return one of the users or return null).

Specified by:
getUserFromEmailAddress in interface AdvancedUserManager
Parameters:
email - the email address to get a user object for.
Returns:
a user object corresponding to the given email address.

getUsersFromEmailAddress

public java.util.Iterator getUsersFromEmailAddress(java.lang.String email)
Description copied from interface: AdvancedUserManager
Returns an iterator of user objects corresponding to the email address given. There is not a uniqueness contraint on the email id ofr a user object, so multiples may be returned. If no users are found which correspond to the given email address, an empty iterator should be returned.

Specified by:
getUsersFromEmailAddress in interface AdvancedUserManager
Parameters:
email - the email address to get a user object for.
Returns:
an iterator of user objects corresponding to the given email address.

isCreateUserSupported

public boolean isCreateUserSupported()
Description copied from interface: IntrospectiveUserManager
Indicates whether user creation (createUser(String username, String password, String email)) is supported.

Specified by:
isCreateUserSupported in interface IntrospectiveUserManager
Overrides:
isCreateUserSupported in class UserManagerAdapter
Returns:
true if user creation is supported.

isDeleteUserSupported

public boolean isDeleteUserSupported()
Description copied from interface: IntrospectiveUserManager
Indicates whether user deletion (deleteUser(User user)) is supported.

Specified by:
isDeleteUserSupported in interface IntrospectiveUserManager
Overrides:
isDeleteUserSupported in class UserManagerAdapter
Returns:
true if user deletion is supported.

isGetUserCountSupported

public boolean isGetUserCountSupported()
Description copied from interface: IntrospectiveUserManager
Indicates whether getting a count of all users (getUserCount()) is supported.

Specified by:
isGetUserCountSupported in interface IntrospectiveUserManager
Overrides:
isGetUserCountSupported in class UserManagerAdapter
Returns:
true if getting a count of all users is supported.

isUserListSupported

public boolean isUserListSupported()
Description copied from interface: IntrospectiveUserManager
Indicates whether getting an Iterator of all users (users()) is supported.

Specified by:
isUserListSupported in interface IntrospectiveUserManager
Overrides:
isUserListSupported in class UserManagerAdapter
Returns:
true if getting an iterator of all users is supported.

isGetUserFromEmailAddressSupported

public boolean isGetUserFromEmailAddressSupported()
Description copied from interface: IntrospectiveUserManager
Indicates whether retrieving a user for an email address (getUserFromEmailAddress(String emailAddr)) is supported.

Specified by:
isGetUserFromEmailAddressSupported in interface IntrospectiveUserManager
Overrides:
isGetUserFromEmailAddressSupported in class UserManagerAdapter
Returns:
true if getting a user with a specific email address is supported.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.