* @return the user's list of permissions\r
*/\r
public List<RegistrantAccessPermission> getRepositoryPermissions() {\r
- List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
+ List<RegistrantAccessPermission> list = new ArrayList<>();\r
if (canAdmin()) {\r
// user has REWIND access to all repositories\r
return list;\r
Collections.sort(list);\r
\r
// include immutable team permissions, being careful to preserve order\r
- Set<RegistrantAccessPermission> set = new LinkedHashSet<RegistrantAccessPermission>(list);\r
- ArrayList<RegistrantAccessPermission> arrayList = new ArrayList<RegistrantAccessPermission>(list);\r
for (TeamModel team : teams) {\r
for (RegistrantAccessPermission teamPermission : team.getRepositoryPermissions()) {\r
// we can not change an inherited team permission, though we can override\r
teamPermission.permissionType = PermissionType.TEAM;\r
teamPermission.source = team.name;\r
teamPermission.mutable = false;\r
- if(arrayList.contains(teamPermission) && arrayList.get(arrayList.indexOf(teamPermission)).permissionType != PermissionType.REGEX){\r
- //checking either to replace permission in set or not\r
- if(teamPermission.permission.compareTo(arrayList.get(arrayList.indexOf(teamPermission)).permission) > 0 ){\r
- arrayList.remove(teamPermission);\r
- arrayList.add(teamPermission);\r
- set.remove(teamPermission);\r
- set.add(teamPermission);\r
- }\r
- }\r
- else{\r
- arrayList.add(teamPermission);\r
- }\r
- set.add(teamPermission);\r
+ int i = list.indexOf(teamPermission);\r
+ if (i < 0) list.add(teamPermission);\r
+ else {\r
+ RegistrantAccessPermission lp = list.get(i);\r
+ if (teamPermission.permission.exceeds(lp.permission)) {\r
+ list.set(i, teamPermission);\r
+ }\r
+ }\r
}\r
}\r
- return new ArrayList<RegistrantAccessPermission>(set);\r
+ return list;\r
}\r
\r
/**\r