Interface NotificationManager
- All Known Implementing Classes:
NotificationManagerImpl
public interface NotificationManager
Provide methods to manage notifications.
-
Method Summary
Modifier and TypeMethodDescriptioncloneNotificationSet(NotificationSet oldSet) Clone notification set and rules for use when cloningPlan@NotNull NotificationRulecreateNotificationRule(@NotNull Class<? extends NotificationType> notificationTypeClass, @Nullable String conditionData, @NotNull Class<? extends NotificationRecipient> recipientTypeClass, @Nullable String recipientString) createNotificationRule(String conditionKey, String conditionData, String recipientString, String recipientType) Create notification rule and provide required managers.createNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientType, Map<String, String[]> actionParameters) Creates a notification rule based on the keys and params passed in from the action@NotNull NotificationSetGet the system notification set for this bamboo and if one doesn't exist create it!Return notification types marked explicitly as "chain" notification in plugin xml description@Nullable NotificationRecipientInstantiate and populate notification recipient from a rule.@Nullable NotificationRecipientgetNotificationRecipientFromKey(String notificationRecipientKey) @Nullable NotificationRulegetNotificationRuleById(long notificationId) Get a specific notification rule@NotNull Set<NotificationRule>getNotificationRules(@Nullable ImmutablePlan plan) Extract notification rules for a plan.getNotificationRules(@Nullable Plan plan) Deprecated.@NotNull List<UsersNotification>getNotificationRulesForUser(@NotNull BambooUser user) Retrieves all notification rules associated with a given user searches for notification rules: * assigned to the user * assigned to a group the user belongs to * assigned to the user's email or user's im address * assigned to watchers of a build the user has marked as their favourite@Nullable NotificationSetgetNotificationSetById(long notificationSetId) Get a specific notification set@Nullable NotificationTypeInstantiate and populate notification type from a rule.@Nullable NotificationTypeRetrieve a specificNotificationTypeplugin module based on the given key.booleanisRecipientUserBase(NotificationRule notificationRule) Determines whether or not a notification rule recipient evaluates to a bamboo user and therefore comply with the users notification preference.voidreplaceNotificationRule(@NotNull NotificationSet notificationSet, long existingNotificationId, @NotNull NotificationRule newNotificationRule) Replaces a notification rule with the new definition.voidSaves a notification set without requiring a build.voidsaveSystemNotificationRule(@NotNull NotificationRule notificationRule) Do not use this method.
-
Method Details
-
createNotificationRule
NotificationRule createNotificationRule(String conditionKey, String conditionData, String recipientString, String recipientType) Create notification rule and provide required managers.- Parameters:
conditionKey- - key representation of the notification typeconditionData- - any data the notification type requiresrecipientString- - data the recipient type requires (e.g user or group name)recipientType- - key representing the type of recipient- Returns:
- a newly created notification rule
-
createNotificationRule
@NotNull @NotNull NotificationRule createNotificationRule(@NotNull @NotNull Class<? extends NotificationType> notificationTypeClass, @Nullable @Nullable String conditionData, @NotNull @NotNull Class<? extends NotificationRecipient> recipientTypeClass, @Nullable @Nullable String recipientString) - Parameters:
notificationTypeClass-NotificationTypeconditionData- - any data the notification type requiresrecipientTypeClass-NotificationRecipientrecipientString- - data the recipient type requires (e.g user or group name)- Returns:
- a newly created notification rule
-
createNotificationRuleFromAction
NotificationRule createNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientType, Map<String, String[]> actionParameters) throws IllegalArgumentExceptionCreates a notification rule based on the keys and params passed in from the action- Parameters:
notificationTypeKey- - the plugin key for the notification type selectednotificationRecipientType- - the plugin key for the notification recipient type selectedactionParameters- - the action params.- Returns:
- a new notification rule
- Throws:
IllegalArgumentException- if either of the keys provided is invalid
-
getNotificationRules
@NotNull @NotNull Set<NotificationRule> getNotificationRules(@Nullable @Nullable ImmutablePlan plan) Extract notification rules for a plan.- Parameters:
plan- to get notifications for- Returns:
- a set of notification rules belonging to the given plan.
-
getNotificationRules
Deprecated.since 5.4 usegetNotificationRules(com.atlassian.bamboo.plan.cache.ImmutablePlan)instead -
cloneNotificationSet
Clone notification set and rules for use when cloningPlan- Parameters:
oldSet- - the notification set to clone- Returns:
- a new notification set containing the same notifications as in the original set.
-
getAllNotificationTypes
List<NotificationType> getAllNotificationTypes()- Returns:
- a list of all enabled
NotificationTypeplugin modules regardless of scope.
-
getSystemNotificationTypes
List<NotificationType> getSystemNotificationTypes()- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "system" scope
-
getDeploymentNotificationTypes
List<NotificationType> getDeploymentNotificationTypes()- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "deployment" scope
-
getPlanNotificationTypes
List<NotificationType> getPlanNotificationTypes()- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "plan" scope
-
getChainNotificationTypes
List<NotificationType> getChainNotificationTypes()Return notification types marked explicitly as "chain" notification in plugin xml description- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "chain" scope
-
getNotificationTypeFromKey
Retrieve a specificNotificationTypeplugin module based on the given key.- Parameters:
key- of the notification type- Returns:
- a specific
NotificationTypeplugin module based on the given key.
-
getAllNotificationRecipients
List<NotificationRecipient> getAllNotificationRecipients()- Returns:
- a list of all enabled
NotificationRecipientplugin modules
-
getNotificationRecipientFromKey
@Nullable @Nullable NotificationRecipient getNotificationRecipientFromKey(String notificationRecipientKey) - Parameters:
notificationRecipientKey- representing the NotificationRecipient required- Returns:
- a specific
NotificationRecipientplugin module based on the given key.
-
getNotificationRecipient
Instantiate and populate notification recipient from a rule.- Since:
- 5.15
-
getNotificationType
Instantiate and populate notification type from a rule.- Since:
- 5.15
-
saveNotificationSet
Saves a notification set without requiring a build.- Parameters:
nSet- the notification set to save
-
getNotificationRulesForUser
@NotNull @NotNull List<UsersNotification> getNotificationRulesForUser(@NotNull @NotNull BambooUser user) Retrieves all notification rules associated with a given user searches for notification rules: * assigned to the user * assigned to a group the user belongs to * assigned to the user's email or user's im address * assigned to watchers of a build the user has marked as their favourite- Parameters:
user- BambooUser to look up notifications for- Returns:
- all notification rules associated with a given user following the above rules
-
isRecipientUserBase
Determines whether or not a notification rule recipient evaluates to a bamboo user and therefore comply with the users notification preference.- Parameters:
notificationRule- to check- Returns:
- true if the recipient evaluates to a user
-
replaceNotificationRule
void replaceNotificationRule(@NotNull @NotNull NotificationSet notificationSet, long existingNotificationId, @NotNull @NotNull NotificationRule newNotificationRule) Replaces a notification rule with the new definition. This method should always be preferred when replacing an existing rule instead of operating on theNotificationSetmanually. Reason: as of current Hibernate, queries which modify collections (such asNotificationSet) are batched and executed in a specific order. In particular, inserts are executed before deletes. Due to constraints on theNotificationRuleclass/table this may lead to database constraint violations, resulting in unsuccessful updates and exceptions.- Parameters:
notificationSet- notification set on which the operation should be executedexistingNotificationId- id of the existing notification rulenewNotificationRule- new notification rule to replace the existing one- See Also:
-
saveSystemNotificationRule
Do not use this method. Use SystemNotificationService.saveSystemNotificationRule(); Save an individual system notification rule.- Parameters:
notificationRule- to be added
-
getNotificationRuleById
Get a specific notification rule- Parameters:
notificationId- of the notification to get.- Returns:
- the notification rule with the given ID, or null if one doesn't eixst
-
createOrGetSystemNotificationSet
Get the system notification set for this bamboo and if one doesn't exist create it!- Returns:
-
getNotificationSetById
Get a specific notification set- Parameters:
notificationSetId- of the notification set to get.- Returns:
- the notification set with the given ID, or null if one doesn't exist
-
getNotificationRules(com.atlassian.bamboo.plan.cache.ImmutablePlan)instead