Package org.dspace.harvest

Examples of org.dspace.harvest.OAIHarvester


     */
    private void runHarvest(String collectionID, String email) {
      System.out.println("Running: a harvest cycle on " + collectionID);
     
      System.out.print("Initializing the harvester... ");
      OAIHarvester harvester = null;
      try {
        Collection collection = resolveCollection(collectionID);
          HarvestedCollection hc = HarvestedCollection.find(context, collection.getID());
        harvester = new OAIHarvester(context, collection, hc);
        System.out.println("success. ");
      }
      catch (HarvestingException hex) {
        System.out.print("failed. ");
        System.out.println(hex.getMessage());
        System.exit(1);
      } catch (SQLException se) {
      // TODO Auto-generated catch block
      se.printStackTrace();
    }
           
      try {
        // Harvest will not work for an anonymous user
          EPerson eperson = EPerson.findByEmail(context, email);
          System.out.println("Harvest started... ");
          context.setCurrentUser(eperson);
        harvester.runHarvest();
        context.complete();
      }
      catch (Exception e) {
      // Not much else we can do at this point
      e.printStackTrace();
View Full Code Here


   * @throws CrosswalkException
   */
  public static FlowResult processRunCollectionHarvest(Context context, int collectionID, Request request) throws SQLException, IOException, AuthorizeException, CrosswalkException, ParserConfigurationException, SAXException, TransformerException
  {
    FlowResult result = new FlowResult();
    OAIHarvester harvester;
    List<String> testErrors = new ArrayList<String>();
    Collection collection = Collection.find(context, collectionID);
    HarvestedCollection hc = HarvestedCollection.find(context, collectionID);

    //TODO: is there a cleaner way to do this?
    try {
      if (HarvestScheduler.status != HarvestScheduler.HARVESTER_STATUS_STOPPED) {
        synchronized(HarvestScheduler.lock) {
          HarvestScheduler.interrupt = HarvestScheduler.HARVESTER_INTERRUPT_INSERT_THREAD;
          HarvestScheduler.interruptValue = collection.getID();
          HarvestScheduler.lock.notify();
        }
      }
      else {
        harvester = new OAIHarvester(context, collection, hc);
        harvester.runHarvest();
      }
    }
    catch (Exception e) {
      testErrors.add(e.getMessage());
      result.setErrors(testErrors);
View Full Code Here

   * @throws CrosswalkException
   */
  public static FlowResult processRunCollectionHarvest(Context context, int collectionID, Request request) throws SQLException, IOException, AuthorizeException, CrosswalkException, ParserConfigurationException, SAXException, TransformerException
  {
    FlowResult result = new FlowResult();
    OAIHarvester harvester;
    List<String> testErrors = new ArrayList<String>();
    Collection collection = Collection.find(context, collectionID);
    HarvestedCollection hc = HarvestedCollection.find(context, collectionID);

    //TODO: is there a cleaner way to do this?
    try {
      if (!HarvestScheduler.hasStatus(HarvestScheduler.HARVESTER_STATUS_STOPPED)) {
        synchronized(HarvestScheduler.lock) {
          HarvestScheduler.setInterrupt(HarvestScheduler.HARVESTER_INTERRUPT_INSERT_THREAD, collectionID);
          HarvestScheduler.lock.notify();
        }
      }
      else {
        harvester = new OAIHarvester(context, collection, hc);
        harvester.runHarvest();
      }
    }
    catch (Exception e) {
      testErrors.add(e.getMessage());
      result.setErrors(testErrors);
View Full Code Here

     */
    private void runHarvest(String collectionID, String email) {
      System.out.println("Running: a harvest cycle on " + collectionID);
     
      System.out.print("Initializing the harvester... ");
      OAIHarvester harvester = null;
      try {
        Collection collection = resolveCollection(collectionID);
          HarvestedCollection hc = HarvestedCollection.find(context, collection.getID());
        harvester = new OAIHarvester(context, collection, hc);
        System.out.println("success. ");
      }
      catch (HarvestingException hex) {
        System.out.print("failed. ");
        System.out.println(hex.getMessage());
        throw new IllegalStateException("Unable to harvest", hex);
      } catch (SQLException se) {
            System.out.print("failed. ");
            System.out.println(se.getMessage());
            throw new IllegalStateException("Unable to access database", se);
    }
           
      try {
        // Harvest will not work for an anonymous user
          EPerson eperson = EPerson.findByEmail(context, email);
          System.out.println("Harvest started... ");
          context.setCurrentUser(eperson);
        harvester.runHarvest();
        context.complete();
      }
        catch (SQLException e) {
            throw new IllegalStateException("Failed to run harvester", e);
        }
View Full Code Here

TOP

Related Classes of org.dspace.harvest.OAIHarvester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.