public class NotificationManagerImpl extends Object implements NotificationManager
Modifier and Type | Field and Description |
---|---|
static String |
COMMITTER_RECIPIENT |
static String |
FAILED_CHAIN_NOTIFICATION |
static String |
USER_RECIPIENT |
static String |
WATCHER_RECIPIENT |
Constructor and Description |
---|
NotificationManagerImpl() |
Modifier and Type | Method and Description |
---|---|
NotificationSet |
cloneNotificationSet(NotificationSet oldSet)
Clone notification set and rules for use when cloning
Plan |
NotificationRule |
createNotificationRule(Class<? extends NotificationType> notificationTypeClass,
String conditionData,
Class<? extends NotificationRecipient> recipientTypeClass,
String recipientString)
|
NotificationRule |
createNotificationRule(String conditionKey,
String conditionData,
String recipientString,
String recipientType)
Create notification rule and provide required managers.
|
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
|
NotificationSet |
createOrGetSystemNotificationSet()
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 description
|
List<NotificationType> |
getDeploymentNotificationTypes() |
NotificationRecipient |
getNotificationRecipient(NotificationRule rule)
Instantiate and populate notification recipient from a rule.
|
NotificationRecipient |
getNotificationRecipientFromKey(String notificationRecipientKey) |
NotificationRule |
getNotificationRuleById(long notificationId)
Get a specific notification rule
|
Set<NotificationRule> |
getNotificationRules(ImmutablePlan plan)
Extract notification rules for a plan.
|
Set<NotificationRule> |
getNotificationRules(Plan plan) |
List<UsersNotification> |
getNotificationRulesForUser(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
|
List<NotificationSet> |
getNotificationSetsForType(NotificationSet.NotificationSetType type) |
NotificationType |
getNotificationType(NotificationRule rule)
Instantiate and populate notification type from a rule.
|
NotificationType |
getNotificationTypeFromKey(String key)
Retrieve a specific
NotificationType plugin module based on the given key. |
List<NotificationType> |
getPlanNotificationTypes() |
List<NotificationType> |
getSystemNotificationTypes() |
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(NotificationSet notificationSet,
long existingNotificationId,
NotificationRule newNotificationRule)
Replaces a notification rule with the new definition.
|
void |
saveNotificationSet(NotificationSet notificationSet)
Saves a notification set without requiring a build.
|
void |
saveSystemNotificationRule(NotificationRule notificationRule)
Do not use this method.
|
void |
setBambooUserManager(BambooUserManager bambooUserManager) |
void |
setLabelManager(LabelManager labelManager) |
void |
setNotificationDao(NotificationDao notificationRuleDao) |
void |
setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor) |
public static final String USER_RECIPIENT
public static final String COMMITTER_RECIPIENT
public static final String WATCHER_RECIPIENT
public static final String FAILED_CHAIN_NOTIFICATION
public void saveNotificationSet(NotificationSet notificationSet)
NotificationManager
saveNotificationSet
in interface NotificationManager
notificationSet
- the notification set to savepublic NotificationRule createNotificationRule(String conditionKey, String conditionData, String recipientString, String recipientType)
NotificationManager
createNotificationRule
in interface NotificationManager
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@NotNull public NotificationRule createNotificationRule(@NotNull Class<? extends NotificationType> notificationTypeClass, @Nullable String conditionData, @NotNull Class<? extends NotificationRecipient> recipientTypeClass, @Nullable String recipientString)
NotificationManager
createNotificationRule
in interface NotificationManager
notificationTypeClass
- NotificationType
conditionData
- - any data the notification type requiresrecipientTypeClass
- NotificationRecipient
recipientString
- - data the recipient type requires (e.g user or group name)@NotNull public NotificationRule createNotificationRuleFromAction(String notificationTypeKey, String notificationRecipientKey, Map<String,String[]> actionParams) throws IllegalArgumentException
NotificationManager
createNotificationRuleFromAction
in interface NotificationManager
notificationTypeKey
- - the plugin key for the notification type selectednotificationRecipientKey
- - the plugin key for the notification recipient type selectedactionParams
- - the action params.IllegalArgumentException
- if either of the keys provided is invalidpublic Set<NotificationRule> getNotificationRules(@Nullable Plan plan)
getNotificationRules
in interface NotificationManager
@NotNull public Set<NotificationRule> getNotificationRules(@Nullable ImmutablePlan plan)
NotificationManager
getNotificationRules
in interface NotificationManager
plan
- to get notifications forpublic NotificationSet cloneNotificationSet(NotificationSet oldSet)
NotificationManager
Plan
cloneNotificationSet
in interface NotificationManager
oldSet
- - the notification set to clone@NotNull public List<NotificationSet> getNotificationSetsForType(NotificationSet.NotificationSetType type)
public List<NotificationType> getAllNotificationTypes()
getAllNotificationTypes
in interface NotificationManager
NotificationType
plugin modules regardless of scope.public List<NotificationType> getSystemNotificationTypes()
getSystemNotificationTypes
in interface NotificationManager
NotificationType
plugin modules which have the "system" scopepublic List<NotificationType> getDeploymentNotificationTypes()
getDeploymentNotificationTypes
in interface NotificationManager
NotificationType
plugin modules which have the "deployment" scopepublic List<NotificationType> getPlanNotificationTypes()
getPlanNotificationTypes
in interface NotificationManager
NotificationType
plugin modules which have the "plan" scopepublic List<NotificationType> getChainNotificationTypes()
NotificationManager
getChainNotificationTypes
in interface NotificationManager
NotificationType
plugin modules which have the "chain" scopepublic List<NotificationRecipient> getAllNotificationRecipients()
getAllNotificationRecipients
in interface NotificationManager
NotificationRecipient
plugin modulespublic NotificationRecipient getNotificationRecipientFromKey(String notificationRecipientKey)
getNotificationRecipientFromKey
in interface NotificationManager
notificationRecipientKey
- representing the NotificationRecipient requiredNotificationRecipient
plugin module based on the given key.@Nullable public NotificationRecipient getNotificationRecipient(NotificationRule rule)
NotificationManager
getNotificationRecipient
in interface NotificationManager
@Nullable public NotificationType getNotificationType(NotificationRule rule)
NotificationManager
getNotificationType
in interface NotificationManager
@Nullable public NotificationType getNotificationTypeFromKey(String key)
NotificationManager
NotificationType
plugin module based on the given key.getNotificationTypeFromKey
in interface NotificationManager
key
- of the notification typeNotificationType
plugin module based on the given key.@NotNull public List<UsersNotification> getNotificationRulesForUser(@NotNull BambooUser user)
NotificationManager
getNotificationRulesForUser
in interface NotificationManager
user
- BambooUser to look up notifications forpublic boolean isRecipientUserBase(NotificationRule notificationRule)
NotificationManager
isRecipientUserBase
in interface NotificationManager
notificationRule
- to checkpublic void replaceNotificationRule(@NotNull NotificationSet notificationSet, long existingNotificationId, @NotNull NotificationRule newNotificationRule)
NotificationManager
NotificationSet
manually.
Reason: as of current Hibernate, queries which modify collections (such as NotificationSet
) are batched
and executed in a specific order. In particular, inserts are executed before deletes. Due to constraints on the
NotificationRule
class/table this may lead to database constraint violations, resulting in unsuccessful
updates and exceptions.replaceNotificationRule
in interface NotificationManager
notificationSet
- notification set on which the operation should be executedexistingNotificationId
- id of the existing notification rulenewNotificationRule
- new notification rule to replace the existing one@NotNull public NotificationSet createOrGetSystemNotificationSet()
NotificationManager
createOrGetSystemNotificationSet
in interface NotificationManager
public void saveSystemNotificationRule(@NotNull NotificationRule notificationRule)
NotificationManager
saveSystemNotificationRule
in interface NotificationManager
notificationRule
- to be added@Nullable public NotificationRule getNotificationRuleById(long notificationId)
NotificationManager
getNotificationRuleById
in interface NotificationManager
notificationId
- of the notification to get.public void setNotificationDao(NotificationDao notificationRuleDao)
public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)
public void setBambooUserManager(BambooUserManager bambooUserManager)
public void setLabelManager(LabelManager labelManager)
Copyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.