com.terracotta.management.user.dao.impl
Class IniFileUserInfoDao

java.lang.Object
  extended by com.terracotta.management.user.dao.impl.IniFileUserInfoDao
All Implemented Interfaces:
GenericDao<UserInfo,String>, UserInfoDao

public final class IniFileUserInfoDao
extends Object
implements UserInfoDao

An implementation of UserInfoDao that uses a file in the Shiro Ini format as a datastore.

By default this dao implementation will try and load and persist its data from a ini file location provided via the JVM property com.tc.management.security.ini. If that JVM property is not set, it will look to $&#123;user.home&#125;/.tc/mgmt/security.ini.

Author:
brandony

Constructor Summary
IniFileUserInfoDao()
           
IniFileUserInfoDao(File iniFile)
          A constructor that allows the ini file location used to be explicitly set.
IniFileUserInfoDao(File iniFile, boolean createFile)
          A constructor that allows the ini file location used to be explicitly set.
 
Method Summary
 void create(UserInfo user)
          Create the submitted obj.
 void createOrUpdate(UserInfo user)
          Create or update the submitted obj.
 void delete(UserInfo user)
          Deletes the submitted obj
 void evict(UserInfo user)
          Evicts the obj from persistent cache.
 void flush()
          Synchronizes persistence layer's state with the datastore.
 UserInfo getById(String username)
          Returns the obj T with the given id, or null if there is no such entity.
 boolean hasUserInfos()
          Determines whether or not UserInfo objects are currently available.
 void truncate()
          Truncates the datastore.
 void validate(boolean establish)
          Validates the underlying datastore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IniFileUserInfoDao

public IniFileUserInfoDao()
                   throws DataAccessException
Throws:
DataAccessException

IniFileUserInfoDao

public IniFileUserInfoDao(File iniFile)
                   throws DataAccessException
A constructor that allows the ini file location used to be explicitly set.

Parameters:
iniFile - the file holding security data
Throws:
DataAccessException

IniFileUserInfoDao

public IniFileUserInfoDao(File iniFile,
                          boolean createFile)
                   throws DataAccessException
A constructor that allows the ini file location used to be explicitly set.

Parameters:
iniFile - the file holding security data
createFile - will create the file, if not already existent
Throws:
DataAccessException
Method Detail

getById

public UserInfo getById(String username)
                 throws DataAccessException
Returns the obj T with the given id, or null if there is no such entity.

Specified by:
getById in interface GenericDao<UserInfo,String>
Parameters:
username - the id of the entity to return
Returns:
T or null
Throws:
DataAccessException

create

public void create(UserInfo user)
            throws DataAccessException
Create the submitted obj.

Specified by:
create in interface GenericDao<UserInfo,String>
Parameters:
user - obj to be created
Throws:
DataAccessException

createOrUpdate

public void createOrUpdate(UserInfo user)
                    throws DataAccessException
Create or update the submitted obj.

Specified by:
createOrUpdate in interface GenericDao<UserInfo,String>
Parameters:
user - the obj to create or update.
Throws:
DataAccessException

delete

public void delete(UserInfo user)
            throws DataAccessException
Deletes the submitted obj

Specified by:
delete in interface GenericDao<UserInfo,String>
Parameters:
user - obj to delete
Throws:
DataAccessException

flush

public void flush()
Synchronizes persistence layer's state with the datastore.

Specified by:
flush in interface GenericDao<UserInfo,String>

evict

public void evict(UserInfo user)
Evicts the obj from persistent cache.

Specified by:
evict in interface GenericDao<UserInfo,String>
Parameters:
user - the obj to evict

hasUserInfos

public boolean hasUserInfos()
                     throws DataAccessException
Determines whether or not UserInfo objects are currently available.

Specified by:
hasUserInfos in interface UserInfoDao
Returns:
true if any UserInfo objects are available, false if not
Throws:
DataAccessException - if the store cannot be accessed to make the determination

truncate

public void truncate()
              throws DataAccessException
Description copied from interface: UserInfoDao
Truncates the datastore.

Specified by:
truncate in interface UserInfoDao
Throws:
DataAccessException - if the store cannot be truncated

validate

public void validate(boolean establish)
              throws DataAccessException
Validates the underlying datastore.

Specified by:
validate in interface UserInfoDao
Parameters:
establish - a boolean value indicating whether or not an attempt should be made to try and setup the underlying datastore for UserInfo objects if it doesn't already exist. If true, the store will be established if possible in the event that validation fails.
Throws:
DataAccessException - if the could not be established
DatastoreNotFoundException - if the store cannot be validated


Copyright © 2013 Terracotta, Inc.. All Rights Reserved.