info.aduna.gee.publication.servlets.cache
Class UserInfoCache

java.lang.Object
  extended by info.aduna.gee.publication.servlets.cache.UserInfoCache

public class UserInfoCache
extends Object

Class UserInfoCache


Field Summary
protected static HashMap _usersPerHost
          A mapping of hostnames to (Array)Lists of UserInfo objects.
 
Constructor Summary
UserInfoCache()
           
 
Method Summary
protected static ArrayList _fillCache(String host)
          Fills the cache for the indicated host with the info from the userdb.
protected static UserInfo _get(String host, String username)
          Gets a UserInfo object from the cache.
static int binarySearch(List users, String name)
          See Arrays.binarySearch() for comments.
static void changeAselev(String host, String username, int aselev)
          Changes the aselev (Associates Edit Level -- currently only 0 or 1) value for a certain user.
static void changeCover(String host, String username, String cover)
          Change the cover of a certain user.
static void changeEmail(String host, String username, String email)
          Changes the email address for a certain user.
static void changeInheritCfg(String host, String username, String inheritcfg)
          Changes the inheritcfg for a certain user.
static void changePassword(String host, String username, String password)
          Changes the password for a certain user.
static ArrayList ensureUsersLoaded(String host)
          Ensures the list of users for a certain host is loaded.
static boolean exists(String host, String username)
           
static UserInfo get(String host, String username)
          Gets a UserInfo object from this cache.
static List getAllHosts()
          Get a list of all hosts currently active.
static List getAllUserNames(String host)
          Gets all usernames known for a certain host.
static List getAllUsers(String host)
          Gets a list of all UserInfo objects for a certain host.
static List getCfgInheritors(String host, String user)
          Get a list of all UserInfo objects for a certain host that inherit their configuration (a.k.a.
static void put(String host, UserInfo userInfo)
          Puts a (new) user into the UserInfoCache and the underlying userdb.
static void refresh(String host)
          Refreshes (throws away) the cached info for a certain host.
static void remove(String host, UserInfo userInfo)
          Removes a user and all of its aliases from the UserInfoCache, the AliasInfoCache, the AssociateInfoCache as well as from the underlying databases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_usersPerHost

protected static HashMap _usersPerHost
A mapping of hostnames to (Array)Lists of UserInfo objects.

Constructor Detail

UserInfoCache

public UserInfoCache()
Method Detail

refresh

public static void refresh(String host)
Refreshes (throws away) the cached info for a certain host.

Parameters:
host - the name of the server to refresh the cache for

ensureUsersLoaded

public static ArrayList ensureUsersLoaded(String host)
Ensures the list of users for a certain host is loaded.

Parameters:
host - the name of the server to ensure the loaded list for
Returns:
the list of users (guaranteed non-null).

exists

public static boolean exists(String host,
                             String username)
Returns:
true if the user exists in the cache

get

public static UserInfo get(String host,
                           String username)
Gets a UserInfo object from this cache. If the supplied username is an alias, then a new UserInfo object containing the real user's info and the alias's cover will be created.

Parameters:
host - the Zpad server on which the user is registered
username - the name of a user
Returns:
the UserInfo object for the user or null if not found.

getAllUsers

public static List getAllUsers(String host)
Gets a list of all UserInfo objects for a certain host. The returned List is the object used by this cache, so be carefull with that (DON'T CHANGE)! Also, the returned List is unsynchronized!


getCfgInheritors

public static List getCfgInheritors(String host,
                                    String user)
Get a list of all UserInfo objects for a certain host that inherit their configuration (a.k.a. Privacy Groups) of a given user.


getAllHosts

public static List getAllHosts()
Get a list of all hosts currently active.


getAllUserNames

public static List getAllUserNames(String host)
Gets all usernames known for a certain host. The list returned is a snapshot of the names in this cache, so don't count on all names still existing when you use them!


_get

protected static UserInfo _get(String host,
                               String username)
Gets a UserInfo object from the cache.


put

public static void put(String host,
                       UserInfo userInfo)
Puts a (new) user into the UserInfoCache and the underlying userdb. Any info with the same username will be overwritten.


remove

public static void remove(String host,
                          UserInfo userInfo)
Removes a user and all of its aliases from the UserInfoCache, the AliasInfoCache, the AssociateInfoCache as well as from the underlying databases.


changeCover

public static void changeCover(String host,
                               String username,
                               String cover)
Change the cover of a certain user. If the supplied username is an alias, the cover will be changed on that alias.


changeEmail

public static void changeEmail(String host,
                               String username,
                               String email)
Changes the email address for a certain user. If the supplied name is an alias, the email address will be set on the real user.


changePassword

public static void changePassword(String host,
                                  String username,
                                  String password)
Changes the password for a certain user. If the supplied name is an alias, the password will be set on the real user.


changeAselev

public static void changeAselev(String host,
                                String username,
                                int aselev)
Changes the aselev (Associates Edit Level -- currently only 0 or 1) value for a certain user.


changeInheritCfg

public static void changeInheritCfg(String host,
                                    String username,
                                    String inheritcfg)
Changes the inheritcfg for a certain user.


_fillCache

protected static ArrayList _fillCache(String host)
Fills the cache for the indicated host with the info from the userdb. If the userdb for that host does not exist, an empty ArrayList will be inserted.


binarySearch

public static int binarySearch(List users,
                               String name)
See Arrays.binarySearch() for comments.



Copyright © 1997-2008 Aduna. All Rights Reserved.