Class CmsUserDataRequestManager


  • public class CmsUserDataRequestManager
    extends java.lang.Object
    Manager class for user data requests.

    Users can request their data either via username/password, in which case the user data will be collected for that user, or by email, in which case the data for all users with the given email address is collected.

    User data is formatted as HTML by one or more configurable 'user data domain' classes, which implement the I_CmsUserDataDomain interface.

    After the user requests their data, they are sent an email with a link (which is only valid for a certain time). When opening that link, they have to confirm the credentials they requested the data with, and if they successfully do so, are shown a page with their user data.

    • Method Detail

      • addDigesterRules

        public static void addDigesterRules​(org.apache.commons.digester3.Digester digester,
                                            java.lang.String basePath)
        Adds digester rules for configuration.
        Parameters:
        digester - the digester
        basePath - the base xpath for the configuration of user data requests
      • getUsersByEmail

        public static java.util.List<CmsUsergetUsersByEmail​(CmsObject cms,
                                                              java.lang.String email)
                                                       throws CmsException
        Gets all users with a given email address (maximum of 999).
        Parameters:
        cms - the CMS context
        email - the email address
        Returns:
        the list of users
        Throws:
        CmsException - if something goes wrong
      • addUserDataDomain

        public void addUserDataDomain​(I_CmsUserDataDomain domain)
        Adds a user data domain during configuration phase.
        Parameters:
        domain - the user data domain to add
      • appendToXml

        public void appendToXml​(org.dom4j.Element element)
        Writes the configuration back to XML.
        Parameters:
        element - the parent element
      • checkNotInitialized

        public void checkNotInitialized()
        Checks that the manager has not already been initialized, and throws an exception otherwise.
      • getAllDomains

        public java.util.List<I_CmsUserDataDomaingetAllDomains()
        Gets the list of all user data domains, both those from the configuration and those loaded via service loader.
        Returns:
        the list of all user data domains
      • getInfoForEmail

        public boolean getInfoForEmail​(CmsObject cms,
                                       I_CmsUserDataDomain.Mode mode,
                                       java.lang.String email,
                                       java.util.List<java.lang.String> searchStrings,
                                       org.jsoup.nodes.Element root,
                                       I_CmsReport report)
                                throws CmsException
        Gets the user data for an email address.

        Only callable by root admin users.

        Parameters:
        cms - the CMS context
        mode - the mode
        email - the email address (may be null)
        searchStrings - a list of additional search strings entered by the user
        root - the root element to which the report should be added
        report - the report to write to
        Returns:
        true if the HTML document was changed as a result of executing this method
        Throws:
        CmsException - if something goes wrong
      • getInfoForUser

        public boolean getInfoForUser​(CmsObject cms,
                                      I_CmsUserDataDomain.Mode mode,
                                      CmsUser user,
                                      org.jsoup.nodes.Element root,
                                      I_CmsReport report)
                               throws CmsException
        Gets the user data for a specific OpenCms user.

        Only callable by root admin users.

        Parameters:
        cms - the CMS context
        mode - the mode
        user - the OpenCms user
        root - the root element to which the report should be added
        report - the report to write to
        Returns:
        true if the HTML document was changed as a result of executing this method
        Throws:
        CmsException - if something goes wrong
      • initialize

        public void initialize​(CmsObject cms)
        Initializes the manager.
        Parameters:
        cms - a CMS context with admin privileges
      • loadConfig

        public java.util.Optional<CmsUserDataRequestConfigloadConfig​(CmsObject cms,
                                                                       java.lang.String path)
        Loads the user data request configuration from the given file.

        Returns null if no configuration is found.

        Parameters:
        cms - the CMS context
        path - the site path of the configuration
        Returns:
        the configuration for the given path
      • startUserDataRequest

        public void startUserDataRequest​(CmsObject cms,
                                         CmsUserDataRequestConfig config,
                                         CmsUser user)
                                  throws javax.mail.internet.AddressException,
                                         org.apache.commons.mail.EmailException
        Starts a user data request for the single user case (with user name and password).

        Parameters:
        cms - the CMS context
        config - the configuration
        user - the user for which the data was requested
        Throws:
        javax.mail.internet.AddressException - if parsing the email address fails
        org.apache.commons.mail.EmailException - if sending the email fails
      • startUserDataRequest

        public void startUserDataRequest​(CmsObject cms,
                                         CmsUserDataRequestConfig config,
                                         java.lang.String email)
                                  throws CmsUserDataRequestException,
                                         org.apache.commons.mail.EmailException,
                                         javax.mail.internet.AddressException
        Starts a user data request for the email case.
        Parameters:
        cms - the CMS context
        config - the user data request configuration
        email - the email address
        Throws:
        CmsUserDataRequestException - if something goes wrong
        org.apache.commons.mail.EmailException - if sending the email fails
        javax.mail.internet.AddressException - if parsing the email address fails
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • setAutoload

        protected void setAutoload​(boolean autoload)
        Sets the autoload flag, which enables automatic loading of plugins via service loader.
        Parameters:
        autoload - the value of the autoload flag