Ejemplo n.º 1
0
  public FolderDetails retrieveVisibleEntries(
      String userId, ColumnField field, boolean asc, int start, int limit) {
    Set<Entry> results;
    FolderDetails details = new FolderDetails();
    Account account = accountController.getByEmail(userId);

    if (authorization.isAdmin(userId)) {
      // no filters
      results = dao.retrieveAllEntries(field, asc, start, limit);
    } else {
      // retrieve groups for account and filter by permission
      Set<Group> accountGroups = new HashSet<>(account.getGroups());
      GroupController controller = new GroupController();
      Group everybodyGroup = controller.createOrRetrievePublicGroup();
      accountGroups.add(everybodyGroup);
      results = dao.retrieveVisibleEntries(account, accountGroups, field, asc, start, limit);
    }

    for (Entry entry : results) {
      PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
      details.getEntries().add(info);
    }

    return details;
  }