Search in sources :

Example 1 with HtmlNext

use of org.lastaflute.web.response.next.HtmlNext in project fess by codelibs.

the class FessProp method getVirtualHostPath.

@SuppressWarnings("unchecked")
public default default HtmlNext getVirtualHostPath(final HtmlNext page) {
    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 -> {
            final String[] v1 = s.split("=");
            if (v1.length == 2) {
                final String[] v2 = v1[0].split(":");
                if (v2.length == 2) {
                    return new Tuple3<String, String, String>(v2[0].trim(), v2[0].trim(), "/" + v1[1].trim());
                }
            }
            return null;
        }).filter(v -> v != null).toArray(n -> new Tuple3[n]));
        propMap.put(VIRTUAL_HOST_HEADERS, hosts);
    }
    final Tuple3<String, String, String>[] vHosts = hosts;
    return LaRequestUtil.getOptionalRequest().map(req -> {
        for (Tuple3<String, String, String> host : vHosts) {
            final String headerValue = req.getHeader(host.getValue1());
            if (host.getValue2().equalsIgnoreCase(headerValue)) {
                return new HtmlNext(host.getValue3() + page.getRoutingPath());
            }
        }
        return page;
    }).orElse(page);
}
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) HtmlNext(org.lastaflute.web.response.next.HtmlNext) Tuple3(org.codelibs.core.misc.Tuple3)

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