From 4b09a1feb7756139c7516a49d2cb0d0937c1d0d4 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 30 Jan 2017 12:25:40 +0100 Subject: [PATCH] SONAR-8684 Update response examples for removed WS --- .../server/component/ws/ResourcesWs.java | 3 +- .../server/measure/ws/TimeMachineWs.java | 3 +- .../server/qualityprofile/ws/ProfilesWs.java | 5 +- .../server/user/ws/UserPropertiesWs.java | 4 +- .../server/ws/RemovedWebServiceHandler.java | 6 +++ .../component/ws/resources-example-index.json | 49 +++---------------- .../ws/resources-example-search.json | 25 ---------- .../measure/ws/timemachine-example-index.json | 28 ----------- .../qualityprofile/ws/example-index.json | 41 ---------------- .../qualityprofile/ws/example-list.json | 12 ----- .../user/ws/user_properties-index-example.xml | 30 ------------ .../sonar/server/ws/removed-ws-example.json | 7 +++ 12 files changed, 26 insertions(+), 187 deletions(-) delete mode 100644 server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-search.json delete mode 100644 server/sonar-server/src/main/resources/org/sonar/server/measure/ws/timemachine-example-index.json delete mode 100644 server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-index.json delete mode 100644 server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-list.json delete mode 100644 server/sonar-server/src/main/resources/org/sonar/server/user/ws/user_properties-index-example.xml create mode 100644 server/sonar-server/src/main/resources/org/sonar/server/ws/removed-ws-example.json diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java index 716d8221502..299102c64fe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java @@ -19,7 +19,6 @@ */ package org.sonar.server.component.ws; -import com.google.common.io.Resources; import org.sonar.api.server.ws.WebService; import org.sonar.server.ws.RemovedWebServiceHandler; @@ -46,7 +45,7 @@ public class ResourcesWs implements WebService { .setSince("2.10") .setDeprecatedSince("5.4") .setHandler(RemovedWebServiceHandler.INSTANCE) - .setResponseExample(Resources.getResource(this.getClass(), "resources-example-index.json")); + .setResponseExample(RemovedWebServiceHandler.INSTANCE.getResponseExample()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java index 279268b674b..9f30ccc1058 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/TimeMachineWs.java @@ -19,7 +19,6 @@ */ package org.sonar.server.measure.ws; -import com.google.common.io.Resources; import org.sonar.api.server.ws.WebService; import org.sonar.server.ws.RemovedWebServiceHandler; @@ -40,7 +39,7 @@ public class TimeMachineWs implements WebService { .setSince("2.10") .setDeprecatedSince("6.3") .setHandler(RemovedWebServiceHandler.INSTANCE) - .setResponseExample(Resources.getResource(this.getClass(), "timemachine-example-index.json")); + .setResponseExample(RemovedWebServiceHandler.INSTANCE.getResponseExample()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java index 0ecb585ae05..dff4269e9a1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java @@ -19,7 +19,6 @@ */ package org.sonar.server.qualityprofile.ws; -import com.google.common.io.Resources; import org.sonar.api.server.ws.WebService; import org.sonar.server.ws.RemovedWebServiceHandler; @@ -55,7 +54,7 @@ public class ProfilesWs implements WebService { .setSince("3.3") .setDeprecatedSince("5.2") .setHandler(RemovedWebServiceHandler.INSTANCE) - .setResponseExample(Resources.getResource(ProfilesWs.class, "example-index.json")); + .setResponseExample(RemovedWebServiceHandler.INSTANCE.getResponseExample()); } private static void defineListAction(NewController controller) { @@ -65,6 +64,6 @@ public class ProfilesWs implements WebService { .setSince("3.3") .setDeprecatedSince("5.2") .setHandler(RemovedWebServiceHandler.INSTANCE) - .setResponseExample(Resources.getResource(ProfilesWs.class, "example-list.json")); + .setResponseExample(RemovedWebServiceHandler.INSTANCE.getResponseExample()); } } 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 0caad8934e6..42590c9b49b 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 @@ -38,8 +38,8 @@ public class UserPropertiesWs implements WebService { .setDescription("This web service is removed") .setSince("2.6") .setDeprecatedSince("6.3") - .setResponseExample(getClass().getResource("user_properties-index-example.xml")) - .setHandler(RemovedWebServiceHandler.INSTANCE); + .setHandler(RemovedWebServiceHandler.INSTANCE) + .setResponseExample(RemovedWebServiceHandler.INSTANCE.getResponseExample()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/RemovedWebServiceHandler.java b/server/sonar-server/src/main/java/org/sonar/server/ws/RemovedWebServiceHandler.java index 8a3700c3389..f61f973959c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/RemovedWebServiceHandler.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/RemovedWebServiceHandler.java @@ -20,6 +20,8 @@ package org.sonar.server.ws; +import com.google.common.io.Resources; +import java.net.URL; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.RequestHandler; import org.sonar.api.server.ws.Response; @@ -38,4 +40,8 @@ public enum RemovedWebServiceHandler implements RequestHandler { public void handle(Request request, Response response) throws Exception { throw new ServerException(HTTP_GONE, String.format("The web service '%s' doesn't exist anymore, please read its documentation to use alternatives", request.getPath())); } + + public URL getResponseExample() { + return Resources.getResource(RemovedWebServiceHandler.class, "removed-ws-example.json"); + } } diff --git a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-index.json b/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-index.json index 905f3bb54a0..5ee255d0324 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-index.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-index.json @@ -1,42 +1,7 @@ -[ - { - "id": 2865, - "key": "org.codehaus.sonar:sonar", - "name": "Sonar", - "scope": "PRJ", - "qualifier": "TRK", - "date": "2012-08-10T04:03:51+0200", - "creationDate": "2012-08-10T04:03:51+0200", - "lname": "Sonar", - - // Only available at file level - "lang": "java", - - // Only available at project and module levels - "version": "3.3-SNAPSHOT", - "description": "Open source platform for continuous inspection of code quality", - - // Description of differential periods - "p1": "previous_analysis", - "p1p": "2012-08-09", - "p1d": "2012-08-09T04:04:01+0200", - "p2": "days", - "p2p": "7", - "p2d": "2012-08-03T04:03:51+0200", - - // Values for the selected metrics - "msr": [ - { - "key": "coverage", - "val": 70.3, - "frmt_val": "70.3%", - "alert": null, - "alert_text": null, - "trend": 0, - "var": 0, - "var1": 0.0, - "var2": 0.0 - } - ] - } -] +{ + "errors": [ + { + "msg": "The web service '/api/resources/index' doesn't exists anymore, please read its documentation to use alternatives" + } + ] +} diff --git a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-search.json b/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-search.json deleted file mode 100644 index fc4c74ae1a6..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/resources-example-search.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "total": 405, - "page": 1, - "page_size": 10, - "data": [ - { - "id": 21434, - "key": "org.codehaus.mojo:sonar-maven-plugin:src/main/java/org/codehaus/mojo/sonar/SonarMojo.java", - "nm": "src/main/java/org/codehaus/mojo/sonar/SonarMojo.java", - "q": "FIL" - }, - { - "id": 4138, - "key": "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/Sonar.java", - "nm": "src/main/java/org/sonar/wsclient/Sonar.java", - "q": "FIL" - }, - { - "id": 3868, - "key": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/platform/SonarHome.java", - "nm": "src/main/java/org/sonar/server/platform/SonarHome.java", - "q": "FIL" - } - ] -} diff --git a/server/sonar-server/src/main/resources/org/sonar/server/measure/ws/timemachine-example-index.json b/server/sonar-server/src/main/resources/org/sonar/server/measure/ws/timemachine-example-index.json deleted file mode 100644 index 0fb7a624359..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/measure/ws/timemachine-example-index.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "cols": [ - { - "metric": "complexity" - }, - { - "metric": "lines" - } - ], - "cells": [ - { - "d": "2011-10-02T00:01:00+0200", - "v": [ - 11879, - 94500 - ] - }, - { - "d": "2011-10-25T12:27:41+0200", - "v": [ - 13528, - 102508 - ] - } - ] - } -] diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-index.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-index.json deleted file mode 100644 index b80303d34e6..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-index.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "name": "Sonar way", - "language": "java", - "default": true, - "rules": [ - { - "key": "DuplicatedBlocks", - "repo": "common-java", - "severity": "MAJOR" - }, - { - "key": "InsufficientBranchCoverage", - "repo": "common-java", - "severity": "MAJOR", - "params": [ - { - "key": "minimumBranchCoverageRatio", - "value": "65.0" - } - ] - }, - { - "key": "S00105", - "repo": "squid", - "severity": "MINOR" - }, - { - "key": "MethodCyclomaticComplexity", - "repo": "squid", - "severity": "MAJOR", - "params": [ - { - "key": "max", - "value": "10" - } - ] - } - ] - } -] diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-list.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-list.json deleted file mode 100644 index 21f3b6364b0..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "Sonar way with Findbugs", - "language": "java", - "default": false - }, - { - "name": "Sonar way", - "language": "java", - "default": false - } -] diff --git a/server/sonar-server/src/main/resources/org/sonar/server/user/ws/user_properties-index-example.xml b/server/sonar-server/src/main/resources/org/sonar/server/user/ws/user_properties-index-example.xml deleted file mode 100644 index 58b6d4b522c..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/user/ws/user_properties-index-example.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - favourite - - - - favourite - - - - notification.ChangesOnMyIssue.EmailNotificationChannel - - - - notification.SQ-MyNewIssues.EmailNotificationChannel - - - - notification.ChangesOnMyIssue.EmailNotificationChannel - - - - notification.SQ-MyNewIssues.EmailNotificationChannel - - - - notification.NewIssues.EmailNotificationChannel - - - diff --git a/server/sonar-server/src/main/resources/org/sonar/server/ws/removed-ws-example.json b/server/sonar-server/src/main/resources/org/sonar/server/ws/removed-ws-example.json new file mode 100644 index 00000000000..6764a133ed3 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/ws/removed-ws-example.json @@ -0,0 +1,7 @@ +{ + "errors": [ + { + "msg": "The web service '/api/...' doesn't exists anymore, please read its documentation to use alternatives" + } + ] +} -- 2.39.5