001/* 002 * Copyright 2017 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.indexing.solr; 017 018import java.io.IOException; 019import java.util.Collection; 020 021import org.apache.solr.client.solrj.SolrClient; 022import org.apache.solr.client.solrj.SolrRequest; 023import org.apache.solr.client.solrj.response.SolrResponseBase; 024import org.apache.solr.common.params.ModifiableSolrParams; 025import org.apache.solr.common.params.SolrParams; 026import org.apache.solr.common.util.ContentStream; 027 028/** 029 * {@link SolrRequest} to reload the ACL Solr cache 030 */ 031public class ReloadAclCacheRequest extends SolrRequest<SolrResponseBase> 032{ 033 /** If true, only the segments which are not already in cache are computed */ 034 protected boolean _checkIfNecessary; 035 036 /** 037 * Default constructor 038 */ 039 public ReloadAclCacheRequest() 040 { 041 this(false); 042 } 043 044 /** 045 * Default constructor 046 * @param checkIfNecessary true to check if the reload is necessary for each segment (i.e. reload only the segments not already in cache) 047 */ 048 public ReloadAclCacheRequest(boolean checkIfNecessary) 049 { 050 super(METHOD.GET, "/reloadAclCache"); 051 _checkIfNecessary = checkIfNecessary; 052 } 053 054 @Override 055 public SolrParams getParams() 056 { 057 ModifiableSolrParams params = new ModifiableSolrParams(); 058 params.add("checkIfNecessary", String.valueOf(_checkIfNecessary)); 059 return params; 060 } 061 062 @Override 063 public Collection<ContentStream> getContentStreams() throws IOException 064 { 065 return null; 066 } 067 068 @Override 069 protected SolrResponseBase createResponse(SolrClient client) 070 { 071 return new SolrResponseBase(); 072 } 073 074 @Override 075 public String getRequestType() 076 { 077 return SolrRequestType.ADMIN.toString(); 078 } 079}