diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8331b141de5..c61f84f91d8 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -346,6 +346,9 @@ Bug Fixes Other Changes ---------------------- +* SOLR-2750: Make both "update.chain" and the deprecated "update.param" work + consistently everywhere; see also SOLR-2105. (Mark Miller, janhoy) + * LUCENE-3410: Deprecated the WordDelimiterFilter constructors accepting multiple ints masquerading as booleans. Preferred constructor now accepts a single int bitfield (Chris Male) diff --git a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImportHandler.java b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImportHandler.java index fd04012a978..8b01ace965a 100644 --- a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImportHandler.java +++ b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/DataImportHandler.java @@ -22,7 +22,6 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.ContentStream; @@ -39,6 +38,7 @@ import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.update.processor.UpdateRequestProcessor; import org.apache.solr.update.processor.UpdateRequestProcessorChain; +import org.apache.solr.util.SolrPluginUtils; import org.apache.solr.util.plugin.SolrCoreAware; import java.util.*; @@ -191,7 +191,7 @@ public class DataImportHandler extends RequestHandlerBase implements IMPORT_CMD.equals(command)) { UpdateRequestProcessorChain processorChain = - req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN)); + req.getCore().getUpdateProcessingChain(SolrPluginUtils.resolveUpdateChainParam(params, LOG)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); SolrResourceLoader loader = req.getCore().getResourceLoader(); SolrWriter sw = getSolrWriter(processor, loader, requestParams, req); diff --git a/solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java index ac360f70bba..c431b45368b 100644 --- a/solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java +++ b/solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java @@ -18,12 +18,12 @@ package org.apache.solr.handler; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.processor.UpdateRequestProcessor; import org.apache.solr.update.processor.UpdateRequestProcessorChain; +import org.apache.solr.util.SolrPluginUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,17 +38,8 @@ public abstract class ContentStreamHandlerBase extends RequestHandlerBase { @Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); - String updateChainName = null; - if(params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED) != null) { - log.warn("Use of deprecated update request parameter "+UpdateParams.UPDATE_CHAIN_DEPRECATED+ - " detected. Please use the new parameter "+UpdateParams.UPDATE_CHAIN+" instead, as support"+ - " for "+UpdateParams.UPDATE_CHAIN_DEPRECATED+" will be removed in a later version."); - updateChainName = params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED); - } else { - updateChainName = params.get(UpdateParams.UPDATE_CHAIN); - } UpdateRequestProcessorChain processorChain = - req.getCore().getUpdateProcessingChain(updateChainName); + req.getCore().getUpdateProcessingChain(SolrPluginUtils.resolveUpdateChainParam(params, log)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java index 211f6968e99..d345e193c27 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java @@ -37,6 +37,7 @@ import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.search.SolrIndexSearcher; import org.apache.solr.util.NumberUtils; import org.apache.solr.util.RefCounted; +import org.apache.solr.util.SolrPluginUtils; import org.apache.solr.update.MergeIndexesCommand; import org.apache.solr.update.processor.UpdateRequestProcessor; import org.apache.solr.update.processor.UpdateRequestProcessorChain; @@ -231,7 +232,7 @@ public class CoreAdminHandler extends RequestHandlerBase { } UpdateRequestProcessorChain processorChain = - core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN)); + core.getUpdateProcessingChain(SolrPluginUtils.resolveUpdateChainParam(params, log)); wrappedReq = new LocalSolrQueryRequest(core, req.getParams()); UpdateRequestProcessor processor = processorChain.createProcessor(wrappedReq, rsp); diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java index 0201e9e79af..8af5fd30931 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java +++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java @@ -29,6 +29,7 @@ import org.apache.solr.common.params.AppendedSolrParams; import org.apache.solr.common.params.DefaultSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.UpdateParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.StrUtils; @@ -42,6 +43,8 @@ import org.apache.solr.schema.IndexSchema; import org.apache.solr.schema.SchemaField; import org.apache.solr.search.*; import org.apache.solr.update.DocumentBuilder; +import org.slf4j.Logger; + import java.io.IOException; import java.util.*; import java.util.regex.Pattern; @@ -856,6 +859,28 @@ public class SolrPluginUtils { } } } + + + /** + * This method helps resolve if the deprecated "update.processor" request parameter is used + * and logs a warning if it is. In a future version, this method will be removed and + * Solr will assume "update.chain" and not look for "update.processor" + * @param params an instance of SolrParams from the request + * @param log an instance of a slf4j logger to log a warning in case of deprecated param usage + * @return null if neither is specified, else the value of the param specified + * @deprecated + */ + public static String resolveUpdateChainParam(SolrParams params, Logger log) { + if(params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED) != null && log != null) { + log.warn("Use of deprecated update request parameter "+UpdateParams.UPDATE_CHAIN_DEPRECATED+ + " detected. Please use the new parameter "+UpdateParams.UPDATE_CHAIN+" instead, as support"+ + " for "+UpdateParams.UPDATE_CHAIN_DEPRECATED+" will be removed in a later version."); + } + return (params.get(UpdateParams.UPDATE_CHAIN) != null) + ? params.get(UpdateParams.UPDATE_CHAIN) + : params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED); + } + }