001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.userdata;
029
030import org.opencms.configuration.I_CmsConfigurationParameterHandler;
031import org.opencms.file.CmsObject;
032import org.opencms.file.CmsUser;
033
034import java.util.List;
035
036import org.jsoup.nodes.Element;
037
038/**
039 * Interface for user data domains.<p>
040 *
041 * A user data domain can provide information about users which have requested their user data.
042 * Several user data domains can be configured in opencms-system.xml. When requesting information,
043 * there are two types of scenarios:
044 *
045 * <ul>
046 * <li>The user requests data with his email address.
047 * <li>The user requests data with his user name and password.
048 * </ul>
049 *
050 * In the first case, more than one user can match the email address, in the second case at most one user is found.
051 * For each of the users, they will be matched against each of the user data domains (a user can match more than one domain).
052 * Then the domain produces the user data for the list of matching users by appending it to an HTML document.
053 */
054public interface I_CmsUserDataDomain extends I_CmsConfigurationParameterHandler {
055
056    /**
057     * Describes the different places from which the user data domain plugins can be used.
058     */
059    enum Mode {
060        /** The frontend-based way to query user data. */
061        frontend,
062
063        /** The workplace-based way to query user data. */
064        workplace;
065    }
066
067    /**
068     * Appends the user data to the given HTML element.
069     *
070     * @param cms the CMS context
071     * @param reqType the request type (email or single user)
072     * @param user the list of users (if the request type is singleUser, this has only one element)
073     * @param element the HTML element to append the data to
074     */
075    void appendInfoHtml(CmsObject cms, CmsUserDataRequestType reqType, List<CmsUser> user, Element element);
076
077    /**
078     * Writes additional information related to an email address which is not directly associated with a specific OpenCms user.
079     *
080     * @param cms the CMS context
081     * @param email the email address to check
082     * @param searchStrings additional search strings entered by the user
083     * @param element the element which the additional information should be appended to
084     *
085     */
086    default void appendlInfoForEmail(CmsObject cms, String email, List<String> searchStrings, Element element) {
087
088        // do nothing
089    }
090
091    /**
092     * Initializes the domain with an admin CmsObject.
093     *
094     * @param cms a CmsObject
095     */
096    void initialize(CmsObject cms);
097
098    /**
099     * Checks if the plugin is available in the given mode.
100     *
101     * @param mode the mode
102     *
103     * @return true if the plugin is available
104     */
105    default boolean isAvailableForMode(Mode mode) {
106
107        return true;
108    }
109
110    /**
111     * Checks if the user matches the domain for the given user data request type.
112     *
113     * @param cms the CMS context
114     * @param reqType the user data request type (email or single user)
115     * @param user the user
116     *
117     * @return true if the domain matches the user
118     */
119    boolean matchesUser(CmsObject cms, CmsUserDataRequestType reqType, CmsUser user);
120
121}