public class JdbcXmlUserPreferencesStorage extends AbstractLogEnabled implements DefaultUserPreferencesStorage, ThreadSafe, Configurable, Serviceable
DefaultUserPreferencesStorage
.
This implementation stores preferences in a database, as an XML file.Modifier and Type | Field and Description |
---|---|
protected String |
_databaseTable
The database table in which the preferences are stored.
|
protected String |
_dataSourceId
The id of the data source used.
|
protected SAXParser |
_saxParser
A SAX parser.
|
ROLE
Constructor and Description |
---|
JdbcXmlUserPreferencesStorage() |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
_getPreferencesXmlBytes(Map<String,String> preferences)
Write a Map of preferences as XML and return an InputStream on this XML.
|
void |
configure(Configuration configuration) |
Map<String,String> |
getUnTypedUserPrefs(UserIdentity user,
String storageContext,
Map<String,String> contextVars)
Get a user's preference values (as String) for a given context.
|
Boolean |
getUserPreferenceAsBoolean(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
String id)
Get a single boolean user preference value for a given context.
|
Date |
getUserPreferenceAsDate(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
String id)
Get a single date user preference value for a given context.
|
Double |
getUserPreferenceAsDouble(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
String id)
Get a single double user preference value for a given context.
|
Long |
getUserPreferenceAsLong(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
String id)
Get a single long user preference value for a given context.
|
String |
getUserPreferenceAsString(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
String id)
Get a single string user preference value for a given context.
|
void |
removeUserPreferences(UserIdentity user,
String storageContext,
Map<String,String> contextVars)
Remove the stored user preferences for a login in a given context.
|
void |
service(ServiceManager manager) |
void |
setUserPreferences(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
Map<String,String> preferences)
Set a user's preferences for a given context.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected SAXParser _saxParser
protected String _dataSourceId
protected String _databaseTable
public JdbcXmlUserPreferencesStorage()
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,String> getUnTypedUserPrefs(UserIdentity user, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
UserPreferencesStorage
getUnTypedUserPrefs
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsUserPreferencesException
- if an error occurs getting the preferences.public void removeUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
UserPreferencesStorage
removeUserPreferences
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- the context variables.UserPreferencesException
- if an error occurredpublic void setUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars, Map<String,String> preferences) throws UserPreferencesException
UserPreferencesStorage
setUserPreferences
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementspreferences
- a Map of the preference values indexed by ID.UserPreferencesException
- if an error occurredpublic String getUserPreferenceAsString(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
UserPreferencesStorage
getUserPreferenceAsString
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsid
- the preference ID.UserPreferencesException
- if an error occurredpublic Long getUserPreferenceAsLong(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
UserPreferencesStorage
getUserPreferenceAsLong
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsid
- the preference ID.UserPreferencesException
- if an error occurredpublic Date getUserPreferenceAsDate(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
UserPreferencesStorage
getUserPreferenceAsDate
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsid
- the preference ID.UserPreferencesException
- if an error occurredpublic Boolean getUserPreferenceAsBoolean(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
UserPreferencesStorage
getUserPreferenceAsBoolean
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsid
- the preference ID.UserPreferencesException
- if an error occurredpublic Double getUserPreferenceAsDouble(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
UserPreferencesStorage
getUserPreferenceAsDouble
in interface UserPreferencesStorage
user
- the user.storageContext
- the preferences storage context.contextVars
- The context variables including environment elementsid
- the preference ID.UserPreferencesException
- if an error occurredprotected byte[] _getPreferencesXmlBytes(Map<String,String> preferences) throws UserPreferencesException
preferences
- the preferences Map.UserPreferencesException
- if an error occurred