You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2021/02/23 06:42:33 UTC

[lucene-solr] branch jira/solr15183 created (now e3017a2)

This is an automated email from the ASF dual-hosted git repository.

noble pushed a change to branch jira/solr15183
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


      at e3017a2  new class for collection apis

This branch includes the following new commits:

     new e3017a2  new class for collection apis

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-solr] 01/01: new class for collection apis

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch jira/solr15183
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit e3017a2e91b4418bd258628134a4c355184d4e8c
Author: Noble Paul <no...@gmail.com>
AuthorDate: Tue Feb 23 17:41:44 2021 +1100

    new class for collection apis
---
 .../java/org/apache/solr/core/CoreContainer.java   |  2 +
 .../org/apache/solr/handler/CollectionAPI.java     | 47 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

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 15741c8..675e063 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -95,6 +95,7 @@ import org.apache.solr.core.backup.repository.BackupRepository;
 import org.apache.solr.core.backup.repository.BackupRepositoryFactory;
 import org.apache.solr.filestore.PackageStoreAPI;
 import org.apache.solr.handler.ClusterAPI;
+import org.apache.solr.handler.CollectionAPI;
 import org.apache.solr.handler.CollectionBackupsAPI;
 import org.apache.solr.handler.CollectionsAPI;
 import org.apache.solr.handler.RequestHandlerBase;
@@ -754,6 +755,7 @@ public class CoreContainer {
     containerHandlers.getApiBag().registerObject(clusterAPI);
     containerHandlers.getApiBag().registerObject(clusterAPI.commands);
     containerHandlers.getApiBag().registerObject(clusterAPI.configSetCommands);
+    containerHandlers.getApiBag().registerObject(new CollectionAPI(collectionsHandler));
     /*
      * HealthCheckHandler needs to be initialized before InfoHandler, since the later one will call CoreContainer.getHealthCheckHandler().
      * We don't register the handler here because it'll be registered inside InfoHandler
diff --git a/solr/core/src/java/org/apache/solr/handler/CollectionAPI.java b/solr/core/src/java/org/apache/solr/handler/CollectionAPI.java
new file mode 100644
index 0000000..a48bcb6
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/CollectionAPI.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.solr.handler;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.CollectionsHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.handler.ClusterAPI.wrapParams;
+import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM;
+
+public class CollectionAPI {
+  private final CollectionsHandler collectionsHandler;
+
+  public CollectionAPI(CollectionsHandler collectionsHandler) {
+    this.collectionsHandler = collectionsHandler;
+  }
+
+  @EndPoint(method = GET,
+      path = {
+      "/c/{collection}",
+          "/collections/{collection}" ,
+          "/collections/{collection}/shards/{shard}",
+          "/c/{collection}/shards/{shard}"},
+      permission = COLL_READ_PERM)
+  public void getCollection(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+    wrapParams(req, "collection", req.getPathTemplateValues().get("collection"), "shard",req.getPathTemplateValues().get("shard") );
+    CollectionsHandler.CollectionOperation.CLUSTERSTATUS_OP.execute(req, rsp, collectionsHandler);
+  }
+}