Package org.ametys.plugins.core.userpref
Class SetUserPreferencesAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
org.ametys.plugins.core.userpref.SetUserPreferencesAction
- All Implemented Interfaces:
Component,LogEnabled,Serviceable,ThreadSafe,Action
- Direct Known Subclasses:
SetFOUserPreferencesAction,SetUserProfileAction
Action which saves the user preferences values into the database.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Set<DateFormat>The input date format.protected UserPreferencesExtensionPointThe user preferences extension point.protected UserPreferencesManagerThe user preferences manager.Fields inherited from class org.apache.cocoon.acting.ServiceableAction
managerFields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_getValues(Request request, Map<String, String> contextVars, UserIdentity user, Collection<String> preferenceIds, UserPreferencesErrors errors) Get the preferences values from the request.protected Date_parseDate(String value) Parse a user-submitted date.act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) getContextVars(Request request) Get the preferences context variables.protected Collection<String>getPreferenceIds(Request request, Map<String, Object> parentContext) Get the preferences to set.protected StringgetStorageContext(Request request, Parameters parameters) Get the context of user's preference storageprotected UserIdentitygetUser(Request request, Parameters parameters) Get the uservoidservice(ServiceManager serviceManager) setUserPreferences(Request request, String storageContext, Map<String, String> contextVars, UserIdentity user) Set user preferences.setUserPreferences(Request request, String storageContext, Map<String, String> contextVars, UserIdentity user, Collection<String> preferenceIds) Set user preferences.Methods inherited from class org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
_getCurrentUserMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_INPUT_DATE_FORMATS
The input date format. -
_userPrefEP
The user preferences extension point. -
_userPrefManager
The user preferences manager.
-
-
Constructor Details
-
SetUserPreferencesAction
public SetUserPreferencesAction()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classServiceableAction- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception - Throws:
Exception
-
getUser
Get the user- Parameters:
request- The requestparameters- The sitemap parameters- Returns:
- the user
-
getStorageContext
Get the context of user's preference storage- Parameters:
request- The requestparameters- The sitemap parameters- Returns:
- the storage context
-
setUserPreferences
protected Map<String,String> setUserPreferences(Request request, String storageContext, Map<String, String> contextVars, UserIdentity user) throws UserPreferencesExceptionSet user preferences.- Parameters:
request- the request.storageContext- the preferences storage context.contextVars- the preferences context map.user- the user.- Returns:
- the results.
- Throws:
UserPreferencesException- if an error occurred
-
setUserPreferences
protected Map<String,String> setUserPreferences(Request request, String storageContext, Map<String, String> contextVars, UserIdentity user, Collection<String> preferenceIds) throws UserPreferencesExceptionSet user preferences.- Parameters:
request- the request.storageContext- the preferences context.contextVars- the preferences context map.user- the user.preferenceIds- a collection of the IDs of preferences to set.- Returns:
- the results.
- Throws:
UserPreferencesException- if an error occurred
-
_getValues
protected Map<String,String> _getValues(Request request, Map<String, String> contextVars, UserIdentity user, Collection<String> preferenceIds, UserPreferencesErrors errors) Get the preferences values from the request.- Parameters:
request- the request.contextVars- The context varsuser- the user.preferenceIds- a collection of the IDs of preferences to set.errors- the errors object to fill in.- Returns:
- the user preferences values as a Map.
-
_parseDate
Parse a user-submitted date.- Parameters:
value- the date value as a String.- Returns:
- the Date.
-
getContextVars
Get the preferences context variables.- Parameters:
request- the request.- Returns:
- the preferences context as a Map.
-
getPreferenceIds
Get the preferences to set.- Parameters:
request- the request.parentContext- the parent context.- Returns:
- a collection of the IDs of preferences to set.
-