Search in sources :

Example 1 with FailureUrlBhv

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);
    });
}
Also used : ContainerNotAvailableException(org.codelibs.fess.exception.ContainerNotAvailableException) PrintWriter(java.io.PrintWriter) BeanUtil(org.codelibs.core.beans.util.BeanUtil) Constants(org.codelibs.fess.Constants) FailureUrlBhv(org.codelibs.fess.es.config.exbhv.FailureUrlBhv) ListResultBean(org.dbflute.cbean.result.ListResultBean) OptionalEntity(org.dbflute.optional.OptionalEntity) ContainerNotAvailableException(org.codelibs.fess.exception.ContainerNotAvailableException) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) StringUtils(org.apache.commons.lang3.StringUtils) CrawlingConfig(org.codelibs.fess.es.config.exentity.CrawlingConfig) ArrayList(java.util.ArrayList) List(java.util.List) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) FailureUrlCB(org.codelibs.fess.es.config.cbean.FailureUrlCB) PagingResultBean(org.dbflute.cbean.result.PagingResultBean) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SystemHelper(org.codelibs.fess.helper.SystemHelper) StringBuilderWriter(org.apache.commons.io.output.StringBuilderWriter) FailureUrlPager(org.codelibs.fess.app.pager.FailureUrlPager) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) FailureUrl(org.codelibs.fess.es.config.exentity.FailureUrl) FailureUrlBhv(org.codelibs.fess.es.config.exbhv.FailureUrlBhv) FailureUrl(org.codelibs.fess.es.config.exentity.FailureUrl)

Aggregations

PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 Resource (javax.annotation.Resource)1 StringBuilderWriter (org.apache.commons.io.output.StringBuilderWriter)1 StringUtils (org.apache.commons.lang3.StringUtils)1 BeanUtil (org.codelibs.core.beans.util.BeanUtil)1 StringUtil (org.codelibs.core.lang.StringUtil)1 Constants (org.codelibs.fess.Constants)1 FailureUrlPager (org.codelibs.fess.app.pager.FailureUrlPager)1 FailureUrlCB (org.codelibs.fess.es.config.cbean.FailureUrlCB)1 FailureUrlBhv (org.codelibs.fess.es.config.exbhv.FailureUrlBhv)1 CrawlingConfig (org.codelibs.fess.es.config.exentity.CrawlingConfig)1 FailureUrl (org.codelibs.fess.es.config.exentity.FailureUrl)1 ContainerNotAvailableException (org.codelibs.fess.exception.ContainerNotAvailableException)1 SystemHelper (org.codelibs.fess.helper.SystemHelper)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 ComponentUtil (org.codelibs.fess.util.ComponentUtil)1