diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-30 09:56:04 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-30 09:56:04 +0200 |
commit | 5971e4bde6ffde66db4ba42ce0c447aafe4a7f8c (patch) | |
tree | e34ecdab9202a8ed5ac5f110a10570e8e504d589 /sonar-plugin-api | |
parent | 02bdbf6b0c871a89d6d55d657974e96d9073df4c (diff) | |
download | sonarqube-5971e4bde6ffde66db4ba42ce0c447aafe4a7f8c.tar.gz sonarqube-5971e4bde6ffde66db4ba42ce0c447aafe4a7f8c.zip |
Drop WebService#setResponseExampleFormat()
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java | 21 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java | 4 |
2 files changed, 9 insertions, 16 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index 94a41cf436e..cc2803e1ba3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -23,6 +23,7 @@ import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerExtension; @@ -253,7 +254,6 @@ public interface WebService extends ServerExtension { private RequestHandler handler; private Map<String, NewParam> newParams = Maps.newHashMap(); private URL responseExample = null; - private String responseExampleFormat = null; private NewAction(String key) { this.key = key; @@ -299,16 +299,6 @@ public interface WebService extends ServerExtension { return this; } - /** - * Used only if {@link #setResponseExample(java.net.URL)} is set. Example of values: "xml", "json", "txt", "csv". - * - * @since 4.4 - */ - public NewAction setResponseExampleFormat(@Nullable String format) { - this.responseExampleFormat = format; - return this; - } - public NewParam createParam(String paramKey) { if (newParams.containsKey(paramKey)) { throw new IllegalStateException( @@ -337,7 +327,6 @@ public interface WebService extends ServerExtension { private final RequestHandler handler; private final Map<String, Param> params; private final URL responseExample; - private final String responseExampleFormat; private Action(Controller controller, NewAction newAction) { this.key = newAction.key; @@ -347,7 +336,6 @@ public interface WebService extends ServerExtension { this.post = newAction.post; this.isInternal = newAction.isInternal; this.responseExample = newAction.responseExample; - this.responseExampleFormat = newAction.responseExampleFormat; if (newAction.handler == null) { throw new IllegalArgumentException("RequestHandler is not set on action " + path); @@ -418,11 +406,14 @@ public interface WebService extends ServerExtension { } /** - * @see org.sonar.api.server.ws.WebService.NewAction#setResponseExampleFormat(String) + * @see org.sonar.api.server.ws.WebService.NewAction#setResponseExample(java.net.URL) */ @CheckForNull public String responseExampleFormat() { - return responseExampleFormat; + if (responseExample != null) { + return StringUtils.lowerCase(FilenameUtils.getExtension(responseExample.getFile())); + } + return null; } @CheckForNull diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java index 431e21a2e9f..ccebd01cd4b 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java @@ -54,7 +54,6 @@ public class WebServiceTest { .setSince("4.1") .setPost(true) .setInternal(true) - .setResponseExampleFormat("txt") .setResponseExample(getClass().getResource("/org/sonar/api/server/ws/WebServiceTest/response-example.txt")) .setHandler(new RequestHandler() { @Override @@ -102,6 +101,9 @@ public class WebServiceTest { assertThat(showAction.key()).isEqualTo("show"); assertThat(showAction.description()).isEqualTo("Show metric"); assertThat(showAction.handler()).isNotNull(); + assertThat(showAction.responseExample()).isNull(); + assertThat(showAction.responseExampleFormat()).isNull(); + assertThat(showAction.responseExampleAsString()).isNull(); // same as controller assertThat(showAction.since()).isEqualTo("3.2"); assertThat(showAction.isPost()).isFalse(); |