001/* 002 * Copyright 2018 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 java.io.IOException; 019import java.util.Optional; 020 021import org.apache.solr.client.solrj.SolrClient; 022import org.apache.solr.client.solrj.SolrServerException; 023import org.apache.solr.client.solrj.response.UpdateResponse; 024import org.slf4j.Logger; 025 026/** 027 * Default update {@link SolrClient} which uses the Solr default Update Request Processor chain 028 */ 029public class DefaultUpdateClient extends AbstractAmetysConcurrentUpdateClient 030{ 031 /** 032 * Constructor 033 * @param solrServerUrl The Solr server URL 034 * @param login The login to authenticate on the Solr app 035 * @param password The password to authenticate on the Solr app 036 * @param solrSocketTimeout The Solr socket timeout (in millis) 037 * @param collectionName The name of the collection, on which operations will be allowed. Operations on other collections will be forbidden. 038 * @param queueSize The buffer size before the documents are sent to the server 039 * @param threadCount The number of background threads used to empty the queue 040 * @param logger internal logger 041 */ 042 public DefaultUpdateClient(String solrServerUrl, String login, String password, Optional<Integer> solrSocketTimeout, String collectionName, int queueSize, int threadCount, Logger logger) 043 { 044 super(solrServerUrl, login, password, solrSocketTimeout, collectionName, queueSize, threadCount, logger); 045 } 046 047 @Override 048 public UpdateResponse commit() throws SolrServerException, IOException 049 { 050 throw new CommitNotAllowedException(); 051 } 052 053 @Override 054 public UpdateResponse commit(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException 055 { 056 throw new CommitNotAllowedException(); 057 } 058 059 @Override 060 public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean softCommit) throws SolrServerException, IOException 061 { 062 throw new CommitNotAllowedException(); 063 } 064 065 @Override 066 public UpdateResponse commit(String collection) throws SolrServerException, IOException 067 { 068 throw new CommitNotAllowedException(); 069 } 070 071 @Override 072 public UpdateResponse commit(String collection, boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException 073 { 074 throw new CommitNotAllowedException(); 075 } 076 077 @Override 078 public UpdateResponse commit(String collection, boolean waitFlush, boolean waitSearcher, boolean softCommit) throws SolrServerException, IOException 079 { 080 throw new CommitNotAllowedException(); 081 } 082 083 static class CommitNotAllowedException extends RuntimeException 084 { 085 CommitNotAllowedException() 086 { 087 super("Commit is not allowed with the default update client."); 088 } 089 } 090}