]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6300 Fix WS descriptions
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 2 Apr 2015 10:04:24 +0000 (12:04 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 2 Apr 2015 10:29:50 +0000 (12:29 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/LanguageParamUtils.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectAssociationActions.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSetDefaultAction.java

index a8ff5ee260f7dd93064879a087b487e079f0797b..e4f04ce4a99613919aee8be5c866074f9d6593e5 100644 (file)
@@ -29,6 +29,10 @@ import java.util.Collection;
 
 class LanguageParamUtils {
 
+  private LanguageParamUtils() {
+    // Utility class
+  }
+
   static Collection<String> getLanguageKeys(Languages languages) {
     return Collections2.transform(Arrays.asList(languages.all()), new NonNullInputFunction<Language, String>() {
       @Override
index ded3b7f597e73ad08fa187c1b5320c1b4499a339..84994ea18cbd300e2d27a0e501fcfd40c252e174 100644 (file)
@@ -80,16 +80,21 @@ public class ProjectAssociationActions implements ServerComponent {
   private void setCommonAttributes(NewAction action) {
     action.setPost(true);
     action.createParam(PARAM_PROJECT_UUID)
-      .setDescription("A project UUID. Either this parameter, or projectKey must be set.");
+      .setDescription("A project UUID. Either this parameter, or projectKey must be set.")
+      .setExampleValue("69e57151-be0d-4157-adff-c06741d88879");
     action.createParam(PARAM_PROJECT_KEY)
-      .setDescription("A project key. Either this parameter, or projectUuid must be set.");
+      .setDescription("A project key. Either this parameter, or projectUuid must be set.")
+      .setExampleValue("org.codehaus.sonar:sonar");
     action.createParam(PARAM_PROFILE_KEY)
-      .setDescription("A quality profile key. Either this parameter, or a combination of profileName + language must be set.");
+      .setDescription("A quality profile key. Either this parameter, or a combination of profileName + language must be set.")
+      .setExampleValue("sonar-way-java-12345");
     action.createParam(PARAM_PROFILE_NAME)
-      .setDescription("A quality profile name. If this parameter is set, profileKey must not be set and language must be set to disambiguate.");
+      .setDescription("A quality profile name. If this parameter is set, profileKey must not be set and language must be set to disambiguate.")
+      .setExampleValue("Soanr way");
     action.createParam(PARAM_LANGUAGE)
       .setDescription("A quality profile language. If this parameter is set, profileKey must not be set and profileName must be set to disambiguate.")
-      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
+      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages))
+      .setExampleValue("js");
   }
 
   private abstract static class AssociationHandler implements RequestHandler {
index 4c0653b01ee83d34acd6fa458b11a3fa6e6bfcc0..cbee96e3a49fcd89dac80cba9655e45e12382324 100644 (file)
@@ -68,6 +68,25 @@ public class QProfileSearchAction implements BaseQProfileWsAction {
     this.profileLoader = profileLoader;
   }
 
+  @Override
+  public void define(WebService.NewController controller) {
+    NewAction search = controller.createAction("search")
+      .setSince("5.2")
+      .setDescription("List quality profiles.")
+      .setHandler(this)
+      .setResponseExample(getClass().getResource("example-search.json"));
+
+    search.createParam(PARAM_LANGUAGE)
+      .setDescription("The key of a language supported by the platform. If specified, only profiles for the given language are returned.")
+      .setExampleValue("js")
+      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
+
+    search.createParam(PARAM_FIELDS)
+      .setDescription("Use to restrict returned fields.")
+      .setExampleValue("key,language")
+      .setPossibleValues(ALL_FIELDS);
+  }
+
   @Override
   public void handle(Request request, Response response) throws Exception {
     List<String> fields = request.paramAsStrings(PARAM_FIELDS);
@@ -154,24 +173,4 @@ public class QProfileSearchAction implements BaseQProfileWsAction {
   private boolean fieldIsNeeded(String field, @Nullable List<String> fields) {
     return fields == null || fields.contains(field);
   }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    NewAction search = controller.createAction("search")
-      .setSince("5.2")
-      .setDescription("List quality profiles.")
-      .setHandler(this)
-      .setResponseExample(getClass().getResource("example-search.json"));
-
-    search.createParam(PARAM_LANGUAGE)
-      .setDescription("The key of a language supported by the platform. If specified, only profiles for the given language are returned.")
-      .setExampleValue("js")
-      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
-
-    search.createParam(PARAM_FIELDS)
-      .setDescription("Use to restrict returned fields.")
-      .setExampleValue("key,language")
-      .setPossibleValues(ALL_FIELDS);
-  }
-
 }
index 462b626205a2a397aef40a28efb6feeda960ad3c..1b3a7ee0c9772e84e9c8c0aef348f99876391fe1 100644 (file)
@@ -52,6 +52,28 @@ public class QProfileSetDefaultAction implements BaseQProfileWsAction {
     this.profileFactory = profileFactory;
   }
 
+  @Override
+  public void define(WebService.NewController controller) {
+    NewAction setDefault = controller.createAction("set_default")
+      .setSince("5.2")
+      .setDescription("Select the default profile for a given language.")
+      .setPost(true)
+      .setHandler(this);
+
+    setDefault.createParam(PARAM_LANGUAGE)
+      .setDescription("The key of a language supported by the platform. If specified, profileName must be set to select the default profile for the selected language.")
+      .setExampleValue("js")
+      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
+
+    setDefault.createParam(PARAM_PROFILE_NAME)
+      .setDescription("The name of a quality profile. If specified, language must be set. The matching profile will be used as default for the selected language.")
+      .setExampleValue("Sonar way");
+
+    setDefault.createParam(PARAM_PROFILE_KEY)
+      .setDescription("The key of a quality profile. If specified, language and profileName must not be set. The matching profile will be used as default for its language.")
+      .setExampleValue("sonar-way-js-12345");
+  }
+
   @Override
   public void handle(Request request, Response response) throws Exception {
     UserSession.get().checkLoggedIn().checkGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN);
@@ -79,28 +101,4 @@ public class QProfileSetDefaultAction implements BaseQProfileWsAction {
     }
     return profile.key();
   }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    NewAction setDefault = controller.createAction("set_default")
-      .setSince("5.2")
-      .setDescription("Select the default profile for a given language.")
-      .setPost(true)
-      .setHandler(this)
-      .setResponseExample(getClass().getResource("example-search.json"));
-
-    setDefault.createParam(PARAM_LANGUAGE)
-      .setDescription("The key of a language supported by the platform. If specified, profileName must be set to select the default profile for the selected language.")
-      .setExampleValue("js")
-      .setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
-
-    setDefault.createParam(PARAM_PROFILE_NAME)
-      .setDescription("The name of a quality profile. If specified, language must be set. The matching profile will be used as default for the selected language.")
-      .setExampleValue("sonar-way-js-12345");
-
-    setDefault.createParam(PARAM_PROFILE_KEY)
-      .setDescription("The key of a quality profile. If specified, language and profileName must not be set. The matching profile will be used as default for its language.")
-      .setExampleValue("sonar-way-js-12345");
-  }
-
 }