From: kaspars.kurms Date: Mon, 11 Jul 2016 09:55:21 +0000 (+0300) Subject: fix user effective permission display if users is in multiple groups with different... X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea9526d456219a063296ddce2f29c9de802ffa8c;p=gitblit.git fix user effective permission display if users is in multiple groups with different permissions --- diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index 1d9e413b..1d95569f 100644 --- a/src/main/java/com/gitblit/models/UserModel.java +++ b/src/main/java/com/gitblit/models/UserModel.java @@ -136,6 +136,7 @@ public class UserModel implements Principal, Serializable, Comparable // include immutable team permissions, being careful to preserve order Set set = new LinkedHashSet(list); + ArrayList arrayList = new ArrayList(list); for (TeamModel team : teams) { for (RegistrantAccessPermission teamPermission : team.getRepositoryPermissions()) { // we can not change an inherited team permission, though we can override @@ -143,6 +144,18 @@ public class UserModel implements Principal, Serializable, Comparable teamPermission.permissionType = PermissionType.TEAM; teamPermission.source = team.name; teamPermission.mutable = false; + if(arrayList.contains(teamPermission) && arrayList.get(arrayList.indexOf(teamPermission)).permissionType != PermissionType.REGEX){ + //checking either to replace permission in set or not + if(teamPermission.permission.compareTo(arrayList.get(arrayList.indexOf(teamPermission)).permission) > 0 ){ + arrayList.remove(teamPermission); + arrayList.add(teamPermission); + set.remove(teamPermission); + set.add(teamPermission); + } + } + else{ + arrayList.add(teamPermission); + } set.add(teamPermission); } }