From: simonbrandhof Date: Fri, 5 Nov 2010 15:16:21 +0000 (+0000) Subject: SONAR-1897 URL /api/plugins conflicts with existing web service extension point.... X-Git-Tag: 2.6~646 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=feec99a308549901f0ad927e0d7a88956444cd9f;p=sonarqube.git SONAR-1897 URL /api/plugins conflicts with existing web service extension point. Rename to /api/updatecenter/installed_plugins --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/plugins_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/plugins_controller.rb deleted file mode 100644 index 147f8ca7071..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/plugins_controller.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2009 SonarSource SA -# mailto:contact AT sonarsource DOT com -# -# Sonar is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# Sonar is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with Sonar; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 -# - -require 'json' - -class Api::PluginsController < Api::ApiController - - before_filter :admin_required - - # - # GET /api/plugins - # curl http://localhost:9000/api/plugins -v -u admin:admin - # - def index - respond_to do |format| - format.json { render :json => jsonp(plugins_to_json(Plugin.user_plugins)) } - format.xml { render :xml => plugins_to_xml(Plugin.user_plugins) } - format.text { render :text => text_not_supported } - end - end - - def plugins_to_json(plugins=[]) - json=[] - plugins.each do |p| - json< 0)) - xml.plugins do - plugins.each do |plugin| - xml.plugin do - xml.key(plugin.plugin_key) - xml.name(plugin.name) - xml.version(plugin.version || '-') - end - end - end - end -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb new file mode 100644 index 00000000000..dbbaa13598f --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb @@ -0,0 +1,66 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2009 SonarSource SA +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +require 'json' + +class Api::UpdatecenterController < Api::ApiController + + before_filter :admin_required + + # + # GET /api/updatecenter/installed_plugins + # curl http://localhost:9000/api/updatecenter/installed_plugins -v -u admin:admin + # + def installed_plugins + respond_to do |format| + format.json { render :json => jsonp(plugins_to_json(Plugin.user_plugins)) } + format.xml { render :xml => plugins_to_xml(Plugin.user_plugins) } + format.text { render :text => text_not_supported } + end + end + + def plugins_to_json(plugins=[]) + json=[] + plugins.each do |p| + json< 0)) + xml.plugins do + plugins.each do |plugin| + xml.plugin do + xml.key(plugin.plugin_key) + xml.name(plugin.name) + xml.version(plugin.version || '-') + end + end + end + end +end diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PluginQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PluginQuery.java deleted file mode 100644 index 6ba030cf03c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PluginQuery.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sonar.wsclient.services; - -/** - * @since 2.4 - */ -public class PluginQuery extends Query { - - public static final String BASE_URL = "/api/plugins"; - - @Override - public Class getModelClass() { - return Plugin.class; - } - - @Override - public String getUrl() { - return BASE_URL; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java new file mode 100644 index 00000000000..f25bd86ebc7 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java @@ -0,0 +1,29 @@ +package org.sonar.wsclient.services; + +/** + * @since 2.4 + */ +public class UpdateCenterQuery extends Query { + + public static final String BASE_URL = "/api/updatecenter/"; + private String action; + + private UpdateCenterQuery(String action) { + this.action = action; + } + + @Override + public Class getModelClass() { + return Plugin.class; + } + + @Override + public String getUrl() { + return BASE_URL + action; + } + + public static UpdateCenterQuery createForInstalledPlugins() { + return new UpdateCenterQuery("installed_plugins"); + } + +} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PluginQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PluginQueryTest.java deleted file mode 100644 index 49d226852ee..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PluginQueryTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sonar.wsclient.services; - -import org.junit.Test; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -public class PluginQueryTest { - - @Test - public void index() { - PluginQuery query = new PluginQuery(); - assertThat(query.getUrl(), is("/api/plugins")); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java new file mode 100644 index 00000000000..a7be24f929d --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java @@ -0,0 +1,16 @@ +package org.sonar.wsclient.services; + +import org.junit.Test; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +public class UpdateCenterQueryTest { + + @Test + public void index() { + UpdateCenterQuery query = UpdateCenterQuery.createForInstalledPlugins(); + assertThat(query.getUrl(), is("/api/updatecenter/installed_plugins")); + } + +}