コード例 #1
0
  /**
   * Purge the collection of all items, then run a fresh harvest cycle.
   *
   * @param context The current DSpace context.
   * @param collectionID The collection id.
   * @param request the Cocoon request object
   * @return A process result's object.
   * @throws TransformerException
   * @throws SAXException
   * @throws ParserConfigurationException
   * @throws CrosswalkException
   * @throws BrowseException
   */
  public static FlowResult processReimportCollection(
      Context context, int collectionID, Request request)
      throws SQLException, IOException, AuthorizeException, CrosswalkException,
          ParserConfigurationException, SAXException, TransformerException, BrowseException {
    Collection collection = Collection.find(context, collectionID);
    HarvestedCollection hc = HarvestedCollection.find(context, collectionID);

    ItemIterator it = collection.getAllItems();
    // IndexBrowse ib = new IndexBrowse(context);
    while (it.hasNext()) {
      Item item = it.next();
      // System.out.println("Deleting: " + item.getHandle());
      // ib.itemRemoved(item);
      collection.removeItem(item);
    }
    hc.setHarvestResult(null, "");
    hc.update();
    collection.update();
    context.commit();

    return processRunCollectionHarvest(context, collectionID, request);
  }