modify role search
This commit is contained in:
parent
6208d8603c
commit
3ee4c5a264
13 changed files with 63 additions and 10 deletions
|
@ -21,8 +21,10 @@ import javax.validation.constraints.Max;
|
|||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
|
@ -83,5 +85,9 @@ public class CreateForm implements Serializable {
|
|||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
roleTypeIds = StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ import javax.validation.constraints.Max;
|
|||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
|
@ -119,5 +121,9 @@ public class CreateForm implements Serializable {
|
|||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
roleTypeIds = StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ import javax.validation.constraints.Min;
|
|||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
|
@ -74,5 +76,9 @@ public class CreateForm implements Serializable {
|
|||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
roleTypeIds = StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,12 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
|
@ -128,5 +129,9 @@ public class CreateForm implements Serializable {
|
|||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
roleTypeIds = StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.codelibs.fess.helper.JobHelper;
|
|||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.job.TriggeredJob;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
|
@ -177,6 +178,10 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
wConfig.setUpdatedTime(now);
|
||||
wConfig.setUrls(configPath);
|
||||
wConfig.setUserAgent(getDefaultString("default.config.web.userAgent", ComponentUtil.getUserAgentName()));
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
wConfig.setRoleTypeIds(StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
webConfigService.store(wConfig);
|
||||
|
||||
|
@ -204,6 +209,10 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
fConfig.setUpdatedBy(username);
|
||||
fConfig.setUpdatedTime(now);
|
||||
fConfig.setPaths(configPath);
|
||||
String roles = ComponentUtil.getFessConfig().getSearchDefaultRoles();
|
||||
if (StringUtil.isNotBlank(roles)) {
|
||||
fConfig.setRoleTypeIds(StreamUtil.of(roles.split(",")).map(role -> role.trim()).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
fileConfigService.store(fConfig);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ public class QueryHelper implements Serializable {
|
|||
queryContext.addQuery(boolQuery -> {
|
||||
BoolQueryBuilder roleQuery = QueryBuilders.boolQuery();
|
||||
roleSet.stream().forEach(name -> {
|
||||
roleQuery.filter(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
|
||||
roleQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
|
||||
});
|
||||
boolQuery.filter(roleQuery);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.codelibs.fess.helper.impl;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -26,6 +27,7 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -34,7 +36,6 @@ import org.codelibs.core.lang.StringUtil;
|
|||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.web.base.login.FessLoginAssist;
|
||||
import org.codelibs.fess.helper.RoleQueryHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.StreamUtil;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
|
@ -75,9 +76,15 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable {
|
|||
|
||||
protected Map<String, String> cookieNameMap;
|
||||
|
||||
public List<String> defaultRoleList;
|
||||
private List<String> defaultRoleList = new ArrayList<>();
|
||||
|
||||
public SystemHelper systemHelper;
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
StreamUtil.of(ComponentUtil.getFessConfig().getSearchDefaultRoles().split(",")).filter(name -> StringUtil.isNotBlank(name))
|
||||
.forEach(name -> {
|
||||
defaultRoleList.add(name);
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.codelibs.fess.helper.impl.RoleQueryHelper#build()
|
||||
|
|
|
@ -623,7 +623,7 @@ public class FessLabels extends ActionMessages {
|
|||
/** The key of the message: Search */
|
||||
public static final String LABELS_SEARCH = "{labels.search}";
|
||||
|
||||
/** The key of the message: Results <b>{2}</b><span class="br-phone"></span><span class="hidden-phone"> -</span> <b>{3}</b> of <b>{1}</b> pages for <b>{0}</b> */
|
||||
/** The key of the message: Results <b>{2}</b><span class="br-phone"></span><span class="hidden-phone"> -</span> <b>{3}</b> of <b>{1}</b> for <b>{0}</b> */
|
||||
public static final String LABELS_search_result_status = "{labels.search_result_status}";
|
||||
|
||||
/** The key of the message: ({0} sec) */
|
||||
|
|
|
@ -118,6 +118,9 @@ public interface FessConfig extends FessEnv {
|
|||
/** The key of the configuration. e.g. admin */
|
||||
String AUTHENTICATION_ADMIN_ROLES = "authentication.admin.roles";
|
||||
|
||||
/** The key of the configuration. e.g. guest */
|
||||
String SEARCH_DEFAULT_ROLES = "search.default.roles";
|
||||
|
||||
/** The key of the configuration. e.g. / */
|
||||
String COOKIE_DEFAULT_PATH = "cookie.default.path";
|
||||
|
||||
|
@ -504,6 +507,13 @@ public interface FessConfig extends FessEnv {
|
|||
*/
|
||||
String getAuthenticationAdminRoles();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'search.default.roles'. <br>
|
||||
* The value is, e.g. guest <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getSearchDefaultRoles();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'cookie.default.path'. <br>
|
||||
* The value is, e.g. / <br>
|
||||
|
@ -1047,6 +1057,10 @@ public interface FessConfig extends FessEnv {
|
|||
return get(FessConfig.AUTHENTICATION_ADMIN_ROLES);
|
||||
}
|
||||
|
||||
public String getSearchDefaultRoles() {
|
||||
return get(FessConfig.SEARCH_DEFAULT_ROLES);
|
||||
}
|
||||
|
||||
public String getCookieDefaultPath() {
|
||||
return get(FessConfig.COOKIE_DEFAULT_PATH);
|
||||
}
|
||||
|
|
|
@ -130,9 +130,6 @@
|
|||
<property name="key">"1234567890123456"</property>
|
||||
</component>
|
||||
</property>
|
||||
<property name="defaultRoleList">
|
||||
{"guest"}
|
||||
</property>
|
||||
<property name="valueSeparator">"\\n"</property>
|
||||
<property name="roleSeparator">","</property>
|
||||
-->
|
||||
|
|
|
@ -56,6 +56,7 @@ index.document.type=doc
|
|||
# ------
|
||||
authentication.admin.roles=admin
|
||||
|
||||
search.default.roles=guest
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# Cookie
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
{"index":{"_index":".fess_config","_type":"role_type","_id":"guest"}}
|
||||
{"updatedTime":0,"updatedBy":"admin","createdBy":"admin","name":"Guest","createdTime":0,"value":"guest"}
|
|
@ -202,7 +202,7 @@ labels.menu_search_list=Search
|
|||
labels.sidebar.placeholder_search=Search...
|
||||
labels.footer.copyright=Copyright(C) 2009-2015 <a href="https://github.com/codelibs">CodeLibs Project</a>. <span class="br-phone"></span>All Rights Reserved.
|
||||
labels.search=Search
|
||||
labels.search_result_status=Results <b>{2}</b><span class="br-phone"></span><span class="hidden-phone"> -</span> <b>{3}</b> of <b>{1}</b> pages for <b>{0}</b>
|
||||
labels.search_result_status=Results <b>{2}</b><span class="br-phone"></span><span class="hidden-phone"> -</span> <b>{3}</b> of <b>{1}</b> for <b>{0}</b>
|
||||
labels.search_result_time=({0} sec)
|
||||
labels.prev_page=Prev
|
||||
labels.next_page=Next
|
||||
|
|
Loading…
Add table
Reference in a new issue