Class NotificationPreferencesHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.workspaces.project.notification.preferences.NotificationPreferencesHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class NotificationPreferencesHelper
extends AbstractLogEnabled
implements Component, Serviceable
Helper for notifications preferences
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The frequency of notifications -
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
To get the current userprotected JSONUtils
The JSON utilsprotected ProjectManager
The project managerprotected UserPreferencesExtensionPoint
The user preferences extension pointprotected UserPreferencesManager
The user preferences managerstatic final String
The avalon rolestatic final String
the id of the user prefs for notification preferences -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
askedToBeNotified
(UserIdentity userIdentity, String projectName, NotificationPreferencesHelper.Frequency frequency) Determines if a user asked to be notify for a given project and frequencyboolean
askedToBeNotified
(User user, String projectName, NotificationPreferencesHelper.Frequency frequency) Determines if a user asked to be notify for a given project and frequencyvoid
deleteProjectNotificationPreferences
(UserIdentity userIdentity, String projectName) Delete the user preferences for notification on the given projectGet the user's notification preferencesgetNotificationPreferences
(UserIdentity userIdentity) Get the user's notification preferencesGet the user's notification preferences as json StringgetNotificationPreferencesAsString
(UserIdentity userIdentity) Get the user's notification preferences as json StringGet the collection of paused project for a given usergetUserProjectsWithFrequency
(User user, NotificationPreferencesHelper.Frequency frequency) Get the user's project set to receive notification for given frequencyboolean
hasFrequencyInPreferences
(User user, NotificationPreferencesHelper.Frequency frequency) Determines if a user has at least one notification preference with the given frequencyvoid
service
(ServiceManager manager) boolean
setPauseProject
(String projectName, boolean pause) Change the pause status for the notifications of one projectMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
USERPREFS_ID
the id of the user prefs for notification preferences- See Also:
-
ROLE
The avalon role -
_jsonUtils
The JSON utils -
_userPrefManager
The user preferences manager -
_userPrefEP
The user preferences extension point -
_projectManager
The project manager -
_currentUserProvider
To get the current user
-
-
Constructor Details
-
NotificationPreferencesHelper
public NotificationPreferencesHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
askedToBeNotified
public boolean askedToBeNotified(User user, String projectName, NotificationPreferencesHelper.Frequency frequency) Determines if a user asked to be notify for a given project and frequency- Parameters:
user
- the userprojectName
- the project namefrequency
- the required frequency (each, daily, weekly or monthly)- Returns:
- true if the user need to be notified
-
askedToBeNotified
public boolean askedToBeNotified(UserIdentity userIdentity, String projectName, NotificationPreferencesHelper.Frequency frequency) Determines if a user asked to be notify for a given project and frequency- Parameters:
userIdentity
- the user identityprojectName
- the project namefrequency
- the required frequency (each, daily, weekly or monthly). Cannot be null.- Returns:
- true if the user need to be notified
-
getPausedProjects
Get the collection of paused project for a given user- Parameters:
user
- The user to consider- Returns:
- The set of projects names that are paused or null for a general pause
-
setPauseProject
Change the pause status for the notifications of one project- Parameters:
projectName
- The project name to changepause
- The pause status- Returns:
- true is the change was done successfully
-
hasFrequencyInPreferences
public boolean hasFrequencyInPreferences(User user, NotificationPreferencesHelper.Frequency frequency) Determines if a user has at least one notification preference with the given frequency- Parameters:
user
- the userfrequency
- the frequency- Returns:
- true if the user has at least one notification preference with the given frequency
-
getUserProjectsWithFrequency
public Set<String> getUserProjectsWithFrequency(User user, NotificationPreferencesHelper.Frequency frequency) Get the user's project set to receive notification for given frequency- Parameters:
user
- the userfrequency
- the matching frequency- Returns:
- The names of user's project's with same frequency
-
getNotificationPreferences
Get the user's notification preferences- Parameters:
user
- the user- Returns:
- the user's notification preferences
- Throws:
UserPreferencesException
- if failed to retrieve user's preferences
-
getNotificationPreferences
public Map<String,Object> getNotificationPreferences(UserIdentity userIdentity) throws UserPreferencesException Get the user's notification preferences- Parameters:
userIdentity
- the user identity- Returns:
- the user's notification preferences
- Throws:
UserPreferencesException
- if failed to retrieve user's preference
-
getNotificationPreferencesAsString
Get the user's notification preferences as json String- Parameters:
user
- the user- Returns:
- the user's notification preferences as json String
- Throws:
UserPreferencesException
- if failed to retrieve user's preference
-
getNotificationPreferencesAsString
public String getNotificationPreferencesAsString(UserIdentity userIdentity) throws UserPreferencesException Get the user's notification preferences as json String- Parameters:
userIdentity
- the user identity- Returns:
- the user's notification preferences as json String
- Throws:
UserPreferencesException
- if failed to retrieve user's preference
-
deleteProjectNotificationPreferences
Delete the user preferences for notification on the given project- Parameters:
userIdentity
- the user identityprojectName
- the name of the project to delete
-