@@ -110,7 +110,7 @@ public boolean isLocalAccount() {
110
110
* @return the user's list of permissions
111
111
*/
112
112
public List <RegistrantAccessPermission > getRepositoryPermissions () {
113
- List <RegistrantAccessPermission > list = new ArrayList <RegistrantAccessPermission >();
113
+ List <RegistrantAccessPermission > list = new ArrayList <>();
114
114
if (canAdmin ()) {
115
115
// user has REWIND access to all repositories
116
116
return list ;
@@ -135,31 +135,24 @@ public List<RegistrantAccessPermission> getRepositoryPermissions() {
135
135
Collections .sort (list );
136
136
137
137
// 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 );
140
138
for (TeamModel team : teams ) {
141
139
for (RegistrantAccessPermission teamPermission : team .getRepositoryPermissions ()) {
142
140
// we can not change an inherited team permission, though we can override
143
141
teamPermission .registrantType = RegistrantType .REPOSITORY ;
144
142
teamPermission .permissionType = PermissionType .TEAM ;
145
143
teamPermission .source = team .name ;
146
144
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
+ }
160
153
}
161
154
}
162
- return new ArrayList < RegistrantAccessPermission >( set ) ;
155
+ return list ;
163
156
}
164
157
165
158
/**
0 commit comments