From b7ddac884ec3beb698015701adfd1eb55105942d Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Wed, 7 Jan 2015 07:08:00 +0000 Subject: [PATCH] SOLR-6533 implicit requesthandlers were not exposed git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1650000 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/handler/SolrConfigHandler.java | 20 +++++++++++++++++-- .../solr/core/TestSolrConfigHandler.java | 11 ++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java index 7a701e5dbc7..cc2e05d1be3 100644 --- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java @@ -40,6 +40,7 @@ import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.StrUtils; import org.apache.solr.core.ConfigOverlay; import org.apache.solr.core.PluginInfo; +import org.apache.solr.core.PluginsRegistry; import org.apache.solr.core.RequestParams; import org.apache.solr.core.SolrConfig; import org.apache.solr.core.SolrResourceLoader; @@ -99,7 +100,7 @@ public class SolrConfigHandler extends RequestHandlerBase { private void handleGET() { if(parts.size() == 1) { - resp.add("config", req.getCore().getSolrConfig().toMap()); + resp.add("config", getConfigDetails()); } else { if(ConfigOverlay.NAME.equals(parts.get(1))){ resp.add(ConfigOverlay.NAME, req.getCore().getSolrConfig().getOverlay().toMap()); @@ -118,12 +119,27 @@ public class SolrConfigHandler extends RequestHandlerBase { } } else { - Map m = req.getCore().getSolrConfig().toMap(); + Map m = getConfigDetails(); resp.add("config", ZkNodeProps.makeMap(parts.get(1),m.get(parts.get(1)))); } } } + private Map getConfigDetails() { + Map map = req.getCore().getSolrConfig().toMap(); + Map reqHandlers = (Map) map.get(SolrRequestHandler.TYPE); + if(reqHandlers == null) map.put(SolrRequestHandler.TYPE, reqHandlers = new LinkedHashMap<>()); + List plugins = PluginsRegistry.getHandlers(req.getCore()); + for (PluginInfo plugin : plugins) { + if(SolrRequestHandler.TYPE.equals( plugin.type)){ + if(!reqHandlers.containsKey(plugin.name)){ + reqHandlers.put(plugin.name,plugin.toMap()); + } + } + } + return map; + } + private void handlePOST() throws IOException { Iterable streams = req.getContentStreams(); diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java index 3624dfdeefc..25d6d6dcac0 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java @@ -96,6 +96,17 @@ public class TestSolrConfigHandler extends RestTestBase { public void testProperty() throws Exception{ RestTestHarness harness = restTestHarness; + Map confMap = getRespMap("/config?wt=json" ,harness); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/luke"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/system"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/mbeans"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/plugins"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/threads"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/properties"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/logging"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/file"))); + assertNotNull( getObjectByPath(confMap,false,Arrays.asList("config","requestHandler","/admin/ping"))); + String payload= "{\n" + " 'set-property' : { 'updateHandler.autoCommit.maxDocs':100, 'updateHandler.autoCommit.maxTime':10 } \n" + " }";