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.search.controller;
029
030import org.opencms.file.CmsObject;
031import org.opencms.search.solr.CmsSolrQuery;
032
033import java.util.Arrays;
034import java.util.List;
035import java.util.Map;
036
037/** Interface all search controllers must implement. It consists of methods for query generation and state updates. */
038public interface I_CmsSearchController {
039
040    /** Solr query params that can have only one value. */
041    List<String> SET_VARIABLES = Arrays.asList(new String[] {"q", "rows", "start", "sort", "fl"});
042
043    /** Add the request parameters that reflect the controllers current state (useful for link generation outside of a form).
044     * @param parameters The request parameters reflecting the controllers currents state.
045     */
046    void addParametersForCurrentState(Map<String, String[]> parameters);
047
048    /** Generate the Solr query part specific for the controller, e.g., the part for a field facet.
049     *
050     * @param query A, possibly empty, query, where further query parts are added
051     *
052     * @deprecated use {@link #addQueryParts(CmsSolrQuery, CmsObject)} instead.
053     */
054    @Deprecated
055    default void addQueryParts(CmsSolrQuery query) {
056
057        addQueryParts(query, null);
058    }
059
060    /** Generate the Solr query part specific for the controller, e.g., the part for a field facet.
061     * @param query A, possibly empty, query, where further query parts are added
062     * @param cms the current context to resolve context-specific macros.
063     */
064    void addQueryParts(CmsSolrQuery query, CmsObject cms);
065
066    /** Update the controllers state in case the term that is search for (the query as given by the user) has changed. */
067    void updateForQueryChange();
068
069    /** Update the controllers state from the given request parameters.
070     * @param parameters The request parameters.
071     * @param isRepeated a flag, indicating, if the search is performed repeatedly, opposed to entering the search page for the first time. */
072    void updateFromRequestParameters(final Map<String, String[]> parameters, final boolean isRepeated);
073}