示例#1
0
  /** Set status and other details correctly for a stopped harvest */
  public void stopHarvest(
      StepLogger slog,
      LinkedList<StagePluginInterface> steps,
      StagePluginInterface harveststage,
      Hashtable<String, Integer> stopFlags)
      throws Exception {

    DateFormat userdateformater = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    userdateformater.setTimeZone(TimeZone.getDefault());

    // We need to call dispose on everything
    harveststage.Dispose();

    for (StagePluginInterface spi : steps) {
      spi.Dispose();
    }

    Integer shutdown = stopFlags.get("ALL");

    if (TaskProcessor.SERVER_SHUTTING_DOWN.equals(shutdown)) {
      slog.info(
          "Harvest stopped since server is shutting down. [Local Time: "
              + userdateformater.format(new Date())
              + "]");
    } else {
      slog.info(
          "Harvest stopped by user. [Local Time: " + userdateformater.format(new Date()) + "]");
    }

    Harvest h = daofactory.getHarvestDAO().getHarvest(harvestid);
    h.setStatuscode(Harvest.SUCCESSFUL);
    h.setStatus("Stopped");
    h.setEndtime(new Date());
    daofactory.getHarvestDAO().ApplyChanges(h);
  }
示例#2
0
 public TaskUtilities(int harvestid, Properties props, ServletContext ctx, Contributor c) {
   daofactory = DAOFactory.getDAOFactory();
   this.props = props;
   this.ctx = ctx;
   this.c = c;
   this.harvestid = harvestid;
 }
示例#3
0
 /**
  * If a user has set them selves up to be notified of harvest results, we email them here
  *
  * @param success status of just finished harvest
  */
 public void email(int success) {
   if (props.get("mail.on") != null && props.get("mail.on").equals("true")) {
     try {
       Harvest h = daofactory.getHarvestDAO().getHarvest(harvestid);
       logger.info("hid=" + harvestid + " " + "setting up email module");
       harvester.processor.email.Email email = new harvester.processor.email.Email();
       email.setC(c);
       email.setH(h);
       email.setProps(props);
       email.setCtx(ctx);
       email.EmailInit();
       if (success == Email.SUCCESS) email.emailSuccess();
       else if (success == Email.HARVEST_ERRORS) email.emailHarvestErrors();
       else if (success == Email.RECORD_FAILURES) email.emailRecordFailure();
       else if (success == Email.HARVEST_FAILURE) email.emailHarvestFailure();
     } catch (Exception e) {
       logger.info("unable to email contacts:" + e.toString());
       for (StackTraceElement el : e.getStackTrace()) logger.error(el.toString());
     }
   } else logger.info("emailing turned off");
 }