]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2205 Web service /api/rules should provide configKey
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 22 Feb 2011 15:25:17 +0000 (16:25 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 22 Feb 2011 15:25:17 +0000 (16:25 +0100)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Rule.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/RuleUnmarshaller.java

index 0d9a4bb5394b586961bfcac0fa2732a5f5778b3c..6b5b0d52b1749f09a3e8788740e5d7a2a7c4048c 100644 (file)
@@ -80,7 +80,7 @@ class Api::RulesController < Api::RestController
     xml.instruct!
     xml.rules do
       rules.each do |rule|
-        xml << rule.to_xml(profile)
+        rule.to_xml(profile, xml)
       end
     end
   end
index c485d0d0736c7ec8be77cc50f0c6407c815daf07..6b2a91db46d2545549c75bda60f4c8ae2ffe36e2 100644 (file)
@@ -57,6 +57,10 @@ class Rule < ActiveRecord::Base
   def <=>(rule)
     name<=>rule.name
   end
+  
+  def config_key
+    plugin_config_key
+  end
 
   def self.to_i(key_or_id)
     id=key_or_id.to_i
@@ -87,7 +91,7 @@ class Rule < ActiveRecord::Base
   end
 
   def to_hash_json(profile)
-    json = {'title' => name, 'key' => key, 'plugin' => plugin_name}
+    json = {'title' => name, 'key' => key, 'plugin' => plugin_name, 'config_key' => config_key}
     json['description'] = description
     active_rule = nil
     if profile
@@ -106,11 +110,11 @@ class Rule < ActiveRecord::Base
     json
   end
 
-  def to_xml(profile)
-    xml = Builder::XmlMarkup.new
+  def to_xml(profile, xml)
     xml.rule do
       xml.title(name)
       xml.key(key)
+      xml.config_key(config_key)
       xml.plugin(plugin_name)
       xml.description {xml.cdata!(description)}
       active_rule = nil
@@ -127,7 +131,7 @@ class Rule < ActiveRecord::Base
         xml.priority(priority_text)
       end
       parameters.each do |parameter|
-        xml << parameter.to_xml(active_rule)
+        parameter.to_xml(active_rule, xml)
       end
     end
   end
index 1bcc7fd012df880eb44d90715f4292a2eb2d2e02..d7c67334baa718525c8e09eb684fa4bf8cf0f6d1 100644 (file)
@@ -109,8 +109,7 @@ class RulesParameter < ActiveRecord::Base
     json
   end
 
-  def to_xml(active_rule)
-    xml = Builder::XmlMarkup.new
+  def to_xml(active_rule, xml)
     xml.param do
       xml.name(name)
       xml.description {xml.cdata!(description)}
index 9407dd776cf7477738284a97568525c05e8c71f0..d7b4d267b8829df56b1b73416e0d7a1009443777 100644 (file)
@@ -28,6 +28,7 @@ public class Rule extends Model {
 
   private String title = null;
   private String key = null;
+  private String configKey = null;
   private String repository = null;
   private String description = null;
   private String severity = null;
@@ -52,6 +53,22 @@ public class Rule extends Model {
     return this;
   }
 
+  /**
+   * @since 2.7
+   */
+  public String getConfigKey() {
+    return configKey;
+  }
+
+  /**
+   * @since 2.7
+   */
+
+  public Rule setConfigKey(String s) {
+    this.configKey = s;
+    return this;
+  }
+
   public String getRepository() {
     return repository;
   }
index 4d9c391f7d4b2854661f9d1e69dab47cf381a22b..7c982e57ac1d85f8e0c8d99214c3db47a1ea2907 100644 (file)
@@ -44,6 +44,7 @@ public class RuleUnmarshaller extends AbstractUnmarshaller<Rule> {
 
     rule.setTitle(utils.getString(json, "title"))
         .setKey(utils.getString(json, "key"))
+        .setConfigKey(utils.getString(json, "config_key"))
         .setRepository(utils.getString(json, "plugin"))
         .setDescription(utils.getString(json, "description"))
         .setSeverity(utils.getString(json, "priority"))