de.fh_mannheim.mm.dms.framework
Class UserManager

java.lang.Object
  extended byde.fh_mannheim.mm.dms.framework.UserManager
All Implemented Interfaces:
IElement, IProducer

public class UserManager
extends java.lang.Object
implements IProducer

Organizes user accounts and connects to the database.

Version:
$Revision: 1.37 $
Author:
Jan Löffler, mail@jlsoft.de

Constructor Summary
UserManager(Config cfg)
          Constructor.
 
Method Summary
 boolean addUser(java.lang.String strName, java.lang.String strUsername, java.lang.String strPassword)
          Add a new user.
 boolean addUser(java.lang.String strName, java.lang.String strUsername, java.lang.String strPassword, Accesstype accesstype)
          Add a new user.
 boolean addUser(User newUser)
          Add a new user.
 boolean addUserCatgory(int nUserID, java.lang.String strCategory)
          Add a category to a user.
 boolean addUserDirectory(User user)
          Add a user directory.
 boolean clearUserProfile(int nID)
          Clear profile of user.
 boolean deleteUser(int nID)
          Delete user.
 boolean existsUser(int nUserID)
          Check if user exists.
 boolean existsUser(java.lang.String strUsername)
          Check if user exists.
 boolean exportUsers(java.lang.String strFilename)
          Export users to xml file.
 java.util.ArrayList getAllNames()
          Get all usernames.
 java.util.ArrayList getAllUsernames()
          Get all usernames.
 UserList getAllUsers()
          Get all users.
 User getCurrentUser()
          Get current user.
 User getDefaultUser()
          Get default user.
 UserList getEqualUsers(int nUserID, int nLimit)
          Search users who have the same categories.
 User getUser(int nUserID)
          Search user.
 User getUser(int nUserID, java.lang.String strPassword)
          Search user.
 User getUser(java.lang.String strUsername)
          Search user.
 User getUser(java.lang.String strUsername, java.lang.String strPassword)
          Search user.
 User getUserByName(java.lang.String strName)
          Search user.
 CategoryList getUserCategoryList(int nUserID)
          Search categories for user.
 int getUserNum()
          Count all users.
 int importUsers(java.lang.String strFilename)
          Import users from xml file..
 org.w3c.dom.Document produceReport()
          Generate xml document.
 boolean setCurrentUser(int nUserID, java.lang.String strPassword)
          Set current user.
 boolean setCurrentUser(java.lang.String strUsername, java.lang.String strPassword)
          Set current user.
 boolean setCurrentUser(User user)
          Set current user.
 org.w3c.dom.Element toElement(org.w3c.dom.Document doc)
          Write information of uploads in a xml element.
 org.w3c.dom.Element toElement(org.w3c.dom.Element element, org.w3c.dom.Document doc)
          Write information of uploads in a xml element.
 java.lang.String toString()
          Write information of users in a string.
 boolean updateUser(User editedUser)
          Update an existing user.
 boolean updateUser(User editedUser, java.lang.String strPassword)
          Update an existing user.
 boolean validateUser(int nUserID, java.lang.String strPassword)
          Validate user.
 boolean validateUser(User user)
          Validate user.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserManager

public UserManager(Config cfg)
Constructor.

Parameters:
cfg - Config
Method Detail

addUser

public boolean addUser(java.lang.String strName,
                       java.lang.String strUsername,
                       java.lang.String strPassword)
                throws DuplicateUserException
Add a new user.

Parameters:
strName - Name of user
strUsername - Username of user
strPassword - Password
Returns:
true, if successful
Throws:
DuplicateUserException

addUser

public boolean addUser(java.lang.String strName,
                       java.lang.String strUsername,
                       java.lang.String strPassword,
                       Accesstype accesstype)
                throws DuplicateUserException
Add a new user.

Parameters:
strName - Name of user
strUsername - Username of user
strPassword - Password
accesstype - User rights
Returns:
true, if successful
Throws:
DuplicateUserException

addUser

public boolean addUser(User newUser)
                throws DuplicateUserException
Add a new user.

Parameters:
newUser - User, which should be added
Returns:
true, if successful
Throws:
DuplicateUserException

addUserCatgory

public boolean addUserCatgory(int nUserID,
                              java.lang.String strCategory)
Add a category to a user.

Parameters:
nUserID - User
strCategory - Category
Returns:
true, if successful

addUserDirectory

public boolean addUserDirectory(User user)
Add a user directory.

Parameters:
user - User, which should be added
Returns:
true, if successful

deleteUser

public boolean deleteUser(int nID)
Delete user.

