From fac6e241bdb9cf31bc16e219a9fca3f4bc7641a9 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 14 Sep 2016 11:51:28 +0200 Subject: [PATCH] SONAR-7865 Deprecate XML format of web service responses --- .../java/org/sonar/server/component/ws/EventsWs.java | 3 ++- .../java/org/sonar/server/config/ws/PropertiesWs.java | 5 ++++- .../main/java/org/sonar/server/user/ws/FavouritesWs.java | 5 ++++- .../java/org/sonar/server/user/ws/UserPropertiesWs.java | 9 ++++++--- .../main/java/org/sonar/api/server/ws/RailsHandler.java | 6 ++++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java index c60de5082f0..aa622e704a5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/EventsWs.java @@ -36,10 +36,11 @@ public class EventsWs implements WebService { } private void defineIndexAction(NewController controller) { - controller.createAction("index") + WebService.NewAction action = controller.createAction("index") .setDescription("Documentation of this web service is available here") .setResponseExample(getClass().getResource("events-index-example.json")) .setSince("2.6") .setHandler(RailsHandler.INSTANCE); + RailsHandler.addFormatParam(action); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java b/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java index 3b2a9085b9a..3aa3f58d8a0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/config/ws/PropertiesWs.java @@ -22,6 +22,8 @@ package org.sonar.server.config.ws; import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; +import static org.sonar.api.server.ws.RailsHandler.addFormatParam; + public class PropertiesWs implements WebService { @Override @@ -36,10 +38,11 @@ public class PropertiesWs implements WebService { } private void defineIndexAction(NewController controller) { - controller.createAction("index") + NewAction action = controller.createAction("index") .setDescription("Documentation of this web service is available here") .setResponseExample(getClass().getResource("index-example.xml")) .setSince("2.6") .setHandler(RailsHandler.INSTANCE); + addFormatParam(action); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavouritesWs.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavouritesWs.java index 7ec8beccd90..543ee6fd39f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavouritesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/FavouritesWs.java @@ -22,6 +22,8 @@ package org.sonar.server.user.ws; import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; +import static org.sonar.api.server.ws.RailsHandler.addFormatParam; + public class FavouritesWs implements WebService { @Override @@ -36,10 +38,11 @@ public class FavouritesWs implements WebService { } private void defineIndexAction(NewController controller) { - controller.createAction("index") + NewAction action = controller.createAction("index") .setDescription("Documentation of this web service is available here") .setResponseExample(getClass().getResource("favourites-index-example.xml")) .setSince("2.6") .setHandler(RailsHandler.INSTANCE); + addFormatParam(action); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java index 9736620d95a..e4ce7ce692c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/UserPropertiesWs.java @@ -19,9 +19,11 @@ */ package org.sonar.server.user.ws; -import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; +import static org.sonar.api.server.ws.RailsHandler.INSTANCE; +import static org.sonar.api.server.ws.RailsHandler.addFormatParam; + public class UserPropertiesWs implements WebService { @Override @@ -36,11 +38,12 @@ public class UserPropertiesWs implements WebService { } private void defineIndexAction(NewController controller) { - controller.createAction("index") + NewAction action = controller.createAction("index") .setDescription("Documentation of this web service is available here") .setSince("2.6") .setResponseExample(getClass().getResource("user_properties-index-example.xml")) - .setHandler(RailsHandler.INSTANCE); + .setHandler(INSTANCE); + addFormatParam(action); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java index 40c9f5ad0ba..3edc0647afa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java @@ -47,8 +47,10 @@ public class RailsHandler implements RequestHandler { "
  • Accept:text/xml
  • " + "
  • Accept:application/json
  • " + "" + - "If nothing is set, json is used") - .setPossibleValues("json", "xml"); + "If nothing is set, json is used.
    " + + "Since 6.1, XML format is deprecated, only JSON format should be used.") + .setPossibleValues("json", "xml") + .setDeprecatedSince("6.1"); } public static WebService.NewParam addJsonOnlyFormatParam(WebService.NewAction action) { -- 2.39.5