janhoy commented on a change in pull request #372:
URL: https://github.com/apache/solr/pull/372#discussion_r742757625



##########
File path: 
solr/core/src/java/org/apache/solr/handler/admin/ZookeeperReadAPI.java
##########
@@ -58,41 +59,44 @@
 
 public class ZookeeperReadAPI {
   private final CoreContainer coreContainer;
+  private SolrParams rawWtParams;
 
   public ZookeeperReadAPI(CoreContainer coreContainer) {
     this.coreContainer = coreContainer;
+    Map<String, String> map = new HashMap<>(1);
+    map.put(WT, "raw");
+    map.put(OMIT_HEADER, "true");
+    rawWtParams = new MapSolrParams(map);
   }
+
+  /**
+   * Request contents of a znode, except security.json
+   */
   @EndPoint(path = "/cluster/zk/data/*",
       method = SolrRequest.METHOD.GET,
       permission = ZK_READ_PERM)
   public void readNode(SolrQueryRequest req, SolrQueryResponse rsp) {
     String path = req.getPathTemplateValues().get("*");
     if (path == null || path.isEmpty()) path = "/";
-    byte[] d = null;
-    try {
-      d = coreContainer.getZkController().getZkClient().getData(path, null, 
null, false);
-    } catch (KeeperException.NoNodeException e) {
-      throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "No such 
node: " + path);
-    } catch (Exception e) {
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, 
"Unexpected error", e);
-    }
-    if (d == null || d.length == 0) {
-      rsp.add(path, null);
-      return;
-    }
-
-    Map<String, String> map = new HashMap<>(1);
-    map.put(WT, "raw");
-    map.put(OMIT_HEADER, "true");
-    req.setParams(SolrParams.wrapDefaults(new MapSolrParams(map), 
req.getParams()));
-
-    String mime = BinaryResponseParser.BINARY_CONTENT_TYPE;
+    req.setParams(SolrParams.wrapDefaults(rawWtParams, req.getParams()));
+    readNodeAndAddToResponse(path, rsp);
+  }
 
-    if (d[0] == '{') mime = CommonParams.JSON_MIME;
-    if (d[0] == '<' || d[1] == '?') mime = XMLResponseParser.XML_CONTENT_TYPE;
-    rsp.add(CONTENT, new ContentStreamBase.ByteArrayStream(d, null, mime));
+  /**
+   * Request contents of the security.json node
+   */
+  @EndPoint(path = "/cluster/zk/data/security.json",
+      method = SolrRequest.METHOD.GET,
+      permission = SECURITY_READ_PERM)
+  public void readSecurityJsonNode(SolrQueryRequest req, SolrQueryResponse 
rsp) {

Review comment:
       @noblepaul This actually worked. Solr chooses the most specific 
`@EndPoint` first, thus when I request `/security.json`, this method gets 
called, with a different permission. The other end point is the catch-all for 
all other paths.




-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to