| 71 | } |
| 72 | |
| 73 | protected String callGet(String url, String credentials) throws Exception { |
| 74 | URI uri = new URI(url.replace("+", "%20")); |
| 75 | String solrUrl = getSolrUrlFromUri(uri); |
| 76 | String path = uri.getPath(); |
| 77 | try (var solrClient = CLIUtils.getSolrClient(solrUrl, credentials)) { |
| 78 | // For path parameter we need the path without the root so from the second / char |
| 79 | // (because root can be configured) |
| 80 | // E.g. URL is http://localhost:8983/solr/admin/info/system path is |
| 81 | // /solr/admin/info/system and the path without root is /admin/info/system |
| 82 | var req = |
| 83 | new GenericSolrRequest( |
| 84 | SolrRequest.METHOD.GET, |
| 85 | path.substring(path.indexOf("/", path.indexOf("/") + 1)), |
| 86 | getSolrParamsFromUri(uri) // .add("indent", "true") |
| 87 | ); |
| 88 | // Using the "smart" solr parsers won't work, because they decode into Solr objects. |
| 89 | // When trying to re-write into JSON, the JSONWriter doesn't have the right info to print it |
| 90 | // correctly. |
| 91 | // All we want to do is pass the JSON response to the user, so do that. |
| 92 | req.setResponseParser(new JsonMapResponseParser()); |
| 93 | NamedList<Object> response = solrClient.request(req); |
| 94 | // pretty-print the response to stdout |
| 95 | CharArr arr = new CharArr(); |
| 96 | new JSONWriter(arr, 2).write(response.asMap(10)); |
| 97 | return arr.toString(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Get Solr base url with port if present and root from URI |