Search in sources :

Example 86 with FessConfig

use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.

the class UserInfoHelper method createUserCodeFromUserId.

protected String createUserCodeFromUserId(String userCode) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final PrimaryCipher cipher = ComponentUtil.getPrimaryCipher();
    userCode = cipher.encrypt(userCode);
    if (fessConfig.isValidUserCode(userCode)) {
        return userCode;
    }
    return null;
}
Also used : PrimaryCipher(org.lastaflute.core.security.PrimaryCipher) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 87 with FessConfig

use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.

the class UserInfoHelper method getUserCodeFromRequest.

protected String getUserCodeFromRequest(final HttpServletRequest request) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final String userCode = request.getParameter(fessConfig.getUserCodeRequestParameter());
    if (StringUtil.isBlank(userCode)) {
        return null;
    }
    if (fessConfig.isValidUserCode(userCode)) {
        request.setAttribute(Constants.USER_CODE, userCode);
        return userCode;
    }
    return null;
}
Also used : FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 88 with FessConfig

use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.

the class UserInfoHelper method getUserCodeFromCookie.

protected String getUserCodeFromCookie(final HttpServletRequest request) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (final Cookie cookie : cookies) {
            if (cookieName.equals(cookie.getName()) && fessConfig.isValidUserCode(cookie.getValue())) {
                return cookie.getValue();
            }
        }
    }
    return null;
}
Also used : Cookie(javax.servlet.http.Cookie) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 89 with FessConfig

use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.

the class IndexUpdater method getAccessResultList.

private List<EsAccessResult> getAccessResultList(final Consumer<SearchRequestBuilder> cb, final long cleanupTime) {
    if (logger.isDebugEnabled()) {
        logger.debug("Getting documents in IndexUpdater queue.");
    }
    final long execTime = System.currentTimeMillis();
    final List<EsAccessResult> arList = ((EsDataService) dataService).getAccessResultList(cb);
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    if (!arList.isEmpty()) {
        final long commitMarginTime = fessConfig.getIndexerWebfsCommitMarginTimeAsInteger().longValue();
        for (final AccessResult<?> ar : arList.toArray(new AccessResult[arList.size()])) {
            if (ar.getCreateTime().longValue() > execTime - commitMarginTime) {
                arList.remove(ar);
            }
        }
    }
    final long totalHits = ((EsResultList<EsAccessResult>) arList).getTotalHits();
    if (logger.isInfoEnabled()) {
        final StringBuilder buf = new StringBuilder(100);
        buf.append("Processing ");
        if (totalHits > 0) {
            buf.append(arList.size()).append('/').append(totalHits).append(" docs (Doc:{access ");
        } else {
            buf.append("no docs in indexing queue (Doc:{access ");
        }
        buf.append(System.currentTimeMillis() - execTime).append("ms");
        if (cleanupTime >= 0) {
            buf.append(", cleanup ").append(cleanupTime).append("ms");
        }
        buf.append("}, ");
        buf.append(MemoryUtil.getMemoryUsageLog());
        buf.append(')');
        logger.info(buf.toString());
    }
    final long unprocessedDocumentSize = fessConfig.getIndexerUnprocessedDocumentSizeAsInteger().longValue();
    final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper();
    if (totalHits > unprocessedDocumentSize && intervalControlHelper.isCrawlerRunning()) {
        if (logger.isInfoEnabled()) {
            logger.info("Stopped all crawler threads. You have {} (>{}) unprocessed docs.", totalHits, unprocessedDocumentSize);
        }
        intervalControlHelper.setCrawlerRunning(false);
    }
    return arList;
}
Also used : EsAccessResult(org.codelibs.fess.crawler.entity.EsAccessResult) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) EsDataService(org.codelibs.fess.crawler.service.impl.EsDataService) EsResultList(org.codelibs.fess.crawler.util.EsResultList) IntervalControlHelper(org.codelibs.fess.helper.IntervalControlHelper)

Example 90 with FessConfig

use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.

the class IndexUpdater method updateDocument.

protected void updateDocument(final Map<String, Object> map) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    if (fessConfig.getIndexerClickCountEnabledAsBoolean()) {
        addClickCountField(map);
    }
    if (fessConfig.getIndexerFavoriteCountEnabledAsBoolean()) {
        addFavoriteCountField(map);
    }
    float documentBoost = 0.0f;
    for (final DocBoostMatcher docBoostMatcher : docBoostMatcherList) {
        if (docBoostMatcher.match(map)) {
            documentBoost = docBoostMatcher.getValue(map);
            break;
        }
    }
    if (documentBoost > 0) {
        addBoostValue(map, documentBoost);
    }
    if (!map.containsKey(fessConfig.getIndexFieldDocId())) {
        map.put(fessConfig.getIndexFieldDocId(), systemHelper.generateDocId(map));
    }
    ComponentUtil.getLanguageHelper().updateDocument(map);
}
Also used : FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Aggregations

FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)176 ArrayList (java.util.ArrayList)60 Map (java.util.Map)54 HashMap (java.util.HashMap)48 StringUtil (org.codelibs.core.lang.StringUtil)42 ComponentUtil (org.codelibs.fess.util.ComponentUtil)42 List (java.util.List)37 Constants (org.codelibs.fess.Constants)36 LogManager (org.apache.logging.log4j.LogManager)30 Logger (org.apache.logging.log4j.Logger)30 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)28 PostConstruct (javax.annotation.PostConstruct)27 IOException (java.io.IOException)24 SystemHelper (org.codelibs.fess.helper.SystemHelper)19 File (java.io.File)18 Collectors (java.util.stream.Collectors)18 SearchEngineClient (org.codelibs.fess.es.client.SearchEngineClient)18 FessSystemException (org.codelibs.fess.exception.FessSystemException)17 Collections (java.util.Collections)15 DocumentUtil (org.codelibs.fess.util.DocumentUtil)15