001/*
002 *  Copyright 2015 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.web.indexing;
017
018import org.apache.solr.client.solrj.SolrClient;
019
020import org.ametys.cms.indexing.IndexingException;
021import org.ametys.core.schedule.progression.ContainerProgressionTracker;
022import org.ametys.web.repository.site.Site;
023import org.ametys.web.repository.sitemap.Sitemap;
024
025/**
026 * Component indexing a {@link Site}.
027 */
028public interface SiteIndexer
029{
030    
031    /** The component role. */
032    public static final String ROLE = SiteIndexer.class.getName();
033    
034    /**
035     * Index a site in all workspaces
036     * @param site the site to index.
037     * @throws IndexingException If an error occurs while indexing the site.
038     */
039    void indexSite(Site site) throws IndexingException;
040    
041    /**
042     * Index a site in a specific workspace.
043     * @param site the site to index.
044     * @param progressionTracker The progression of the indexation
045     * @throws IndexingException If an error occurs while indexing the site.
046     */
047    void indexSite(Site site, ContainerProgressionTracker progressionTracker) throws IndexingException;
048    
049    /**
050     * Index a site in all workspaces
051     * @param siteName  the name of the site to index.
052     * @throws IndexingException If an error occurs while indexing the site.
053     */
054    void indexSite(String siteName) throws IndexingException;
055    
056    /**
057     * Index a site in a specific workspace.
058     * @param siteName the name of the site to index.
059     * @param workspaceName The workspace name.
060     * @throws IndexingException If an error occurs while indexing the site.
061     */
062    void indexSite(String siteName, String workspaceName) throws IndexingException;
063
064    /**
065     * Index a site in a specific workspace.
066     * @param siteName the name of the site to index.
067     * @param workspaceName The workspace name.
068     * @param progressionTracker A progression tracker
069     * @throws IndexingException If an error occurs while indexing the site.
070     */
071    void indexSite(String siteName, String workspaceName, ContainerProgressionTracker progressionTracker) throws IndexingException;
072    
073    /**
074     * Index a site in a specific workspace.
075     * @param siteName the name of the site to index.
076     * @param workspaceName The workspace name.
077     * @param solrClient The solr client to use
078     * @param progressionTracker The progression of the indexation
079     * @throws IndexingException If an error occurs while indexing the site.
080     */
081    void indexSite(String siteName, String workspaceName, SolrClient solrClient, ContainerProgressionTracker progressionTracker) throws IndexingException;
082    
083    /**
084     * Index a sitemap in all workpaces
085     * @param sitemap the sitemap to index.
086     * @throws IndexingException If an error occurs while indexing the sitemap.
087     */
088    void indexSitemap(Sitemap sitemap) throws IndexingException;
089    
090    /**
091     * Index a sitemap in all workpaces
092     * @param siteName the site name.
093     * @param sitemapName the name of the sitemap to index.
094     * @throws IndexingException If an error occurs while indexing the sitemap.
095     */
096    void indexSitemap(String siteName, String sitemapName) throws IndexingException;
097    
098    /**
099     * Index a sitemap in a specific workspace.
100     * @param siteName the site name.
101     * @param sitemapName the name of the sitemap to index.
102     * @param workspaceName The workspace name.
103     * @throws IndexingException If an error occurs while indexing the sitemap.
104     */
105    void indexSitemap(String siteName, String sitemapName, String workspaceName) throws IndexingException;
106    
107    /**
108     * Unindex a site in a specific workspace.
109     * @param siteName the name of site to unindex.
110     * @param workspaceName The workspace name.
111     * @throws IndexingException If an error occurs while unindexing the site.
112     */
113    void unindexSite(String siteName, String workspaceName) throws IndexingException;
114    
115    /**
116     * Unindex a site in all workspaces
117     * @param siteName the name of site to unindex.
118     * @throws IndexingException If an error occurs while unindexing the site.
119     */
120    void unindexSite(String siteName) throws IndexingException;
121    
122    /**
123     * Unindex a sitemap in all workpaces
124     * @param siteName the site name.
125     * @param sitemapName the name of the sitemap to index.
126     * @throws IndexingException If an error occurs while unindexing the sitemap.
127     */
128    void unindexSitemap(String siteName, String sitemapName) throws IndexingException;
129    
130    /**
131     * Unindex a sitemap in a specific workspace.
132     * @param siteName the site name.
133     * @param sitemapName the name of the sitemap to index.
134     * @param workspaceName The workspace name.
135     * @throws IndexingException If an error occurs while unindexing the sitemap.
136     */
137    void unindexSitemap(String siteName, String sitemapName, String workspaceName) throws IndexingException;
138}