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
,EnhancedFunction
,PluginAware
,Initializable
,LogEnabled
,Serviceable
public class TranslationAlertFunction
extends AbstractContentWorkflowComponent
implements EnhancedFunction, 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
AbstractWorkflowComponent.ConditionFailure
Nested classes/interfaces inherited from interface org.ametys.plugins.workflow.EnhancedFunction
EnhancedFunction.FunctionType
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The server base URL.protected I18nUtils
The i18n utils.protected String
The plugin name.protected AmetysObjectResolver
The ametys object resolver.protected RightManager
The rights manager.protected UserManager
The users manager.static final String
The e-mail body i18n key.static final String
The e-mail body's title i18n key.static final String
The e-mail subject i18n key.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEY
Fields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_VALIDATION_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
getLabel()
Get the label for this functionprotected String
getPageUrl
(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.void
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.protected void
sendAlerts
(WebContent content) Send the alerts to tell users the translated content was modified.protected void
Send a translation alert e-mail to the specified users.void
service
(ServiceManager serviceManager) void
setPluginInfo
(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
getContent
Methods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.workflow.EnhancedFunction
getArguments, getFullLabel, getFunctionExecType, getVisibilities
-
Field Details
-
I18N_KEY_SUBJECT
The e-mail subject i18n key.- See Also:
-
I18N_KEY_BODY_TITLE
The e-mail body's title 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:PluginAware
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.- Specified by:
setPluginInfo
in 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:
initialize
in interfaceInitializable
- Throws:
Exception
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractContentWorkflowComponent
- Throws:
ServiceException
-
execute
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException - Specified by:
execute
in 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.htmlBody
- 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.
-
getLabel
Description copied from interface:EnhancedFunction
Get the label for this function- Specified by:
getLabel
in interfaceEnhancedFunction
- Returns:
- the label
-