]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6298 Apply feedback from PR
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 9 Apr 2015 08:10:03 +0000 (10:10 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 9 Apr 2015 08:14:48 +0000 (10:14 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileCreateAction.java

index 6f21a2d694332ed6c0b8c9f5b71f2648832ce60d..dc9a0f2d74fca16e58905d067f9aba3e588d326e 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.qualityprofile;
 
+import com.google.common.base.Charsets;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.ServerComponent;
@@ -134,7 +135,7 @@ public class QProfileExporters implements ServerComponent {
   }
 
   public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, InputStream xml, DbSession dbSession) {
-    return importXml(profileDto, importerKey, new InputStreamReader(xml), dbSession);
+    return importXml(profileDto, importerKey, new InputStreamReader(xml, Charsets.UTF_8), dbSession);
   }
 
   public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, Reader xml, DbSession dbSession) {
index 80a86379ac81cfba59b5882a7d17bebed3ab1a94..bb6f12d3c7aa8e8272137394ad54dd69586c8f5c 100644 (file)
@@ -68,29 +68,27 @@ public class QProfileCreateAction implements BaseQProfileWsAction {
 
   @Override
   public void define(WebService.NewController controller) {
-    NewAction setDefault = controller.createAction("create")
+    NewAction create = controller.createAction("create")
       .setSince("5.2")
       .setDescription("Create a quality profile.")
       .setPost(true)
       .setResponseExample(getClass().getResource("example-create.json"))
       .setHandler(this);
 
-    setDefault.createParam(PARAM_PROFILE_NAME)
+    create.createParam(PARAM_PROFILE_NAME)
       .setDescription("The name for the new quality profile.")
       .setExampleValue("My Sonar way")
       .setRequired(true);
 
-    setDefault.createParam(PARAM_LANGUAGE)
+    create.createParam(PARAM_LANGUAGE)
       .setDescription("The language for the quality profile.")
       .setExampleValue("js")
       .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages))
       .setRequired(true);
 
-    if (importers.length > 0) {
-      for (ProfileImporter importer : importers) {
-        setDefault.createParam(getBackupParamName(importer.getKey()))
-          .setDescription("A configuration file for " + importer.getName() + ".");
-      }
+    for (ProfileImporter importer : importers) {
+      create.createParam(getBackupParamName(importer.getKey()))
+        .setDescription(String.format("A configuration file for %s.", importer.getName()));
     }
   }
 
@@ -107,12 +105,10 @@ public class QProfileCreateAction implements BaseQProfileWsAction {
       QProfileResult result = new QProfileResult();
       QualityProfileDto profile = profileFactory.create(dbSession, QProfileName.createFor(language, name));
       result.setProfile(profile);
-      if (importers.length > 0) {
-        for (ProfileImporter importer : importers) {
-          InputStream contentToImport = request.paramAsInputStream(getBackupParamName(importer.getKey()));
-          if (contentToImport != null) {
-            result.add(exporters.importXml(profile, importer.getKey(), contentToImport, dbSession));
-          }
+      for (ProfileImporter importer : importers) {
+        InputStream contentToImport = request.paramAsInputStream(getBackupParamName(importer.getKey()));
+        if (contentToImport != null) {
+          result.add(exporters.importXml(profile, importer.getKey(), contentToImport, dbSession));
         }
       }
       dbSession.commit();