fix #2265 add system properties

This commit is contained in:
Shinsuke Sugaya 2019-10-08 06:42:01 +09:00
parent 796c1f6999
commit 9cf0378587
14 changed files with 66 additions and 2 deletions

View file

@ -104,6 +104,8 @@ public class Constants extends CoreLibConstants {
public static final String WEB_DESIGN_EDITOR_PROPERTY = "design.editor";
public static final String APP_VALUE_PROPERTY = "system.properties";
public static final String DEFAULT_LABEL_VALUE_PROPERTY = "label.value";
public static final String DEFAULT_SORT_VALUE_PROPERTY = "sort.value";

View file

@ -29,6 +29,7 @@ import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.fess.Constants;
import org.codelibs.fess.app.web.base.FessAdminAction;
import org.codelibs.fess.helper.SystemHelper;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.codelibs.fess.mylasta.mail.TestmailPostcard;
import org.codelibs.fess.util.ComponentUtil;
@ -136,6 +137,7 @@ public class AdminGeneralAction extends FessAdminAction {
fessConfig.setUserInfo(isCheckboxEnabled(form.userInfo));
fessConfig.setUserFavorite(isCheckboxEnabled(form.userFavorite));
fessConfig.setWebApiJson(isCheckboxEnabled(form.webApiJson));
fessConfig.setAppValue(form.appValue);
fessConfig.setDefaultLabelValue(form.defaultLabelValue);
fessConfig.setDefaultSortValue(form.defaultSortValue);
fessConfig.setVirtualHostValue(form.virtualHostValue);
@ -167,10 +169,12 @@ public class AdminGeneralAction extends FessAdminAction {
fessConfig.storeSystemProperties();
ComponentUtil.getLdapManager().updateConfig();
ComponentUtil.getSystemHelper().refreshDesignJspFiles();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
systemHelper.refreshDesignJspFiles();
systemHelper.updateSystemProperties();
if (StringUtil.isNotBlank(form.logLevel)) {
ComponentUtil.getSystemHelper().setLogLevel(form.logLevel);
systemHelper.setLogLevel(form.logLevel);
}
}
@ -186,6 +190,7 @@ public class AdminGeneralAction extends FessAdminAction {
form.userInfo = fessConfig.isUserInfo() ? Constants.TRUE : Constants.FALSE;
form.userFavorite = fessConfig.isUserFavorite() ? Constants.TRUE : Constants.FALSE;
form.webApiJson = fessConfig.isWebApiJson() ? Constants.TRUE : Constants.FALSE;
form.appValue = fessConfig.getAppValue();
form.defaultLabelValue = fessConfig.getDefaultLabelValue();
form.defaultSortValue = fessConfig.getDefaultSortValue();
form.virtualHostValue = fessConfig.getVirtualHostValue();

View file

@ -55,6 +55,9 @@ public class EditForm {
@Size(max = 10)
public String webApiJson;
@Size(max = 10000)
public String appValue;
@Size(max = 1000)
public String defaultLabelValue;

View file

@ -61,6 +61,7 @@ import org.codelibs.fess.mylasta.action.FessUserBean;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.codelibs.fess.util.ComponentUtil;
import org.codelibs.fess.util.GsaConfigParser;
import org.codelibs.fess.util.ParameterUtil;
import org.codelibs.fess.util.ResourceUtil;
import org.codelibs.fess.validation.FessActionValidator;
import org.lastaflute.core.message.supplier.UserMessagesCreator;
@ -109,6 +110,7 @@ public class SystemHelper {
if (logger.isDebugEnabled()) {
logger.debug("Initialize " + this.getClass().getSimpleName());
}
updateSystemProperties();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
filterPathEncoding = fessConfig.getPathEncoding();
supportedLanguages = fessConfig.getSupportedLanguagesAsArray();
@ -433,6 +435,25 @@ public class SystemHelper {
ComponentUtil.getRelatedContentHelper().update();
ComponentUtil.getRelatedQueryHelper().update();
ComponentUtil.getKeyMatchHelper().update();
updateSystemProperties();
}
public void updateSystemProperties() {
final String value = ComponentUtil.getFessConfig().getAppValue();
if (StringUtil.isNotBlank(value)) {
ParameterUtil.parse(value).entrySet().stream().filter(e -> {
final String key = e.getKey();
if (StringUtil.isNotBlank(key)) {
return false;
}
if (key.startsWith("fess.")) {
return true;
}
return System.getProperty(key) == null;
}).forEach(e -> {
System.setProperty(e.getKey(), e.getValue());
});
}
}
public String updateConfiguration() {

View file

@ -1169,6 +1169,9 @@ public class FessLabels extends UserMessages {
/** The key of the message: JSON Response */
public static final String LABELS_web_api_json_enabled = "{labels.web_api_json_enabled}";
/** The key of the message: System Properties */
public static final String LABELS_app_value = "{labels.app_value}";
/** The key of the message: Default Label Value */
public static final String LABELS_default_label_value = "{labels.default_label_value}";

View file

@ -139,6 +139,8 @@ public interface FessProp {
String ROLE_VALUE_PREFIX = "role:";
String APP_VALUES = "appValues";
String DEFAULT_SORT_VALUES = "defaultSortValues";
String DEFAULT_LABEL_VALUES = "defaultLabelValues";
@ -312,6 +314,15 @@ public interface FessProp {
}).filter(StringUtil::isNotBlank).toArray(n -> new String[n]);
}
default void setAppValue(final String value) {
setSystemProperty(Constants.APP_VALUE_PROPERTY, value);
propMap.remove(APP_VALUES);
}
default String getAppValue() {
return getSystemProperty(Constants.APP_VALUE_PROPERTY, StringUtil.EMPTY);
}
default void setDefaultLabelValue(final String value) {
setSystemProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, value);
propMap.remove(DEFAULT_LABEL_VALUES);

View file

@ -381,6 +381,7 @@ labels.search_log_enabled=Search Logging
labels.user_info_enabled=User Logging
labels.user_favorite_enabled=Favorite Logging
labels.web_api_json_enabled=JSON Response
labels.app_value=System Properties
labels.default_label_value=Default Label Value
labels.default_sort_value=Default Sort Value
labels.virtual_host_value=Virtual Hosts

View file

@ -371,6 +371,7 @@ labels.search_log_enabled=Protokollierung Suche
labels.user_info_enabled=User Logging
labels.user_favorite_enabled=Favorite Logging
labels.web_api_json_enabled=JSON Response
labels.app_value=System Properties
labels.default_label_value=Default Label Value
labels.default_sort_value=Default Sort Value
labels.virtual_host_value=Virtual Hosts

View file

@ -381,6 +381,7 @@ labels.search_log_enabled=Search Logging
labels.user_info_enabled=User Logging
labels.user_favorite_enabled=Favorite Logging
labels.web_api_json_enabled=JSON Response
labels.app_value=System Properties
labels.default_label_value=Default Label Value
labels.default_sort_value=Default Sort Value
labels.virtual_host_value=Virtual Hosts

View file

@ -373,6 +373,7 @@ labels.search_log_enabled=検索ログ
labels.user_info_enabled=ユーザログ
labels.user_favorite_enabled=お気に入りログ
labels.web_api_json_enabled=JSONレスポンス
labels.app_value=システムプロパティ
labels.default_label_value=デフォルトのラベル値
labels.default_sort_value=デフォルトのソート値
labels.virtual_host_value=仮想ホスト

View file

@ -355,6 +355,7 @@ labels.search_log_enabled = 검색 로그
labels.user_info_enabled = 사용자 로그
labels.user_favorite_enabled = 즐겨찾기 로그
labels.web_api_json_enabled = JSON 응답
labels.app_value=System Properties
labels.default_label_value = 기본 레이블 값
labels.default_sort_value = 기본 정렬 값
labels.append_query_param_enabled = 검색 매개 변수 추가

View file

@ -358,6 +358,7 @@ labels.search_log_enabled=Search Logging
labels.user_info_enabled=User Logging
labels.user_favorite_enabled=Favorite Logging
labels.web_api_json_enabled=JSON Response
labels.app_value=System Properties
labels.default_label_value=Default Label Value
labels.default_sort_value=Default Sort Value
labels.append_query_param_enabled=Append Params to URL

View file

@ -93,6 +93,15 @@
</div>
</div>
</div>
<div class="form-group">
<label for="appValue" class="col-sm-3 control-label"><la:message
key="labels.app_value" /></label>
<div class="col-sm-9">
<la:errors property="appValue" />
<la:textarea styleId="appValue" property="appValue"
styleClass="form-control" />
</div>
</div>
<div class="form-group">
<label for="defaultLabelValue" class="col-sm-3 control-label"><la:message
key="labels.default_label_value" /></label>

View file

@ -30,6 +30,10 @@ public class SystemHelperTest extends UnitFessTestCase {
@Override
protected void parseProjectProperties() {
}
@Override
public void updateSystemProperties() {
}
};
systemHelper.init();
}