de.hs_rm.cs.lecturenotes.server.core.persistence.dao
Class UserDAO

java.lang.Object
  extended by de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO<User>
      extended by de.hs_rm.cs.lecturenotes.server.core.persistence.dao.UserDAO
All Implemented Interfaces:
IDAO<User>

public final class UserDAO
extends AbstractDAO<User>

Data Access Object for System Entity Lecture.

Version:
$LastChangedRevision: 296 $
Author:
Enrico Homann

Field Summary
static java.lang.String PASSWORD_HIDDEN_PLACEHOLDER
          No user entity will be given to the client with the real password contents set.
static java.lang.String SQL_TABLENAME
          SQL Table Name.
 
Fields inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO
SQL_DELETEALL_TEMPLATE, SQL_DROP_TEMPLATE
 
Fields inherited from interface de.hs_rm.cs.lecturenotes.server.core.persistence.dao.IDAO
SQLERRORCODE_DUPLICATE_ENTRY
 
Constructor Summary
UserDAO(SQLConnection db)
          DAO Constructor.
 
Method Summary
 java.lang.Long createEntity(User entity)
          Creates a new User entity.
 User getOwnerForParagraphId(long id)
          Will return the owner user for a Paragraph object where id equals long paraId.
 User getOwnerForParaId(long paraId)
          Will return the owner user for a Paragraph object where paraId equals long paraId.
 User getUserById(long id)
          Will return an User entity by it's primary key long id.
 User getUserByLoginNameAndPassword(java.lang.String loginName, java.lang.String loginPassword)
          Will return the User object corresponding to given parameters or return null if none was found.
 User getUserBySQL(java.lang.String sql)
          Will return a single User entity for SQL Select Statement String sql.
 java.util.List<User> getUserList()
          Will return a List of all system users in the dataabse.
 java.lang.Integer hardDeleteUser(User entity, javax.servlet.ServletContext cntxt)
          Removes a user and its dependencies from the database.
 java.lang.Integer updateEntity(User user)
          Will update a User entity and return the number of rows that were updated, which must be one.
 
Methods inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO
createEntity, deleteTableContents, dropTable, executeCreateSQL, executeUpdateSQL, getDb, setDb
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL_TABLENAME

public static final java.lang.String SQL_TABLENAME
SQL Table Name.

See Also:
Constant Field Values

PASSWORD_HIDDEN_PLACEHOLDER

public static final java.lang.String PASSWORD_HIDDEN_PLACEHOLDER
No user entity will be given to the client with the real password contents set. Instead of this a placeholder will be used.

See Also:
Constant Field Values
Constructor Detail

UserDAO

public UserDAO(SQLConnection db)
DAO Constructor.

Parameters:
db - SQLConnection connection
Method Detail

getUserBySQL

public User getUserBySQL(java.lang.String sql)
Will return a single User entity for SQL Select Statement String sql. The password hash is replaced with the tag provided in PASSWORD_HIDDEN_PLACEHOLDER for security reasons.

Parameters:
sql - String SQL Select Statement
Returns:
User

getUserById

public User getUserById(long id)
Will return an User entity by it's primary key long id. The password hash is replaced with the tag provided in PASSWORD_HIDDEN_PLACEHOLDER for security reasons.

Parameters:
id - long
Returns:
User

getUserByLoginNameAndPassword

public User getUserByLoginNameAndPassword(java.lang.String loginName,
                                          java.lang.String loginPassword)
Will return the User object corresponding to given parameters or return null if none was found. The password hash is replaced with the tag provided in PASSWORD_HIDDEN_PLACEHOLDER for security reasons.

Parameters:
loginName - String Login name to search for
loginPassword - String provided clear text password
Returns:
User object of the found entity

getUserList

public java.util.List<User> getUserList()
Will return a List of all system users in the dataabse.

Returns:
List of User

updateEntity

public java.lang.Integer updateEntity(User user)
Will update a User entity and return the number of rows that were updated, which must be one. If the number is not one a failure had occurred.

Parameters:
user - User.
Returns:
Integer Number of rows that were updated

getOwnerForParagraphId

public User getOwnerForParagraphId(long id)
Will return the owner user for a Paragraph object where id equals long paraId. There a multiple rows in the paragraph with the same paraId due to the versioning scheme, only the first is returned.

Parameters:
id - long
Returns:
User

getOwnerForParaId

public User getOwnerForParaId(long paraId)
Will return the owner user for a Paragraph object where paraId equals long paraId. There a multiple rows in the paragraph with the same paraId due to the versioning scheme, only the first is returned.

Parameters:
paraId - long
Returns:
User

hardDeleteUser

public java.lang.Integer hardDeleteUser(User entity,
                                        javax.servlet.ServletContext cntxt)
Removes a user and its dependencies from the database. This action cannot be undone. The number of deleted user rows is returned. Should be exactly one.

Parameters:
entity - User
cntxt - ServletContext
Returns:
Integer

createEntity

public java.lang.Long createEntity(User entity)
                            throws java.sql.SQLException
Creates a new User entity. Will return the id.

Parameters:
entity - User to create
Returns:
Long ID that the entity was persisted as
Throws:
java.sql.SQLException - Thrown if there was DBMS error, most probably a duplicate entry