From ddc1d53a74a150cfa592fb915ef976ede078812b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 27 Nov 2013 03:42:00 +0000 Subject: [PATCH] [MRM-1765] #users > edit -- please sort effective roles git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1545917 13f79535-47bb-0310-9956-ffa450edef68 --- .../services/DefaultRoleManagementService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java index b5d6511f..3c5f9501 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java @@ -54,6 +54,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -261,6 +262,9 @@ public class DefaultRoleManagementService { effectivelyAssignedRoles.add( new Role( r ) ); } + + Collections.sort( effectivelyAssignedRoles, RoleComparator.INSTANCE ); + return effectivelyAssignedRoles; } catch ( RbacManagerException rme ) @@ -270,6 +274,17 @@ public class DefaultRoleManagementService return new ArrayList( 0 ); } + private static class RoleComparator implements Comparator { + + private static RoleComparator INSTANCE = new RoleComparator(); + + @Override + public int compare( Role role, Role role2 ) + { + return role.getName().compareTo( role2.getName() ); + } + } + public List getApplications( String username ) throws RedbackServiceException