@Override
 public List<Resource> filterList(List<Resource> resourceList, Session cs) {
   for (Iterator<Resource> it = resourceList.iterator(); it.hasNext(); ) {
     Resource resource = it.next();
     if (!resource.getActive()) {
       if (!(cs.getPrivileges() != null && checkPrivileges(resource, cs.getPrivileges()))) {
         it.remove();
       }
     }
   }
   return resourceList;
 }
 @Override
 public boolean checkReadPermission(Resource resource, Session cs) {
   if (cs.getPrivileges() != null) {
     if (checkPrivileges(resource, cs.getPrivileges())) {
       return true;
     }
   }
   Map<Long, Resource> groupMap = new HashMap<Long, Resource>();
   for (Iterator<Resource> it = cs.getGroups().iterator(); it.hasNext(); ) {
     Resource currGroup = it.next();
     groupMap.put(currGroup.getId(), currGroup);
   }
   if (resource.getOwnResourceId().equals(cs.getAccount().getResource().getId())) {
     Byte permission = resource.getCurrentAccountPermission();
     if (permission.equals(CommonConstants.PERMISSION.ALL)
         || permission.equals(CommonConstants.PERMISSION.RW)
         || permission.equals(CommonConstants.PERMISSION.RX)
         || permission.equals(CommonConstants.PERMISSION.READ)) {
       return true;
     }
   }
   if (groupMap.get(resource.getOwnGroupResourceId()) != null) {
     Byte permission = resource.getCurrentGroupPermission();
     if (permission.equals(CommonConstants.PERMISSION.ALL)
         || permission.equals(CommonConstants.PERMISSION.RW)
         || permission.equals(CommonConstants.PERMISSION.RX)
         || permission.equals(CommonConstants.PERMISSION.READ)) {
       return true;
     }
   }
   Byte permission = resource.getOthersPermission();
   if (permission.equals(CommonConstants.PERMISSION.ALL)
       || permission.equals(CommonConstants.PERMISSION.RW)
       || permission.equals(CommonConstants.PERMISSION.RX)
       || permission.equals(CommonConstants.PERMISSION.READ)) {
     return true;
   }
   return false;
 }