Class TranslationAlertFunction
java.lang.Object
org.ametys.plugins.workflow.AbstractWorkflowComponent
org.ametys.cms.workflow.AbstractContentWorkflowComponent
org.ametys.plugins.translationflagging.TranslationAlertFunction
- All Implemented Interfaces:
com.opensymphony.workflow.FunctionProvider,PluginAware,Initializable,LogEnabled,Serviceable
public class TranslationAlertFunction
extends AbstractContentWorkflowComponent
implements com.opensymphony.workflow.FunctionProvider, Initializable, PluginAware
When a content is saved, this workflow function looks if the pages it belongs to are translated in other languages.
If this is the case, an alert e-mail is sent to all the persons who are responsible for modifying the translated pages,
to inform them that a new version is available.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe server base URL.protected I18nUtilsThe i18n utils.protected StringThe plugin name.protected AmetysObjectResolverThe ametys object resolver.protected RightManagerThe rights manager.protected UserManagerThe users manager.static final StringThe e-mail body i18n key.static final StringThe e-mail subject i18n key.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEYFields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_ERRORS_KEY, WORKFLOW_WARNS_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected StringgetPageUrl(Page page) Get the URL of the back-office, opening on the page tool.getTranslations(Page page) Get the translations of a given page.protected HashSet<UserIdentity>getUsersToNotify(Page translatedPage) Get the users to notify about the page translation.voidprotected voidsendAlert(Page page, WebContent content, Page translatedPage, Set<UserIdentity> users) Build and send an alert e-mail to inform of a translation to a list of users.protected voidsendAlerts(WebContent content) Send the alerts to tell users the translated content was modified.protected voidSend a translation alert e-mail to the specified users.voidservice(ServiceManager serviceManager) voidsetPluginInfo(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
getContentMethods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser
-
Field Details
-
I18N_KEY_SUBJECT
The e-mail subject i18n key.- See Also:
-
I18N_KEY_BODY
The e-mail body i18n key.- See Also:
-
_userManager
The users manager. -
_rightManager
The rights manager. -
_i18nUtils
The i18n utils. -
_resolver
The ametys object resolver. -
_pluginName
The plugin name. -
_baseUrl
The server base URL.
-
-
Constructor Details
-
TranslationAlertFunction
public TranslationAlertFunction()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
service
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractContentWorkflowComponent- Throws:
ServiceException
-
execute
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException - Specified by:
executein interfacecom.opensymphony.workflow.FunctionProvider- Throws:
com.opensymphony.workflow.WorkflowException
-
sendAlerts
Send the alerts to tell users the translated content was modified.- Parameters:
content- the modified content.
-
sendAlert
protected void sendAlert(Page page, WebContent content, Page translatedPage, Set<UserIdentity> users) Build and send an alert e-mail to inform of a translation to a list of users.- Parameters:
page- the modified page.content- the content which was modified.translatedPage- the translated page.users- the users to send the e-mail to.
-
sendMails
Send a translation alert e-mail to the specified users.- Parameters:
subject- the e-mail subject.body- the e-mail body.users- the users to send the e-mail to.from- the e-mail will be sent with this "from" header.
-
getUsersToNotify
Get the users to notify about the page translation.- Parameters:
translatedPage- the translated version of the page.- Returns:
- the logins of the users to notify.
-
getTranslations
Get the translations of a given page.- Parameters:
page- the page.- Returns:
- the translated pages as a Map of pages, indexed by sitemap name (language).
-
getPageUrl
Get the URL of the back-office, opening on the page tool.- Parameters:
page- the page to open on.- Returns:
- the page URL.
-