\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
}\r
}\r