class LanguageParamUtils {
+ private LanguageParamUtils() {
+ // Utility class
+ }
+
static Collection<String> getLanguageKeys(Languages languages) {
return Collections2.transform(Arrays.asList(languages.all()), new NonNullInputFunction<Language, String>() {
@Override
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 {
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);
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);
- }
-
}
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);
}
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");
- }
-
}