From f47a41472402354bcbea8d4699b78463b42ae254 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Tue, 17 Jul 2012 19:13:58 +0200 Subject: Restore Api compatibility --- .../src/main/java/org/sonar/api/utils/HttpDownloader.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sonar-plugin-api') 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); } -- cgit v1.2.3