use of org.codelibs.fess.es.config.exbhv.FailureUrlBhv in project fess by codelibs.
the class FailureUrlService method store.
public void store(final CrawlingConfig crawlingConfig, final String errorName, final String url, final Throwable e) {
if (e instanceof ContainerNotAvailableException) {
return;
}
final FailureUrlBhv bhv = ComponentUtil.getComponent(FailureUrlBhv.class);
final FailureUrl failureUrl = bhv.selectEntity(cb -> {
cb.query().setUrl_Equal(url);
if (crawlingConfig != null) {
cb.query().setConfigId_Equal(crawlingConfig.getConfigId());
}
}).map(entity -> {
entity.setErrorCount(entity.getErrorCount() + 1);
return entity;
}).orElseGet(() -> {
final FailureUrl entity = new FailureUrl();
entity.setErrorCount(1);
entity.setUrl(url);
if (crawlingConfig != null) {
entity.setConfigId(crawlingConfig.getConfigId());
}
return entity;
});
failureUrl.setErrorName(errorName);
failureUrl.setErrorLog(StringUtils.abbreviate(getStackTrace(e), 4000));
failureUrl.setLastAccessTime(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
failureUrl.setThreadName(Thread.currentThread().getName());
bhv.insertOrUpdate(failureUrl, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
}
Aggregations