Package org.ametys.plugins.core.userpref
Class GetUserPreferencesAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.plugins.core.userpref.GetUserPreferencesAction
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,Action
Get user preferences as a JSON object
-
Field Summary
Modifier and TypeFieldDescriptionprotected UserPreferencesExtensionPoint
The user preferences extension point.protected UserPreferencesManager
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
-
Method Summary
Modifier and TypeMethodDescriptionact
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) getContextVars
(Request request) Get the preferences context.protected UserIdentity
getUser
(Parameters parameters) Get the user in the user manager.userPref2JsonObject
(UserPreference userPref, Object value) Convert a user preference to JSON objectuserPrefs2JsonObject
(String storageContext, Map<String, String> contextVars, UserIdentity user, boolean excludePrivate) Convert user preferences to JSON objectuserPrefs2JsonObject
(List<UserPreference> userPrefs, Map<String, String> prefValues, boolean excludePrivate) Convert user preferences to JSON objectMethods inherited from class org.apache.cocoon.acting.ServiceableAction
service
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_userPrefEP
The user preferences extension point. -
_userPrefManager
The user preferences manager.
-
-
Constructor Details
-
GetUserPreferencesAction
public GetUserPreferencesAction()
-
-
Method Details
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception - Throws:
Exception
-
userPrefs2JsonObject
protected Map<String,Object> userPrefs2JsonObject(String storageContext, Map<String, String> contextVars, UserIdentity user, boolean excludePrivate) throws ProcessingException, UserPreferencesExceptionConvert user preferences to JSON object- Parameters:
storageContext
- the preferences context.contextVars
- The context varsuser
- the userexcludePrivate
- true to exclude private preferences- Returns:
- The JSON object representing the user preferences
- Throws:
ProcessingException
- if an error occurredUserPreferencesException
- if an error occurred
-
userPrefs2JsonObject
protected Map<String,Object> userPrefs2JsonObject(List<UserPreference> userPrefs, Map<String, String> prefValues, boolean excludePrivate) throws ProcessingExceptionConvert user preferences to JSON object- Parameters:
userPrefs
- the user preferences.prefValues
- The valuesexcludePrivate
- true to exclude private preferences- Returns:
- The JSON object representing the user preferences
- Throws:
ProcessingException
- if an error occurred
-
userPref2JsonObject
protected Map<String,Object> userPref2JsonObject(UserPreference userPref, Object value) throws ProcessingException Convert a user preference to JSON object- Parameters:
userPref
- the user preference.value
- The value- Returns:
- The JSON object representing the user preferences
- Throws:
ProcessingException
- if an error occurred
-
getUser
Get the user in the user manager.- Parameters:
parameters
- The parameters- Returns:
- the user .
-
getContextVars
Get the preferences context.- Parameters:
request
- the request.- Returns:
- the preferences context as a Map.
-