private boolean containsPermissionVO( List<ContentPermissionVO> list, ContentPermissionEntity permission) { for (ContentPermissionVO perm : list) { if (perm.getGroup().getId().equals(permission.getGroupId())) { return true; } } return false; }
@Override public List<ContentPermissionVO> selectByUrl(String pageUrl) { List<ContentPermissionEntity> direct = getDao().getContentPermissionDao().selectByUrl(pageUrl); List<ContentPermissionEntity> inherited = getBusiness() .getContentPermissionBusiness() .getInheritedPermissions(UrlUtil.getParentFriendlyURL(pageUrl)); Map<Long, GroupEntity> groups = GroupHelper.createIdMap(getDao().getGroupDao().select()); List<ContentPermissionVO> result = new ArrayList<ContentPermissionVO>(); for (ContentPermissionEntity perm : inherited) { if (!containsPermission(direct, perm) && !containsPermissionVO(result, perm)) { ContentPermissionVO vo = new ContentPermissionVO(perm); vo.setInherited(true); vo.setGroup(groups.get(perm.getGroupId())); result.add(vo); } } for (ContentPermissionEntity perm : direct) { ContentPermissionVO vo = new ContentPermissionVO(perm); vo.setInherited(false); vo.setGroup(groups.get(perm.getGroupId())); result.add(vo); } return result; }