예제 #1
0
파일: FeedServlet.java 프로젝트: ekate/fda5
  // returns recently changed items, checking for accessibility
  private Item[] getItems(Context context, DSpaceObject dso) throws IOException, SQLException {
    try {
      // new method of doing the browse:
      String idx = ConfigurationManager.getProperty("recent.submissions.sort-option");
      if (idx == null) {
        throw new IOException(
            "There is no configuration supplied for: recent.submissions.sort-option");
      }
      BrowseIndex bix = BrowseIndex.getItemBrowseIndex();
      if (bix == null) {
        throw new IOException("There is no browse index with the name: " + idx);
      }

      BrowserScope scope = new BrowserScope(context);
      scope.setBrowseIndex(bix);
      if (dso != null) {
        scope.setBrowseContainer(dso);
      }

      for (SortOption so : SortOption.getSortOptions()) {
        if (so.getName().equals(idx)) {
          scope.setSortBy(so.getNumber());
        }
      }
      scope.setOrder(SortOption.DESCENDING);
      scope.setResultsPerPage(itemCount);

      // gather & add items to the feed.
      BrowseEngine be = new BrowseEngine(context);
      BrowseInfo bi = be.browseMini(scope);
      Item[] results = bi.getItemResults(context);

      if (includeAll) {
        return results;
      } else {
        // Check to see if we can include this item
        // Group[] authorizedGroups = AuthorizeManager.getAuthorizedGroups(context, results[i],
        // Constants.READ);
        // boolean added = false;
        List<Item> items = new ArrayList<Item>();
        for (Item result : results) {
          checkAccess:
          for (Group group :
              AuthorizeManager.getAuthorizedGroups(context, result, Constants.READ)) {
            if ((group.getID() == Group.ANONYMOUS_ID)) {
              items.add(result);
              break checkAccess;
            }
          }
        }
        return items.toArray(new Item[items.size()]);
      }
    } catch (SortException se) {
      log.error("caught exception: ", se);
      throw new IOException(se.getMessage(), se);
    } catch (BrowseException e) {
      log.error("caught exception: ", e);
      throw new IOException(e.getMessage(), e);
    }
  }
예제 #2
0
  protected void buildSearchControls(Division div) throws WingException {
    Table controlsTable = div.addTable("search-controls", 1, 3);
    Row controlsRow = controlsTable.addRow(Row.ROLE_DATA);

    // Create a control for the number of records to display
    Cell rppCell = controlsRow.addCell();
    rppCell.addContent(T_rpp);
    Select rppSelect = rppCell.addSelect("rpp");
    for (int i : RESULTS_PER_PAGE_PROGRESSION) {
      rppSelect.addOption((i == getParameterRpp()), i, Integer.toString(i));
    }

    Cell sortCell = controlsRow.addCell();
    try {
      // Create a drop down of the different sort columns available
      sortCell.addContent(T_sort_by);
      Select sortSelect = sortCell.addSelect("sort_by");
      sortSelect.addOption(false, 0, T_sort_by_relevance);
      for (SortOption so : SortOption.getSortOptions()) {
        if (so.isVisible()) {
          sortSelect.addOption(
              (so.getNumber() == getParameterSortBy()),
              so.getNumber(),
              message("xmlui.ArtifactBrowser.AbstractSearch.sort_by." + so.getName()));
        }
      }
    } catch (SortException se) {
      throw new WingException("Unable to get sort options", se);
    }

    // Create a control to changing ascending / descending order
    Cell orderCell = controlsRow.addCell();
    orderCell.addContent(T_order);
    Select orderSelect = orderCell.addSelect("order");
    orderSelect.addOption(
        SortOption.ASCENDING.equals(getParameterOrder()), SortOption.ASCENDING, T_order_asc);
    orderSelect.addOption(
        SortOption.DESCENDING.equals(getParameterOrder()), SortOption.DESCENDING, T_order_desc);

    // Create a control for the number of authors per item to display
    // FIXME This is currently disabled, as the supporting functionality
    // is not currently present in xmlui
    // if (isItemBrowse(info))
    // {
    //    controlsForm.addContent(T_etal);
    //    Select etalSelect = controlsForm.addSelect(BrowseParams.ETAL);
    //
    //    etalSelect.addOption((info.getEtAl() < 0), 0, T_etal_all);
    //    etalSelect.addOption(1 == info.getEtAl(), 1, Integer.toString(1));
    //
    //    for (int i = 5; i <= 50; i += 5)
    //    {
    //        etalSelect.addOption(i == info.getEtAl(), i, Integer.toString(i));
    //    }
    // }
  }