fix #2660 add osdd.link.enabled

This commit is contained in:
Shinsuke Sugaya 2022-06-03 21:22:07 +09:00
parent 77420167bc
commit 1c867e8596
6 changed files with 46 additions and 15 deletions

View file

@ -34,7 +34,7 @@ import org.codelibs.fess.Constants;
import org.codelibs.fess.app.web.sso.SsoAction;
import org.codelibs.fess.entity.SearchRequestParams.SearchRequestType;
import org.codelibs.fess.helper.LabelTypeHelper;
import org.codelibs.fess.helper.OpenSearchHelper;
import org.codelibs.fess.helper.OsddHelper;
import org.codelibs.fess.helper.PopularWordHelper;
import org.codelibs.fess.helper.QueryHelper;
import org.codelibs.fess.helper.RoleQueryHelper;
@ -77,7 +77,7 @@ public abstract class FessSearchAction extends FessBaseAction {
protected UserInfoHelper userInfoHelper;
@Resource
protected OpenSearchHelper openSearchHelper;
protected OsddHelper osddHelper;
@Resource
protected PopularWordHelper popularWordHelper;
@ -121,7 +121,7 @@ public abstract class FessSearchAction extends FessBaseAction {
super.setupHtmlData(runtime);
systemHelper.setupSearchHtmlData(this, runtime);
runtime.registerData("osddLink", openSearchHelper.hasOpenSearchFile());
runtime.registerData("osddLink", osddHelper.hasOpenSearchFile());
final List<Map<String, String>> labelTypeItems = labelTypeHelper.getLabelTypeItemList(SearchRequestType.SEARCH,
request.getLocale() == null ? Locale.ROOT : request.getLocale());

View file

@ -42,7 +42,7 @@ public class OsddAction extends FessSearchAction {
if (isLoginRequired()) {
return redirectToLogin();
}
return openSearchHelper.asStream();
return osddHelper.asStream();
}
}
}

View file

@ -35,8 +35,8 @@ import org.lastaflute.web.util.LaServletContextUtil;
* @author shinsuke
*
*/
public class OpenSearchHelper {
private static final Logger logger = LogManager.getLogger(OpenSearchHelper.class);
public class OsddHelper {
private static final Logger logger = LogManager.getLogger(OsddHelper.class);
protected String osddPath;
@ -51,15 +51,19 @@ public class OpenSearchHelper {
if (logger.isDebugEnabled()) {
logger.debug("Initialize {}", this.getClass().getSimpleName());
}
if (StringUtil.isNotBlank(osddPath)) {
final String path = LaServletContextUtil.getServletContext().getRealPath(osddPath);
osddFile = new File(path);
if (!osddFile.isFile()) {
osddFile = null;
logger.warn("{} was not found.", path);
if (Constants.TRUE.equalsIgnoreCase(ComponentUtil.getFessConfig().getOsddLinkEnabled())) {
if (StringUtil.isNotBlank(osddPath)) {
final String path = LaServletContextUtil.getServletContext().getRealPath(osddPath);
osddFile = new File(path);
if (!osddFile.isFile()) {
osddFile = null;
logger.warn("{} was not found.", path);
}
} else {
logger.info("OSDD file is not found.");
}
} else {
logger.info("OSDD file is not found.");
logger.debug("OSDD is disabled.");
}
}

View file

@ -1112,6 +1112,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. __TEMPLATE__ */
String FORM_ADMIN_DEFAULT_TEMPLATE_NAME = "form.admin.default.template.name";
/** The key of the configuration. e.g. true */
String OSDD_LINK_ENABLED = "osdd.link.enabled";
/** The key of the configuration. e.g. admin */
String AUTHENTICATION_ADMIN_USERS = "authentication.admin.users";
@ -5139,6 +5142,20 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
String getFormAdminDefaultTemplateName();
/**
* Get the value for the key 'osdd.link.enabled'. <br>
* The value is, e.g. true <br>
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
String getOsddLinkEnabled();
/**
* Is the property for the key 'osdd.link.enabled' true? <br>
* The value is, e.g. true <br>
* @return The determination, true or false. (if not found, exception but basically no way)
*/
boolean isOsddLinkEnabled();
/**
* Get the value for the key 'authentication.admin.users'. <br>
* The value is, e.g. admin <br>
@ -8996,6 +9013,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return get(FessConfig.FORM_ADMIN_DEFAULT_TEMPLATE_NAME);
}
public String getOsddLinkEnabled() {
return get(FessConfig.OSDD_LINK_ENABLED);
}
public boolean isOsddLinkEnabled() {
return is(FessConfig.OSDD_LINK_ENABLED);
}
public String getAuthenticationAdminUsers() {
return get(FessConfig.AUTHENTICATION_ADMIN_USERS);
}
@ -10463,6 +10488,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
defaultMap.put(FessConfig.FORM_ADMIN_MAX_INPUT_SIZE, "4000");
defaultMap.put(FessConfig.FORM_ADMIN_LABEL_IN_CONFIG_ENABLED, "false");
defaultMap.put(FessConfig.FORM_ADMIN_DEFAULT_TEMPLATE_NAME, "__TEMPLATE__");
defaultMap.put(FessConfig.OSDD_LINK_ENABLED, "true");
defaultMap.put(FessConfig.AUTHENTICATION_ADMIN_USERS, "admin");
defaultMap.put(FessConfig.AUTHENTICATION_ADMIN_ROLES, "admin");
defaultMap.put(FessConfig.ROLE_SEARCH_DEFAULT_PERMISSIONS, "");

View file

@ -102,7 +102,7 @@
</arg>
</postConstruct>
</component>
<component name="openSearchHelper" class="org.codelibs.fess.helper.OpenSearchHelper">
<component name="osddHelper" class="org.codelibs.fess.helper.OsddHelper">
<property name="osddPath">"/WEB-INF/orig/open-search/osdd.xml"</property>
<property name="encoding">"UTF-8"</property>
</component>

View file

@ -602,6 +602,7 @@ logging.app.packages=org.codelibs,org.dbflute,org.lastaflute
form.admin.max.input.size=4000
form.admin.label.in.config.enabled=false
form.admin.default.template.name=__TEMPLATE__
osdd.link.enabled=true
# ----------------------------------------------------------
# Permission