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

gerlowskija pushed a commit to branch SOLR-15740-v2-read-schema-apis
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 381a599931ab60d28f98f062652e211980716ce6
Author: Jason Gerlowski <[email protected]>
AuthorDate: Mon Feb 21 11:38:04 2022 -0500

    SOLR-15470: Convert v2 GET /schema APIs to annotations
    
    Solr's been in the slow process of moving its v2 APIs away from the
    existing apispec/mapping framework towards one that relies on more
    explicit annotations to specify API properties.
    
    This commit converts the APIs from the core.SchemaRead,
    core.SchemaRead.fields, core.SchemaRead.copyfields, and
    core.SchemaRead.dynamicFields_fieldTypes apispec files to the new
    framework.
---
 .../org/apache/solr/handler/SchemaHandler.java     | 61 ++++++++++++++++------
 .../admin/api/SchemaGetDynamicFieldAPI.java        | 48 +++++++++++++++++
 .../solr/handler/admin/api/SchemaGetFieldAPI.java  | 47 +++++++++++++++++
 .../handler/admin/api/SchemaGetFieldTypeAPI.java   | 48 +++++++++++++++++
 .../solr/handler/admin/api/SchemaInfoAPI.java      | 47 +++++++++++++++++
 .../solr/handler/admin/api/SchemaKeyAPI.java       | 48 +++++++++++++++++
 .../admin/api/SchemaListAllCopyFieldsAPI.java      | 48 +++++++++++++++++
 .../admin/api/SchemaListAllDynamicFieldsAPI.java   | 48 +++++++++++++++++
 .../admin/api/SchemaListAllFieldTypesAPI.java      | 48 +++++++++++++++++
 .../handler/admin/api/SchemaListAllFieldsAPI.java  | 47 +++++++++++++++++
 .../solr/handler/admin/api/SchemaNameAPI.java      | 47 +++++++++++++++++
 .../handler/admin/api/SchemaSimilarityAPI.java     | 48 +++++++++++++++++
 .../solr/handler/admin/api/SchemaVersionAPI.java   | 48 +++++++++++++++++
 .../solr/handler/admin/api/SchemaZkVersionAPI.java | 48 +++++++++++++++++
 .../apispec/core.SchemaRead.copyFields.json        | 26 ---------
 .../core.SchemaRead.dynamicFields_fieldTypes.json  | 20 -------
 .../resources/apispec/core.SchemaRead.fields.json  | 34 ------------
 .../src/resources/apispec/core.SchemaRead.json     | 17 ------
 18 files changed, 664 insertions(+), 114 deletions(-)

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 f85254b..56e00a3 100644
--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
@@ -16,15 +16,7 @@
  */
 package org.apache.solr.handler;
 
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import org.apache.solr.api.AnnotatedApi;
 import org.apache.solr.api.Api;
 import org.apache.solr.api.ApiBag;
 import org.apache.solr.cloud.ZkSolrResourceLoader;
@@ -38,6 +30,19 @@ import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.admin.api.SchemaGetFieldAPI;
+import org.apache.solr.handler.admin.api.SchemaGetDynamicFieldAPI;
+import org.apache.solr.handler.admin.api.SchemaGetFieldTypeAPI;
+import org.apache.solr.handler.admin.api.SchemaInfoAPI;
+import org.apache.solr.handler.admin.api.SchemaKeyAPI;
+import org.apache.solr.handler.admin.api.SchemaListAllFieldsAPI;
+import org.apache.solr.handler.admin.api.SchemaListAllCopyFieldsAPI;
+import org.apache.solr.handler.admin.api.SchemaListAllDynamicFieldsAPI;
+import org.apache.solr.handler.admin.api.SchemaListAllFieldTypesAPI;
+import org.apache.solr.handler.admin.api.SchemaNameAPI;
+import org.apache.solr.handler.admin.api.SchemaSimilarityAPI;
+import org.apache.solr.handler.admin.api.SchemaVersionAPI;
+import org.apache.solr.handler.admin.api.SchemaZkVersionAPI;
 import org.apache.solr.pkg.PackageListeningClassLoader;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestHandler;
@@ -53,6 +58,16 @@ import org.apache.solr.util.plugin.SolrCoreAware;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import static java.util.Collections.singletonMap;
 import static org.apache.solr.common.params.CommonParams.JSON;
 import static 
