From e17624b6dd6dc6fe00c9e0a10045c570351d5f04 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Mon, 23 Dec 2013 02:06:33 +0100 Subject: [PATCH] added html retrieval from alternative DATA/HTDOCS path --- .../net/yacy/http/servlets/YaCyDefaultServlet.java | 13 ++++++++++--- source/net/yacy/server/http/HTTPDFileHandler.java | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java index 0ed057736..fd7172ad3 100644 --- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java +++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java @@ -59,6 +59,7 @@ import net.yacy.peers.graphics.EncodedImage; import net.yacy.peers.operation.yacyBuildProperties; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; +import net.yacy.server.http.HTTPDFileHandler; import net.yacy.server.http.HTTPDemon; import net.yacy.server.http.TemplateEngine; import net.yacy.server.serverClassLoader; @@ -251,8 +252,6 @@ public class YaCyDefaultServlet extends HttpServlet { Resource resource = null; try { - // find resource - resource = getResource(pathInContext); // Look for a class resource boolean hasClass = false; @@ -267,11 +266,19 @@ public class YaCyDefaultServlet extends HttpServlet { } } } + + // find resource + resource = getResource(pathInContext); + if (!hasClass && (resource == null || !resource.exists()) && !pathInContext.contains("..")) { + // try to get this in the alternative htDocsPath + resource = Resource.newResource(new File(HTTPDFileHandler.htDocsPath, pathInContext)); + } + if (ConcurrentLog.isFine("FILEHANDLER")) { ConcurrentLog.fine("FILEHANDLER","YaCyDefaultServlet: uri=" + request.getRequestURI() + " resource=" + resource); } - + // Handle resource if (!hasClass && (resource == null || !resource.exists())) { if (included) { diff --git a/source/net/yacy/server/http/HTTPDFileHandler.java b/source/net/yacy/server/http/HTTPDFileHandler.java index 233a1916d..2241ec56a 100644 --- a/source/net/yacy/server/http/HTTPDFileHandler.java +++ b/source/net/yacy/server/http/HTTPDFileHandler.java @@ -72,7 +72,7 @@ public final class HTTPDFileHandler { private static serverSwitch switchboard = null; private static File htRootPath = null; - private static File htDocsPath = null; + public static File htDocsPath = null; private static String[] defaultFiles = null; private static File htDefaultPath = null; private static File htLocalePath = null;