Examples of HarvesterConfiguration


Examples of com.esri.gpt.control.webharvest.engine.HarvesterConfiguration

* Loads harvester configuration.
* @param appConfig application configuration
*/
private void loadHarvesterConfiguration(ApplicationConfiguration appConfig, Document dom, Node root) throws XPathExpressionException {
  StringAttributeMap parameters = appConfig.getCatalogConfiguration().getParameters();
  HarvesterConfiguration cfg = appConfig.getHarvesterConfiguration();

  String active = Val.chkStr(parameters.getValue("webharvester.active"));
  String suspended = Val.chkStr(parameters.getValue("webharvester.suspended"));
  String queueEnabled = Val.chkStr(parameters.getValue("webharvester.queueEnabled"));
  String poolsize = Val.chkStr(parameters.getValue("webharvester.poolSize"));
  String autoselectfrequency = Val.chkStr(parameters.getValue("webharvester.autoSelectFrequency"));
  String watchdogfrequency = Val.chkStr(parameters.getValue("webharvester.watchDogFrequency"));
  String basecontextpath = Val.chkStr(parameters.getValue("webharvester.baseContextPath"));
  String maxRepRecords = Val.chkStr(parameters.getValue("webharvester.maxRepRecords"));
  String maxRepErrors = Val.chkStr(parameters.getValue("webharvester.maxRepErrors"));
  String resourceAutoApprove = Val.chkStr(parameters.getValue("webharvester.resource.autoApprove"));

  Logger logger = getLogger();

  if (Val.chkBool(active, true)) {
    cfg.setActive(true);
    cfg.setQueueEnabled(true);
  } else {
    cfg.setActive(false);
    cfg.setQueueEnabled(false);
  }

  if (Val.chkBool(suspended, false)) {
    cfg.setSuspended(true);
  } else {
    cfg.setSuspended(false);
  }

  if (queueEnabled.length()>0) {
    cfg.setQueueEnabled(Val.chkBool(queueEnabled, cfg.getQueueEnabled()) || cfg.getActive());
  }

  if (poolsize.length() > 0) {
    try {
      int num = Integer.parseInt(poolsize);
      if (num <= 0) {
        logger.info("[SYNCHRONIZER] Parameter \"webharvester.poolSize\" less or equal to zero. No harvestig will be performed.");
      }
      cfg.setPoolSize(num);
    } catch (NumberFormatException ex) {
      logger.log(Level.INFO, "[SYNCHRONIZER] Invalid \"webharvester.poolSize\" parameter. Default {0} will be used instead.", HarvesterConfiguration.DEFAULT_POOL_SIZE);
      cfg.setPoolSize(HarvesterConfiguration.DEFAULT_POOL_SIZE);
    }
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.poolSize\" parameter. Default {0} will be used instead.", HarvesterConfiguration.DEFAULT_POOL_SIZE);
    cfg.setPoolSize(HarvesterConfiguration.DEFAULT_POOL_SIZE);
  }

  if (autoselectfrequency.length() > 0) {
    try {
      TimePeriod tp = TimePeriod.parseValue(autoselectfrequency);
      cfg.setAutoSelectFrequency(tp);
    } catch (NumberFormatException ex) {
      logger.log(Level.INFO, "[SYNCHRONIZER] Invalid \"webharvester.autoSelectFrequency\" parameter. Default {0} will be used instead.", HarvesterConfiguration.AUTOSELECT_FREQUENCY);
      cfg.setAutoSelectFrequency(new TimePeriod(HarvesterConfiguration.AUTOSELECT_FREQUENCY));
    }
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.autoSelectFrequency\" parameter. Default {0} will be used instead.", HarvesterConfiguration.AUTOSELECT_FREQUENCY);
    cfg.setAutoSelectFrequency(new TimePeriod(HarvesterConfiguration.AUTOSELECT_FREQUENCY));
  }

  if (watchdogfrequency.length() > 0) {
    try {
      TimePeriod tp = TimePeriod.parseValue(watchdogfrequency);
      cfg.setWatchDogFrequency(tp);
    } catch (NumberFormatException ex) {
      logger.log(Level.INFO, "[SYNCHRONIZER] Invalid \"webharvester.watchDogFrequency\" parameter. Default {0} will be used instead.", HarvesterConfiguration.WATCHDOG_FREQUENCY);
      cfg.setWatchDogFrequency(new TimePeriod(HarvesterConfiguration.WATCHDOG_FREQUENCY));
    }
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.watchDogFrequency\" parameter. Default {0} will be used instead.", HarvesterConfiguration.WATCHDOG_FREQUENCY);
    cfg.setWatchDogFrequency(new TimePeriod(HarvesterConfiguration.WATCHDOG_FREQUENCY));
  }

  if (basecontextpath.length() > 0) {
    cfg.setBaseContextPath(basecontextpath);
  } else {
    String reverseProxyPath = Val.chkStr(parameters.getValue("reverseProxy.baseContextPath"));
    if (reverseProxyPath.length() > 0) {
      logger.info("[SYNCHRONIZER] Missing \"webharvester.baseContextPath\" parameter. Value of \"reverseProxy.baseContextPath\" will be used instead.");
    } else {
      logger.info("[SYNCHRONIZER] Missing \"webharvester.baseContextPath\" parameter. Harvest notification messages will be sent without information about harvest report.");
    }
  }

  if (maxRepRecords.length() > 0) {
    try {
      long num = Long.parseLong(maxRepRecords);
      if (num < 0) {
        logger.info("[SYNCHRONIZER] Parameter \"webharvester.maxRepRecords\" less than zero. No limits will be set.");
      }
      cfg.setMaxRepRecords(num);
    } catch (NumberFormatException ex) {
      logger.log(Level.INFO, "[SYNCHRONIZER] Invalid \"webharvester.maxRepRecords\" parameter. Default {0} will be used instead.", HarvesterConfiguration.MAX_REP_RECORDS);
      cfg.setMaxRepRecords(HarvesterConfiguration.MAX_REP_RECORDS);
    }
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.maxRepRecords\" parameter. Default {0} will be used instead.", HarvesterConfiguration.MAX_REP_RECORDS);
    cfg.setMaxRepRecords(HarvesterConfiguration.MAX_REP_RECORDS);
  }


  if (maxRepErrors.length() > 0) {
    try {
      long num = Long.parseLong(maxRepErrors);
      if (num < 0) {
        logger.info("[SYNCHRONIZER] Parameter \"webharvester.maxRepErrors\" less than zero. No limits will be set.");
      }
      cfg.setMaxRepErrors(num);
    } catch (NumberFormatException ex) {
      logger.log(Level.INFO, "[SYNCHRONIZER] Invalid \"webharvester.maxRepErrors\" parameter. Default {0} will be used instead.", HarvesterConfiguration.MAX_REP_ERRORS);
      cfg.setMaxRepErrors(HarvesterConfiguration.MAX_REP_ERRORS);
    }
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.maxRepErrors\" parameter. Default {0} will be used instead.", HarvesterConfiguration.MAX_REP_ERRORS);
    cfg.setMaxRepErrors(HarvesterConfiguration.MAX_REP_ERRORS);
  }

  if (resourceAutoApprove.length() > 0) {
    boolean bool = Val.chkBool(resourceAutoApprove,HarvesterConfiguration.RESOURCE_AUTOAPPROVE);
    cfg.setResourceAutoApprove(bool);
  } else {
    logger.log(Level.INFO, "[SYNCHRONIZER] Missing \"webharvester.resource.autoApprove\" parameter. Default {0} will be used instead.", HarvesterConfiguration.RESOURCE_AUTOAPPROVE);
    cfg.setResourceAutoApprove(HarvesterConfiguration.RESOURCE_AUTOAPPROVE);
  }
 
  // load data processor factories
  XPath xpath = XPathFactory.newInstance().newXPath();
 
  // add local data processor factory by default
  cfg.getDataProcessorFactories().add(new LocalDataProcessorFactory());

  // get root of webharvester configuration
  Node ndWebHarvester = (Node) xpath.evaluate("webharvester", root, XPathConstants.NODE);
  if (ndWebHarvester!=null) {
    // create and initialize data processor for each netry in configuration
    NodeList ndDataProcessorFactories = (NodeList) xpath.evaluate("dataProcessorFactory", ndWebHarvester, XPathConstants.NODESET);
    for (Node ndDataProcessorFactory : new NodeListAdapter(ndDataProcessorFactories)) {
      String className = Val.chkStr((String) xpath.evaluate("@className", ndDataProcessorFactory, XPathConstants.STRING));
      String name = Val.chkStr((String) xpath.evaluate("@name", ndDataProcessorFactory, XPathConstants.STRING));
      boolean enabled = Val.chkBool(Val.chkStr((String) xpath.evaluate("@enabled", ndDataProcessorFactory, XPathConstants.STRING)), true);
      if (enabled) {
        try {
          Class factoryClass = Class.forName(className);
          DataProcessorFactory processorFactory = (DataProcessorFactory) factoryClass.newInstance();
          processorFactory.setName(name);
          processorFactory.init(ndDataProcessorFactory);
          cfg.getDataProcessorFactories().add(processorFactory);
        } catch (Exception ex) {
          getLogger().log(Level.SEVERE, "Error creating processor factory: "+className, ex);
        }
      } else {
        if (LocalDataProcessorFactory.class.getCanonicalName().equals(className)) {
          removeDataProcessorFactory(cfg.getDataProcessorFactories(), className);
        }
      }
    }
  }
}
View Full Code Here

