* @param permissions the list of permissions to get
* @param entity the entity to get for
* @return {@link org.jtalks.jcommune.model.dto.GroupsPermissions} for provided {@link org.jtalks.common.model.entity.Entity}
*/
public GroupsPermissions getPermissionsMapFor(List<JtalksPermission> permissions, Entity entity) {
GroupsPermissions groupsPermissions = new GroupsPermissions(permissions);
List<GroupAce> groupAces = aclManager.getGroupPermissionsOn(entity);
for (JtalksPermission permission : permissions) {
for (GroupAce groupAce : groupAces) {
if (groupAce.getPermissionMask() == permission.getMask()) {
groupsPermissions.add(permission, getGroup(groupAce), groupAce.isGranting());
}
}
for (AccessControlEntry controlEntry : aclUtil.getAclFor(entity).getEntries()) {
if (controlEntry.getPermission().equals(permission)
&& ((UniversalSid)controlEntry.getSid()).getSidId().equals(UserSid.createAnonymous().getSidId())) {
groupsPermissions.add(permission, AnonymousGroup.ANONYMOUS_GROUP, controlEntry.isGranting());
}
}
}
return groupsPermissions;
}