コード例 #1
0
 @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;
 }
コード例 #2
0
 private boolean containsPermission(
     List<ContentPermissionEntity> list, ContentPermissionEntity permission) {
   for (ContentPermissionEntity perm : list) {
     if (perm.getGroupId().equals(permission.getGroupId())) {
       return true;
     }
   }
   return false;
 }