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
Fields Modifier and Type Field Description protected String_baseUrlThe server base URL.protected I18nUtils_i18nUtilsThe i18n utils.protected String_pluginNameThe plugin name.protected AmetysObjectResolver_resolverThe ametys object resolver.protected RightManager_rightManagerThe rights manager.protected UserManager_userManagerThe users manager.static StringI18N_KEY_BODYThe e-mail body i18n key.static StringI18N_KEY_SUBJECTThe 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_ERRORS_KEY, WORKFLOW_WARNS_KEY
-
-
Constructor Summary
Constructors Constructor Description TranslationAlertFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps)protected StringgetPageUrl(Page page)Get the URL of the back-office, opening on the page tool.protected Map<String,Page>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.voidinitialize()protected 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 voidsendMails(String subject, String body, Set<UserIdentity> users, String from)Send 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
getContent
-
Methods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser
-
-
-
-
Field Detail
-
I18N_KEY_SUBJECT
public static final String I18N_KEY_SUBJECT
The e-mail subject i18n key.- See Also:
- Constant Field Values
-
I18N_KEY_BODY
public static final String I18N_KEY_BODY
The e-mail body i18n key.- See Also:
- Constant Field Values
-
_userManager
protected UserManager _userManager
The users manager.
-
_rightManager
protected RightManager _rightManager
The rights manager.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_pluginName
protected String _pluginName
The plugin name.
-
-
Constructor Detail
-
TranslationAlertFunction
public TranslationAlertFunction()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
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
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- 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
protected void sendAlerts(WebContent content)
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
protected void sendMails(String subject, String body, Set<UserIdentity> users, String from)
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
protected HashSet<UserIdentity> getUsersToNotify(Page translatedPage)
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
protected Map<String,Page> getTranslations(Page page)
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
protected String getPageUrl(Page page)
Get the URL of the back-office, opening on the page tool.- Parameters:
page- the page to open on.- Returns:
- the page URL.
-
-