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 update the value of a core property
030 */
031public class UpdateCorePropertyRequest extends SolrRequest<SolrResponseBase>
032{
033    private String _key;
034    private String _value;
035
036    /**
037     * Default constructor
038     * @param key The property key to update
039     * @param value The new value to set
040     */
041    public UpdateCorePropertyRequest(String key, String value)
042    {
043        super(METHOD.GET, "/updateCoreProperty");
044        _key = key;
045        _value = value;
046    }
047    
048    @Override
049    public SolrParams getParams()
050    {
051        ModifiableSolrParams params = new ModifiableSolrParams();
052        params.add("key", _key);
053        params.add("value", _value);
054        return params;
055    }
056
057    @Override
058    public Collection<ContentStream> getContentStreams() throws IOException
059    {
060        return null;
061    }
062
063    @Override
064    protected SolrResponseBase createResponse(SolrClient client)
065    {
066        return new SolrResponseBase();
067    }
068}