@@ -110,7 +110,7 @@ public boolean isLocalAccount() {
110110 * @return the user's list of permissions
111111 */
112112 public List <RegistrantAccessPermission > getRepositoryPermissions () {
113- List <RegistrantAccessPermission > list = new ArrayList <RegistrantAccessPermission >();
113+ List <RegistrantAccessPermission > list = new ArrayList <>();
114114 if (canAdmin ()) {
115115 // user has REWIND access to all repositories
116116 return list ;
@@ -135,31 +135,24 @@ public List<RegistrantAccessPermission> getRepositoryPermissions() {
135135 Collections .sort (list );
136136
137137 // include immutable team permissions, being careful to preserve order
138- Set <RegistrantAccessPermission > set = new LinkedHashSet <RegistrantAccessPermission >(list );
139- ArrayList <RegistrantAccessPermission > arrayList = new ArrayList <RegistrantAccessPermission >(list );
140138 for (TeamModel team : teams ) {
141139 for (RegistrantAccessPermission teamPermission : team .getRepositoryPermissions ()) {
142140 // we can not change an inherited team permission, though we can override
143141 teamPermission .registrantType = RegistrantType .REPOSITORY ;
144142 teamPermission .permissionType = PermissionType .TEAM ;
145143 teamPermission .source = team .name ;
146144 teamPermission .mutable = false ;
147- if (arrayList .contains (teamPermission ) && arrayList .get (arrayList .indexOf (teamPermission )).permissionType != PermissionType .REGEX ){
148- //checking either to replace permission in set or not
149- if (teamPermission .permission .compareTo (arrayList .get (arrayList .indexOf (teamPermission )).permission ) > 0 ){
150- arrayList .remove (teamPermission );
151- arrayList .add (teamPermission );
152- set .remove (teamPermission );
153- set .add (teamPermission );
154- }
155- }
156- else {
157- arrayList .add (teamPermission );
158- }
159- set .add (teamPermission );
145+ int i = list .indexOf (teamPermission );
146+ if (i < 0 ) list .add (teamPermission );
147+ else {
148+ RegistrantAccessPermission lp = list .get (i );
149+ if (teamPermission .permission .exceeds (lp .permission )) {
150+ list .set (i , teamPermission );
151+ }
152+ }
160153 }
161154 }
162- return new ArrayList < RegistrantAccessPermission >( set ) ;
155+ return list ;
163156 }
164157
165158 /**
0 commit comments