コード例 #1
0
ファイル: EntryController.java プロジェクト: chimaerase/ice
  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;
  }
コード例 #2
0
ファイル: EntryController.java プロジェクト: chimaerase/ice
  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;
  }
コード例 #3
0
ファイル: EntryController.java プロジェクト: chimaerase/ice
  public long getNumberOfOwnerEntries(String requesterUserEmail, String ownerEmail) {
    Account account = DAOFactory.getAccountDAO().getByEmail(requesterUserEmail);
    if (authorization.isAdmin(requesterUserEmail) || account.getEmail().equals(ownerEmail)) {
      return dao.ownerEntryCount(ownerEmail);
    }

    Set<Group> accountGroups = new HashSet<>(account.getGroups());
    GroupController controller = new GroupController();
    Group everybodyGroup = controller.createOrRetrievePublicGroup();
    accountGroups.add(everybodyGroup);
    return dao.ownerEntryCount(account, ownerEmail, accountGroups);
  }
コード例 #4
0
ファイル: EntryController.java プロジェクト: chimaerase/ice
  /**
   * 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);
  }