private void harvest(String url, Option<Date> from, RecordHandler handler)
throws Exception {
logger.info("Harvesting " + url + " from " + from + " on thread " + Thread.currentThread());
OaiPmhRepositoryClient repositoryClient = OaiPmhRepositoryClient.newHarvester(url);
ListRecordsResponse response = repositoryClient.listRecords(handler.getMetadataPrefix(), from, Option.<Date> none(), Option.<String> none());
if (!response.isError()) {
for (Node recordNode : ListRecordsResponse.getAllRecords(response, repositoryClient)) {
handler.handle(recordNode);
}
} else if (response.isErrorNoRecordsMatch()) {
logger.info("Repository returned no records.");
} else {
logger.error("Repository returned error code: " + response.getErrorCode().getOrElse("?"));
}
}