aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 00:10:10 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 00:20:57 +0200
commitf0231f6e3aa917119ac4cbf1fc9abaf885873223 (patch)
tree732ac684db9d6b10679e0b91139de7fc78c36f12 /sonar-server/src/main/webapp
parenteea9a9d25d3bc21e68199398ceda1c8faf13d8dd (diff)
downloadsonarqube-f0231f6e3aa917119ac4cbf1fc9abaf885873223.tar.gz
sonarqube-f0231f6e3aa917119ac4cbf1fc9abaf885873223.zip
SONAR-5007 refactor Q profile exporters
Diffstat (limited to 'sonar-server/src/main/webapp')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb46
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_create_form.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb2
6 files changed, 40 insertions, 32 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 9c9d485beb8..008f76db170 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -30,7 +30,7 @@ class ProfilesController < ApplicationController
add_breadcrumbs ProfilesController::root_breadcrumb
call_backend do
@profiles = Internal.quality_profiles.allProfiles().to_a
- @active_rule_counts = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).countAllActiveRules()
+ @active_rule_counts = Internal.qprofile_loader.countAllActiveRules()
end
Api::Utils.insensitive_sort!(@profiles) { |profile| profile.name() }
end
@@ -39,10 +39,10 @@ class ProfilesController < ApplicationController
def show
require_parameters 'key'
call_backend do
- @profile = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getByKey(params[:key])
+ @profile = Internal.qprofile_loader.getByKey(params[:key])
not_found('Profile not found') unless @profile
- @deprecated_active_rules = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).countDeprecatedActiveRulesByProfile(@profile.getKey())
- @stats = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getStatsByProfile(@profile.getKey())
+ @deprecated_active_rules = Internal.qprofile_loader.countDeprecatedActiveRulesByProfile(@profile.getKey())
+ @stats = Internal.qprofile_loader.getStatsByProfile(@profile.getKey())
end
set_profile_breadcrumbs
end
@@ -66,7 +66,7 @@ class ProfilesController < ApplicationController
end
end
profile_name = Java::OrgSonarServerQualityprofile::QProfileName.new(params[:language], params[:name])
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).create(profile_name)
+ Internal.qprofile_service.create(profile_name)
# TODO use files_by_key
#flash[:notice] = message('quality_profiles.profile_x_created', :params => result.profile.name)
#flash_result(result)
@@ -81,7 +81,7 @@ class ProfilesController < ApplicationController
require_parameters 'language'
@language = java_facade.getLanguages().find { |l| l.getKey()==params[:language].to_s }
call_backend do
- @builtin_profile_names = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).builtInProfileNamesForLanguage(params[:language].to_s)
+ @builtin_profile_names = Internal.qprofile_service.builtInProfileNamesForLanguage(params[:language].to_s)
end
render :partial => 'profiles/restore_built_in_form'
end
@@ -91,7 +91,7 @@ class ProfilesController < ApplicationController
verify_post_request
require_parameters 'language'
call_backend do
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).restoreBuiltInProfilesForLanguage(params[:language].to_s)
+ Internal.qprofile_service.restoreBuiltInProfilesForLanguage(params[:language].to_s)
end
redirect_to :action => 'index'
end
@@ -103,7 +103,7 @@ class ProfilesController < ApplicationController
profile_key = profile_id_to_key(params[:id].to_i)
call_backend do
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).delete(profile_key)
+ Internal.qprofile_service.delete(profile_key)
end
redirect_to(:controller => 'profiles', :action => 'index')
@@ -117,7 +117,7 @@ class ProfilesController < ApplicationController
profile_key = profile_id_to_key(params[:id].to_i)
call_backend do
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).setDefault(profile_key)
+ Internal.qprofile_service.setDefault(profile_key)
end
redirect_to :action => 'index'
end
@@ -146,7 +146,7 @@ class ProfilesController < ApplicationController
target_name = params['name']
call_backend do
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).copyToName(source_key, target_name)
+ Internal.qprofile_service.copyToName(source_key, target_name)
flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => target_name)
render :text => 'ok', :status => 200
end
@@ -159,7 +159,7 @@ class ProfilesController < ApplicationController
profile_key=params[:key]
call_backend do
- xml = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).backup(profile_key)
+ xml = Internal.qprofile_service.backup(profile_key)
send_data(xml, :type => 'text/xml', :disposition => "attachment; filename=#{profile_key}.xml")
end
end
@@ -179,7 +179,7 @@ class ProfilesController < ApplicationController
else
call_backend do
xml=Api::Utils.read_post_request_param(params[:backup])
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).restore(xml)
+ Internal.qprofile_service.restore(xml)
end
end
redirect_to :action => 'index'
@@ -189,21 +189,21 @@ class ProfilesController < ApplicationController
# GET /profiles/export?name=<profile name>&language=<language>&format<exporter key>
def export
language = params[:language]
- if (params[:name].blank?)
- profile = Internal.quality_profiles.defaultProfile(language)
+ if params[:name].blank?
+ profile = Internal.qprofile_service.getDefault(language)
else
- profile = Internal.quality_profiles.profile(CGI::unescape(params[:name]), language)
+ profile = Internal.qprofile_loader.getByLangAndName(language, CGI::unescape(params[:name]))
end
not_found('Profile not found') unless profile
- if (params[:format].blank?)
+ if params[:format].blank?
# standard sonar format
- result = Internal.profile_backup.backupProfile(profile)
+ result = Internal.qprofile_service.backup(profile.getKee())
send_data(result, :type => 'text/xml', :disposition => 'inline')
else
exporter_key = params[:format]
- result = Internal.profile_exporter.exportToXml(profile, exporter_key)
- send_data(result, :type => Internal.profile_exporter.getProfileExporterMimeType(exporter_key), :disposition => 'inline')
+ result = Internal.qprofile_exporters.export(profile.getKee(), exporter_key)
+ send_data(result, :type => Internal.qprofile_exporters.mimeType(exporter_key), :disposition => 'inline')
end
end
@@ -221,7 +221,7 @@ class ProfilesController < ApplicationController
profiles = Api::Utils.insensitive_sort(profiles) { |p| p.name() }
@select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name(), profile.id()] }
- @all_profile_stats = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getAllProfileStats()
+ @all_profile_stats = Internal.qprofile_loader.getAllProfileStats()
end
set_profile_breadcrumbs
@@ -236,7 +236,7 @@ class ProfilesController < ApplicationController
profile_key = profile_id_to_key(params[:id].to_i)
parent_key = profile_id_to_key(params[:parent_id].to_i) unless params[:parent_id].empty?
call_backend do
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).setParent(profile_key, parent_key)
+ Internal.qprofile_service.setParent(profile_key, parent_key)
end
redirect_to :action => 'inheritance', :id => params[:id]
end
@@ -245,7 +245,7 @@ class ProfilesController < ApplicationController
def changelog
require_parameters 'key'
- @profile = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getByKey(params[:key])
+ @profile = Internal.qprofile_loader.getByKey(params[:key])
search = {'profileKeys' => @profile.key().to_s, 'since' => params[:since], 'to' => params[:to], 'p' => params[:p]}
result = Internal.component(Java::OrgSonarServerActivity::RubyQProfileActivityService.java_class).search(search)
@changes = result.activities
@@ -341,7 +341,7 @@ class ProfilesController < ApplicationController
call_backend do
profile_key = profile_id_to_key(params[:id].to_i)
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).rename(profile_key, params[:new_name])
+ Internal.qprofile_service.rename(profile_key, params[:new_name])
end
render :text => 'ok', :status => 200
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
index 6c0f82c432f..edc76af0fa9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
@@ -25,7 +25,7 @@ module ProfilesHelper
def label_for_rules_count(qProfile, all_profile_stats)
profile_stat = all_profile_stats[qProfile.key()] if all_profile_stats
- profile_rules_count = profile_rules_count(qProfile, profile_stat)
+ profile_rules_count = profile_rules_count(profile_stat)
label = "#{profile_rules_count} #{message('rules').downcase}"
count_overriding = overriding_rules_count(profile_stat)
@@ -52,7 +52,7 @@ module ProfilesHelper
Internal.quality_profiles.countProjects(qProfile).to_i
end
- def profile_rules_count(qProfile, profile_stat)
+ def profile_rules_count(profile_stat)
count = 0
count = profile_stat.get('countActiveRules').get(0).getValue() if profile_stat && profile_stat.get('countActiveRules')
count
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
index bab4d8a47dc..d2bd4ed0bf0 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
@@ -66,12 +66,20 @@ class Internal
component(Java::OrgSonarServerQualityprofile::QProfiles.java_class)
end
- def self.quality_gates
- component(Java::OrgSonarServerQualitygate::QualityGates.java_class)
+ def self.qprofile_service
+ component(Java::OrgSonarServerQualityprofile::QProfileService.java_class)
+ end
+
+ def self.qprofile_loader
+ component(Java::OrgSonarServerQualityprofile::QProfileLoader.java_class)
end
- def self.profile_exporter
- component(Java::OrgSonarServerQualityprofile::QProfileRepositoryExporter.java_class)
+ def self.qprofile_exporters
+ component(Java::OrgSonarServerQualityprofile::QProfileExporters.java_class)
+ end
+
+ def self.quality_gates
+ component(Java::OrgSonarServerQualitygate::QualityGates.java_class)
end
def self.rules
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_create_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_create_form.html.erb
index 04101669b78..328e2af6add 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_create_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_create_form.html.erb
@@ -1,6 +1,6 @@
<%
language = controller.java_facade.getLanguages().find { |l| l.getKey()==language_key }
- importers = Internal.profile_exporter.getProfileImportersForLanguage(language_key)
+ importers = Internal.component(Java::OrgSonarServerQualityprofile::QProfileRepositoryExporter.java_class).getProfileImportersForLanguage(language_key)
%>
<form id="create-profile-form" action="profiles/create" enctype="multipart/form-data" method="POST">
<fieldset>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
index 5770af503fe..ab14ed861dd 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
@@ -50,7 +50,7 @@
</tr>
</thead>
<tbody>
- <% @profiles.select { |p| p.language == language.getKey() }.each do |profile|
+ <% @profiles.select { |p| p.language == language.getKey() }.each do |profile|
projects_count = projects_count(profile)
is_default_profile = default_profile && default_profile==profile.key()
%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb
index 76e4a6e449d..71bb6fdfb07 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb
@@ -2,7 +2,7 @@
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Permalinks'} %>
<div class="tabs-panel marginbottom10 ">
- <% exporters = Internal.profile_exporter.getProfileExportersForLanguage(@profile.language()) %>
+ <% exporters = Internal.qprofile_exporters.exportersForLanguage(@profile.language()) %>
<br/>
<table class="data without-header marginbottom10" id="permalinks-table">
<tbody>