summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:16:09 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:16:09 +0000
commitf4f4f5f279804dc50bd908917f42b3d8eb94bdfe (patch)
tree0793dab16fd9edd2c189a96b328e58389158994a /sonar-server
parentaeadc1f9129274949daaa57738c7c4550bdfbc7b (diff)
downloadsonarqube-f4f4f5f279804dc50bd908917f42b3d8eb94bdfe.tar.gz
sonarqube-f4f4f5f279804dc50bd908917f42b3d8eb94bdfe.zip
SONAR-1480 backup a Q profile
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb19
2 files changed, 17 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb
index b964800c9fe..8c850104edd 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb
@@ -29,7 +29,7 @@ class Api::RulesController < Api::RestController
if params[:plugins]
options[:plugins] = params[:plugins].split(',')
else
- options[:plugins] = java_facade.getPluginsByRuleLanguage(language).collect { |plugin| plugin.getKey() }
+ options[:plugins] = java_facade.getRuleRepositoriesByLanguage(language).collect { |repo| repo.getKey() }
end
options[:categories]=params[:categories].split(',') if params[:categories]
options[:priorities]=params[:priorities].split(',') if params[:priorities]
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
index 079d2bd0136..c9ae845b911 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
@@ -29,7 +29,7 @@ class RulesConfigurationController < ApplicationController
RULE_PRIORITIES = Sonar::RulePriority.as_options.reverse
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
- verify :method => :post, :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete'], :redirect_to => { :action => 'index' }
+ verify :method => :post, :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete', 'backup'], :redirect_to => { :action => 'index' }
before_filter :admin_required, :except => [ 'index', 'export' ]
@@ -51,13 +51,13 @@ class RulesConfigurationController < ApplicationController
init_params()
- @select_plugins = ANY_SELECTION + java_facade.getPluginsByRuleLanguage(@profile.language).collect { |plugin| [plugin.getName(), plugin.getKey()]}.sort
+ @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort
@select_categories = ANY_SELECTION + RulesCategory.all.collect {|rc| [ rc.name, rc.name ] }.sort
@select_priority = ANY_SELECTION + RULE_PRIORITIES
@select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]]
if @plugins.include?('')
- plugins_to_search = java_facade.getPluginsByRuleLanguage(@profile.language).collect { |plugin| plugin.getKey() }
+ plugins_to_search = java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| repo.getKey() }
else
plugins_to_search = @plugins
end
@@ -91,6 +91,7 @@ class RulesConfigurationController < ApplicationController
send_data(result, :type => 'text/xml', :disposition => 'inline')
end
+
#
#
# POST /rules_configuration/activate_rule?id=<profile id>&rule_id=<rule id>&level=<priority>
@@ -264,6 +265,18 @@ class RulesConfigurationController < ApplicationController
end
+ #
+ #
+ # POST /rules_configuration/backup?id=<profile_id>
+ #
+ #
+ def backup
+ profile = RulesProfile.find(params[:id])
+ xml = java_facade.exportProfile(profile.id)
+ send_data(xml, :type => 'text/xml', :disposition => "attachment; filename=#{profile.name}_#{profile.language}.xml")
+ end
+
+
def update_param
is_admin=true # security has already been checked by controller filters
profile = RulesProfile.find(params[:profile_id].to_i)