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()));
}
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);
});
}
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;
}
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);
}
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()]));
}
}
}
Aggregations