Examples of com.esri.gpt.control.webharvest.engine.HarvesterConfiguration

/**
* Sets harvester configuration.
* @param harvesterConfiguration harvester configuration
*/
public void setHarvesterConfiguration(HarvesterConfiguration harvesterConfiguration) {
  this._harvesterConfiguration = harvesterConfiguration != null ? harvesterConfiguration : new HarvesterConfiguration();
}
View Full Code Here

Examples of com.esri.gpt.control.webharvest.engine.HarvesterConfiguration

   *
   * @throws Exception
   *             if exception occurs.
   */
  private void collectEnvironmentInfo() throws Exception {
    HarvesterConfiguration cfg = getRequestContext()
        .getApplicationConfiguration().getHarvesterConfiguration();
    sb.append("\"configuration\":{");
    addSpaces(3);
    makeElement("active", String.valueOf(cfg.getActive()), true, false);
    addSpaces(3);
    makeElement("queueEnabled", String.valueOf(cfg.getQueueEnabled()),
        true, false);
    addSpaces(3);
    makeElement("poolSize", String.valueOf(cfg.getPoolSize()), true, true);
    addSpaces(3);
    makeElement("autoSelectFrequency",
        String.valueOf(cfg.getAutoSelectFrequency()), true, true);
    addSpaces(3);
    makeElement("watchDogFrequency",
        String.valueOf(cfg.getWatchDogFrequency()), true, true);
    addSpaces(3);
    makeElement("baseContextPath",
        String.valueOf(cfg.getBaseContextPath()), true, false);
    addSpaces(3);
    makeElement("maxRepRecords", String.valueOf(cfg.getMaxRepRecords()),
        true, true);
    addSpaces(3);
    makeElement("maxRepErrors", String.valueOf(cfg.getMaxRepErrors()),
        true, true);
    addSpaces(3);
    makeElement("resourceAutoApprove",
        String.valueOf(cfg.getResourceAutoApprove()), false, false);
    addSpaces(2);
    sb.append("}");
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.