/**
* 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.");
}