Class NotificationContext
- java.lang.Object
-
- com.atlassian.confluence.plugin.descriptor.mail.NotificationContext
-
public class NotificationContext extends Object
Contains data about an email Notification that is specific to a single Email sent to a single User.- Since:
- 4.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringWEB_FRAGMENT_INNER_CONTEXT
-
Constructor Summary
Constructors Constructor Description NotificationContext()NotificationContext(NotificationContext context)NotificationContext(NotificationContext context, Set<javax.activation.DataSource> dataSources)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTemplateImage(javax.activation.DataSource dataSource)Adds a datasource to the current set of datasources for 1 instance of notification.voidaddToWebFragmentContext(String key, String value)Adds a key/value pair to the Web-Fragment context.voidaddWebFragmentContext()Copies the current state of this context and stores it in a sub-map.Objectget(String key)StringgetAction()com.atlassian.user.UsergetActor()ConfluenceEntityObjectgetContent()Return the context's Content.ContentIdgetContentId()Return the context's Content id.com.atlassian.event.EventgetEvent()Map<String,Object>getMap()Returns a map for the renderer.com.atlassian.user.UsergetRecipient()Collection<javax.activation.DataSource>getTemplateImageDataSources()Notification.WatchTypegetWatchType()booleanisManageNotificationOverridden()voidput(String key, Object value)voidputAll(Map<? extends String,?> map)voidsetAction(String action)The type of action (e.g.voidsetActor(com.atlassian.user.User actor)Sets the user that performed the action that caused the notification to be sent.voidsetContent(ConfluenceEntityObject entity)Sets the entity that the notification is being sent regarding.voidsetContentId(ContentId contentId)Sets id of the entity that the notification is being sent regarding.voidsetEvent(com.atlassian.event.Event event)voidsetI18n(I18NBean i18NBean)voidsetManageNotificationOverridden(boolean isOverridden)voidsetRecipient(com.atlassian.user.User recipient)Sets the recipient for a notification.voidsetSpace(Space space)voidsetWatchType(Notification.WatchType watchType)
-
-
-
Field Detail
-
WEB_FRAGMENT_INNER_CONTEXT
public static final String WEB_FRAGMENT_INNER_CONTEXT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NotificationContext
public NotificationContext()
-
NotificationContext
public NotificationContext(NotificationContext context)
-
NotificationContext
public NotificationContext(NotificationContext context, Set<javax.activation.DataSource> dataSources)
-
-
Method Detail
-
getMap
public Map<String,Object> getMap()
Returns a map for the renderer. It aims at being rendered by the template engine, so no modification is allowed. Do not use it to modify values of the map.- Returns:
- an immutable map
-
getContent
public ConfluenceEntityObject getContent()
Return the context's Content.
-
setContent
public void setContent(ConfluenceEntityObject entity)
Sets the entity that the notification is being sent regarding.Should be set on the common NotificationContext in the
NotificationDataobject.
-
getContentId
public ContentId getContentId()
Return the context's Content id. This method is preferred overgetContent()because the Content reference might leak theConfluenceEntityObjectHibernate object.
-
setContentId
public void setContentId(ContentId contentId)
Sets id of the entity that the notification is being sent regarding.Should be set on the common NotificationContext in the
NotificationDataobject. This method is preferred oversetContent(ConfluenceEntityObject)because that method might leak theConfluenceEntityObjectHibernate object.
-
getEvent
public com.atlassian.event.Event getEvent()
-
setEvent
public void setEvent(com.atlassian.event.Event event)
-
isManageNotificationOverridden
public boolean isManageNotificationOverridden()
-
setManageNotificationOverridden
public void setManageNotificationOverridden(boolean isOverridden)
-
getWatchType
public Notification.WatchType getWatchType()
-
setWatchType
public void setWatchType(Notification.WatchType watchType)
-
setSpace
public void setSpace(Space space)
-
setRecipient
public void setRecipient(com.atlassian.user.User recipient)
Sets the recipient for a notification.This should be only ever be called on the per-email NotificationContext instance, never on the common one inside the
NotificationDataobject.
-
getRecipient
public com.atlassian.user.User getRecipient()
-
setActor
public void setActor(com.atlassian.user.User actor)
Sets the user that performed the action that caused the notification to be sent.Should be set on the common NotificationContext in the
NotificationDataobject.
-
getActor
public com.atlassian.user.User getActor()
-
setAction
public void setAction(String action)
The type of action (e.g. create, delete, like, mention, share) that is causing the notification to be sent. This value must be represented by a string so that plugins can provide custom action types.Should be set on the common NotificationContext in the
NotificationDataobject.- Parameters:
action-
-
getAction
public String getAction()
-
setI18n
public void setI18n(I18NBean i18NBean)
-
addTemplateImage
public void addTemplateImage(javax.activation.DataSource dataSource)
Adds a datasource to the current set of datasources for 1 instance of notification.- Parameters:
dataSource- the datasource for the image.- See Also:
if you intend to add the image to all notification.
-
getTemplateImageDataSources
public Collection<javax.activation.DataSource> getTemplateImageDataSources()
-
addWebFragmentContext
public void addWebFragmentContext()
Copies the current state of this context and stores it in a sub-map.This is required for rendering web-panels in the Notification template that:
a) cannot be passed the entire render context for technical reasons b) shouldn't be passed the entire render context because it leaks services
This method should be called on the object returned by
NotificationData.cloneContext()as soon as the Recipient user is added.
-
addToWebFragmentContext
public void addToWebFragmentContext(String key, String value)
Adds a key/value pair to the Web-Fragment context.The webFragmentContext is purposely limited so that only named items like recipient and explicitly-added pairs are present in it. This is so that the context can be serialized to things like email tracking URLs. However, there's no stopping code like WebPanelFunction from adding further data to the context passed into the Soy render.
To avoid this context pollution we hide additional explicit context inside a map *inside* the map. Yo dawg indeed.
-
-