Class AbstractSendNotificationObserver

    • Method Detail

      • 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
      • getPriority

        public int getPriority​(Event event)
        Description copied from interface: Observer
        Retrieves the priority to observe this event.
        This can be used to process a supported event before others observers.
        Specified by:
        getPriority in interface Observer
        Parameters:
        event - the event.
        Returns:
        the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
      • observe

        public void observe​(Event event,
                            Map<String,​Object> transientVars)
        Description copied from interface: Observer
        Observes an event.
        Specified by:
        observe in interface Observer
        Parameters:
        event - the event.
        transientVars - transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.
      • notifyEvent

        protected abstract void notifyEvent​(Project project,
                                            String eventId,
                                            Map<String,​Object> eventParams,
                                            User issuer)
        Notify email by mail
        Parameters:
        project - The project
        eventId - The id of event
        eventParams - The event's arguments
        issuer - The issuer
      • getProject

        protected Project getProject​(Event event)
        Get the project from event
        Parameters:
        event - The event
        Returns:
        the project or null if not found
      • getMailCommonParams

        protected List<StringgetMailCommonParams​(Project project,
                                                   User issuer,
                                                   String explorerNodeId)
        Get the common mail parameters
        Parameters:
        project - The parent project
        issuer - The user responsible of the action
        explorerNodeId - the id of the explorer node. Can be null.
        Returns:
        an array of strings used in every mail
      • getDefaultLanguage

        protected String getDefaultLanguage()
        Get the default language to resolve module's page
        Returns:
        The default language
      • getModulePage

        protected Page getModulePage​(Project project,
                                     String moduleId)
        Get the module's page
        Parameters:
        project - The project
        moduleId - The module
        Returns:
        The page or null if not found
      • getModuleUrl

        protected String getModuleUrl​(Project project,
                                      String moduleId,
                                      String objectId)
        Get the absolute full url of module'page
        Parameters:
        project - The project
        moduleId - The module. Can not be null
        objectId - The id of concerned object. Can be null.
        Returns:
        The
      • getProjectUrl

        protected String getProjectUrl​(Project project)
        Get the absolute url of project
        Parameters:
        project - The project
        Returns:
        the project's url
      • getUrl

        protected abstract String getUrl​(Project project,
                                         String objectId)
        Get the URL of project to insert in email body
        Parameters:
        project - The project
        objectId - The id of concerned object
        Returns:
        The full URL
      • sendMail

        protected void sendMail​(String eventId,
                                List<UserIdentity> recipients,
                                String mailBodyi18nKey,
                                String mailSubjecti18nKey,
                                List<String> mailBodyParams,
                                List<String> mailSubjectParams)
        Sent an email
        Parameters:
        eventId - The id of event
        recipients - The recipients of the mail
        mailBodyi18nKey - i18n key for the body
        mailSubjecti18nKey - i18n key for the subject
        mailBodyParams - parameters for the body
        mailSubjectParams - parameters for the subject
      • getUsersToNotify

        protected List<UserIdentitygetUsersToNotify​(String eventId,
                                                      AmetysObject object)
        Get the users allowed to be notified
        Parameters:
        eventId - The id of event
        object - The object on which to test rights
        Returns:
        The allowed users
      • getRightIdForNotify

        protected abstract String getRightIdForNotify()
        Get the right to check allowed users to notify by mail
        Returns:
        the right id to check
      • _getPath

        protected String _getPath​(String rootPath,
                                  String path)
        format the path without the root path
        Parameters:
        rootPath - The root path to remove
        path - The absolute path
        Returns:
        the local path