lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject lucene-solr:apiv2: SOLR-8029: Added configset and blob store APIs to /v2 path
Date Tue, 31 May 2016 15:32:52 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/apiv2 5df4ca1eb -> f72c6914a


SOLR-8029: Added configset and blob store APIs to /v2 path


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f72c6914
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f72c6914
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f72c6914

Branch: refs/heads/apiv2
Commit: f72c6914a83f6cf5b287c53beb40c52244ba5a9b
Parents: 5df4ca1
Author: Noble Paul <noble@apache.org>
Authored: Tue May 31 21:02:25 2016 +0530
Committer: Noble Paul <noble@apache.org>
Committed: Tue May 31 21:02:25 2016 +0530

----------------------------------------------------------------------
 .../java/org/apache/solr/api/ApiSupport.java    |   9 ++
 .../org/apache/solr/core/CoreContainer.java     |  12 +-
 .../java/org/apache/solr/core/PluginBag.java    |  39 +++---
 .../org/apache/solr/handler/BlobHandler.java    |  14 ++-
 .../apache/solr/handler/PingRequestHandler.java |   6 +
 .../apache/solr/handler/RealTimeGetHandler.java |   5 +
 .../org/apache/solr/handler/SchemaHandler.java  |   5 +-
 .../apache/solr/handler/SolrConfigHandler.java  |   5 +
 .../solr/handler/UpdateRequestHandlerApi.java   |  10 ++
 .../apache/solr/handler/admin/ApiCommand.java   |  11 +-
 .../handler/admin/CollectionHandlerApi.java     |  14 +--
 .../solr/handler/admin/CollectionsHandler.java  |   4 +
 .../solr/handler/admin/ConfigSetsHandler.java   |  16 ++-
 .../handler/admin/ConfigSetsHandlerApi.java     | 118 +++++++++++++++++++
 .../solr/handler/admin/CoreAdminHandler.java    |   5 +
 .../solr/handler/admin/CoreAdminHandlerApi.java |  22 +---
 .../apache/solr/handler/admin/InfoHandler.java  |   6 +-
 .../solr/handler/admin/SecurityConfHandler.java |   4 +
 solr/core/src/resources/ImplicitPlugins.json    |  13 +-
 .../apispec/cluster.config.commands.json        |  33 ++++++
 .../apispec/cluster.config.delete.json          |  11 ++
 .../src/resources/apispec/cluster.config.json   |  11 ++
 .../core/src/resources/apispec/system.blob.json |  19 +++
 .../resources/apispec/system.blob.upload.json   |  11 ++
 .../solr/handler/admin/TestApiFramework.java    |  16 +--
 .../org/apache/solr/util/JsonValidatorTest.java |  10 +-
 26 files changed, 342 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/api/ApiSupport.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/api/ApiSupport.java b/solr/core/src/java/org/apache/solr/api/ApiSupport.java
