Package org.ametys.plugins.mobileapp
Class UserPreferencesHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.mobileapp.UserPreferencesHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class UserPreferencesHelper extends AbstractLogEnabled implements Serviceable, Component
Helper to store/retreive conf per user
-
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
The current user providerprotected JSONUtils
_jsonUtils
JSON Utilsprotected UserPreferencesManager
_userPreferencesManager
User Preferences Managerstatic String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description UserPreferencesHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNotificationToken(String pushToken, String lang)
Add a notification token for the current uservoid
addNotificationToken(String pushToken, String lang, UserIdentity user)
Add a notification token for a userprotected Map<String,Set<String>>
addTokenToMap(String token, List<String> feedIds, Map<String,Set<String>> existingMap)
Add a token in a map, with the feeds impactedMap<String,Object>
getNotificationSettings(String pushToken, UserIdentity user)
Get the notification settings for a tokenSet<String>
getNotificationTokens()
Get all notification tokens for current userSet<String>
getNotificationTokens(UserIdentity user)
Get all notification tokens a userMap<String,Set<String>>
getUserImpactedTokens(UserIdentity user, List<String> feedIds)
Get the list of impacted tokens for each feeds, for a userMap<String,Set<String>>
getUserImpactedTokens(UserIdentity user, Project project, String eventType)
Get the list of impacted tokens for each feeds, for a uservoid
removeAllNotificationTokens(UserIdentity user)
Remove all the notification tokens for a uservoid
removeNotificationToken(String pushToken)
Removes a notification token for the current uservoid
removeNotificationToken(String pushToken, UserIdentity user)
Removes a notification token for a uservoid
service(ServiceManager manager)
void
setNotificationSettings(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang)
Save the notification settings for the current uservoid
setNotificationSettings(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang, UserIdentity user)
Save the notification settings for a user-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_userPreferencesManager
protected UserPreferencesManager _userPreferencesManager
User Preferences Manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_jsonUtils
protected JSONUtils _jsonUtils
JSON Utils
-
-
Constructor Detail
-
UserPreferencesHelper
public UserPreferencesHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getUserImpactedTokens
public Map<String,Set<String>> getUserImpactedTokens(UserIdentity user, List<String> feedIds)
Get the list of impacted tokens for each feeds, for a user- Parameters:
user
- user to checkfeedIds
- list of feeds to check- Returns:
- a map with a Set of tokens for each feedId
-
getUserImpactedTokens
public Map<String,Set<String>> getUserImpactedTokens(UserIdentity user, Project project, String eventType)
Get the list of impacted tokens for each feeds, for a user- Parameters:
user
- user to checkproject
- test if a notification should be sent for this projecteventType
- test if a notification should be sent for this event type- Returns:
- a map with a the set of tokens impacted for each languages
-
addTokenToMap
protected Map<String,Set<String>> addTokenToMap(String token, List<String> feedIds, Map<String,Set<String>> existingMap)
Add a token in a map, with the feeds impacted- Parameters:
token
- the token to testfeedIds
- the feeds impactedexistingMap
- the existing map of feed -> set of tokens- Returns:
- the map, with the token added
-
addNotificationToken
public void addNotificationToken(String pushToken, String lang)
Add a notification token for the current user- Parameters:
pushToken
- the token to storelang
- lang of this device
-
addNotificationToken
public void addNotificationToken(String pushToken, String lang, UserIdentity user)
Add a notification token for a user- Parameters:
pushToken
- the token to storelang
- lang of this deviceuser
- the user impacted
-
getNotificationTokens
public Set<String> getNotificationTokens()
Get all notification tokens for current user- Returns:
- the list of notification tokens
-
getNotificationTokens
public Set<String> getNotificationTokens(UserIdentity user)
Get all notification tokens a user- Parameters:
user
- the user impacted- Returns:
- the list of notification tokens
-
removeNotificationToken
public void removeNotificationToken(String pushToken)
Removes a notification token for the current user- Parameters:
pushToken
- the token to remove
-
removeNotificationToken
public void removeNotificationToken(String pushToken, UserIdentity user)
Removes a notification token for a user- Parameters:
pushToken
- the token to removeuser
- the user impacted
-
removeAllNotificationTokens
public void removeAllNotificationTokens(UserIdentity user)
Remove all the notification tokens for a user- Parameters:
user
- the user impacted
-
setNotificationSettings
public void setNotificationSettings(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang)
Save the notification settings for the current user- Parameters:
pushToken
- the token to impactfeeds
- list of feeds ID for notificationsprojects
- list of project ID for notificationstypes
- list of notifications types for notifications in projectslang
- lang of this device
-
setNotificationSettings
public void setNotificationSettings(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang, UserIdentity user)
Save the notification settings for a user- Parameters:
pushToken
- token impacted by this settingsfeeds
- list of feeds ID for notificationsprojects
- list of project ID for notificationstypes
- list of notifications types for notifications in projectslang
- lang of this deviceuser
- the user impacted
-
getNotificationSettings
public Map<String,Object> getNotificationSettings(String pushToken, UserIdentity user)
Get the notification settings for a token- Parameters:
pushToken
- the token to readuser
- the user impacted- Returns:
- a map containing feeds, projects and types as Set<String>, and epochDay as the last modification date
-
-