public class ODFCartUserPreferencesStorage extends AbstractLogEnabled implements UserPreferencesStorage, Configurable, Component
Modifier and Type | Field and Description |
---|---|
protected String |
_contentIdColumn
The content id column
|
protected String |
_contextColumn
The context column, can be null if the database is not context-dependent.
|
protected String |
_dataSourceId
The id of the data source used.
|
protected String |
_loginColumn
The login column, cannot be null.
|
protected String |
_populationColumn
The population id column, cannot be null.
|
protected Map<String,String> |
_prefIdToTable
Mapping from preference id to table name.
|
static String |
ROLE
The Avalon Role
|
Constructor and Description |
---|
ODFCartUserPreferencesStorage() |
Modifier and Type | Method and Description |
---|---|
private void |
_insertPreferences(Connection connection,
Map<String,String> preferences,
UserIdentity user,
String storageContext) |
private void |
_removeUserPreferencesFromTable(Connection connection,
UserIdentity user,
String storageContext,
String table) |
void |
configure(Configuration configuration) |
void |
configureMappings(Configuration configuration)
Configure the mappings from preference ID to table name.
|
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 |
removeContentFromUserPreferences(String contentId)
Remove content from all user preferences
|
void |
removeUserPreferences(UserIdentity user,
String storageContext,
Map<String,String> contextVars)
Remove the stored user preferences for a login in a given context.
|
void |
setUserPreferences(UserIdentity user,
String storageContext,
Map<String,String> contextVars,
Map<String,String> preferences)
Set a user's preferences for a given context.
|
getLogger, setLogger
protected String _dataSourceId
protected String _loginColumn
protected String _populationColumn
protected String _contextColumn
protected String _contentIdColumn
protected Map<String,String> _prefIdToTable
public ODFCartUserPreferencesStorage()
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void configureMappings(Configuration configuration) throws ConfigurationException
configuration
- the mapping configuration root.ConfigurationException
- if an error occurs.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 occurredprivate void _removeUserPreferencesFromTable(Connection connection, UserIdentity user, String storageContext, String table) throws SQLException
SQLException
public void removeContentFromUserPreferences(String contentId) throws UserPreferencesException
contentId
- the content id to removeUserPreferencesException
- if failed to remove user preferencespublic 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 occurredprivate void _insertPreferences(Connection connection, Map<String,String> preferences, UserIdentity user, String storageContext) throws SQLException
SQLException
public 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 occurred