]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5851 Add back the WS /profiles/export web page 608/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 29 Oct 2015 16:42:33 +0000 (17:42 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 30 Oct 2015 08:48:53 +0000 (09:48 +0100)
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb

index a1316df93665b10ce1682642b3aa523256cbe948..aa8d7613397bfcbf7daadc7d1d3b9241fe4a2fc3 100644 (file)
@@ -36,4 +36,25 @@ class ProfilesController < ApplicationController
     render :action => 'index'
   end
 
+  # GET /profiles/export?name=<profile name>&language=<language>&format=<exporter key>
+  def export
+    language = params[:language]
+    if params[:name].blank?
+      profile = Internal.qprofile_service.getDefault(language)
+    else
+      profile = Internal.qprofile_loader.getByLangAndName(language, CGI::unescape(params[:name]))
+    end
+    not_found('Profile not found') unless profile
+
+    if params[:format].blank?
+      # standard sonar format
+      result = Internal.qprofile_service.backup(profile.getKee())
+      send_data(result, :type => 'text/xml', :disposition => 'inline')
+    else
+      exporter_key = params[:format]
+      result = Internal.qprofile_exporters.export(profile.getKee(), exporter_key)
+      send_data(result, :type => Internal.qprofile_exporters.mimeType(exporter_key), :disposition => 'inline')
+    end
+  end
+
 end