Class NotificationManagerImpl
- java.lang.Object
-
- com.atlassian.bamboo.notification.NotificationManagerImpl
-
- All Implemented Interfaces:
NotificationManager
public class NotificationManagerImpl extends Object implements NotificationManager
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMMITTER_RECIPIENTstatic StringFAILED_CHAIN_NOTIFICATIONstatic StringUSER_RECIPIENTstatic StringWATCHER_RECIPIENTstatic StringWEBHOOK_RECIPIENT
-
Constructor Summary
Constructors Constructor Description NotificationManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NotificationSetcloneNotificationSet(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)NotificationRulecreateNotificationRule(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 NotificationSetcreateOrGetSystemNotificationSet()Get the system notification set for this bamboo and if one doesn't exist create it!List<NotificationRecipient>getAllNotificationRecipients()List<NotificationType>getAllNotificationTypes()List<NotificationType>getChainNotificationTypes()Return notification types marked explicitly as "chain" notification in plugin xml descriptionList<NotificationType>getDeploymentNotificationTypes()@Nullable NotificationRecipientgetNotificationRecipient(NotificationRule rule)Instantiate and populate notification recipient from a rule.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.Set<NotificationRule>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>getNotificationSetsForType(NotificationSet.NotificationSetType type)@Nullable NotificationTypegetNotificationType(NotificationRule rule)Instantiate and populate notification type from a rule.@Nullable NotificationTypegetNotificationTypeFromKey(String key)Retrieve a specificNotificationTypeplugin module based on the given key.List<NotificationType>getPlanNotificationTypes()List<NotificationType>getSystemNotificationTypes()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 Detail
-
USER_RECIPIENT
public static final String USER_RECIPIENT
- See Also:
- Constant Field Values
-
COMMITTER_RECIPIENT
public static final String COMMITTER_RECIPIENT
- See Also:
- Constant Field Values
-
WATCHER_RECIPIENT
public static final String WATCHER_RECIPIENT
- See Also:
- Constant Field Values
-
WEBHOOK_RECIPIENT
public static final String WEBHOOK_RECIPIENT
- See Also:
- Constant Field Values
-
FAILED_CHAIN_NOTIFICATION
public static final String FAILED_CHAIN_NOTIFICATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
saveNotificationSet
public void saveNotificationSet(NotificationSet notificationSet)
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 IllegalArgumentException
Description 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
public Set<NotificationRule> getNotificationRules(@Nullable @Nullable Plan plan)
- 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
public NotificationSet cloneNotificationSet(NotificationSet oldSet)
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
public List<NotificationType> getAllNotificationTypes()
- Specified by:
getAllNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules regardless of scope.
-
getSystemNotificationTypes
public List<NotificationType> getSystemNotificationTypes()
- Specified by:
getSystemNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "system" scope
-
getDeploymentNotificationTypes
public List<NotificationType> getDeploymentNotificationTypes()
- Specified by:
getDeploymentNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "deployment" scope
-
getPlanNotificationTypes
public List<NotificationType> getPlanNotificationTypes()
- Specified by:
getPlanNotificationTypesin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationTypeplugin modules which have the "plan" scope
-
getChainNotificationTypes
public List<NotificationType> 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
public List<NotificationRecipient> getAllNotificationRecipients()
- Specified by:
getAllNotificationRecipientsin interfaceNotificationManager- Returns:
- a list of all enabled
NotificationRecipientplugin modules
-
getNotificationRecipientFromKey
public NotificationRecipient getNotificationRecipientFromKey(String notificationRecipientKey)
- Specified by:
getNotificationRecipientFromKeyin interfaceNotificationManager- Parameters:
notificationRecipientKey- representing the NotificationRecipient required- Returns:
- a specific
NotificationRecipientplugin module based on the given key.
-
getNotificationRecipient
@Nullable public @Nullable NotificationRecipient getNotificationRecipient(NotificationRule rule)
Description copied from interface:NotificationManagerInstantiate and populate notification recipient from a rule.- Specified by:
getNotificationRecipientin interfaceNotificationManager
-
getNotificationType
@Nullable public @Nullable NotificationType getNotificationType(NotificationRule rule)
Description copied from interface:NotificationManagerInstantiate and populate notification type from a rule.- Specified by:
getNotificationTypein interfaceNotificationManager
-
getNotificationTypeFromKey
@Nullable public @Nullable NotificationType getNotificationTypeFromKey(String key)
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
public boolean isRecipientUserBase(NotificationRule notificationRule)
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:
- HHH-2801
-
createOrGetSystemNotificationSet
@NotNull public @NotNull NotificationSet 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
public void saveSystemNotificationRule(@NotNull @NotNull NotificationRule notificationRule)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
@Nullable public @Nullable NotificationRule getNotificationRuleById(long notificationId)
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
@Nullable public @Nullable NotificationSet getNotificationSetById(long notificationSetId)
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
public void setNotificationDao(NotificationDao notificationRuleDao)
-
setPluginAccessor
public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)
-
-