Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

use config value htroot in Jetty init (was hardcoded) - move htroot exist check from old httpdfilehandler to startup, remove from filehandler and legacy proxyhandler - use SwitchboardConstant.htroot where appropriate

reger3b89176b9ffa
diff --git a/source/net/yacy/data/Translator.java b/source/net/yacy/data/Translator.java
index 6ed1d7489..e1ed98829 100644
--- a/source/net/yacy/data/Translator.java
+++ b/source/net/yacy/data/Translator.java
@@ -49,6 +49,7 @@ import java.util.regex.Pattern;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.util.Formatter;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverSwitch;
import java.util.*;
@@ -243,7 +244,7 @@ public class Translator {
env.setConfig("locale.language", "default");
ret = true;
} else {
- final String htRootPath = env.getConfig("htRootPath", "htroot");
+ final String htRootPath = env.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT);
final File sourceDir = new File(env.getAppPath(), htRootPath);
final File destDir = new File(env.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), lang.substring(0, lang.length() - 4));// cut
// .lng
diff --git a/source/net/yacy/http/Jetty8HttpServerImpl.java b/source/net/yacy/http/Jetty8HttpServerImpl.java
index 47ebd07bf..085445fb7 100644
--- a/source/net/yacy/http/Jetty8HttpServerImpl.java
+++ b/source/net/yacy/http/Jetty8HttpServerImpl.java
@@ -105,11 +105,11 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {
domainHandler.setAlternativeResolver(sb.peers);
// configure root context
- // ServletContextHandler htrootContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
WebAppContext htrootContext = new WebAppContext();
htrootContext.setContextPath("/");
+ String htrootpath = sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT);
try {
- htrootContext.setBaseResource(Resource.newResource("htroot"));
+ htrootContext.setBaseResource(Resource.newResource(htrootpath));
// set web.xml to use
// make use of Jetty feature to define web.xml other as default WEB-INF/web.xml
@@ -131,7 +131,7 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {
// as fundamental component leave this hardcoded, other servlets may be defined in web.xml only
ServletHolder sholder = new ServletHolder(YaCyDefaultServlet.class);
- sholder.setInitParameter("resourceBase", "htroot");
+ sholder.setInitParameter("resourceBase", htrootpath);
//sholder.setInitParameter("welcomeFile", "index.html"); // default is index.html, welcome.html
htrootContext.addServlet(sholder,"/*");
diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
index deff7e73d..31c9bf391 100644
--- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java
+++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
@@ -160,7 +160,7 @@ public class YaCyDefaultServlet extends HttpServlet {
if (rb != null) {
_resourceBase = Resource.newResource(rb);
} else {
- _resourceBase = Resource.newResource(Switchboard.getSwitchboard().getConfig("htRootPath", "htroot")); //default
+ _resourceBase = Resource.newResource(Switchboard.getSwitchboard().getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT)); //default
}
} catch (IOException e) {
ConcurrentLog.severe("FILEHANDLER", "YaCyDefaultServlet: resource base (htRootPath) missing");
diff --git a/source/net/yacy/server/http/HTTPDFileHandler.java b/source/net/yacy/server/http/HTTPDFileHandler.java
index 8652f37d4..5658693a1 100644
--- a/source/net/yacy/server/http/HTTPDFileHandler.java
+++ b/source/net/yacy/server/http/HTTPDFileHandler.java
@@ -71,7 +71,6 @@ public final class HTTPDFileHandler {
// create a class loader
private static serverSwitch switchboard = null;
- private static File htRootPath = null;
public static File htDocsPath = null;
public static String[] defaultFiles = null;
private static File htDefaultPath = null;
@@ -105,12 +104,6 @@ public final class HTTPDFileHandler {
// create default files array
initDefaultPath();
- // create a htRootPath: system pages
- if (htRootPath == null) {
- htRootPath = new File(theSwitchboard.getAppPath(), theSwitchboard.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT));
- if (!(htRootPath.exists())) htRootPath.mkdir();
- }
-
// create a htDocsPath: user defined pages
if (htDocsPath == null) {
htDocsPath = theSwitchboard.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
@@ -122,7 +115,7 @@ public final class HTTPDFileHandler {
if (!repository.exists()) repository.mkdirs();
// create htLocaleDefault, htLocalePath
- if (htDefaultPath == null) htDefaultPath = theSwitchboard.getAppPath("htDefaultPath", "htroot");
+ if (htDefaultPath == null) htDefaultPath = theSwitchboard.getAppPath("htDefaultPath", SwitchboardConstants.HTROOT_PATH_DEFAULT);
if (htLocalePath == null) htLocalePath = theSwitchboard.getDataPath("locale.translated_html", "DATA/LOCALE/htroot");
}
}
diff --git a/source/net/yacy/server/http/HTTPDProxyHandler.java b/source/net/yacy/server/http/HTTPDProxyHandler.java
index 6ce08fdf7..4769706cd 100644
--- a/source/net/yacy/server/http/HTTPDProxyHandler.java
+++ b/source/net/yacy/server/http/HTTPDProxyHandler.java
@@ -106,7 +106,6 @@ public final class HTTPDProxyHandler {
private static BufferedReader redirectorReader = null;
private static Transformer transformer = null;
- private static File htRootPath = null;
//private Properties connectionProperties = null;
// creating a logger
@@ -124,13 +123,6 @@ public final class HTTPDProxyHandler {
// set timeout
timeout = Integer.parseInt(sb.getConfig("proxy.clientTimeout", "60000"));
- // create a htRootPath: system pages
- htRootPath = new File(sb.getAppPath(), sb.getConfig(SwitchboardConstants.HTROOT_PATH,SwitchboardConstants.HTROOT_PATH_DEFAULT));
- if (!(htRootPath.exists())) {
- if(!htRootPath.mkdir())
- ConcurrentLog.severe("PROXY", "could not create htRoot "+ htRootPath);
- }
-
// do logger initialization
try {
log.info("Configuring proxy access logging ...");
diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java
index ba6ce44a0..aec25f4a0 100644
--- a/source/net/yacy/server/http/HTTPDemon.java
+++ b/source/net/yacy/server/http/HTTPDemon.java
@@ -54,6 +54,7 @@ import net.yacy.cora.util.NumberTools;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.util.MemoryControl;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
@@ -371,7 +372,7 @@ public final class HTTPDemon {
tp.put("date", systemDate);
// rewrite the file
- final File htRootPath = new File(switchboard.getAppPath(), switchboard.getConfig("htRootPath","htroot"));
+ final File htRootPath = new File(switchboard.getAppPath(), switchboard.getConfig(SwitchboardConstants.HTROOT_PATH,SwitchboardConstants.HTROOT_PATH_DEFAULT));
TemplateEngine.writeTemplate(
fis = new FileInputStream(new File(htRootPath, "/proxymsg/error.html")),
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index b0b5135a6..cc0b40a80 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -229,7 +229,8 @@ public final class yacy {
yacyVersion.latestRelease = version;
// create some directories
- final File htRootPath = new File(appHome, sb.getConfig("htRootPath", "htroot"));
+ final File htRootPath = new File(appHome, sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT));
+ mkdirIfNeseccary(htRootPath);
final File htDocsPath = sb.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
mkdirIfNeseccary(htDocsPath);
//final File htTemplatePath = new File(homePath, sb.getConfig("htTemplatePath","htdocs"));
@@ -327,7 +328,7 @@ public final class yacy {
}
if (!currentRev.equals(sb.getConfig("svnRevision", ""))) try { //is this another version?!
- final File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));
+ final File sourceDir = new File(sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT));
final File destDir = new File(sb.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), lang);
if (Translator.translateFilesRecursive(sourceDir, destDir, new File(locale_source, lang + ".lng"), "html,template,inc", "locale")){ //translate it
//write the new Versionnumber