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
Nested Classes Modifier and Type Class Description static classNotificationPreferencesHelper.FrequencyThe frequency of notifications
-
Field Summary
Fields Modifier and Type Field Description protected JSONUtils_jsonUtilsThe JSON utilsprotected ProjectManager_projectManagerThe project managerprotected UserPreferencesExtensionPoint_userPrefEPThe user preferences extension pointprotected UserPreferencesManager_userPrefManagerThe user preferences managerstatic StringROLEThe avalon rolestatic StringUSERPREFS_IDthe id of the user prefs for notification preferences
-
Constructor Summary
Constructors Constructor Description NotificationPreferencesHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaskedToBeNotified(UserIdentity userIdentity, String projectName, NotificationPreferencesHelper.Frequency frequency)Determines if a user asked to be notify for a given project and frequencybooleanaskedToBeNotified(User user, String projectName, NotificationPreferencesHelper.Frequency frequency)Determines if a user asked to be notify for a given project and frequencyvoiddeleteProjectNotificationPreferences(UserIdentity userIdentity, String projectName)Delete the user preferences for notification on the given projectMap<String,Object>getNotificationPreferences(User user)Get the user's notification preferencesMap<String,Object>getNotificationPreferences(UserIdentity userIdentity)Get the user's notification preferencesStringgetNotificationPreferencesAsString(User user)Get the user's notification preferences as json StringStringgetNotificationPreferencesAsString(UserIdentity userIdentity)Get the user's notification preferences as json StringSet<String>getUserProjectsWithFrequency(User user, NotificationPreferencesHelper.Frequency frequency)Get the user's project set to receive notification for given frequencybooleanhasFrequencyInPreferences(User user, NotificationPreferencesHelper.Frequency frequency)Determines if a user has at least one notification preference with the given frequencyvoidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
USERPREFS_ID
public static final String USERPREFS_ID
the id of the user prefs for notification preferences- See Also:
- Constant Field Values
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSON utils
-
_userPrefManager
protected UserPreferencesManager _userPrefManager
The user preferences manager
-
_userPrefEP
protected UserPreferencesExtensionPoint _userPrefEP
The user preferences extension point
-
_projectManager
protected ProjectManager _projectManager
The project manager
-
-
Constructor Detail
-
NotificationPreferencesHelper
public NotificationPreferencesHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein 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
-
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
public Map<String,Object> getNotificationPreferences(User user) throws UserPreferencesException
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
public String getNotificationPreferencesAsString(User user) throws UserPreferencesException
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
public void deleteProjectNotificationPreferences(UserIdentity userIdentity, String projectName)
Delete the user preferences for notification on the given project- Parameters:
userIdentity- the user identityprojectName- the name of the project to delete
-
-