dsmiley commented on a change in pull request #994: SOLR-13662: Package Manager (CLI) URL: https://github.com/apache/lucene-solr/pull/994#discussion_r345570908
########## File path: solr/core/src/java/org/apache/solr/packagemanager/PackageUtils.java ########## @@ -90,52 +88,123 @@ public static void postFile(SolrClient client, ByteBuffer buffer, String name, S } } - public static String getStringFromStream(String url) { - return get(url); + /** + * Download JSON from the url and deserialize into klass. + */ + public static <T> T getJson(HttpClient client, String url, Class<T> klass) { + try { + return new ObjectMapper().readValue(getJson(client, url), klass); + } catch (IOException e) { + throw new RuntimeException(e); + } } - public static String get(String url) { - try (CloseableHttpClient client = PackageUtils.createTrustAllHttpClientBuilder()) { - HttpGet httpGet = new HttpGet(url); - httpGet.setHeader("Content-type", "application/json"); - - CloseableHttpResponse response = client.execute(httpGet); - - try { - HttpEntity rspEntity = response.getEntity(); - if (rspEntity != null) { - InputStream is = rspEntity.getContent(); - StringWriter writer = new StringWriter(); - IOUtils.copy(is, writer, "UTF-8"); - String results = writer.toString(); - - return(results); - } - } catch (IOException e) { - e.printStackTrace(); + /** + * Search through the list of jar files for a given file. Returns string of + * the file contents or null if file wasn't found. This is suitable for looking + * for manifest or property files within pre-downloaded jar files. + */ + public static String getFileFromArtifacts(List<Path> jars, String filename) { Review comment: I suggest appending "AsString" to the name. Maybe replace "Artifacts" with "Jars" at your discretion. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org