Interface NotificationManager
-
- All Known Implementing Classes:
DefaultNotificationManager
public interface NotificationManager
A manager of notification against users. It provides all the plumb to make, set and send the notifications. It is not dedicated to be used directly but by the implementation of theUserNotification
interface.- Author:
- mmoquillon
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addDefaultAddress(String aNotificationAddressId, String aUserId)
Sets the specified notification address as a default one for the given user identifier.void
deleteAllDefaultAddress(String userId)
Deletes all the notification addresses set as default for the specified user.void
deleteNotifAddress(String aNotificationAddressId)
Deletes the specified custom notification address.void
deletePreference(String aPreferenceId)
Deletes the specified preference.NotificationManager
forLanguage(String language)
static NotificationManager
get()
String
getComponentFullName(String compInst)
Gets the full name of a component instance.String
getDefaultAddressId(String aUserId)
Gets the default notification address of the specified user.List<Properties>
getNotifAddressProperties(String aUserId)
Gets all the properties about the different notification addresses that were set for the specified user.Properties
getNotifAddressProperties(String addressId, String aUserId)
Gets the properties of the specified notification address of the given user.List<Properties>
getNotifChannels()
Gets All the notification channels that are available in Silverpeas.Properties
getNotifPreference(String aPrefId, String aUserId)
Gets the properties about the specified preference of the given user on the notifications.List<Properties>
getNotifPreferences(String aUserId)
Gets the notifications preferences of the specified user.Collection<UserRecipient>
getUsersFromGroup(String groupId)
Gets all the notification recipients that are members of the specified user group.boolean
isMultiChannelNotification()
Is the multi-channel option enabled?void
notifyExternals(NotificationParameters params, Collection<ExternalRecipient> externals)
Notifies the specified external users by using the given notification parameters.void
notifyUsers(NotificationParameters params, Collection<String> userIds)
Notifies the specified users by using the given notification parameters.void
saveNotifAddress(NotificationAddress notificationAddress)
Saves the specified custom notification address for the specified user.void
savePreferences(String aUserId, int instanceLocalId, int aMessageType, String notifAddressId)
Saves the preference on notification of the given user and for the specified component instance and for the specified type of message.void
setDefaultAddress(String aNotificationAddressId, String aUserId)
Sets the specified notification address as the default one for the given user.void
testNotifAddress(String addressId, String aUserId)
Tests the specified address for specified user by sending a notification message through the channel related by this address.
-
-
-
Method Detail
-
get
static NotificationManager get()
-
forLanguage
NotificationManager forLanguage(String language)
-
getNotifAddressProperties
List<Properties> getNotifAddressProperties(String aUserId) throws NotificationException
Gets all the properties about the different notification addresses that were set for the specified user. The notification addresses are made up of both the built-in notification addresses and those that were created by the user himself.- Throws:
NotificationException
- if an error occurs while building the properties the notification addresses.
-
getNotifAddressProperties
Properties getNotifAddressProperties(String addressId, String aUserId) throws NotificationException
Gets the properties of the specified notification address of the given user.- Parameters:
addressId
- the unique identifier of a notification address. It can be either a built-in address identifier or the identifier of a custom address set by the user.aUserId
- the unique identifier of a user.- Returns:
- a
Properties
instance with the notification address properties. - Throws:
NotificationException
- if an error occurs while building the address properties.
-
getDefaultAddressId
String getDefaultAddressId(String aUserId) throws NotificationException
Gets the default notification address of the specified user. If multi-channel is supported, the user can have several default notification addresses. In that case, only the first one is get.- Parameters:
aUserId
- the unique identifier of the user.- Returns:
- the unique identifier of a notification address. It can be either a built-in address identifier of a notification channel or the identifier of a custom notification address set by the user.
- Throws:
NotificationException
- if an error occurs while getting a default address.
-
getNotifChannels
List<Properties> getNotifChannels() throws NotificationException
Gets All the notification channels that are available in Silverpeas. A channel is the medium through which notification messages are transmitted. For more information about the supported channels, seeNotifChannel
.- Returns:
- a list of properties containing "id" and "name" keys for each channel.
- Throws:
NotificationException
- if an error occurs while getting the supported channels.
-
getNotifPreferences
List<Properties> getNotifPreferences(String aUserId) throws NotificationException
Gets the notifications preferences of the specified user.- Parameters:
aUserId
- the unique identifier of the user.- Returns:
- a list of properties containing "name", "type", "usage" and "address" keys for each notification preference. The address identifies the unique identifier of a notification address that can be the identifier of either a built-in notification address or a custom notification address set by the user.
- Throws:
NotificationException
- if an error occurs while getting the preferences of the user about the notifications.
-
getNotifPreference
Properties getNotifPreference(String aPrefId, String aUserId) throws NotificationException
Gets the properties about the specified preference of the given user on the notifications.- Parameters:
aPrefId
- a unique identifier of the preference.aUserId
- a unique identifier of the user.- Returns:
- the properties containing "name", "type", "usage" and "address" keys of the preference.
- Throws:
NotificationException
- if an error occurs while getting the given preference.
-
setDefaultAddress
void setDefaultAddress(String aNotificationAddressId, String aUserId) throws NotificationException
Sets the specified notification address as the default one for the given user. If multi-channel is disabled, the specified address will replace the previous one if any.- Parameters:
aNotificationAddressId
- the unique identifier of a notification address. It can be either a built-in address identifier or a custom one set by the user.aUserId
- the unique identifier of the user.- Throws:
NotificationException
- if an error occurs while setting the specified address as a default one.
-
addDefaultAddress
void addDefaultAddress(String aNotificationAddressId, String aUserId) throws NotificationException
Sets the specified notification address as a default one for the given user identifier. Whatever the multi-channel support, the specified address is added among the others default ones of the user.- Parameters:
aNotificationAddressId
- the unique identifier of an address.aUserId
- the unique identifier of a user.- Throws:
NotificationException
- if an error occurs while adding the setting the address as a new default one for the user.
-
savePreferences
void savePreferences(String aUserId, int instanceLocalId, int aMessageType, String notifAddressId) throws NotificationException
Saves the preference on notification of the given user and for the specified component instance and for the specified type of message.- Parameters:
aUserId
- the unique identifier of a user.instanceLocalId
- the local identifier of a component instance.aMessageType
- the type of message.notifAddressId
- the unique identifier of a notification address.- Throws:
NotificationException
- if an error occurs while saving the preferences.
-
saveNotifAddress
void saveNotifAddress(NotificationAddress notificationAddress) throws NotificationException
Saves the specified custom notification address for the specified user. A custom address is a notification address the user defines himself in order to be notified either through another channel that those related to the built-in addresses or to another address that the built-in ones.- Parameters:
notificationAddress
- a custom notification address to save.- Throws:
NotificationException
- if an error occurs while saving the specified custom address.
-
deletePreference
void deletePreference(String aPreferenceId) throws NotificationException
Deletes the specified preference. A preference is always related to a user and it is unique to that user.- Parameters:
aPreferenceId
- the unique identifier of a preference.- Throws:
NotificationException
- if an error occurs while deleting the notification preference.
-
deleteNotifAddress
void deleteNotifAddress(String aNotificationAddressId) throws NotificationException
Deletes the specified custom notification address. If this address was set as a default one, then it is replaced by the first channel that values the propertynotif.defaultChannels
in theNotificationManagerSettings.properties
properties file.- Parameters:
aNotificationAddressId
- the unique identifier of a custom notification address.- Throws:
NotificationException
- if an error occurs while deleting the notification address.
-
deleteAllDefaultAddress
void deleteAllDefaultAddress(String userId) throws NotificationException
Deletes all the notification addresses set as default for the specified user.- Parameters:
userId
- the unique identifier of a user.- Throws:
NotificationException
- if an error occurs while deleting the addresses.
-
testNotifAddress
void testNotifAddress(String addressId, String aUserId) throws NotificationException
Tests the specified address for specified user by sending a notification message through the channel related by this address. If the address is a built-in one, then the unique identifier of the user is required to know at whom the address refers. Otherwise, for a custom address, the address itself identifies the concerned user.- Parameters:
addressId
- the unique identifier of a notification address. It can be either a built-in or a custom one defined by the user himself.aUserId
- the unique identifier of a user.- Throws:
NotificationException
- if an error occurs while sending a test notification message.
-
notifyUsers
void notifyUsers(NotificationParameters params, Collection<String> userIds) throws NotificationException
Notifies the specified users by using the given notification parameters.- Parameters:
params
- the parameters that describe among others the channel to use, the message to send, and so on.userIds
- a collection with the unique identifiers of the users to notify.- Throws:
NotificationException
- if an error occurs while sending the notification.
-
notifyExternals
void notifyExternals(NotificationParameters params, Collection<ExternalRecipient> externals) throws NotificationException
Notifies the specified external users by using the given notification parameters. Whatever the channels defined in the parameters, only the SMTP channel is used to notify external users.- Parameters:
params
- the parameters that carries among others the message to send, the subject of the notification, and so on.externals
- a collection of external recipients.- Throws:
NotificationException
- if an error occurs while sending the notification.
-
getUsersFromGroup
Collection<UserRecipient> getUsersFromGroup(String groupId) throws NotificationException
Gets all the notification recipients that are members of the specified user group. The user that have not an activated state in Silverpeas is not taken into account, so this kind of users is not included into the returned collection.- Parameters:
groupId
- the unique identifier of a user group in Silverpeas.- Returns:
- a collection of recipients.
- Throws:
NotificationException
- if an error occurs while getting the recipients of the given user group.
-
getComponentFullName
String getComponentFullName(String compInst) throws NotificationException
Gets the full name of a component instance. Such a full name is made up of the name of the space that contains the component instance followed by the name of the component instance.- Parameters:
compInst
- the unique identifier of a component instance.- Returns:
- the full name of the given component instance: the space name followed by the component name, separated by the minus character.
- Throws:
NotificationException
- if an error occurs computing the component instance full name.
-
isMultiChannelNotification
boolean isMultiChannelNotification()
Is the multi-channel option enabled? If true, then several notification addresses can be set as the default ones for the users.- Returns:
- true if the multi-channel property is enabled. False otherwise.
-
-