Class 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 Details

  • Constructor Details

  • Method Details

    • setPluginInfo

      public void setPluginInfo(String pluginName, String featureName, String id)
      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 interface PluginAware
      Parameters:
      pluginName - Unique identifier for the plugin hosting the extension
      featureName - Unique feature identifier (unique for a given pluginName)
      id - Unique identifier of this component
    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • service

      public void service(ServiceManager serviceManager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Overrides:
      service in class AbstractContentWorkflowComponent
      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 interface com.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.