From: David Gageot Date: Tue, 17 Jul 2012 17:13:58 +0000 (+0200) Subject: Restore Api compatibility X-Git-Tag: 3.2~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f47a41472402354bcbea8d4699b78463b42ae254;p=sonarqube.git Restore Api compatibility --- diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java index f555cc72291..7b576266060 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java @@ -86,7 +86,7 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo System.setProperty("http.agent", userAgent); } - private static String getProxySynthesis(URI uri) { + public String getProxySynthesis(URI uri) { return getProxySynthesis(uri, ProxySelector.getDefault()); } @@ -160,6 +160,14 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo return readString(uri, Charset.forName(encoding)); } + public InputStream openStream(URI uri) { + try { + return new HttpInputSupplier(uri).getInput(); + } catch (Exception e) { + throw new SonarException("Fail to download the file: " + uri + " (" + getProxySynthesis(uri) + ")", e); + } + } + public void download(URI uri, File toFile) { try { Files.copy(new HttpInputSupplier(uri), toFile); @@ -169,7 +177,7 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo } } - private static SonarException failToDownload(URI uri, IOException e) { + private SonarException failToDownload(URI uri, IOException e) { return new SonarException(String.format("Fail to download the file: %s (%s)", uri, getProxySynthesis(uri)), e); }