From 4b32ba0e118c0018c1c2a1b6c101c487b2c2461b Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 20 Jan 2015 15:23:20 +0100 Subject: [PATCH] SONAR-6060 Fix regression with JSON report --- .../java/org/sonar/plugins/core/CorePlugin.java | 6 ------ .../org/sonar/batch/bootstrap/BatchComponents.java | 2 ++ .../org/sonar/batch/scan/report/JSONReport.java | 13 ++++++++++++- .../java/org/sonar/batch/user/UserRepository.java | 4 ++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 71580c29ad0..9040b071b1a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -176,12 +176,6 @@ import java.util.List; global = true, project = false, defaultValue = CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE, category = CoreProperties.CATEGORY_GENERAL), - @Property( - key = "sonar.report.export.path", - defaultValue = "sonar-report.json", - name = "Report Results Export File", - type = PropertyType.STRING, - global = false, project = false), // SERVER-SIDE TECHNICAL PROPERTIES diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java index 42c78ea50ba..333a041f13f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java @@ -31,6 +31,7 @@ import org.sonar.batch.maven.MavenProjectBootstrapper; import org.sonar.batch.maven.MavenProjectBuilder; import org.sonar.batch.maven.MavenProjectConverter; import org.sonar.batch.scan.report.ConsoleReport; +import org.sonar.batch.scan.report.JSONReport; import org.sonar.batch.scm.ScmConfiguration; import org.sonar.batch.scm.ScmSensor; import org.sonar.batch.source.LinesSensor; @@ -67,6 +68,7 @@ public class BatchComponents { // Reports ConsoleReport.class, + JSONReport.class, // dbcleaner DefaultPeriodCleaner.class, diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java index 78688636482..043507a6db4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java @@ -24,6 +24,9 @@ import com.google.common.base.Charsets; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.PropertyType; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputDir; import org.sonar.api.batch.fs.InputFile; @@ -56,8 +59,16 @@ import java.util.Set; import static com.google.common.collect.Sets.newHashSet; +@Properties({ + @Property( + key = JSONReport.SONAR_REPORT_EXPORT_PATH, + defaultValue = "sonar-report.json", + name = "Report Results Export File", + type = PropertyType.STRING, + global = false, project = false)}) public class JSONReport implements Reporter { + static final String SONAR_REPORT_EXPORT_PATH = "sonar.report.export.path"; private static final Logger LOG = LoggerFactory.getLogger(JSONReport.class); private final Settings settings; private final FileSystem fileSystem; @@ -82,7 +93,7 @@ public class JSONReport implements Reporter { @Override public void execute() { - String exportPath = settings.getString("sonar.report.export.path"); + String exportPath = settings.getString(SONAR_REPORT_EXPORT_PATH); if (exportPath != null) { exportResults(exportPath); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/user/UserRepository.java b/sonar-batch/src/main/java/org/sonar/batch/user/UserRepository.java index b82325cf0bf..c129bb704df 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/user/UserRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/user/UserRepository.java @@ -25,6 +25,7 @@ import org.sonar.batch.protocol.GsonHelper; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; public class UserRepository { @@ -45,6 +46,9 @@ public class UserRepository { } public Collection loadFromWs(List userLogins) { + if (userLogins.isEmpty()) { + return Collections.emptyList(); + } String url = "/api/users/search?format=json&includeDeactivated=true&logins=" + Joiner.on(',').join(userLogins); String json = serverClient.request(url); Users users = GsonHelper.create().fromJson(json, Users.class); -- 2.39.5