From: Jean-Baptiste Vilain Date: Wed, 24 Jul 2013 08:09:48 +0000 (+0200) Subject: SONAR-3392 Disable paging when searching for components to which a permission templat... X-Git-Tag: 3.7~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5edbce381be268c40e7ea907274d68147a24a717;p=sonarqube.git SONAR-3392 Disable paging when searching for components to which a permission template should be applied --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 6c511ff2322..38febb52930 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -2263,7 +2263,6 @@ projects_role.bulk_change=Bulk Change projects_role.apply_template=Apply Permission Template projects_role.apply_template_to_xxx=Apply Permission Template To "{0}" projects_role.no_projects=There are currently no results to apply the permission template to. -projects_role.exceeds_projects_limit_xxx=The current selection exceeds the limit of {0} projects that can be updated in a row. Please narrow your search before applying the permission template. diff --git a/sonar-server/src/main/java/org/sonar/server/component/ComponentQuery.java b/sonar-server/src/main/java/org/sonar/server/component/ComponentQuery.java index 32bcb356557..387963227e7 100644 --- a/sonar-server/src/main/java/org/sonar/server/component/ComponentQuery.java +++ b/sonar-server/src/main/java/org/sonar/server/component/ComponentQuery.java @@ -37,6 +37,7 @@ public class ComponentQuery { public static final int DEFAULT_PAGE_INDEX = 1; public static final int DEFAULT_PAGE_SIZE = 100; + public static final int NO_PAGINATION = -1; public static final String SORT_BY_NAME = "NAME"; public static final Set SORTS = ImmutableSet.of(SORT_BY_NAME); diff --git a/sonar-server/src/main/java/org/sonar/server/component/DefaultComponentFinder.java b/sonar-server/src/main/java/org/sonar/server/component/DefaultComponentFinder.java index 6bd4e9291de..ac199cbb23b 100644 --- a/sonar-server/src/main/java/org/sonar/server/component/DefaultComponentFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/component/DefaultComponentFinder.java @@ -57,11 +57,16 @@ public class DefaultComponentFinder { // 2. Sort components Collection sortedComponents = new ComponentsFinderSort(foundComponents, query).sort(); - // 3. Apply pagination - Paging paging = Paging.create(query.pageSize(), query.pageIndex(), foundComponents.size()); - Collection pagedComponents = pagedComponents(sortedComponents, paging); + if(ComponentQuery.NO_PAGINATION == query.pageSize()) { + return new DefaultComponentQueryResult(sortedComponents).setQuery(query); + } else { + // 3. Apply pagination + Paging paging = Paging.create(query.pageSize(), query.pageIndex(), foundComponents.size()); + Collection pagedComponents = pagedComponents(sortedComponents, paging); + + return new DefaultComponentQueryResult(pagedComponents).setPaging(paging).setQuery(query); + } - return new DefaultComponentQueryResult(pagedComponents).setPaging(paging).setQuery(query); } finally { LOG.debug("ComponentQuery execution time : {} ms", System.currentTimeMillis() - start); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb index d49b116980f..3b68aac03b5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb @@ -21,7 +21,6 @@ class RolesController < ApplicationController helper RolesHelper SECTION=Navigation::SECTION_CONFIGURATION - BULK_LIMIT=500 before_filter :admin_required verify :method => :post, :only => [:set_users, :set_groups], :redirect_to => {:action => 'global'} @@ -84,19 +83,17 @@ class RolesController < ApplicationController @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]} params['qualifiers'] ||= 'TRK' - params['pageSize'] = 500 + params['pageSize'] = -1 query_result = Internal.component_api.find(params) components = query_result.components().to_a - total_results_count = query_result.paging.total.to_i @projects_ids = components.collect{|component| component.getId()} @qualifier = params[:qualifiers] render :partial => 'apply_template_form', :locals => {:project_name => components.size == 1 ? components[0].name : nil, - :empty => @projects_ids.nil? || @projects_ids.size == 0, - :overflow => total_results_count > BULK_LIMIT} + :empty => @projects_ids.nil? || @projects_ids.size == 0} end # POST /roles/apply_template?criteria diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb index c8796ae10eb..58e2a63cbb6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb @@ -1,5 +1,5 @@
- <% unless @projects_ids.nil? %> + <% unless empty %> <% end %>
@@ -17,11 +17,6 @@ <%= message 'projects_role.no_projects' -%> - <% elsif overflow %> -
- - <%= message 'projects_role.exceeds_projects_limit_xxx', :params => RolesController::BULK_LIMIT -%> -
<% else %>