use of org.codelibs.core.misc.Tuple3 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);
}
Aggregations