public class HibernateContextDAO extends Object implements ContextDAO
ContextDAO
. These methods should not be used
directly, instead, the methods on the static Context
file should be used.ContextDAO
,
Context
Constructor and Description |
---|
HibernateContextDAO() |
Modifier and Type | Method and Description |
---|---|
User |
authenticate(String login,
String password)
Authenticate user with the given username and password.
|
void |
clearEntireCache()
Evicts data from all cache regions.
|
void |
clearSession() |
void |
closeSession()
Close session.
|
User |
createUser(User user,
String password,
List<String> roleNames)
Creates a new user.
|
void |
evictAllEntities(Class<?> entityClass)
Evicts all entity data of a particular class from the given region.
|
void |
evictEntity(OpenmrsObject obj)
Evicts the entity data for a particular entity instance.
|
void |
evictFromSession(Object obj)
Used to clear a cached object out of a session in the middle of a unit of work.
|
void |
flushSession() |
Connection |
getDatabaseConnection() |
User |
getUserByUsername(String username)
Gets a user given the username.
|
User |
getUserByUuid(String uuid)
Gets a user given the uuid.
|
void |
mergeDefaultRuntimeProperties(Properties runtimeProperties)
Takes the default properties defined in /metadata/api/hibernate/hibernate.default.properties
and merges it into the user-defined runtime properties
|
void |
openSession()
Open session.
|
void |
refreshEntity(Object obj)
Used to re-read the state of the given instance from the underlying database.
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Session factory to use for this DAO.
|
void |
setupSearchIndex()
Updates the search index if necessary.
|
void |
setUserDAO(UserDAO userDao) |
void |
shutdown()
Stops the OpenMRS System Should be called after all activity has ended and application is
closing
|
void |
startup(Properties properties)
Starts the OpenMRS System
Should be called prior to any kind of activity
|
void |
updateSearchIndex() |
Future<?> |
updateSearchIndexAsync() |
void |
updateSearchIndexForObject(Object object) |
void |
updateSearchIndexForType(Class<?> type) |
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- public void setUserDAO(UserDAO userDao)
@Transactional(noRollbackFor=ContextAuthenticationException.class) public User authenticate(String login, String password) throws ContextAuthenticationException
ContextDAO
authenticate
in interface ContextDAO
login
- user's username or systemIdpassword
- user's passwordContextAuthenticationException
- Should authenticate given username and password
Should authenticate given systemId and password
Should authenticate given systemId without hyphen and password
Should not authenticate given username and incorrect password
Should not authenticate given systemId and incorrect password
Should not authenticate given incorrect username
Should not authenticate given incorrect systemId
Should not authenticate given null login
Should not authenticate given empty login
Should not authenticate given null password when password in database is null
Should not authenticate given non null password when password in database is null
Should not authenticate when password in database is empty
Should give identical error messages between username and password mismatch
Should lockout user after eight failed attempts
Should authenticateWithCorrectHashedPassword
Should authenticateWithIncorrectHashedPassword
Should set uuid on user property when authentication fails with valid user
Should pass regression test for 1580
Should throw a ContextAuthenticationException if username is an empty string
Should throw a ContextAuthenticationException if username is white spaceContextDAO.authenticate(java.lang.String, java.lang.String)
@Transactional(readOnly=true) public User getUserByUuid(String uuid)
ContextDAO
Context.getAuthenticatedUser()
method.getUserByUuid
in interface ContextDAO
uuid
- uuid of user to fetchContextDAO.getUserByUuid(java.lang.String)
@Transactional(readOnly=true) public User getUserByUsername(String username)
ContextDAO
Context.getAuthenticatedUser()
or Context.authenticate(org.openmrs.api.context.Credentials)
methods.getUserByUsername
in interface ContextDAO
username
- The username of the user to fetchContextDAO.getUserByUsername(String)
@Transactional public User createUser(User user, String password, List<String> roleNames) throws Exception
ContextDAO
createUser
in interface ContextDAO
user
- A new user to be created.password
- The password for the new user.roleNames
- A list of role names to add to the user.Exception
org.openmrs.api.db.ContextDAO#createUser(User, String)
public void openSession()
ContextDAO
openSession
in interface ContextDAO
public void closeSession()
ContextDAO
closeSession
in interface ContextDAO
Context.closeSession()
@Transactional public void clearSession()
clearSession
in interface ContextDAO
ContextDAO.clearSession()
public void evictFromSession(Object obj)
ContextDAO
evictFromSession
in interface ContextDAO
obj
- The object to evict/remove from the sessionContextDAO.evictFromSession(java.lang.Object)
public void evictEntity(OpenmrsObject obj)
ContextDAO
evictEntity
in interface ContextDAO
obj
- entity instance to evict from the DB cacheContextDAO.evictEntity(OpenmrsObject)
public void evictAllEntities(Class<?> entityClass)
ContextDAO
evictAllEntities
in interface ContextDAO
entityClass
- entity class to evict from the DB cacheContextDAO.evictAllEntities(Class)
public void clearEntireCache()
ContextDAO
clearEntireCache
in interface ContextDAO
ContextDAO.clearEntireCache()
public void refreshEntity(Object obj)
ContextDAO
refreshEntity
in interface ContextDAO
obj
- The object to refresh from the database in the sessionContextDAO.refreshEntity(Object)
@Transactional public void flushSession()
flushSession
in interface ContextDAO
ContextDAO.flushSession()
@Transactional public void startup(Properties properties)
ContextDAO
Should be called prior to any kind of activity
startup
in interface ContextDAO
properties
- PropertiesContext.startup(Properties)
public void shutdown()
ContextDAO
shutdown
in interface ContextDAO
Context.shutdown()
public void mergeDefaultRuntimeProperties(Properties runtimeProperties)
mergeDefaultRuntimeProperties
in interface ContextDAO
runtimeProperties
- The current user specific runtime propertiesShould merge default runtime properties
@Transactional public void updateSearchIndexForType(Class<?> type)
updateSearchIndexForType
in interface ContextDAO
Context.updateSearchIndexForType(Class)
@Transactional public void updateSearchIndexForObject(Object object)
updateSearchIndexForObject
in interface ContextDAO
ContextDAO.updateSearchIndexForObject(java.lang.Object)
public void setupSearchIndex()
ContextDAO
The update is triggered if OpenmrsConstants.GP_SEARCH_INDEX_VERSION
is blank
or the value does not match OpenmrsConstants.SEARCH_INDEX_VERSION
.
setupSearchIndex
in interface ContextDAO
ContextDAO.setupSearchIndex()
public void updateSearchIndex()
updateSearchIndex
in interface ContextDAO
ContextDAO.updateSearchIndex()
public Future<?> updateSearchIndexAsync()
updateSearchIndexAsync
in interface ContextDAO
ContextDAO.updateSearchIndexAsync()
public Connection getDatabaseConnection()
getDatabaseConnection
in interface ContextDAO
ContextDAO.getDatabaseConnection()
Copyright © 2024 OpenMRS Inc.. All rights reserved.