org.apache.solr.schema.IndexSchema.SchemaProps.Handler.COPY_FIELDS;
@@ -116,6 +131,7 @@ public class SchemaHandler extends RequestHandlerBase 
implements SolrCoreAware,
   private void handleGET(SolrQueryRequest req, SolrQueryResponse rsp) {
     try {
       String path = (String) req.getContext().get("path");
+      log.info("In SchemaHandler.handleGET and path is: " + path);
       switch (path) {
         case "/schema":
           rsp.add(IndexSchema.SCHEMA, 
req.getSchema().getNamedPropertyValues());
@@ -139,7 +155,7 @@ public class SchemaHandler extends RequestHandlerBase 
implements SolrCoreAware,
           break;
         }
         case "/schema/zkversion": {
-          int refreshIfBelowVersion = 
req.getParams().getInt("refreshIfBelowVersion");
+          int refreshIfBelowVersion = 
req.getParams().getInt("refreshIfBelowVersion", -1);
           int zkVersion = -1;
           IndexSchema schema = req.getSchema();
           if (schema instanceof ManagedIndexSchema) {
@@ -277,13 +293,24 @@ public class SchemaHandler extends RequestHandlerBase 
implements SolrCoreAware,
 
   @Override
   public Collection<Api> getApis() {
-    return ApiBag.wrapRequestHandlers(this, "core.SchemaRead",
-        "core.SchemaRead.fields",
-        "core.SchemaRead.copyFields",
-        "core.SchemaEdit",
-        "core.SchemaRead.dynamicFields_fieldTypes"
-        );
-
+    final List<Api> immList = 
ApiBag.wrapRequestHandlers(this,"core.SchemaEdit");
+    final List<Api> mutList = new ArrayList<>();
+    mutList.addAll(immList);
+    mutList.addAll(AnnotatedApi.getApis(new SchemaNameAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaInfoAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaKeyAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaVersionAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaSimilarityAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaZkVersionAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaListAllFieldsAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaGetFieldAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaListAllCopyFieldsAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new 
SchemaListAllDynamicFieldsAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaGetDynamicFieldAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaListAllFieldTypesAPI(this)));
+    mutList.addAll(AnnotatedApi.getApis(new SchemaGetFieldTypeAPI(this)));
+
+    return mutList;
   }
 
   @Override
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetDynamicFieldAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetDynamicFieldAPI.java
new file mode 100644
index 0000000..4383b56
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetDynamicFieldAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting information about a single dynamic field definition from 
an in-use schema.
+ *
+ * This API (GET 
/v2/collections/collectionName/schema/dynamicfields/fieldName) is analogous to 
the v1
+ * /solr/collectionName/schema/dynamicfields/fieldName API.
+ */
+public class SchemaGetDynamicFieldAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaGetDynamicFieldAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/dynamicfields/{name}"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSingleDynamicField(SolrQueryRequest req, SolrQueryResponse 
rsp) throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldAPI.java
new file mode 100644
index 0000000..2c941e7
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldAPI.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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API to retrieve information about a single field from an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/field/fieldName) is 
analogous to the v1 /solr/collectionName/schema/fields/fieldName API.
+ */
+public class SchemaGetFieldAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaGetFieldAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/fields/{field}"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void retrieveFieldInfo(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldTypeAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldTypeAPI.java
new file mode 100644
index 0000000..70ddc01
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaGetFieldTypeAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting information about a single field-type definition from an 
in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/fieldtypes/typeName) is 
analogous to the v1
+ * /solr/collectionName/schema/fieldtypes/typeName API.
+ */
+public class SchemaGetFieldTypeAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaGetFieldTypeAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/fieldtypes/{name}"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSingleFieldType(SolrQueryRequest req, SolrQueryResponse 
rsp) throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaInfoAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaInfoAPI.java
new file mode 100644
index 0000000..b36bddf
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaInfoAPI.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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting basic information about an in-use schema
+ *
+ * This API (GET /v2/collections/collectionName/schema) is analogous to the v1 
/solr/collectionName/schema API.
+ */
+public class SchemaInfoAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaInfoAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaInfo(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaKeyAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaKeyAPI.java
new file mode 100644
index 0000000..ce5fc92
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaKeyAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting the name of the unique-key field for an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/uniquekey) is analogous 
to the v1
+ * /solr/collectionName/schema/uniquekey API.
+ */
+public class SchemaKeyAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaKeyAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/uniquekey"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaUniqueKey(SolrQueryRequest req, SolrQueryResponse 
rsp) throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllCopyFieldsAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllCopyFieldsAPI.java
new file mode 100644
index 0000000..b7acaeb
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllCopyFieldsAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for listing all copyfield's in an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/copyfields) is 
analogous to the v1
+ * /solr/collectionName/schema/copyfields API.
+ */
+public class SchemaListAllCopyFieldsAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaListAllCopyFieldsAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/copyfields"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getCopyFields(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllDynamicFieldsAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllDynamicFieldsAPI.java
new file mode 100644
index 0000000..fbb8420
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllDynamicFieldsAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for listing all dynamic field definitions in an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/dynamicfields) is 
analogous to the v1
+ * /solr/collectionName/schema/dynamicfields API.
+ */
+public class SchemaListAllDynamicFieldsAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaListAllDynamicFieldsAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/dynamicfields"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void listDynamicFields(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldTypesAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldTypesAPI.java
new file mode 100644
index 0000000..204833c
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldTypesAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for listing all field-type definitions in an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/fieldtypes) is 
analogous to the v1
+ * /solr/collectionName/schema/fieldtypes API.
+ */
+public class SchemaListAllFieldTypesAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaListAllFieldTypesAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/fieldtypes"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void listFieldTypes(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldsAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldsAPI.java
new file mode 100644
index 0000000..1513f0f
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaListAllFieldsAPI.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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API listing all fields defined in an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/fields) is analogous to 
the v1 /solr/collectionName/schema/fields API.
+ */
+public class SchemaListAllFieldsAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaListAllFieldsAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/fields"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void listSchemaFields(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaNameAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaNameAPI.java
new file mode 100644
index 0000000..9fd47b2
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaNameAPI.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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for checking the name of an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/name) is analogous to 
the v1 /solr/collectionName/schema/name API.
+ */
+public class SchemaNameAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaNameAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/name"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaName(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaSimilarityAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaSimilarityAPI.java
new file mode 100644
index 0000000..f489379
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaSimilarityAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting information about the 'similarity' settings for an 
in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/similarity) is 
analogous to the v1
+ * /solr/collectionName/schema/similarity API.
+ */
+public class SchemaSimilarityAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaSimilarityAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/similarity"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaSimilarity(SolrQueryRequest req, SolrQueryResponse 
rsp) throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaVersionAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaVersionAPI.java
new file mode 100644
index 0000000..68d28d5
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaVersionAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for getting the version of an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/version) is analogous 
to the v1
+ * /solr/collectionName/schema/version API.
+ */
+public class SchemaVersionAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaVersionAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/version"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaVersion(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaZkVersionAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaZkVersionAPI.java
new file mode 100644
index 0000000..d9043a6
--- /dev/null
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaZkVersionAPI.java
@@ -0,0 +1,48 @@
+/*
+ * 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.admin.api;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.SchemaHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+
+/**
+ * V2 API for checking the ZK version of an in-use schema.
+ *
+ * This API (GET /v2/collections/collectionName/schema/zkversion) is analogous 
to the v1
+ * /solr/collectionName/schema/zkversion API.
+ */
+public class SchemaZkVersionAPI {
+    private final SchemaHandler schemaHandler;
+
+    public SchemaZkVersionAPI(SchemaHandler schemaHandler) {
+        this.schemaHandler = schemaHandler;
+    }
+
+    @EndPoint(
+            path = {"/schema/zkversion"},
+            method = GET,
+            permission = PermissionNameProvider.Name.SCHEMA_READ_PERM)
+    public void getSchemaZkVersion(SolrQueryRequest req, SolrQueryResponse 
rsp) throws Exception {
+        schemaHandler.handleRequestBody(req, rsp);
+    }
+}
diff --git a/solr/solrj/src/resources/apispec/core.SchemaRead.copyFields.json 
b/solr/solrj/src/resources/apispec/core.SchemaRead.copyFields.json
deleted file mode 100644
index 4fbb0a3..0000000
--- a/solr/solrj/src/resources/apispec/core.SchemaRead.copyFields.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
-  "documentation": 
"https://solr.apache.org/guide/schema-api.html#list-copy-fields";,
-  "description": "Lists all copy fields.",
-  "methods": [
-    "GET"
-  ],
-  "url": {
-    "paths": [
-      "schema/copyfields"
-    ],
-    "params": {
-      "wt": {
-         "type": "string",
-         "description": "The format of the response. Valid options are xml or 
json."
-      },
-      "source.fl": {
-        "type": "string",
-        "description": "Comma- or space-separated list of one or more source 
fields to include in the response. copyField directives with all other source 
fields will be excluded from the response. If not specified, all copyFields 
will be included in the response"
-      },
-      "dest.fl": {
-        "type": "string",
-        "description": "Comma or space-separated list of one or more copyField 
dest (destination) fields to include in the response. copyField directives with 
all other dest fields will be excluded. If not specified, all copyFields will 
be included in the response."
-      }
-    }
-  }
-}
diff --git 
a/solr/solrj/src/resources/apispec/core.SchemaRead.dynamicFields_fieldTypes.json
 