index c3da75c..301de31 100644
--- a/solr/core/src/java/org/apache/solr/api/ApiSupport.java
+++ b/solr/core/src/java/org/apache/solr/api/ApiSupport.java
@@ -23,4 +23,13 @@ public interface ApiSupport {
 
   Collection<Api> getApis();
 
+  default Boolean registerV1() {
+    return Boolean.TRUE;
+  }
+
+  default Boolean registerV2() {
+    return Boolean.FALSE;
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index f36328c..e2cee55 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -447,15 +447,15 @@ public class CoreContainer {
     containerHandlers.put(ZK_PATH, new ZookeeperInfoHandler(this));
     securityConfHandler = new SecurityConfHandler(this);
     collectionsHandler = createHandler(cfg.getCollectionsHandlerClass(), CollectionsHandler.class);
-    containerHandlers.put(COLLECTIONS_HANDLER_PATH, collectionsHandler, true);
+    containerHandlers.put(COLLECTIONS_HANDLER_PATH, collectionsHandler);
     infoHandler        = createHandler(cfg.getInfoHandlerClass(), InfoHandler.class);
-    containerHandlers.put(INFO_HANDLER_PATH, infoHandler, true);
+    containerHandlers.put(INFO_HANDLER_PATH, infoHandler);
     coreAdminHandler   = createHandler(cfg.getCoreAdminHandlerClass(), CoreAdminHandler.class);
-    containerHandlers.put(CORES_HANDLER_PATH, coreAdminHandler, true);
+    containerHandlers.put(CORES_HANDLER_PATH, coreAdminHandler);
     configSetsHandler = createHandler(cfg.getConfigSetsHandlerClass(), ConfigSetsHandler.class);
-    containerHandlers.put(CONFIGSETS_HANDLER_PATH, configSetsHandler, true);
-    containerHandlers.put(AUTHZ_PATH, securityConfHandler, true);
-    containerHandlers.put(AUTHC_PATH, securityConfHandler, true);
+    containerHandlers.put(CONFIGSETS_HANDLER_PATH, configSetsHandler);
+    containerHandlers.put(AUTHZ_PATH, securityConfHandler);
+    containerHandlers.put(AUTHC_PATH, securityConfHandler);
     if(pkiAuthenticationPlugin != null)
       containerHandlers.put(PKIAuthenticationPlugin.PATH, pkiAuthenticationPlugin.getRequestHandler());
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/core/PluginBag.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/PluginBag.java b/solr/core/src/java/org/apache/solr/core/PluginBag.java
index 356fcd3..75c4bff 100644
--- a/solr/core/src/java/org/apache/solr/core/PluginBag.java
+++ b/solr/core/src/java/org/apache/solr/core/PluginBag.java
@@ -174,27 +174,20 @@ public class PluginBag<T> implements AutoCloseable {
   /**
    * register a plugin by a name
    */
-  public T put(String name, T plugin , boolean registerAPI) {
+  public T put(String name, T plugin) {
     if (plugin == null) return null;
     PluginHolder<T> pluginHolder = new PluginHolder<>(null, plugin);
-    pluginHolder.registerAPI = registerAPI;
+    pluginHolder.registerAPI = false;
     PluginHolder<T> old = put(name, pluginHolder);
     return old == null ? null : old.get();
   }
 
-  public T put(String name, T plugin){
-    return put(name, plugin, false);
-  }
-
   PluginHolder<T> put(String name, PluginHolder<T> plugin) {
-    boolean registerApi = false;
-    boolean disableHandler = false;
+    Boolean registerApi = null;
+    Boolean disableHandler = null;
     if (plugin.pluginInfo != null) {
       String registerAt = plugin.pluginInfo.attributes.get("registerPath");
-      if(registerAt == null){
-        registerApi = false;
-        disableHandler = false;
-      } else {
+      if (registerAt != null) {
         List<String> strs = StrUtils.splitSmart(registerAt, ',');
         disableHandler = !strs.contains("/");
         registerApi = strs.contains("/v2");
@@ -204,20 +197,28 @@ public class PluginBag<T> implements AutoCloseable {
     if (apiBag != null) {
       if (plugin.isLoaded()) {
         T inst = plugin.get();
-        if (inst instanceof ApiSupport && (registerApi || plugin.registerAPI)) {
+        if (inst instanceof ApiSupport) {
           ApiSupport apiSupport = (ApiSupport) inst;
-          Collection<Api> apis = apiSupport.getApis();
-          if (apis != null) {
-            Map<String, String> nameSubstitutes = singletonMap(HANDLER_NAME, name);
-            for (Api api : apis) {
-              apiBag.register(api, nameSubstitutes);
+          if (registerApi == null) registerApi = apiSupport.registerV2();
+          if (disableHandler == null) disableHandler = !apiSupport.registerV1();
+
+          if(registerApi) {
+            Collection<Api> apis = apiSupport.getApis();
+            if (apis != null) {
+              Map<String, String> nameSubstitutes = singletonMap(HANDLER_NAME, name);
+              for (Api api : apis) {
+                apiBag.register(api, nameSubstitutes);
+              }
             }
           }
+
         }
       } else {
-        if (registerApi) apiBag.registerLazy((PluginHolder<SolrRequestHandler>) plugin,
plugin.pluginInfo);
+        if (registerApi != null && registerApi)
+          apiBag.registerLazy((PluginHolder<SolrRequestHandler>) plugin, plugin.pluginInfo);
       }
     }
+    if(disableHandler == null) disableHandler = Boolean.FALSE;
     PluginHolder<T> old = null;
     if(!disableHandler) old = registry.put(name, plugin);
     if (plugin.pluginInfo != null && plugin.pluginInfo.isDefault()) setDefault(name);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
index 4b71187..597e2a2 100644
--- a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
@@ -22,6 +22,7 @@ import java.lang.invoke.MethodHandles;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.security.MessageDigest;
+import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +35,8 @@ import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.TopFieldDocs;
+import org.apache.solr.api.Api;
+import org.apache.solr.api.ApiBag;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.CommonParams;
@@ -72,7 +75,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
 
   @Override
   public void handleRequestBody(final SolrQueryRequest req, SolrQueryResponse rsp) throws
Exception {
-    String httpMethod = (String) req.getContext().get("httpMethod");
+    String httpMethod = req.getHttpMethod();
     String path = (String) req.getContext().get("path");
     SolrConfigHandler.setWt(req, JSON);
 
@@ -277,4 +280,13 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
     req.getCore().getRequestHandler(handler).handleRequest(r, rsp);
   }
 
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
+
+  @Override
+  public Collection<Api> getApis() {
+    return ApiBag.wrapRequestHandlers(this, "system.blob", "system.blob.upload");
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
index 4b72e0f..818da35 100644
--- a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
@@ -24,6 +24,7 @@ import java.time.Instant;
 import java.util.Locale;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.solr.api.Api;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
@@ -328,4 +329,9 @@ public class PingRequestHandler extends RequestHandlerBase implements
SolrCoreAw
   public String getDescription() {
     return "Reports application health to a load-balancer";
   }
+
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
index 64787f4..9049318 100644
--- a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
@@ -51,6 +51,11 @@ public class RealTimeGetHandler extends SearchHandler {
   public Collection<Api> getApis() {
     return ApiBag.wrapRequestHandlers(this, "core.RealtimeGet");
   }
+
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
index a1c1ddf..288c96c 100644
--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
@@ -258,5 +258,8 @@ public class SchemaHandler extends RequestHandlerBase implements SolrCoreAware,
 
   }
 
-
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
----------------------------------------------------------------------
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 6460a99..64b657f 100644
--- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
@@ -838,4 +838,9 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
         "core.config.Params",
         "core.config.Params.Commands");
   }
+
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
index 541d398..1e07277 100644
--- a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
@@ -58,6 +58,16 @@ public class UpdateRequestHandlerApi extends UpdateRequestHandler  {
     };
   }
 
+  @Override
+  public Boolean registerV1() {
+    return Boolean.FALSE;
+  }
+
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
+
   private static final Map<String, String> mapping = ImmutableMap.<String,String>builder()
       .put("/update", DOC_PATH)
       .put(JSON_PATH, DOC_PATH)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java b/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
index cce86fb..8899a7a 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
@@ -33,11 +33,16 @@ public interface ApiCommand<T> {
   V2EndPoint getEndPoint();
 
 
-  void command(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation c, T handler)
throws Exception;
+ /* void command(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation c, T handler)
throws Exception;
 
   void GET(SolrQueryRequest req, SolrQueryResponse rsp, T handler) throws Exception;
+*/
+  default Collection<String> getParamNames(CommandOperation op) {
+    return BaseHandlerApiSupport.getParamNames(op, this);
+  }
 
-  Collection<String> getParamNames(CommandOperation op);
 
-  String getParamSubstitute(String name);
+  default String getParamSubstitute(String name) {
+    return name;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
index a3c7168..502a0d1 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
@@ -53,12 +53,12 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
 
   @Override
   protected void invokeCommand(SolrQueryRequest req, SolrQueryResponse rsp, ApiCommand command,
CommandOperation c) throws Exception {
-    ((Cmd) command).command(req, rsp,c, this);
+    handler.invokeAction(req, rsp, handler.coreContainer, ((Cmd) command).target.action,
((Cmd) command).target);
   }
 
   @Override
   protected void invokeUrl(ApiCommand command, SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
-    ((Cmd) command).GET(req,rsp, this);
+    handler.invokeAction(req, rsp, handler.coreContainer, ((Cmd) command).target.action,
((Cmd) command).target);
   }
 
   @Override
@@ -214,16 +214,6 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
 
 
     @Override
-    public void command(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation c,
CollectionHandlerApi handler) throws Exception {
-      handler.handler.invokeAction(req, rsp, handler.handler.coreContainer, target.action,target);
-    }
-
-    @Override
-    public void GET(SolrQueryRequest req, SolrQueryResponse rsp, CollectionHandlerApi handler)
throws Exception {
-      handler.handler.invokeAction(req, rsp, handler.handler.coreContainer, target.action,target);
-    }
-
-    @Override
     public Collection<String> getParamNames(CommandOperation op) {
       Collection<String> paramNames = BaseHandlerApiSupport.getParamNames(op, this);
       if (!prefixSubStitutes.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index c2b3316..c0ca223 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -1029,4 +1029,8 @@ public class CollectionsHandler extends RequestHandlerBase implements
Permission
     return v2Handler.getApis();
   }
 
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
index 4db2950..212009b 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
@@ -18,13 +18,14 @@ package org.apache.solr.handler.admin;
 
 import java.lang.invoke.MethodHandles;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.solr.api.Api;
 import org.apache.solr.client.solrj.SolrResponse;
-import org.apache.solr.cloud.Overseer;
 import org.apache.solr.cloud.OverseerSolrResponse;
 import org.apache.solr.cloud.OverseerTaskQueue.QueueEvent;
 import org.apache.solr.common.SolrException;
@@ -62,6 +63,7 @@ public class ConfigSetsHandler extends RequestHandlerBase {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   protected final CoreContainer coreContainer;
   public static long DEFAULT_ZK_TIMEOUT = 300*1000;
+  private final ConfigSetsHandlerApi configSetsHandlerApi = new ConfigSetsHandlerApi(this);
 
   /**
    * Overloaded ctor to inject CoreContainer into the handler.
@@ -162,7 +164,7 @@ public class ConfigSetsHandler extends RequestHandlerBase {
     return "Manage SolrCloud ConfigSets";
   }
 
-  enum ConfigSetOperation {
+  public enum ConfigSetOperation {
     CREATE_OP(CREATE) {
       @Override
       Map<String, Object> call(SolrQueryRequest req, SolrQueryResponse rsp, ConfigSetsHandler
h) throws Exception {
@@ -205,4 +207,14 @@ public class ConfigSetsHandler extends RequestHandlerBase {
       throw new SolrException(ErrorCode.SERVER_ERROR, "No such action" + action);
     }
   }
+
+  @Override
+  public Collection<Api> getApis() {
+    return configSetsHandlerApi.getApis();
+  }
+
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
new file mode 100644
index 0000000..e4fd709
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
@@ -0,0 +1,118 @@
+package org.apache.solr.handler.admin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.CommandOperation;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
+import static org.apache.solr.handler.admin.ConfigSetsHandler.ConfigSetOperation.CREATE_OP;
+import static org.apache.solr.handler.admin.ConfigSetsHandler.ConfigSetOperation.DELETE_OP;
+import static org.apache.solr.handler.admin.ConfigSetsHandler.ConfigSetOperation.LIST_OP;
+
+public class ConfigSetsHandlerApi extends BaseHandlerApiSupport {
+
+  private final ConfigSetsHandler configSetHandler;
+
+  public ConfigSetsHandlerApi(ConfigSetsHandler configSetHandler) {
+    this.configSetHandler = configSetHandler;
+  }
+
+  @Override
+  protected void invokeCommand(SolrQueryRequest req, SolrQueryResponse rsp, ApiCommand command,
CommandOperation c)
+      throws Exception {
+    ((Cmd) command).op.call(req, rsp, this.configSetHandler);
+
+  }
+
+  @Override
+  protected void invokeUrl(ApiCommand command, SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
+    ((Cmd)command).op.call(req, rsp,configSetHandler);
+  }
+
+  @Override
+  protected List<ApiCommand> getCommands() {
+    return Arrays.asList(Cmd.values());
+  }
+
+  @Override
+  protected List<V2EndPoint> getEndPoints() {
+    return Arrays.asList(EndPoint.values());
+  }
+
+  enum Cmd implements ApiCommand<ConfigSetsHandler> {
+    LIST(EndPoint.LIST_CONFIG, LIST_OP, GET),
+    CREATE(EndPoint.CONFIG_COMMANDS, CREATE_OP, POST, "create"),
+    DEL(EndPoint.CONFIG_DEL, DELETE_OP, DELETE)
+    ;
+    private final EndPoint endPoint;
+    private final ConfigSetsHandler.ConfigSetOperation op;
+    private final SolrRequest.METHOD method;
+    private final String cmdName;
+
+    Cmd(EndPoint endPoint, ConfigSetsHandler.ConfigSetOperation op, SolrRequest.METHOD method)
{
+      this(endPoint, op, method, null);
+    }
+
+    Cmd(EndPoint endPoint, ConfigSetsHandler.ConfigSetOperation op, SolrRequest.METHOD method,
String cmdName) {
+      this.cmdName = cmdName;
+      this.endPoint = endPoint;
+      this.op = op;
+      this.method = method;
+    }
+
+    @Override
+    public String getName() {
+      return cmdName;
+    }
+
+    @Override
+    public SolrRequest.METHOD getHttpMethod() {
+      return method;
+    }
+
+    @Override
+    public V2EndPoint getEndPoint() {
+      return endPoint;
+    }
+  }
+  enum EndPoint implements V2EndPoint {
+    LIST_CONFIG("cluster.config"),
+    CONFIG_COMMANDS("cluster.config.commands"),
+    CONFIG_DEL("cluster.config.delete");
+
+    public final String spec;
+
+    EndPoint(String spec) {
+      this.spec = spec;
+    }
+
+    @Override
+    public String getSpecName() {
+      return spec;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
----------------------------------------------------------------------
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 b18d6b6..d969a0c46 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
@@ -113,6 +113,11 @@ public class CoreAdminHandler extends RequestHandlerBase  {
                     "it is a special Handler configured directly by the RequestDispatcher");
   }
 
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
+
   /**
    * The instance of CoreContainer this handler handles. This should be the CoreContainer
instance that created this
    * handler.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
index 3f54b13..dc96bd2 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
@@ -19,7 +19,6 @@ package org.apache.solr.handler.admin;
 
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
@@ -108,23 +107,6 @@ public class CoreAdminHandlerApi extends BaseHandlerApiSupport {
     }
 
     @Override
-    public void command(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation c,
CoreAdminHandlerApi handler) throws Exception {
-      target.call(new CoreAdminHandler.CallInfo(handler.handler,req,rsp,target ));
-
-    }
-
-    @Override
-    public void GET(SolrQueryRequest req, SolrQueryResponse rsp, CoreAdminHandlerApi handler)
throws Exception {
-      target.call(new CoreAdminHandler.CallInfo(handler.handler,req,rsp,target ));
-
-    }
-
-    @Override
-    public Collection<String> getParamNames(CommandOperation op) {
-      return BaseHandlerApiSupport.getParamNames(op, this);
-    }
-
-    @Override
     public String getParamSubstitute(String param) {
       return paramstoAttr.containsKey(param) ? paramstoAttr.get(param) : param;
     }
@@ -156,12 +138,12 @@ public class CoreAdminHandlerApi extends BaseHandlerApiSupport {
   @Override
   protected void invokeCommand(SolrQueryRequest req, SolrQueryResponse rsp, ApiCommand command,
                                CommandOperation c) throws Exception {
-    ((Cmd) command).command(req,rsp, c, this);
+    ((Cmd) command).target.call(new CoreAdminHandler.CallInfo(handler, req, rsp, ((Cmd) command).target));
   }
 
   @Override
   protected void invokeUrl(ApiCommand command, SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
-    command.GET(req,rsp, this);
+    ((Cmd) command).target.call(new CoreAdminHandler.CallInfo(handler, req, rsp, ((Cmd) command).target));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
index 1164ab5..fbcdec1 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
@@ -41,7 +41,7 @@ import static java.util.Collections.singletonList;
 import static org.apache.solr.api.ApiBag.getSpec;
 import static org.apache.solr.common.params.CommonParams.PATH;
 
-public class InfoHandler extends RequestHandlerBase implements ApiSupport {
+public class InfoHandler extends RequestHandlerBase  {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   protected final CoreContainer coreContainer;
@@ -152,4 +152,8 @@ public class InfoHandler extends RequestHandlerBase implements ApiSupport
{
     return singletonList(new ReqHandlerToApi(this, getSpec("node.Info")));
   }
 
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
index 3049263..238e7aa 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
@@ -241,5 +241,9 @@ public class SecurityConfHandler extends RequestHandlerBase implements
Permissio
     return this.apis;
   }
 
+  @Override
+  public Boolean registerV2() {
+    return Boolean.TRUE;
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/ImplicitPlugins.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/ImplicitPlugins.json b/solr/core/src/resources/ImplicitPlugins.json
index bbd8102..380e01d 100644
--- a/solr/core/src/resources/ImplicitPlugins.json
+++ b/solr/core/src/resources/ImplicitPlugins.json
@@ -25,16 +25,13 @@
     },
     "update":{
       "class":"solr.UpdateRequestHandlerApi",
-      "registerPath":"/v2",
       "useParams": "update_json_docs"
     },
     "/config": {
-      "class": "solr.SolrConfigHandler",
-      "registerPath":"/,/v2"
+      "class": "solr.SolrConfigHandler"
     },
     "/schema": {
-      "class": "solr.SchemaHandler",
-      "registerPath":"/,/v2"
+      "class": "solr.SchemaHandler"
     },
     "/replication": {
       "class": "solr.ReplicationHandler"
@@ -45,16 +42,14 @@
         "omitHeader": true,
         "wt": "json",
         "indent": true
-      },
-      "registerPath":"/,/v2"
+      }
     },
     "/admin/ping": {
       "class": "solr.PingRequestHandler",
       "invariants": {
         "echoParams": "all",
         "q": "{!lucene}*:*"
-      },
-      "registerPath":"/,/v2"
+      }
     },
     "/admin/segments": {
       "class": "solr.SegmentsInfoRequestHandler"

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/apispec/cluster.config.commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.config.commands.json b/solr/core/src/resources/apispec/cluster.config.commands.json
new file mode 100644
index 0000000..eda56d6
--- /dev/null
+++ b/solr/core/src/resources/apispec/cluster.config.commands.json
@@ -0,0 +1,33 @@
+{
+  "documentation": "https://cwiki.apache.org/confluence/display/solr/ConfigSets+API",
+  "methods": [
+    "POST"
+  ],
+  "url": {
+    "paths": [
+      "/cluster/configs"]
+  },
+  "commands": {
+    "create": {
+      "type" :"object",
+      "properties": {
+        "name" :{
+          "type" :"string",
+          "description" : "ConfigSet to be created"
+        },
+        "baseConfigSet":{
+          "type" : "string",
+          "description" :"ConfigSet to copy as a base"
+        },
+        "properties" : {
+          "type":"object",
+          "additionalProperties" : true
+        }
+      },
+      "required" : ["name", "baseConfigSet"]
+    },
+    "delete" : {
+      "type":"string"
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/apispec/cluster.config.delete.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.config.delete.json b/solr/core/src/resources/apispec/cluster.config.delete.json
new file mode 100644
index 0000000..ae8dbc3
--- /dev/null
+++ b/solr/core/src/resources/apispec/cluster.config.delete.json
@@ -0,0 +1,11 @@
+{
+  "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1",
+  "methods": [
+    "DELETE"
+  ],
+  "url": {
+    "paths": [
+      "/cluster/configs/{name}"
+    ]
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/apispec/cluster.config.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.config.json b/solr/core/src/resources/apispec/cluster.config.json
new file mode 100644
index 0000000..b3d8c23
--- /dev/null
+++ b/solr/core/src/resources/apispec/cluster.config.json
@@ -0,0 +1,11 @@
+{
+  "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1",
+  "methods": [
+    "GET"
+  ],
+  "url": {
+    "paths": [
+      "/cluster/configs"
+    ]
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/apispec/system.blob.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/system.blob.json b/solr/core/src/resources/apispec/system.blob.json
new file mode 100644
index 0000000..3541450
--- /dev/null
+++ b/solr/core/src/resources/apispec/system.blob.json
@@ -0,0 +1,19 @@
+{
+  "documentation": "https://cwiki.apache.org/confluence/display/solr/Blob+Store+API",
+  "methods": [
+    "GET"
+  ],
+  "url": {
+    "paths": [
+      "/blob",
+      "/blob/{name}",
+      "/blob/{name}/{version}"
+    ]
+  },
+  "params": {
+    "wt": {
+      "type":"string",
+      "description": "use the value 'filestream' to get the file content. Use other response
writers to fetch the metadata"
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/resources/apispec/system.blob.upload.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/system.blob.upload.json b/solr/core/src/resources/apispec/system.blob.upload.json
new file mode 100644
index 0000000..e6f0371
--- /dev/null
+++ b/solr/core/src/resources/apispec/system.blob.upload.json
@@ -0,0 +1,11 @@
+{
+  "documentation": "https://cwiki.apache.org/confluence/display/solr/Blob+Store+API",
+  "methods": [
+    "POST"
+  ],
+  "url": {
+    "paths": [
+      "/blob/{name}"
+    ]
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
index b04625d..d1ec3ba 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.util.Predicate;
 import org.apache.solr.common.util.StrUtils;
@@ -43,6 +44,7 @@ import org.apache.solr.util.CommandOperation;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
 import static org.apache.solr.common.params.CommonParams.COLLECTIONS_HANDLER_PATH;
+import static org.apache.solr.common.params.CommonParams.CONFIGSETS_HANDLER_PATH;
 import static org.apache.solr.common.params.CommonParams.CORES_HANDLER_PATH;
 import static org.apache.solr.common.util.Map2.NOT_NULL;
 
@@ -53,14 +55,15 @@ public class TestApiFramework extends SolrTestCaseJ4 {
     Map<String, Object> out = new HashMap<>();
     CoreContainer mockCC = TestCoreAdminApis.getCoreContainerMock(calls, out);
     PluginBag<SolrRequestHandler> containerHandlers = new PluginBag<>(SolrRequestHandler.class,
null, false);
-    containerHandlers.put(COLLECTIONS_HANDLER_PATH, new TestCollectionAPIs.MockCollectionsHandler(),
true);
-    containerHandlers.put(CORES_HANDLER_PATH, new CoreAdminHandler(mockCC), true);
+    containerHandlers.put(COLLECTIONS_HANDLER_PATH, new TestCollectionAPIs.MockCollectionsHandler());
+    containerHandlers.put(CORES_HANDLER_PATH, new CoreAdminHandler(mockCC));
+    containerHandlers.put(CONFIGSETS_HANDLER_PATH, new ConfigSetsHandler(mockCC));
     out.put("getRequestHandlers", containerHandlers);
 
     PluginBag<SolrRequestHandler> coreHandlers = new PluginBag<>(SolrRequestHandler.class,
null, false);
-    coreHandlers.put("/schema", new SchemaHandler(), true);
-    coreHandlers.put("/config", new SolrConfigHandler(), true);
-    coreHandlers.put("/admin/ping", new PingRequestHandler(), true);
+    coreHandlers.put("/schema", new SchemaHandler());
+    coreHandlers.put("/config", new SolrConfigHandler());
+    coreHandlers.put("/admin/ping", new PingRequestHandler());
 
     Map<String, String> parts = new HashMap<>();
     String fullPath = "/collections/hello/shards";
@@ -184,8 +187,5 @@ public class TestApiFramework extends SolrTestCaseJ4 {
         assertEquals("incorrect value for path " + e.getKey() + " in :" + Utils.toJSONString(root),
e.getValue(), val);
       }
     }
-
   }
-
-
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f72c6914/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
index 6e446f5..71b2952 100644
--- a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
+++ b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
@@ -31,7 +31,7 @@ import static org.apache.solr.common.util.Utils.toJSONString;
 
 public class JsonValidatorTest extends SolrTestCaseJ4 {
 
-  public void testSchema(){
+  public void testSchema() {
     checkSchema("collections.commands");
     checkSchema("collections.collection.commands");
     checkSchema("collections.collection.shards.Commands");
@@ -44,10 +44,10 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
     checkSchema("cluster.security.RuleBasedAuthorization");
     checkSchema("core.config.Commands");
     checkSchema("core.SchemaEdit");
+    checkSchema("cluster.config.commands");
   }
 
 
-
   public void testSchemaValidation() {
     Map2 spec = ApiBag.getSpec("collections.commands").getSpec();
     Map createSchema = spec.getMap("commands", NOT_NULL).getMap("create-alias", NOT_NULL);
@@ -63,7 +63,7 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
     assertFalse(toJSONString(errs), errs.isEmpty());
     assertTrue(toJSONString(errs), errs.get(0).contains("Expected type"));
     errs = validator.validateJson(Utils.fromJSONString("{x:y, collections: [ c1 , c2]}"));
-    assertEquals(toJSONString(errs),2, errs.size());
+    assertEquals(toJSONString(errs), 2, errs.size());
     assertTrue(toJSONString(errs), StrUtils.join(errs, '|').contains("Missing field"));
     assertTrue(toJSONString(errs), StrUtils.join(errs, '|').contains("Unknown"));
     errs = validator.validateJson(Utils.fromJSONString("{name : x, collections: [ 1 , 2]}"));
@@ -83,7 +83,7 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
 
     errs = validator.validateJson(Utils.fromJSONString("{name:x, age:'x21', adult:'true'}"));
     assertEquals(1, errs.size());
-    
+
 
   }
 
@@ -95,7 +95,7 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
       try {
         JsonSchemaValidator validator = new JsonSchemaValidator((Map) cmd.getValue());
       } catch (Exception e) {
-        throw new RuntimeException("Error in command  "+ cmd.getKey() +" in schema "+name,
e);
+        throw new RuntimeException("Error in command  " + cmd.getKey() + " in schema " +
name, e);
       }
     }
   }


Mime
View raw message