Beispiel #1
0
  /**
   * Retrieve the number of entries that is visible to a particular user
   *
   * @param userId user account unique identifier
   * @return Number of entries that user with account referenced in the parameter can read.
   */
  public long getNumberOfVisibleEntries(String userId) {
    Account account = accountController.getByEmail(userId);

    if (account == null) return -1;

    if (authorization.isAdmin(userId)) {
      return dao.getAllEntryCount();
    }

    Set<Group> accountGroups = new HashSet<>(account.getGroups());
    GroupController controller = new GroupController();
    Group everybodyGroup = controller.createOrRetrievePublicGroup();
    accountGroups.add(everybodyGroup);
    return dao.visibleEntryCount(account, accountGroups);
  }