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
public class SetUserPreferencesAction extends AbstractCurrentUserProviderServiceableAction
Action which saves the user preferences values into the database.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Set<DateFormat>
_INPUT_DATE_FORMATS
The input date format.protected UserPreferencesExtensionPoint
_userPrefEP
The user preferences extension point.protected UserPreferencesManager
_userPrefManager
The user preferences manager.-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description SetUserPreferencesAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.protected Date
_parseDate(String value)
Parse a user-submitted date.Map
act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
protected Map<String,String>
getContextVars(Request request)
Get the preferences context variables.protected Collection<String>
getPreferenceIds(Request request, Map<String,Object> parentContext)
Get the preferences to set.protected String
getStorageContext(Request request, Parameters parameters)
Get the context of user's preference storageprotected UserIdentity
getUser(Request request, Parameters parameters)
Get the uservoid
service(ServiceManager serviceManager)
protected Map<String,String>
setUserPreferences(Request request, String storageContext, Map<String,String> contextVars, UserIdentity user)
Set user preferences.protected Map<String,String>
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
_getCurrentUser
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_INPUT_DATE_FORMATS
protected static final Set<DateFormat> _INPUT_DATE_FORMATS
The input date format.
-
_userPrefEP
protected UserPreferencesExtensionPoint _userPrefEP
The user preferences extension point.
-
_userPrefManager
protected UserPreferencesManager _userPrefManager
The user preferences manager.
-
-
Constructor Detail
-
SetUserPreferencesAction
public SetUserPreferencesAction()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
- Throws:
Exception
-
getUser
protected UserIdentity getUser(Request request, Parameters parameters)
Get the user- Parameters:
request
- The requestparameters
- The sitemap parameters- Returns:
- the user
-
getStorageContext
protected String getStorageContext(Request request, Parameters parameters)
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 UserPreferencesException
Set 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 UserPreferencesException
Set 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
protected Date _parseDate(String value)
Parse a user-submitted date.- Parameters:
value
- the date value as a String.- Returns:
- the Date.
-
getContextVars
protected Map<String,String> getContextVars(Request request)
Get the preferences context variables.- Parameters:
request
- the request.- Returns:
- the preferences context as a Map.
-
getPreferenceIds
protected Collection<String> getPreferenceIds(Request request, Map<String,Object> parentContext)
Get the preferences to set.- Parameters:
request
- the request.parentContext
- the parent context.- Returns:
- a collection of the IDs of preferences to set.
-
-