b/solr/solrj/src/resources/apispec/core.SchemaRead.dynamicFields_fieldTypes.json
deleted file mode 100644
index fc901a9..0000000
--- 
a/solr/solrj/src/resources/apispec/core.SchemaRead.dynamicFields_fieldTypes.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "documentation": "https://solr.apache.org/guide/schema-api.html";,
-  "methods": [
-    "GET"
-  ],
-  "url": {
-    "paths": [
-      "/schema/dynamicfields",
-      "/schema/dynamicfields/{name}",
-      "/schema/fieldtypes",
-      "/schema/fieldtypes/{name}"
-    ],
-    "params":{
-      "showDefaults":{
-        "type":"boolean",
-        "description":"If true, all default field properties from each field's 
field type will be included in the response (e.g.   tokenized  for   
solr.TextField). If false, only explicitly specified field properties will be 
included."
-      }
-    }
-  }
-}
diff --git a/solr/solrj/src/resources/apispec/core.SchemaRead.fields.json 
b/solr/solrj/src/resources/apispec/core.SchemaRead.fields.json
deleted file mode 100644
index d2ad02b..0000000
--- a/solr/solrj/src/resources/apispec/core.SchemaRead.fields.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
-  "documentation": "https://solr.apache.org/guide/schema-api.html#list-fields";,
-  "description": "Get only the fields defined in the schema.",
-  "methods": [
-    "GET"
-  ],
-  "url": {
-    "paths": [
-      "/schema/fields",
-      "/schema/fields/{name}"
-    ],
-    "params": {
-      "wt": {
-         "type": "string",
-         "description": "The format of the response. Valid options are xml or 
json.",
-         "default": "json"
-      },
-      "fl": {
-         "type": "string",
-         "description": "A comma- or space-separated list fields to return. If 
not specified, all fields will be returned. Note a single field can be 
requested by adding the field name to the endpoint."
-      },
-      "includeDynamic": {
-        "type": "boolean",
-        "description": "If true, dynamic fields will be returned in the 
response.",
-        "default": false
-      },
-      "showDefaults": {
-        "type": "boolean",
-        "description": "If true, all field properties from each field's field 
type will be included in the response, even if they are not explicitly defined 
on the field. If false, only explicitly defined field properties will be 
included.",
-        "default": false
-      }
-    }
-  }
-}
diff --git a/solr/solrj/src/resources/apispec/core.SchemaRead.json 
b/solr/solrj/src/resources/apispec/core.SchemaRead.json
deleted file mode 100644
index 756342b..0000000
--- a/solr/solrj/src/resources/apispec/core.SchemaRead.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-  "documentation": "https://solr.apache.org/guide/schema-api.html";,
-  "methods": [
-    "GET"
-  ],
-  "url": {
-    "paths": [
-      "/schema",
-      "/schema/name",
-      "/schema/uniquekey",
-      "/schema/version",
-      "/schema/similarity",
-      "/schema/solrqueryparser",
-      "/schema/zkversion"
-    ]
-  }
-}

Reply via email to