summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-17 19:13:58 +0200
committerDavid Gageot <david@gageot.net>2012-07-17 19:27:28 +0200
commitf47a41472402354bcbea8d4699b78463b42ae254 (patch)
treebc245ad6d188438ae6d72e58c15ef9e8454bb247 /sonar-plugin-api
parentd3d7f253ecd6bb7cfa61e1e8d8fce10a7371e096 (diff)
downloadsonarqube-f47a41472402354bcbea8d4699b78463b42ae254.tar.gz
sonarqube-f47a41472402354bcbea8d4699b78463b42ae254.zip
Restore Api compatibility
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java12
1 files changed, 10 insertions, 2 deletions
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);
}