janhoy commented on code in PR #1829:
URL: https://github.com/apache/solr/pull/1829#discussion_r1286929061


##########
solr/core/src/java/org/apache/solr/rest/RestManager.java:
##########
@@ -288,27 +288,31 @@ public void doInit(SolrQueryRequest solrRequest, 
SolrQueryResponse solrResponse)
       final String resourceId = resolveResourceId(solrRequest.getPath());
       managedResource = restManager.getManagedResourceOrNull(resourceId);
       if (managedResource == null) {
-        // see if we have a registered endpoint one-level up ...
-        int lastSlashAt = resourceId.lastIndexOf('/');
-        if (lastSlashAt != -1) {
-          String parentResourceId = resourceId.substring(0, lastSlashAt);
+        int lastSlashAt;
+        String parentResourceId;
+        String initialResourceId = resourceId;
+        // Check if we have a registered endpoint, going one level up each 
time...
+        do {
+          lastSlashAt = initialResourceId.lastIndexOf('/');
+          parentResourceId = resourceId.substring(0, lastSlashAt);
           log.info(
               "Resource not found for {}, looking for parent: {}", resourceId, 
parentResourceId);

Review Comment:
   This could be DEBUG level



##########
solr/core/src/java/org/apache/solr/rest/RestManager.java:
##########
@@ -288,27 +288,31 @@ public void doInit(SolrQueryRequest solrRequest, 
SolrQueryResponse solrResponse)
       final String resourceId = resolveResourceId(solrRequest.getPath());
       managedResource = restManager.getManagedResourceOrNull(resourceId);
       if (managedResource == null) {
-        // see if we have a registered endpoint one-level up ...
-        int lastSlashAt = resourceId.lastIndexOf('/');
-        if (lastSlashAt != -1) {
-          String parentResourceId = resourceId.substring(0, lastSlashAt);
+        int lastSlashAt;
+        String parentResourceId;
+        String initialResourceId = resourceId;
+        // Check if we have a registered endpoint, going one level up each 
time...
+        do {
+          lastSlashAt = initialResourceId.lastIndexOf('/');
+          parentResourceId = resourceId.substring(0, lastSlashAt);
           log.info(
               "Resource not found for {}, looking for parent: {}", resourceId, 
parentResourceId);
           managedResource = 
restManager.getManagedResourceOrNull(parentResourceId);
-          if (managedResource != null) {
-            // verify this resource supports child resources
-            if (!(managedResource instanceof 
ManagedResource.ChildResourceSupport)) {
-              String errMsg =
-                  String.format(
-                      Locale.ROOT,
-                      "%s does not support child resources!",
-                      managedResource.getResourceId());
-              throw new SolrException(ErrorCode.BAD_REQUEST, errMsg);
-            }
-
-            childId = resourceId.substring(lastSlashAt + 1);
-            log.info("Found parent resource {} for child: {}", 
parentResourceId, childId);
+          initialResourceId = parentResourceId;
+        } while (managedResource == null && initialResourceId.lastIndexOf("/") 
!= -1);
+        if (managedResource != null) {
+          // verify this resource supports child resources
+          if (!(managedResource instanceof 
ManagedResource.ChildResourceSupport)) {
+            String errMsg =
+                String.format(
+                    Locale.ROOT,
+                    "%s does not support child resources!",
+                    managedResource.getResourceId());
+            throw new SolrException(ErrorCode.BAD_REQUEST, errMsg);
           }
+
+          childId = resourceId.substring(lastSlashAt + 1);
+          log.info("Found parent resource {} for child: {}", parentResourceId, 
childId);

Review Comment:
   Put this as DEBUG level as well



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