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)));
}
Aggregations