mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1191689969


##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String 
coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " 
does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            
coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Hi Jason, thanks for the review! Glad most of it looks good.
   
   As for your comment on injecting the SolrCore, I'm not sure how this would 
be done in this API. The user specifies the `coreName` for which the API then 
uses to retrieve the SolrCore from the coreContainer. 
   
   Maybe I need to read more on Solr's Jersey Injections, but how would you 
inject the SolrCore in the constructor without knowing what `coreName` the user 
was asking for that is specified in the URI path?



-- 
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]

Reply via email to