diff options
4 files changed, 0 insertions, 252 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index d0922654bd2..de062342146 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -234,7 +234,6 @@ import org.sonar.server.qualityprofile.ws.ExportAction; import org.sonar.server.qualityprofile.ws.ExportersAction; import org.sonar.server.qualityprofile.ws.ImportersAction; import org.sonar.server.qualityprofile.ws.InheritanceAction; -import org.sonar.server.qualityprofile.ws.ProfilesWs; import org.sonar.server.qualityprofile.ws.ProjectAssociationActions; import org.sonar.server.qualityprofile.ws.ProjectsAction; import org.sonar.server.qualityprofile.ws.QProfilesWs; @@ -416,7 +415,6 @@ public class PlatformLevel4 extends PlatformLevel { ExportAction.class, ExportersAction.class, QProfilesWs.class, - ProfilesWs.class, RuleActivationActions.class, BulkRuleActivationActions.class, ProjectAssociationActions.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java deleted file mode 100644 index 76c57de8b96..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProfilesWs.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.qualityprofile.ws; - -import org.sonar.api.server.ws.RailsHandler; -import org.sonar.api.server.ws.WebService; - -/** - * List of quality profiles WS implemented in Rails. - * New WS on quality profiles MUST be declared in {@link org.sonar.server.qualityprofile.ws.QProfilesWs} - */ -public class ProfilesWs implements WebService { - - @Override - public void define(Context context) { - NewController controller = context.createController("api/profiles") - .setDescription("Former quality profiles web service"); - - defineBackupAction(controller); - - controller.done(); - } - - private static void defineBackupAction(NewController controller) { - WebService.NewAction action = controller.createAction("backup") - .setDescription("Backup a quality profile. Requires Administer Quality Profiles permission") - .setSince("3.1") - .setPost(true) - .setHandler(RailsHandler.INSTANCE); - - action.createParam("language") - .setDescription("Profile language") - .setRequired(true) - .setExampleValue("java"); - action.createParam("name") - .setDescription("Profile name. If not set, the default profile for the selected language is used") - .setExampleValue("Sonar way"); - RailsHandler.addFormatParam(action); - } -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProfilesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProfilesWsTest.java deleted file mode 100644 index 3f77ff988e4..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProfilesWsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.qualityprofile.ws; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.sonar.api.server.ws.RailsHandler; -import org.sonar.api.server.ws.WebService; -import org.sonar.server.ws.WsTester; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(MockitoJUnitRunner.class) -public class ProfilesWsTest { - - WsTester tester; - - @Before - public void setUp() { - tester = new WsTester(new ProfilesWs()); - } - - @Test - public void define_controller() { - WebService.Controller controller = tester.controller("api/profiles"); - assertThat(controller).isNotNull(); - assertThat(controller.path()).isEqualTo("api/profiles"); - assertThat(controller.description()).isNotEmpty(); - assertThat(controller.actions()).hasSize(1); - } - - @Test - public void define_backup_action() { - WebService.Controller controller = tester.controller("api/profiles"); - - WebService.Action restoreProfiles = controller.action("backup"); - assertThat(restoreProfiles).isNotNull(); - assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); - assertThat(restoreProfiles.params()).hasSize(3); - } -} diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb deleted file mode 100644 index 87c2ab7151a..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb +++ /dev/null @@ -1,132 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -require 'json' - -class Api::ProfilesController < Api::ApiController - - # Backup a profile. If output format is xml, then backup is directly returned. - # GET /api/profiles/backup?language=<language>[&name=my_profile] -v - def backup - require_parameters :language - - language = params[:language] - if (params[:name].blank?) - profile = Internal.qprofile_service.getDefault(language) - else - profile = Internal.quality_profiles.profile(params[:name], params[:language]) - end - - not_found('Profile not found') unless profile - backup = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).backup(profile.key) - - respond_to do |format| - format.xml { render :xml => backup } - format.json { render :json => jsonp({:backup => backup}) } - end - end - - private - - def validation_messages_to_json(messages) - hash={} - hash[:errors]=messages.getErrors().to_a.map { |message| message } - hash[:warnings]=messages.getWarnings().to_a.map { |message| message } - hash[:infos]=messages.getInfos().to_a.map { |message| message } - hash - end - - def validation_result_to_json(result) - hash={} - hash[:warnings]=result.warnings().to_a.map { |message| message } - hash[:infos]=result.infos().to_a.map { |message| message } - hash - end - - def filter_rules - conditions=['active_rules.profile_id=?'] - condition_values=[@profile.id] - - if params[:rule_repositories].present? - conditions<<'rules.plugin_name in (?)' - condition_values<<params[:rule_repositories].split(',') - end - - if params[:rule_severities].present? - conditions<<'failure_level in (?)' - condition_values<<params[:rule_severities].split(',').map { |severity| Sonar::RulePriority.id(severity) } - end - - ActiveRule.find(:all, :include => [:rule, {:active_rule_parameters => :rules_parameter}], :conditions => [conditions.join(' AND ')].concat(condition_values)) - end - - def to_json - result={} - result[:name]=@profile.name - result[:language]=@profile.language - result[:parent]=@profile.parent_kee if @profile.parent_kee.present? - result[:default]=@profile.default_profile? - - rules=[] - @active_rules.each do |active_rule| - hash={} - hash[:key]=active_rule.rule.plugin_rule_key - hash[:repo]=active_rule.rule.plugin_name - hash[:severity]=active_rule.priority_text - hash[:inheritance]=active_rule.inheritance if active_rule.inheritance - params_hash=[] - active_rule.active_rule_parameters.each do |param| - params_hash<<{:key => param.name, :value => param.value} - end - hash[:params]=params_hash unless params_hash.empty? - rules<<hash - end - result[:rules]=rules unless rules.empty? - - [result] - end - - def to_xml - xml = Builder::XmlMarkup.new(:indent => 0) - xml.instruct! - - xml.profile do - xml.name(@profile.name) - xml.language(@profile.language) - xml.parent(@profile.parent_kee) if @profile.parent_kee.present? - xml.default(@profile.default_profile?) - - @active_rules.each do |active_rule| - xml.rule do - xml.key(active_rule.rule.plugin_rule_key) - xml.repo(active_rule.rule.plugin_name) - xml.severity(active_rule.priority_text) - xml.inheritance(active_rule.inheritance) if active_rule.inheritance - active_rule.active_rule_parameters.each do |param| - xml.param do - xml.key(param.name) - xml.value(param.value) - end - end - end - end - end - end - -end |