Class NotificationManagerImpl
java.lang.Object
com.atlassian.bamboo.notification.NotificationManagerImpl
- All Implemented Interfaces:
NotificationManager
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncloneNotificationSet
(NotificationSet oldSet) Clone notification set and rules for use when cloningPlan
@NotNull NotificationRule
createNotificationRule
(@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.@NotNull NotificationRule
createNotificationRuleFromAction
(String notificationTypeKey, String notificationRecipientKey, Map<String, String[]> actionParams) Creates a notification rule based on the keys and params passed in from the action@NotNull NotificationSet
Get 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 NotificationRecipient
Instantiate and populate notification recipient from a rule.getNotificationRecipientFromKey
(String notificationRecipientKey) @Nullable NotificationRule
getNotificationRuleById
(long notificationId) Get a specific notification rule@NotNull Set<NotificationRule>
getNotificationRules
(@Nullable ImmutablePlan plan) Extract notification rules for a plan.getNotificationRules
(@Nullable Plan plan) @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 NotificationSet
getNotificationSetById
(long notificationSetId) Get a specific notification set@NotNull List<NotificationSet>
@Nullable NotificationType
Instantiate and populate notification type from a rule.@Nullable NotificationType
Retrieve a specificNotificationType
plugin module based on the given key.boolean
isRecipientUserBase
(NotificationRule notificationRule) Determines whether or not a notification rule recipient evaluates to a bamboo user and therefore comply with the users notification preference.void
replaceNotificationRule
(@NotNull NotificationSet notificationSet, long existingNotificationId, @NotNull NotificationRule newNotificationRule) Replaces a notification rule with the new definition.void
saveNotificationSet
(NotificationSet notificationSet) Saves a notification set without requiring a build.void
saveSystemNotificationRule
(@NotNull NotificationRule notificationRule) Do not use this method.void
setNotificationDao
(NotificationDao notificationRuleDao) void
setPluginAccessor
(com.atlassian.plugin.PluginAccessor pluginAccessor)
-
Field Details
-
USER_RECIPIENT
- See Also:
-
COMMITTER_RECIPIENT
- See Also:
-
WATCHER_RECIPIENT
- See Also:
-
WEBHOOK_RECIPIENT
- See Also:
-
FAILED_CHAIN_NOTIFICATION
- See Also:
-
-
Constructor Details
-
NotificationManagerImpl
public NotificationManagerImpl()
-
-
Method Details
-
saveNotificationSet
Description copied from interface:NotificationManager
Saves a notification set without requiring a build.- Specified by:
saveNotificationSet
in interfaceNotificationManager
- Parameters:
notificationSet
- the notification set to save
-
createNotificationRule
public NotificationRule createNotificationRule(String conditionKey, String conditionData, String recipientString, String recipientType) Description copied from interface:NotificationManager
Create notification rule and provide required managers.- Specified by:
createNotificationRule
in interfaceNotificationManager
- 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 public @NotNull NotificationRule createNotificationRule(@NotNull @NotNull Class<? extends NotificationType> notificationTypeClass, @Nullable @Nullable String conditionData, @NotNull @NotNull Class<? extends NotificationRecipient> recipientTypeClass, @Nullable @Nullable String recipientString) Description copied from interface:NotificationManager
- Specified by:
createNotificationRule
in interfaceNotificationManager
- Parameters:
notificationTypeClass
-NotificationType
conditionData
- - any data the notification type requiresrecipientTypeClass
-NotificationRecipient
recipientString
- - data the recipient type requires (e.g user or group name)- Returns:
- a newly created notification rule
-
createNotificationRuleFromAction
@NotNull public @NotNull NotificationRule createNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientKey, Map<String, String[]> actionParams) throws IllegalArgumentExceptionDescription copied from interface:NotificationManager
Creates a notification rule based on the keys and params passed in from the action- Specified by:
createNotificationRuleFromAction
in interfaceNotificationManager
- Parameters:
notificationTypeKey
- - the plugin key for the notification type selectednotificationRecipientKey
- - the plugin key for the notification recipient type selectedactionParams
- - the action params.- Returns:
- a new notification rule
- Throws:
IllegalArgumentException
- if either of the keys provided is invalid
-
getNotificationRules
- Specified by:
getNotificationRules
in interfaceNotificationManager
-
getNotificationRules
@NotNull public @NotNull Set<NotificationRule> getNotificationRules(@Nullable @Nullable ImmutablePlan plan) Description copied from interface:NotificationManager
Extract notification rules for a plan.- Specified by:
getNotificationRules
in interfaceNotificationManager
- Parameters:
plan
- to get notifications for- Returns:
- a set of notification rules belonging to the given plan.
-
cloneNotificationSet
Description copied from interface:NotificationManager
Clone notification set and rules for use when cloningPlan
- Specified by:
cloneNotificationSet
in interfaceNotificationManager
- Parameters:
oldSet
- - the notification set to clone- Returns:
- a new notification set containing the same notifications as in the original set.
-
getNotificationSetsForType
@NotNull public @NotNull List<NotificationSet> getNotificationSetsForType(NotificationSet.NotificationSetType type) -
getAllNotificationTypes
- Specified by:
getAllNotificationTypes
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationType
plugin modules regardless of scope.
-
getSystemNotificationTypes
- Specified by:
getSystemNotificationTypes
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationType
plugin modules which have the "system" scope
-
getDeploymentNotificationTypes
- Specified by:
getDeploymentNotificationTypes
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationType
plugin modules which have the "deployment" scope
-
getPlanNotificationTypes
- Specified by:
getPlanNotificationTypes
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationType
plugin modules which have the "plan" scope
-
getChainNotificationTypes
Description copied from interface:NotificationManager
Return notification types marked explicitly as "chain" notification in plugin xml description- Specified by:
getChainNotificationTypes
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationType
plugin modules which have the "chain" scope
-
getAllNotificationRecipients
- Specified by:
getAllNotificationRecipients
in interfaceNotificationManager
- Returns:
- a list of all enabled
NotificationRecipient
plugin modules
-
getNotificationRecipientFromKey
- Specified by:
getNotificationRecipientFromKey
in interfaceNotificationManager
- Parameters:
notificationRecipientKey
- representing the NotificationRecipient required- Returns:
- a specific
NotificationRecipient
plugin module based on the given key.
-
getNotificationRecipient
Description copied from interface:NotificationManager
Instantiate and populate notification recipient from a rule.- Specified by:
getNotificationRecipient
in interfaceNotificationManager
-
getNotificationType
Description copied from interface:NotificationManager
Instantiate and populate notification type from a rule.- Specified by:
getNotificationType
in interfaceNotificationManager
-
getNotificationTypeFromKey
Description copied from interface:NotificationManager
Retrieve a specificNotificationType
plugin module based on the given key.- Specified by:
getNotificationTypeFromKey
in interfaceNotificationManager
- Parameters:
key
- of the notification type- Returns:
- a specific
NotificationType
plugin module based on the given key.
-
getNotificationRulesForUser
@NotNull public @NotNull List<UsersNotification> getNotificationRulesForUser(@NotNull @NotNull BambooUser user) Description copied from interface:NotificationManager
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- Specified by:
getNotificationRulesForUser
in interfaceNotificationManager
- Parameters:
user
- BambooUser to look up notifications for- Returns:
- all notification rules associated with a given user following the above rules
-
isRecipientUserBase
Description copied from interface:NotificationManager
Determines whether or not a notification rule recipient evaluates to a bamboo user and therefore comply with the users notification preference.- Specified by:
isRecipientUserBase
in interfaceNotificationManager
- Parameters:
notificationRule
- to check- Returns:
- true if the recipient evaluates to a user
-
replaceNotificationRule
public void replaceNotificationRule(@NotNull @NotNull NotificationSet notificationSet, long existingNotificationId, @NotNull @NotNull NotificationRule newNotificationRule) Description copied from interface:NotificationManager
Replaces a notification rule with the new definition. This method should always be preferred when replacing an existing rule instead of operating on theNotificationSet
manually. 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 theNotificationRule
class/table this may lead to database constraint violations, resulting in unsuccessful updates and exceptions.- Specified by:
replaceNotificationRule
in interfaceNotificationManager
- 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:
-
createOrGetSystemNotificationSet
Description copied from interface:NotificationManager
Get the system notification set for this bamboo and if one doesn't exist create it!- Specified by:
createOrGetSystemNotificationSet
in interfaceNotificationManager
- Returns:
-
saveSystemNotificationRule
Description copied from interface:NotificationManager
Do not use this method. Use SystemNotificationService.saveSystemNotificationRule(); Save an individual system notification rule.- Specified by:
saveSystemNotificationRule
in interfaceNotificationManager
- Parameters:
notificationRule
- to be added
-
getNotificationRuleById
Description copied from interface:NotificationManager
Get a specific notification rule- Specified by:
getNotificationRuleById
in interfaceNotificationManager
- Parameters:
notificationId
- of the notification to get.- Returns:
- the notification rule with the given ID, or null if one doesn't eixst
-
getNotificationSetById
Description copied from interface:NotificationManager
Get a specific notification set- Specified by:
getNotificationSetById
in interfaceNotificationManager
- Parameters:
notificationSetId
- of the notification set to get.- Returns:
- the notification set with the given ID, or null if one doesn't exist
-
setNotificationDao
-
setPluginAccessor
public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)
-