Merge pull request #421 from tonkatu05/master

change from getProperty(...) to fessConfig.getFoo()
This commit is contained in:
Shinsuke Sugaya 2016-03-09 22:54:14 +09:00
commit ecc3678f01
18 changed files with 34 additions and 88 deletions

View file

@ -75,7 +75,7 @@ public class JsonApiManager extends BaseApiManager {
@Override
public boolean matches(final HttpServletRequest request) {
if (Constants.FALSE.equals(ComponentUtil.getSystemProperties().getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE))) {
if (!ComponentUtil.getFessConfig().isWebApiJson()) {
return false;
}
@ -313,7 +313,7 @@ public class JsonApiManager extends BaseApiManager {
}
protected void processPopularWordRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) {
if (Constants.FALSE.equals(systemProperties.getProperty(Constants.WEB_API_POPULAR_WORD_PROPERTY, Constants.TRUE))) {
if (!ComponentUtil.getFessConfig().isWebApiPopularWord()) {
writeJsonResponse(9, null, "Unsupported operation.");
return;
}
@ -359,7 +359,7 @@ public class JsonApiManager extends BaseApiManager {
}
protected void processFavoriteRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) {
if (Constants.FALSE.equals(systemProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) {
if (!ComponentUtil.getFessConfig().isUserFavorite()) {
writeJsonResponse(9, null, "Unsupported operation.");
return;
}
@ -442,7 +442,7 @@ public class JsonApiManager extends BaseApiManager {
}
protected void processFavoritesRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) {
if (Constants.FALSE.equals(systemProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) {
if (!ComponentUtil.getFessConfig().isUserFavorite()) {
writeJsonResponse(9, null, "Unsupported operation.");
return;
}

View file

@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.fess.Constants;
import org.codelibs.fess.api.BaseApiManager;
import org.codelibs.fess.api.json.JsonApiManager;
import org.codelibs.fess.helper.RoleQueryHelper;
@ -75,10 +74,10 @@ public class SuggestApiManager extends BaseApiManager {
builder.setSize(parameter.getNum());
builder.addKind(SuggestItem.Kind.USER.toString());
if (Constants.TRUE.equals(systemProperties.getProperty(Constants.SUGGEST_SEARCH_LOG_PROPERTY, Constants.TRUE))) {
if (ComponentUtil.getFessConfig().isSuggestSearchLog()) {
builder.addKind(SuggestItem.Kind.QUERY.toString());
}
if (Constants.TRUE.equals(systemProperties.getProperty(Constants.SUGGEST_DOCUMENTS_PROPERTY, Constants.TRUE))) {
if (ComponentUtil.getFessConfig().isSuggestDocuments()) {
builder.addKind(SuggestItem.Kind.DOCUMENT.toString());
}

View file

@ -130,17 +130,8 @@ public class FailureUrlService implements Serializable {
}
public List<String> getExcludedUrlList(final String configId) {
final String failureCountStr = systemProperties.getProperty(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY);
final String ignoreFailureType =
systemProperties.getProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, Constants.DEFAULT_IGNORE_FAILURE_TYPE);
int failureCount = Constants.DEFAULT_FAILURE_COUNT;
if (failureCountStr != null) {
try {
failureCount = Integer.parseInt(failureCountStr);
} catch (final NumberFormatException ignore) {
// ignore
}
}
int failureCount = fessConfig.getFailureCountThreshold();
final String ignoreFailureType = fessConfig.getIgnoreFailureType();
if (failureCount < 0) {
return Collections.emptyList();

View file

@ -85,7 +85,7 @@ public class SearchService {
final long requestedTime = systemHelper.getCurrentTimeAsLong();
final long startTime = System.currentTimeMillis();
final boolean searchLogSupport = Constants.TRUE.equals(systemProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE));
final boolean searchLogSupport = fessConfig.isSearchLog();
final String query =
QueryStringBuilder.query(params.getQuery()).extraQueries(params.getExtraQueries()).fields(params.getFields()).build();

View file

@ -46,12 +46,10 @@ public class RootAction extends FessSearchAction {
op.setup(form -> {
buildFormParams(form);
});
}).renderWith(
data -> {
buildInitParams();
RenderDataUtil.register(data, "notification",
systemProperties.getProperty(Constants.NOTIFICATION_SEARCH_TOP, StringUtil.EMPTY));
});
}).renderWith(data -> {
buildInitParams();
RenderDataUtil.register(data, "notification", fessConfig.getNotificationSearchTop());
});
}
}

View file

@ -321,7 +321,7 @@ public class AdminBadwordAction extends FessAdminAction {
}
private String getCsvEncoding() {
return systemProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
return fessConfig.getCsvFileEncoding();
}
// ===================================================================================

View file

@ -336,7 +336,7 @@ public class AdminElevatewordAction extends FessAdminAction {
}
private String getCsvEncoding() {
return systemProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
return fessConfig.getCsvFileEncoding();
}
// ===================================================================================

View file

@ -151,10 +151,6 @@ public class AdminGeneralAction extends FessAdminAction {
return redirect(getClass());
}
private String getCheckboxValue(final String value) {
return Constants.ON.equalsIgnoreCase(value) ? Constants.TRUE : Constants.FALSE;
}
protected void updateForm(final EditForm form) {
form.loginRequired = fessConfig.isLoginRequired() ? Constants.TRUE : Constants.FALSE;
form.incrementalCrawling = fessConfig.isIncrementalCrawling() ? Constants.TRUE : Constants.FALSE;
@ -191,18 +187,6 @@ public class AdminGeneralAction extends FessAdminAction {
systemProperties.setProperty(key, value == null ? StringUtil.EMPTY : value);
}
private Integer getPropertyAsInteger(final String key, final int defaultValue) {
final String value = systemProperties.getProperty(key);
if (value != null) {
try {
return Integer.valueOf(value);
} catch (final NumberFormatException e) {
// ignore
}
}
return defaultValue;
}
private List<String> getDayItems() {
final List<String> items = new ArrayList<String>();
for (int i = 0; i < 32; i++) {

View file

@ -91,8 +91,8 @@ public abstract class FessSearchAction extends FessBaseAction {
@Override
public ActionResponse hookBefore(final ActionRuntime runtime) { // application may override
searchLogSupport = Constants.TRUE.equals(systemProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE));
favoriteSupport = Constants.TRUE.equals(systemProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE));
searchLogSupport = fessConfig.isSearchLog();
favoriteSupport = fessConfig.isUserFavorite();
runtime.registerData("searchLogSupport", searchLogSupport);
runtime.registerData("favoriteSupport", favoriteSupport);
if (fessConfig.isWebApiPopularWord()) {

View file

@ -94,7 +94,7 @@ public class GoAction extends FessSearchAction {
return redirect(ErrorAction.class);
}
if (Constants.TRUE.equals(systemProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE))) {
if (fessConfig.isSearchLog()) {
final String userSessionId = userInfoHelper.getUserCode();
if (userSessionId != null) {
final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper();

View file

@ -46,7 +46,7 @@ public class LoginAction extends FessSearchAction {
@Execute
public HtmlResponse index() {
return asHtml(path_Login_IndexJsp).renderWith(data -> {
RenderDataUtil.register(data, "notification", systemProperties.getProperty(Constants.NOTIFICATION_LOGIN, StringUtil.EMPTY));
RenderDataUtil.register(data, "notification", fessConfig.getNotificationLogin());
}).useForm(LoginForm.class);
}

View file

@ -27,8 +27,6 @@ import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.fess.Constants;
import org.codelibs.fess.crawler.builder.RequestDataBuilder;
import org.codelibs.fess.crawler.client.CrawlerClient;
import org.codelibs.fess.crawler.client.smb.SmbClient;
@ -56,8 +54,7 @@ public class FessCrawlerThread extends CrawlerThread {
@Override
protected boolean isContentUpdated(final CrawlerClient client, final UrlQueue<?> urlQueue) {
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
if (systemProperties.getProperty(Constants.INCREMENTAL_CRAWLING_PROPERTY, Constants.TRUE).equals(Constants.TRUE)) {
if (ComponentUtil.getFessConfig().isIncrementalCrawling()) {
final long startTime = System.currentTimeMillis();

View file

@ -242,16 +242,15 @@ public class Crawler implements Serializable {
try {
crawlingInfoHelper.store(options.sessionId, true);
final String dayForCleanupStr;
int dayForCleanup = -1;
if (StringUtil.isNotBlank(options.expires)) {
dayForCleanupStr = options.expires;
try {
dayForCleanup = Integer.parseInt(dayForCleanupStr);
} catch (final NumberFormatException e) {}
} else {
dayForCleanupStr =
systemProperties.getProperty(Constants.DAY_FOR_CLEANUP_PROPERTY, Constants.DEFAULT_DAY_FOR_CLEANUP.toString());
dayForCleanup = ComponentUtil.getFessConfig().getDayForCleanup();
}
int dayForCleanup = -1;
try {
dayForCleanup = Integer.parseInt(dayForCleanupStr);
} catch (final NumberFormatException e) {}
crawlingInfoHelper.updateParams(options.sessionId, options.name, dayForCleanup);
} catch (final Exception e) {
logger.warn("Failed to store crawling information.", e);

View file

@ -156,8 +156,7 @@ public class SuggestCreator implements Serializable {
}
private int create() {
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
if (!Constants.TRUE.equals(systemProperties.getProperty(Constants.SUGGEST_DOCUMENTS_PROPERTY, Constants.TRUE))) {
if (!ComponentUtil.getFessConfig().isSuggestDocuments()) {
logger.info("Skip create suggest document.");
return 0;
}
@ -187,13 +186,10 @@ public class SuggestCreator implements Serializable {
private int purge(final LocalDateTime time) {
final SuggestHelper suggestHelper = ComponentUtil.getSuggestHelper();
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
try {
suggestHelper.purgeDocumentSuggest(time);
final long cleanupDay =
Long.parseLong(systemProperties.getProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY,
Constants.DEFAULT_SUGGEST_PURGE_DAY));
final long cleanupDay = ComponentUtil.getFessConfig().getPurgeSuggestSearchLogDay();
if (cleanupDay > 0) {
suggestHelper.purgeSearchlogSuggest(time.minusDays(cleanupDay));
}

View file

@ -93,13 +93,7 @@ public class DataIndexHelper implements Serializable {
}
protected void doCrawl(final String sessionId, final List<DataConfig> configList) {
int multiprocessCrawlingCount = 5;
final String value = systemProperties.getProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5");
try {
multiprocessCrawlingCount = Integer.parseInt(value);
} catch (final NumberFormatException e) {
// NOP
}
int multiprocessCrawlingCount = ComponentUtil.getFessConfig().getCrawlingThreadCount();
final long startTime = System.currentTimeMillis();

View file

@ -83,7 +83,7 @@ public class SearchLogHelper {
final UserInfoHelper userInfoHelper = ComponentUtil.getUserInfoHelper();
final SearchLog searchLog = new SearchLog();
if (Constants.TRUE.equals(systemProperties.getProperty(Constants.USER_INFO_PROPERTY, Constants.TRUE))) {
if (ComponentUtil.getFessConfig().isUserInfo()) {
final String userCode = userInfoHelper.getUserCode();
if (userCode != null) {
searchLog.setUserSessionId(userCode);
@ -189,7 +189,7 @@ public class SearchLogHelper {
}
protected void processSearchLogQueue(final Queue<SearchLog> queue) {
final String value = systemProperties.getProperty(Constants.PURGE_BY_BOTS_PROPERTY, StringUtil.EMPTY);
final String value = ComponentUtil.getFessConfig().getPurgeByBots();
String[] botNames;
if (StringUtil.isBlank(value)) {
botNames = StringUtil.EMPTY_STRINGS;

View file

@ -126,13 +126,7 @@ public class WebFsIndexHelper implements Serializable {
}
protected void doCrawl(final String sessionId, final List<WebConfig> webConfigList, final List<FileConfig> fileConfigList) {
int multiprocessCrawlingCount = 5;
final String value = systemProperties.getProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5");
try {
multiprocessCrawlingCount = Integer.parseInt(value);
} catch (final NumberFormatException e) {
// NOP
}
int multiprocessCrawlingCount = ComponentUtil.getFessConfig().getCrawlingThreadCount();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final FessConfig fessConfig = ComponentUtil.getFessConfig();

View file

@ -15,8 +15,6 @@
*/
package org.codelibs.fess.job;
import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.fess.Constants;
import org.codelibs.fess.app.service.CrawlingInfoService;
import org.codelibs.fess.app.service.JobLogService;
import org.codelibs.fess.app.service.SearchLogService;
@ -35,7 +33,6 @@ public class PurgeLogJob {
final SearchLogService searchLogService = ComponentUtil.getComponent(SearchLogService.class);
final JobLogService jobLogService = ComponentUtil.getComponent(JobLogService.class);
final UserInfoService userInfoService = ComponentUtil.getComponent(UserInfoService.class);
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final StringBuilder resultBuf = new StringBuilder();
@ -50,8 +47,7 @@ public class PurgeLogJob {
// purge search logs
try {
final String value = systemProperties.getProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
final int days = ComponentUtil.getFessConfig().getPurgeSearchLogDay();
if (days >= 0) {
searchLogService.deleteBefore(days);
} else {
@ -64,8 +60,7 @@ public class PurgeLogJob {
// purge job logs
try {
final String value = systemProperties.getProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
final int days = ComponentUtil.getFessConfig().getPurgeJobLogDay();
if (days >= 0) {
jobLogService.deleteBefore(days);
} else {
@ -78,8 +73,7 @@ public class PurgeLogJob {
// purge user info
try {
final String value = systemProperties.getProperty(Constants.PURGE_USER_INFO_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
final int days = ComponentUtil.getFessConfig().getPurgeUserInfoDay();
if (days >= 0) {
userInfoService.deleteBefore(days);
} else {