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;
031
032import java.io.IOException;
033
034/**
035 * Abstracts the index writer implementation for the most important index manipulation operations.
036 *
037 * @since 8.0.2
038 */
039public interface I_CmsIndexWriter {
040
041    /**
042     * Close this IndexWriter.<p>
043     *
044     * @throws IOException thrown if the close action fails.
045     */
046    void close() throws IOException;
047
048    /**
049     * Commit all previous operations.<p>
050     *
051     * @throws IOException thrown if the commit action fails.
052     */
053    void commit() throws IOException;
054
055    /**
056     * Delete a document from the index.<p>
057     *
058     * @param resource the resource to delete
059     *
060     * @throws IOException in case something goes wrong
061     */
062    void deleteDocument(CmsPublishedResource resource) throws IOException;
063
064    /**
065     * Optimizes the index.<p>
066     *
067     * Please note that as of Lucene 3.5, the direct use of optimize is discouraged
068     * as Lucene apparently is now able to manage the file structure so efficiently that
069     * frequent optimizations are not longer required.<p>
070     *
071     * @throws IOException thrown if the optimization fails.
072     */
073    void optimize() throws IOException;
074
075    /**
076     * Update a document in the index.<p>
077     *
078     * @param rootPath the root path of the document to update
079     * @param document the document to update
080     *
081     * @throws IOException in case something goes wrong
082     */
083    void updateDocument(String rootPath, I_CmsSearchDocument document) throws IOException;
084}