@Service public class UserPreferenceService extends Object
Constructor and Description |
---|
UserPreferenceService() |
Modifier and Type | Method and Description |
---|---|
<T extends UserPreference> |
getPreferences(Class<T> preferencesType)
Method to load the given preferences for the current user.
|
UserPreference |
getPreferences(String className)
Method to load the given preferences for the current user.
|
String |
getPreferencesAsJson() |
<T extends UserPreference> |
getPreferencesAsJson(Class<T> preferencesType)
Method to load the given preferences for the current user.
|
<T extends UserPreference> |
getPreferencesAsJson(String className)
Method to load the given preferences for the current user.
|
void |
initialize()
Initializer method.
|
void |
mergePreferences(String className,
Map<String,String> preferences)
This method can be used to merge the given properties with already existing data.
|
<T extends UserPreference> |
register(Class<T> preferencesType)
Register a new preference type to allow storing and loading of preferences of this type.
|
<T extends UserPreference> |
removePreferences(Class<T> preferencesType)
Method to remove all values for the given preferences type from the current user.
|
void |
storePreferences(UserPreference preferences)
Persists the given preferences.
|
<T extends UserPreference> |
unregister(Class<T> preferencesType)
Method to unregister the type.
|
public <T extends UserPreference> T getPreferences(Class<T> preferencesType) throws AuthorizationException
T
- Concrete type of the user preference.preferencesType
- Type of the preferences to load.AuthorizationException
- Thrown, when the current user does not have access to the given preferences.public UserPreference getPreferences(String className) throws AuthorizationException
className
- Full qualified class name of the preferences.AuthorizationException
- Thrown, when the current user does not have access to the given preferences.public String getPreferencesAsJson()
public <T extends UserPreference> String getPreferencesAsJson(Class<T> preferencesType) throws AuthorizationException
T
- Concrete type of the user preference.preferencesType
- Type of the preferences to load.AuthorizationException
- Thrown, when the current user does not have access to the given preferences.public <T extends UserPreference> String getPreferencesAsJson(String className) throws AuthorizationException
T
- Concrete type of the user preference.className
- Full qualified class name of the preferences.AuthorizationException
- Thrown, when the current user does not have access to the given preferences.@PostConstruct public void initialize()
public void mergePreferences(String className, Map<String,String> preferences) throws NotFoundException, AuthorizationException
className
- Full qualified class name of the preferences.preferences
- The preferences to merge.NotFoundException
- Thrown, when there is not type for the given class name registered.AuthorizationException
- Thrown, when the current user doesn't have access to the preferences.public <T extends UserPreference> void register(Class<T> preferencesType)
T
- Concrete type of the user preference.preferencesType
- The type to register.public <T extends UserPreference> void removePreferences(Class<T> preferencesType) throws AuthorizationException
T
- Concrete type of the user preference.preferencesType
- The preference type.AuthorizationException
- Thrown, when the user is not allowed to access the given preference.public void storePreferences(UserPreference preferences)
preferences
- The preferences to persist.public <T extends UserPreference> void unregister(Class<T> preferencesType)
T
- Concrete type of the user preference.preferencesType
- The type to remove.Copyright © 2019 Communote team. All rights reserved.