Skip to content

Commit

Permalink
rename to system.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Jan 6, 2016
1 parent 38f9329 commit 4c13056
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 35 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/codelibs/fess/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class Constants extends CoreLibConstants {

public static final String WEB_API_SUGGEST_PROPERTY = "web.api.suggest";

public static final String WEB_API_ANALYSIS_PROPERTY = "web.api.analysis";
public static final String WEB_API_POPULAR_WORD_PROPERTY = "web.api.popularword";

public static final String WEB_DESIGN_EDITOR_PROPERTY = "design.editor";

Expand All @@ -115,8 +115,6 @@ public class Constants extends CoreLibConstants {

public static final String FAILURE_COUNT_THRESHOLD_PROPERTY = "failure.countthreshold";

public static final String WEB_API_POPULAR_WORD_PROPERTY = "web.api.popularword";

public static final String CSV_FILE_ENCODING_PROPERTY = "csv.file.encoding";

public static final String PURGE_SEARCH_LOG_DAY_PROPERTY = "purge.searchlog.day";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public JsonApiManager() {

@Override
public boolean matches(final HttpServletRequest request) {
if (Constants.FALSE.equals(ComponentUtil.getCrawlerProperties().getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE))) {
if (Constants.FALSE.equals(ComponentUtil.getSystemProperties().getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE))) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public HtmlResponse update(final EditForm form) {
updateProperty(Constants.APPEND_QUERY_PARAMETER_PROPERTY, getCheckboxValue(form.appendQueryParameter));
updateProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, form.ignoreFailureType);
updateProperty(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, form.failureCountThreshold.toString());
updateProperty(Constants.WEB_API_POPULAR_WORD_PROPERTY, getCheckboxValue(form.popularWord));
fessConfig.setWebApiPopularWord(Constants.ON.equalsIgnoreCase(form.popularWord));
updateProperty(Constants.CSV_FILE_ENCODING_PROPERTY, form.csvFileEncoding);
updateProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, form.purgeSearchLogDay.toString());
updateProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, form.purgeJobLogDay.toString());
Expand Down Expand Up @@ -175,7 +175,7 @@ protected void updateForm(final EditForm form) {
form.ignoreFailureType =
crawlerProperties.getProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, Constants.DEFAULT_IGNORE_FAILURE_TYPE);
form.failureCountThreshold = getPropertyAsInteger(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, Constants.DEFAULT_FAILURE_COUNT);
form.popularWord = crawlerProperties.getProperty(Constants.WEB_API_POPULAR_WORD_PROPERTY, Constants.TRUE);
form.popularWord = fessConfig.isWebApiPopularWord() ? Constants.TRUE : Constants.FALSE;
form.csvFileEncoding = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
form.purgeSearchLogDay =
Integer.parseInt(crawlerProperties.getProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public ActionResponse hookBefore(final ActionRuntime runtime) { // application m
favoriteSupport = Constants.TRUE.equals(crawlerProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE));
runtime.registerData("searchLogSupport", searchLogSupport);
runtime.registerData("favoriteSupport", favoriteSupport);
runtime.registerData("popularWords", popularWordHelper.getWordList(null, null, null, null));// TODO parameters
if (fessConfig.isWebApiPopularWord()) {
runtime.registerData("popularWords", popularWordHelper.getWordList(null, null, null, null));// TODO parameters
}
return super.hookBefore(runtime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class FessCrawlerThread extends CrawlerThread {

@Override
protected boolean isContentUpdated(final CrawlerClient client, final UrlQueue<?> urlQueue) {
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();
if (crawlerProperties.getProperty(Constants.INCREMENTAL_CRAWLING_PROPERTY, Constants.TRUE).equals(Constants.TRUE)) {

log(logHelper, LogType.CHECK_LAST_MODIFIED, crawlerContext, urlQueue);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/codelibs/fess/exec/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private static int process(final Options options) {
}

final CrawlingInfoHelper crawlingInfoHelper = ComponentUtil.getCrawlingInfoHelper();
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();

if (StringUtil.isNotBlank(options.propertiesPath)) {
crawlerProperties.reload(options.propertiesPath);
Expand All @@ -219,7 +219,7 @@ private static int process(final Options options) {
crawlerProperties.reload(propFile.getAbsolutePath());
propFile.deleteOnExit(); // NOSONAR
} catch (final IOException e) {
logger.warn("Failed to create crawler properties file.", e);
logger.warn("Failed to create system properties file.", e);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/codelibs/fess/exec/SuggestCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,20 @@ public void run() {
}

private static int process(final Options options) {
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();

if (StringUtil.isNotBlank(options.propertiesPath)) {
crawlerProperties.reload(options.propertiesPath);
} else {
try {
final File propFile = File.createTempFile("crawler_", ".properties");
final File propFile = File.createTempFile("suggest_", ".properties");
if (propFile.delete() && logger.isDebugEnabled()) {
logger.debug("Deleted a temp file: " + propFile.getAbsolutePath());
}
crawlerProperties.reload(propFile.getAbsolutePath());
propFile.deleteOnExit(); // NOSONAR
} catch (final IOException e) {
logger.warn("Failed to create crawler properties file.", e);
logger.warn("Failed to create system properties file.", e);
}
}

Expand All @@ -140,7 +140,7 @@ private static int process(final Options options) {
}

private int create() {
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();
if (!Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SUGGEST_DOCUMENTS_PROPERTY, Constants.TRUE))) {
logger.info("Skip create suggest document.");
return 0;
Expand Down Expand Up @@ -171,7 +171,7 @@ private int create() {

private int purge(final LocalDateTime time) {
final SuggestHelper suggestHelper = ComponentUtil.getSuggestHelper();
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();

try {
suggestHelper.purgeDocumentSuggest(time);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codelibs/fess/job/CrawlJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ protected void executeCrawler() {
cmdList.add(propFile.getAbsolutePath());
try (FileOutputStream out = new FileOutputStream(propFile)) {
Properties prop = new Properties();
prop.putAll(ComponentUtil.getCrawlerProperties());
prop.putAll(ComponentUtil.getSystemProperties());
prop.store(out, cmdList.toString());
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codelibs/fess/job/PurgeLogJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String execute() {
final SearchLogService searchLogService = ComponentUtil.getComponent(SearchLogService.class);
final JobLogService jobLogService = ComponentUtil.getComponent(JobLogService.class);
final UserInfoService userInfoService = ComponentUtil.getComponent(UserInfoService.class);
final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties();
final DynamicProperties crawlerProperties = ComponentUtil.getSystemProperties();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();

final StringBuilder resultBuf = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codelibs/fess/job/SuggestJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected void executeSuggestCreator() {
cmdList.add(propFile.getAbsolutePath());
try (FileOutputStream out = new FileOutputStream(propFile)) {
Properties prop = new Properties();
prop.putAll(ComponentUtil.getCrawlerProperties());
prop.putAll(ComponentUtil.getSystemProperties());
prop.store(out, cmdList.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ public class FessLabels extends ActionMessages {
/** The key of the message: Properties for Bug Report */
public static final String LABELS_system_info_bug_report_title = "{labels.system_info_bug_report_title}";

/** The key of the message: crawler.properties does not exist. Default values are applied. */
public static final String LABELS_system_info_crawler_properties_does_not_exist =
"{labels.system_info_crawler_properties_does_not_exist}";
/** The key of the message: system.properties does not exist. Default values are applied. */
public static final String LABELS_system_info_system_properties_does_not_exist =
"{labels.system_info_system_properties_does_not_exist}";

/** The key of the message: File Authentication */
public static final String LABELS_file_auth_configuration = "{labels.file_auth_configuration}";
Expand Down
34 changes: 26 additions & 8 deletions src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,37 @@
import org.codelibs.fess.util.StreamUtil;

public interface FessProp {
public default String getProperty(final String key) {
return ComponentUtil.getCrawlerProperties().getProperty(key);

//
// system.properties
//

public default String getSystemProperty(final String key) {
return ComponentUtil.getSystemProperties().getProperty(key);
}

public default String getProperty(final String key, final String defaultValue) {
return ComponentUtil.getCrawlerProperties().getProperty(key, defaultValue);
return ComponentUtil.getSystemProperties().getProperty(key, defaultValue);
}

public default void setLoginRequired(final boolean value) {
ComponentUtil.getCrawlerProperties().setProperty(Constants.LOGIN_REQUIRED_PROPERTY, value ? Constants.TRUE : Constants.FALSE);
ComponentUtil.getSystemProperties().setProperty(Constants.LOGIN_REQUIRED_PROPERTY, value ? Constants.TRUE : Constants.FALSE);
}

public default boolean isLoginRequired() {
return Constants.TRUE.equalsIgnoreCase(ComponentUtil.getCrawlerProperties().getProperty(Constants.LOGIN_REQUIRED_PROPERTY,
return Constants.TRUE.equalsIgnoreCase(ComponentUtil.getSystemProperties().getProperty(Constants.LOGIN_REQUIRED_PROPERTY,
Constants.FALSE));
}

public default void setWebApiPopularWord(final boolean value) {
ComponentUtil.getSystemProperties().setProperty(Constants.WEB_API_POPULAR_WORD_PROPERTY, value ? Constants.TRUE : Constants.FALSE);
}

public default boolean isWebApiPopularWord() {
return Constants.TRUE.equalsIgnoreCase(ComponentUtil.getSystemProperties().getProperty(Constants.WEB_API_POPULAR_WORD_PROPERTY,
Constants.TRUE));
}

public default String getLdapInitialContextFactory() {
return getProperty(Constants.LDAP_INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
}
Expand All @@ -47,21 +61,25 @@ public default String getLdapSecurityAuthentication() {
}

public default String getLdapProviderUrl() {
return getProperty(Constants.LDAP_PROVIDER_URL);
return getSystemProperty(Constants.LDAP_PROVIDER_URL);
}

public default String getLdapSecurityPrincipal(final String username) {
return String.format(getProperty(Constants.LDAP_SECURITY_PRINCIPAL, StringUtil.EMPTY), username);
}

public default String getLdapBaseDn() {
return getProperty(Constants.LDAP_BASE_DN);
return getSystemProperty(Constants.LDAP_BASE_DN);
}

public default String getLdapAccountFilter() {
return getProperty(Constants.LDAP_ACCOUNT_FILTER);
return getSystemProperty(Constants.LDAP_ACCOUNT_FILTER);
}

//
// fess_*.properties
//

String getAuthenticationAdminRoles();

public default String[] getAuthenticationAdminRolesAsArray() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codelibs/fess/util/ComponentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static DynamicProperties getSolrGroupProperties(final String groupName) {
return SingletonLaContainer.getComponent(groupName + PROPERTIES_SUFFIX);
}

public static DynamicProperties getCrawlerProperties() {
public static DynamicProperties getSystemProperties() {
return SingletonLaContainer.getComponent(CRAWLER_PROPERTIES);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fess_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<components>
<component name="crawlerProperties" class="org.codelibs.core.misc.DynamicProperties">
<arg>
org.codelibs.fess.util.ResourceUtil.getConfPath("crawler.properties")
org.codelibs.fess.util.ResourceUtil.getConfPath("system.properties")
</arg>
</component>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fess_label.properties
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ labels.system_info_env_title=Env Properties
labels.system_info_prop_title=System Properties
labels.system_info_fess_prop_title=Fess Properties
labels.system_info_bug_report_title=Properties for Bug Report
labels.system_info_crawler_properties_does_not_exist=crawler.properties does not exist. Default values are applied.
labels.system_info_system_properties_does_not_exist=system.properties does not exist. Default values are applied.
labels.file_auth_configuration=File Authentication
labels.file_auth_list_hostname=Hostname
labels.file_auth_list_file_crawling_config=Config Name
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fess_label_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ labels.system_info_env_title=Env Properties
labels.system_info_prop_title=System Properties
labels.system_info_fess_prop_title=Fess Properties
labels.system_info_bug_report_title=Properties for Bug Report
labels.system_info_crawler_properties_does_not_exist=crawler.properties does not exist. Default values are applied.
labels.system_info_system_properties_does_not_exist=system.properties does not exist. Default values are applied.
labels.file_auth_configuration=File Authentication
labels.file_auth_list_hostname=Hostname
labels.file_auth_list_file_crawling_config=Config Name
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fess_label_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ labels.system_info_env_title = \u74b0\u5883\u5909\u6570\u306e\u30d7\u30ed\u30d1\
labels.system_info_prop_title = \u30b7\u30b9\u30c6\u30e0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3
labels.system_info_fess_prop_title = \u30a2\u30d7\u30ea\u306e\u30d7\u30ed\u30d1\u30c6\u30a3
labels.system_info_bug_report_title = \u30d0\u30b0\u30ec\u30dd\u30fc\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3
labels.system_info_crawler_properties_does_not_exist = crawler.properties\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002
labels.system_info_system_properties_does_not_exist = system.properties\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002
labels.file_auth_configuration = \u30d5\u30a1\u30a4\u30eb\u8a8d\u8a3c
labels.file_auth_list_hostname = \u30db\u30b9\u30c8\u540d
labels.file_auth_list_file_crawling_config = \u8a2d\u5b9a\u540d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<c:if test="${empty fessPropItems}">
<textarea id="fessPropData" class="systemInfoData form-control"
readonly><la:message
key="labels.system_info_crawler_properties_does_not_exist" /></textarea>
key="labels.system_info_system_properties_does_not_exist" /></textarea>
</c:if>
<c:if test="${!empty fessPropItems}">
<textarea id="fessPropData" class="systemInfoData form-control"
Expand Down

0 comments on commit 4c13056

Please sign in to comment.