]> source.dussan.org Git - sonarqube.git/commitdiff
Rename Permisson by GlobalPermission in ruby files
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 19 Sep 2013 17:59:49 +0000 (19:59 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 19 Sep 2013 17:59:49 +0000 (19:59 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/global.html.erb
sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb
sonar-server/src/main/webapp/WEB-INF/lib/need_authorization.rb

index 36715cd1bed9b392af0aba0b12c74ba52753b69f..35bd7b54f207a4391917bdf6c5c3c8987754e92e 100644 (file)
@@ -26,7 +26,7 @@ class BatchBootstrapController < Api::ApiController
 
   # GET /batch_bootstrap/db?project=<key or id>
   def db
-    has_dryrun_role = has_role?(Java::OrgSonarCorePermission::Permission::DRY_RUN_EXECUTION)
+    has_dryrun_role = has_role?(Java::OrgSonarCorePermission::GlobalPermission::DRY_RUN_EXECUTION)
     return render_unauthorized("You're not authorized to execute a dry run analysis. Please contact your SonarQube administrator.") if !has_dryrun_role
     project = load_project()
     return render_unauthorized("You're not authorized to access to project '" + project.name + "', please contact your SonarQube administrator") if project && !has_role?(:user, project)
@@ -37,7 +37,7 @@ class BatchBootstrapController < Api::ApiController
 
   # PUT /batch_bootstrap/evict?project=<key or id>
   def evict
-    has_scan_role = has_role?(Java::OrgSonarCorePermission::Permission::SCAN_EXECUTION)
+    has_scan_role = has_role?(Java::OrgSonarCorePermission::GlobalPermission::SCAN_EXECUTION)
     return render_unauthorized("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.") if !has_scan_role
 
     project = load_project()
@@ -54,8 +54,8 @@ class BatchBootstrapController < Api::ApiController
   # GET /batch_bootstrap/properties?[project=<key or id>][&dryRun=true|false]
   def properties
     dryRun = params[:dryRun].present? && params[:dryRun] == "true"
-    has_dryrun_role = has_role?(Java::OrgSonarCorePermission::Permission::DRY_RUN_EXECUTION)
-    has_scan_role = has_role?(Java::OrgSonarCorePermission::Permission::SCAN_EXECUTION)
+    has_dryrun_role = has_role?(Java::OrgSonarCorePermission::GlobalPermission::DRY_RUN_EXECUTION)
+    has_scan_role = has_role?(Java::OrgSonarCorePermission::GlobalPermission::SCAN_EXECUTION)
 
     return render_unauthorized("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.") if (!has_dryrun_role && !has_scan_role)
     return render_unauthorized("You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.") if (!dryRun && !has_scan_role)
index b05d1f224c3543865297124479a0defafaab2ac2..7d2bc2747e9e6c644659b8f1a4cfafb67c3afad7 100644 (file)
@@ -10,7 +10,7 @@
   </thead>
   <tbody>
   <%
-     permission_keys = Java::OrgSonarCorePermission::Permission::allGlobal.keySet
+     permission_keys = Java::OrgSonarCorePermission::GlobalPermission::allGlobal.keySet
      key_to_name = permission_keys.inject({}) do |hash, key|
        hash[key] = message("global_permissions.#{key}")
        hash
index 5ad9b2fb3d4fada3a474ec69e28360f319840ab6..c4f97f7c5e341dfd600d7ff7cb2f001af3af3834 100644 (file)
@@ -34,11 +34,11 @@ class AddScanAndDryRunPermissions < ActiveRecord::Migration
   def self.up
     # -- Role scan --
     # Anyone
-    GroupRole.create(:group_id => nil, :role => Java::OrgSonarCorePermission::Permission::SCAN_EXECUTION.key, :resource_id => nil)
+    GroupRole.create(:group_id => nil, :role => Java::OrgSonarCorePermission::GlobalPermission::SCAN_EXECUTION.key, :resource_id => nil)
 
     # -- Role dryRunScan --
     # Anyone
-    GroupRole.create(:group_id => nil, :role => Java::OrgSonarCorePermission::Permission::DRY_RUN_EXECUTION.key, :resource_id => nil)
+    GroupRole.create(:group_id => nil, :role => Java::OrgSonarCorePermission::GlobalPermission::DRY_RUN_EXECUTION.key, :resource_id => nil)
   end
 
 end
index 95161fbf12e0e5b1917857f7efab02bf98b67f46..92d5978e94b2497d1cb64ff1c088c141d19a00a1 100644 (file)
@@ -57,10 +57,10 @@ module NeedAuthorization
     # has_role?(:admin, [30,45,7]) checks if the user is administrator of the projects 30, 40 and 7. It returns an array of 3 booleans.
     #
     def has_role?(role, objects=nil)
-      role = role.key if role.java_kind_of?(Java::OrgSonarCorePermission::Permission)
+      role = role.key if role.java_kind_of?(Java::OrgSonarCorePermission::GlobalPermission)
       role = role.to_s
       if objects.nil?
-        if Java::OrgSonarCorePermission::Permission::allGlobal.keySet.include?(role)
+        if Java::OrgSonarCorePermission::GlobalPermission::allGlobal.keySet.include?(role)
           AuthorizerFactory.authorizer.has_role?(self, role.to_sym)
         else
           # There's no concept of global users or global codeviewers.