fix #1142 add virtual.host.value to system.properties
This commit is contained in:
parent
74e2928ff2
commit
7b7d031910
12 changed files with 46 additions and 5 deletions
|
@ -111,6 +111,8 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final String DEFAULT_SORT_VALUE_PROPERTY = "sort.value";
|
||||
|
||||
public static final String VIRTUAL_HOST_VALUE_PROPERTY = "virtual.host.value";
|
||||
|
||||
public static final String LOGIN_REQUIRED_PROPERTY = "login.required";
|
||||
|
||||
public static final String RESULT_COLLAPSED_PROPERTY = "result.collapsed";
|
||||
|
|
|
@ -138,6 +138,7 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
fessConfig.setWebApiJson(Constants.ON.equalsIgnoreCase(form.webApiJson));
|
||||
fessConfig.setDefaultLabelValue(form.defaultLabelValue);
|
||||
fessConfig.setDefaultSortValue(form.defaultSortValue);
|
||||
fessConfig.setVirtualHostValue(form.virtualHostValue);
|
||||
fessConfig.setAppendQueryParameter(Constants.ON.equalsIgnoreCase(form.appendQueryParameter));
|
||||
fessConfig.setIgnoreFailureType(form.ignoreFailureType);
|
||||
fessConfig.setFailureCountThreshold(form.failureCountThreshold);
|
||||
|
@ -181,6 +182,7 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
form.webApiJson = fessConfig.isWebApiJson() ? Constants.TRUE : Constants.FALSE;
|
||||
form.defaultLabelValue = fessConfig.getDefaultLabelValue();
|
||||
form.defaultSortValue = fessConfig.getDefaultSortValue();
|
||||
form.virtualHostValue = fessConfig.getVirtualHostValue();
|
||||
form.appendQueryParameter = fessConfig.isAppendQueryParameter() ? Constants.TRUE : Constants.FALSE;
|
||||
form.ignoreFailureType = fessConfig.getIgnoreFailureType();
|
||||
form.failureCountThreshold = fessConfig.getFailureCountThreshold();
|
||||
|
|
|
@ -61,6 +61,9 @@ public class EditForm {
|
|||
@Size(max = 1000)
|
||||
public String defaultSortValue;
|
||||
|
||||
@Size(max = 10000)
|
||||
public String virtualHostValue;
|
||||
|
||||
@Size(max = 10)
|
||||
public String appendQueryParameter;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public class KeyMatchHelper {
|
|||
}
|
||||
|
||||
protected Map<String, Pair<QueryBuilder, ScoreFunctionBuilder<?>>> getQueryMap() {
|
||||
final String key = ComponentUtil.getFessConfig().getVirtualHostValue();
|
||||
final String key = ComponentUtil.getFessConfig().getVirtualHostKey();
|
||||
final Map<String, Pair<QueryBuilder, ScoreFunctionBuilder<?>>> map = keyMatchQueryMap.get(key);
|
||||
if (map != null) {
|
||||
return map;
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RelatedContentHelper {
|
|||
|
||||
public String getRelatedContent(final String query) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String key = fessConfig.getVirtualHostValue();
|
||||
final String key = fessConfig.getVirtualHostKey();
|
||||
Map<String, String> map = relatedContentMap.get(key);
|
||||
if (map != null) {
|
||||
final String content = map.get(toLowerCase(query));
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RelatedQueryHelper {
|
|||
|
||||
public String[] getRelatedQueries(final String query) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String key = fessConfig.getVirtualHostValue();
|
||||
final String key = fessConfig.getVirtualHostKey();
|
||||
Map<String, String[]> map = relatedQueryMap.get(key);
|
||||
if (map != null) {
|
||||
final String[] queries = map.get(toLowerCase(query));
|
||||
|
|
|
@ -1139,6 +1139,9 @@ public class FessLabels extends UserMessages {
|
|||
/** The key of the message: Default Sort Value */
|
||||
public static final String LABELS_default_sort_value = "{labels.default_sort_value}";
|
||||
|
||||
/** The key of the message: Virtual Hosts */
|
||||
public static final String LABELS_virtual_host_value = "{labels.virtual_host_value}";
|
||||
|
||||
/** The key of the message: Append Params to URL */
|
||||
public static final String LABELS_append_query_param_enabled = "{labels.append_query_param_enabled}";
|
||||
|
||||
|
|
|
@ -117,6 +117,8 @@ public interface FessProp {
|
|||
|
||||
public static final String DEFAULT_LABEL_VALUES = "defaultLabelValues";
|
||||
|
||||
public static final String VIRTUAL_HOST_VALUES = "virtualHostValues";
|
||||
|
||||
public static final String QUERY_LANGUAGE_MAPPING = "queryLanguageMapping";
|
||||
|
||||
public static final String CRAWLER_METADATA_NAME_MAPPING = "crawlerMetadataNameMapping";
|
||||
|
@ -284,6 +286,15 @@ public interface FessProp {
|
|||
return getSystemProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, StringUtil.EMPTY);
|
||||
}
|
||||
|
||||
public default void setVirtualHostValue(final String value) {
|
||||
setSystemProperty(Constants.VIRTUAL_HOST_VALUE_PROPERTY, value);
|
||||
propMap.remove(VIRTUAL_HOST_HEADERS);
|
||||
}
|
||||
|
||||
public default String getVirtualHostValue() {
|
||||
return getSystemProperty(Constants.VIRTUAL_HOST_VALUE_PROPERTY, getVirtualHostHeaders());
|
||||
}
|
||||
|
||||
public default void setLoginRequired(final boolean value) {
|
||||
setSystemPropertyAsBoolean(Constants.LOGIN_REQUIRED_PROPERTY, value);
|
||||
}
|
||||
|
@ -1588,7 +1599,7 @@ public interface FessProp {
|
|||
return processVirtualHost(s -> new HtmlNext(s + page.getRoutingPath()), page);
|
||||
}
|
||||
|
||||
public default String getVirtualHostValue() {
|
||||
public default String getVirtualHostKey() {
|
||||
return LaRequestUtil.getOptionalRequest().map(req -> (String) req.getAttribute(VIRTUAL_HOST_VALUE)).orElseGet(() -> {
|
||||
final String value = processVirtualHost(s -> s, StringUtil.EMPTY);
|
||||
LaRequestUtil.getOptionalRequest().ifPresent(req -> req.setAttribute(VIRTUAL_HOST_VALUE, value));
|
||||
|
@ -1596,11 +1607,19 @@ public interface FessProp {
|
|||
});
|
||||
}
|
||||
|
||||
public default String getVirtualHostHeaderValue() {
|
||||
final String value = getVirtualHostValue();
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
return getVirtualHostHeaders();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public default <T> T processVirtualHost(final Function<String, T> func, final T defaultValue) {
|
||||
Tuple3<String, String, String>[] hosts = (Tuple3<String, String, String>[]) propMap.get(VIRTUAL_HOST_HEADERS);
|
||||
if (hosts == null) {
|
||||
hosts = split(getVirtualHostHeaders(), "\n").get(stream -> stream.map(s -> {
|
||||
hosts = split(getVirtualHostHeaderValue(), "\n").get(stream -> stream.map(s -> {
|
||||
final String[] v1 = s.split("=");
|
||||
if (v1.length == 2) {
|
||||
final String[] v2 = v1[0].split(":");
|
||||
|
|
|
@ -370,6 +370,7 @@ labels.user_favorite_enabled=Favorite Logging
|
|||
labels.web_api_json_enabled=JSON Response
|
||||
labels.default_label_value=Default Label Value
|
||||
labels.default_sort_value=Default Sort Value
|
||||
labels.virtual_host_value=Virtual Hosts
|
||||
labels.append_query_param_enabled=Append Params to URL
|
||||
labels.login_required=Login Required
|
||||
labels.result_collapsed=Similar Result Collapsed
|
||||
|
|
|
@ -370,6 +370,7 @@ labels.user_favorite_enabled=Favorite Logging
|
|||
labels.web_api_json_enabled=JSON Response
|
||||
labels.default_label_value=Default Label Value
|
||||
labels.default_sort_value=Default Sort Value
|
||||
labels.virtual_host_value=Virtual Hosts
|
||||
labels.append_query_param_enabled=Append Params to URL
|
||||
labels.login_required=Login Required
|
||||
labels.result_collapsed=Similar Result Collapsed
|
||||
|
|
|
@ -363,6 +363,7 @@ labels.user_favorite_enabled=\u304a\u6c17\u306b\u5165\u308a\u30ed\u30b0
|
|||
labels.web_api_json_enabled=JSON\u30ec\u30b9\u30dd\u30f3\u30b9
|
||||
labels.default_label_value=\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30e9\u30d9\u30eb\u5024
|
||||
labels.default_sort_value=\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30bd\u30fc\u30c8\u5024
|
||||
labels.virtual_host_value=\u4eee\u60f3\u30db\u30b9\u30c8
|
||||
labels.append_query_param_enabled=\u691c\u7d22\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8ffd\u52a0
|
||||
labels.login_required=\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981
|
||||
labels.result_collapsed=\u91cd\u8907\u7d50\u679c\u306e\u6298\u308a\u7573\u307f
|
||||
|
|
|
@ -111,6 +111,15 @@
|
|||
styleClass="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="virtualHostValue" class="col-sm-3 control-label"><la:message
|
||||
key="labels.virtual_host_value" /></label>
|
||||
<div class="col-sm-9">
|
||||
<la:errors property="virtualHostValue" />
|
||||
<la:textarea styleId="virtualHostValue" property="virtualHostValue"
|
||||
styleClass="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="popularWord" class="col-sm-3 control-label"><la:message
|
||||
key="labels.popular_word_word_enabled" /></label>
|
||||
|
|
Loading…
Add table
Reference in a new issue