Search in sources :

Example 1 with OptionalThing

use of org.dbflute.optional.OptionalThing in project fess by codelibs.

the class FessProp method processSearchPreference.

public default default void processSearchPreference(final SearchRequestBuilder searchRequestBuilder, final OptionalThing<FessUserBean> userBean) {
    userBean.map(user -> {
        if (user.hasRoles(getAuthenticationAdminRolesAsArray())) {
            return Constants.SEARCH_PREFERENCE_PRIMARY;
        }
        return user.getUserId();
    }).ifPresent(p -> searchRequestBuilder.setPreference(p)).orElse(() -> LaRequestUtil.getOptionalRequest().map(r -> {
        final HttpSession session = r.getSession(false);
        if (session != null) {
            return session.getId();
        }
        final String preference = r.getParameter("preference");
        if (preference != null) {
            return Integer.toString(preference.hashCode());
        }
        return null;
    }).ifPresent(p -> searchRequestBuilder.setPreference(p)));
}
Also used : ClassNotFoundRuntimeException(org.codelibs.core.exception.ClassNotFoundRuntimeException) Constants(org.codelibs.fess.Constants) SortBuilders(org.elasticsearch.search.sort.SortBuilders) Enumeration(java.util.Enumeration) Date(java.util.Date) JobConcurrentExec(org.lastaflute.job.subsidiary.JobConcurrentExec) OptionalThing(org.dbflute.optional.OptionalThing) Pair(org.codelibs.core.misc.Pair) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) IntegerTypeValidator(org.lastaflute.web.validation.theme.typed.IntegerTypeValidator) LaRequestUtil(org.lastaflute.web.util.LaRequestUtil) LongTypeValidator(org.lastaflute.web.validation.theme.typed.LongTypeValidator) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BasicAttribute(javax.naming.directory.BasicAttribute) FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) Attribute(javax.naming.directory.Attribute) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Locale(java.util.Locale) Map(java.util.Map) PrunedTag(org.codelibs.fess.util.PrunedTag) HtmlNext(org.lastaflute.web.response.next.HtmlNext) SortBuilder(org.elasticsearch.search.sort.SortBuilder) HttpSession(javax.servlet.http.HttpSession) LaJob(org.lastaflute.job.LaJob) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) FloatTypeValidator(org.lastaflute.web.validation.theme.typed.FloatTypeValidator) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StringUtil(org.codelibs.core.lang.StringUtil) Set(java.util.Set) RequiredValidator(org.lastaflute.web.validation.RequiredValidator) Tuple3(org.codelibs.core.misc.Tuple3) Collectors(java.util.stream.Collectors) List(java.util.List) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SortOrder(org.elasticsearch.search.sort.SortOrder) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) DoubleTypeValidator(org.lastaflute.web.validation.theme.typed.DoubleTypeValidator) FessFunctions(org.codelibs.fess.taglib.FessFunctions) HttpSession(javax.servlet.http.HttpSession)

Aggregations

ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Date (java.util.Date)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Attribute (javax.naming.directory.Attribute)1 BasicAttribute (javax.naming.directory.BasicAttribute)1 HttpSession (javax.servlet.http.HttpSession)1 ClassNotFoundRuntimeException (org.codelibs.core.exception.ClassNotFoundRuntimeException)1 StringUtil (org.codelibs.core.lang.StringUtil)1 Pair (org.codelibs.core.misc.Pair)1 Tuple3 (org.codelibs.core.misc.Tuple3)1 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)1