Class NotificationPreferenceScriptService
- java.lang.Object
-
- org.xwiki.notifications.preferences.script.NotificationPreferenceScriptService
-
- All Implemented Interfaces:
org.xwiki.script.service.ScriptService
@Component @Named("notification.preferences") @Singleton public class NotificationPreferenceScriptService extends Object implements org.xwiki.script.service.ScriptServiceScript service for the notification preferences.- Since:
- 9.7RC1
- Version:
- $Id: 41cadddc39bd93665a12009575f1246a2f48ca0e $
-
-
Constructor Summary
Constructors Constructor Description NotificationPreferenceScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NotificationEmailDiffTypegetDiffType()NotificationEmailDiffTypegetDiffType(String userId)NotificationEmailDiffTypegetDiffType(org.xwiki.user.UserReference user)NotificationEmailIntervalgetInterval()NotificationEmailIntervalgetInterval(org.xwiki.user.UserReference user)booleanhasAnyEnabledNotificationPreferences()booleanisEventTypeEnabled(String eventType, NotificationFormat format)booleanisEventTypeEnabled(String eventType, NotificationFormat format, String wiki)booleanisEventTypeEnabledForUser(String eventType, NotificationFormat format, org.xwiki.user.UserReference userReference)voidsaveNotificationPreferences(String json)Update notification preferences of the given user.voidsaveNotificationPreferences(String json, org.xwiki.model.reference.DocumentReference userReference)Save preferences given as JSON.voidsaveNotificationPreferencesForCurrentWiki(String json)Update notification preferences of the current wiki.voidsetStartDate(String userId, Date startDate)Set the start date for every notification preference of the given user.voidsetStartDate(Date startDate)Set the start date for the current user.
-
-
-
Method Detail
-
saveNotificationPreferences
public void saveNotificationPreferences(String json, org.xwiki.model.reference.DocumentReference userReference) throws NotificationException, org.xwiki.security.authorization.AccessDeniedException
Save preferences given as JSON.- Parameters:
json- a list of preferences as JSONuserReference- reference of the user concerned by the preferences- Throws:
NotificationException- if error happensorg.xwiki.security.authorization.AccessDeniedException- if the current user has not the right to edit the given document
-
saveNotificationPreferences
public void saveNotificationPreferences(String json) throws NotificationException
Update notification preferences of the given user.- Parameters:
json- a list of notification preferences represented as JSON- Throws:
NotificationException- if an error occurs
-
saveNotificationPreferencesForCurrentWiki
public void saveNotificationPreferencesForCurrentWiki(String json) throws NotificationException, org.xwiki.security.authorization.AccessDeniedException
Update notification preferences of the current wiki.- Parameters:
json- a list of notification preferences represented as JSON- Throws:
NotificationException- if an error occursorg.xwiki.security.authorization.AccessDeniedException- if the current user has not the right to administrate the current wiki
-
setStartDate
public void setStartDate(Date startDate) throws NotificationException
Set the start date for the current user.- Parameters:
startDate- the date before which we ignore notifications- Throws:
NotificationException- if an error occurs
-
setStartDate
public void setStartDate(String userId, Date startDate) throws NotificationException
Set the start date for every notification preference of the given user.- Parameters:
userId- id of the userstartDate- the date before which we ignore notifications- Throws:
NotificationException- if an error occurs
-
hasAnyEnabledNotificationPreferences
public boolean hasAnyEnabledNotificationPreferences() throws NotificationException- Returns:
- if there is a least one preference enabled
- Throws:
NotificationException- if an error occurs- Since:
- 9.9RC1
-
getDiffType
public NotificationEmailDiffType getDiffType()
- Returns:
- the diff type for emails configured for the current user
- Since:
- 9.11RC1
-
getDiffType
public NotificationEmailDiffType getDiffType(String userId)
- Parameters:
userId- id of a user- Returns:
- the diff type for emails configured for the given user
- Since:
- 9.11RC1
-
getDiffType
@Unstable public NotificationEmailDiffType getDiffType(org.xwiki.user.UserReference user)
- Parameters:
user- reference of a user- Returns:
- the diff type for emails configured for the given user
- Since:
- 14.10
-
getInterval
@Unstable public NotificationEmailInterval getInterval()
- Returns:
- the email notification interval configured for the current user
- Since:
- 14.10
-
getInterval
@Unstable public NotificationEmailInterval getInterval(org.xwiki.user.UserReference user)
- Parameters:
user- reference of a user- Returns:
- the notification email interval configured for the given user
- Since:
- 14.10
-
isEventTypeEnabled
public boolean isEventTypeEnabled(String eventType, NotificationFormat format, String wiki) throws NotificationException, org.xwiki.security.authorization.AccessDeniedException
- Parameters:
eventType- an event typeformat- a notification formatwiki- id of the wiki- Returns:
- either or not the given event type is enabled by default on the given wiki in the given format
- Throws:
NotificationException- if an error happensorg.xwiki.security.authorization.AccessDeniedException- if the current user has not the admin right on the wiki
-
isEventTypeEnabled
public boolean isEventTypeEnabled(String eventType, NotificationFormat format) throws NotificationException
- Parameters:
eventType- an event typeformat- a notification format- Returns:
- either or not the given event type is enabled for the current user in the given format
- Throws:
NotificationException- if an error happens
-
isEventTypeEnabledForUser
public boolean isEventTypeEnabledForUser(String eventType, NotificationFormat format, org.xwiki.user.UserReference userReference) throws NotificationException
- Parameters:
eventType- an event typeformat- a notification formatuserReference- the reference of the user for which to check the event type- Returns:
- either or not the given event type is enabled for the given user in the given format
- Throws:
NotificationException- if an error happens- Since:
- 13.2RC1
-
-