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
public class GetUserPreferencesAction extends ServiceableAction
Get user preferences as a JSON object
-
-
Field Summary
Fields Modifier and Type Field Description protected UserPreferencesExtensionPoint_userPrefEPThe user preferences extension point.protected UserPreferencesManager_userPrefManagerThe 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 GetUserPreferencesAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mapact(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)protected Map<String,String>getContextVars(Request request)Get the preferences context.protected UserIdentitygetUser(Parameters parameters)Get the user in the user manager.protected Map<String,Object>userPref2JsonObject(UserPreference userPref, Object value)Convert a user preference to JSON objectprotected Map<String,Object>userPrefs2JsonObject(String storageContext, Map<String,String> contextVars, UserIdentity user, boolean excludePrivate)Convert user preferences to JSON objectprotected Map<String,Object>userPrefs2JsonObject(List<UserPreference> userPrefs, Map<String,String> prefValues, boolean excludePrivate)Convert user preferences to JSON object-
Methods 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 Detail
-
_userPrefEP
protected UserPreferencesExtensionPoint _userPrefEP
The user preferences extension point.
-
_userPrefManager
protected UserPreferencesManager _userPrefManager
The user preferences manager.
-
-
Constructor Detail
-
GetUserPreferencesAction
public GetUserPreferencesAction()
-
-
Method Detail
-
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, UserPreferencesException
Convert 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 ProcessingException
Convert 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
protected UserIdentity getUser(Parameters parameters)
Get the user in the user manager.- Parameters:
parameters- The parameters- Returns:
- the user .
-
getContextVars
protected Map<String,String> getContextVars(Request request)
Get the preferences context.- Parameters:
request- the request.- Returns:
- the preferences context as a Map.
-
-