From 90b5e2cece88aa9549998f19af872d6e1ab29fd6 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 8 Sep 2016 15:00:14 +0200 Subject: [PATCH] Drop Ruby dead code --- .../src/main/java/RubyApiGlobalPage.java | 40 ----- .../src/main/java/RubyApiProjectPage.java | 42 ------ .../src/main/java/UiExtensionsPlugin.java | 2 - .../main/resources/ruby-api-global-page.erb | 33 ----- .../main/resources/ruby-api-project.page.rb | 3 - .../java/it/uiExtension/UiExtensionsTest.java | 1 - .../UiExtensionsTest/ruby-api-tester.html | 39 ----- .../controllers/api/profiles_controller.rb | 15 -- .../app/controllers/application_controller.rb | 70 --------- .../app/controllers/resource_controller.rb | 1 - .../rules_configuration_controller.rb | 2 - .../WEB-INF/app/helpers/metrics_helper.rb | 23 --- .../WEB-INF/app/helpers/plugins_helper.rb | 22 --- .../WEB-INF/app/helpers/profiles_helper.rb | 65 --------- .../WEB-INF/app/helpers/project_helper.rb | 1 - .../WEB-INF/app/helpers/roles_helper.rb | 54 ------- .../app/helpers/rules_configuration_helper.rb | 59 -------- .../WEB-INF/app/helpers/settings_helper.rb | 107 -------------- .../WEB-INF/app/helpers/system_helper.rb | 23 --- .../app/helpers/updatecenter_helper.rb | 30 ---- .../WEB-INF/app/helpers/users_helper.rb | 112 -------------- .../webapp/WEB-INF/app/models/active_rule.rb | 8 - .../WEB-INF/app/models/active_rule_change.rb | 45 ------ .../app/models/active_rule_param_change.rb | 32 ---- .../main/webapp/WEB-INF/app/models/author.rb | 31 ---- .../main/webapp/WEB-INF/app/models/group.rb | 13 -- .../main/webapp/WEB-INF/app/models/profile.rb | 137 ------------------ .../app/models/resource_deletion_manager.rb | 122 ---------------- .../main/webapp/WEB-INF/app/models/rule.rb | 112 -------------- .../WEB-INF/app/models/rules_parameter.rb | 1 - .../main/webapp/WEB-INF/app/models/user.rb | 41 ------ .../_pending_deletions_screen.html.erb | 43 ------ 32 files changed, 1329 deletions(-) delete mode 100644 it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java delete mode 100644 it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java delete mode 100644 it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb delete mode 100644 it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb delete mode 100644 it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-api-tester.html delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/plugins_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/system_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/helpers/users_helper.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_change.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_param_change.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/models/author.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java deleted file mode 100644 index 37c3ae6e180..00000000000 --- a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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. - */ -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.NavigationSection; -import org.sonar.api.web.RubyRailsPage; - -@NavigationSection({NavigationSection.HOME}) -public class RubyApiGlobalPage extends AbstractRubyTemplate implements RubyRailsPage { - - public String getId() { - return getClass().getName(); - } - - public String getTitle() { - return "Ruby API Global Page"; - } - - @Override - public String getTemplatePath() { - return "/ruby-api-global-page.erb"; - } - -} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java deleted file mode 100644 index c868215ba11..00000000000 --- a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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. - */ -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.NavigationSection; -import org.sonar.api.web.RubyRailsPage; -import org.sonar.api.web.UserRole; - -@NavigationSection({NavigationSection.RESOURCE}) -@UserRole(UserRole.USER) -public class RubyApiProjectPage extends AbstractRubyTemplate implements RubyRailsPage { - - public String getId() { - return getClass().getName(); - } - - public String getTitle() { - return "Ruby API Project Page"; - } - - @Override - public String getTemplatePath() { - return "/ruby-api-project-page.erb"; - } - -} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java b/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java index e75149eb32d..c236dff6b71 100644 --- a/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java @@ -26,8 +26,6 @@ public class UiExtensionsPlugin extends SonarPlugin { public List getExtensions() { return Arrays.asList( FakePageDecorations.class, - RubyApiGlobalPage.class, - RubyApiProjectPage.class, ResourceConfigurationPage.class ); } diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb deleted file mode 100644 index 40aea8687f9..00000000000 --- a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb +++ /dev/null @@ -1,33 +0,0 @@ -

Ruby API Global Page

- -<% success=true %> - -<% if logged_in? %> -

User Properties

- -<% end %> - -
-

Result: <%= success ? 'OK' : 'FAIL' %>

diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb deleted file mode 100644 index 7cbc55a983d..00000000000 --- a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb +++ /dev/null @@ -1,3 +0,0 @@ -

Ruby API Project

- -

Project name is: <%= @project.name -%>

diff --git a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java index decffdaa5f2..7aca814487a 100644 --- a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java +++ b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java @@ -85,7 +85,6 @@ public class UiExtensionsTest { @Test public void test_ruby_extensions() { Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("ui-ruby-extensions", - "/uiExtension/UiExtensionsTest/ruby-api-tester.html", "/uiExtension/UiExtensionsTest/ruby-rails-app.html", "/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html" ).build(); diff --git a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-api-tester.html b/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-api-tester.html deleted file mode 100644 index 36e93f69b7b..00000000000 --- a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-api-tester.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - ruby-api - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ruby-api
open/
waitForElementPresentlink=Ruby API Global Page
clickAndWaitlink=Ruby API Global Page
waitForTextruby-api-resultOK
- - 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 index 892ec9e3eb4..cf8f21c2769 100644 --- 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 @@ -106,21 +106,6 @@ class Api::ProfilesController < Api::ApiController 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] diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index b2e07cd7b86..0f19befb9b9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -279,74 +279,4 @@ class ApplicationController < ActionController::Base @hide_sidebar = true end - # - # SETTINGS - # - # TODO - remove from ApplicationController - def by_category_name(categories) - Api::Utils.insensitive_sort(categories) { |category| category_name(category) } - end - - # TODO - remove from ApplicationController - def by_subcategory_name(category, subcategories) - Api::Utils.insensitive_sort(subcategories) { |subcategory| - if (subcategory == category) - # Hack to have default category in first position - "aaaaa" - else - subcategory_name(category, subcategory) - end - } - end - - # TODO - remove from ApplicationController - def category_name(category) - # Try with lowercase key then with original key for backward compatibility - message("property.category.#{category.key}", :default => message("property.category.#{category.originalKey}", :default => category.originalKey)) - end - - # TODO - remove from ApplicationController - def subcategory_name(category, subcategory) - if (category.key == subcategory.key) - # If subcategory == category then it is the default one - category_name(category) - else - # Try with lowercase key then with original key for backward compatibility - message("property.category.#{category.key}.#{subcategory.key}", - :default => message("property.category.#{category.originalKey}.#{subcategory.originalKey}", :default => subcategory.originalKey)) - end - end - - # TODO - remove from ApplicationController - def processProperties(definitions_per_category) - @categories = by_category_name(definitions_per_category.keys) - - if params[:category].nil? - # Select the 'general' category by default. If 'general' category is not found, then return the first one. - default_category = @categories.empty? ? nil : (@categories.find {|c| c && c.key.downcase == 'general'} || @categories[0]) - @category = default_category - else - @category = @categories.find {|c| c && c.key.casecmp(params[:category])==0} - not_found('category') if @category.nil? - end - - unless @category.isSpecial then - @subcategories_per_categories = {} - definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys)) } - - if params[:subcategory].nil? - default_subcategory = - @subcategories_per_categories[@category].nil? ? nil : - ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0]) - @subcategory = default_subcategory - else - @subcategory = @subcategories_per_categories[@category].find {|s| s && s.key.casecmp(params[:subcategory])==0} - not_found('subcategory') if @subcategory.nil? - end - - @definitions = definitions_per_category[@category] || {} - @definitions = @definitions[@subcategory] || [] - end - end - end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 2d72b550e06..41c1bfb978e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -23,7 +23,6 @@ class ResourceController < ApplicationController SECTION=Navigation::SECTION_RESOURCE helper :dashboard - helper UsersHelper # DO NOT REMOVE - used by eclipse plugin def index diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 52c95c7d03d..fd85c86c87f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -23,8 +23,6 @@ class RulesConfigurationController < ApplicationController SECTION=Navigation::SECTION_QUALITY_PROFILES - RULE_PRIORITIES = Sonar::RulePriority.as_options.reverse - # deprecated since 2.3 def export redirect_to request.query_parameters.merge({:controller => 'profiles', :action => 'export'}) diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb index ed2c2c0a953..2de72350546 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb @@ -23,27 +23,4 @@ module MetricsHelper metrics.map {|m| m.domain(translate)}.uniq.compact.sort end - def options_grouped_by_domain(metrics, selected_key='', options={}) - metrics_per_domain={} - metrics.each do |metric| - domain=metric.domain || '' - metrics_per_domain[domain]||=[] - metrics_per_domain[domain]<" - metrics_per_domain[domain].each do |m| - selected_attr = (m.key==selected_key || m.id==selected_key) ? " selected='selected'" : '' - html += "" - end - html += '' - end - html - end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/plugins_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/plugins_helper.rb deleted file mode 100644 index 727cee0d2ec..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/plugins_helper.rb +++ /dev/null @@ -1,22 +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. - # -module PluginsHelper - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb deleted file mode 100644 index edc76af0fa9..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb +++ /dev/null @@ -1,65 +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. -# -module ProfilesHelper - - def languages - controller.java_facade.getLanguages() - end - - 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(profile_stat) - label = "#{profile_rules_count} #{message('rules').downcase}" - - count_overriding = overriding_rules_count(profile_stat) - if count_overriding && count_overriding>0 - label += message('quality_profiles.including_x_overriding.suffix', :params => count_overriding) - label += image_tag('overrides.png') - end - label - end - - def options_for_profiles(profiles, selected_id=nil) - html="" - profiles.group_by(&:language).each do |language, profiles| - html += "" - profiles.each do |profile| - html += "" - end - html += "" - end - html - end - - def projects_count(qProfile) - Internal.quality_profiles.countProjects(qProfile).to_i - end - - def profile_rules_count(profile_stat) - count = 0 - count = profile_stat.get('countActiveRules').get(0).getValue() if profile_stat && profile_stat.get('countActiveRules') - count - end - - def overriding_rules_count(profile_stat) - inheritance_stats = Hash[ *profile_stat.get('inheritance').collect { |v| [ v.getKey(), v ] }.flatten ] if profile_stat - inheritance_stats['OVERRIDES'].getValue().to_i if inheritance_stats && inheritance_stats['OVERRIDES'] - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/project_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/project_helper.rb index b8516f7d2be..98025c2eb68 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/project_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/project_helper.rb @@ -19,7 +19,6 @@ # module ProjectHelper include ActionView::Helpers::UrlHelper - include SettingsHelper def formatted_value(measure, default='') measure ? measure.formatted_value : default diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb index b65f841539f..03823212cf9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb @@ -38,62 +38,8 @@ module RolesHelper Api::Utils.insensitive_sort(groups) { |group| group ? group.name : '' } end - def all_groups - [nil].concat(Api::Utils.insensitive_sort(Group.all) { |group| group.name }) - end - def group_name(group) group ? group.name : 'Anyone' end - def group_ref(group_name) - group_name.blank? ? 'Anyone' : group_name - end - - def default_project_group_names(role, qualifier) - group_names=(controller.java_facade.getConfigurationValue("sonar.role.#{role}.#{qualifier}.defaultGroups")||'').split(',') - - # verify that groups still exist - result = [] - if group_names.size>0 - groups = Group.all(:conditions => ['name in (?)', group_names]) - result = Api::Utils.insensitive_sort(groups.map{|g| g.name}) - result = ['Anyone'].concat(result) if group_names.include? 'Anyone' - end - result - end - - def default_project_users(role, qualifier) - logins=(controller.java_facade.getConfigurationValue("sonar.role.#{role}.#{qualifier}.defaultUsers") || '').split(',') - users = User.all(:conditions => ['login in (?) and active=?', logins, true]) - Api::Utils.insensitive_sort(users) { |user| user.name } - end - - def role_name(role) - case (role.to_s) - when 'admin' then - 'Administrators' - when 'user' then - 'Users' - when 'codeviewer' then - 'Code Viewers' - else - role.to_s - end - end - - def global_role_name(role) - message("global_permissions.#{role}", :default => role) - end - - def link_to_edit_roles_permission_form(label, role, resource_id, html_id) - link_to message(label), {:controller => :roles, :action => :edit_users, :role => role, :resource => resource_id}, - :id => html_id, :class => 'open-modal link-action nowrap', 'modal-width' => '540px' - end - - def link_to_edit_groups_permission_form(label, role, resource_id, html_id) - link_to message(label), {:controller => :roles, :action => :edit_groups, :role => role, :resource => resource_id}, - :id => html_id, :class => 'open-modal link-action nowrap', 'modal-width' => '540px' - end - end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb deleted file mode 100644 index 4449bcdf547..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb +++ /dev/null @@ -1,59 +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. -# -module RulesConfigurationHelper - include PropertiesHelper - - def property_type(type) - value_type = type.type - return PropertyType::TYPE_STRING if value_type == 'STRING' - return PropertyType::TYPE_INTEGER if value_type == 'INTEGER' - return PropertyType::TYPE_BOOLEAN if value_type == 'BOOLEAN' - return PropertyType::TYPE_STRING if value_type == 'SINGLE_SELECT_LIST' - value_type - end - - def readable_type(type) - property_type = property_type(type) - - return "Number" if property_type == PropertyType::TYPE_INTEGER - return "Set of comma delimited values" if type.type() == PropertyType::TYPE_SINGLE_SELECT_LIST - "" - end - - def param_value_input(rule, parameter, value, options = {}) - property_type = property_type(parameter.type()) - name = options[:name] || 'value' - property_input_field name, property_type, value, 'WIDGET', {:id => "#{rule.id().to_s}#{parameter.key().to_s}", :size => options[:size]}.update(options) - end - - def rule_key(qProfileRule) - "#{qProfileRule.repositoryKey().to_s}:#{qProfileRule.key().to_s}" - end - - def html_text(text) - Api::Utils.markdown_to_html(text) - end - - def plain_text(text) - Api::Utils.convert_string_to_unix_newlines(text) - end - -end - diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb deleted file mode 100644 index be4bf396542..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb +++ /dev/null @@ -1,107 +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. -# -module SettingsHelper - include PropertiesHelper - - def category_name(category) - # Try with lowercase key then with original key for backward compatibility - message("property.category.#{category.key}", :default => message("property.category.#{category.originalKey}", :default => category.originalKey)) - end - - def subcategory_name(category, subcategory) - if (category.key == subcategory.key) - # If subcategory == category then it is the default one - category_name(category) - else - # Try with lowercase key then with original key for backward compatibility - message("property.category.#{category.key}.#{subcategory.key}", - :default => message("property.category.#{category.originalKey}.#{subcategory.originalKey}", :default => subcategory.originalKey)) - end - end - - def property_name(property) - message("property.#{property.key}.name", :default => property.name) - end - - def property_description(property) - message("property.#{property.key}.description", :default => property.description) - end - - def field_name(property, field) - message("field.#{property.key}.#{field.key}.name", :default => field.name) - end - - def field_description(property, field) - message("field.#{property.key}.#{field.key}.description", :default => field.description) - end - - def key_field(property) - property.fields.find { |f| f.key == 'key' } - end - - def option_name(property, field, option) - option_name_with_key(property.key, field && field.key, option, nil) - end - - def category_help(category) - message("category.#{category}.help", :default => '') - end - - def category_desc(category) - message("property.category.#{category.key}.description", :default => '') - end - - def subcategory_desc(category, subcategory) - message("property.category.#{category.key}.#{subcategory.key}.description", :default => '') - end - - def property_value(property) - if property.multi_values? - Property.values(property.key, @resource && @resource.id) - else - Property.value(property.key, @resource && @resource.id, '') - end - end - - # for backward-compatibility with properties that do not define the type TEXT - def property_type(property, value) - unless property.fields.blank? - return 'PROPERTY_SET_DEFINITION' - end - - if property.type.to_s=='STRING' && value && value.include?('\n') - return 'TEXT' - end - - property.type - end - - def by_property_index_or_name(properties) - properties.sort_by { |p| [p.index, property_name(p).downcase] } - end - - def input_name(property) - name = "settings[#{h property.key}]" - if property.multi_values? - name += '[]' - end - name - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/system_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/system_helper.rb deleted file mode 100644 index 676a5fd2683..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/system_helper.rb +++ /dev/null @@ -1,23 +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. -# -module SystemHelper - - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb deleted file mode 100644 index 4e51fcc766e..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb +++ /dev/null @@ -1,30 +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. -# -module UpdatecenterHelper - - def release_date(date) - if date - Time.at(date.getTime() / 1000).strftime('%b %e, %Y') - else - nil - end - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/users_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/users_helper.rb deleted file mode 100644 index cdddfdae5e5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/users_helper.rb +++ /dev/null @@ -1,112 +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. -# -module UsersHelper - - # - # Use this to wrap view elements that the user can't access. - # !! Note: this is an *interface*, not *security* feature !! - # You need to do all access control at the controller level. - # - # Example: - # <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> | - # <%= if_authorized?(:edit, @user) do link_to('Edit this user', edit_user_path) end %> | - # <%= if_authorized?(:destroy, @user) do link_to 'Destroy', @user, :confirm => 'Are you sure?', :method => :delete end %> - # - # - def if_authorized?(action, resource, &block) - if authorized?(action, resource) - yield action, resource - end - end - - # - # Link to user's page ('users/1') - # - # By default, their login is used as link text and link title (tooltip) - # - # Takes options - # * :content_text => 'Content text in place of user.login', escaped with - # the standard h() function. - # * :content_method => :user_instance_method_to_call_for_content_text - # * :title_method => :user_instance_method_to_call_for_title_attribute - # * as well as link_to()'s standard options - # - # Examples: - # link_to_user @user - # # => barmy - # - # # if you've added a .name attribute: - # content_tag :span, :class => :vcard do - # (link_to_user user, :class => 'fn n', :title_method => :login, :content_method => :name) + - # ': ' + (content_tag :span, user.email, :class => 'email') - # end - # # => Cyril Fotheringay-Phipps: - # - # link_to_user @user, :content_text => 'Your user page' - # # => Your user page - # - def link_to_user(user, options={}) - raise "Invalid user" unless user - options.reverse_merge! :content_method => :login, :title_method => :login, :class => :nickname - content_text = options.delete(:content_text) - content_text ||= user.send(options.delete(:content_method)) - options[:title] ||= user.send(options.delete(:title_method)) - link_to h(content_text), user_path(user), options - end - - # - # Link to login page using remote ip address as link content - # - # The :title (and thus, tooltip) is set to the IP address - # - # Examples: - # link_to_login_with_IP - # # => 169.69.69.69 - # - # link_to_login_with_IP :content_text => 'not signed in' - # # => not signed in - # - def link_to_login_with_IP content_text=nil, options={} - ip_addr = request.remote_ip - content_text ||= ip_addr - options.reverse_merge! :title => ip_addr - if tag = options.delete(:tag) - content_tag tag, h(content_text), options - else - link_to h(content_text), login_path, options - end - end - - # - # Link to the current user's page (using link_to_user) or to the login page - # (using link_to_login_with_IP). - # - def link_to_current_user(options={}) - if current_user - link_to_user current_user, options - else - content_text = options.delete(:content_text) || 'not signed in' - # kill ignored options from link_to_user - [:content_method, :title_method].each{|opt| options.delete(opt)} - link_to_login_with_IP content_text, options - end - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule.rb index 68afc99a0b9..5c3c68ab921 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule.rb @@ -18,7 +18,6 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # class ActiveRule < ActiveRecord::Base - belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id' belongs_to :rule has_many :active_rule_parameters, :dependent => :destroy @@ -92,11 +91,4 @@ class ActiveRule < ActiveRecord::Base nil end - def inherited? - inheritance=='INHERITED' - end - - def overrides? - inheritance=='OVERRIDES' - end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_change.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_change.rb deleted file mode 100644 index 8a81fabf583..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_change.rb +++ /dev/null @@ -1,45 +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. -# -class ActiveRuleChange < ActiveRecord::Base - belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id' - belongs_to :rule - has_many :active_rule_param_changes, :dependent => :destroy - - def action_text - case enabled - when true then "on" - when false then "off" - when nil then "modified" - end - end - - def old_severity_text - Sonar::RulePriority.to_s old_severity - end - - def new_severity_text - Sonar::RulePriority.to_s new_severity - end - - def parameters - active_rule_param_changes - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_param_change.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_param_change.rb deleted file mode 100644 index b39e55400a2..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_rule_param_change.rb +++ /dev/null @@ -1,32 +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 -# License along with {library}; if not, write to the Free Software -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - class ActiveRuleParamChange < ActiveRecord::Base - belongs_to :active_rule_change - belongs_to :rules_parameter - - def name - rules_parameter.name - end - - def parameter - rules_parameter - end - - end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/author.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/author.rb deleted file mode 100644 index 1db85053c31..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/author.rb +++ /dev/null @@ -1,31 +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. -# -class Author < ActiveRecord::Base - - belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id' - - validates_uniqueness_of :login - validates_presence_of :person - validates_length_of :login, :allow_blank => false, :maximum => 255 - - def <=>(other) - login<=>other.login - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/group.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/group.rb index e8da706e761..6138ac9aed0 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/group.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/group.rb @@ -30,19 +30,6 @@ class Group < ActiveRecord::Base validates_uniqueness_of :name validate :name_cant_be_anyone - # all the users that are NOT members of this group - def available_users - User.find(:all, :conditions => ["active=?", true], :order => 'name') - users - end - - def set_users(new_users=[]) - self.users.clear - - new_users=(new_users||[]).compact.uniq - self.users = User.find(new_users) - save - end - def <=>(other) return -1 if name.nil? return 1 if other.nil? || other.name.nil? diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb index 7b4d1d690cf..e38f0847994 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb @@ -21,30 +21,9 @@ class Profile < ActiveRecord::Base set_table_name 'rules_profiles' has_many :active_rules, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :dependent => :destroy, :include => ['rule'] - has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :include => ['active_rule_parameters'] - has_many :changes, :class_name => 'ActiveRuleChange', :dependent => :destroy - MAX_NAME_LENGTH = 100 after_initialize :readonly! - # The warnings that are set on this record, equivalent to normal ActiveRecord errors but does not prevent - # the record from saving. - def warnings - @warnings ||= ActiveRecord::Errors.new(self) - end - - def warnings? - !warnings.empty? - end - - def notices - @notices ||= ActiveRecord::Errors.new(self) - end - - def notices? - not notices.empty? - end - def active? active end @@ -57,103 +36,6 @@ class Profile < ActiveRecord::Base Property.value("sonar.profile.#{language}")==name end - def active_by_rule_id(rule_id) - active_hash_by_rule_id[rule_id] - end - - def self.options_for_select - array=[] - Profile.all(:order => 'name').each do |profile| - label = profile.name - label = label + ' (active)' if profile.default_profile? - array<<[label, profile.id] - end - array - end - - @active_hash_by_rule_id=nil - - def active_hash_by_rule_id - if @active_hash_by_rule_id.nil? - @active_hash_by_rule_id={} - active_rules_with_params.each do |active_rule| - @active_hash_by_rule_id[active_rule.rule_id]=active_rule - end - end - @active_hash_by_rule_id - end - - def deletable? - !default_profile? && children.empty? - end - - def count_overriding_rules - @count_overriding_rules||= - begin - active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES']) - end - end - - def inherited? - parent_kee.present? - end - - def parent - @parent||= - begin - if parent_kee.present? - Profile.first(:conditions => ['language=? and kee=?', language, parent_kee]) - else - nil - end - end - end - - def children - @children ||= - begin - Profile.all(:conditions => ['parent_kee=? and language=?', kee, language]) - end - end - - def count_active_rules - active_rules.select { |ar| ar.rule.enabled? }.size - end - - def ancestors - @ancestors ||= - begin - array=[] - if parent - array< 'LEFT JOIN properties ON properties.resource_id = projects.id', - :conditions => ['properties.resource_id is not null and properties.prop_key=? and properties.text_value like ?', "sonar.profile.#{language}", name]) - end - end - - def add_project_id(project_id) - Property.set("sonar.profile.#{language}", name, project_id) - @projects = nil - end - - def remove_projects - Property.clear_for_resources("sonar.profile.#{language}", name) - @projects = nil - end - def to_hash_json { :name => name, @@ -163,30 +45,11 @@ class Profile < ActiveRecord::Base } end - def self.reset_default_profile_for_project_id(lang, project_id) - Property.clear("sonar.profile.#{lang}", project_id) - end - - def self.by_project_id(language, project_id, returns_default_if_nil=false) - profile_name=Property.value("sonar.profile.#{language}", project_id) - profile = (profile_name.present? ? Profile.find_by_name_and_language(profile_name, language) : nil) - - if !profile && returns_default_if_nil - profile = by_default(language) - end - profile - end - def self.by_default(language) default_name = Property.value("sonar.profile.#{language}") default_name.present? ? Profile.first(:conditions => {:name => default_name, :language => language}) : nil end - # Results are NOT sorted - def self.all_by_language(language) - Profile.all(:conditions => {:language => language}) - end - def self.find_by_name_and_language(name, language) Profile.first(:conditions => {:name => name, :language => language}) end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb deleted file mode 100644 index a62824b7a16..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb +++ /dev/null @@ -1,122 +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. -# - -# -# Class that centralizes the management of resource deletions in Sonar Web UI -# - -require 'singleton' -require 'thread' - -class ResourceDeletionManager - - # mixin the singleton module to ensure we have only one instance of the class - # it will be accessible with "ResourceDeletionManager.instance" - include Singleton - - # the status of the migration - @status - AVAILABLE = "AVAILABLE" - WORKING = "WORKING" - - # the corresponding message that can be given to the user - @message - - # list of resources that could not be deleted because of a problem - @failed_deletions - - # the time when the deletion was started - @start_time - - def initialize - reinit() - end - - def reinit - @message = nil - @status = AVAILABLE - @failed_deletions = [] - end - - def message - @message - end - - def currently_deleting_resources? - @status==WORKING - end - - def deletion_failures_occured? - !failed_deletions.empty? - end - - def failed_deletions - @failed_deletions - end - - def deletion_start_time - @start_time - end - - def delete_resources(resource_ids=[]) - # Use an exclusive block of code to ensure that only 1 thread will be able to proceed with the deletion - can_start_deletion = false - Thread.exclusive do - unless currently_deleting_resources? - reinit() - @status = WORKING - @message = Api::Utils.message('bulk_deletion.deletion_manager.deleting_resources') - can_start_deletion = true - end - end - - if can_start_deletion - if resource_ids.empty? - @status = AVAILABLE - @message = Api::Utils.message('bulk_deletion.deletion_manager.no_resource_to_delete') - else - Thread.new do - Thread.current[:name] = "Bulk Deletion of Projects" - @start_time = Time.now - - java_facade = Java::OrgSonarServerUi::JRubyFacade.getInstance() - # launch the deletion - resource_ids.each_with_index do |resource_id, index| - resource = Project.first(:conditions => {:id => resource_id.to_i}) - @message = Api::Utils.message('bulk_deletion.deletion_manager.currently_deleting_x_out_of_x', :params => [(index+1).to_s, resource_ids.size.to_s]) - if resource && java_facade.getResourceTypeBooleanProperty(resource.qualifier, 'deletable') - begin - java_facade.deleteResourceTree(resource.key) - rescue Exception => e - @failed_deletions << resource.name - # no need to rethrow the exception as it has been logged by the Java component - end - end - end - - @status = AVAILABLE - @message = Api::Utils.message('bulk_deletion.deletion_manager.deletion_completed') - @message += ' ' + Api::Utils.message('bulk_deletion.deletion_manager.however_failures_occurred') unless @failed_deletions.empty? - end - end - end - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/rule.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/rule.rb index a5bd31ca656..1e018a95554 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/rule.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/rule.rb @@ -166,17 +166,6 @@ class Rule < ActiveRecord::Base Rule.first(:conditions => ['status=? and plugin_name=? and id=?', STATUS_READY, MANUAL_REPOSITORY_KEY, id]) end - def self.create_manual_rule(options) - key = options[:name].strip.downcase.gsub(/\s/, '_') - creation_options = {:name => options[:name], - :description => options[:description], - :plugin_rule_key => key, - :status => STATUS_READY, - :is_template => false, - :plugin_name => MANUAL_REPOSITORY_KEY} - Rule.create!(creation_options) - end - def self.to_hash(java_rule) l10n_name = java_rule.getName() l10n_desc = java_rule.getDescription() @@ -187,66 +176,6 @@ class Rule < ActiveRecord::Base hash end - def to_hash_json(profile, active_rule = nil) - json = {'title' => name, 'key' => key, 'plugin' => plugin_name, 'config_key' => config_key} - json['description'] = description if description - if profile - active_rule = active_rule || profile.active_by_rule_id(id) - if active_rule - json['priority'] = active_rule.priority_text - json['status'] = 'ACTIVE' - else - json['priority'] = priority_text - json['status'] = 'INACTIVE' - end - else - json['priority'] = priority_text - end - json['params'] = parameters.collect { |parameter| parameter.to_hash_json(active_rule) } unless parameters.empty? - json - end - - 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) } if description - active_rule = nil - if profile - active_rule = profile.active_by_rule_id(id) - if active_rule - xml.priority(active_rule.priority_text) - xml.status('ACTIVE') - else - xml.priority(priority_text) - xml.status("INACTIVE") - end - else - xml.priority(priority_text) - end - parameters.each do |parameter| - parameter.to_xml(active_rule, xml) - end - end - end - - def to_csv(profile) - csv = [name.strip, plugin_rule_key, plugin_name] - if profile - active_rule = profile.active_by_rule_id(id) - if active_rule - csv << active_rule.priority_text - csv << 'ACTIVE' - else - csv << priority_text - csv << 'INACTIVE' - end - end - csv - end - def self.remove_blank(array) if array array = array - [''] @@ -256,47 +185,6 @@ class Rule < ActiveRecord::Base end end - def self.filter(rules, options) - priorities = remove_blank(options[:priorities]) - profile = options[:profile] - inheritance = options[:inheritance] - - if profile - inactive = (options[:activation]=='INACTIVE') - active = (options[:activation]=='ACTIVE') - - rules = rules.reject do |rule| - active_rule = profile.active_by_rule_id(rule.id) - ((inactive && active_rule) || (active && active_rule.nil?)) - end - - if priorities - rules = rules.select do |rule| - active_rule = profile.active_by_rule_id(rule.id) - (active_rule && priorities.include?(active_rule.priority_text)) || (active_rule.nil? && priorities.include?(rule.priority_text)) - end - end - - if inheritance=='NOT' - rules = rules.select do |rule| - active_rule = profile.active_by_rule_id(rule.id) - (active_rule.nil? || active_rule.inheritance.blank?) - end - elsif inheritance.present? && inheritance != 'any' - rules = rules.select do |rule| - active_rule = profile.active_by_rule_id(rule.id) - (active_rule && active_rule.inheritance==inheritance) - end - end - - elsif priorities - rules = rules.select do |rule| - priorities.include?(rule.priority_text) - end - end - rules - end - def self.sort_by(rules, sort_by) case sort_by when SORT_BY_CREATION_DATE diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/rules_parameter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/rules_parameter.rb index c1785dc0d13..3f01fc4b20f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/rules_parameter.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/rules_parameter.rb @@ -18,7 +18,6 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # class RulesParameter < ActiveRecord::Base - include RulesConfigurationHelper PARAM_MAX_NUMBER = 4 diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/user.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/user.rb index 713faeff81e..73c89188be8 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/user.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/user.rb @@ -129,32 +129,6 @@ class User < ActiveRecord::Base #--------------------------------------------------------------------- # USER PROPERTIES #--------------------------------------------------------------------- - def property(key) - properties().each do |p| - return p if (p.key==key) - end - nil - end - - def property_value(key) - prop=property(key) - prop && prop.value - end - - def set_property(options) - key=options[:prop_key] - prop=property(key) - if prop - prop.attributes=options - prop.user_id=id - prop.save! - else - prop=Property.new(options) - prop.user_id=id - properties<0 - User.find(:all, :select => 'id', :conditions => ['login in (?)', logins]).map { |user| user.id } - else - [] - end - end - #--------------------------------------------------------------------- # FAVOURITES #--------------------------------------------------------------------- diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb deleted file mode 100644 index 7149cb483e6..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -<% - deletion_manager = ResourceDeletionManager.instance - pending_deletions = deletion_manager.currently_deleting_resources? - failed_deletions = deletion_manager.failed_deletions - start_time = deletion_manager.deletion_start_time -%> - -<% if pending_deletions %> - -<% end %> - -
- - -
- <% if pending_deletions %> - <%= image_tag 'loading.gif' -%> - <% end %> - - <%= deletion_manager.message -%> -
-
- <%= message('bulk_deletion.started_since_x', :params => distance_of_time_in_words(start_time, Time.now) ) -%> (<%= l start_time -%>) -
-
- - <% if !pending_deletions && !failed_deletions.empty? %> -

- <%= message('bulk_deletion.following_deletions_failed') -%> -

    - <% failed_deletions.each do |name| %> -
  • <%= name -%>
  • - <% end %> -
-

-

- <%= message('bulk_deletion.hide_message') -%> -

- <% end %> -
-
-- 2.39.5