Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16825: Migrate v2 definitions to 'api' module, pt 6 (#1978)

Jason Gerlowskib74fcaf7ce28
diff --git a/solr/api/src/java/org/apache/solr/client/api/endpoint/DeleteShardApi.java b/solr/api/src/java/org/apache/solr/client/api/endpoint/DeleteShardApi.java
new file mode 100644
index 00000000000..935803f7ca7
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/DeleteShardApi.java
@@ -0,0 +1,45 @@
+/*
+ * 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.client.api.endpoint;
+
+import static org.apache.solr.client.api.model.Constants.ASYNC;
+
+import io.swagger.v3.oas.annotations.Operation;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse;
+
+/** V2 API definition for deleting a particular shard from its collection. */
+@Path("/collections/{collectionName}/shards/{shardName}")
+public interface DeleteShardApi {
+
+ @DELETE
+ @Operation(
+ summary = "Delete an existing shard",
+ tags = {"shards"})
+ SubResponseAccumulatingJerseyResponse deleteShard(
+ @PathParam("collectionName") String collectionName,
+ @PathParam("shardName") String shardName,
+ @QueryParam("deleteInstanceDir") Boolean deleteInstanceDir,
+ @QueryParam("deleteDataDir") Boolean deleteDataDir,
+ @QueryParam("deleteIndex") Boolean deleteIndex,
+ @QueryParam("followAliases") Boolean followAliases,
+ @QueryParam(ASYNC) String asyncId)
+ throws Exception;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java b/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java
new file mode 100644
index 00000000000..c0102a26c4b
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java
@@ -0,0 +1,85 @@
+/*
+ * 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.client.api.endpoint;
+
+import static org.apache.solr.client.api.util.Constants.STORE_PATH_PREFIX;
+
+import io.swagger.v3.oas.annotations.Operation;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import org.apache.solr.client.api.model.SchemaInfoResponse;
+import org.apache.solr.client.api.model.SchemaNameResponse;
+import org.apache.solr.client.api.model.SchemaSimilarityResponse;
+import org.apache.solr.client.api.model.SchemaUniqueKeyResponse;
+import org.apache.solr.client.api.model.SchemaVersionResponse;
+import org.apache.solr.client.api.model.SchemaZkVersionResponse;
+import org.apache.solr.client.api.util.StoreApiParameters;
+
+@Path(STORE_PATH_PREFIX + "/schema")
+public interface GetSchemaApi {
+
+ @GET
+ @StoreApiParameters
+ @Operation(
+ summary = "Fetch the entire schema of the specified core or collection",
+ tags = {"schema"})
+ SchemaInfoResponse getSchemaInfo();
+
+ @GET
+ @Path("/name")
+ @StoreApiParameters
+ @Operation(
+ summary = "Get the name of the schema used by the specified core or collection",
+ tags = {"schema"})
+ SchemaNameResponse getSchemaName() throws Exception;
+
+ @GET
+ @Path("/similarity")
+ @StoreApiParameters
+ @Operation(
+ summary = "Get the default similarity configuration used by the specified core or collection",
+ tags = {"schema"})
+ SchemaSimilarityResponse getSchemaSimilarity();
+
+ @GET
+ @Path("/uniquekey")
+ @StoreApiParameters
+ @Operation(
+ summary = "Fetch the uniquekey of the specified core or collection",
+ tags = {"schema"})
+ SchemaUniqueKeyResponse getSchemaUniqueKey();
+
+ @GET
+ @Path("/version")
+ @StoreApiParameters
+ @Operation(
+ summary = "Fetch the schema version currently used by the specified core or collection",
+ tags = {"schema"})
+ SchemaVersionResponse getSchemaVersion();
+
+ @GET
+ @Path("/zkversion")
+ @StoreApiParameters
+ @Operation(
+ summary = "Fetch the schema version currently used by the specified core or collection",
+ tags = {"schema"})
+ SchemaZkVersionResponse getSchemaZkVersion(
+ @DefaultValue("-1") @QueryParam("refreshIfBelowVersion") Integer refreshIfBelowVersion)
+ throws Exception;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaInfoResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaInfoResponse.java
new file mode 100644
index 00000000000..9a6fede6a3c
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaInfoResponse.java
@@ -0,0 +1,29 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Map;
+
+public class SchemaInfoResponse extends SolrJerseyResponse {
+ // TODO The schema response is quite complicated, so for the moment it's sufficient to record it
+ // here only as a Map. However, if SOLR-16825 is tackled then there will be a lot of value in
+ // describing this response format more accurately so that clients can navigate the contents
+ // without lots of map fetching and casting.
+ @JsonProperty("schema")
+ public Map<String, Object> schema;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaNameResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaNameResponse.java
new file mode 100644
index 00000000000..b8431424285
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaNameResponse.java
@@ -0,0 +1,24 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class SchemaNameResponse extends SolrJerseyResponse {
+ @JsonProperty("name")
+ public String name;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaSimilarityResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaSimilarityResponse.java
new file mode 100644
index 00000000000..56c34ba6f03
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaSimilarityResponse.java
@@ -0,0 +1,28 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class SchemaSimilarityResponse extends SolrJerseyResponse {
+ // TODO The schema response is quite complicated, so for the moment it's sufficient to record it
+ // here only as a Map. However, if SOLR-16825 is tackled then there will be a lot of value in
+ // describing this response format more accurately so that clients can navigate the contents
+ // without lots of map fetching and casting.
+ @JsonProperty("similarity")
+ public Object similarity;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaUniqueKeyResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaUniqueKeyResponse.java
new file mode 100644
index 00000000000..760c2f60e24
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaUniqueKeyResponse.java
@@ -0,0 +1,24 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class SchemaUniqueKeyResponse extends SolrJerseyResponse {
+ @JsonProperty("uniqueKey")
+ public String uniqueKey;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaVersionResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaVersionResponse.java
new file mode 100644
index 00000000000..27073048cf7
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaVersionResponse.java
@@ -0,0 +1,24 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class SchemaVersionResponse extends SolrJerseyResponse {
+ @JsonProperty("version")
+ public float version;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/SchemaZkVersionResponse.java b/solr/api/src/java/org/apache/solr/client/api/model/SchemaZkVersionResponse.java
new file mode 100644
index 00000000000..bfa60704282
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SchemaZkVersionResponse.java
@@ -0,0 +1,23 @@
+/*
+ * 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.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class SchemaZkVersionResponse extends SolrJerseyResponse {
+ @JsonProperty public int zkversion;
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/model/StoreType.java b/solr/api/src/java/org/apache/solr/client/api/model/StoreType.java
new file mode 100644
index 00000000000..9e88a289485
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/StoreType.java
@@ -0,0 +1,22 @@
+/*
+ * 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.client.api.model;
+
+public enum StoreType {
+ COLLECTION,
+ CORE
+}
diff --git a/solr/api/src/java/org/apache/solr/client/api/util/Constants.java b/solr/api/src/java/org/apache/solr/client/api/util/Constants.java
index 1dbd6e61a6c..f8368a7b19b 100644
--- a/solr/api/src/java/org/apache/solr/client/api/util/Constants.java
+++ b/solr/api/src/java/org/apache/solr/client/api/util/Constants.java
@@ -22,5 +22,10 @@ public class Constants {
/* Private ctor prevents instantiation */
}
+ public static final String STORE_TYPE_PATH_PARAMETER = "storeType";
+ public static final String STORE_NAME_PATH_PARAMETER = "storeName";
+ public static final String STORE_PATH_PREFIX =
+ "/{" + STORE_TYPE_PATH_PARAMETER + ":cores|collections}/{" + STORE_NAME_PATH_PARAMETER + "}";
+
public static final String BINARY_CONTENT_TYPE_V2 = "application/vnd.apache.solr.javabin";
}
diff --git a/solr/api/src/java/org/apache/solr/client/api/util/StoreApiParameters.java b/solr/api/src/java/org/apache/solr/client/api/util/StoreApiParameters.java
new file mode 100644
index 00000000000..f13a639e356
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/util/StoreApiParameters.java
@@ -0,0 +1,45 @@
+/*
+ * 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.client.api.util;
+
+import static org.apache.solr.client.api.util.Constants.STORE_NAME_PATH_PARAMETER;
+import static org.apache.solr.client.api.util.Constants.STORE_TYPE_PATH_PARAMETER;
+
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.solr.client.api.model.StoreType;
+
+/**
+ * Concisely collects the parameters shared by APIs that interact with contents of a specific
+ * core/collection.
+ *
+ * <p>Used primarily as a way to avoid duplicating these parameter definitions on each relevant
+ * interface method in {@link org.apache.solr.client.api.endpoint}
+ */
+@Target({ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@Parameter(
+ name = STORE_TYPE_PATH_PARAMETER,
+ in = ParameterIn.PATH,
+ schema = @Schema(implementation = StoreType.class, enumAsRef = true))
+@Parameter(name = STORE_NAME_PATH_PARAMETER, in = ParameterIn.PATH)
+public @interface StoreApiParameters {}
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 58a2ad1890a..6d8e7c319bf 100644
--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
@@ -41,9 +41,8 @@ import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.handler.admin.api.GetSchemaAPI;
+import org.apache.solr.handler.admin.api.GetSchema;
import org.apache.solr.handler.admin.api.GetSchemaFieldAPI;
-import org.apache.solr.handler.admin.api.GetSchemaZkVersionAPI;
import org.apache.solr.handler.admin.api.SchemaBulkModifyAPI;
import org.apache.solr.handler.api.V2ApiUtils;
import org.apache.solr.request.SolrQueryRequest;
@@ -122,38 +121,42 @@ public class SchemaHandler extends RequestHandlerBase
case "/schema":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
- rsp, new GetSchemaAPI(req.getCore().getLatestSchema()).getSchemaInfo());
+ rsp, new GetSchema(req.getCore(), req.getCore().getLatestSchema()).getSchemaInfo());
break;
}
case "/schema/version":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
- rsp, new GetSchemaAPI(req.getCore().getLatestSchema()).getSchemaVersion());
+ rsp,
+ new GetSchema(req.getCore(), req.getCore().getLatestSchema()).getSchemaVersion());
break;
}
case "/schema/uniquekey":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
- rsp, new GetSchemaAPI(req.getCore().getLatestSchema()).getSchemaUniqueKey());
+ rsp,
+ new GetSchema(req.getCore(), req.getCore().getLatestSchema()).getSchemaUniqueKey());
break;
}
case "/schema/similarity":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
- rsp, new GetSchemaAPI(req.getCore().getLatestSchema()).getSchemaSimilarity());
+ rsp,
+ new GetSchema(req.getCore(), req.getCore().getLatestSchema())
+ .getSchemaSimilarity());
break;
}
case "/schema/name":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
- rsp, new GetSchemaAPI(req.getCore().getLatestSchema()).getSchemaName());
+ rsp, new GetSchema(req.getCore(), req.getCore().getLatestSchema()).getSchemaName());
break;
}
case "/schema/zkversion":
{
V2ApiUtils.squashIntoSolrResponseWithoutHeader(
rsp,
- new GetSchemaZkVersionAPI(req.getCore())
+ new GetSchema(req.getCore(), req.getCore().getLatestSchema())
.getSchemaZkVersion(req.getParams().getInt("refreshIfBelowVersion", -1)));
break;
}
@@ -291,7 +294,7 @@ public class SchemaHandler extends RequestHandlerBase
@Override
public Collection<Class<? extends JerseyResource>> getJerseyResources() {
- return List.of(GetSchemaAPI.class, GetSchemaFieldAPI.class, GetSchemaZkVersionAPI.class);
+ return List.of(GetSchema.class, GetSchemaFieldAPI.class);
}
@Override
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 0ed22f2f065..f01e8efa02c 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
@@ -186,7 +186,7 @@ import org.apache.solr.handler.admin.api.DeleteCollectionSnapshot;
import org.apache.solr.handler.admin.api.DeleteNode;
import org.apache.solr.handler.admin.api.DeleteReplica;
import org.apache.solr.handler.admin.api.DeleteReplicaProperty;
-import org.apache.solr.handler.admin.api.DeleteShardAPI;
+import org.apache.solr.handler.admin.api.DeleteShard;
import org.apache.solr.handler.admin.api.ForceLeader;
import org.apache.solr.handler.admin.api.InstallShardData;
import org.apache.solr.handler.admin.api.ListAliases;
@@ -719,7 +719,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
DELETESHARD_OP(
DELETESHARD,
(req, rsp, h) -> {
- DeleteShardAPI.invokeWithV1Params(h.coreContainer, req, rsp);
+ DeleteShard.invokeWithV1Params(h.coreContainer, req, rsp);
return null;
}),
FORCELEADER_OP(
@@ -1372,7 +1372,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
DeleteCollection.class,
DeleteReplica.class,
DeleteReplicaProperty.class,
- DeleteShardAPI.class,
+ DeleteShard.class,
ForceLeader.class,
InstallShardData.class,
ListCollections.class,
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShard.java
similarity index 85%
rename from solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java
rename to solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShard.java
index 593e6ed5e81..2d627162e7d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShard.java
@@ -30,10 +30,7 @@ import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PER
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
+import org.apache.solr.client.api.endpoint.DeleteShardApi;
import org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.params.CollectionParams;
@@ -44,32 +41,31 @@ import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
/**
- * V2 API for deleting a particular shard from its collection.
+ * V2 API implementation for deleting a particular shard from its collection.
*
* <p>This API (DELETE /v2/collections/collectionName/shards/shardName) is analogous to the v1
* /admin/collections?action=DELETESHARD command.
*/
-@Path("/collections/{collectionName}/shards/{shardName}")
-public class DeleteShardAPI extends AdminAPIBase {
+public class DeleteShard extends AdminAPIBase implements DeleteShardApi {
@Inject
- public DeleteShardAPI(
+ public DeleteShard(
CoreContainer coreContainer,
SolrQueryRequest solrQueryRequest,
SolrQueryResponse solrQueryResponse) {
super(coreContainer, solrQueryRequest, solrQueryResponse);
}
- @DELETE
+ @Override
@PermissionName(COLL_EDIT_PERM)
public SubResponseAccumulatingJerseyResponse deleteShard(
- @PathParam("collectionName") String collectionName,
- @PathParam("shardName") String shardName,
- @QueryParam(DELETE_INSTANCE_DIR) Boolean deleteInstanceDir,
- @QueryParam(DELETE_DATA_DIR) Boolean deleteDataDir,
- @QueryParam(DELETE_INDEX) Boolean deleteIndex,
- @QueryParam(FOLLOW_ALIASES) Boolean followAliases,
- @QueryParam(ASYNC) String asyncId)
+ String collectionName,
+ String shardName,
+ Boolean deleteInstanceDir,
+ Boolean deleteDataDir,
+ Boolean deleteIndex,
+ Boolean followAliases,
+ String asyncId)
throws Exception {
final var response = instantiateJerseyResponse(SubResponseAccumulatingJerseyResponse.class);
ensureRequiredParameterProvided(COLLECTION_PROP, collectionName);
@@ -120,8 +116,7 @@ public class DeleteShardAPI extends AdminAPIBase {
final var v1Params = solrQueryRequest.getParams();
v1Params.required().check(COLLECTION_PROP, SHARD_ID_PROP);
- final var deleteShardApi =
- new DeleteShardAPI(coreContainer, solrQueryRequest, solrQueryResponse);
+ final var deleteShardApi = new DeleteShard(coreContainer, solrQueryRequest, solrQueryResponse);
final var v2Response =
deleteShardApi.deleteShard(
v1Params.get(COLLECTION_PROP),
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchema.java
similarity index 52%
rename from solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaAPI.java
rename to solr/core/src/java/org/apache/solr/handler/admin/api/GetSchema.java
index b474a9c80c2..3e12805e3cc 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchema.java
@@ -17,35 +17,41 @@
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.Map;
+import java.lang.invoke.MethodHandles;
import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
import org.apache.solr.api.JerseyResource;
-import org.apache.solr.client.api.model.SolrJerseyResponse;
+import org.apache.solr.client.api.endpoint.GetSchemaApi;
+import org.apache.solr.client.api.model.SchemaInfoResponse;
+import org.apache.solr.client.api.model.SchemaNameResponse;
+import org.apache.solr.client.api.model.SchemaSimilarityResponse;
+import org.apache.solr.client.api.model.SchemaUniqueKeyResponse;
+import org.apache.solr.client.api.model.SchemaVersionResponse;
+import org.apache.solr.client.api.model.SchemaZkVersionResponse;
+import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.jersey.PermissionName;
import org.apache.solr.schema.IndexSchema;
+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;
+
+public class GetSchema extends JerseyResource implements GetSchemaApi {
-@Path("/{a:cores|collections}/{collectionName}/schema")
-public class GetSchemaAPI extends JerseyResource {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected final IndexSchema indexSchema;
+ protected final SolrCore solrCore;
@Inject
- public GetSchemaAPI(IndexSchema indexSchema) {
+ public GetSchema(SolrCore solrCore, IndexSchema indexSchema) {
+ this.solrCore = solrCore;
this.indexSchema = indexSchema;
}
- @GET
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+ @Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
public SchemaInfoResponse getSchemaInfo() {
final var response = instantiateJerseyResponse(SchemaInfoResponse.class);
@@ -55,18 +61,7 @@ public class GetSchemaAPI extends JerseyResource {
return response;
}
- public static class SchemaInfoResponse extends SolrJerseyResponse {
- // TODO The schema response is quite complicated, so for the moment it's sufficient to record it
- // here only as a Map. However, if SOLR-16825 is tackled then there will be a lot of value in
- // describing this response format more accurately so that clients can navigate the contents
- // without lots of map fetching and casting.
- @JsonProperty("schema")
- public Map<String, Object> schema;
- }
-
- @GET
- @Path("/name")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+ @Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
public SchemaNameResponse getSchemaName() throws Exception {
final SchemaNameResponse response = instantiateJerseyResponse(SchemaNameResponse.class);
@@ -78,14 +73,7 @@ public class GetSchemaAPI extends JerseyResource {
return response;
}
- public static class SchemaNameResponse extends SolrJerseyResponse {
- @JsonProperty("name")
- public String name;
- }
-
- @GET
- @Path("/similarity")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+ @Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
public SchemaSimilarityResponse getSchemaSimilarity() {
final var response = instantiateJerseyResponse(SchemaSimilarityResponse.class);
@@ -95,18 +83,7 @@ public class GetSchemaAPI extends JerseyResource {
return response;
}
- public static class SchemaSimilarityResponse extends SolrJerseyResponse {
- // TODO The schema response is quite complicated, so for the moment it's sufficient to record it
- // here only as a Map. However, if SOLR-16825 is tackled then there will be a lot of value in
- // describing this response format more accurately so that clients can navigate the contents
- // without lots of map fetching and casting.
- @JsonProperty("similarity")
- public SimpleOrderedMap<Object> similarity;
- }
-
- @GET
- @Path("/uniquekey")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+ @Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
public SchemaUniqueKeyResponse getSchemaUniqueKey() {
final var response = instantiateJerseyResponse(SchemaUniqueKeyResponse.class);
@@ -116,14 +93,7 @@ public class GetSchemaAPI extends JerseyResource {
return response;
}
- public static class SchemaUniqueKeyResponse extends SolrJerseyResponse {
- @JsonProperty("uniqueKey")
- public String uniqueKey;
- }
-
- @GET
- @Path("/version")
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, BINARY_CONTENT_TYPE_V2})
+ @Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
public SchemaVersionResponse getSchemaVersion() {
final var response = instantiateJerseyResponse(SchemaVersionResponse.class);
@@ -133,8 +103,29 @@ public class GetSchemaAPI extends JerseyResource {
return response;
}
- public static class SchemaVersionResponse extends SolrJerseyResponse {
- @JsonProperty("version")
- public float version;
+ @Override
+ @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+ public SchemaZkVersionResponse getSchemaZkVersion(Integer refreshIfBelowVersion)
+ throws Exception {
+ final SchemaZkVersionResponse response =
+ instantiateJerseyResponse(SchemaZkVersionResponse.class);
+ int zkVersion = -1;
+ if (solrCore.getLatestSchema() instanceof ManagedIndexSchema) {
+ ManagedIndexSchema managed = (ManagedIndexSchema) solrCore.getLatestSchema();
+ zkVersion = managed.getSchemaZkVersion();
+ if (refreshIfBelowVersion != -1 && zkVersion < refreshIfBelowVersion) {
+ log.info(
+ "REFRESHING SCHEMA (refreshIfBelowVersion={}, currentVersion={}) before returning version!",
+ refreshIfBelowVersion,
+ zkVersion);
+ ZkSolrResourceLoader zkSolrResourceLoader =
+ (ZkSolrResourceLoader) solrCore.getResourceLoader();
+ ZkIndexSchemaReader zkIndexSchemaReader = zkSolrResourceLoader.getZkIndexSchemaReader();
+ managed = zkIndexSchemaReader.refreshSchemaFromZk(refreshIfBelowVersion);
+ zkVersion = managed.getSchemaZkVersion();
+ }
+ }
+ response.zkversion = zkVersion;
+ return response;
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java
deleted file mode 100644
index 9a97af7b3eb..00000000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 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.client.api.model.SolrJerseyResponse;
-import org.apache.solr.cloud.ZkSolrResourceLoader;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.jersey.PermissionName;
-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)
- throws Exception {
- final SchemaZkVersionResponse response =
- instantiateJerseyResponse(SchemaZkVersionResponse.class);
- int zkVersion = -1;
- if (solrCore.getLatestSchema() instanceof ManagedIndexSchema) {
- ManagedIndexSchema managed = (ManagedIndexSchema) solrCore.getLatestSchema();
- zkVersion = managed.getSchemaZkVersion();
- if (refreshIfBelowVersion != -1 && zkVersion < refreshIfBelowVersion) {
- log.info(
- "REFRESHING SCHEMA (refreshIfBelowVersion={}, currentVersion={}) before returning version!",
- refreshIfBelowVersion,
- zkVersion);
- ZkSolrResourceLoader zkSolrResourceLoader =
- (ZkSolrResourceLoader) solrCore.getResourceLoader();
- ZkIndexSchemaReader zkIndexSchemaReader = zkSolrResourceLoader.getZkIndexSchemaReader();
- managed = zkIndexSchemaReader.refreshSchemaFromZk(refreshIfBelowVersion);
- zkVersion = managed.getSchemaZkVersion();
- }
- }
- response.zkversion = zkVersion;
- return response;
- }
-
- public static class SchemaZkVersionResponse extends SolrJerseyResponse {
- @JsonProperty("zkversion")
- public int zkversion;
- }
-}
diff --git a/solr/core/src/test/org/apache/solr/api/JerseyResourceTest.java b/solr/core/src/test/org/apache/solr/api/JerseyResourceTest.java
index 5e6f193c4e6..1d1110340e8 100644
--- a/solr/core/src/test/org/apache/solr/api/JerseyResourceTest.java
+++ b/solr/core/src/test/org/apache/solr/api/JerseyResourceTest.java
@@ -23,7 +23,7 @@ import static org.apache.solr.jersey.container.ContainerRequestUtils.DEFAULT_SEC
import java.net.URI;
import javax.ws.rs.container.ContainerRequestContext;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.handler.admin.api.GetSchemaAPI;
+import org.apache.solr.client.api.model.SchemaNameResponse;
import org.glassfish.jersey.internal.MapPropertiesDelegate;
import org.glassfish.jersey.server.ContainerRequest;
import org.junit.Test;
@@ -38,12 +38,12 @@ public class JerseyResourceTest extends SolrTestCaseJ4 {
resource.containerRequestContext = requestContext;
assertTrue(requestContext.getPropertyNames().isEmpty());
- final GetSchemaAPI.SchemaNameResponse returned =
- resource.instantiateJerseyResponse(GetSchemaAPI.SchemaNameResponse.class);
+ final SchemaNameResponse returned =
+ resource.instantiateJerseyResponse(SchemaNameResponse.class);
assertTrue(requestContext.getPropertyNames().contains(SOLR_JERSEY_RESPONSE));
- final GetSchemaAPI.SchemaNameResponse stashed =
- (GetSchemaAPI.SchemaNameResponse) requestContext.getProperty(SOLR_JERSEY_RESPONSE);
+ final SchemaNameResponse stashed =
+ (SchemaNameResponse) requestContext.getProperty(SOLR_JERSEY_RESPONSE);
assertEquals(stashed, returned);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/DeleteShardAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/DeleteShardAPITest.java
index c821bcb68cc..e26653e6d89 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/DeleteShardAPITest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/DeleteShardAPITest.java
@@ -30,7 +30,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.junit.Test;
-/** Unit tests for {@link DeleteShardAPI} */
+/** Unit tests for {@link DeleteShard} */
public class DeleteShardAPITest extends SolrTestCaseJ4 {
@Test
public void testReportsErrorIfCollectionNameMissing() {
@@ -38,7 +38,7 @@ public class DeleteShardAPITest extends SolrTestCaseJ4 {
expectThrows(
SolrException.class,
() -> {
- final var api = new DeleteShardAPI(null, null, null);
+ final var api = new DeleteShard(null, null, null);
api.deleteShard(null, "someShard", null, null, null, null, null);
});
@@ -52,7 +52,7 @@ public class DeleteShardAPITest extends SolrTestCaseJ4 {
expectThrows(
SolrException.class,
() -> {
- final var api = new DeleteShardAPI(null, null, null);
+ final var api = new DeleteShard(null, null, null);
api.deleteShard("someCollection", null, null, null, null, null, null);
});
@@ -63,7 +63,7 @@ public class DeleteShardAPITest extends SolrTestCaseJ4 {
@Test
public void testCreateRemoteMessageAllProperties() {
final var remoteMessage =
- DeleteShardAPI.createRemoteMessage(
+ DeleteShard.createRemoteMessage(
"someCollName", "someShardName", true, false, true, false, "someAsyncId")
.getProperties();
@@ -81,7 +81,7 @@ public class DeleteShardAPITest extends SolrTestCaseJ4 {
@Test
public void testMissingValuesExcludedFromRemoteMessage() {
final var remoteMessage =
- DeleteShardAPI.createRemoteMessage(
+ DeleteShard.createRemoteMessage(
"someCollName", "someShardName", null, null, null, null, null)
.getProperties();
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaAPITest.java
index 69e8a9ba686..531f2379dff 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaAPITest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaAPITest.java
@@ -21,9 +21,11 @@ import static org.mockito.Mockito.when;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.api.model.SchemaNameResponse;
import org.apache.solr.client.solrj.response.schema.SchemaResponse;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.SchemaHandler;
import org.apache.solr.handler.api.V2ApiUtils;
import org.apache.solr.schema.IndexSchema;
@@ -33,18 +35,21 @@ import org.apache.solr.schema.StrField;
import org.junit.Before;
import org.junit.Test;
-/** Unit tests for {@link GetSchemaAPI} */
+/** Unit tests for {@link GetSchema} */
public class GetSchemaAPITest extends SolrTestCaseJ4 {
+ private SolrCore mockCore;
private IndexSchema mockSchema;
- private GetSchemaAPI api;
+ private GetSchema api;
@Before
public void setUpMocks() {
assumeWorkingMockito();
+ mockCore = mock(SolrCore.class);
mockSchema = mock(IndexSchema.class);
- api = new GetSchemaAPI(mockSchema);
+ when(mockCore.getLatestSchema()).thenReturn(mockSchema);
+ api = new GetSchema(mockCore, mockSchema);
}
@Test
@@ -63,7 +68,7 @@ public class GetSchemaAPITest extends SolrTestCaseJ4 {
public void testLooksUpNameFromLatestCoreSchema() throws Exception {
when(mockSchema.getSchemaName()).thenReturn("expectedSchemaName");
- final GetSchemaAPI.SchemaNameResponse response = api.getSchemaName();
+ final SchemaNameResponse response = api.getSchemaName();
assertEquals("expectedSchemaName", response.name);
assertNull(response.error);
@@ -72,16 +77,16 @@ public class GetSchemaAPITest extends SolrTestCaseJ4 {
/**
* 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
+ * <p>{@link SchemaHandler} uses the v2 {@link GetSchema} (and its response class {@link
+ * 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() {
final NamedList<Object> squashedResponse = new NamedList<>();
- final GetSchemaAPI.SchemaNameResponse typedResponse = new GetSchemaAPI.SchemaNameResponse();
+ final SchemaNameResponse typedResponse = new SchemaNameResponse();
typedResponse.name = "someName";
V2ApiUtils.squashIntoNamedList(squashedResponse, typedResponse);
@@ -92,6 +97,7 @@ public class GetSchemaAPITest extends SolrTestCaseJ4 {
}
@Test
+ @SuppressWarnings("unchecked")
public void testReliesOnIndexSchemaWhenFetchingSimilarity() {
final var map = new SimpleOrderedMap<Object>();
map.add("flagKey", "flagValue");
@@ -103,8 +109,9 @@ public class GetSchemaAPITest extends SolrTestCaseJ4 {
assertNotNull(response);
assertNotNull(response.similarity);
- assertEquals(1, response.similarity.size());
- assertEquals("flagValue", response.similarity.get("flagKey"));
+ final var similarityMap = (SimpleOrderedMap<Object>) response.similarity;
+ assertEquals(1, similarityMap.size());
+ assertEquals("flagValue", similarityMap.get("flagKey"));
}
@Test
@@ -126,4 +133,13 @@ public class GetSchemaAPITest extends SolrTestCaseJ4 {
assertNotNull(response);
assertEquals(123.456f, response.version, 0.1f);
}
+
+ @Test
+ public void testReturnsInvalidZkVersionWhenNotManagedIndexSchema() throws Exception {
+
+ final var response = api.getSchemaZkVersion(-1);
+
+ assertNotNull(response);
+ assertEquals(-1, response.zkversion);
+ }
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPITest.java
deleted file mode 100644
index b6476613fd2..00000000000
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPITest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.schema.IndexSchema;
-import org.junit.Before;
-import org.junit.Test;
-
-/** Unit tests for {@link GetSchemaZkVersionAPI} */
-public class GetSchemaZkVersionAPITest extends SolrTestCaseJ4 {
-
- private SolrCore mockCore;
- private IndexSchema mockSchema;
- private GetSchemaZkVersionAPI api;
-
- @Before
- public void setUpMocks() {
- assumeWorkingMockito();
-
- mockCore = mock(SolrCore.class);
- mockSchema = mock(IndexSchema.class);
- when(mockCore.getLatestSchema()).thenReturn(mockSchema);
- api = new GetSchemaZkVersionAPI(mockCore);
- }
-
- @Test
- public void testReturnsInvalidZkVersionWhenNotManagedIndexSchema() throws Exception {
-
- final var response = api.getSchemaZkVersion(-1);
-
- assertNotNull(response);
- assertEquals(-1, response.zkversion);
- }
-}
diff --git a/solr/solrj/src/resources/java-template/api.mustache b/solr/solrj/src/resources/java-template/api.mustache
index 7f40f2332d7..0767d51e09b 100644
--- a/solr/solrj/src/resources/java-template/api.mustache
+++ b/solr/solrj/src/resources/java-template/api.mustache
@@ -91,7 +91,7 @@ public class {{classname}} {
super(
SolrRequest.METHOD.valueOf("{{httpMethod}}"),
"{{{path}}}"{{#pathParams}}
- .replace("{" + "{{baseName}}" + "}", {{paramName}}){{/pathParams}}
+ .replace("{" + "{{baseName}}" + "}", {{paramName}}{{#isEnumRef}}.name(){{/isEnumRef}}){{/pathParams}}
);
{{#requiredParams}}