*/
package org.sonar.batch.bootstrap;
+import com.google.common.base.Charsets;
+
import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.CharUtils;
String url = baseUrl + "/deploy/plugins/index.txt";
try {
LOG.debug("Downloading index of plugins");
- String indexContent = httpDownloader.downloadPlainText(new URI(url), "UTF-8");
+ String indexContent = httpDownloader.downloadPlainText(new URI(url), Charsets.UTF_8);
String[] rows = StringUtils.split(indexContent, CharUtils.LF);
List<RemotePlugin> remoteLocations = Lists.newArrayList();
for (String row : rows) {
}
}
- public String downloadPlainText(URI uri, String encoding) {
+ public String downloadPlainText(URI uri, Charset charset) {
InputStream input = null;
try {
HttpURLConnection connection = newHttpConnection(uri);
input = connection.getInputStream();
- return IOUtils.toString(input, encoding);
+ return IOUtils.toString(input, charset.name());
} catch (Exception e) {
throw new SonarException("Fail to download the file: " + uri + " (" + getProxySynthesis(uri) + ")", e);
@Override
String readString(URI uri, Charset charset) {
- return downloadPlainText(uri, charset.name());
+ return downloadPlainText(uri, charset);
}
private HttpURLConnection newHttpConnection(URI uri) throws IOException {