コード例 #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
  /**
   * Get the recently submitted items for the given collection.
   *
   * @param collection The collection.
   */
  @SuppressWarnings(
      "unchecked") // The cast from getLastSubmitted is correct, it dose infact return a list of
                   // Items.
  private java.util.List<BrowseItem> getRecientlySubmittedIems(Collection collection)
      throws SQLException {
    if (recentSubmissionItems != null) return recentSubmissionItems;

    String source = ConfigurationManager.getProperty("recent.submissions.sort-option");
    BrowserScope scope = new BrowserScope(context);
    scope.setCollection(collection);
    scope.setResultsPerPage(RECENT_SUBMISISONS);

    // FIXME Exception Handling
    try {
      scope.setBrowseIndex(BrowseIndex.getItemBrowseIndex());
      for (SortOption so : SortOption.getSortOptions()) {
        if (so.getName().equals(source)) scope.setSortBy(so.getNumber());
      }

      BrowseEngine be = new BrowseEngine(context);
      this.recentSubmissionItems = be.browse(scope).getResults();
    } catch (BrowseException bex) {
      log.error("Caught BrowseException", bex);
    }

    return this.recentSubmissionItems;
  }
コード例 #3
0
  /**
   * Get the results of the browse. If the results haven't been generated yet, then this will
   * perform the browse.
   *
   * @return
   * @throws SQLException
   * @throws UIException
   */
  private BrowseInfo getBrowseInfo() throws SQLException, UIException {
    if (this.browseInfo != null) return this.browseInfo;

    Context context = ContextUtil.obtainContext(objectModel);

    // Get the parameters we will use for the browse
    // (this includes a browse scope)
    BrowseParams params = getUserParams();

    try {
      // Create a new browse engine, and perform the browse
      BrowseEngine be = new BrowseEngine(context);
      this.browseInfo = be.browse(params.scope);

      // figure out the setting for author list truncation
      if (params.etAl < 0) {
        // there is no limit, or the UI says to use the default
        int etAl = ConfigurationManager.getIntProperty("webui.browse.author-limit");
        if (etAl != 0) {
          this.browseInfo.setEtAl(etAl);
        }

      } else if (params.etAl == 0) // 0 is the user setting for unlimited
      {
        this.browseInfo.setEtAl(-1); // but -1 is the application
        // setting for unlimited
      } else
      // if the user has set a limit
      {
        this.browseInfo.setEtAl(params.etAl);
      }
    } catch (BrowseException bex) {
      throw new UIException("Unable to process browse", bex);
    }

    return this.browseInfo;
  }