aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-26 16:38:13 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-10-05 13:18:11 +0200
commitac56b7dfeb4252dec8594f8869913b88da3d996c (patch)
treea004701ae697b512e8fee921b997ba94928023fa /server
parentd901a2ade4aee181ba26d2e1522201cf09ce40d5 (diff)
downloadsonarqube-ac56b7dfeb4252dec8594f8869913b88da3d996c.tar.gz
sonarqube-ac56b7dfeb4252dec8594f8869913b88da3d996c.zip
Remove ruby dead code related to roles
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb1
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb1
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb45
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/group_role.rb16
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb15
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb9
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/user.rb10
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/user_role.rb16
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb2
9 files changed, 1 insertions, 114 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
index 179f5b85fd7..aee910ec9fe 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb
@@ -18,7 +18,6 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
class ProjectRolesController < ApplicationController
- helper RolesHelper
SECTION=Navigation::SECTION_RESOURCE
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb
index bb4f673275a..299d254f952 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb
@@ -18,7 +18,6 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
class RolesController < ApplicationController
- helper RolesHelper
SECTION=Navigation::SECTION_CONFIGURATION
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
deleted file mode 100644
index 03823212cf9..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/roles_helper.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.
-#
-module RolesHelper
-
- def users(role, resource_id=nil)
- resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- user_roles=UserRole.all(:include => 'user', :conditions => {:role => role, :resource_id => resource_id, :users => {:active => true}})
- users = user_roles.map { |ur| ur.user }
- Api::Utils.insensitive_sort(users) { |user| user.name }
- end
-
- def all_users
- users = User.all(:conditions => ["active=?", true])
- Api::Utils.insensitive_sort(users) { |user| user.name }
- end
-
- def groups(role, resource_id=nil)
- resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- group_roles=GroupRole.all(:include => 'group', :conditions => {:role => role, :resource_id => resource_id})
- groups = group_roles.map { |ur| ur.group }
- Api::Utils.insensitive_sort(groups) { |group| group ? group.name : '' }
- end
-
- def group_name(group)
- group ? group.name : 'Anyone'
- end
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/group_role.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/group_role.rb
index 8fc42c7f718..0acd7b95a3f 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/group_role.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/group_role.rb
@@ -19,20 +19,4 @@
#
class GroupRole < ActiveRecord::Base
- belongs_to :group
- belongs_to :resource, :class_name => 'Project', :foreign_key => "resource_id"
-
- def self.grant_groups(group_ids, role, resource_id=nil)
- resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- if resource_id
- GroupRole.delete_all(["role=? and resource_id=?", role, resource_id])
- else
- GroupRole.delete_all(["role=? and resource_id is null", role])
- end
- if group_ids
- group_ids.compact.uniq.each do |group_id|
- GroupRole.create(:group_id => group_id, :role => role, :resource_id => resource_id)
- end
- end
- end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb
index 204c8f49b83..45faacb4800 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb
@@ -244,21 +244,6 @@ class Metric < ActiveRecord::Base
result.compact.uniq
end
- def self.ids_from_keys(keys_array)
- keys_array.collect{ |key| Metric.by_name(key).id if Metric.by_name(key) }
- end
-
- def self.delete_with_manual_measures(id)
- ManualMeasure.delete_all(["metric_id = ?", id])
- self.deactivate(id)
- end
-
- def self.deactivate(id)
- metric = by_id(id)
- metric.enabled = false
- metric.save!
- end
-
def to_hash_json(options={})
return {'key' => name, 'name' => short_name, 'description' => description, 'domain' => domain,
'qualitative' => qualitative, 'user_managed' => self.user_managed,
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
index 863b6bf1a67..800f8e53133 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb
@@ -23,8 +23,6 @@ class Project < ActiveRecord::Base
has_many :events, :foreign_key => 'component_uuid', :primary_key => 'uuid', :order => 'event_date DESC'
has_many :project_links, :foreign_key => 'component_uuid', :primary_key => 'uuid', :dependent => :delete_all, :order => 'link_type'
- has_many :user_roles, :foreign_key => 'resource_id'
- has_many :group_roles, :foreign_key => 'resource_id'
has_many :manual_measures, :foreign_key => 'component_uuid', :primary_key => 'uuid'
belongs_to :root, :class_name => 'Project', :foreign_key => 'root_uuid', :primary_key => 'uuid'
belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_component_uuid', :primary_key => 'uuid'
@@ -50,13 +48,6 @@ class Project < ActiveRecord::Base
end
end
- def self.delete_resource_tree(project)
- java_facade = Java::OrgSonarServerUi::JRubyFacade.getInstance()
- if project && java_facade.getResourceTypeBooleanProperty(project.qualifier, 'deletable')
- java_facade.deleteResourceTree(project.key)
- end
- end
-
def self.root_qualifiers()
@root_types ||=
begin
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 0bb1010d6d7..27954262a92 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
@@ -25,7 +25,6 @@ class User < ActiveRecord::Base
has_and_belongs_to_many :groups
- has_many :user_roles, :dependent => :delete_all
has_many :properties, :foreign_key => 'user_id', :dependent => :delete_all
has_many :active_dashboards, :dependent => :destroy, :order => 'order_index'
has_many :dashboards, :dependent => :destroy
@@ -83,15 +82,6 @@ class User < ActiveRecord::Base
write_attribute :email, (value && value.downcase)
end
- # SCM accounts should also contain login and email
- def full_scm_accounts
- new_scm_accounts = self.scm_accounts.split(/\r?\n/).reject { |c| c.empty? } if self.scm_accounts
- new_scm_accounts = [] unless new_scm_accounts
- new_scm_accounts << self.login
- new_scm_accounts << self.email
- new_scm_accounts
- end
-
def <=>(other)
return -1 if name.nil?
return 1 if other.name.nil?
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/user_role.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/user_role.rb
index d9e91113910..a80ca615ade 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/user_role.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/user_role.rb
@@ -18,21 +18,5 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
class UserRole < ActiveRecord::Base
- belongs_to :user
- belongs_to :resource, :class_name => 'Project', :foreign_key => "resource_id"
- def self.grant_users(user_ids, role, resource_id)
- resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- if resource_id
- UserRole.delete_all(["role=? and resource_id=?", role, resource_id])
- else
- UserRole.delete_all(["role=? and resource_id is null", role])
- end
-
- if user_ids
- user_ids.compact.uniq.each do |user_id|
- UserRole.create(:user_id => user_id, :role=> role, :resource_id => resource_id)
- end
- end
- end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb
index 1350390f746..f19b47ac992 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb
@@ -110,7 +110,7 @@ class DefaultAuthorizer
)
end
end
- global_user_roles=user.user_roles.select{|ur| ur.resource_id.nil?}.map{|ur| ur.role.to_sym}
+ global_user_roles=UserRole.all(:select => 'role', :conditions => ["user_id=? and resource_id is null", user.id]).map{|ur| ur.role.to_sym}
global_roles=(global_group_roles.concat(global_user_roles))
global_roles