fix #1658 remove @Resource properties
This commit is contained in:
parent
8ab5b2def5
commit
54af75e45e
50 changed files with 481 additions and 385 deletions
|
@ -172,7 +172,7 @@ public abstract class BaseJsonApiManager extends BaseApiManager {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
public void setMimeType(final String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,12 +82,4 @@ public class BoostDocumentRuleService {
|
|||
|
||||
}
|
||||
|
||||
public List<BoostDocumentRule> getAvailableBoostDocumentRuleList() {
|
||||
return boostDocumentRuleBhv.selectList(cb -> {
|
||||
cb.query().matchAll();
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.fetchFirst(fessConfig.getPageDocboostMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -74,33 +74,6 @@ public class DataConfigService {
|
|||
|
||||
}
|
||||
|
||||
public List<DataConfig> getAllDataConfigList() {
|
||||
return getAllDataConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<DataConfig> getDataConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllDataConfigList();
|
||||
} else {
|
||||
return getAllDataConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DataConfig> getAllDataConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return dataConfigBhv.selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(fessConfig.getPageDataConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public OptionalEntity<DataConfig> getDataConfig(final String id) {
|
||||
return dataConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
package org.codelibs.fess.app.service;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -37,7 +34,6 @@ import org.codelibs.fess.exception.ContainerNotAvailableException;
|
|||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.cbean.result.ListResultBean;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
|
@ -122,41 +118,6 @@ public class FailureUrlService {
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void deleteByConfigId(final String configId) {
|
||||
failureUrlBhv.queryDelete(cb -> {
|
||||
cb.query().setConfigId_Equal(configId);
|
||||
|
|
|
@ -80,33 +80,6 @@ public class FileConfigService {
|
|||
});
|
||||
}
|
||||
|
||||
public List<FileConfig> getAllFileConfigList() {
|
||||
return getAllFileConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<FileConfig> getFileConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllFileConfigList();
|
||||
} else {
|
||||
return getAllFileConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<FileConfig> getAllFileConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return fileConfigBhv.selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(fessConfig.getPageFileConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public OptionalEntity<FileConfig> getFileConfig(final String id) {
|
||||
return fileConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
|
|
|
@ -88,33 +88,6 @@ public class WebConfigService {
|
|||
});
|
||||
}
|
||||
|
||||
public List<WebConfig> getAllWebConfigList() {
|
||||
return getAllWebConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<WebConfig> getWebConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllWebConfigList();
|
||||
} else {
|
||||
return getAllWebConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<WebConfig> getAllWebConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return webConfigBhv.selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(fessConfig.getPageWebConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public OptionalEntity<WebConfig> getWebConfig(final String id) {
|
||||
return webConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
logger.warn("Failed to process system.properties file: " + form.bulkFile.getFileName(), e);
|
||||
}
|
||||
} else if (fileName.startsWith("gsa") && fileName.endsWith(".xml")) {
|
||||
GsaConfigParser configParser = ComponentUtil.getComponent(GsaConfigParser.class);
|
||||
final GsaConfigParser configParser = ComponentUtil.getComponent(GsaConfigParser.class);
|
||||
try (final InputStream in = form.bulkFile.getInputStream()) {
|
||||
configParser.parse(new InputSource(in));
|
||||
} catch (final IOException e) {
|
||||
|
|
|
@ -106,7 +106,7 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
RenderDataUtil.register(data, "fileAuthenticationItems",
|
||||
fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !fileConfigService.getAllFileConfigList(false, false, false, null).isEmpty());
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper.getAllFileConfigList(false, false, false, null).isEmpty());
|
||||
// restore from pager
|
||||
copyBeanToBean(fileAuthenticationPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
|
||||
protected void registerFileConfigItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<>();
|
||||
final List<FileConfig> fileConfigList = fileConfigService.getAllFileConfigList(false, false, false, null);
|
||||
final List<FileConfig> fileConfigList = crawlingConfigHelper.getAllFileConfigList(false, false, false, null);
|
||||
for (final FileConfig fileConfig : fileConfigList) {
|
||||
itemList.add(createItem(fileConfig.getName(), fileConfig.getId().toString()));
|
||||
}
|
||||
|
@ -317,8 +317,8 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
data -> {
|
||||
RenderDataUtil.register(data, "fileAuthenticationItems",
|
||||
fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !fileConfigService.getAllFileConfigList(false, false, false, null)
|
||||
.isEmpty());
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper
|
||||
.getAllFileConfigList(false, false, false, null).isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(fileAuthenticationPager, form, op -> op.include("id"));
|
||||
|
|
|
@ -104,7 +104,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
RenderDataUtil.register(data, "requestHeaderItems", requestHeaderService.getRequestHeaderList(reqHeaderPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(reqHeaderPager, form, op -> op.include("id"));
|
||||
|
@ -273,7 +273,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
|
||||
protected void registerWebConfigItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<>();
|
||||
final List<WebConfig> webConfigList = webConfigService.getAllWebConfigList(false, false, false, null);
|
||||
final List<WebConfig> webConfigList = crawlingConfigHelper.getAllWebConfigList(false, false, false, null);
|
||||
for (final WebConfig webConfig : webConfigList) {
|
||||
itemList.add(createItem(webConfig.getName(), webConfig.getId().toString()));
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderJsp).renderWith(data -> {
|
||||
RenderDataUtil.register(data, "requestHeaderItems", requestHeaderService.getRequestHeaderList(reqHeaderPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null)
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper.getAllWebConfigList(false, false, false, null)
|
||||
.isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
|
|
|
@ -123,7 +123,7 @@ public class AdminSysteminfoAction extends FessAdminAction {
|
|||
itemList.add(createItem(k, value));
|
||||
});
|
||||
if (fessConfig instanceof ObjectiveConfig) {
|
||||
ObjectiveConfig config = (ObjectiveConfig) fessConfig;
|
||||
final ObjectiveConfig config = (ObjectiveConfig) fessConfig;
|
||||
config.keySet().stream().forEach(k -> {
|
||||
final String value;
|
||||
if (isMaskedValue(k)) {
|
||||
|
|
|
@ -104,7 +104,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
RenderDataUtil.register(data, "webAuthenticationItems", webAuthenticationService.getWebAuthenticationList(webAuthPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
// restore from pager
|
||||
copyBeanToBean(webAuthPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
|
||||
protected void registerWebConfigItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<>();
|
||||
final List<WebConfig> webConfigList = webConfigService.getAllWebConfigList(false, false, false, null);
|
||||
final List<WebConfig> webConfigList = crawlingConfigHelper.getAllWebConfigList(false, false, false, null);
|
||||
for (final WebConfig webConfig : webConfigList) {
|
||||
itemList.add(createItem(webConfig.getName(), webConfig.getId().toString()));
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminWebauth_AdminWebauthJsp).renderWith(data -> {
|
||||
RenderDataUtil.register(data, "webAuthenticationItems", webAuthenticationService.getWebAuthenticationList(webAuthPager)); // page navi
|
||||
RenderDataUtil.register(data, "displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null)
|
||||
RenderDataUtil.register(data, "displayCreateLink", !crawlingConfigHelper.getAllWebConfigList(false, false, false, null)
|
||||
.isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
*/
|
||||
package org.codelibs.fess.app.web.base;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.codelibs.fess.exception.UserRoleLoginException;
|
||||
import org.codelibs.fess.helper.CrawlingConfigHelper;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.di.util.LdiFileUtil;
|
||||
import org.lastaflute.web.login.LoginManager;
|
||||
|
@ -31,6 +33,12 @@ import org.lastaflute.web.util.LaServletContextUtil;
|
|||
*/
|
||||
public abstract class FessAdminAction extends FessBaseAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
protected CrawlingConfigHelper crawlingConfigHelper;
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
|
|
|
@ -199,7 +199,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
|
|||
|
||||
protected void processMetaRobots(final ResponseData responseData, final ResultData resultData, final Document document) {
|
||||
final Map<String, String> configMap = getConfigPrameterMap(responseData, ConfigName.CONFIG);
|
||||
String ignore = configMap.get(IGNORE_ROBOTS_TAGS);
|
||||
final String ignore = configMap.get(IGNORE_ROBOTS_TAGS);
|
||||
if (ignore == null) {
|
||||
if (fessConfig.isCrawlerIgnoreRobotsTags()) {
|
||||
return;
|
||||
|
|
|
@ -155,7 +155,7 @@ public class JsonDataStoreImpl extends AbstractDataStoreImpl {
|
|||
}
|
||||
}
|
||||
|
||||
public void setFileSuffixes(String[] fileSuffixes) {
|
||||
public void setFileSuffixes(final String[] fileSuffixes) {
|
||||
this.fileSuffixes = fileSuffixes;
|
||||
}
|
||||
}
|
|
@ -169,7 +169,7 @@ public class QueryContext {
|
|||
return defaultField;
|
||||
}
|
||||
|
||||
public void setDefaultField(String defaultField) {
|
||||
public void setDefaultField(final String defaultField) {
|
||||
this.defaultField = defaultField;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public interface SearchRequestParams {
|
|||
|| !isEmptyArray(conditions.get(AS_FILETYPE));
|
||||
}
|
||||
|
||||
public default boolean isEmptyArray(String[] values) {
|
||||
public default boolean isEmptyArray(final String[] values) {
|
||||
if (values == null || values.length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -612,7 +612,7 @@ public class FessEsClient implements Client {
|
|||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ public class FessEsClient implements Client {
|
|||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -1475,11 +1475,11 @@ public class FessEsClient implements Client {
|
|||
this.scrollForSearch = scrollForSearch;
|
||||
}
|
||||
|
||||
public void setMaxConfigSyncStatusRetry(int maxConfigSyncStatusRetry) {
|
||||
public void setMaxConfigSyncStatusRetry(final int maxConfigSyncStatusRetry) {
|
||||
this.maxConfigSyncStatusRetry = maxConfigSyncStatusRetry;
|
||||
}
|
||||
|
||||
public void setMaxEsStatusRetry(int maxEsStatusRetry) {
|
||||
public void setMaxEsStatusRetry(final int maxEsStatusRetry) {
|
||||
this.maxEsStatusRetry = maxEsStatusRetry;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class PathMapping extends BsPathMapping {
|
|||
}
|
||||
try {
|
||||
return pathMapper.apply(input, matcher);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to apply " + pathMapper, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ public class GsaConfigException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public GsaConfigException(String message, Throwable cause) {
|
||||
public GsaConfigException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public GsaConfigException(String message) {
|
||||
public GsaConfigException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
*/
|
||||
public class ActivityHelper {
|
||||
private Logger logger = null;
|
||||
protected Logger logger = null;
|
||||
|
||||
protected String loggerName = "fess.log.audit";
|
||||
|
||||
|
|
|
@ -15,19 +15,35 @@
|
|||
*/
|
||||
package org.codelibs.fess.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.service.DataConfigService;
|
||||
import org.codelibs.fess.app.service.FileConfigService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
import org.codelibs.fess.es.config.exbhv.DataConfigBhv;
|
||||
import org.codelibs.fess.es.config.exbhv.FailureUrlBhv;
|
||||
import org.codelibs.fess.es.config.exbhv.FileConfigBhv;
|
||||
import org.codelibs.fess.es.config.exbhv.WebConfigBhv;
|
||||
import org.codelibs.fess.es.config.exentity.CrawlingConfig;
|
||||
import org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType;
|
||||
import org.codelibs.fess.es.config.exentity.DataConfig;
|
||||
import org.codelibs.fess.es.config.exentity.FailureUrl;
|
||||
import org.codelibs.fess.es.config.exentity.FileConfig;
|
||||
import org.codelibs.fess.es.config.exentity.WebConfig;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.cbean.result.ListResultBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -121,4 +137,120 @@ public class CrawlingConfigHelper {
|
|||
return crawlingConfigMap.get(sessionId);
|
||||
}
|
||||
|
||||
public List<WebConfig> getAllWebConfigList() {
|
||||
return getAllWebConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<WebConfig> getWebConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllWebConfigList();
|
||||
} else {
|
||||
return getAllWebConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<WebConfig> getAllWebConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return ComponentUtil.getComponent(WebConfigBhv.class).selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageWebConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public List<FileConfig> getAllFileConfigList() {
|
||||
return getAllFileConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<FileConfig> getFileConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllFileConfigList();
|
||||
} else {
|
||||
return getAllFileConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<FileConfig> getAllFileConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return ComponentUtil.getComponent(FileConfigBhv.class).selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageFileConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public List<DataConfig> getAllDataConfigList() {
|
||||
return getAllDataConfigList(true, true, true, null);
|
||||
}
|
||||
|
||||
public List<DataConfig> getDataConfigListByIds(final List<String> idList) {
|
||||
if (idList == null) {
|
||||
return getAllDataConfigList();
|
||||
} else {
|
||||
return getAllDataConfigList(true, true, false, idList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DataConfig> getAllDataConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available,
|
||||
final List<String> idList) {
|
||||
return ComponentUtil.getComponent(DataConfigBhv.class).selectList(cb -> {
|
||||
if (available) {
|
||||
cb.query().setAvailable_Equal(Constants.T);
|
||||
}
|
||||
if (idList != null) {
|
||||
cb.query().setId_InScope(idList);
|
||||
}
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().addOrderBy_Name_Asc();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageDataConfigMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
public List<String> getExcludedUrlList(final String configId) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final int failureCount = fessConfig.getFailureCountThreshold();
|
||||
final String ignoreFailureType = fessConfig.getIgnoreFailureType();
|
||||
|
||||
if (failureCount < 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final int count = failureCount;
|
||||
final ListResultBean<FailureUrl> list = ComponentUtil.getComponent(FailureUrlBhv.class).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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.service.DataConfigService;
|
||||
import org.codelibs.fess.app.service.FailureUrlService;
|
||||
import org.codelibs.fess.ds.DataStore;
|
||||
import org.codelibs.fess.ds.DataStoreFactory;
|
||||
|
@ -45,20 +42,14 @@ public class DataIndexHelper {
|
|||
|
||||
private static final String DELETE_OLD_DOCS = "delete_old_docs";
|
||||
|
||||
@Resource
|
||||
public DataConfigService dataConfigService;
|
||||
protected long crawlingExecutionInterval = Constants.DEFAULT_CRAWLING_EXECUTION_INTERVAL;
|
||||
|
||||
@Resource
|
||||
protected CrawlingConfigHelper crawlingConfigHelper;
|
||||
protected int crawlerPriority = Thread.NORM_PRIORITY;
|
||||
|
||||
public long crawlingExecutionInterval = Constants.DEFAULT_CRAWLING_EXECUTION_INTERVAL;
|
||||
|
||||
public int crawlerPriority = Thread.NORM_PRIORITY;
|
||||
|
||||
private final List<DataCrawlingThread> dataCrawlingThreadList = Collections.synchronizedList(new ArrayList<DataCrawlingThread>());
|
||||
protected final List<DataCrawlingThread> dataCrawlingThreadList = Collections.synchronizedList(new ArrayList<DataCrawlingThread>());
|
||||
|
||||
public void crawl(final String sessionId) {
|
||||
final List<DataConfig> configList = dataConfigService.getAllDataConfigList();
|
||||
final List<DataConfig> configList = ComponentUtil.getCrawlingConfigHelper().getAllDataConfigList();
|
||||
|
||||
if (configList.isEmpty()) {
|
||||
// nothing
|
||||
|
@ -72,7 +63,7 @@ public class DataIndexHelper {
|
|||
}
|
||||
|
||||
public void crawl(final String sessionId, final List<String> configIdList) {
|
||||
final List<DataConfig> configList = dataConfigService.getDataConfigListByIds(configIdList);
|
||||
final List<DataConfig> configList = ComponentUtil.getCrawlingConfigHelper().getDataConfigListByIds(configIdList);
|
||||
|
||||
if (configList.isEmpty()) {
|
||||
// nothing
|
||||
|
@ -97,7 +88,7 @@ public class DataIndexHelper {
|
|||
final List<String> dataCrawlingThreadStatusList = new ArrayList<>();
|
||||
for (final DataConfig dataConfig : configList) {
|
||||
final Map<String, String> initParamMap = new HashMap<>();
|
||||
final String sid = crawlingConfigHelper.store(sessionId, dataConfig);
|
||||
final String sid = ComponentUtil.getCrawlingConfigHelper().store(sessionId, dataConfig);
|
||||
sessionIdList.add(sid);
|
||||
|
||||
initParamMap.put(Constants.SESSION_ID, sessionId);
|
||||
|
@ -189,7 +180,7 @@ public class DataIndexHelper {
|
|||
|
||||
for (final String sid : sessionIdList) {
|
||||
// remove config
|
||||
crawlingConfigHelper.remove(sid);
|
||||
ComponentUtil.getCrawlingConfigHelper().remove(sid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -311,4 +302,12 @@ public class DataIndexHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCrawlingExecutionInterval(final long crawlingExecutionInterval) {
|
||||
this.crawlingExecutionInterval = crawlingExecutionInterval;
|
||||
}
|
||||
|
||||
public void setCrawlerPriority(final int crawlerPriority) {
|
||||
this.crawlerPriority = crawlerPriority;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class DocumentHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocumentHelper.class);
|
||||
|
||||
private static final String SIMILAR_DOC_HASH_PREFIX = "$";
|
||||
protected static final String SIMILAR_DOC_HASH_PREFIX = "$";
|
||||
|
||||
public String getTitle(final ResponseData responseData, final String title, final Map<String, Object> dataMap) {
|
||||
if (title == null) {
|
||||
|
|
|
@ -34,11 +34,11 @@ import org.slf4j.LoggerFactory;
|
|||
public class IndexingHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(IndexingHelper.class);
|
||||
|
||||
public int maxRetryCount = 5;
|
||||
protected int maxRetryCount = 5;
|
||||
|
||||
public int defaultRowSize = 100;
|
||||
protected int defaultRowSize = 100;
|
||||
|
||||
public long requestInterval = 500;
|
||||
protected long requestInterval = 500;
|
||||
|
||||
public void sendDocuments(final FessEsClient fessEsClient, final DocList docList) {
|
||||
if (docList.isEmpty()) {
|
||||
|
@ -199,4 +199,16 @@ public class IndexingHelper {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
public void setMaxRetryCount(final int maxRetryCount) {
|
||||
this.maxRetryCount = maxRetryCount;
|
||||
}
|
||||
|
||||
public void setDefaultRowSize(final int defaultRowSize) {
|
||||
this.defaultRowSize = defaultRowSize;
|
||||
}
|
||||
|
||||
public void setRequestInterval(final long requestInterval) {
|
||||
this.requestInterval = requestInterval;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class IntervalControlHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(IntervalControlHelper.class);
|
||||
|
||||
private volatile boolean crawlerRunning = true;
|
||||
protected volatile boolean crawlerRunning = true;
|
||||
|
||||
public long crawlerWaitMillis = 10000;
|
||||
protected long crawlerWaitMillis = 10000;
|
||||
|
||||
protected List<IntervalRule> ruleList = new ArrayList<>();
|
||||
|
||||
|
@ -195,4 +195,8 @@ public class IntervalControlHelper {
|
|||
return values;
|
||||
}
|
||||
|
||||
public void setCrawlerWaitMillis(final long crawlerWaitMillis) {
|
||||
this.crawlerWaitMillis = crawlerWaitMillis;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class JobHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(JobHelper.class);
|
||||
private int monitorInterval = 60 * 60;// 1hour
|
||||
|
||||
protected int monitorInterval = 60 * 60;// 1hour
|
||||
|
||||
public void register(final ScheduledJob scheduledJob) {
|
||||
final JobManager jobManager = ComponentUtil.getJobManager();
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -42,9 +41,6 @@ import org.slf4j.LoggerFactory;
|
|||
public class LabelTypeHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LabelTypeHelper.class);
|
||||
|
||||
@Resource
|
||||
protected RoleQueryHelper roleQueryHelper;
|
||||
|
||||
protected volatile List<LabelTypeItem> labelTypeItemList = new ArrayList<>();
|
||||
|
||||
protected volatile List<LabelTypePattern> labelTypePatternList;
|
||||
|
@ -92,7 +88,7 @@ public class LabelTypeHelper {
|
|||
}
|
||||
|
||||
final List<Map<String, String>> itemList = new ArrayList<>();
|
||||
final Set<String> roleSet = roleQueryHelper.build(searchRequestType);
|
||||
final Set<String> roleSet = ComponentUtil.getRoleQueryHelper().build(searchRequestType);
|
||||
if (roleSet.isEmpty()) {
|
||||
for (final LabelTypeItem item : labelList) {
|
||||
if (item.getPermissions().length == 0) {
|
||||
|
|
|
@ -38,13 +38,13 @@ import org.slf4j.LoggerFactory;
|
|||
public class OpenSearchHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(OpenSearchHelper.class);
|
||||
|
||||
public String osddPath;
|
||||
protected String osddPath;
|
||||
|
||||
public String encoding = Constants.UTF_8;
|
||||
protected String encoding = Constants.UTF_8;
|
||||
|
||||
public String contentType = "text/xml"; // "application/opensearchdescription+xml";
|
||||
protected String contentType = "text/xml"; // "application/opensearchdescription+xml"
|
||||
|
||||
private File osddFile;
|
||||
protected File osddFile;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
@ -75,4 +75,16 @@ public class OpenSearchHelper {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setOsddPath(final String osddPath) {
|
||||
this.osddPath = osddPath;
|
||||
}
|
||||
|
||||
public void setEncoding(final String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public void setContentType(final String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,13 +40,13 @@ public class PathMappingHelper {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PathMappingHelper.class);
|
||||
|
||||
private static final String FUNCTION_ENCODEURL_MATCHER = "function:encodeUrl";
|
||||
protected static final String FUNCTION_ENCODEURL_MATCHER = "function:encodeUrl";
|
||||
|
||||
private static final String GROOVY_MATCHER = "groovy:";
|
||||
protected static final String GROOVY_MATCHER = "groovy:";
|
||||
|
||||
private final Map<String, List<PathMapping>> pathMappingMap = new HashMap<>();
|
||||
protected final Map<String, List<PathMapping>> pathMappingMap = new HashMap<>();
|
||||
|
||||
volatile List<PathMapping> cachedPathMappingList = null;
|
||||
protected volatile List<PathMapping> cachedPathMappingList = null;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
|
|
@ -39,11 +39,11 @@ import com.google.common.cache.CacheBuilder;
|
|||
public class PopularWordHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PopularWordHelper.class);
|
||||
|
||||
private static final char CACHE_KEY_SPLITTER = '\n';
|
||||
protected static final char CACHE_KEY_SPLITTER = '\n';
|
||||
|
||||
private Cache<String, List<String>> cache;
|
||||
protected Cache<String, List<String>> cache;
|
||||
|
||||
private FessConfig fessConfig;
|
||||
protected FessConfig fessConfig;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
|
|
@ -39,9 +39,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class ProcessHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProcessHelper.class);
|
||||
|
||||
private final ConcurrentHashMap<String, JobProcess> runningProcessMap = new ConcurrentHashMap<>();
|
||||
protected final ConcurrentHashMap<String, JobProcess> runningProcessMap = new ConcurrentHashMap<>();
|
||||
|
||||
private int processDestroyTimeout = 10;
|
||||
protected int processDestroyTimeout = 10;
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.function.Consumer;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -88,21 +87,6 @@ public class QueryHelper {
|
|||
|
||||
protected static final String SITE_FIELD = "site";
|
||||
|
||||
@Resource
|
||||
protected FessConfig fessConfig;
|
||||
|
||||
@Resource
|
||||
protected RoleQueryHelper roleQueryHelper;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected KeyMatchHelper keyMatchHelper;
|
||||
|
||||
@Resource
|
||||
protected VirtualHostHelper virtualHostHelper;
|
||||
|
||||
protected Set<String> apiResponseFieldSet;
|
||||
|
||||
protected Set<String> highlightFieldSet = new HashSet<>();
|
||||
|
@ -143,6 +127,7 @@ public class QueryHelper {
|
|||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (responseFields == null) {
|
||||
responseFields = fessConfig.getQueryAdditionalResponseFields(//
|
||||
SCORE_FIELD, //
|
||||
|
@ -348,10 +333,10 @@ public class QueryHelper {
|
|||
// nothing to do
|
||||
break;
|
||||
default:
|
||||
final String key = virtualHostHelper.getVirtualHostKey();
|
||||
final String key = ComponentUtil.getVirtualHostHelper().getVirtualHostKey();
|
||||
if (StringUtil.isNotBlank(key)) {
|
||||
queryContext.addQuery(boolQuery -> {
|
||||
boolQuery.filter(QueryBuilders.termQuery(fessConfig.getIndexFieldVirtualHost(), key));
|
||||
boolQuery.filter(QueryBuilders.termQuery(ComponentUtil.getFessConfig().getIndexFieldVirtualHost(), key));
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
@ -359,13 +344,13 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected void buildRoleQuery(final QueryContext queryContext, final SearchRequestType searchRequestType) {
|
||||
if (roleQueryHelper != null && queryContext.roleQueryEnabled()) {
|
||||
final Set<String> roleSet = roleQueryHelper.build(searchRequestType);
|
||||
if (queryContext.roleQueryEnabled()) {
|
||||
final Set<String> roleSet = ComponentUtil.getRoleQueryHelper().build(searchRequestType);
|
||||
if (!roleSet.isEmpty()) {
|
||||
queryContext.addQuery(boolQuery -> {
|
||||
final BoolQueryBuilder roleQuery = QueryBuilders.boolQuery();
|
||||
roleSet.stream().forEach(name -> {
|
||||
roleQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
|
||||
roleQuery.should(QueryBuilders.termQuery(ComponentUtil.getFessConfig().getIndexFieldRole(), name));
|
||||
});
|
||||
boolQuery.filter(roleQuery);
|
||||
});
|
||||
|
@ -375,10 +360,9 @@ public class QueryHelper {
|
|||
|
||||
protected void buildBoostQuery(final QueryContext queryContext) {
|
||||
queryContext.addFunctionScore(list -> {
|
||||
list.add(new FilterFunctionBuilder(ScoreFunctionBuilders.fieldValueFactorFunction(fessConfig.getIndexFieldBoost())));
|
||||
if (keyMatchHelper != null) {
|
||||
keyMatchHelper.buildQuery(queryContext.getDefaultKeyword(), list);
|
||||
}
|
||||
list.add(new FilterFunctionBuilder(ScoreFunctionBuilders.fieldValueFactorFunction(ComponentUtil.getFessConfig()
|
||||
.getIndexFieldBoost())));
|
||||
ComponentUtil.getKeyMatchHelper().buildQuery(queryContext.getDefaultKeyword(), list);
|
||||
list.addAll(boostFunctionList);
|
||||
});
|
||||
}
|
||||
|
@ -558,6 +542,7 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected QueryBuilder buildMatchPhraseQuery(final String f, final String text) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (text == null || text.length() != 1
|
||||
|| (!fessConfig.getIndexFieldTitle().equals(f) && !fessConfig.getIndexFieldContent().equals(f))) {
|
||||
return QueryBuilders.matchPhraseQuery(f, text);
|
||||
|
@ -577,6 +562,7 @@ public class QueryHelper {
|
|||
protected QueryBuilder convertTermQuery(final QueryContext context, final TermQuery termQuery, final float boost) {
|
||||
final String field = getSearchField(context, termQuery.getTerm().field());
|
||||
final String text = termQuery.getTerm().text();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
if (fessConfig.getQueryReplaceTermWithPrefixQueryAsBoolean() && text.length() > 1 && text.endsWith("*")) {
|
||||
return convertPrefixQuery(context, new PrefixQuery(new Term(field, text.substring(0, text.length() - 1))), boost);
|
||||
} else if (Constants.DEFAULT_FIELD.equals(field)) {
|
||||
|
@ -631,7 +617,7 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected QueryBuilder convertSiteQuery(final QueryContext context, final String text, final float boost) {
|
||||
return QueryBuilders.prefixQuery(fessConfig.getIndexFieldSite(), text).boost(boost);
|
||||
return QueryBuilders.prefixQuery(ComponentUtil.getFessConfig().getIndexFieldSite(), text).boost(boost);
|
||||
}
|
||||
|
||||
private QueryBuilder convertPhraseQuery(final QueryContext context, final PhraseQuery query, final float boost) {
|
||||
|
@ -659,6 +645,7 @@ public class QueryHelper {
|
|||
|
||||
private QueryBuilder buildDefaultQueryBuilder(final DefaultQueryBuilderFunction builder) {
|
||||
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final QueryBuilder titleQuery =
|
||||
builder.apply(fessConfig.getIndexFieldTitle(), fessConfig.getQueryBoostTitleAsDecimal().floatValue());
|
||||
boolQuery.should(titleQuery);
|
||||
|
@ -685,8 +672,8 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected OptionalThing<String[]> getQueryLanguages() {
|
||||
return LaRequestUtil.getOptionalRequest()
|
||||
.map(request -> fessConfig.getQueryLanguages(request.getLocales(),
|
||||
return LaRequestUtil.getOptionalRequest().map(
|
||||
request -> ComponentUtil.getFessConfig().getQueryLanguages(request.getLocales(),
|
||||
(String[]) request.getAttribute(Constants.REQUEST_LANGUAGES)));
|
||||
}
|
||||
|
||||
|
@ -736,7 +723,7 @@ public class QueryHelper {
|
|||
|
||||
public void processSearchPreference(final SearchRequestBuilder searchRequestBuilder, final OptionalThing<FessUserBean> userBean) {
|
||||
userBean.map(user -> {
|
||||
if (user.hasRoles(fessConfig.getAuthenticationAdminRolesAsArray())) {
|
||||
if (user.hasRoles(ComponentUtil.getFessConfig().getAuthenticationAdminRolesAsArray())) {
|
||||
return Constants.SEARCH_PREFERENCE_LOCAL;
|
||||
}
|
||||
return user.getUserId();
|
||||
|
@ -760,7 +747,7 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected String processJsonSearchPreference(final HttpServletRequest req) {
|
||||
final String pref = fessConfig.getQueryJsonDefaultPreference();
|
||||
final String pref = ComponentUtil.getFessConfig().getQueryJsonDefaultPreference();
|
||||
if (StringUtil.isNotBlank(pref)) {
|
||||
return pref;
|
||||
}
|
||||
|
@ -768,7 +755,7 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected String processGsaSearchPreference(final HttpServletRequest req) {
|
||||
final String pref = fessConfig.getQueryGsaDefaultPreference();
|
||||
final String pref = ComponentUtil.getFessConfig().getQueryGsaDefaultPreference();
|
||||
if (StringUtil.isNotBlank(pref)) {
|
||||
return pref;
|
||||
}
|
||||
|
@ -793,7 +780,7 @@ public class QueryHelper {
|
|||
return scrollResponseFields;
|
||||
}
|
||||
|
||||
public void setScrollResponseFields(String[] scrollResponseFields) {
|
||||
public void setScrollResponseFields(final String[] scrollResponseFields) {
|
||||
this.scrollResponseFields = scrollResponseFields;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,31 +51,31 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class RoleQueryHelper {
|
||||
|
||||
private static final String USER_ROLES = "userRoles";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RoleQueryHelper.class);
|
||||
|
||||
public CachedCipher cipher;
|
||||
protected static final String USER_ROLES = "userRoles";
|
||||
|
||||
public String valueSeparator = "\n";
|
||||
protected CachedCipher cipher;
|
||||
|
||||
public String roleSeparator = ",";
|
||||
protected String valueSeparator = "\n";
|
||||
|
||||
public String parameterKey;
|
||||
protected String roleSeparator = ",";
|
||||
|
||||
public boolean encryptedParameterValue = true;
|
||||
protected String parameterKey;
|
||||
|
||||
public String headerKey;
|
||||
protected boolean encryptedParameterValue = true;
|
||||
|
||||
public boolean encryptedHeaderValue = true;
|
||||
protected String headerKey;
|
||||
|
||||
public String cookieKey;
|
||||
protected boolean encryptedHeaderValue = true;
|
||||
|
||||
public boolean encryptedCookieValue = true;
|
||||
protected String cookieKey;
|
||||
|
||||
protected boolean encryptedCookieValue = true;
|
||||
|
||||
protected Map<String, String> cookieNameMap;
|
||||
|
||||
private final List<String> defaultRoleList = new ArrayList<>();
|
||||
protected final List<String> defaultRoleList = new ArrayList<>();
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
@ -258,4 +258,40 @@ public class RoleQueryHelper {
|
|||
cookieNameMap.put(cookieName, roleName);
|
||||
}
|
||||
|
||||
public void setCipher(final CachedCipher cipher) {
|
||||
this.cipher = cipher;
|
||||
}
|
||||
|
||||
public void setValueSeparator(final String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
public void setRoleSeparator(final String roleSeparator) {
|
||||
this.roleSeparator = roleSeparator;
|
||||
}
|
||||
|
||||
public void setParameterKey(final String parameterKey) {
|
||||
this.parameterKey = parameterKey;
|
||||
}
|
||||
|
||||
public void setEncryptedParameterValue(final boolean encryptedParameterValue) {
|
||||
this.encryptedParameterValue = encryptedParameterValue;
|
||||
}
|
||||
|
||||
public void setHeaderKey(final String headerKey) {
|
||||
this.headerKey = headerKey;
|
||||
}
|
||||
|
||||
public void setEncryptedHeaderValue(final boolean encryptedHeaderValue) {
|
||||
this.encryptedHeaderValue = encryptedHeaderValue;
|
||||
}
|
||||
|
||||
public void setCookieKey(final String cookieKey) {
|
||||
this.cookieKey = cookieKey;
|
||||
}
|
||||
|
||||
public void setEncryptedCookieValue(final boolean encryptedCookieValue) {
|
||||
this.encryptedCookieValue = encryptedCookieValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SambaHelper {
|
|||
|
||||
public static final int SID_TYPE_WKN_GRP = 5;
|
||||
|
||||
private FessConfig fessConfig;
|
||||
protected FessConfig fessConfig;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
|
|
@ -57,9 +57,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class SearchLogHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SearchLogHelper.class);
|
||||
|
||||
public long userCheckInterval = 5 * 60 * 1000L;// 5 min
|
||||
protected long userCheckInterval = 5 * 60 * 1000L;// 5 min
|
||||
|
||||
public int userInfoCacheSize = 1000;
|
||||
protected int userInfoCacheSize = 1000;
|
||||
|
||||
protected volatile Queue<SearchLog> searchLogQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
|
@ -329,4 +329,12 @@ public class SearchLogHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserCheckInterval(final long userCheckInterval) {
|
||||
this.userCheckInterval = userCheckInterval;
|
||||
}
|
||||
|
||||
public void setUserInfoCacheSize(final int userInfoCacheSize) {
|
||||
this.userInfoCacheSize = userInfoCacheSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.misc.Pair;
|
||||
|
@ -62,16 +61,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class SuggestHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SuggestHelper.class);
|
||||
|
||||
private static final String TEXT_SEP = " ";
|
||||
|
||||
@Resource
|
||||
protected ElevateWordBhv elevateWordBhv;
|
||||
|
||||
@Resource
|
||||
protected BadWordBhv badWordBhv;
|
||||
|
||||
@Resource
|
||||
protected FessEsClient fessEsClient;
|
||||
protected static final String TEXT_SEP = " ";
|
||||
|
||||
protected Suggester suggester;
|
||||
|
||||
|
@ -96,6 +86,7 @@ public class SuggestHelper {
|
|||
split(fessConfig.getSuggestFieldRoles(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(roleFieldNameSet::add));
|
||||
contentFieldList = Arrays.asList(stream(fessConfig.getSuggestFieldContents()).get(stream -> stream.toArray(n -> new String[n])));
|
||||
|
||||
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
|
||||
fessEsClient.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(fessConfig.getIndexHealthTimeout());
|
||||
|
||||
final SuggestSettingsBuilder settingsBuilder = SuggestSettings.builder();
|
||||
|
@ -112,7 +103,7 @@ public class SuggestHelper {
|
|||
suggester.createIndexIfNothing();
|
||||
|
||||
final Set<String> undefinedAnalyzer = suggester.settings().analyzer().checkAnalyzer();
|
||||
if (undefinedAnalyzer.size() > 0) {
|
||||
if (!undefinedAnalyzer.isEmpty()) {
|
||||
logger.warn("Undefined lang analyzer. " + undefinedAnalyzer.toString());
|
||||
}
|
||||
|
||||
|
@ -194,8 +185,8 @@ public class SuggestHelper {
|
|||
.indexFromDocument(
|
||||
() -> {
|
||||
final ESSourceReader reader =
|
||||
new ESSourceReader(fessEsClient, suggester.settings(), fessConfig.getIndexDocumentSearchIndex(),
|
||||
fessConfig.getIndexDocumentType());
|
||||
new ESSourceReader(ComponentUtil.getFessEsClient(), suggester.settings(),
|
||||
fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType());
|
||||
reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger());
|
||||
reader.setLimitDocNumPercentage(fessConfig.getSuggestUpdateContentsLimitNumPercentage());
|
||||
reader.setLimitNumber(fessConfig.getSuggestUpdateContentsLimitNumAsInteger());
|
||||
|
@ -225,7 +216,8 @@ public class SuggestHelper {
|
|||
boolQueryBuilder.mustNot(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.QUERY.toString()));
|
||||
boolQueryBuilder.mustNot(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.USER.toString()));
|
||||
|
||||
SuggestUtil.deleteByQuery(fessEsClient, suggester.settings(), suggester.getIndex(), suggester.getType(), boolQueryBuilder);
|
||||
SuggestUtil.deleteByQuery(ComponentUtil.getFessEsClient(), suggester.settings(), suggester.getIndex(), suggester.getType(),
|
||||
boolQueryBuilder);
|
||||
}
|
||||
|
||||
public void purgeSearchlogSuggest(final LocalDateTime time) {
|
||||
|
@ -237,7 +229,8 @@ public class SuggestHelper {
|
|||
boolQueryBuilder.must(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.QUERY.toString()));
|
||||
boolQueryBuilder.mustNot(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.USER.toString()));
|
||||
|
||||
SuggestUtil.deleteByQuery(fessEsClient, suggester.settings(), suggester.getIndex(), suggester.getType(), boolQueryBuilder);
|
||||
SuggestUtil.deleteByQuery(ComponentUtil.getFessEsClient(), suggester.settings(), suggester.getIndex(), suggester.getType(),
|
||||
boolQueryBuilder);
|
||||
}
|
||||
|
||||
public long getAllWordsNum() {
|
||||
|
@ -285,7 +278,7 @@ public class SuggestHelper {
|
|||
public void storeAllElevateWords(final boolean apply) {
|
||||
deleteAllElevateWord(apply);
|
||||
|
||||
final List<ElevateWord> list = elevateWordBhv.selectList(cb -> {
|
||||
final List<ElevateWord> list = ComponentUtil.getComponent(ElevateWordBhv.class).selectList(cb -> {
|
||||
cb.query().matchAll();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageElevateWordMaxFetchSizeAsInteger());
|
||||
});
|
||||
|
@ -298,7 +291,7 @@ public class SuggestHelper {
|
|||
}
|
||||
|
||||
public void deleteAllElevateWord(final boolean apply) {
|
||||
final List<ElevateWord> list = elevateWordBhv.selectList(cb -> {
|
||||
final List<ElevateWord> list = ComponentUtil.getComponent(ElevateWordBhv.class).selectList(cb -> {
|
||||
cb.query().matchAll();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageElevateWordMaxFetchSizeAsInteger());
|
||||
});
|
||||
|
@ -349,7 +342,7 @@ public class SuggestHelper {
|
|||
|
||||
public void storeAllBadWords(final boolean apply) {
|
||||
deleteAllBadWords();
|
||||
final List<BadWord> list = badWordBhv.selectList(cb -> {
|
||||
final List<BadWord> list = ComponentUtil.getComponent(BadWordBhv.class).selectList(cb -> {
|
||||
cb.query().matchAll();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageBadWordMaxFetchSizeAsInteger());
|
||||
});
|
||||
|
|
|
@ -137,7 +137,7 @@ public class SystemHelper {
|
|||
protected void parseProjectProperties() {
|
||||
final Path propPath = ResourceUtil.getProjectPropertiesFile();
|
||||
try (final InputStream in = Files.newInputStream(propPath)) {
|
||||
Properties prop = new Properties();
|
||||
final Properties prop = new Properties();
|
||||
prop.load(in);
|
||||
version = prop.getProperty("fess.version", "0.0.0");
|
||||
final String[] values = version.split("\\.");
|
||||
|
@ -146,7 +146,7 @@ public class SystemHelper {
|
|||
productVersion = majorVersion + "." + minorVersion;
|
||||
System.setProperty("fess.version", version);
|
||||
System.setProperty("fess.product.version", productVersion);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new FessSystemException("Failed to parse project.properties.", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.codelibs.fess.helper;
|
|||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
|
||||
public class UserAgentHelper {
|
||||
private static final String USER_AGENT = "user-agent";
|
||||
protected static final String USER_AGENT = "user-agent";
|
||||
|
||||
private static final String USER_AGENT_TYPE = "ViewHelper.UserAgent";
|
||||
protected static final String USER_AGENT_TYPE = "ViewHelper.UserAgent";
|
||||
|
||||
public UserAgentType getUserAgentType() {
|
||||
return LaRequestUtil.getOptionalRequest().map(request -> {
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
@ -37,10 +36,7 @@ import org.lastaflute.web.util.LaRequestUtil;
|
|||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
|
||||
public class UserInfoHelper {
|
||||
private static final String USER_BEAN = "lastaflute.action.USER_BEAN.FessUserBean";
|
||||
|
||||
@Resource
|
||||
protected SearchLogHelper searchLogHelper;
|
||||
protected static final String USER_BEAN = "lastaflute.action.USER_BEAN.FessUserBean";
|
||||
|
||||
protected int resultDocIdsCacheSize = 20;
|
||||
|
||||
|
@ -133,7 +129,7 @@ public class UserInfoHelper {
|
|||
}
|
||||
|
||||
protected void updateUserSessionId(final String userCode) {
|
||||
searchLogHelper.updateUserInfo(userCode);
|
||||
ComponentUtil.getSearchLogHelper().updateUserInfo(userCode);
|
||||
|
||||
final HttpServletRequest request = LaRequestUtil.getRequest();
|
||||
request.setAttribute(Constants.USER_CODE, userCode);
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.catalina.connector.ClientAbortException;
|
||||
|
@ -79,38 +78,29 @@ import com.ibm.icu.text.SimpleDateFormat;
|
|||
|
||||
public class ViewHelper {
|
||||
|
||||
private static final String CONTENT_DISPOSITION = "Content-Disposition";
|
||||
|
||||
private static final String HL_CACHE = "hl_cache";
|
||||
|
||||
private static final String QUERIES = "queries";
|
||||
|
||||
private static final String CACHE_MSG = "cache_msg";
|
||||
|
||||
private static final Pattern LOCAL_PATH_PATTERN = Pattern.compile("^file:/+[a-zA-Z]:");
|
||||
|
||||
private static final Pattern SHARED_FOLDER_PATTERN = Pattern.compile("^file:/+[^/]\\.");
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ViewHelper.class);
|
||||
|
||||
@Resource
|
||||
protected DynamicProperties systemProperties;
|
||||
protected static final String CONTENT_DISPOSITION = "Content-Disposition";
|
||||
|
||||
@Resource
|
||||
protected PathMappingHelper pathMappingHelper;
|
||||
protected static final String HL_CACHE = "hl_cache";
|
||||
|
||||
@Resource
|
||||
protected UserAgentHelper userAgentHelper;
|
||||
protected static final String QUERIES = "queries";
|
||||
|
||||
public boolean encodeUrlLink = false;
|
||||
protected static final String CACHE_MSG = "cache_msg";
|
||||
|
||||
public String urlLinkEncoding = Constants.UTF_8;
|
||||
protected static final Pattern LOCAL_PATH_PATTERN = Pattern.compile("^file:/+[a-zA-Z]:");
|
||||
|
||||
protected static final Pattern SHARED_FOLDER_PATTERN = Pattern.compile("^file:/+[^/]\\.");
|
||||
|
||||
protected boolean encodeUrlLink = false;
|
||||
|
||||
protected String urlLinkEncoding = Constants.UTF_8;
|
||||
|
||||
protected String[] highlightedFields;
|
||||
|
||||
public String originalHighlightTagPre = "<em>";
|
||||
protected String originalHighlightTagPre = "<em>";
|
||||
|
||||
public String originalHighlightTagPost = "</em>";
|
||||
protected String originalHighlightTagPost = "</em>";
|
||||
|
||||
protected String highlightTagPre;
|
||||
|
||||
|
@ -126,7 +116,7 @@ public class ViewHelper {
|
|||
|
||||
protected final List<FacetQueryView> facetQueryViewList = new ArrayList<>();
|
||||
|
||||
public String cacheTemplateName = "cache";
|
||||
protected String cacheTemplateName = "cache";
|
||||
|
||||
protected String escapedHighlightPre = null;
|
||||
|
||||
|
@ -207,9 +197,7 @@ public class ViewHelper {
|
|||
final boolean isSmbOrFtpUrl = isSmbUrl || isFtpUrl;
|
||||
|
||||
// replacing url with mapping data
|
||||
if (pathMappingHelper != null) {
|
||||
url = pathMappingHelper.replaceUrl(url);
|
||||
}
|
||||
url = ComponentUtil.getPathMappingHelper().replaceUrl(url);
|
||||
|
||||
final boolean isHttpUrl = url.startsWith("http:") || url.startsWith("https:");
|
||||
|
||||
|
@ -263,7 +251,8 @@ public class ViewHelper {
|
|||
final int pos = url.indexOf(':', 5);
|
||||
final boolean isLocalFile = pos > 0 && pos < 12;
|
||||
|
||||
final UserAgentType ua = userAgentHelper.getUserAgentType();
|
||||
final UserAgentType ua = ComponentUtil.getUserAgentHelper().getUserAgentType();
|
||||
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
|
||||
switch (ua) {
|
||||
case IE:
|
||||
if (isLocalFile) {
|
||||
|
@ -437,7 +426,7 @@ public class ViewHelper {
|
|||
if (!ComponentUtil.getFessConfig().isHtmlMimetypeForCache(mimetype)) {
|
||||
cache = StringEscapeUtils.escapeHtml4(cache);
|
||||
}
|
||||
cache = pathMappingHelper.replaceUrls(cache);
|
||||
cache = ComponentUtil.getPathMappingHelper().replaceUrls(cache);
|
||||
if (queries != null && queries.length > 0) {
|
||||
doc.put(HL_CACHE, replaceHighlightQueries(cache, queries));
|
||||
} else {
|
||||
|
@ -697,4 +686,24 @@ public class ViewHelper {
|
|||
consumer.accept(runtime);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEncodeUrlLink(final boolean encodeUrlLink) {
|
||||
this.encodeUrlLink = encodeUrlLink;
|
||||
}
|
||||
|
||||
public void setUrlLinkEncoding(final String urlLinkEncoding) {
|
||||
this.urlLinkEncoding = urlLinkEncoding;
|
||||
}
|
||||
|
||||
public void setOriginalHighlightTagPre(final String originalHighlightTagPre) {
|
||||
this.originalHighlightTagPre = originalHighlightTagPre;
|
||||
}
|
||||
|
||||
public void setOriginalHighlightTagPost(final String originalHighlightTagPost) {
|
||||
this.originalHighlightTagPost = originalHighlightTagPost;
|
||||
}
|
||||
|
||||
public void setCacheTemplateName(final String cacheTemplateName) {
|
||||
this.cacheTemplateName = cacheTemplateName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.service.BoostDocumentRuleService;
|
||||
import org.codelibs.fess.app.service.FailureUrlService;
|
||||
import org.codelibs.fess.app.service.FileAuthenticationService;
|
||||
import org.codelibs.fess.app.service.FileConfigService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
import org.codelibs.fess.crawler.Crawler;
|
||||
import org.codelibs.fess.crawler.CrawlerContext;
|
||||
import org.codelibs.fess.crawler.CrawlerStatus;
|
||||
|
@ -37,6 +30,8 @@ import org.codelibs.fess.crawler.interval.FessIntervalController;
|
|||
import org.codelibs.fess.crawler.service.impl.EsDataService;
|
||||
import org.codelibs.fess.crawler.service.impl.EsUrlFilterService;
|
||||
import org.codelibs.fess.crawler.service.impl.EsUrlQueueService;
|
||||
import org.codelibs.fess.es.config.exbhv.BoostDocumentRuleBhv;
|
||||
import org.codelibs.fess.es.config.exentity.BoostDocumentRule;
|
||||
import org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigName;
|
||||
import org.codelibs.fess.es.config.exentity.FileConfig;
|
||||
import org.codelibs.fess.es.config.exentity.WebConfig;
|
||||
|
@ -50,45 +45,27 @@ public class WebFsIndexHelper {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebFsIndexHelper.class);
|
||||
|
||||
@Resource
|
||||
public WebConfigService webConfigService;
|
||||
protected long maxAccessCount = Long.MAX_VALUE;
|
||||
|
||||
@Resource
|
||||
protected FileConfigService fileConfigService;
|
||||
protected long crawlingExecutionInterval = Constants.DEFAULT_CRAWLING_EXECUTION_INTERVAL;
|
||||
|
||||
@Resource
|
||||
protected FileAuthenticationService fileAuthenticationService;
|
||||
protected int indexUpdaterPriority = Thread.MAX_PRIORITY;
|
||||
|
||||
@Resource
|
||||
public FailureUrlService failureUrlService;
|
||||
protected int crawlerPriority = Thread.NORM_PRIORITY;
|
||||
|
||||
@Resource
|
||||
protected BoostDocumentRuleService boostDocumentRuleService;
|
||||
|
||||
@Resource
|
||||
protected CrawlingConfigHelper crawlingConfigHelper;
|
||||
|
||||
public long maxAccessCount = Long.MAX_VALUE;
|
||||
|
||||
public long crawlingExecutionInterval = Constants.DEFAULT_CRAWLING_EXECUTION_INTERVAL;
|
||||
|
||||
public int indexUpdaterPriority = Thread.MAX_PRIORITY;
|
||||
|
||||
public int crawlerPriority = Thread.NORM_PRIORITY;
|
||||
|
||||
private final List<Crawler> crawlerList = Collections.synchronizedList(new ArrayList<Crawler>());
|
||||
protected final List<Crawler> crawlerList = Collections.synchronizedList(new ArrayList<Crawler>());
|
||||
|
||||
public void crawl(final String sessionId, final List<String> webConfigIdList, final List<String> fileConfigIdList) {
|
||||
final boolean runAll = webConfigIdList == null && fileConfigIdList == null;
|
||||
final List<WebConfig> webConfigList;
|
||||
if (runAll || webConfigIdList != null) {
|
||||
webConfigList = webConfigService.getWebConfigListByIds(webConfigIdList);
|
||||
webConfigList = ComponentUtil.getCrawlingConfigHelper().getWebConfigListByIds(webConfigIdList);
|
||||
} else {
|
||||
webConfigList = Collections.emptyList();
|
||||
}
|
||||
final List<FileConfig> fileConfigList;
|
||||
if (runAll || fileConfigIdList != null) {
|
||||
fileConfigList = fileConfigService.getFileConfigListByIds(fileConfigIdList);
|
||||
fileConfigList = ComponentUtil.getCrawlingConfigHelper().getFileConfigListByIds(fileConfigIdList);
|
||||
} else {
|
||||
fileConfigList = Collections.emptyList();
|
||||
}
|
||||
|
@ -117,7 +94,7 @@ public class WebFsIndexHelper {
|
|||
final List<String> crawlerStatusList = new ArrayList<>();
|
||||
// Web
|
||||
for (final WebConfig webConfig : webConfigList) {
|
||||
final String sid = crawlingConfigHelper.store(sessionId, webConfig);
|
||||
final String sid = ComponentUtil.getCrawlingConfigHelper().store(sessionId, webConfig);
|
||||
|
||||
// create crawler
|
||||
final Crawler crawler = ComponentUtil.getComponent(Crawler.class);
|
||||
|
@ -209,7 +186,7 @@ public class WebFsIndexHelper {
|
|||
}
|
||||
|
||||
// failure url
|
||||
final List<String> excludedUrlList = failureUrlService.getExcludedUrlList(webConfig.getConfigId());
|
||||
final List<String> excludedUrlList = ComponentUtil.getCrawlingConfigHelper().getExcludedUrlList(webConfig.getConfigId());
|
||||
for (final String u : excludedUrlList) {
|
||||
if (StringUtil.isNotBlank(u)) {
|
||||
final String urlValue = Pattern.quote(u.trim());
|
||||
|
@ -233,7 +210,7 @@ public class WebFsIndexHelper {
|
|||
|
||||
// File
|
||||
for (final FileConfig fileConfig : fileConfigList) {
|
||||
final String sid = crawlingConfigHelper.store(sessionId, fileConfig);
|
||||
final String sid = ComponentUtil.getCrawlingConfigHelper().store(sessionId, fileConfig);
|
||||
|
||||
// create crawler
|
||||
final Crawler crawler = ComponentUtil.getComponent(Crawler.class);
|
||||
|
@ -351,7 +328,7 @@ public class WebFsIndexHelper {
|
|||
}
|
||||
|
||||
// failure url
|
||||
final List<String> excludedUrlList = failureUrlService.getExcludedUrlList(fileConfig.getConfigId());
|
||||
final List<String> excludedUrlList = ComponentUtil.getCrawlingConfigHelper().getExcludedUrlList(fileConfig.getConfigId());
|
||||
if (excludedUrlList != null) {
|
||||
for (final String u : excludedUrlList) {
|
||||
if (StringUtil.isNotBlank(u)) {
|
||||
|
@ -382,7 +359,7 @@ public class WebFsIndexHelper {
|
|||
indexUpdater.setSessionIdList(sessionIdList);
|
||||
indexUpdater.setDaemon(true);
|
||||
indexUpdater.setCrawlerList(crawlerList);
|
||||
boostDocumentRuleService.getAvailableBoostDocumentRuleList().forEach(rule -> {
|
||||
getAvailableBoostDocumentRuleList().forEach(rule -> {
|
||||
indexUpdater.addDocBoostMatcher(new org.codelibs.fess.indexer.DocBoostMatcher(rule));
|
||||
});
|
||||
indexUpdater.start();
|
||||
|
@ -478,11 +455,19 @@ public class WebFsIndexHelper {
|
|||
|
||||
for (final String sid : sessionIdList) {
|
||||
// remove config
|
||||
crawlingConfigHelper.remove(sid);
|
||||
ComponentUtil.getCrawlingConfigHelper().remove(sid);
|
||||
deleteCrawlData(sid);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<BoostDocumentRule> getAvailableBoostDocumentRuleList() {
|
||||
return ComponentUtil.getComponent(BoostDocumentRuleBhv.class).selectList(cb -> {
|
||||
cb.query().matchAll();
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.fetchFirst(ComponentUtil.getFessConfig().getPageDocboostMaxFetchSizeAsInteger());
|
||||
});
|
||||
}
|
||||
|
||||
protected void deleteCrawlData(final String sid) {
|
||||
final EsUrlFilterService urlFilterService = ComponentUtil.getComponent(EsUrlFilterService.class);
|
||||
final EsUrlQueueService urlQueueService = ComponentUtil.getComponent(EsUrlQueueService.class);
|
||||
|
@ -511,4 +496,20 @@ public class WebFsIndexHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void setMaxAccessCount(final long maxAccessCount) {
|
||||
this.maxAccessCount = maxAccessCount;
|
||||
}
|
||||
|
||||
public void setCrawlingExecutionInterval(final long crawlingExecutionInterval) {
|
||||
this.crawlingExecutionInterval = crawlingExecutionInterval;
|
||||
}
|
||||
|
||||
public void setIndexUpdaterPriority(final int indexUpdaterPriority) {
|
||||
this.indexUpdaterPriority = indexUpdaterPriority;
|
||||
}
|
||||
|
||||
public void setCrawlerPriority(final int crawlerPriority) {
|
||||
this.crawlerPriority = crawlerPriority;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ public class ThumbnailManager {
|
|||
return idList.size();
|
||||
}
|
||||
|
||||
protected void process(final FessConfig fessConfig, ThumbnailQueue entity) {
|
||||
protected void process(final FessConfig fessConfig, final ThumbnailQueue entity) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing thumbnail: " + entity);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
package org.codelibs.fess.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.lucene.queryparser.classic.QueryParser;
|
||||
|
@ -71,6 +73,7 @@ import org.codelibs.fess.thumbnail.ThumbnailManager;
|
|||
import org.lastaflute.core.message.MessageManager;
|
||||
import org.lastaflute.core.security.PrimaryCipher;
|
||||
import org.lastaflute.di.core.SingletonLaContainer;
|
||||
import org.lastaflute.di.core.exception.ComponentNotFoundException;
|
||||
import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
|
||||
import org.lastaflute.di.core.smart.hot.HotdeployUtil;
|
||||
import org.lastaflute.job.JobManager;
|
||||
|
@ -83,6 +86,8 @@ public final class ComponentUtil {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ComponentUtil.class);
|
||||
|
||||
private static Map<String, Object> componentMap = new HashMap<>();
|
||||
|
||||
private static final String CURL_HELPER = "curlHelper";
|
||||
|
||||
private static final String QUERY_STRING_BUILDER = "queryStringBuilder";
|
||||
|
@ -341,7 +346,8 @@ public final class ComponentUtil {
|
|||
if (fessConfig != null) {
|
||||
return fessConfig;
|
||||
}
|
||||
return getComponent(FessConfig.class);
|
||||
fessConfig = getComponent(FessConfig.class);
|
||||
return fessConfig;
|
||||
}
|
||||
|
||||
public static SuggestHelper getSuggestHelper() {
|
||||
|
@ -449,6 +455,13 @@ public final class ComponentUtil {
|
|||
} else {
|
||||
throw new ContainerNotAvailableException(componentName);
|
||||
}
|
||||
} catch (ComponentNotFoundException e) {
|
||||
if (componentMap.containsKey(componentName)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final T c = (T) componentMap.get(componentName);
|
||||
return c;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,7 +499,11 @@ public final class ComponentUtil {
|
|||
ComponentUtil.fessConfig = fessConfig;
|
||||
if (fessConfig == null) {
|
||||
FessProp.propMap.clear();
|
||||
componentMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void register(final Object instance, final String name) {
|
||||
componentMap.put(name, instance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
labelType = new LabelType();
|
||||
labelType.setName(name);
|
||||
labelType.setValue(name);
|
||||
labelType.setPermissions(new String[] {"Rguest"});
|
||||
labelType.setPermissions(new String[] { "Rguest" });
|
||||
labelType.setCreatedBy(Constants.SYSTEM_USER);
|
||||
labelType.setCreatedTime(now);
|
||||
labelType.setUpdatedBy(Constants.SYSTEM_USER);
|
||||
|
@ -178,7 +178,7 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
webConfig.setExcludedUrls(parseFilterPaths(globalParams.get(BAD_URLS), true, false));
|
||||
webConfig.setExcludedDocUrls(StringUtil.EMPTY);
|
||||
webConfig.setUserAgent(userAgent);
|
||||
webConfig.setPermissions(new String[] {"Rguest"});
|
||||
webConfig.setPermissions(new String[] { "Rguest" });
|
||||
webConfig.setCreatedBy(Constants.SYSTEM_USER);
|
||||
webConfig.setCreatedTime(now);
|
||||
webConfig.setUpdatedBy(Constants.SYSTEM_USER);
|
||||
|
@ -202,7 +202,7 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
fileConfig.setIncludedDocPaths(StringUtil.EMPTY);
|
||||
fileConfig.setExcludedPaths(parseFilterPaths(globalParams.get(BAD_URLS), false, true));
|
||||
fileConfig.setExcludedDocPaths(StringUtil.EMPTY);
|
||||
fileConfig.setPermissions(new String[] {"Rguest"});
|
||||
fileConfig.setPermissions(new String[] { "Rguest" });
|
||||
fileConfig.setCreatedBy(Constants.SYSTEM_USER);
|
||||
fileConfig.setCreatedTime(now);
|
||||
fileConfig.setUpdatedBy(Constants.SYSTEM_USER);
|
||||
|
@ -218,7 +218,7 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
|
||||
@Override
|
||||
public void characters(final char[] ch, final int start, final int length) throws SAXException {
|
||||
String text = new String(ch, start, length);
|
||||
final String text = new String(ch, start, length);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Text: " + text);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
}).collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
protected String getFilterPath(String s) {
|
||||
protected String getFilterPath(final String s) {
|
||||
if (s.startsWith("#")) {
|
||||
return StringUtil.EMPTY;
|
||||
} else if (s.startsWith(CONTAINS)) {
|
||||
|
|
|
@ -203,7 +203,7 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
allPageCount = currentPageNumber;
|
||||
}
|
||||
currentStartRecordNumber = allRecordCount != 0 ? start + 1 : 0;
|
||||
currentEndRecordNumber = currentStartRecordNumber + (long) pageSize - 1;
|
||||
currentEndRecordNumber = currentStartRecordNumber + pageSize - 1;
|
||||
currentEndRecordNumber = allRecordCount < currentEndRecordNumber ? allRecordCount : currentEndRecordNumber;
|
||||
|
||||
final int pageRangeSize = 5;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class QueryStringBuilder {
|
|||
final int maxQueryLength = fessConfig.getQueryMaxLengthAsInteger().intValue();
|
||||
final StringBuilder queryBuf = new StringBuilder(255);
|
||||
|
||||
Map<String, String[]> conditions = params.getConditions();
|
||||
final Map<String, String[]> conditions = params.getConditions();
|
||||
if (params.hasConditionQuery()) {
|
||||
appendConditions(queryBuf, conditions);
|
||||
} else {
|
||||
|
@ -97,7 +97,7 @@ public class QueryStringBuilder {
|
|||
return queryBuf.toString().trim();
|
||||
}
|
||||
|
||||
protected void appendConditions(StringBuilder queryBuf, Map<String, String[]> conditions) {
|
||||
protected void appendConditions(final StringBuilder queryBuf, final Map<String, String[]> conditions) {
|
||||
if (conditions == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class QueryStringBuilder {
|
|||
|
||||
protected String escape(final String q, final String... values) {
|
||||
String value = q;
|
||||
for (String s : values) {
|
||||
for (final String s : values) {
|
||||
value = value.replace(s, "\\" + s);
|
||||
}
|
||||
return value;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
/*
|
||||
// TODO
|
||||
private File file1;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
file1 = File.createTempFile("kuromoji_", ".txt");
|
||||
|
@ -37,7 +37,7 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
"token1,seg1,reading1,pos1\ntoken2,seg2,reading2,pos2\ntoken3,seg3,reading3,pos3"
|
||||
.getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
file1.delete();
|
||||
|
@ -92,7 +92,7 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
final PagingList<KuromojiItem> itemList1 = kuromojiFile.selectList(0,
|
||||
20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem1 = new KuromojiItem(0, "token4",
|
||||
"seg4", "reading4", "pos4");
|
||||
kuromojiFile.insert(kuromojiItem1);
|
||||
|
@ -103,7 +103,7 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
assertEquals("seg4", itemList2.get(3).getSegmentation());
|
||||
assertEquals("reading4", itemList2.get(3).getReading());
|
||||
assertEquals("pos4", itemList2.get(3).getPos());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem2 = new KuromojiItem(0, "token5",
|
||||
"seg5", "reading5", "pos5");
|
||||
kuromojiFile.insert(kuromojiItem2);
|
||||
|
@ -115,13 +115,13 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
assertEquals("reading5", itemList3.get(4).getReading());
|
||||
assertEquals("pos5", itemList3.get(4).getPos());
|
||||
}
|
||||
|
||||
|
||||
public void test_update() {
|
||||
final KuromojiFile kuromojiFile = new KuromojiFile(file1);
|
||||
final PagingList<KuromojiItem> itemList1 = kuromojiFile.selectList(0,
|
||||
20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem1 = itemList1.get(0);
|
||||
kuromojiItem1.setNewToken("TOKEN1");
|
||||
kuromojiItem1.setNewSegmentation("SEG1");
|
||||
|
@ -137,7 +137,7 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
assertEquals("READING1", kuromojiItem2.getReading());
|
||||
assertEquals("POS1", kuromojiItem2.getPos());
|
||||
assertFalse(kuromojiItem2.isUpdated());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem3 = itemList2.get(2);
|
||||
kuromojiItem3.setNewToken("TOKEN3");
|
||||
kuromojiItem3.setNewSegmentation("SEG3");
|
||||
|
@ -154,28 +154,28 @@ public class KuromojiFileTest extends UnitFessTestCase {
|
|||
assertEquals("POS3", kuromojiItem4.getPos());
|
||||
assertFalse(kuromojiItem4.isUpdated());
|
||||
}
|
||||
|
||||
|
||||
public void test_delete() throws Exception {
|
||||
final KuromojiFile kuromojiFile = new KuromojiFile(file1);
|
||||
final PagingList<KuromojiItem> itemList1 = kuromojiFile.selectList(0,
|
||||
20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem1 = itemList1.get(0);
|
||||
kuromojiFile.delete(kuromojiItem1);
|
||||
final PagingList<KuromojiItem> itemList2 = kuromojiFile.selectList(0,
|
||||
20);
|
||||
assertEquals(2, itemList2.size());
|
||||
|
||||
|
||||
final KuromojiItem kuromojiItem2 = itemList2.get(1);
|
||||
kuromojiFile.delete(kuromojiItem2);
|
||||
final PagingList<KuromojiItem> itemList3 = kuromojiFile.selectList(0,
|
||||
20);
|
||||
assertEquals(1, itemList3.size());
|
||||
|
||||
|
||||
assertEquals("token2,seg2,reading2,pos2" + Constants.LINE_SEPARATOR,
|
||||
new String(FileUtil.getBytes(file1), Constants.UTF_8));
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
// TODO set up elasticsearch and dictionaryManager
|
||||
synonymFile = new SynonymFile("1", file1.getAbsolutePath(), new Date());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
file1.delete();
|
||||
|
@ -120,7 +120,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
public void test_insert() {
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
|
||||
final SynonymItem synonymItem1 = new SynonymItem(0, new String[] { "z1", "z2" }, new String[] { "Z1", "Z2" });
|
||||
synonymFile.insert(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
|
@ -129,7 +129,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
assertEquals("z2", itemList2.get(5).getInputs()[1]);
|
||||
assertEquals("Z1", itemList2.get(5).getOutputs()[0]);
|
||||
assertEquals("Z2", itemList2.get(5).getOutputs()[1]);
|
||||
|
||||
|
||||
final SynonymItem synonymItem2 = new SynonymItem(0, new String[] {"z1", "z2" }, new String[] { "z1", "z2" });
|
||||
synonymFile.insert(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
|
@ -144,7 +144,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymItem1.setNewInputs(new String[] { "a1", "a2" });
|
||||
synonymItem1.setNewOutputs(new String[] { "A1", "A2" });
|
||||
|
@ -159,7 +159,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
assertEquals("A1", synonymItem2.getOutputs()[0]);
|
||||
assertEquals("A2", synonymItem2.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
|
||||
|
||||
final SynonymItem synonymItem3 = itemList2.get(2);
|
||||
synonymItem3.setNewInputs(new String[] { "c1", "c2" });
|
||||
synonymItem3.setNewOutputs(new String[] { "c1", "c2" });
|
||||
|
@ -175,22 +175,22 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
assertEquals("c2", synonymItem4.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
}
|
||||
|
||||
|
||||
public void test_delete() throws Exception {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymFile.delete(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(4, itemList2.size());
|
||||
|
||||
|
||||
final SynonymItem synonymItem2 = itemList2.get(3);
|
||||
synonymFile.delete(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(3, itemList3.size());
|
||||
|
||||
|
||||
assertEquals(
|
||||
"b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2"
|
||||
+ Constants.LINE_SEPARATOR + "X1,x1"
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.codelibs.core.io.FileUtil;
|
|||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.entity.SearchRequestParams.SearchRequestType;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.unit.UnitFessTestCase;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
|
@ -33,7 +32,6 @@ import org.elasticsearch.index.query.PrefixQueryBuilder;
|
|||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
||||
import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
|
||||
|
||||
public class QueryHelperTest extends UnitFessTestCase {
|
||||
|
||||
|
@ -49,17 +47,15 @@ public class QueryHelperTest extends UnitFessTestCase {
|
|||
queryParser.setDefaultOperator(QueryParser.Operator.AND);
|
||||
return queryParser;
|
||||
}
|
||||
|
||||
};
|
||||
File file = File.createTempFile("test", ".properties");
|
||||
file.deleteOnExit();
|
||||
FileUtil.writeBytes(file.getAbsolutePath(), "ldap.security.principal=%s@fess.codelibs.local".getBytes("UTF-8"));
|
||||
DynamicProperties systemProps = new DynamicProperties(file);
|
||||
SingletonLaContainerFactory.getContainer().register(systemProps, "systemProperties");
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
registerMock(fessConfig);
|
||||
registerMock(new SystemHelper());
|
||||
registerMock(new VirtualHostHelper());
|
||||
ComponentUtil.register(systemProps, "systemProperties");
|
||||
ComponentUtil.register(new SystemHelper(), "systemHelper");
|
||||
ComponentUtil.register(new VirtualHostHelper(), "virtualHostHelper");
|
||||
ComponentUtil.register(new KeyMatchHelper(), "keyMatchHelper");
|
||||
inject(queryHelper);
|
||||
queryHelper.init();
|
||||
}
|
||||
|
|
|
@ -31,12 +31,32 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
public class ViewHelperTest extends UnitFessTestCase {
|
||||
public ViewHelper viewHelper;
|
||||
|
||||
private UserAgentHelper userAgentHelper;
|
||||
|
||||
private PathMappingHelper pathMappingHelper;
|
||||
|
||||
private File propertiesFile;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
propertiesFile = File.createTempFile("test", ".properties");
|
||||
propertiesFile.deleteOnExit();
|
||||
DynamicProperties systemProps = new DynamicProperties(propertiesFile);
|
||||
ComponentUtil.register(systemProps, "systemProperties");
|
||||
userAgentHelper = new UserAgentHelper();
|
||||
ComponentUtil.register(userAgentHelper, "userAgentHelper");
|
||||
pathMappingHelper = new PathMappingHelper();
|
||||
pathMappingHelper.cachedPathMappingList = new ArrayList<>();
|
||||
ComponentUtil.register(pathMappingHelper, "pathMappingHelper");
|
||||
viewHelper = new ViewHelper();
|
||||
viewHelper.init();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
propertiesFile.delete();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_getUrlLink() throws IOException {
|
||||
ComponentUtil.setFessConfig(new FessConfig.SimpleImpl() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -88,15 +108,13 @@ public class ViewHelperTest extends UnitFessTestCase {
|
|||
assertUrlLink("ftp://www.codelibs.org/%z", //
|
||||
"ftp://www.codelibs.org/%z");
|
||||
|
||||
viewHelper.userAgentHelper = new UserAgentHelper() {
|
||||
userAgentHelper = new UserAgentHelper() {
|
||||
public UserAgentType getUserAgentType() {
|
||||
return UserAgentType.IE;
|
||||
}
|
||||
};
|
||||
File tempFile = File.createTempFile("test", ".properties");
|
||||
FileUtil.writeBytes(tempFile.getAbsolutePath(), new byte[0]);
|
||||
tempFile.deleteOnExit();
|
||||
viewHelper.systemProperties = new DynamicProperties(tempFile);
|
||||
ComponentUtil.register(userAgentHelper, "userAgentHelper");
|
||||
FileUtil.writeBytes(propertiesFile.getAbsolutePath(), new byte[0]);
|
||||
|
||||
// file
|
||||
assertUrlLink("file:/home/taro/test.txt", //
|
||||
|
@ -117,9 +135,8 @@ public class ViewHelperTest extends UnitFessTestCase {
|
|||
PathMapping pathMapping = new PathMapping();
|
||||
pathMapping.setRegex("ftp:");
|
||||
pathMapping.setReplacement("file:");
|
||||
viewHelper.pathMappingHelper = new PathMappingHelper();
|
||||
viewHelper.pathMappingHelper.cachedPathMappingList = new ArrayList<>();
|
||||
viewHelper.pathMappingHelper.cachedPathMappingList.add(pathMapping);
|
||||
pathMappingHelper.cachedPathMappingList = new ArrayList<>();
|
||||
pathMappingHelper.cachedPathMappingList.add(pathMapping);
|
||||
// ftp->file
|
||||
assertUrlLink("ftp:/home/taro/test.txt", //
|
||||
"file://home/taro/test.txt");
|
||||
|
|
Loading…
Add table
Reference in a new issue