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 GmbH & Co. KG, 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.search;
029
030import org.opencms.db.CmsPublishedResource;
031import org.opencms.file.CmsObject;
032import org.opencms.report.I_CmsReport;
033
034import java.util.List;
035
036/**
037 * Indexes resources for the OpenCms search.<p>
038 *
039 * This is a high level interface that abstracts the index generation process from the search index itself.
040 * Implement this in case special handling of the index generation process is required.<p>
041 *
042 * @since 6.0.0
043 */
044public interface I_CmsIndexer {
045
046    /**
047     * Incremental index update - delete the index entry for all resources in the given list.<p>
048     *
049     * @param indexWriter the writer to the index to delete the entries from
050     * @param resourcesToDelete a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be deleted
051     *
052     * @throws CmsIndexException if something goes wrong
053     */
054    void deleteResources(I_CmsIndexWriter indexWriter, List<CmsPublishedResource> resourcesToDelete)
055    throws CmsIndexException;
056
057    /**
058     * Calculates the data for an incremental search index update.<p>
059     *
060     * @param source the search index source to update
061     * @param publishedResources a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> objects that are to be updated
062     *
063     * @return a container with the information about the resources to delete and / or update
064     *
065     * @throws CmsIndexException if something goes wrong
066     */
067    CmsSearchIndexUpdateData getUpdateData(CmsSearchIndexSource source, List<CmsPublishedResource> publishedResources)
068    throws CmsIndexException;
069
070    /**
071     * Returns <code>true</code> if this VFS indexer is able to resolve locale dependencies between documents.<p>
072     *
073     * @return <code>true</code> if this VFS indexer is able to resolve locale dependencies between documents
074     */
075    boolean isLocaleDependenciesEnable();
076
077    /**
078     * Creates and initializes a new instance of this indexer implementation.<p>
079     *
080     * @param cms the OpenCms user context to use when reading resources from the VFS during indexing
081     * @param report the report to write the indexing output to
082     * @param index the search index to update
083     *
084     * @return a new instance of this indexer implementation
085     */
086    I_CmsIndexer newInstance(CmsObject cms, I_CmsReport report, I_CmsSearchIndex index);
087
088    /**
089     * Rebuilds the index for the given configured index source.<p>
090     *
091     * This is used when the index is fully rebuild, not for updating only some parts
092     * of an existing index.<p>
093     *
094     * @param writer the index writer to write the update to
095     * @param source the search index source to update
096     * @param threadManager the thread manager to use when extracting the document text
097     *
098     * @throws CmsIndexException if something goes wrong
099     */
100    void rebuildIndex(I_CmsIndexWriter writer, CmsIndexingThreadManager threadManager, CmsSearchIndexSource source)
101    throws CmsIndexException;
102
103    /**
104     * Incremental index update - create a new index entry for all resources in the given list.<p>
105     *
106     * @param writer the index writer to write the update to
107     * @param resourcesToUpdate a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be updated
108     * @param threadManager the thread manager to use when extracting the document text
109     *
110     * @throws CmsIndexException if something goes wrong
111     */
112    void updateResources(
113        I_CmsIndexWriter writer,
114        CmsIndexingThreadManager threadManager,
115        List<CmsPublishedResource> resourcesToUpdate)
116    throws CmsIndexException;
117}