org.locomotive.loco.store.user
Class UserStoreJdbc

java.lang.Object
  |
  +--org.locomotive.loco.store.user.UserStore
        |
        +--org.locomotive.loco.store.user.UserStoreJdbc
Direct Known Subclasses:
UserStoreJdbcCloudscape, UserStoreJdbcInformix, UserStoreJdbcInterbase, UserStoreJdbcMysql, UserStoreJdbcOracle, UserStoreJdbcPostgresql, UserStoreJdbcSolid

public class UserStoreJdbc
extends UserStore


Constructor Summary
UserStoreJdbc()
           
 
Method Summary
 int createUser(java.sql.Connection conn, int uid, java.lang.String un, java.lang.String pword, int locoflg)
          Persistantly stores User's data.
 boolean exists(java.sql.Connection conn, int id)
          returns true if a user with this userid exists in the user database
 boolean exists(java.sql.Connection conn, java.lang.String un)
          returns true if a user in the user database has the same name
 boolean existsAnyCase(java.sql.Connection conn, java.lang.String un)
          returns true if a user in the user database has the same name, regardless of case.
protected  java.math.BigInteger getNextUserId(java.sql.Connection conn)
          returns the next free user id
 java.lang.String getUsername(java.sql.Connection conn, int userid)
          Given a userid, return the username
 java.util.Vector getUsernames(java.sql.Connection conn, java.util.Vector userids)
          Given a vector of Integer-ized userids, look up each username for them.
 LocoUserRow load(java.sql.Connection conn, int uid)
          used by constructor above - loads User based on uid from db
 LocoUserRow load(java.sql.Connection conn, java.lang.String un, boolean sensitiveToCase)
          used by constructor above - loads User based on un from db
 java.lang.String[] loadAllUserNames(java.sql.Connection conn)
          Returns an array of all the user names in the database.
 User[] loadUsers(java.sql.Connection conn, int[] userids)
          Searches the user database and returns a list of Users, based upon userid.
 void save(java.sql.Connection conn, int userid, java.lang.String username, java.lang.String password, int loco_flags)
          Updates the User data in the database if changes have been made, silently ignored on anonymous users
 void saveLoginTime(java.sql.Connection conn, int userid)
          Updates the user.last_login field in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserStoreJdbc

public UserStoreJdbc()
Method Detail

getNextUserId

protected java.math.BigInteger getNextUserId(java.sql.Connection conn)
                                      throws IdException
returns the next free user id
Overrides:
getNextUserId in class UserStore
Parameters:
conn - a JDBC connection with access to the Loco user database
Throws:
IdException - if the id could not be generated

createUser

public int createUser(java.sql.Connection conn,
                      int uid,
                      java.lang.String un,
                      java.lang.String pword,
                      int locoflg)
               throws LoadUserException
Persistantly stores User's data. Will fail if uid is not unique (uid <= 0 will cause system to pick a userid). Will also fail if un (intended username) is already used.
Overrides:
createUser in class UserStore
Parameters:
conn - a JDBC connection with access to the Loco user database
uid - the userid, system will pick if <= 0
un - username of the new user
pword - password of the new user
locoflg - flags of the new user for Loco-specific functions
Throws:
LoadUserException - if there is a database storage error

exists

public boolean exists(java.sql.Connection conn,
                      int id)
               throws LoadUserException
returns true if a user with this userid exists in the user database
Overrides:
exists in class UserStore
Parameters:
conn - a JDBC connection with access to the Loco user database
id - the userid of the user to look for
Throws:
LoadUserException - if there is a database access error

exists

public boolean exists(java.sql.Connection conn,
                      java.lang.String un)
               throws LoadUserException
returns true if a user in the user database has the same name
Overrides:
exists in class UserStore
Parameters:
conn - a JDBC connection with access to the Loco user database
un - the username of the user to look for
Throws:
LoadUserException - if there is a database access error

existsAnyCase

public boolean existsAnyCase(java.sql.Connection conn,
                             java.lang.String un)
                      throws LoadUserException
returns true if a user in the user database has the same name, regardless of case. e.g. user "bob" exists, even though the userbase only contains a user "Bob"
Overrides:
existsAnyCase in class UserStore
Parameters:
conn - a JDBC connection with access to the Loco user database
un - the username of the user to look for
Throws:
LoadUserException - if there is a database access error

saveLoginTime

public void saveLoginTime(java.sql.Connection conn,
                          int userid)
                   throws LoadUserException
Updates the user.last_login field in the database. silently ignored on anonymous users
Overrides:
saveLoginTime in class UserStore
Parameters:
conn - an active JDBC connection
Throws:
LoadUserException - if there is a database storage error

save

public void save(java.sql.Connection conn,
                 int userid,
                 java.lang.String username,
                 java.lang.String password,
                 int loco_flags)
          throws LoadUserException
Updates the User data in the database if changes have been made, silently ignored on anonymous users
Overrides:
save in class UserStore
Parameters:
conn - an active JDBC connection
Throws:
LoadUserException - if there is a database storage error

load

public LocoUserRow load(java.sql.Connection conn,
                        java.lang.String un,
                        boolean sensitiveToCase)
                 throws LoadUserException
used by constructor above - loads User based on un from db
Overrides:
load in class UserStore

load

public LocoUserRow load(java.sql.Connection conn,
                        int uid)
                 throws LoadUserException
used by constructor above - loads User based on uid from db
Overrides:
load in class UserStore

loadUsers

public User[] loadUsers(java.sql.Connection conn,
                        int[] userids)
                 throws LoadUserException
Searches the user database and returns a list of Users, based upon userid.
Overrides:
loadUsers in class UserStore
Parameters:
conn - a JDBC connection
userids - a list of userids to retrieve
Throws:
LoadUserException - if there is a database storage error

loadAllUserNames

public java.lang.String[] loadAllUserNames(java.sql.Connection conn)
                                    throws LoadUserException
Returns an array of all the user names in the database.
Overrides:
loadAllUserNames in class UserStore
Parameters:
conn - a JDBC connection
Throws:
LoadUserException - if there is a database storage error

getUsernames

public java.util.Vector getUsernames(java.sql.Connection conn,
                                     java.util.Vector userids)
                              throws java.sql.SQLException
Given a vector of Integer-ized userids, look up each username for them.
Overrides:
getUsernames in class UserStore

getUsername

public java.lang.String getUsername(java.sql.Connection conn,
                                    int userid)
                             throws java.sql.SQLException
Given a userid, return the username
Overrides:
getUsername in class UserStore