]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1897 URL /api/plugins conflicts with existing web service extension point....
authorsimonbrandhof <simon.brandhof@gmail.com>
Fri, 5 Nov 2010 15:16:21 +0000 (15:16 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Fri, 5 Nov 2010 15:16:21 +0000 (15:16 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/plugins_controller.rb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb [new file with mode: 0644]
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PluginQuery.java [deleted file]
sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java [new file with mode: 0644]
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PluginQueryTest.java [deleted file]
sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java [new file with mode: 0644]

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 (file)
index 147f8ca..0000000
+++ /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<<plugin_to_json(p)
-    end
-    json
-  end
-
-  def plugin_to_json(plugin)
-    hash={}
-    hash['key']=plugin.plugin_key
-    hash['name']=plugin.name
-    hash['version']=plugin.version || '-'
-    hash
-  end
-
-  def plugins_to_xml(plugins, xml=Builder::XmlMarkup.new(:indent => 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 (file)
index 0000000..dbbaa13
--- /dev/null
@@ -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<<plugin_to_json(p)
+    end
+    json
+  end
+
+  def plugin_to_json(plugin)
+    hash={}
+    hash['key']=plugin.plugin_key
+    hash['name']=plugin.name
+    hash['version']=plugin.version || '-'
+    hash
+  end
+
+  def plugins_to_xml(plugins, xml=Builder::XmlMarkup.new(:indent => 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 (file)
index 6ba030c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.sonar.wsclient.services;
-
-/**
- * @since 2.4
- */
-public class PluginQuery extends Query<Plugin> {
-
-  public static final String BASE_URL = "/api/plugins";
-
-  @Override
-  public Class<Plugin> 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 (file)
index 0000000..f25bd86
--- /dev/null
@@ -0,0 +1,29 @@
+package org.sonar.wsclient.services;
+
+/**
+ * @since 2.4
+ */
+public class UpdateCenterQuery extends Query<Plugin> {
+
+  public static final String BASE_URL = "/api/updatecenter/";
+  private String action;
+
+  private UpdateCenterQuery(String action) {
+    this.action = action;
+  }
+
+  @Override
+  public Class<Plugin> 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 (file)
index 49d2268..0000000
+++ /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 (file)
index 0000000..a7be24f
--- /dev/null
@@ -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"));
+  }
+
+}