Beispiel #1
0
  public List<PartData> retrieveOwnerEntries(
      String userId, String ownerEmail, ColumnField sort, boolean asc, int start, int limit) {
    List<Entry> entries;
    Account account = DAOFactory.getAccountDAO().getByEmail(userId);

    if (authorization.isAdmin(userId) || account.getEmail().equals(ownerEmail)) {
      entries = dao.retrieveOwnerEntries(ownerEmail, sort, asc, start, limit);
    } else {
      Set<Group> accountGroups = new HashSet<>(account.getGroups());
      GroupController controller = new GroupController();
      Group everybodyGroup = controller.createOrRetrievePublicGroup();
      accountGroups.add(everybodyGroup);
      // retrieve entries for user that can be read by others
      entries =
          dao.retrieveUserEntries(account, ownerEmail, accountGroups, sort, asc, start, limit);
    }

    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : entries) {
      PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
      info.setViewCount(DAOFactory.getAuditDAO().getHistoryCount(entry));
      data.add(info);
    }
    return data;
  }