gerlowskija commented on code in PR #1682:
URL: https://github.com/apache/solr/pull/1682#discussion_r1221410361
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
Review Comment:
[-1] Looks like this file is missing the copyright header. Can you get the
header from (e.g.) GetSchemaAPI.java and copy in here please?
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrClassLoader;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.PluginInfo;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.pkg.PackageListeningClassLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.security.PermissionNameProvider;
+
+public class GetSchemaFieldAPI extends GetSchemaAPI {
Review Comment:
[0] Might be worth a small javadoc comment at the class level here to list
out what APIs are in this class.
[+1] Oh, neat - so this class inherits the class-level `@Path` annotation
from GetSchemaAPI? Cool.
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrClassLoader;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.PluginInfo;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.pkg.PackageListeningClassLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.security.PermissionNameProvider;
+
+public class GetSchemaFieldAPI extends GetSchemaAPI {
+
+ private final SolrParams params;
+
+ @Inject
+ public GetSchemaFieldAPI(IndexSchema indexSchema, SolrParams params) {
+ super(indexSchema);
+ this.params = params;
+ }
+
+ @GET
+ @Path("/fields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListFieldsResponse listSchemaFields() {
+ SchemaListFieldsResponse response =
instantiateJerseyResponse(SchemaListFieldsResponse.class);
+ final String realName = "fields";
+
+ response.fields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListFieldsResponse extends SolrJerseyResponse {
+ @JsonProperty("fields")
+ public Object fields;
Review Comment:
[Q] Should this really be typed as "Object"?
I totally understand if the response format is too complex to represent with
a more specific type. I've run into a few response fields where I punted and
left them as `Object` or `Map<String, Object>` due to complexity.
But, at least from what I thought I knew of this API, it seems like we could
go with `List<Object>`? Or are there some cases where the "fields" part of
this response isn't a list/array?
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrClassLoader;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.PluginInfo;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.pkg.PackageListeningClassLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.security.PermissionNameProvider;
+
+public class GetSchemaFieldAPI extends GetSchemaAPI {
+
+ private final SolrParams params;
+
+ @Inject
+ public GetSchemaFieldAPI(IndexSchema indexSchema, SolrParams params) {
+ super(indexSchema);
+ this.params = params;
+ }
+
+ @GET
+ @Path("/fields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListFieldsResponse listSchemaFields() {
+ SchemaListFieldsResponse response =
instantiateJerseyResponse(SchemaListFieldsResponse.class);
+ final String realName = "fields";
+
+ response.fields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListFieldsResponse extends SolrJerseyResponse {
+ @JsonProperty("fields")
+ public Object fields;
+ }
+
+ @GET
+ @Path("/fields/{fieldName}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaGetFieldInfoResponse getFieldInfo(@PathParam("fieldName")
String fieldName) {
+ SchemaGetFieldInfoResponse response =
+ instantiateJerseyResponse(SchemaGetFieldInfoResponse.class);
+ final String realName = "fields";
+
+ SimpleOrderedMap<Object> fieldInfo = retrieveFieldInfoOfType(realName,
fieldName, params);
+ if (fieldInfo != null) {
+ response.fieldInfo = fieldInfo;
+ return response;
+ }
+ throw new SolrException(
+ SolrException.ErrorCode.NOT_FOUND, "No such path /" + realName + "/" +
fieldName);
Review Comment:
[Q] I suspect this was just something you copied over from SchemaHandler,
but it might make sense to reword this error message to be more explicit in
saying that the field doesn't exist.
e.g.
```
throw new SolrException(
SolrException.ErrorCode.NOT_FOUND, "No such field [" + fieldName +
"]");
```
##########
solr/core/src/java/org/apache/solr/jersey/InjectionFactories.java:
##########
@@ -104,6 +106,24 @@ public IndexSchema provide() {
public void dispose(IndexSchema instance) {}
}
+ public static class ReuseFromContextSolrParamsFactory implements
Factory<SolrParams> {
Review Comment:
[+1] Technically, v2 code that needs the SolrParams could inject the
SolrQueryRequest and call `getParams`. So this injector isn't strictly
required.
But I'm a big fan of only injecting what you actually need - it makes the
code easier to understand, and really helps simplify unit tests. So 👍
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.solr.handler.admin.api;
Review Comment:
[-1] Ditto, re: missing copyright header.
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrClassLoader;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.PluginInfo;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.pkg.PackageListeningClassLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.security.PermissionNameProvider;
+
+public class GetSchemaFieldAPI extends GetSchemaAPI {
+
+ private final SolrParams params;
+
+ @Inject
+ public GetSchemaFieldAPI(IndexSchema indexSchema, SolrParams params) {
+ super(indexSchema);
+ this.params = params;
+ }
+
+ @GET
+ @Path("/fields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListFieldsResponse listSchemaFields() {
+ SchemaListFieldsResponse response =
instantiateJerseyResponse(SchemaListFieldsResponse.class);
+ final String realName = "fields";
+
+ response.fields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListFieldsResponse extends SolrJerseyResponse {
+ @JsonProperty("fields")
+ public Object fields;
+ }
+
+ @GET
+ @Path("/fields/{fieldName}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaGetFieldInfoResponse getFieldInfo(@PathParam("fieldName")
String fieldName) {
+ SchemaGetFieldInfoResponse response =
+ instantiateJerseyResponse(SchemaGetFieldInfoResponse.class);
Review Comment:
[0] Maybe it'd just be useless sanity-checking, but it might be good to
ensure that fieldName is non-null 🤷
##########
solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaAPITest.java:
##########
@@ -55,6 +59,38 @@ public void testReliesOnIndexSchemaWhenFetchingWholeSchema()
{
assertEquals("flagValue", response.schema.get("flagKey"));
}
+ @Test
+ public void testLooksUpNameFromLatestCoreSchema() throws Exception {
+ when(mockSchema.getSchemaName()).thenReturn("expectedSchemaName");
+
+ final GetSchemaAPI.SchemaNameResponse response = api.getSchemaName();
+
+ assertEquals("expectedSchemaName", response.name);
+ assertNull(response.error);
+ }
+
+ /**
+ * Test the v2 to v1 response mapping for /schema/name
+ *
+ * <p>{@link SchemaHandler} uses the v2 {@link GetSchemaAPI} (and its
response class {@link
+ * GetSchemaAPI.SchemaNameResponse}) internally to serve the v1 version of
this functionality. So
+ * it's important to make sure that our response stays compatible with SolrJ
- both because that's
+ * important in its own right and because that ensures we haven't
accidentally changed the v1
+ * response format.
+ */
+ @Test
+ public void testResponseCanBeParsedBySolrJ() {
Review Comment:
[+1] Great idea to test the SolrJ compatibility - I should've been doing
this in a lot of other places but hadn't thought of it.
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.lang.invoke.MethodHandles;
+import javax.inject.Inject;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkSolrResourceLoader;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.schema.ManagedIndexSchema;
+import org.apache.solr.schema.ZkIndexSchemaReader;
+import org.apache.solr.security.PermissionNameProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/{a:cores|collections}/{collectionName}/schema")
+public class GetSchemaZkVersionAPI extends JerseyResource {
Review Comment:
[Q] Curious: is there a reason that you had `GetSchemaFieldAPI` extend
`GetSchemaAPI`, but didn't do the same here?
(That's not a loaded question - I'm just curious)
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaFieldAPI.java:
##########
@@ -0,0 +1,255 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrClassLoader;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.PluginInfo;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.pkg.PackageListeningClassLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.security.PermissionNameProvider;
+
+public class GetSchemaFieldAPI extends GetSchemaAPI {
+
+ private final SolrParams params;
+
+ @Inject
+ public GetSchemaFieldAPI(IndexSchema indexSchema, SolrParams params) {
+ super(indexSchema);
+ this.params = params;
+ }
+
+ @GET
+ @Path("/fields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListFieldsResponse listSchemaFields() {
+ SchemaListFieldsResponse response =
instantiateJerseyResponse(SchemaListFieldsResponse.class);
+ final String realName = "fields";
+
+ response.fields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListFieldsResponse extends SolrJerseyResponse {
+ @JsonProperty("fields")
+ public Object fields;
+ }
+
+ @GET
+ @Path("/fields/{fieldName}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaGetFieldInfoResponse getFieldInfo(@PathParam("fieldName")
String fieldName) {
+ SchemaGetFieldInfoResponse response =
+ instantiateJerseyResponse(SchemaGetFieldInfoResponse.class);
+ final String realName = "fields";
+
+ SimpleOrderedMap<Object> fieldInfo = retrieveFieldInfoOfType(realName,
fieldName, params);
+ if (fieldInfo != null) {
+ response.fieldInfo = fieldInfo;
+ return response;
+ }
+ throw new SolrException(
+ SolrException.ErrorCode.NOT_FOUND, "No such path /" + realName + "/" +
fieldName);
+ }
+
+ public static class SchemaGetFieldInfoResponse extends SolrJerseyResponse {
+ @JsonProperty("field")
+ public SimpleOrderedMap<?> fieldInfo;
+ }
+
+ @GET
+ @Path("/copyfields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListCopyFieldsResponse listCopyFields() {
+ SchemaListCopyFieldsResponse response =
+ instantiateJerseyResponse(SchemaListCopyFieldsResponse.class);
+ final String realName = "copyfields";
+
+ response.copyFields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListCopyFieldsResponse extends SolrJerseyResponse {
+ @JsonProperty("copyFields")
+ public Object copyFields;
+ }
+
+ @GET
+ @Path("/dynamicfields")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListDynamicFieldsResponse listDynamicFields() {
+ SchemaListDynamicFieldsResponse response =
+ instantiateJerseyResponse(SchemaListDynamicFieldsResponse.class);
+ final String realName = "dynamicfields";
+
+ response.dynamicFields = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListDynamicFieldsResponse extends
SolrJerseyResponse {
+ @JsonProperty("dynamicFields")
+ public Object dynamicFields;
+ }
+
+ @GET
+ @Path("/dynamicfields/{fieldName}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(
+ @PathParam("fieldName") String fieldName) {
+ SchemaGetDynamicFieldInfoResponse response =
+ instantiateJerseyResponse(SchemaGetDynamicFieldInfoResponse.class);
+ final String realName = "dynamicfields";
+
+ SimpleOrderedMap<Object> dynamicFieldInfo =
+ retrieveFieldInfoOfType(realName, fieldName, params);
+ if (dynamicFieldInfo != null) {
+ response.dynamicFieldInfo = dynamicFieldInfo;
+ return response;
+ }
+ throw new SolrException(
+ SolrException.ErrorCode.NOT_FOUND, "No such path /" + realName + "/" +
fieldName);
+ }
+
+ public static class SchemaGetDynamicFieldInfoResponse extends
SolrJerseyResponse {
+ @JsonProperty("dynamicField")
+ public SimpleOrderedMap<?> dynamicFieldInfo;
+ }
+
+ @GET
+ @Path("/fieldtypes")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaListFieldTypesResponse listSchemaFieldTypes() {
+ SchemaListFieldTypesResponse response =
+ instantiateJerseyResponse(SchemaListFieldTypesResponse.class);
+ final String realName = "fieldtypes";
+
+ response.fieldTypes = listAllFieldsOfType(realName, params);
+
+ return response;
+ }
+
+ public static class SchemaListFieldTypesResponse extends SolrJerseyResponse {
+ @JsonProperty("fieldTypes")
+ public Object fieldTypes;
+ }
+
+ @GET
+ @Path("/fieldtypes/{fieldTypeName}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaGetFieldTypeInfoResponse getFieldTypeInfo(
+ @PathParam("fieldTypeName") String fieldTypeName) {
+ SchemaGetFieldTypeInfoResponse response =
+ instantiateJerseyResponse(SchemaGetFieldTypeInfoResponse.class);
+
+ final String realName = "fieldtypes";
+
+ SimpleOrderedMap<Object> fieldTypeInfo =
+ retrieveFieldInfoOfType(realName, fieldTypeName, params);
+ if (fieldTypeInfo != null) {
+ response.fieldTypeInfo = fieldTypeInfo;
+ return response;
+ }
+ throw new SolrException(
+ SolrException.ErrorCode.NOT_FOUND, "No such path /" + realName + "/" +
fieldTypeName);
+ }
+
+ public static class SchemaGetFieldTypeInfoResponse extends
SolrJerseyResponse {
+ @JsonProperty("fieldType")
+ public SimpleOrderedMap<?> fieldTypeInfo;
+ }
+
+ private Object listAllFieldsOfType(String realName, SolrParams params) {
+ String camelCaseRealName = IndexSchema.nameMapping.get(realName);
Review Comment:
[0] Mostly thinking aloud here, but I wonder what parameters the schema code
looks for in this `SolrParams` object. Obviously there's 'meta' below, but
there's probably others in `getNamedPropertyValues`.
The more explicit we can be about the accepted parameters, the easier this
code will be to read. And the nicer any sort of client code will be if we
start doing automated client generation (see SOLR-16835). If the number of
parameters is relatively small it might be worth calling each param out
explicitly in the API methods above, and then packaging them up in a
SolrParam to satisfy the IndexSchema call below.
##########
solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaFieldsAPITest.java:
##########
@@ -0,0 +1,133 @@
+package org.apache.solr.handler.admin.api;
Review Comment:
[-1] Ditto, re: missing copyright header
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.lang.invoke.MethodHandles;
+import javax.inject.Inject;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkSolrResourceLoader;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.schema.ManagedIndexSchema;
+import org.apache.solr.schema.ZkIndexSchemaReader;
+import org.apache.solr.security.PermissionNameProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/{a:cores|collections}/{collectionName}/schema")
+public class GetSchemaZkVersionAPI extends JerseyResource {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private SolrCore solrCore;
+
+ @Inject
+ public GetSchemaZkVersionAPI(SolrCore solrCore) {
+ this.solrCore = solrCore;
+ }
+
+ @GET
+ @Path("/zkversion")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML,
BINARY_CONTENT_TYPE_V2})
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaZkVersionResponse getSchemaZkVersion(
+ @DefaultValue("-1") @QueryParam("refreshIfBelowVersion") Integer
refreshIfBelowVersion)
Review Comment:
[+1] Good use of `@DefaultValue`, I need to be using that more...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]