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.ScriptService
Script service for the notification preferences.- Since:
- 9.7RC1
- Version:
- $Id: 2cf15b22e79bec4eca2315dc2380541409f93386 $
-
-
Constructor Summary
Constructors Constructor Description NotificationPreferenceScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NotificationEmailDiffType
getDiffType()
NotificationEmailDiffType
getDiffType(String userId)
boolean
hasAnyEnabledNotificationPreferences()
boolean
isEventTypeEnabled(String eventType, NotificationFormat format)
boolean
isEventTypeEnabled(String eventType, NotificationFormat format, String wiki)
boolean
isEventTypeEnabledForUser(String eventType, NotificationFormat format, org.xwiki.user.UserReference userReference)
void
saveNotificationPreferences(String json)
Update notification preferences of the given user.void
saveNotificationPreferences(String json, org.xwiki.model.reference.DocumentReference userReference)
Save preferences given as JSON.void
saveNotificationPreferencesForCurrentWiki(String json)
Update notification preferences of the current wiki.void
setStartDate(String userId, Date startDate)
Set the start date for every notification preference of the given user.void
setStartDate(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
-
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
@Unstable 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
-
-