Class ThymeleafMessageBuilder
java.lang.Object
com.broadleafcommerce.notification.service.ThymeleafMessageBuilder
- All Implemented Interfaces:
MessageBuilder
Builds a message using the data from the notification and the associated template
-
Constructor Summary
ConstructorsConstructorDescriptionThymeleafMessageBuilder
(NotificationServiceProperties properties, TemplateNameResolver templateNameResolver, org.thymeleaf.TemplateEngine templateEngine) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAdditionalPropertiesToThymeleafContext
(org.thymeleaf.context.Context thymeleafContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Responsible for adding any additional properties to the Thymeleaf context that a template may need.protected String
buildFullLogoUrl
(NotificationServiceProperties.MessageProperties.MessageVariables.Asset assetProperties) Responsible for building the fully qualified logo URL from properties.buildMessage
(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getMessageVariablesFromProperties
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the supporting message variables that should be used for the currentcontextInfo
.
-
Constructor Details
-
ThymeleafMessageBuilder
public ThymeleafMessageBuilder(NotificationServiceProperties properties, TemplateNameResolver templateNameResolver, org.thymeleaf.TemplateEngine templateEngine)
-
-
Method Details
-
buildMessage
public String buildMessage(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
buildMessage
in interfaceMessageBuilder
-
addAdditionalPropertiesToThymeleafContext
protected void addAdditionalPropertiesToThymeleafContext(org.thymeleaf.context.Context thymeleafContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Responsible for adding any additional properties to the Thymeleaf context that a template may need.- Parameters:
thymeleafContext
- the Thymeleaf Context on which to add additional propertiescontextInfo
- context information surrounding multitenant state
-
getMessageVariablesFromProperties
@Nullable protected NotificationServiceProperties.MessageProperties.MessageVariables getMessageVariablesFromProperties(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the supporting message variables that should be used for the currentcontextInfo
. If the current context is an application context and properties have been specifically defined for it, they are returned. If not, then there will be a check for properties specific for the current tenant. If neither check produces results, thennull
will be returned.- Parameters:
contextInfo
- context information surrounding multitenant state- Returns:
- the supporting message properties that should be used for the current context, or
null
if none are found - See Also:
-
buildFullLogoUrl
protected String buildFullLogoUrl(NotificationServiceProperties.MessageProperties.MessageVariables.Asset assetProperties) Responsible for building the fully qualified logo URL from properties.- Parameters:
assetProperties
- properties from which to build the logo URL- Returns:
- the fully qualified URL to the logo
-