org.activemath.webapp.user
Class UserManager

java.lang.Object
  extended by org.activemath.webapp.user.UserManager

public class UserManager
extends Object

Describe me!


Method Summary
 void addGroup(UserGroup group)
          Add a UserGroup to groupMap if it doesn't already exist
 void buildUserGroups()
          Instantiate UserGroups from DB.
 String createBookId(String userId)
           
 List<User> getAdmins()
           
 User getAnyUser(String userId)
          Return the User object for any user (doesn't have to be logged in).
 List<User> getAuthors()
           
static UserManager getInstance()
           
 Set<String> getLoggedInUsers()
           
 UserManagerService getService()
           
 List<User> getTutors()
           
 User getUser(String userId)
          Return the User object of a logged-in user.
 UserGroup getUserGroup(String groupId)
          Retrieve a user group, fall back to default group.
 String getUserGroupId(String userId)
          Get group id for user id.
 List<UserGroup> getUserGroups()
           
 List<User> getUsersWithRole(UserRole role)
           
 boolean isDefaultAdmin(String userId)
           
 boolean isLoggedIn(String userId)
           
 boolean isValidUserId(String userId)
          Say if a userId is valid.
 boolean isVisitor(String userId)
           
 User login(String userId)
          Login the given user.
 void logout(String userId)
          Logs out the given user.
 void registerNewUser(User newUser)
          Creates a new user in the UserModel server.
 boolean removeGroup(String groupId)
          Delete a UserGroup, if existent
 void saveGroup(UserGroup group)
          Overwrite existing UserGroup in groupMap, or else create new group
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static UserManager getInstance()

buildUserGroups

public void buildUserGroups()
Instantiate UserGroups from DB.


addGroup

public void addGroup(UserGroup group)
Add a UserGroup to groupMap if it doesn't already exist


saveGroup

public void saveGroup(UserGroup group)
Overwrite existing UserGroup in groupMap, or else create new group


removeGroup

public boolean removeGroup(String groupId)
Delete a UserGroup, if existent


getUserGroupId

public String getUserGroupId(String userId)
Get group id for user id.

Returns:
groupId if user userId exists, or null.

getUserGroup

public UserGroup getUserGroup(String groupId)
Retrieve a user group, fall back to default group.

Returns:
UserGroup with groupId if it exists, or the instance of default group.

getUserGroups

public List<UserGroup> getUserGroups()
Returns:
List of all UserGroups, sorted by name.

getService

public UserManagerService getService()

createBookId

public String createBookId(String userId)

isDefaultAdmin

public boolean isDefaultAdmin(String userId)

getUser

public User getUser(String userId)
Return the User object of a logged-in user.

Parameters:
userId - a user's id (handled in lowercase)
Returns:
User object of logged-in user, or null.

getAnyUser

public User getAnyUser(String userId)
Return the User object for any user (doesn't have to be logged in).

Returns:
User object, or null.

getUsersWithRole

public List<User> getUsersWithRole(UserRole role)
Returns:
a list of all users with a specific role.

getTutors

public List<User> getTutors()
Returns:
a list of all users with role "Tutor".

getAuthors

public List<User> getAuthors()
Returns:
a list of all users with role "AUTHOR".

getAdmins

public List<User> getAdmins()
Returns:
a list of all users with role "ADMIN".

getLoggedInUsers

public Set<String> getLoggedInUsers()

isLoggedIn

public boolean isLoggedIn(String userId)

isVisitor

public boolean isVisitor(String userId)

isValidUserId

public boolean isValidUserId(String userId)
Say if a userId is valid. A user id must contain only letters and digits.


registerNewUser

public void registerNewUser(User newUser)
                     throws UserManagerException
Creates a new user in the UserModel server.

Parameters:
newUser - user to create in UserModel
Throws:
UserManagerException

login

public User login(String userId)
           throws UserManagerException
Login the given user.

Parameters:
userId - id of the user to log in.
Throws:
UserManagerException - when the login process didn't succeed.

logout

public void logout(String userId)
            throws UserManagerException
Logs out the given user.

Parameters:
userId - The user to log out
Throws:
UserManagerException - If something went wrong in the logout process.