return;
}
// Try to resolve node from URI (without context path).
String nodePath = uri.substring(request.getContextPath().length());
Node node = Nodes.getByPath(nodePath);
// Process redirect rules
if (node == null && !servlets.matcher(nodePath).matches()) {
String sourceURI = buildURI(nodePath, request.getQueryString());
String targetURI = rewriteURI(sourceURI);
if (!targetURI.equals(sourceURI)) {
if (targetURI.contains("://")) {
response.sendRedirect(response.encodeRedirectURL(targetURI));
} else {
response.sendRedirect(response.encodeRedirectURL(request
.getContextPath() + targetURI));
}
return;
}
}
// Save "virtual" root node. Per default it is the absolute root of the
// instance.
// If a node with the server name exists, this node is used as virtual
// root.
if (request.getAttribute("Root") == null) {
String server = Servlets.getServerName(request).replaceFirst(
"www.", "");
Node root = Nodes.getRoot() != null ? Nodes.getRoot().getChild(
server) : null;
if (root == null) {
root = Nodes.getRoot();
}
request.setAttribute("Root", root);
if (node != null && root.getParent() == node) {
response.sendRedirect(response.encodeRedirectURL(request
.getContextPath() + root.getPath()));
return;
}
}
// If no node is found, process filter chain.