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.cms.search.solr; 017 018import org.apache.solr.client.solrj.SolrClient; 019 020/** 021 * Component acting as a single entry point to get access to Solr clients. 022 */ 023public interface SolrClientProvider 024{ 025 026 /** The component role. */ 027 public static final String ROLE = SolrClientProvider.class.getName(); 028 029 /** 030 * Get the "read" mode solr client. 031 * @return the "read" mode solr client. 032 */ 033 SolrClient getReadClient(); 034 035 /** 036 * Get a (default) Solr client suited to update. 037 * @param workspaceName The name of the workspace 038 * @return a Solr client suited to update. 039 */ 040 default SolrClient getUpdateClient(String workspaceName) 041 { 042 return getUpdateClient(workspaceName, true); 043 } 044 045 /** 046 * Get a Solr client suited to update. 047 * <br>You must call this method with <code>false</code> value for argument `autocommit` so as to get a client that will not trigger any autocommit on Solr side. 048 * <br>Otherwise, calling this method with <code>true</code> value for argument `autocommit` is equivalent to calling {@link #getUpdateClient(String)} 049 * @param workspaceName The name of the workspace 050 * @param autoCommit <code>false</code> so as to get a client that will not trigger any autocommit on Solr side. 051 * @return a Solr client suited to update. 052 */ 053 SolrClient getUpdateClient(String workspaceName, boolean autoCommit); 054 055 /** 056 * Get the name of the collection to use. 057 * @return The name of the collection to search in. 058 */ 059 String getCollectionName(); 060 061 /** 062 * Get the collection to use. 063 * @param workspaceName The workspace name. 064 * @return The name of the collection to search in. 065 */ 066 String getCollectionName(String workspaceName); 067}