From 4f98807406ae99c2b58f74e219de35a1d83c9a89 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 8 Jun 2011 19:54:47 +0000 Subject: [PATCH] SOLR-2444: Change Map to SolrParams git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1133534 13f79535-47bb-0310-9956-ffa450edef68 --- .../response/transform/DocIdAugmenterFactory.java | 11 ++--------- .../response/transform/ExplainAugmenterFactory.java | 6 +++--- .../response/transform/ShardAugmenterFactory.java | 5 ++--- .../solr/response/transform/TransformerFactory.java | 3 ++- .../response/transform/ValueAugmenterFactory.java | 9 ++++----- .../src/java/org/apache/solr/search/ReturnFields.java | 3 ++- 6 files changed, 15 insertions(+), 22 deletions(-) diff --git a/solr/src/java/org/apache/solr/response/transform/DocIdAugmenterFactory.java b/solr/src/java/org/apache/solr/response/transform/DocIdAugmenterFactory.java index b7ddda8786e..c4e19a1d171 100644 --- a/solr/src/java/org/apache/solr/response/transform/DocIdAugmenterFactory.java +++ b/solr/src/java/org/apache/solr/response/transform/DocIdAugmenterFactory.java @@ -16,11 +16,8 @@ */ package org.apache.solr.response.transform; -import java.util.Map; - import org.apache.solr.common.SolrDocument; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.SolrException.ErrorCode; +import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; /** @@ -30,11 +27,7 @@ import org.apache.solr.request.SolrQueryRequest; public class DocIdAugmenterFactory extends TransformerFactory { @Override - public DocTransformer create(String field, Map args, SolrQueryRequest req) { - if( !args.isEmpty() ) { - throw new SolrException( ErrorCode.BAD_REQUEST, - "DocIdAugmenter does not take any arguments" ); - } + public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) { return new DocIdAugmenter( field ); } } diff --git a/solr/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java b/solr/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java index 094409c3a03..a65b0daed69 100644 --- a/solr/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java +++ b/solr/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java @@ -17,12 +17,12 @@ package org.apache.solr.response.transform; import java.io.IOException; -import java.util.Map; import org.apache.lucene.search.Explanation; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; +import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.util.SolrPluginUtils; @@ -64,8 +64,8 @@ public class ExplainAugmenterFactory extends TransformerFactory } @Override - public DocTransformer create(String field, Map args, SolrQueryRequest req) { - String s = args.get("style"); + public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) { + String s = params.get("style"); Style style = (s==null)?defaultStyle:getStyle(s); return new ExplainAugmenter( field, style ); } diff --git a/solr/src/java/org/apache/solr/response/transform/ShardAugmenterFactory.java b/solr/src/java/org/apache/solr/response/transform/ShardAugmenterFactory.java index 4862a62c81b..670bbbea158 100644 --- a/solr/src/java/org/apache/solr/response/transform/ShardAugmenterFactory.java +++ b/solr/src/java/org/apache/solr/response/transform/ShardAugmenterFactory.java @@ -16,9 +16,8 @@ */ package org.apache.solr.response.transform; -import java.util.Map; - import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.SolrParams; import org.apache.solr.request.SolrQueryRequest; @@ -29,7 +28,7 @@ import org.apache.solr.request.SolrQueryRequest; public class ShardAugmenterFactory extends TransformerFactory { @Override - public DocTransformer create(String field, Map args, SolrQueryRequest req) { + public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) { String v = req.getParams().get(ShardParams.SHARD_URL); if( v == null ) { if( req.getParams().getBool(ShardParams.IS_SHARD, false) ) { diff --git a/solr/src/java/org/apache/solr/response/transform/TransformerFactory.java b/solr/src/java/org/apache/solr/response/transform/TransformerFactory.java index 5ba89389176..832d009ceb7 100644 --- a/solr/src/java/org/apache/solr/response/transform/TransformerFactory.java +++ b/solr/src/java/org/apache/solr/response/transform/TransformerFactory.java @@ -20,6 +20,7 @@ package org.apache.solr.response.transform; import java.util.HashMap; import java.util.Map; +import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.util.plugin.NamedListInitializedPlugin; @@ -37,7 +38,7 @@ public abstract class TransformerFactory implements NamedListInitializedPlugin defaultUserArgs = (String)args.get( "args" ); } - public abstract DocTransformer create(String field, Map args, SolrQueryRequest req); + public abstract DocTransformer create(String field, SolrParams params, SolrQueryRequest req); public static final Map defaultFactories = new HashMap(); static { diff --git a/solr/src/java/org/apache/solr/response/transform/ValueAugmenterFactory.java b/solr/src/java/org/apache/solr/response/transform/ValueAugmenterFactory.java index a12145f9eef..f319f71d4da 100644 --- a/solr/src/java/org/apache/solr/response/transform/ValueAugmenterFactory.java +++ b/solr/src/java/org/apache/solr/response/transform/ValueAugmenterFactory.java @@ -16,11 +16,10 @@ */ package org.apache.solr.response.transform; -import java.util.Map; - import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; +import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.DateUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.SolrQueryRequest; @@ -60,15 +59,15 @@ public class ValueAugmenterFactory extends TransformerFactory } @Override - public DocTransformer create(String field, Map args, SolrQueryRequest req) { + public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) { Object val = value; if( val == null ) { - String v = args.get("v"); + String v = params.get("v"); if( v == null ) { val = defaultValue; } else { - val = getObjectFrom(v, args.get("t")); + val = getObjectFrom(v, params.get("t")); } if( val == null ) { throw new SolrException( ErrorCode.BAD_REQUEST, diff --git a/solr/src/java/org/apache/solr/search/ReturnFields.java b/solr/src/java/org/apache/solr/search/ReturnFields.java index a6ee34d8b2e..741c8d8b700 100644 --- a/solr/src/java/org/apache/solr/search/ReturnFields.java +++ b/solr/src/java/org/apache/solr/search/ReturnFields.java @@ -226,7 +226,8 @@ public class ReturnFields TransformerFactory factory = req.getCore().getTransformerFactory( augmenterName ); if( factory != null ) { - augmenters.addTransformer( factory.create(disp, augmenterArgs, req) ); + MapSolrParams augmenterParams = new MapSolrParams( augmenterArgs ); + augmenters.addTransformer( factory.create(disp, augmenterParams, req) ); } else { // unknown transformer?