Class DefaultNotificationManager
- java.lang.Object
-
- org.silverpeas.core.notification.user.client.DefaultNotificationManager
-
- All Implemented Interfaces:
ComponentInstanceDeletion
,NotificationManager
,NotificationURLProvider
@Service public class DefaultNotificationManager extends Object implements NotificationURLProvider, ComponentInstanceDeletion, NotificationManager
Default implementation of theNotificationManager
service. Its main goal is to figure out the destination of notifications from some predefined rules. The message sending itself is delegated to theNotificationServer
.- Version:
- 1.0
- Author:
- Eric BURGEL
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultNotificationManager()
This hidden constructor permits to IoC to create an instance ofComponentInstanceDeletion
of this implementation.
-
Method Summary
All Methods Instance Methods Concrete 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
delete(String componentInstanceId)
Deletes the resources belonging to the specified component instance.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.DefaultNotificationManager
forLanguage(String language)
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.protected List<NotifChannel>
getDefaultNotificationChannels()
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.notification.user.client.NotificationURLProvider
computeURL, computeURL, getApplicationURL, getUserAutoRedirectServerURL, getUserAutoRedirectSilverpeasServerURL, getUserAutoRedirectURL, getUserAutoRedirectURL
-
-
-
-
Constructor Detail
-
DefaultNotificationManager
protected DefaultNotificationManager()
This hidden constructor permits to IoC to create an instance ofComponentInstanceDeletion
of this implementation.
-
-
Method Detail
-
forLanguage
public DefaultNotificationManager forLanguage(String language)
- Specified by:
forLanguage
in interfaceNotificationManager
-
delete
public void delete(String componentInstanceId)
Deletes the resources belonging to the specified component instance. This method is invoked by Silverpeas when a component instance is being deleted.- Specified by:
delete
in interfaceComponentInstanceDeletion
- Parameters:
componentInstanceId
- the unique identifier of a component instance.
-
getNotifAddressProperties
public List<Properties> getNotifAddressProperties(String aUserId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
getNotifAddressProperties
in interfaceNotificationManager
- Throws:
NotificationException
- if an error occurs while building the properties the notification addresses.
-
getNotifAddressProperties
public Properties getNotifAddressProperties(String addressId, String aUserId) throws NotificationException
Description copied from interface:NotificationManager
Gets the properties of the specified notification address of the given user.- Specified by:
getNotifAddressProperties
in interfaceNotificationManager
- 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
public String getDefaultAddressId(String aUserId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
getDefaultAddressId
in interfaceNotificationManager
- 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
public List<Properties> getNotifChannels() throws NotificationException
Description copied from interface:NotificationManager
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
.- Specified by:
getNotifChannels
in interfaceNotificationManager
- 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
public List<Properties> getNotifPreferences(String aUserId) throws NotificationException
Description copied from interface:NotificationManager
Gets the notifications preferences of the specified user.- Specified by:
getNotifPreferences
in interfaceNotificationManager
- 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
public Properties getNotifPreference(String aPrefId, String aUserId) throws NotificationException
Description copied from interface:NotificationManager
Gets the properties about the specified preference of the given user on the notifications.- Specified by:
getNotifPreference
in interfaceNotificationManager
- 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
public void setDefaultAddress(String aNotificationAddressId, String aUserId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
setDefaultAddress
in interfaceNotificationManager
- 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
public void addDefaultAddress(String aNotificationAddressId, String aUserId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
addDefaultAddress
in interfaceNotificationManager
- 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
public void savePreferences(String aUserId, int instanceLocalId, int aMessageType, String notifAddressId) throws NotificationException
Description copied from interface:NotificationManager
Saves the preference on notification of the given user and for the specified component instance and for the specified type of message.- Specified by:
savePreferences
in interfaceNotificationManager
- 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
public void saveNotifAddress(NotificationAddress notificationAddress) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
saveNotifAddress
in interfaceNotificationManager
- Parameters:
notificationAddress
- a custom notification address to save.- Throws:
NotificationException
- if an error occurs while saving the specified custom address.
-
deletePreference
public void deletePreference(String aPreferenceId) throws NotificationException
Description copied from interface:NotificationManager
Deletes the specified preference. A preference is always related to a user and it is unique to that user.- Specified by:
deletePreference
in interfaceNotificationManager
- Parameters:
aPreferenceId
- the unique identifier of a preference.- Throws:
NotificationException
- if an error occurs while deleting the notification preference.
-
deleteNotifAddress
public void deleteNotifAddress(String aNotificationAddressId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
deleteNotifAddress
in interfaceNotificationManager
- Parameters:
aNotificationAddressId
- the unique identifier of a custom notification address.- Throws:
NotificationException
- if an error occurs while deleting the notification address.
-
deleteAllDefaultAddress
public void deleteAllDefaultAddress(String userId) throws NotificationException
Description copied from interface:NotificationManager
Deletes all the notification addresses set as default for the specified user.- Specified by:
deleteAllDefaultAddress
in interfaceNotificationManager
- Parameters:
userId
- the unique identifier of a user.- Throws:
NotificationException
- if an error occurs while deleting the addresses.
-
testNotifAddress
public void testNotifAddress(String addressId, String aUserId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
testNotifAddress
in interfaceNotificationManager
- 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
public void notifyUsers(NotificationParameters params, Collection<String> userIds) throws NotificationException
Description copied from interface:NotificationManager
Notifies the specified users by using the given notification parameters.- Specified by:
notifyUsers
in interfaceNotificationManager
- 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
public void notifyExternals(NotificationParameters params, Collection<ExternalRecipient> externals) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
notifyExternals
in interfaceNotificationManager
- 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
public Collection<UserRecipient> getUsersFromGroup(String groupId) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
getUsersFromGroup
in interfaceNotificationManager
- 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
public String getComponentFullName(String compInst) throws NotificationException
Description copied from interface:NotificationManager
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.- Specified by:
getComponentFullName
in interfaceNotificationManager
- 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
public boolean isMultiChannelNotification()
Description copied from interface:NotificationManager
Is the multi-channel option enabled? If true, then several notification addresses can be set as the default ones for the users.- Specified by:
isMultiChannelNotification
in interfaceNotificationManager
- Returns:
- true if the multi-channel property is enabled. False otherwise.
- See Also:
NotificationManagerSettings.isMultiChannelNotificationEnabled()
-
getDefaultNotificationChannels
protected List<NotifChannel> getDefaultNotificationChannels()
-
-