use of org.codelibs.fess.es.config.exentity.FailureUrl 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);
});
}
use of org.codelibs.fess.es.config.exentity.FailureUrl in project fess by codelibs.
the class ApiAdminFailureurlAction method logs.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/failureurl/logs
// POST /api/admin/failureurl/logs
@Execute
public JsonResponse<ApiResult> logs(final SearchBody body) {
validateApi(body, messages -> {
});
final FailureUrlPager pager = copyBeanToNewBean(body, FailureUrlPager.class);
final List<FailureUrl> list = failureUrlService.getFailureUrlList(pager);
return asJson(new ApiResult.ApiLogsResponse<EditBody>().logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.FailureUrl in project fess by codelibs.
the class ApiAdminFailureurlAction method delete$all.
// DELETE /api/admin/failureurl/all
@Execute
public JsonResponse<ApiResult> delete$all() {
try {
failureUrlService.deleteAll(failureUrlPager);
failureUrlPager.clear();
saveInfo(messages -> messages.addSuccessFailureUrlDeleteAll(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResponse().status(Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.FailureUrl in project fess by codelibs.
the class FailureUrlService method getExcludedUrlList.
public List<String> getExcludedUrlList(final String configId) {
final int failureCount = fessConfig.getFailureCountThreshold();
final String ignoreFailureType = fessConfig.getIgnoreFailureType();
if (failureCount < 0) {
return Collections.emptyList();
}
final int count = failureCount;
final ListResultBean<FailureUrl> list = failureUrlBhv.selectList(cb -> {
cb.query().setConfigId_Equal(configId);
cb.query().setErrorCount_GreaterEqual(count);
cb.fetchFirst(fessConfig.getPageFailureUrlMaxFetchSizeAsInteger());
});
if (list.isEmpty()) {
return Collections.emptyList();
}
Pattern pattern = null;
if (StringUtil.isNotBlank(ignoreFailureType)) {
pattern = Pattern.compile(ignoreFailureType);
}
final List<String> urlList = new ArrayList<>();
for (final FailureUrl failureUrl : list) {
if (pattern != null) {
if (!pattern.matcher(failureUrl.getErrorName()).matches()) {
urlList.add(failureUrl.getUrl());
}
} else {
urlList.add(failureUrl.getUrl());
}
}
return urlList;
}
Aggregations