org.pentaho.platform.engine.security.userroledao.hibernate
Class HibernateUserRoleDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by org.pentaho.platform.engine.security.userroledao.hibernate.HibernateUserRoleDao
All Implemented Interfaces:
IUserRoleDao, org.springframework.beans.factory.InitializingBean

public class HibernateUserRoleDao
extends org.springframework.orm.hibernate3.support.HibernateDaoSupport
implements IUserRoleDao

An IUserRoleDao that uses Hibernate. Furthermore, it uses Spring's HibernateDaoSupport. This allows instances to be dependency injected. At a minimum, instances require a Hibernate SessionFactory.

The init method must be called after all properties have been set and before calling any of the CRUD methods. Can be called automatically if using Spring via the init-method attribute. Otherwise, call it manually after setting all properties.

Author:
mlowery

Nested Class Summary
static interface HibernateUserRoleDao.InitHandler
          Generic interface to allow extensibility without tight coupling.
 
Field Summary
static String DEFAULT_ALL_ROLES_QUERY
           
static String DEFAULT_ALL_USERS_QUERY
           
 
Constructor Summary
HibernateUserRoleDao()
           
 
Method Summary
 void createRole(IPentahoRole roleToCreate)
          This method is more complex because this is the inverse end of a bidirectional many-to-many relationship.
 void createUser(IPentahoUser userToCreate)
           
 void deleteRole(IPentahoRole roleToDelete)
          This method is more complex because this is the inverse end of a bidirectional many-to-many relationship.
 void deleteUser(IPentahoUser userToDelete)
           
 String getAllRolesQuery()
           
 String getAllUsersQuery()
           
 IPentahoRole getRole(String name)
           
 List<IPentahoRole> getRoles()
           
 IPentahoUser getUser(String username)
           
 List<IPentahoUser> getUsers()
           
 void init()
          A generic initialization method.
 void setAllRolesQuery(String allRolesQuery)
           
 void setAllUsersQuery(String allUsersQuery)
           
 void setInitHandler(HibernateUserRoleDao.InitHandler initHandler)
           
 void updateRole(IPentahoRole roleToUpdate)
          This method is more complex because this is the inverse end of a bidirectional many-to-many relationship.
 void updateUser(IPentahoUser userToUpdate)
           
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
getHibernateTemplate, getSessionFactory, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ALL_USERS_QUERY

public static final String DEFAULT_ALL_USERS_QUERY
See Also:
Constant Field Values

DEFAULT_ALL_ROLES_QUERY

public static final String DEFAULT_ALL_ROLES_QUERY
See Also:
Constant Field Values
Constructor Detail

HibernateUserRoleDao

public HibernateUserRoleDao()
Method Detail

init

public void init()
A generic initialization method. Can be used to load initial data into user- and role-related tables.


createUser

public void createUser(IPentahoUser userToCreate)
                throws AlreadyExistsException,
                       UncategorizedUserRoleDaoException
Specified by:
createUser in interface IUserRoleDao
Throws:
AlreadyExistsException
UncategorizedUserRoleDaoException

deleteUser

public void deleteUser(IPentahoUser userToDelete)
                throws NotFoundException,
                       UncategorizedUserRoleDaoException
Specified by:
deleteUser in interface IUserRoleDao
Throws:
NotFoundException
UncategorizedUserRoleDaoException

getUser

public IPentahoUser getUser(String username)
                     throws UncategorizedUserRoleDaoException
Specified by:
getUser in interface IUserRoleDao
Throws:
UncategorizedUserRoleDaoException

getUsers

public List<IPentahoUser> getUsers()
                            throws UncategorizedUserRoleDaoException
Specified by:
getUsers in interface IUserRoleDao
Throws:
UncategorizedUserRoleDaoException

updateUser

public void updateUser(IPentahoUser userToUpdate)
                throws NotFoundException,
                       UncategorizedUserRoleDaoException
Specified by:
updateUser in interface IUserRoleDao
Throws:
NotFoundException
UncategorizedUserRoleDaoException

createRole

public void createRole(IPentahoRole roleToCreate)
                throws AlreadyExistsException,
                       UncategorizedUserRoleDaoException
This method is more complex because this is the inverse end of a bidirectional many-to-many relationship. See Hibernate documentation section 6.3.2. Bidirectional associations. Basically, this means that the users set of this role must be managed manually.

Specified by:
createRole in interface IUserRoleDao
Throws:
AlreadyExistsException
UncategorizedUserRoleDaoException

deleteRole

public void deleteRole(IPentahoRole roleToDelete)
                throws NotFoundException,
                       UncategorizedUserRoleDaoException
This method is more complex because this is the inverse end of a bidirectional many-to-many relationship. See Hibernate documentation section 6.3.2. Bidirectional associations. Basically, this means that the users set of this role must be managed manually.

Specified by:
deleteRole in interface IUserRoleDao
Throws:
NotFoundException
UncategorizedUserRoleDaoException

getRole

public IPentahoRole getRole(String name)
                     throws UncategorizedUserRoleDaoException
Specified by:
getRole in interface IUserRoleDao
Throws:
UncategorizedUserRoleDaoException

getRoles

public List<IPentahoRole> getRoles()
                            throws UncategorizedUserRoleDaoException
Specified by:
getRoles in interface IUserRoleDao
Throws:
UncategorizedUserRoleDaoException

updateRole

public void updateRole(IPentahoRole roleToUpdate)
                throws NotFoundException,
                       UncategorizedUserRoleDaoException
This method is more complex because this is the inverse end of a bidirectional many-to-many relationship. See Hibernate documentation section 6.3.2. Bidirectional associations. Basically, this means that the users set of this role must be managed manually.

Specified by:
updateRole in interface IUserRoleDao
Throws:
NotFoundException
UncategorizedUserRoleDaoException

setAllUsersQuery

public void setAllUsersQuery(String allUsersQuery)

getAllUsersQuery

public String getAllUsersQuery()

setAllRolesQuery

public void setAllRolesQuery(String allRolesQuery)

getAllRolesQuery

public String getAllRolesQuery()

setInitHandler

public void setInitHandler(HibernateUserRoleDao.InitHandler initHandler)