Search in sources :

Example 81 with FessConfig

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

the class AdminBackupAction method getBackupItems.

public static List<Map<String, String>> getBackupItems() {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    return stream(fessConfig.getIndexBackupAllTargets()).get(stream -> stream.map(name -> {
        final Map<String, String> map = new HashMap<>();
        map.put("id", name);
        map.put("name", name);
        return map;
    }).collect(Collectors.toList()));
}
Also used : HashMap(java.util.HashMap) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 82 with FessConfig

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

the class CrawlingInfoService method getLastCrawlingInfoParamList.

public List<CrawlingInfoParam> getLastCrawlingInfoParamList(final String sessionId) {
    final CrawlingInfo crawlingInfo = getLast(sessionId);
    if (crawlingInfo == null) {
        return Collections.emptyList();
    }
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    return crawlingInfoParamBhv.selectList(cb -> {
        cb.query().setCrawlingInfoId_Equal(crawlingInfo.getId());
        cb.query().addOrderBy_CreatedTime_Asc();
        cb.paging(fessConfig.getPageCrawlingInfoParamMaxFetchSizeAsInteger(), 1);
    });
}
Also used : CrawlingInfo(org.codelibs.fess.es.config.exentity.CrawlingInfo) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 83 with FessConfig

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

the class ViewHelper method getSitePath.

public Object getSitePath(final Map<String, Object> docMap) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final Object siteValue = docMap.get(fessConfig.getIndexFieldSite());
    if (siteValue != null) {
        final String site = siteValue.toString();
        final int size = fessConfig.getResponseMaxSitePathLengthAsInteger();
        if (size > -1) {
            return StringUtils.abbreviate(site, size);
        }
        return site;
    }
    final Object urlLink = docMap.get(fessConfig.getResponseFieldUrlLink());
    if (urlLink != null) {
        final String returnUrl;
        final String url = urlLink.toString();
        if (LOCAL_PATH_PATTERN.matcher(url).find() || SHARED_FOLDER_PATTERN.matcher(url).find()) {
            returnUrl = url.replaceFirst("^file:/+", "");
        } else if (url.startsWith("file:")) {
            returnUrl = url.replaceFirst("^file:/+", "/");
        } else {
            returnUrl = url.replaceFirst("^[a-zA-Z0-9]*:/+", "");
        }
        final int size = fessConfig.getResponseMaxSitePathLengthAsInteger();
        if (size > -1) {
            return StringUtils.abbreviate(returnUrl, size);
        }
        return returnUrl;
    }
    return null;
}
Also used : FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 84 with FessConfig

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

the class ViewHelper method getUrlLink.

public String getUrlLink(final Map<String, Object> document) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    String url = DocumentUtil.getValue(document, fessConfig.getIndexFieldUrl(), String.class);
    if (StringUtil.isBlank(url)) {
        return "#not-found-" + DocumentUtil.getValue(document, fessConfig.getIndexFieldDocId(), String.class);
    }
    final boolean isSmbUrl = url.startsWith("smb:") || url.startsWith("smb1:");
    final boolean isFtpUrl = url.startsWith("ftp:");
    final boolean isSmbOrFtpUrl = isSmbUrl || isFtpUrl;
    // replacing url with mapping data
    url = ComponentUtil.getPathMappingHelper().replaceUrl(url);
    final boolean isHttpUrl = url.startsWith("http:") || url.startsWith("https:");
    if (isSmbUrl) {
        url = url.replace("smb:", "file:");
        url = url.replace("smb1:", "file:");
    }
    if (isHttpUrl && isSmbOrFtpUrl) {
        // smb/ftp->http
        // encode
        final StringBuilder buf = new StringBuilder(url.length() + 100);
        for (final char c : url.toCharArray()) {
            if (CharUtil.isUrlChar(c)) {
                buf.append(c);
            } else {
                try {
                    buf.append(URLEncoder.encode(String.valueOf(c), urlLinkEncoding));
                } catch (final UnsupportedEncodingException e) {
                    buf.append(c);
                }
            }
        }
        url = buf.toString();
    } else if (url.startsWith("file:")) {
        // file, smb/ftp->http
        url = updateFileProtocol(url);
        if (encodeUrlLink) {
            return appendQueryParameter(document, url);
        }
        // decode
        if (!isSmbOrFtpUrl) {
            // file
            try {
                url = URLDecoder.decode(url.replace("+", "%2B"), urlLinkEncoding);
            } catch (final Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.warn("Failed to decode {}", url, e);
                }
            }
        }
    }
    return appendQueryParameter(document, url);
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FessSystemException(org.codelibs.fess.exception.FessSystemException) ClientAbortException(org.apache.catalina.connector.ClientAbortException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 85 with FessConfig

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

the class UserInfoHelper method storeQueryId.

public void storeQueryId(final String queryId, final List<Map<String, Object>> documentItems) {
    final HttpSession session = LaRequestUtil.getRequest().getSession(false);
    if (session != null) {
        final FessConfig fessConfig = ComponentUtil.getFessConfig();
        final List<String> docIdList = new ArrayList<>();
        for (final Map<String, Object> map : documentItems) {
            final Object docId = map.get(fessConfig.getIndexFieldDocId());
            if (docId != null && docId.toString().length() > 0) {
                docIdList.add(docId.toString());
            }
        }
        if (!docIdList.isEmpty()) {
            final Map<String, String[]> resultDocIdsCache = getResultDocIdsCache(session);
            resultDocIdsCache.put(queryId, docIdList.toArray(new String[docIdList.size()]));
        }
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) 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