Skip to content

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

change in handling of the all-visible home path for storage in YaCy: the home path can now be distinguished between - data home; the path where the DATA directory is created - application home; everything else This will make it possible to store application data on Mac releases within the ~/Library/YaCy directory; a place where Mac applications write their data. Similar techniques will be possible for debian and windows. To use the new data path, YaCy can be started with -start <data path> or -gui <data path>

orbiter9d080f387ec6
diff --git a/addon/YaCy.app/Contents/Info.plist b/addon/YaCy.app/Contents/Info.plist
index d2f6bf9ed..27822f575 100644
--- a/addon/YaCy.app/Contents/Info.plist
+++ b/addon/YaCy.app/Contents/Info.plist
@@ -31,7 +31,7 @@
<key>JVMVersion</key>
<string>1.5+</string>
<key>Arguments</key>
- <string>-gui</string>
+ <string>-gui Library/YaCy</string>
<key>ClassPath</key>
<array>
<string>$JAVAROOT/lib/bcmail-jdk15-145.jar</string>
diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.java
index a9116ea16..57cb98e58 100644
--- a/htroot/BlacklistCleaner_p.java
+++ b/htroot/BlacklistCleaner_p.java
@@ -73,7 +73,7 @@ public class BlacklistCleaner_p {
// initialize the list manager
listManager.switchboard = (Switchboard) env;
- listManager.listsPath = new File(env.getRootPath(), env.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(env.getDataPath(), env.getConfig("listManager.listsPath", "DATA/LISTS"));
String blacklistToUse = null;
// get the list of supported blacklist types
diff --git a/htroot/BlacklistImpExp_p.java b/htroot/BlacklistImpExp_p.java
index da1a20e81..9ba6dbf26 100644
--- a/htroot/BlacklistImpExp_p.java
+++ b/htroot/BlacklistImpExp_p.java
@@ -51,7 +51,7 @@ public class BlacklistImpExp_p {
// initialize the list manager
listManager.switchboard = (Switchboard) env;
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
// loading all blacklist files located in the directory
final List<String> dirlist = FileUtils.getDirListing(listManager.listsPath);
diff --git a/htroot/BlacklistTest_p.java b/htroot/BlacklistTest_p.java
index 1d93eb15f..52707df26 100644
--- a/htroot/BlacklistTest_p.java
+++ b/htroot/BlacklistTest_p.java
@@ -47,7 +47,7 @@ public class BlacklistTest_p {
// initialize the list manager
listManager.switchboard = (Switchboard) env;
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
final serverObjects prop = new serverObjects();
prop.putHTML("blacklistEngine", Switchboard.urlBlacklist.getEngineInfo());
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index 3299dd0a5..96667fa85 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -64,7 +64,7 @@ public class Blacklist_p {
// initialize the list manager
listManager.switchboard = (Switchboard) env;
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
// get the list of supported blacklist types
final String supportedBlacklistTypesStr = Blacklist.BLACKLIST_TYPES_STRING;
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index 06518af7d..486b78d63 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -172,8 +172,8 @@ public class BlogComments {
messageForwardingViaEmail(sb, msgEntry);
// finally write notification
- final File notifierSource = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
- final File notifierDest = new File(sb.getConfigPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
+ final File notifierSource = new File(sb.getAppPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
+ final File notifierDest = new File(sb.getDataPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
try {
FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
diff --git a/htroot/ConfigAppearance_p.java b/htroot/ConfigAppearance_p.java
index 6c4433bc1..5e7c2b88e 100644
--- a/htroot/ConfigAppearance_p.java
+++ b/htroot/ConfigAppearance_p.java
@@ -54,7 +54,7 @@ public class ConfigAppearance_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env;
- final String skinPath = new File(env.getRootPath(), env.getConfig("skinPath", "DATA/SKINS")).toString();
+ final String skinPath = new File(env.getDataPath(), env.getConfig("skinPath", "DATA/SKINS")).toString();
// Fallback
prop.put("currentskin", "");
@@ -140,7 +140,7 @@ public class ConfigAppearance_p {
}
private static boolean changeSkin(final Switchboard sb, final String skinPath, final String skin) {
- final File htdocsDir = new File(sb.getConfigPath("htDocsPath", "DATA/HTDOCS"), "env");
+ final File htdocsDir = new File(sb.getDataPath("htDocsPath", "DATA/HTDOCS"), "env");
final File styleFile = new File(htdocsDir, "style.css");
final File skinFile = new File(skinPath, skin);
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index 7fc8f2e6e..34e42a1b5 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -61,7 +61,7 @@ public class ConfigBasic {
// return variable that accumulates replacements
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
- final String langPath = env.getConfigPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();
+ final String langPath = env.getDataPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();
String lang = env.getConfig("locale.language", "default");
final int authentication = sb.adminAuthenticated(header);
@@ -179,7 +179,7 @@ public class ConfigBasic {
}
if (post.get("usecase", "").equals("intranet")) {
String repositoryPath = post.get("repositoryPath", "/DATA/HTROOT/repository");
- File repository = ((repositoryPath.length() > 0 && repositoryPath.charAt(0) == '/') || (repositoryPath.length() > 1 && repositoryPath.charAt(1) == ':')) ? new File(repositoryPath) : new File(sb.getRootPath(), repositoryPath);
+ File repository = ((repositoryPath.length() > 0 && repositoryPath.charAt(0) == '/') || (repositoryPath.length() > 1 && repositoryPath.charAt(1) == ':')) ? new File(repositoryPath) : new File(sb.getDataPath(), repositoryPath);
if (repository.exists() && repository.isDirectory()) {
sb.setConfig("repositoryPath", repositoryPath);
}
diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.java
index f92cc509f..c26d9eed4 100644
--- a/htroot/ConfigLanguage_p.java
+++ b/htroot/ConfigLanguage_p.java
@@ -58,7 +58,7 @@ public class ConfigLanguage_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
- final String langPath = env.getConfigPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();
+ final String langPath = env.getDataPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();
//Fallback
//prop.put("currentlang", ""); //is done by Translationtemplate
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index 6e1e14d63..3a1757591 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -49,7 +49,7 @@ public class ConfigNetwork_p {
int commit = 0;
// load all options for network definitions
- final File networkBootstrapLocationsFile = new File(new File(sb.getRootPath(), "defaults"), "yacy.networks");
+ final File networkBootstrapLocationsFile = new File(new File(sb.getAppPath(), "defaults"), "yacy.networks");
final HashSet<String> networkBootstrapLocations = FileUtils.loadList(networkBootstrapLocationsFile);
diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.java
index 9925eea48..91d2f2646 100644
--- a/htroot/ConfigUpdate_p.java
+++ b/htroot/ConfigUpdate_p.java
@@ -125,7 +125,7 @@ public class ConfigUpdate_p {
sb.getLog().logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.getUrl());
final File downloaded = updateVersion.downloadRelease();
prop.putHTML("candeploy_autoUpdate_downloadedRelease", updateVersion.getName());
- final boolean devenvironment = new File(sb.getRootPath(), ".svn").exists();
+ final boolean devenvironment = new File(sb.getAppPath(), ".svn").exists();
if (devenvironment) {
sb.getLog().logInfo("AUTO-UPDATE: omiting update because this is a development environment");
prop.put("candeploy_autoUpdate", "3");
@@ -154,7 +154,7 @@ public class ConfigUpdate_p {
// version information
final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision();
prop.putHTML("candeploy_versionpp", versionstring);
- final boolean devenvironment = new File(sb.getRootPath(), ".svn").exists();
+ final boolean devenvironment = new File(sb.getAppPath(), ".svn").exists();
double thisVersion = Double.parseDouble(yacyBuildProperties.getVersion());
// cut off the SVN Rev in the Version
try {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (final NumberFormatException e) {}
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index 4a7be5610..0965f9778 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -102,7 +102,7 @@ public class IndexControlURLs_p {
prop.put("reload", 1);
} else {
prop.put("lurlexport", 1);
- prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + DateFormatter.formatShortSecond());
+ prop.put("lurlexport_exportfile", sb.getDataPath() + "/DATA/EXPORT/" + DateFormatter.formatShortSecond());
if (export == null) {
// there has never been an export
prop.put("lurlexportfinished", 0);
diff --git a/htroot/Messages_p.java b/htroot/Messages_p.java
index ca7dbfb1a..ace1062c9 100644
--- a/htroot/Messages_p.java
+++ b/htroot/Messages_p.java
@@ -95,8 +95,8 @@ public class Messages_p {
messageBoard.entry message;
// first reset notification
- final File notifierSource = new File(sb.getRootPath(), sb.getConfig("htRootPath", "htroot") + "/env/grafics/empty.gif");
- final File notifierDest = new File(sb.getConfigPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
+ final File notifierSource = new File(sb.getAppPath(), sb.getConfig("htRootPath", "htroot") + "/env/grafics/empty.gif");
+ final File notifierDest = new File(sb.getDataPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
try {
FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index ac288de74..0b874e7a7 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -52,7 +52,7 @@ public class PerformanceMemory_p {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
if (defaultSettings == null) {
- defaultSettings = FileUtils.loadMap(new File(env.getRootPath(), "defaults/yacy.init"));
+ defaultSettings = FileUtils.loadMap(new File(env.getAppPath(), "defaults/yacy.init"));
}
prop.put("gc", "0");
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 5b11f55b3..1f4f9894e 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -60,7 +60,7 @@ public class PerformanceQueues_p {
// return variable that accumulates replacements
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
- File defaultSettingsFile = new File(sb.getRootPath(), "defaults/yacy.init");
+ File defaultSettingsFile = new File(sb.getAppPath(), "defaults/yacy.init");
// get segment
Segment indexSegment = null;
@@ -77,7 +77,7 @@ public class PerformanceQueues_p {
if(post != null) {
if(post.containsKey("defaultFile")){
// TODO check file-path!
- final File value = new File(sb.getRootPath(), post.get("defaultFile", "defaults/yacy.init"));
+ final File value = new File(sb.getAppPath(), post.get("defaultFile", "defaults/yacy.init"));
// check if value is readable file
if(value.exists() && value.isFile() && value.canRead()) {
defaultSettingsFile = value;
diff --git a/htroot/ProxyIndexingMonitor_p.java b/htroot/ProxyIndexingMonitor_p.java
index 51e5c4d6c..0e73b1354 100644
--- a/htroot/ProxyIndexingMonitor_p.java
+++ b/htroot/ProxyIndexingMonitor_p.java
@@ -87,7 +87,7 @@ public class ProxyIndexingMonitor_p {
newProxyCachePath = newProxyCachePath.substring(0, newProxyCachePath.length() - 1);
}
env.setConfig(SwitchboardConstants.HTCACHE_PATH, newProxyCachePath);
- final File cache = env.getConfigPath(SwitchboardConstants.HTCACHE_PATH, oldProxyCachePath);
+ final File cache = env.getDataPath(SwitchboardConstants.HTCACHE_PATH, oldProxyCachePath);
if (!cache.isDirectory() && !cache.isFile()) cache.mkdirs();
// proxyCacheSize
diff --git a/htroot/Steering.java b/htroot/Steering.java
index 4724489c0..7a4b69982 100644
--- a/htroot/Steering.java
+++ b/htroot/Steering.java
@@ -74,9 +74,9 @@ public class Steering {
if (post.containsKey("update")) {
Log.logInfo("STEERING", "update request from " + requestIP);
- final boolean devenvironment = new File(sb.getRootPath(), ".svn").exists();
+ final boolean devenvironment = new File(sb.getAppPath(), ".svn").exists();
final String releaseFileName = post.get("releaseinstall", "");
- final File releaseFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + releaseFileName);
+ final File releaseFile = new File(sb.getDataPath(), "DATA/RELEASE/".replace("/", File.separator) + releaseFileName);
if ((!devenvironment) && (releaseFileName.length() > 0) && (releaseFile.exists())) {
yacyRelease.deployRelease(releaseFile);
}
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.java
index 295ef205a..32e46b6ae 100644
--- a/htroot/Threaddump_p.java
+++ b/htroot/Threaddump_p.java
@@ -78,6 +78,7 @@ public class Threaddump_p {
bufferappend(buffer, plain, "");
int multipleCount = 100;
+ File appPath = sb.getAppPath();
if (post != null && post.containsKey("multipleThreaddump")) {
multipleCount = post.getInt("count", multipleCount);
final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<Map<Thread,StackTraceElement[]>>();
@@ -85,24 +86,24 @@ public class Threaddump_p {
traces.add(Thread.getAllStackTraces());
if (MemoryControl.available() < 20 * 1024 * 1024) break;
}
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, null);
+ appendStackTraceStats(appPath, buffer, traces, plain, null);
/*
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.BLOCKED);
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.RUNNABLE);
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.TIMED_WAITING);
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.WAITING);
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.NEW);
- appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.TERMINATED);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.BLOCKED);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.RUNNABLE);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.TIMED_WAITING);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.WAITING);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.NEW);
+ appendStackTraceStats(appPath, buffer, traces, plain, Thread.State.TERMINATED);
*/
} else {
// generate a single thread dump
final Map<Thread,StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.BLOCKED);
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.RUNNABLE);
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.TIMED_WAITING);
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.WAITING);
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.NEW);
- appendStackTraces(sb.getRootPath(), buffer, stackTraces, plain, Thread.State.TERMINATED);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.BLOCKED);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.RUNNABLE);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.TIMED_WAITING);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.WAITING);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.NEW);
+ appendStackTraces(appPath, buffer, stackTraces, plain, Thread.State.TERMINATED);
}
bufferappend(buffer, plain, "************* End Thread Dump " + dt + " *******************");
@@ -180,8 +181,8 @@ public class Threaddump_p {
return result;
}
- private static HashMap<String, SortedSet<String>> dumpCollection(final File rootPath, final Map<Thread,StackTraceElement[]> stackTraces, final boolean plain, final Thread.State stateIn) {
- final File classPath = new File(rootPath, "source");
+ private static HashMap<String, SortedSet<String>> dumpCollection(final File appPath, final Map<Thread,StackTraceElement[]> stackTraces, final boolean plain, final Thread.State stateIn) {
+ final File classPath = new File(appPath, "source");
Thread thread;
// collect single dumps
diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java
index 9b4eaddda..1ff4ed4bd 100644
--- a/htroot/ViewImage.java
+++ b/htroot/ViewImage.java
@@ -99,7 +99,7 @@ public class ViewImage {
if (urlString.endsWith(".ico")) {
// load default favicon dfltfvcn.ico
if (defaulticonb == null) try {
- imgb = FileUtils.read(new File(sb.getRootPath(), defaulticon));
+ imgb = FileUtils.read(new File(sb.getAppPath(), defaulticon));
} catch (final IOException e) {
return null;
} else {
diff --git a/htroot/api/blacklists.java b/htroot/api/blacklists.java
index 63d81205b..ba1e1dd6d 100644
--- a/htroot/api/blacklists.java
+++ b/htroot/api/blacklists.java
@@ -14,7 +14,7 @@ public class blacklists {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
final List<String> dirlist = FileUtils.getDirListing(listManager.listsPath);
int blacklistCount=0;
diff --git a/htroot/api/blacklists_p.java b/htroot/api/blacklists_p.java
index 963d576c8..f41c7018f 100644
--- a/htroot/api/blacklists_p.java
+++ b/htroot/api/blacklists_p.java
@@ -16,7 +16,7 @@ public class blacklists_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
final List<String> dirlist = FileUtils.getDirListing(listManager.listsPath);
int blacklistCount=0;
diff --git a/htroot/cytag.java b/htroot/cytag.java
index 2ae808c1e..21956f882 100644
--- a/htroot/cytag.java
+++ b/htroot/cytag.java
@@ -64,7 +64,7 @@ public class cytag {
String defaultimage = "redpillmini.png";
if (post != null && post.get("icon", "").equals("invisible")) defaultimage = "invisible.png";
- File iconfile = new File(sb.getRootPath(), "/htroot/env/grafics/" + defaultimage);
+ File iconfile = new File(sb.getAppPath(), "/htroot/env/grafics/" + defaultimage);
byte[] imgb = null;
try {
diff --git a/htroot/mediawiki_p.java b/htroot/mediawiki_p.java
index 40fc2e4c8..c9fb2e2b7 100644
--- a/htroot/mediawiki_p.java
+++ b/htroot/mediawiki_p.java
@@ -52,7 +52,7 @@ public class mediawiki_p {
if (dump == null || title == null) return post;
- File dumpFile = new File(sb.getRootPath(), "DATA/HTCACHE/mediawiki/" + dump);
+ File dumpFile = new File(sb.getDataPath(), "DATA/HTCACHE/mediawiki/" + dump);
if (!dumpFile.exists()) return post;
MediawikiImporter.checkIndex(dumpFile);
MediawikiImporter.wikisourcerecord w = MediawikiImporter.find(title.replaceAll(" ", "_"), MediawikiImporter.idxFromWikimediaXML(dumpFile));
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index a8560ce2d..009615073 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -88,7 +88,7 @@ public class sharedBlacklist_p {
// initialize the list manager
listManager.switchboard = (Switchboard) env;
- listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
+ listManager.listsPath = new File(listManager.switchboard.getDataPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
// loading all blacklist files located in the directory
diff --git a/htroot/www/welcome.java b/htroot/www/welcome.java
index b5c0a787f..7a7023acd 100644
--- a/htroot/www/welcome.java
+++ b/htroot/www/welcome.java
@@ -68,7 +68,7 @@ public class welcome {
final boolean senior = (peertype.equals(yacySeed.PEERTYPE_SENIOR)) || (peertype.equals(yacySeed.PEERTYPE_PRINCIPAL));
if (senior) { prop.put("couldcan", "can"); } else { prop.put("couldcan", "could"); }
if (senior) { prop.put("seniorinfo", "This peer runs in senior mode which means that your peer can be accessed using the addresses shown above."); } else { prop.putHTML("seniorinfo", "<b>Nobody can access your peer from the outside of your intranet. You must open your firewall and/or set a 'virtual server' in the settings of your router to enable access to the addresses as shown below.</b>"); }
- final File wwwpath = env.getConfigPath("htDocsPath", "DATA/HTDOCS");
+ final File wwwpath = env.getDataPath("htDocsPath", "DATA/HTDOCS");
prop.putHTML("wwwpath", wwwpath.isAbsolute() ? wwwpath.getAbsolutePath() : "<application_root_path>/" + env.getConfig("htDocsPath", "DATA/HTDOCS"));
// return rewrite properties
diff --git a/htroot/yacy/list.java b/htroot/yacy/list.java
index e1c8df7ca..cfd3c7595 100644
--- a/htroot/yacy/list.java
+++ b/htroot/yacy/list.java
@@ -55,7 +55,7 @@ public final class list {
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
final String col = post.get("col", "");
- final File listsPath = env.getConfigPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
+ final File listsPath = env.getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
String otherPeerName = null;
if (post.containsKey("iam")) {
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 4fdb5ce22..bd03f5073 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -142,8 +142,8 @@ public final class message {
messageForwardingViaEmail(sb, msgEntry);
// finally write notification
- final File notifierSource = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
- final File notifierDest = new File(sb.getConfigPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
+ final File notifierSource = new File(sb.getAppPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
+ final File notifierDest = new File(sb.getDataPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
try {
FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
diff --git a/source/de/anomic/crawler/ResourceObserver.java b/source/de/anomic/crawler/ResourceObserver.java
index bcf01696f..aa8a5c813 100644
--- a/source/de/anomic/crawler/ResourceObserver.java
+++ b/source/de/anomic/crawler/ResourceObserver.java
@@ -50,7 +50,7 @@ public class ResourceObserver {
public ResourceObserver(final Switchboard sb) {
this.sb = sb;
- this.path = sb.getConfigPath(SwitchboardConstants.INDEX_PRIMARY_PATH, "");
+ this.path = sb.getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, "");
}
public static void initThread() {
diff --git a/source/de/anomic/data/translator.java b/source/de/anomic/data/translator.java
index cf2c10ba5..73accdf72 100644
--- a/source/de/anomic/data/translator.java
+++ b/source/de/anomic/data/translator.java
@@ -234,8 +234,8 @@ public class translator {
ret = true;
} else {
final String htRootPath = env.getConfig("htRootPath", "htroot");
- final File sourceDir = new File(env.getRootPath(), htRootPath);
- final File destDir = new File(env.getConfigPath("locale.translated_html","DATA/LOCALE/htroot"), lang.substring(0, lang.length() - 4));// cut
+ 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
//File destDir = new File(env.getRootPath(), htRootPath + "/locale/" + lang.substring(0, lang.length() - 4));// cut
// .lng
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index 54b00ad7a..5a33a11e2 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -148,7 +148,7 @@ public final class HTTPDFileHandler {
// load the mime table
final String mimeTablePath = theSwitchboard.getConfig("mimeTable","");
Log.logConfig("HTTPDFiles", "Loading mime mapping file " + mimeTablePath);
- MimeTable.init(new File(theSwitchboard.getRootPath(), mimeTablePath));
+ MimeTable.init(new File(theSwitchboard.getAppPath(), mimeTablePath));
}
// create default files array
@@ -156,13 +156,13 @@ public final class HTTPDFileHandler {
// create a htRootPath: system pages
if (htRootPath == null) {
- htRootPath = new File(theSwitchboard.getRootPath(), theSwitchboard.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT));
+ 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.getConfigPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
+ htDocsPath = theSwitchboard.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
if (!(htDocsPath.exists())) htDocsPath.mkdirs();
}
@@ -172,15 +172,15 @@ public final class HTTPDFileHandler {
// create a htTemplatePath
if (htTemplatePath == null) {
- htTemplatePath = theSwitchboard.getConfigPath("htTemplatePath","htroot/env/templates");
+ htTemplatePath = theSwitchboard.getAppPath("htTemplatePath","htroot/env/templates");
if (!(htTemplatePath.exists())) htTemplatePath.mkdir();
}
//This is now handles by #%env/templates/foo%#
//if (templates.isEmpty()) templates.putAll(httpTemplate.loadTemplates(htTemplatePath));
// create htLocaleDefault, htLocalePath
- if (htDefaultPath == null) htDefaultPath = theSwitchboard.getConfigPath("htDefaultPath", "htroot");
- if (htLocalePath == null) htLocalePath = theSwitchboard.getConfigPath("locale.translated_html", "DATA/LOCALE/htroot");
+ if (htDefaultPath == null) htDefaultPath = theSwitchboard.getAppPath("htDefaultPath", "htroot");
+ if (htLocalePath == null) htLocalePath = theSwitchboard.getDataPath("locale.translated_html", "DATA/LOCALE/htroot");
}
}
@@ -623,7 +623,7 @@ public final class HTTPDFileHandler {
// env.put("AUTH_TYPE", ""); // TODO: implement
// env.put("REMOTE_USER", ""); // TODO: implement
// env.put("REMOTE_IDENT", ""); // I don't think we need this
- env.put("DOCUMENT_ROOT", switchboard.getRootPath().getAbsolutePath() + fileSeparator + switchboard.getConfig("htDocsPath", "DATA/HTDOCS"));
+ env.put("DOCUMENT_ROOT", switchboard.getAppPath().getAbsolutePath() + fileSeparator + switchboard.getConfig("htDocsPath", "DATA/HTDOCS"));
if (requestHeader.getContentType() != null) {
env.put("CONTENT_TYPE", requestHeader.getContentType());
}
diff --git a/source/de/anomic/http/server/HTTPDProxyHandler.java b/source/de/anomic/http/server/HTTPDProxyHandler.java
index 263b8255f..570c7e4b2 100644
--- a/source/de/anomic/http/server/HTTPDProxyHandler.java
+++ b/source/de/anomic/http/server/HTTPDProxyHandler.java
@@ -122,7 +122,24 @@ public final class HTTPDProxyHandler {
* Do logging configuration for special proxy access log file
*/
static {
- // Doing logger initialization
+
+ // get a switchboard
+ sb = Switchboard.getSwitchboard();
+ if (sb != null) {
+
+ isTransparentProxy = Boolean.parseBoolean(sb.getConfig("isTransparentProxy","false"));
+
+ // set timeout
+ timeout = Integer.parseInt(sb.getConfig("proxy.clientTimeout", "10000"));
+
+ // create a htRootPath: system pages
+ htRootPath = new File(sb.getAppPath(), sb.getConfig("htRootPath","htroot"));
+ if (!(htRootPath.exists())) {
+ if(!htRootPath.mkdir())
+ Log.logSevere("PROXY", "could not create htRoot "+ htRootPath);
+ }
+
+ // do logger initialization
try {
log.logInfo("Configuring proxy access logging ...");
@@ -138,6 +155,8 @@ public final class HTTPDProxyHandler {
int limit = 1024*1024, count = 20;
String pattern = manager.getProperty(className + ".logging.FileHandler.pattern");
if (pattern == null) pattern = "DATA/LOG/proxyAccess%u%g.log";
+ // make pattern absolute
+ if (!new File(pattern).isAbsolute()) pattern = new File(sb.getDataPath(), pattern).getAbsolutePath();
final String limitStr = manager.getProperty(className + ".logging.FileHandler.limit");
if (limitStr != null) try { limit = Integer.parseInt(limitStr); } catch (final NumberFormatException e) {}
@@ -150,7 +169,7 @@ public final class HTTPDProxyHandler {
proxyLogger.setUseParentHandlers(false);
proxyLogger.setLevel(Level.FINEST);
- final FileHandler txtLog = new FileHandler(pattern,limit,count,true);
+ final FileHandler txtLog = new FileHandler(pattern, limit, count, true);
txtLog.setFormatter(new ProxyLogFormatter());
txtLog.setLevel(Level.FINEST);
proxyLogger.addHandler(txtLog);
@@ -166,25 +185,10 @@ public final class HTTPDProxyHandler {
} catch (final Exception e) {
log.logSevere("Unable to configure proxy access logging.",e);
}
-
- sb = Switchboard.getSwitchboard();
- if (sb != null) {
-
- isTransparentProxy = Boolean.parseBoolean(sb.getConfig("isTransparentProxy","false"));
-
- // set timeout
- timeout = Integer.parseInt(sb.getConfig("proxy.clientTimeout", "10000"));
-
- // create a htRootPath: system pages
- htRootPath = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot"));
- if (!(htRootPath.exists())) {
- if(!htRootPath.mkdir())
- Log.logSevere("PROXY", "could not create htRoot "+ htRootPath);
- }
// load a transformer
transformer = new ContentTransformer();
- transformer.init(new File(sb.getRootPath(), sb.getConfig(SwitchboardConstants.LIST_BLUE, "")).toString());
+ transformer.init(new File(sb.getAppPath(), sb.getConfig(SwitchboardConstants.LIST_BLUE, "")).toString());
// load the yellow-list
final String f = sb.getConfig("proxyYellowList", null);
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index 7eff11ee2..d39b05711 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -1113,7 +1113,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
tp.put("date", systemDate);
// rewrite the file
- final File htRootPath = new File(switchboard.getRootPath(), switchboard.getConfig("htRootPath","htroot"));
+ final File htRootPath = new File(switchboard.getAppPath(), switchboard.getConfig("htRootPath","htroot"));
TemplateEngine.writeTemplate(
fis = new FileInputStream(new File(htRootPath, "/proxymsg/error.html")),
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 5e26ec014..f221d46b7 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -251,8 +251,8 @@ public final class Switchboard extends serverSwitch {
private static Switchboard sb = null;
- public Switchboard(final File rootPath, final String initPath, final String configPath) throws IOException {
- super(rootPath, initPath, configPath);
+ public Switchboard(final File dataPath, final File appPath, final String initPath, final String configPath) throws IOException {
+ super(dataPath, appPath, initPath, configPath);
MemoryTracker.startSystemProfiling();
sb=this;
@@ -276,24 +276,24 @@ public final class Switchboard extends serverSwitch {
if (MemoryControl.available() > 1024 * 1024 * 1024 * 2) this.exceed134217727 = true;
// load values from configs
- final File indexPath = getConfigPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);
+ final File indexPath = getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);
this.log.logConfig("Index Primary Path: " + indexPath.toString());
- this.listsPath = getConfigPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
+ this.listsPath = getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
this.log.logConfig("Lists Path: " + this.listsPath.toString());
- this.htDocsPath = getConfigPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
+ this.htDocsPath = getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
this.log.logConfig("HTDOCS Path: " + this.htDocsPath.toString());
- this.rankingPath = getConfigPath(SwitchboardConstants.RANKING_PATH, SwitchboardConstants.RANKING_PATH_DEFAULT);
+ this.rankingPath = getDataPath(SwitchboardConstants.RANKING_PATH, SwitchboardConstants.RANKING_PATH_DEFAULT);
this.log.logConfig("Ranking Path: " + this.rankingPath.toString());
this.rankingPermissions = new HashMap<String, String>(); // mapping of permission - to filename.
- this.workPath = getConfigPath(SwitchboardConstants.WORK_PATH, SwitchboardConstants.WORK_PATH_DEFAULT);
+ this.workPath = getDataPath(SwitchboardConstants.WORK_PATH, SwitchboardConstants.WORK_PATH_DEFAULT);
this.log.logConfig("Work Path: " + this.workPath.toString());
- this.dictionariesPath = getConfigPath(SwitchboardConstants.DICTIONARY_SOURCE_PATH, SwitchboardConstants.DICTIONARY_SOURCE_PATH_DEFAULT);
+ this.dictionariesPath = getDataPath(SwitchboardConstants.DICTIONARY_SOURCE_PATH, SwitchboardConstants.DICTIONARY_SOURCE_PATH_DEFAULT);
this.log.logConfig("Dictionaries Path:" + this.dictionariesPath.toString());
// init sessionid name file
- final String sessionidNamesFile = getConfig("sessionidNamesFile","");
+ final String sessionidNamesFile = getConfig("sessionidNamesFile","defaults/sessionid.names");
this.log.logConfig("Loading sessionid file " + sessionidNamesFile);
- MultiProtocolURI.initSessionIDNames(FileUtils.loadList(new File(getRootPath(), sessionidNamesFile)));
+ MultiProtocolURI.initSessionIDNames(FileUtils.loadList(new File(getAppPath(), sessionidNamesFile)));
// init tables
this.tables = new WorkTables(this.workPath);
@@ -397,7 +397,7 @@ public final class Switchboard extends serverSwitch {
// load blacklist
this.log.logConfig("Loading blacklist ...");
- final File blacklistsPath = getConfigPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
+ final File blacklistsPath = getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);
urlBlacklist = new Blacklist(blacklistsPath);
listManager.switchboard = this;
listManager.listsPath = blacklistsPath;
@@ -405,7 +405,7 @@ public final class Switchboard extends serverSwitch {
// load badwords (to filter the topwords)
if (badwords == null || badwords.isEmpty()) {
- final File badwordsFile = new File(rootPath, SwitchboardConstants.LIST_BADWORDS_DEFAULT);
+ final File badwordsFile = new File(appPath, SwitchboardConstants.LIST_BADWORDS_DEFAULT);
badwords = SetTools.loadList(badwordsFile, NaturalOrder.naturalComparator);
badwordHashes = Word.words2hashesHandles(badwords);
this.log.logConfig("loaded badwords from file " + badwordsFile.getName() +
@@ -415,7 +415,7 @@ public final class Switchboard extends serverSwitch {
// load stopwords
if (stopwords == null || stopwords.isEmpty()) {
- final File stopwordsFile = new File(rootPath, SwitchboardConstants.LIST_STOPWORDS_DEFAULT);
+ final File stopwordsFile = new File(appPath, SwitchboardConstants.LIST_STOPWORDS_DEFAULT);
stopwords = SetTools.loadList(stopwordsFile, NaturalOrder.naturalComparator);
stopwordHashes = Word.words2hashesHandles(stopwords);
this.log.logConfig("loaded stopwords from file " + stopwordsFile.getName() + ", " +
@@ -424,7 +424,7 @@ public final class Switchboard extends serverSwitch {
}
// load ranking tables
- final File YBRPath = new File(rootPath, "ranking/YBR");
+ final File YBRPath = new File(appPath, "ranking/YBR");
if (YBRPath.exists()) {
RankingProcess.loadYBR(YBRPath, 15);
}
@@ -438,21 +438,21 @@ public final class Switchboard extends serverSwitch {
log.logConfig("Starting HT Cache Manager");
// create the cache directory
- htCachePath = getConfigPath(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);
+ htCachePath = getDataPath(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);
this.log.logInfo("HTCACHE Path = " + htCachePath.getAbsolutePath());
final long maxCacheSize = 1024 * 1024 * Long.parseLong(getConfig(SwitchboardConstants.PROXY_CACHE_SIZE, "2")); // this is megabyte
Cache.init(htCachePath, peers.mySeed().hash, maxCacheSize);
// create the surrogates directories
- surrogatesInPath = getConfigPath(SwitchboardConstants.SURROGATES_IN_PATH, SwitchboardConstants.SURROGATES_IN_PATH_DEFAULT);
+ surrogatesInPath = getDataPath(SwitchboardConstants.SURROGATES_IN_PATH, SwitchboardConstants.SURROGATES_IN_PATH_DEFAULT);
this.log.logInfo("surrogates.in Path = " + surrogatesInPath.getAbsolutePath());
surrogatesInPath.mkdirs();
- surrogatesOutPath = getConfigPath(SwitchboardConstants.SURROGATES_OUT_PATH, SwitchboardConstants.SURROGATES_OUT_PATH_DEFAULT);
+ surrogatesOutPath = getDataPath(SwitchboardConstants.SURROGATES_OUT_PATH, SwitchboardConstants.SURROGATES_OUT_PATH_DEFAULT);
this.log.logInfo("surrogates.out Path = " + surrogatesOutPath.getAbsolutePath());
surrogatesOutPath.mkdirs();
// create the release download directory
- releasePath = getConfigPath(SwitchboardConstants.RELEASE_PATH, SwitchboardConstants.RELEASE_PATH_DEFAULT);
+ releasePath = getDataPath(SwitchboardConstants.RELEASE_PATH, SwitchboardConstants.RELEASE_PATH_DEFAULT);
releasePath.mkdirs();
this.log.logInfo("RELEASE Path = " + releasePath.getAbsolutePath());
@@ -467,7 +467,7 @@ public final class Switchboard extends serverSwitch {
// Init User DB
this.log.logConfig("Loading User DB");
- final File userDbFile = new File(getRootPath(), "DATA/SETTINGS/user.heap");
+ final File userDbFile = new File(getDataPath(), "DATA/SETTINGS/user.heap");
this.userDB = new userDB(userDbFile);
this.log.logConfig("Loaded User DB from file " + userDbFile.getName() +
", " + this.userDB.size() + " entries" +
@@ -483,7 +483,7 @@ public final class Switchboard extends serverSwitch {
// start a loader
log.logConfig("Starting Crawl Loader");
this.loader = new LoaderDispatcher(this);
- Map<String, File> oaiFriends = OAIListFriendsLoader.loadListFriendsSources(new File("defaults/oaiListFriendsSource.xml"));
+ Map<String, File> oaiFriends = OAIListFriendsLoader.loadListFriendsSources(new File("defaults/oaiListFriendsSource.xml"), getDataPath());
OAIListFriendsLoader.init(this.loader, oaiFriends);
this.crawlQueues = new CrawlQueues(this, queuesRoot);
this.crawlQueues.noticeURL.setMinimumDelta(
@@ -518,8 +518,8 @@ public final class Switchboard extends serverSwitch {
this.remoteSearches = new ArrayList<QueryParams>();
// init messages: clean up message symbol
- final File notifierSource = new File(getRootPath(), getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");
- final File notifierDest = new File(getConfigPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT), "notifier.gif");
+ final File notifierSource = new File(getAppPath(), getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");
+ final File notifierDest = new File(getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT), "notifier.gif");
try {
FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
@@ -740,7 +740,7 @@ public final class Switchboard extends serverSwitch {
} catch (final MalformedURLException e) {}
}
} else {
- final File networkUnitDefinitionFile = (networkUnitDefinition.length() > 0 && networkUnitDefinition.charAt(0) == '/') ? new File(networkUnitDefinition) : new File(getRootPath(), networkUnitDefinition);
+ final File networkUnitDefinitionFile = (networkUnitDefinition.length() > 0 && networkUnitDefinition.charAt(0) == '/') ? new File(networkUnitDefinition) : new File(getAppPath(), networkUnitDefinition);
if (networkUnitDefinitionFile.exists()) {
initProps = FileUtils.loadMap(networkUnitDefinitionFile);
setConfig(initProps);
@@ -751,7 +751,7 @@ public final class Switchboard extends serverSwitch {
setConfig(Switchboard.loadFileAsMap(new DigestURI(networkGroupDefinition, null)));
} catch (final MalformedURLException e) { }
} else {
- final File networkGroupDefinitionFile = new File(getRootPath(), networkGroupDefinition);
+ final File networkGroupDefinitionFile = new File(getAppPath(), networkGroupDefinition);
if (networkGroupDefinitionFile.exists()) {
initProps = FileUtils.loadMap(networkGroupDefinitionFile);
setConfig(initProps);
@@ -850,7 +850,7 @@ public final class Switchboard extends serverSwitch {
// new properties
setConfig("network.unit.definition", networkDefinition);
overwriteNetworkDefinition();
- final File indexPrimaryPath = getConfigPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);
+ final File indexPrimaryPath = getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);
final int wordCacheMaxCount = (int) getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);
final long fileSizeMax = (OS.isWindows) ? sb.getConfigLong("filesize.max.win", (long) Integer.MAX_VALUE) : sb.getConfigLong("filesize.max.other", (long) Integer.MAX_VALUE);
final int redundancy = (int) sb.getConfigLong("network.unit.dhtredundancy.senior", 1);
@@ -1619,7 +1619,7 @@ public final class Switchboard extends serverSwitch {
// there is a version that is more recent. Load it and re-start with it
log.logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.getUrl());
final File downloaded = updateVersion.downloadRelease();
- final boolean devenvironment = new File(this.getRootPath(), ".svn").exists();
+ final boolean devenvironment = new File(this.getAppPath(), ".svn").exists();
if (devenvironment) {
log.logInfo("AUTO-UPDATE: omiting update because this is a development environment");
} else if ((downloaded == null) || (!downloaded.exists()) || (downloaded.length() == 0)) {
diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java
index eb3359bf9..b544adcf4 100644
--- a/source/de/anomic/server/serverSwitch.java
+++ b/source/de/anomic/server/serverSwitch.java
@@ -45,7 +45,8 @@ public class serverSwitch {
// configuration management
private final File configFile;
private final String configComment;
- private final File rootPath;
+ private final File dataPath;
+ private final File appPath;
protected boolean firstInit;
protected Log log;
protected int serverJobs;
@@ -56,17 +57,18 @@ public class serverSwitch {
private final TreeMap<String, serverSwitchAction> switchActions;
private final serverAccessTracker accessTracker;
- public serverSwitch(final File rootPath, final String initPath, final String configPath) {
+ public serverSwitch(final File dataPath, final File appPath, final String initPath, final String configPath) {
// we initialize the switchboard with a property file,
// but maintain these properties then later in a new 'config' file
// to reset all changed configs, the config file must
// be deleted, but not the init file
// the only attribute that will always be read from the init is the
// file name of the config file
- this.rootPath = rootPath;
+ this.dataPath = dataPath;
+ this.appPath = appPath;
this.configComment = "This is an automatically generated file, updated by serverAbstractSwitch and initialized by " + initPath;
- final File initFile = new File(rootPath, initPath);
- this.configFile = new File(rootPath, configPath); // propertiesFile(config);
+ final File initFile = new File(appPath, initPath);
+ this.configFile = new File(dataPath, configPath); // propertiesFile(config);
firstInit = !configFile.exists(); // this is true if the application was started for the first time
new File(configFile.getParent()).mkdir();
@@ -277,11 +279,19 @@ public class serverSwitch {
* returned File is derived from this setting only. Otherwise the path's file
* is constructed from the applications root path + the relative path setting.
*/
- public File getConfigPath(final String key, final String dflt) {
+ public File getDataPath(final String key, final String dflt) {
File ret;
final String path = getConfig(key, dflt).replace('\\', '/');
final File f = new File(path);
- ret = (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(this.rootPath, path));
+ ret = (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(this.dataPath, path));
+ return ret;
+ }
+
+ public File getAppPath(final String key, final String dflt) {
+ File ret;
+ final String path = getConfig(key, dflt).replace('\\', '/');
+ final File f = new File(path);
+ ret = (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(this.appPath, path));
return ret;
}
@@ -511,8 +521,12 @@ public class serverSwitch {
return rights.indexOf(right) >= 0;
}
- public File getRootPath() {
- return rootPath;
+ public File getDataPath() {
+ return this.dataPath;
+ }
+
+ public File getAppPath() {
+ return this.appPath;
}
public String toString() {
diff --git a/source/de/anomic/yacy/Tray.java b/source/de/anomic/yacy/Tray.java
index a0e42e4ac..24cbe690f 100644
--- a/source/de/anomic/yacy/Tray.java
+++ b/source/de/anomic/yacy/Tray.java
@@ -68,7 +68,7 @@ public final class Tray {
System.setProperty("java.awt.headless", "false");
if(nativeTrayIcon.isSupported()) {
- final String iconpath = sb.getRootPath().toString() + "/addon/YaCy_TrayIcon.png".replace("/", File.separator);
+ final String iconpath = sb.getAppPath().toString() + "/addon/YaCy_TrayIcon.png".replace("/", File.separator);
ActionListener al = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
trayClickAction();
diff --git a/source/de/anomic/yacy/yacyAccessible.java b/source/de/anomic/yacy/yacyAccessible.java
index d21e68887..5992214dc 100644
--- a/source/de/anomic/yacy/yacyAccessible.java
+++ b/source/de/anomic/yacy/yacyAccessible.java
@@ -45,7 +45,7 @@ public class yacyAccessible {
public static void setNewPortLink(final int newPort){
try {
final Switchboard sb = Switchboard.getSwitchboard();
- final File shortcut = new File(sb.getRootPath() + "/addon/YaCy-Search.html".replace("/", File.separator));
+ final File shortcut = new File(sb.getAppPath() + "/addon/YaCy-Search.html".replace("/", File.separator));
final String content = "<meta http-equiv=\"refresh\" content=\"0;url=http://localhost:" + newPort + "/\">";
FileUtils.copy(content.getBytes(), shortcut);
} catch (final Exception e) {
@@ -60,7 +60,7 @@ public class yacyAccessible {
public static void setNewPortBat(final int newPort){
try {
final Switchboard sb = Switchboard.getSwitchboard();
- final File shortcut = new File(sb.getRootPath() + "/addon/YaCy-Search.bat".replace("/", File.separator));
+ final File shortcut = new File(sb.getAppPath() + "/addon/YaCy-Search.bat".replace("/", File.separator));
final String content = "rundll32 url.dll,FileProtocolHandler \"http://localhost:" + newPort + "\"";
FileUtils.copy(content.getBytes(), shortcut);
} catch (final Exception e) {
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 93ad67e11..26fe6ce61 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -1034,7 +1034,7 @@ public final class yacyClient {
if(args.length > 1) {
System.out.println("yacyClient Test");
try {
- final Switchboard sb = new Switchboard(new File(args[0]), "httpProxy.init", "DATA/SETTINGS/yacy.conf");
+ final Switchboard sb = new Switchboard(new File(args[0]), new File(args[0]), "httpProxy.init", "DATA/SETTINGS/yacy.conf");
/*final yacyCore core =*/ new yacyCore(sb);
sb.loadSeedLists();
final yacySeed target = sb.peers.getConnected(args[1]);
diff --git a/source/de/anomic/yacy/yacyRelease.java b/source/de/anomic/yacy/yacyRelease.java
index 59ed3188b..b1e3c9889 100644
--- a/source/de/anomic/yacy/yacyRelease.java
+++ b/source/de/anomic/yacy/yacyRelease.java
@@ -401,10 +401,9 @@ public final class yacyRelease extends yacyVersion {
*/
public static void restart() {
final Switchboard sb = Switchboard.getSwitchboard();
- final String apphome = sb.getRootPath().toString();
if (OS.isWindows) {
- final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));
+ final File startType = new File(sb.getDataPath(), "DATA/yacy.noconsole".replace("/", File.separator));
String starterFile = "startYACY_debug.bat";
if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole
@@ -415,16 +414,16 @@ public final class yacyRelease extends yacyVersion {
"title YaCy restarter" + serverCore.LF_STRING +
"set loading=YACY RESTARTER" + serverCore.LF_STRING +
"echo %loading%" + serverCore.LF_STRING +
- "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +
+ "cd \"" + sb.getDataPath().toString() + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +
":WAIT" + serverCore.LF_STRING +
"set loading=%loading%." + serverCore.LF_STRING +
"cls" + serverCore.LF_STRING +
"echo %loading%" + serverCore.LF_STRING +
"ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING +
"IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING +
- "cd \"" + apphome + "\"" + serverCore.LF_STRING +
+ "cd \"" + sb.getAppPath().toString() + "\"" + serverCore.LF_STRING +
"start /MIN CMD /C " + starterFile + serverCore.LF_STRING;
- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.bat".replace("/", File.separator));
+ final File scriptFile = new File(sb.getDataPath(), "DATA/RELEASE/restart.bat".replace("/", File.separator));
OS.deployScript(scriptFile, script);
Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());
OS.execAsynchronous(scriptFile);
@@ -454,7 +453,7 @@ public final class yacyRelease extends yacyVersion {
final String script =
"#!/bin/sh" + serverCore.LF_STRING +
yacyBuildProperties.getRestartCmd() + " >/var/lib/yacy/RELEASE/log" + serverCore.LF_STRING;
- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.sh");
+ final File scriptFile = new File(sb.getDataPath(), "DATA/RELEASE/restart.sh");
OS.deployScript(scriptFile, script);
Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());
OS.execAsynchronous(scriptFile);
@@ -468,13 +467,14 @@ public final class yacyRelease extends yacyVersion {
Log.logInfo("RESTART", "INITIATED");
final String script =
"#!/bin/sh" + serverCore.LF_STRING +
- "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
+ "cd " + sb.getDataPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
"while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
"sleep 1" + serverCore.LF_STRING +
"done" + serverCore.LF_STRING +
- "cd ../../" + serverCore.LF_STRING +
+ //"cd ../../" + serverCore.LF_STRING +
+ "cd " + sb.getAppPath() + serverCore.LF_STRING +
"nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;
- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.sh");
+ final File scriptFile = new File(sb.getDataPath(), "DATA/RELEASE/restart.sh");
OS.deployScript(scriptFile, script);
Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());
OS.execAsynchronous(scriptFile);
@@ -497,17 +497,16 @@ public final class yacyRelease extends yacyVersion {
//byte[] script = ("cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + ";while [ -e ../yacy.running ]; do sleep 1;done;tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes();
try {
final Switchboard sb = Switchboard.getSwitchboard();
- final String apphome = sb.getRootPath().toString();
Log.logInfo("UPDATE", "INITIATED");
try{
- tarTools.unTar(tarTools.getInputStream(releaseFile), sb.getRootPath() + "/DATA/RELEASE/".replace("/", File.separator));
+ tarTools.unTar(tarTools.getInputStream(releaseFile), sb.getDataPath() + "/DATA/RELEASE/".replace("/", File.separator));
} catch (final Exception e){
Log.logSevere("UNTAR", "failed", e);
}
String script = null;
String scriptFileName = null;
if (OS.isWindows) {
- final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));
+ final File startType = new File(sb.getDataPath(), "DATA/yacy.noconsole".replace("/", File.separator));
String starterFile = "startYACY_debug.bat";
if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole
script =
@@ -515,7 +514,7 @@ public final class yacyRelease extends yacyVersion {
"title YaCy updater" + serverCore.LF_STRING +
"set loading=YACY UPDATER" + serverCore.LF_STRING +
"echo %loading%" + serverCore.LF_STRING +
- "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +
+ "cd \"" + sb.getDataPath().toString() + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +
":WAIT" + serverCore.LF_STRING +
"set loading=%loading%." + serverCore.LF_STRING +
@@ -526,8 +525,8 @@ public final class yacyRelease extends yacyVersion {
"IF not exist yacy goto NODATA" + serverCore.LF_STRING +
"cd yacy" + serverCore.LF_STRING +
- "del /Q \"" + apphome + "\\lib\\*\" >nul" + serverCore.LF_STRING +
- "xcopy *.* \"" + apphome + "\" /E /Y >nul" + serverCore.LF_STRING +
+ "del /Q \"" + sb.getAppPath().toString() + "\\lib\\*\" >nul" + serverCore.LF_STRING +
+ "xcopy *.* \"" + sb.getAppPath().toString() + "\" /E /Y >nul" + serverCore.LF_STRING +
// /E - all subdirectories
// /Y - don't ask
"cd .." + serverCore.LF_STRING +
@@ -541,13 +540,13 @@ public final class yacyRelease extends yacyVersion {
"pause" + serverCore.LF_STRING +
":END" + serverCore.LF_STRING +
- "cd \"" + apphome + "\"" + serverCore.LF_STRING +
+ "cd \"" + sb.getAppPath().toString() + "\"" + serverCore.LF_STRING +
"start /MIN CMD /C " + starterFile + serverCore.LF_STRING;
scriptFileName = "update.bat";
} else { // unix/linux
script =
"#!/bin/sh" + serverCore.LF_STRING +
- "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
+ "cd " + sb.getDataPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
/* ((releaseFile.getName().endsWith(".gz")) ?
// test gz-file for integrity and tar xfz then
("if gunzip -t " + releaseFile.getAbsolutePath() + serverCore.LF_STRING +
@@ -559,8 +558,8 @@ public final class yacyRelease extends yacyVersion {
"while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
"sleep 1" + serverCore.LF_STRING +
"done" + serverCore.LF_STRING +
- "rm " + apphome + "/lib/*" + serverCore.LF_STRING +
- "cp -Rf yacy/* " + apphome + serverCore.LF_STRING +
+ "rm " + sb.getAppPath().toString() + "/lib/*" + serverCore.LF_STRING +
+ "cp -Rf yacy/* " + sb.getAppPath().toString() + serverCore.LF_STRING +
"rm -Rf yacy" + serverCore.LF_STRING +
/* ((releaseFile.getName().endsWith(".gz")) ?
// else-case of gunzip -t test: if failed, just restart
@@ -572,13 +571,13 @@ public final class yacyRelease extends yacyVersion {
// in case that we did not made the integrity test, there is no else case
""
) +*/
- "cd " + apphome + serverCore.LF_STRING +
+ "cd " + sb.getAppPath().toString() + serverCore.LF_STRING +
"chmod 755 *.sh" + serverCore.LF_STRING + // tarTools does not keep access/execute right
"chmod 755 bin/*.sh" + serverCore.LF_STRING +
"nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;
scriptFileName = "update.sh";
}
- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + scriptFileName);
+ final File scriptFile = new File(sb.getDataPath(), "DATA/RELEASE/".replace("/", File.separator) + scriptFileName);
OS.deployScript(scriptFile, script);
Log.logInfo("UPDATE", "wrote update-script to " + scriptFile.getAbsolutePath());
OS.execAsynchronous(scriptFile);
diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.java
index 5450a4367..98e5dede5 100644
--- a/source/net/yacy/document/TextParser.java
+++ b/source/net/yacy/document/TextParser.java
@@ -185,7 +185,7 @@ public final class TextParser {
log.logWarning(errorMsg);
throw new Parser.Failure(errorMsg, location);
}
- assert !idioms.isEmpty();
+ assert !idioms.isEmpty() : "no parsers applied for url " + location.toNormalform(true, false);
// if we do not have more than one parser or the content size is over MaxInt
// then we use only one stream-oriented parser.
diff --git a/source/net/yacy/document/importer/OAIListFriendsLoader.java b/source/net/yacy/document/importer/OAIListFriendsLoader.java
index 5b0e9306f..c65a59edb 100644
--- a/source/net/yacy/document/importer/OAIListFriendsLoader.java
+++ b/source/net/yacy/document/importer/OAIListFriendsLoader.java
@@ -62,7 +62,7 @@ public class OAIListFriendsLoader {
}
}
- public static Map<String, File> loadListFriendsSources(File initFile) {
+ public static Map<String, File> loadListFriendsSources(File initFile, File dataPath) {
Properties p = new Properties();
Map<String, File> m = new HashMap<String, File>();
try {
@@ -71,7 +71,7 @@ public class OAIListFriendsLoader {
Log.logException(e);
return m;
}
- for (Entry<Object, Object> e: p.entrySet()) m.put((String) e.getKey(), new File((String) e.getValue()));
+ for (Entry<Object, Object> e: p.entrySet()) m.put((String) e.getKey(), new File(dataPath, (String) e.getValue()));
return m;
}
diff --git a/source/net/yacy/kelondro/logging/Log.java b/source/net/yacy/kelondro/logging/Log.java
index 612602a28..fba8134cd 100644
--- a/source/net/yacy/kelondro/logging/Log.java
+++ b/source/net/yacy/kelondro/logging/Log.java
@@ -28,10 +28,12 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
+
public final class Log {
// log-level categories
@@ -55,7 +57,7 @@ public final class Log {
public static final char LOGTOKEN_FINEST = 'D';
private final Logger theLogger;
-
+
public Log(final String appName) {
this.theLogger = Logger.getLogger(appName);
//this.theLogger.setLevel(Level.FINEST); // set a default level
@@ -341,7 +343,7 @@ public final class Log {
}
}
- public final static void configureLogging(final File homePath, final File loggingConfigFile) throws SecurityException, FileNotFoundException, IOException {
+ public final static void configureLogging(final File dataPath, final File appPath, final File loggingConfigFile) throws SecurityException, FileNotFoundException, IOException {
FileInputStream fileIn = null;
try {
System.out.println("STARTUP: Trying to load logging configuration from file " + loggingConfigFile.toString());
@@ -352,17 +354,23 @@ public final class Log {
logManager.readConfiguration(fileIn);
// creating the logging directory
- final String logPattern = logManager.getProperty("java.util.logging.FileHandler.pattern");
+ String logPattern = logManager.getProperty("java.util.logging.FileHandler.pattern");
int stripPos = logPattern.lastIndexOf('/');
+ if (!new File(logPattern).isAbsolute()) logPattern = new File(dataPath, logPattern).getAbsolutePath();
if (stripPos < 0) stripPos = logPattern.lastIndexOf(File.pathSeparatorChar);
File log = new File(logPattern.substring(0, stripPos));
- if (!log.isAbsolute()) log = new File(homePath, log.getPath());
+ if (!log.isAbsolute()) log = new File(dataPath, log.getPath());
if (!log.canRead()) log.mkdir();
- // TODO: changing the pattern settings for the file handlers
-
// generating the root logger
- /*Logger logger =*/ Logger.getLogger("");
+ Logger logger = Logger.getLogger("");
+ logger.setUseParentHandlers(false);
+
+ //for (Handler h: logger.getHandlers()) logger.removeHandler(h);
+ if (!dataPath.getAbsolutePath().equals(appPath.getAbsolutePath())) {
+ FileHandler handler = new FileHandler(logPattern, 1024*1024, 20, true);
+ logger.addHandler(handler);
+ }
logRunnerThread = new logRunner();
logRunnerThread.start();
diff --git a/source/net/yacy/migration.java b/source/net/yacy/migration.java
index 019709631..8d7df2dee 100644
--- a/source/net/yacy/migration.java
+++ b/source/net/yacy/migration.java
@@ -84,8 +84,8 @@ public class migration {
* copy skins from the release to DATA/SKINS.
*/
public static void installSkins(final Switchboard sb){
- final File skinsPath = sb.getConfigPath("skinPath", "DATA/SKINS");
- final File defaultSkinsPath = new File(sb.getRootPath(), "skins");
+ final File skinsPath = sb.getDataPath("skinPath", "DATA/SKINS");
+ final File defaultSkinsPath = new File(sb.getAppPath(), "skins");
if (defaultSkinsPath.exists()) {
final List<String> skinFiles = FileUtils.getDirListing(defaultSkinsPath.getAbsolutePath());
mkdirs(skinsPath);
@@ -103,9 +103,9 @@ public class migration {
if(skin.equals("")){
skin="default";
}
- final File skinsDir=sb.getConfigPath("skinPath", "DATA/SKINS");
+ final File skinsDir=sb.getDataPath("skinPath", "DATA/SKINS");
final File skinFile=new File(skinsDir, skin+".css");
- final File htdocsPath=new File(sb.getConfigPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT), "env");
+ final File htdocsPath=new File(sb.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT), "env");
final File styleFile=new File(htdocsPath, "style.css");
if(!skinFile.exists()){
if(styleFile.exists()){
@@ -155,7 +155,7 @@ public class migration {
Log.logWarning("MIGRATION", "could not delete "+ filename);
}
public static void migrateWorkFiles(final Switchboard sb){
- File file=new File(sb.getRootPath(), "DATA/SETTINGS/wiki.db");
+ File file=new File(sb.getDataPath(), "DATA/SETTINGS/wiki.db");
File file2;
if (file.exists()) {
Log.logInfo("MIGRATION", "Migrating wiki.db to "+ sb.workPath);
@@ -167,7 +167,7 @@ public class migration {
} catch (final IOException e) {
}
- file = new File(sb.getRootPath(), "DATA/SETTINGS/wiki-bkp.db");
+ file = new File(sb.getDataPath(), "DATA/SETTINGS/wiki-bkp.db");
if (file.exists()) {
Log.logInfo("MIGRATION", "Migrating wiki-bkp.db to "+ sb.workPath);
file2 = new File(sb.workPath, "wiki-bkp.db");
@@ -184,7 +184,7 @@ public class migration {
}
- file=new File(sb.getRootPath(), "DATA/SETTINGS/message.db");
+ file=new File(sb.getDataPath(), "DATA/SETTINGS/message.db");
if(file.exists()){
Log.logInfo("MIGRATION", "Migrating message.db to "+ sb.workPath);
sb.messageDB.close();
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index 8df782d59..444c54f4d 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -157,7 +157,7 @@ public final class yacy {
* @param homePath Root-path where all information is to be found.
* @param startupFree free memory at startup time, to be used later for statistics
*/
- private static void startup(final File homePath, final long startupMemFree, final long startupMemTotal, boolean gui) {
+ private static void startup(final File dataHome, final File appHome, final long startupMemFree, final long startupMemTotal, boolean gui) {
try {
// start up
System.out.println(copyright);
@@ -173,38 +173,39 @@ public final class yacy {
}
// ensure that there is a DATA directory, if not, create one and if that fails warn and die
- File f = homePath;
- mkdirsIfNeseccary(f);
- f = new File(homePath, "DATA/");
+ mkdirsIfNeseccary(dataHome);
+ mkdirsIfNeseccary(appHome);
+ File f = new File(dataHome, "DATA/");
mkdirsIfNeseccary(f);
if (!(f.exists())) {
- System.err.println("Error creating DATA-directory in " + homePath.toString() + " . Please check your write-permission for this folder. YaCy will now terminate.");
+ System.err.println("Error creating DATA-directory in " + dataHome.toString() + " . Please check your write-permission for this folder. YaCy will now terminate.");
System.exit(-1);
}
// setting up logging
- f = new File(homePath, "DATA/LOG/");
+ f = new File(dataHome, "DATA/LOG/");
mkdirsIfNeseccary(f);
- f = new File(homePath, "DATA/LOG/yacy.logging");
+ f = new File(dataHome, "DATA/LOG/yacy.logging");
//if (!f.exists()) try {
- FileUtils.copy(new File(homePath, "yacy.logging"), f);
+ FileUtils.copy(new File(appHome, "yacy.logging"), f);
//} catch (final IOException e){
// System.out.println("could not copy yacy.logging");
//}
try{
- Log.configureLogging(homePath, new File(homePath, "DATA/LOG/yacy.logging"));
+ Log.configureLogging(dataHome, appHome, new File(dataHome, "DATA/LOG/yacy.logging"));
} catch (final IOException e) {
- System.out.println("could not find logging properties in homePath=" + homePath);
+ System.out.println("could not find logging properties in homePath=" + dataHome);
Log.logException(e);
}
Log.logConfig("STARTUP", "YaCy version: " + yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision());
Log.logConfig("STARTUP", "Java version: " + System.getProperty("java.version", "no-java-version"));
Log.logConfig("STARTUP", "Operation system: " + System.getProperty("os.name","unknown"));
- Log.logConfig("STARTUP", "Application root-path: " + homePath);
+ Log.logConfig("STARTUP", "Application root-path: " + appHome);
+ Log.logConfig("STARTUP", "Data root-path: " + dataHome);
Log.logConfig("STARTUP", "Time zone: UTC" + DateFormatter.UTCDiffString() + "; UTC+0000 is " + System.currentTimeMillis());
Log.logConfig("STARTUP", "Maximum file system path length: " + OS.maxPathLength);
- f = new File(homePath, "DATA/yacy.running");
+ f = new File(dataHome, "DATA/yacy.running");
if (f.exists()) { // another instance running? VM crash? User will have to care about this
Log.logSevere("STARTUP", "WARNING: the file " + f + " exists, this usually means that a YaCy instance is still running");
delete(f);
@@ -215,13 +216,13 @@ public final class yacy {
final String oldconf = "DATA/SETTINGS/httpProxy.conf".replace("/", File.separator);
final String newconf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);
- final File oldconffile = new File(homePath, oldconf);
+ final File oldconffile = new File(dataHome, oldconf);
if (oldconffile.exists()) {
- final File newconfFile = new File(homePath, newconf);
+ final File newconfFile = new File(dataHome, newconf);
if(!oldconffile.renameTo(newconfFile))
Log.logSevere("STARTUP", "WARNING: the file " + oldconffile + " can not be renamed to "+ newconfFile +"!");
}
- sb = new Switchboard(homePath, "defaults/yacy.init".replace("/", File.separator), newconf);
+ sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), newconf);
//sbSync.V(); // signal that the sb reference was set
// save information about available memory at startup time
@@ -247,15 +248,16 @@ public final class yacy {
//sb.setConfig("version", Double.toString(version));
//sb.setConfig("vString", yacyVersion.combined2prettyVersion(Double.toString(version)));
//sb.setConfig("vdate", (vDATE.startsWith("@")) ? DateFormatter.formatShortDay() : vDATE);
- sb.setConfig("applicationRoot", homePath.toString());
+ sb.setConfig("applicationRoot", appHome.toString());
+ sb.setConfig("dataRoot", dataHome.toString());
yacyVersion.latestRelease = version;
// read environment
final int timeout = Math.max(5000, Integer.parseInt(sb.getConfig("httpdTimeout", "5000")));
// create some directories
- final File htRootPath = new File(homePath, sb.getConfig("htRootPath", "htroot"));
- final File htDocsPath = sb.getConfigPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
+ final File htRootPath = new File(appHome, sb.getConfig("htRootPath", "htroot"));
+ final File htDocsPath = sb.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);
mkdirIfNeseccary(htDocsPath);
//final File htTemplatePath = new File(homePath, sb.getConfig("htTemplatePath","htdocs"));
@@ -334,8 +336,8 @@ public final class yacy {
Tray.lockBrowserPopup = false;
// Copy the shipped locales into DATA, existing files are overwritten
- final File locale_work = sb.getConfigPath("locale.work", "DATA/LOCALE/locales");
- final File locale_source = sb.getConfigPath("locale.source", "locales");
+ final File locale_work = sb.getDataPath("locale.work", "DATA/LOCALE/locales");
+ final File locale_source = sb.getAppPath("locale.source", "locales");
try{
final File[] locale_source_files = locale_source.listFiles();
mkdirsIfNeseccary(locale_work);
@@ -357,7 +359,7 @@ public final class yacy {
if (!lang.equals("") && !lang.equals("default")) { //locale is used
String currentRev = "";
try{
- final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(sb.getConfigPath("locale.translated_html", "DATA/LOCALE/htroot"), lang+"/version" ))));
+ final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(sb.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), lang+"/version" ))));
currentRev = br.readLine();
br.close();
}catch(final IOException e){
@@ -366,7 +368,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 destDir = new File(sb.getConfigPath("locale.translated_html", "DATA/LOCALE/htroot"), lang);
+ final File destDir = new File(sb.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), lang);
if (translator.translateFilesRecursive(sourceDir, destDir, new File(locale_work, lang + ".lng"), "html,template,inc", "locale")){ //translate it
//write the new Versionnumber
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
@@ -517,16 +519,6 @@ public final class yacy {
return config;
}
- public static void shutdown(String reason) {
- if (sb != null) {
- // YaCy is running in the same runtime. we can shutdown via interrupt
- sb.terminate(reason);
- } else {
- final File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/'));
- shutdown(applicationRoot);
- }
- }
-
/**
* Call the shutdown-page of YaCy to tell it to shut down. This method is
* called if you start yacy with the argument -shutdown.
@@ -654,11 +646,11 @@ public final class yacy {
* @param homePath path to the YaCy directory
* @param networkName
*/
- public static void minimizeUrlDB(final File homePath, final String networkName) {
+ public static void minimizeUrlDB(final File dataHome, final File appHome, final String networkName) {
// run with "java -classpath classes yacy -minimizeUrlDB"
- try {Log.configureLogging(homePath, new File(homePath, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
- final File indexPrimaryRoot = new File(homePath, "DATA/INDEX");
- final File indexRoot2 = new File(homePath, "DATA/INDEX2");
+ try {Log.configureLogging(dataHome, appHome, new File(dataHome, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
+ final File indexPrimaryRoot = new File(dataHome, "DATA/INDEX");
+ final File indexRoot2 = new File(dataHome, "DATA/INDEX2");
final Log log = new Log("URL-CLEANUP");
try {
log.logInfo("STARTING URL CLEANUP");
@@ -846,23 +838,23 @@ public final class yacy {
*
* @param homePath Root-Path where all information is to be found.
*/
- private static void urldbcleanup(final File homePath, final String networkName) {
- final File root = homePath;
+ private static void urldbcleanup(final File dataHome, final File appHome, final String networkName) {
+ final File root = dataHome;
final File indexroot = new File(root, "DATA/INDEX");
- try {Log.configureLogging(homePath, new File(homePath, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
+ try {Log.configureLogging(dataHome, appHome, new File(dataHome, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
final MetadataRepository currentUrlDB = new MetadataRepository(new File(new File(indexroot, networkName), "TEXT"), "text.urlmd", false, false);
currentUrlDB.deadlinkCleaner();
currentUrlDB.close();
}
- private static void RWIHashList(final File homePath, final String targetName, final String resource, final String format) {
+ private static void RWIHashList(final File dataHome, final File appHome, final String targetName, final String resource, final String format) {
Segment WordIndex = null;
final Log log = new Log("HASHLIST");
- final File indexPrimaryRoot = new File(homePath, "DATA/INDEX");
+ final File indexPrimaryRoot = new File(dataHome, "DATA/INDEX");
final String wordChunkStartHash = "AAAAAAAAAAAA";
- try {Log.configureLogging(homePath, new File(homePath, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
+ try {Log.configureLogging(dataHome, appHome, new File(dataHome, "DATA/LOG/yacy.logging"));} catch (final Exception e) {}
log.logInfo("STARTING CREATION OF RWI-HASHLIST");
- final File root = homePath;
+ final File root = dataHome;
try {
Iterator<ReferenceContainer<WordReference>> indexContainerIterator = null;
if (resource.equals("all")) {
@@ -985,16 +977,20 @@ public final class yacy {
System.setProperty("java.awt.headless", "true");
}
+ System.out.print(">"); for (String a: args) System.out.print(a + " "); System.out.println();
+
File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/'));
+ File dataRoot = applicationRoot;
//System.out.println("args.length=" + args.length);
//System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]");
- if ((args.length >= 1) && ((args[0].toLowerCase().equals("-startup")) || (args[0].equals("-start")))) {
+ if ((args.length >= 1) && (args[0].toLowerCase().equals("-startup") || args[0].equals("-start"))) {
// normal start-up of yacy
- if (args.length == 2) applicationRoot= new File(args[1]);
- startup(applicationRoot, startupMemFree, startupMemTotal, false);
+ if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
+ startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
} else if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) {
// start-up of yacy with gui
- startup(applicationRoot, startupMemFree, startupMemTotal, true);
+ if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
+ startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true);
} else if ((args.length >= 1) && ((args[0].toLowerCase().equals("-shutdown")) || (args[0].equals("-stop")))) {
// normal shutdown of yacy
if (args.length == 2) applicationRoot= new File(args[1]);
@@ -1010,7 +1006,7 @@ public final class yacy {
args = shift(args, 1, 2);
}
if (args.length == 2) applicationRoot= new File(args[1]);
- minimizeUrlDB(applicationRoot, "freeworld");
+ minimizeUrlDB(dataRoot, applicationRoot, "freeworld");
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-testpeerdb"))) {
if (args.length == 2) {
applicationRoot = new File(args[1]);
@@ -1038,7 +1034,7 @@ public final class yacy {
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-urldbcleanup"))) {
// generate a url list and save it in a file
if (args.length == 2) applicationRoot= new File(args[1]);
- urldbcleanup(applicationRoot, "freeworld");
+ urldbcleanup(dataRoot, applicationRoot, "freeworld");
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-rwihashlist"))) {
// generate a url list and save it in a file
String domain = "all";
@@ -1047,10 +1043,10 @@ public final class yacy {
if (args.length >= 3) format= args[2];
if (args.length == 4) applicationRoot= new File(args[3]);
final String outfile = "rwihashlist_" + System.currentTimeMillis();
- RWIHashList(applicationRoot, outfile, domain, format);
+ RWIHashList(dataRoot, applicationRoot, outfile, domain, format);
} else {
if (args.length == 1) applicationRoot= new File(args[0]);
- startup(applicationRoot, startupMemFree, startupMemTotal, false);
+ startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
}
}
}