Class NotificationManagerImpl
java.lang.Object
com.atlassian.bamboo.notification.NotificationManagerImpl
- All Implemented Interfaces:
NotificationManager
-
Field Summary
Fields -
Constructor Summary
Constructors -
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.@NotNull NotificationRulecreateNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientKey, Map<String, String[]> actionParams) 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.getNotificationRecipientFromKey(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) @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@NotNull List<NotificationSet>@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.voidsaveNotificationSet(NotificationSet notificationSet) Saves a notification set without requiring a build.voidsaveSystemNotificationRule(@NotNull NotificationRule notificationRule) Do not use this method.voidsetNotificationDao(NotificationDao notificationRuleDao) voidsetPluginAccessor(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:NotificationManagerSaves a notification set without requiring a build.- Specified by:
saveNotificationSetin interfaceNotificationManager- Parameters:
notificationSet- the notification set to save
-
createNotificationRule
public NotificationRule createNotificationRule(String conditionKey, String conditionData, String recipientString, String recipientType) Description copied from interface:NotificationManagerCreate notification rule and provide required managers.- Specified by:
createNotificationRulein 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:
createNotificationRulein interfaceNotificationManager- 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
@NotNull public @NotNull NotificationRule createNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientKey, Map<String, String[]> actionParams) throws IllegalArgumentExceptionDescription copied from interface:NotificationManagerCreates a notification rule based on the keys and params passed in from the action- Specified by:
createNotificationRuleFromActionin 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:
getNotificationRulesin interfaceNotificationManager
-
getNotificationRules
@NotNull public @NotNull Set<NotificationRule> getNotificationRules(@Nullable @Nullable ImmutablePlan plan) Description copied from interface:NotificationManagerExtract notification rules for a plan.- Specified by:
getNotificationRulesin interfaceNotificationManager- Parameters:
plan- to get notifications for- Returns:
- a set of notification rules belonging to the given plan.
-
cloneNotificationSet
Description copied from interface:NotificationManagerClone notification set and rules for use when cloningPlan- Specified by:
cloneNotificationSetin 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:
getAllNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules regardless of scope.
-
getSystemNotificationTypes
- Specified by:
getSystemNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "system" scope
-
getDeploymentNotificationTypes
- Specified by:
getDeploymentNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "deployment" scope
-
getPlanNotificationTypes
- Specified by:
getPlanNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "plan" scope
-
getChainNotificationTypes
Description copied from interface:NotificationManagerReturn notification types marked explicitly as "chain" notification in plugin xml description- Specified by:
getChainNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "chain" scope
-
getAllNotificationRecipients
- Specified by:
getAllNotificationRecipientsin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationRecipientplugin modules
-
getNotificationRecipientFromKey
- Specified by:
getNotificationRecipientFromKeyin interfaceNotificationManager- Parameters:
notificationRecipientKey- representing the NotificationRecipient required- Returns:
- a specific
NotificationRecipientplugin module based on the given key.
-
getNotificationRecipient
Description copied from interface:NotificationManagerInstantiate and populate notification recipient from a rule.- Specified by:
getNotificationRecipientin interfaceNotificationManager
-
getNotificationType
Description copied from interface:NotificationManagerInstantiate and populate notification type from a rule.- Specified by:
getNotificationTypein interfaceNotificationManager
-
getNotificationTypeFromKey
Description copied from interface:NotificationManagerRetrieve a specificNotificationTypeplugin module based on the given key.- Specified by:
getNotificationTypeFromKeyin interfaceNotificationManager- Parameters:
key- of the notification type- Returns:
- a specific
NotificationTypeplugin module based on the given key.
-
getNotificationRulesForUser
@NotNull public @NotNull List<UsersNotification> getNotificationRulesForUser(@NotNull @NotNull BambooUser user) Description copied from interface:NotificationManagerRetrieves 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:
getNotificationRulesForUserin 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:NotificationManagerDetermines whether or not a notification rule recipient evaluates to a bamboo user and therefore comply with the users notification preference.- Specified by:
isRecipientUserBasein 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:NotificationManagerReplaces 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.- Specified by:
replaceNotificationRulein 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:NotificationManagerGet the system notification set for this bamboo and if one doesn't exist create it!- Specified by:
createOrGetSystemNotificationSetin interfaceNotificationManager- Returns:
-
saveSystemNotificationRule
Description copied from interface:NotificationManagerDo not use this method. Use SystemNotificationService.saveSystemNotificationRule(); Save an individual system notification rule.- Specified by:
saveSystemNotificationRulein interfaceNotificationManager- Parameters:
notificationRule- to be added
-
getNotificationRuleById
Description copied from interface:NotificationManagerGet a specific notification rule- Specified by:
getNotificationRuleByIdin 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:NotificationManagerGet a specific notification set- Specified by:
getNotificationSetByIdin 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)
-