XmlRequest t = req.getTransport();
try {
t.setUrl(new URL(params.url));
} catch (MalformedURLException e1) {
HarvestError harvestError = new HarvestError(e1, log);
harvestError.setDescription(harvestError.getDescription() + " " + params.url);
errors.add(harvestError);
throw new AbortExecutionException(e1);
}
if (params.useAccount) {
t.setCredentials(params.username, params.password);
}
//--- set the proxy info if necessary
Lib.net.setupProxy(context, t);
//--- perform all searches
Set<RecordInfo> records = new HashSet<RecordInfo>();
for (Search s : params.getSearches()) {
try {
records.addAll(search(req, s));
} catch (Exception e) {
log.error("Unknown error trying to harvest");
log.error(e.getMessage());
e.printStackTrace();
errors.add(new HarvestError(e, log));
} catch (Throwable e) {
log.fatal("Something unknown and terrible happened while harvesting");
log.fatal(e.getMessage());
e.printStackTrace();
errors.add(new HarvestError(e, log));
}
}
if (params.isSearchEmpty()) {
try {
log.debug("Doing an empty search");
records.addAll(search(req, Search.createEmptySearch()));
} catch(Exception e) {
log.error("Unknown error trying to harvest");
log.error(e.getMessage());
e.printStackTrace();
errors.add(new HarvestError(e, log));
} catch(Throwable e) {
log.fatal("Something unknown and terrible happened while harvesting");
log.fatal(e.getMessage());
e.printStackTrace();
errors.add(new HarvestError(e, log));
}
}
log.info("Total records processed in all searches :"+ records.size());