Parameters:
nID - ID of user
Returns:
true, if successful

clearUserProfile

public boolean clearUserProfile(int nID)
Clear profile of user.

Parameters:
nID - ID of user
Returns:
true, if successful

existsUser

public boolean existsUser(int nUserID)
Check if user exists.

Parameters:
nUserID - ID of user
Returns:
true, if successful

existsUser

public boolean existsUser(java.lang.String strUsername)
Check if user exists.

Parameters:
strUsername - Name of user
Returns:
true, if successful

exportUsers

public boolean exportUsers(java.lang.String strFilename)
                    throws java.io.IOException
Export users to xml file.

Parameters:
strFilename - Filename of xml file
Returns:
true, if successful
Throws:
java.io.IOException - When file could not be saved

getAllUsernames

public java.util.ArrayList getAllUsernames()
Get all usernames.

Returns:
List with all found records

getAllNames

public java.util.ArrayList getAllNames()
Get all usernames.

Returns:
List with all found records

getAllUsers

public UserList getAllUsers()
Get all users.

Returns:
List with all found records

getCurrentUser

public User getCurrentUser()
Get current user.

Returns:
current user

getDefaultUser

public User getDefaultUser()
Get default user.

Returns:
current user

getEqualUsers

public UserList getEqualUsers(int nUserID,
                              int nLimit)
Search users who have the same categories.

Parameters:
nUserID - ID of user
nLimit - Limit of user comparations
Returns:
found users in an userlist

getUser

public User getUser(int nUserID)
Search user.

Parameters:
nUserID - ID of user
Returns:
found user

getUser

public User getUser(int nUserID,
                    java.lang.String strPassword)
Search user.

Parameters:
nUserID - ID of user
strPassword - Password
Returns:
found user

getUser

public User getUser(java.lang.String strUsername,
                    java.lang.String strPassword)
Search user.

Parameters:
strUsername - Username of user
strPassword - Password
Returns:
found user

getUser

public User getUser(java.lang.String strUsername)
Search user.

Parameters:
strUsername - Username of user
Returns:
found user

getUserByName

public User getUserByName(java.lang.String strName)
Search user.

Parameters:
strName - Name of user
Returns:
found user

getUserCategoryList

public CategoryList getUserCategoryList(int nUserID)
Search categories for user.

Parameters:
nUserID - ID of user
Returns:
found categorylist

getUserNum

public int getUserNum()
Count all users.

Returns:
number of found users

importUsers

public int importUsers(java.lang.String strFilename)
Import users from xml file..

Parameters:
strFilename - Filename of xmlfile
Returns:
Number of imported users

produceReport

public org.w3c.dom.Document produceReport()
Generate xml document.

Specified by:
produceReport in interface IProducer
Returns:
xml document

toElement

public org.w3c.dom.Element toElement(org.w3c.dom.Document doc)
Write information of uploads in a xml element.

Specified by:
toElement in interface IElement
Parameters:
doc - XML Document
Returns:
element

toElement

public org.w3c.dom.Element toElement(org.w3c.dom.Element element,
                                     org.w3c.dom.Document doc)
Write information of uploads in a xml element.

Specified by:
toElement in interface IElement
Parameters:
element - Root element
doc - XML Document
Returns:
element

setCurrentUser

public boolean setCurrentUser(int nUserID,
                              java.lang.String strPassword)
Set current user.

Parameters:
nUserID - ID of user
strPassword - password
Returns:
true, if user was validated

setCurrentUser

public boolean setCurrentUser(java.lang.String strUsername,
                              java.lang.String strPassword)
Set current user.

Parameters:
strUsername - Username of user, who should be set as current user
strPassword -
Returns:
true, if user was validated

setCurrentUser

public boolean setCurrentUser(User user)
Set current user.

Parameters:
user - User, who should be set as current user

toString

public java.lang.String toString()
Write information of users in a string.

Specified by:
toString in interface IElement
Returns:
information

updateUser

public boolean updateUser(User editedUser,
                          java.lang.String strPassword)
Update an existing user.

Parameters:
editedUser - User, which should be added
strPassword - Password
Returns:
true, if successful

updateUser

public boolean updateUser(User editedUser)
Update an existing user.

Parameters:
editedUser - User, which should be added
Returns:
true, if successful

validateUser

public boolean validateUser(int nUserID,
                            java.lang.String strPassword)
Validate user.

Parameters:
nUserID - ID of user
strPassword - Password
Returns:
true, if user was validated

validateUser

public boolean validateUser(User user)
Validate user.

Parameters:
user - User, who should be validated
Returns:
true, if user was validated