|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.jdbc.Repository
com.samskivert.jdbc.SimpleRepository
com.samskivert.jdbc.JORARepository
com.samskivert.servlet.user.UserRepository
public class UserRepository
Interfaces with the RDBMS in which the user information is stored. The user repository encapsulates the creating, loading and management of users and sessions.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.samskivert.jdbc.SimpleRepository |
|---|
SimpleRepository.PreCondition |
| Nested classes/interfaces inherited from class com.samskivert.jdbc.Repository |
|---|
Repository.Operation<V> |
| Field Summary | |
|---|---|
protected Table<User> |
_utable
A wrapper that provides access to the userstable. |
static String |
USER_REPOSITORY_IDENT
The database identifier used to obtain a connection from our connection provider. |
| Fields inherited from class com.samskivert.jdbc.SimpleRepository |
|---|
_dbident, _precond |
| Fields inherited from class com.samskivert.jdbc.Repository |
|---|
_provider |
| Constructor Summary | |
|---|---|
UserRepository(ConnectionProvider provider)
Creates the repository and opens the user database. |
|
| Method Summary | |
|---|---|
protected void |
createTables()
During construction, this function will be called to give the repository implementation the opportunity to create its table objects. |
int |
createUser(Username username,
Password password,
String realname,
String email,
int siteId)
Requests that a new user be created in the repository. |
void |
deleteUser(User user)
'Delete' the users account such that they can no longer access it, however we do not delete the record from the db. |
protected String |
genIdString(int[] userIds)
Take the passed in int array and create the a string suitable for using in a SQL set query (I.e., "select foo, from bar where userId in (genIdString(userIds))"; ) |
protected int |
insertUser(User user)
Inserts the supplied user record into the user database, assigning it a userid in the process, which is returned. |
String[] |
loadAllRealNames()
Returns an array with the real names of every user in the system. |
protected String[] |
loadNames(int[] userIds,
String column)
|
String[] |
loadRealNames(int[] userIds)
Loads the real names of the users identified by the supplied user ids and returns them in an array. |
User |
loadUser(int userId)
Looks up a user by userid. |
User |
loadUser(String username)
Looks up a user by username. |
User |
loadUserBySession(String sessionKey)
Looks up a user by a session identifier. |
String[] |
loadUserNames(int[] userIds)
Loads the usernames of the users identified by the supplied user ids and returns them in an array. |
HashIntMap<User> |
loadUsersFromId(int[] userIds)
Looks up users by userid |
protected User |
loadUserWhere(String where)
Loads up a user record that matches the specified where clause. |
ArrayList<User> |
lookupUsersByEmail(String email)
Lookup a user by email address, something that is not efficient and should really only be done by site admins attempting to look up a user record. |
ArrayList<User> |
lookupUsersWhere(String where)
Looks up a list of users that match an arbitrary query. |
protected void |
populateUser(User user,
Username name,
Password pass,
String realname,
String email,
int siteId)
Configures the supplied user record with the provided information in preparation for inserting the record into the database for the first time. |
void |
pruneSessions()
Prunes any expired sessions from the sessions table. |
boolean |
refreshSession(String sessionKey,
int expireDays)
Validates that the supplied session key is still valid and if so, refreshes it for the specified number of days. |
String |
registerSession(User user,
int expireDays)
Creates a new session for the specified user and returns the randomly generated session identifier for that session. |
boolean |
updateUser(User user)
Updates a user that was previously fetched from the repository. |
| Methods inherited from class com.samskivert.jdbc.JORARepository |
|---|
delete, insert, load, load, loadAll, loadAll, loadAllByExample, loadAllByExample, loadByExample, loadByExample, store, update, update, updateField, updateFields |
| Methods inherited from class com.samskivert.jdbc.SimpleRepository |
|---|
checkedUpdate, configureDatabaseIdent, execute, execute, executeUpdate, gotConnection, maintenance, migrateSchema, setExecutePreCondition, toString, update, warnedUpdate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String USER_REPOSITORY_IDENT
userdb which you'll probably need to know to provide the proper
configuration to your connection provider.
protected Table<User> _utable
| Constructor Detail |
|---|
public UserRepository(ConnectionProvider provider)
throws PersistenceException
USER_REPOSITORY_IDENT.
provider - the database connection provider.
PersistenceException| Method Detail |
|---|
public int createUser(Username username,
Password password,
String realname,
String email,
int siteId)
throws UserExistsException,
PersistenceException
username - the username of the new user to create.password - the password for the new user.realname - the user's real name.email - the user's email address.siteId - the unique identifier of the site through which this account is being
created. The resulting user will be tracked as originating from this site for accounting
purposes (SiteIdentifier.DEFAULT_SITE_ID can be used by systems that don't desire to
perform site tracking.
UserExistsException
PersistenceException
public User loadUser(String username)
throws PersistenceException
PersistenceException
public User loadUser(int userId)
throws PersistenceException
PersistenceException
public User loadUserBySession(String sessionKey)
throws PersistenceException
PersistenceException
public HashIntMap<User> loadUsersFromId(int[] userIds)
throws PersistenceException
PersistenceException
public ArrayList<User> lookupUsersByEmail(String email)
throws PersistenceException
PersistenceException
public ArrayList<User> lookupUsersWhere(String where)
throws PersistenceException
PersistenceException
public boolean updateUser(User user)
throws PersistenceException
PersistenceException
public void deleteUser(User user)
throws PersistenceException
PersistenceException
public String registerSession(User user,
int expireDays)
throws PersistenceException
expireDays - the number of days in which the session token should expire.
PersistenceException
public boolean refreshSession(String sessionKey,
int expireDays)
throws PersistenceException
PersistenceException
public void pruneSessions()
throws PersistenceException
PersistenceException
public String[] loadUserNames(int[] userIds)
throws PersistenceException
PersistenceException
public String[] loadRealNames(int[] userIds)
throws PersistenceException
PersistenceException
public String[] loadAllRealNames()
throws PersistenceException
PersistenceException
protected void populateUser(User user,
Username name,
Password pass,
String realname,
String email,
int siteId)
protected int insertUser(User user)
throws UserExistsException,
PersistenceException
UserExistsException
PersistenceException
protected User loadUserWhere(String where)
throws PersistenceException
PersistenceException
protected String[] loadNames(int[] userIds,
String column)
throws PersistenceException
PersistenceExceptionprotected String genIdString(int[] userIds)
protected void createTables()
JORARepository
createTables in class JORARepository
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||