Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base
Class UserManagerProxy

java.lang.Object
  extended by com.jivesoftware.base.UserManagerProxy
All Implemented Interfaces:
IntrospectiveUserManager, UserManager

public class UserManagerProxy
extends java.lang.Object
implements IntrospectiveUserManager

Protection proxy for the UserManager class. It restricts access to protected methods by throwing UnauthorizedExceptions when necessary.

See Also:
UserManager

Constructor Summary
UserManagerProxy(UserManager userManager, AuthToken auth, Permissions permissions)
          Creates a new UserManagerProxy.
 
Method Summary
 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.
 User getUser(long userID)
          Returns a User specified by their ID.
 User getUser(java.lang.String username)
          Returns the User specified by username.
 int getUserCount()
          Returns the number of users in the system.
 long getUserID(java.lang.String username)
          Returns the userID specified by the username.
 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 isReadOnly()
           
 boolean isUserListSupported()
          Indicates whether getting an Iterator of all users (users()) is supported.
protected  void testNumSeats()
           
protected  void triggerEmailExceeded(com.jivesoftware.base.license.Product product, com.jivesoftware.base.license.License license)
           
protected  void triggerEmailWarning(com.jivesoftware.base.license.Product product, com.jivesoftware.base.license.License license)
           
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserManagerProxy

public UserManagerProxy(UserManager userManager,
                        AuthToken auth,
                        Permissions permissions)
Creates a new UserManagerProxy.

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
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
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.

getUser

public User getUser(long userID)
             throws UserNotFoundException
Description copied from interface: UserManager
Returns a User specified by their ID.

Because this method will be called often by other parts of the API, a cache of User objects should be used. UserManagerFactory.userCache can be used for this purpose. The algorithm should be:

  1. Look for the user object in cache with new Long(userID) as the key.
  2. If the object is found in cache, return it.
  3. If the object is not found in cache, load the object from the back-end store then add it to cache with new Long(userID) as the key. Finally, return the user object.

Specified by:
getUser in interface UserManager
Parameters:
userID - the id of the User to lookup.
Returns:
the User specified by userID.
Throws:
UserNotFoundException - if the user does not exist.

getUser

public User getUser(java.lang.String username)
             throws UserNotFoundException
Description copied from interface: UserManager
Returns the User specified by username.

The method should typically be implemented as:
return getUser(getUserID(username));

Specified by:
getUser in interface UserManager
Parameters:
username - the username of the user.
Returns:
the User that matches username.
Throws:
UserNotFoundException - if the user does not exist.

getUserID

public long getUserID(java.lang.String username)
               throws UserNotFoundException
Description copied from interface: UserManager
Returns the userID specified by the username. This method is only useful in specialized cases, as its generally easier to call getUser(username).getID() instead of this method.

Because this method will be called often by other parts of the API, a cache should be used that maps usernames to userIDs. UserManagerFactory.userIDCache can be used for this purpose. The algorithm should be:

  1. Look for the username to userID mapping in cache.
  2. If the mapping is found, return the userID.
  3. If the mapping is not found in cache, load the user object from the back-end store to figure out the correct userID, add the mapping to cache, then return the userID.

Specified by:
getUserID in interface UserManager
Parameters:
username - the username of the usedr.
Returns:
the userID that matches username.
Throws:
UserNotFoundException - if the user does not exist.

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
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
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
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
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.

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
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
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
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
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
Returns:
true if getting a user with a specific email address is supported.

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface IntrospectiveUserManager

testNumSeats

protected void testNumSeats()
                     throws com.jivesoftware.base.license.LicenseException
Throws:
com.jivesoftware.base.license.LicenseException

triggerEmailWarning

protected void triggerEmailWarning(com.jivesoftware.base.license.Product product,
                                   com.jivesoftware.base.license.License license)

triggerEmailExceeded

protected void triggerEmailExceeded(com.jivesoftware.base.license.Product product,
                                    com.jivesoftware.base.license.License license)

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.