aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/pom.xml4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java29
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/RemotePluginFile.java10
-rw-r--r--sonar-core/src/test/java/org/sonar/core/plugins/RemotePluginTest.java2
4 files changed, 17 insertions, 28 deletions
diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml
index 1ec0ff42482..249bf40f460 100644
--- a/sonar-core/pom.xml
+++ b/sonar-core/pom.xml
@@ -34,6 +34,10 @@
<artifactId>sonar-update-center-common</artifactId>
</dependency>
<dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-home</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
index 75be9c70a8a..dc53d64f0ea 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
@@ -20,12 +20,10 @@
package org.sonar.core.plugins;
import com.google.common.collect.Lists;
-import com.google.common.io.Closeables;
-import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
+import org.sonar.home.cache.FileHashes;
import java.io.File;
-import java.io.FileInputStream;
import java.util.List;
public class RemotePlugin {
@@ -52,8 +50,8 @@ public class RemotePlugin {
RemotePlugin result = new RemotePlugin(fields[0], Boolean.parseBoolean(fields[1]));
if (fields.length > 2) {
for (int index = 2; index < fields.length; index++) {
- String[] nameAndMd5 = StringUtils.split(fields[index], "|");
- result.addFile(nameAndMd5[0], nameAndMd5.length > 1 ? nameAndMd5[1] : null);
+ String[] nameAndHash = StringUtils.split(fields[index], "|");
+ result.addFile(nameAndHash[0], nameAndHash.length > 1 ? nameAndHash[1] : null);
}
}
return result;
@@ -64,10 +62,7 @@ public class RemotePlugin {
sb.append(pluginKey).append(",");
sb.append(String.valueOf(core));
for (RemotePluginFile file : files) {
- sb.append(",").append(file.getFilename());
- if (StringUtils.isNotBlank(file.getMd5())) {
- sb.append("|").append(file.getMd5());
- }
+ sb.append(",").append(file.getFilename()).append("|").append(file.getHash());
}
return sb.toString();
}
@@ -80,23 +75,13 @@ public class RemotePlugin {
return core;
}
- public RemotePlugin addFile(String filename, String md5) {
- files.add(new RemotePluginFile(filename, md5));
+ public RemotePlugin addFile(String filename, String hash) {
+ files.add(new RemotePluginFile(filename, hash));
return this;
}
public RemotePlugin addFile(File f) {
- String md5;
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(f);
- md5 = DigestUtils.md5Hex(fis);
- } catch (Exception e) {
- md5 = null;
- } finally {
- Closeables.closeQuietly(fis);
- }
- return this.addFile(f.getName(), md5);
+ return this.addFile(f.getName(), f.exists() ? new FileHashes().of(f) : null);
}
public List<RemotePluginFile> getFiles() {
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePluginFile.java b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePluginFile.java
index 88d85c3485b..87c9495cacb 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePluginFile.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePluginFile.java
@@ -23,18 +23,18 @@ package org.sonar.core.plugins;
public class RemotePluginFile {
private String filename;
- private String md5;
+ private String hash;
- public RemotePluginFile(String filename, String md5) {
+ public RemotePluginFile(String filename, String hash) {
this.filename = filename;
- this.md5 = md5;
+ this.hash = hash;
}
public String getFilename() {
return filename;
}
- public String getMd5() {
- return md5;
+ public String getHash() {
+ return hash;
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/RemotePluginTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/RemotePluginTest.java
index b62dc1d3ad4..d6b44ab6f75 100644
--- a/sonar-core/src/test/java/org/sonar/core/plugins/RemotePluginTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/plugins/RemotePluginTest.java
@@ -60,7 +60,7 @@ public class RemotePluginTest {
assertThat(clirr.isCore(), is(false));
assertThat(clirr.getFiles().size(), is(1));
assertThat(clirr.getFiles().get(0).getFilename(), is("clirr-1.1.jar"));
- assertThat(clirr.getFiles().get(0).getMd5(), is("fakemd5"));
+ assertThat(clirr.getFiles().get(0).getHash(), is("fakemd5"));
}