@Service public class NotificationService extends Object
| Constructor and Description |
|---|
NotificationService() |
| Modifier and Type | Method and Description |
|---|---|
Collection<NotificationDefinition> |
getRegisteredDefinitions() |
Map<NotificationDefinition,NotificationScheduleTypes> |
getUserNotificationSchedules(Long userId)
Method to get a map of all set notification definitions and schedules for a given user.
|
void |
postConstruct()
Post constructor to register default definitions.
|
void |
register(NotificationDefinition... definitions)
Method to register new definitions.
|
void |
saveUserNotificationSchedule(Long userId,
NotificationDefinition definition,
NotificationScheduleTypes scheduleType)
Method to save a setting for the given user.
|
void |
saveUserNotificationSchedules(Long userId,
Map<NotificationDefinition,NotificationScheduleTypes> mappings)
Method to save schedules for the given user.
|
void |
sendMessage(Long noteId,
Long userToNotify,
NotificationDefinition notificationDefinition,
Map<String,Object> model)
Send notifications to users to inform about created or edited notes.
|
void |
sendMessage(Note note,
Collection<User> usersToNotify,
NotificationDefinition notificationDefinition)
Send notifications to users to inform about created or edited notes.
|
void |
unregister(NotificationDefinition... definitions)
Method to remove registered definitions.
|
boolean |
userHasSchedule(Long userId,
NotificationDefinition definition,
NotificationScheduleTypes schedule) |
public Collection<NotificationDefinition> getRegisteredDefinitions()
public Map<NotificationDefinition,NotificationScheduleTypes> getUserNotificationSchedules(Long userId) throws NotFoundException, AuthorizationException
userId - The users id.NotFoundException - Thrown, when the user was not found.AuthorizationException - Thrown, when the current user is not allowed to access the given properties.@PostConstruct public void postConstruct()
public void register(NotificationDefinition... definitions)
definitions - The definitions to register.public void saveUserNotificationSchedule(Long userId, NotificationDefinition definition, NotificationScheduleTypes scheduleType) throws NotFoundException, AuthorizationException
userId - The user to save the setting for.definition - The definition to save.scheduleType - The schedule type to set. Use null to delete the setting.NotFoundException - Thrown, when the user doesn't exists.AuthorizationException - Thrown, when the current user is not allowed to access this settings.public void saveUserNotificationSchedules(Long userId, Map<NotificationDefinition,NotificationScheduleTypes> mappings) throws NotFoundException, AuthorizationException
userId - The user to save the setting for.mappings - Mappings from definitions to schedules.NotFoundException - Thrown, when the user doesn't exists.AuthorizationException - Thrown, when the current user is not allowed to access this settings.public void sendMessage(Long noteId, Long userToNotify, NotificationDefinition notificationDefinition, Map<String,Object> model)
noteId - Id of the note, which should be send. the note to inform aboutuserToNotify - Id of the user to notify.notificationDefinition - The current definition of the notification.model - Additional elements used for the velocity context.public void sendMessage(Note note, Collection<User> usersToNotify, NotificationDefinition notificationDefinition)
note - the note to inform aboutusersToNotify - the users to be notifiednotificationDefinition - The current definition of the notification.public void unregister(NotificationDefinition... definitions)
definitions - The definitions to remove.public boolean userHasSchedule(Long userId, NotificationDefinition definition, NotificationScheduleTypes schedule)
userId - The user.definition - The definition to check.schedule - The schedule to check.Copyright © 2019 Communote team. All rights reserved.