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.
      • 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()