Skip to content

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

moved logging partially to kelondro

orbiter94110df85a99
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index 0dc175eab..ccc706135 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -42,8 +42,8 @@ import de.anomic.data.userDB;
import de.anomic.data.blogBoard.BlogEntry;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
@@ -169,7 +169,7 @@ public class BlogComments {
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");
try {
- serverFileUtils.copy(notifierSource, notifierDest);
+ FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
Log.logSevere("MESSAGE", "NEW MESSAGE ARRIVED! (error: " + e.getMessage() + ")");
diff --git a/htroot/CacheResource_p.java b/htroot/CacheResource_p.java
index 272b56ba8..ff3441c6d 100644
--- a/htroot/CacheResource_p.java
+++ b/htroot/CacheResource_p.java
@@ -28,9 +28,9 @@ import java.io.File;
import java.io.IOException;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -49,7 +49,7 @@ public class CacheResource_p {
byte[] resource;
try {
- resource = serverFileUtils.read(f);
+ resource = FileUtils.read(f);
prop.put("resource", resource);
} catch (final IOException e) {
prop.put("resource", new byte[0]);
diff --git a/htroot/ConfigAppearance_p.java b/htroot/ConfigAppearance_p.java
index b41b7340f..2c5efcd0d 100644
--- a/htroot/ConfigAppearance_p.java
+++ b/htroot/ConfigAppearance_p.java
@@ -38,11 +38,10 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.data.listManager;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyURL;
public class ConfigAppearance_p {
@@ -65,7 +64,7 @@ public class ConfigAppearance_p {
// normally only invoked at first start of YaCy
if (skinFiles.size() == 0) {
try {
- serverFileUtils.copy(new File(env.getRootPath(), "htroot/env/style.css"), new File(skinPath, "default.css"));
+ FileUtils.copy(new File(env.getRootPath(), "htroot/env/style.css"), new File(skinPath, "default.css"));
env.setConfig("currentSkin", "default");
} catch (final IOException e) {
e.printStackTrace();
@@ -92,7 +91,7 @@ public class ConfigAppearance_p {
final yacyURL u = new yacyURL(url, null);
final httpRequestHeader reqHeader = new httpRequestHeader();
reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
- skinVector = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
+ skinVector = FileUtils.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
} catch (final IOException e) {
prop.put("status", "1");// unable to get URL
prop.put("status_url", url);
@@ -161,7 +160,7 @@ public class ConfigAppearance_p {
styleFile.getParentFile().mkdirs();
try {
- serverFileUtils.copy(skinFile, styleFile);
+ FileUtils.copy(skinFile, styleFile);
sb.setConfig("currentSkin", skin.substring(0, skin.length() - 4));
return true;
} catch (final IOException e) {
diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.java
index fff681e8b..1ecb89235 100644
--- a/htroot/ConfigLanguage_p.java
+++ b/htroot/ConfigLanguage_p.java
@@ -41,9 +41,9 @@ import de.anomic.data.listManager;
import de.anomic.data.translator;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyURL;
@@ -81,7 +81,7 @@ public class ConfigLanguage_p {
final yacyURL u = new yacyURL(url, null);
final httpRequestHeader reqHeader = new httpRequestHeader();
reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
- langVector = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
+ langVector = FileUtils.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
}catch(final IOException e){
prop.put("status", "1");//unable to get url
prop.put("status_url", url);
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index 660598b0e..00aba0211 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -30,11 +30,11 @@ import java.util.HashSet;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverBusyThread;
import de.anomic.server.serverCodings;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -48,7 +48,7 @@ public class ConfigNetwork_p {
// load all options for network definitions
final File networkBootstrapLocationsFile = new File(new File(sb.getRootPath(), "defaults"), "yacy.networks");
- final HashSet<String> networkBootstrapLocations = serverFileUtils.loadList(networkBootstrapLocationsFile);
+ final HashSet<String> networkBootstrapLocations = FileUtils.loadList(networkBootstrapLocationsFile);
if (post != null) {
diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java
index 24d0fb638..3881fa628 100644
--- a/htroot/IndexCreateIndexingQueue_p.java
+++ b/htroot/IndexCreateIndexingQueue_p.java
@@ -30,11 +30,11 @@ import java.util.Iterator;
import de.anomic.crawler.IndexingStack;
import de.anomic.crawler.ZURL;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.util.MemoryControl;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
@@ -123,7 +123,7 @@ public class IndexCreateIndexingQueue_p {
prop.put("indexing-queue_list_"+entryCount+"_modified", pcentry.getModificationDate().toString());
prop.putHTML("indexing-queue_list_"+entryCount+"_anchor", (pcentry.anchorName()==null)?"":pcentry.anchorName());
prop.putHTML("indexing-queue_list_"+entryCount+"_url", pcentry.url().toNormalform(false, true));
- prop.put("indexing-queue_list_"+entryCount+"_size", MemoryControl.bytesToString(entrySize));
+ prop.put("indexing-queue_list_"+entryCount+"_size", Formatter.bytesToString(entrySize));
prop.put("indexing-queue_list_"+entryCount+"_inProcess", inProcess ? "1" :"0");
prop.put("indexing-queue_list_"+entryCount+"_inProcess_hash", pcentry.urlHash());
dark = !dark;
@@ -133,7 +133,7 @@ public class IndexCreateIndexingQueue_p {
prop.putNum("indexing-queue_show", entryCount);//show shown entries
prop.putNum("indexing-queue_num", totalCount); //num entries in queue
- prop.put("indexing-queue_totalSize", MemoryControl.bytesToString(totalSize));//num entries in queue
+ prop.put("indexing-queue_totalSize", Formatter.bytesToString(totalSize));//num entries in queue
prop.putNum("indexing-queue_list", entryCount);
}
diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java
index ea75e575e..212977893 100644
--- a/htroot/IndexTransfer_p.java
+++ b/htroot/IndexTransfer_p.java
@@ -35,10 +35,10 @@ import java.util.NoSuchElementException;
import java.util.TreeMap;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.util.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacyPeerSelection;
import de.anomic.yacy.yacySeed;
@@ -95,7 +95,7 @@ public final class IndexTransfer_p {
prop.putNum("running_twEntityCount", sb.transferIdxThread.getTransferedContainerCount());
prop.putNum("running_twEntryCount", sb.transferIdxThread.getTransferedEntryCount());
- prop.put("running_twPayloadSize", MemoryControl.bytesToString(sb.transferIdxThread.getTransferedBytes()));
+ prop.put("running_twPayloadSize", Formatter.bytesToString(sb.transferIdxThread.getTransferedBytes()));
prop.putNum("running_twEntityPercent", sb.transferIdxThread.getTransferedContainerPercent());
prop.putNum("running_twEntrySpeed", sb.transferIdxThread.getTransferedEntrySpeed());
diff --git a/htroot/Messages_p.java b/htroot/Messages_p.java
index e37210eed..ab477538d 100644
--- a/htroot/Messages_p.java
+++ b/htroot/Messages_p.java
@@ -35,8 +35,8 @@ import java.util.TreeMap;
import de.anomic.data.messageBoard;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.order.DateFormatter;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacySeed;
@@ -96,7 +96,7 @@ public class Messages_p {
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");
try {
- serverFileUtils.copy(notifierSource, notifierDest);
+ FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
}
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index 0a8beba01..1939f0815 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -35,11 +35,12 @@ import de.anomic.kelondro.table.CachedRecords;
import de.anomic.kelondro.table.EcoTable;
import de.anomic.kelondro.table.FlexTable;
import de.anomic.kelondro.util.MemoryControl;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDomains;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.tools.Formatter;
public class PerformanceMemory_p {
@@ -51,7 +52,7 @@ public class PerformanceMemory_p {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
if (defaultSettings == null) {
- defaultSettings = serverFileUtils.loadHashMap(new File(env.getRootPath(), "defaults/yacy.init"));
+ defaultSettings = FileUtils.loadMap(new File(env.getRootPath(), "defaults/yacy.init"));
}
prop.put("gc", "0");
@@ -104,7 +105,7 @@ public class PerformanceMemory_p {
prop.put("TableList_" + c + "_tableIndexPath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
prop.put("TableList_" + c + "_tableIndexChunkSize", map.get("tableIndexChunkSize"));
prop.putNum("TableList_" + c + "_tableIndexCount", map.get("tableIndexCount"));
- prop.put("TableList_" + c + "_tableIndexMem", MemoryControl.bytesToString(mem));
+ prop.put("TableList_" + c + "_tableIndexMem", Formatter.bytesToString(mem));
c++;
}
prop.put("TableList", c);
@@ -122,12 +123,12 @@ public class PerformanceMemory_p {
mem = Long.parseLong(map.get("tableKeyMem"));
totalmem += mem;
- prop.put("EcoList_" + c + "_tableKeyMem", MemoryControl.bytesToString(mem));
+ prop.put("EcoList_" + c + "_tableKeyMem", Formatter.bytesToString(mem));
prop.put("EcoList_" + c + "_tableKeyChunkSize", map.get("tableKeyChunkSize"));
mem = Long.parseLong(map.get("tableValueMem"));
totalmem += mem;
- prop.put("EcoList_" + c + "_tableValueMem", MemoryControl.bytesToString(mem));
+ prop.put("EcoList_" + c + "_tableValueMem", Formatter.bytesToString(mem));
prop.put("EcoList_" + c + "_tableValueChunkSize", map.get("tableValueChunkSize"));
c++;
@@ -147,7 +148,7 @@ public class PerformanceMemory_p {
prop.put("NodeList_" + c + "_nodeCachePath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
prop.put("NodeList_" + c + "_nodeChunkSize", map.get("nodeChunkSize"));
prop.putNum("NodeList_" + c + "_nodeCacheCount", map.get("nodeCacheCount"));
- prop.put("NodeList_" + c + "_nodeCacheMem", MemoryControl.bytesToString(mem));
+ prop.put("NodeList_" + c + "_nodeCacheMem", Formatter.bytesToString(mem));
prop.putNum("NodeList_" + c + "_nodeCacheReadHit", map.get("nodeCacheReadHit"));
prop.putNum("NodeList_" + c + "_nodeCacheReadMiss", map.get("nodeCacheReadMiss"));
prop.putNum("NodeList_" + c + "_nodeCacheWriteUnique", map.get("nodeCacheWriteUnique"));
@@ -175,7 +176,7 @@ public class PerformanceMemory_p {
totalhitmem += hitmem;
prop.put("ObjectList_" + c + "_objectHitChunkSize", map.get("objectHitChunkSize"));
prop.putNum("ObjectList_" + c + "_objectHitCacheCount", map.get("objectHitCacheCount"));
- prop.put("ObjectList_" + c + "_objectHitCacheMem", MemoryControl.bytesToString(hitmem));
+ prop.put("ObjectList_" + c + "_objectHitCacheMem", Formatter.bytesToString(hitmem));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadHit", map.get("objectHitCacheReadHit"));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadMiss", map.get("objectHitCacheReadMiss"));
prop.putNum("ObjectList_" + c + "_objectHitCacheWriteUnique", map.get("objectHitCacheWriteUnique"));
@@ -188,7 +189,7 @@ public class PerformanceMemory_p {
totalmissmem += missmem;
prop.put("ObjectList_" + c + "_objectMissChunkSize", map.get("objectMissChunkSize"));
prop.putNum("ObjectList_" + c + "_objectMissCacheCount", map.get("objectMissCacheCount"));
- prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", MemoryControl.bytesToString(missmem));
+ prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", Formatter.bytesToString(missmem));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadHit", map.get("objectMissCacheReadHit"));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadMiss", map.get("objectMissCacheReadMiss"));
prop.putNum("ObjectList_" + c + "_objectMissCacheWriteUnique", map.get("objectMissCacheWriteUnique"));
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 118374727..d98ac13c9 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -30,16 +30,16 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverBusyThread;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.serverSystem;
import de.anomic.server.serverThread;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
public class PerformanceQueues_p {
/**
@@ -76,7 +76,7 @@ public class PerformanceQueues_p {
}
}
}
- final Map<String, String> defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : serverFileUtils.loadHashMap(defaultSettingsFile);
+ final Map<String, String> defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : FileUtils.loadMap(defaultSettingsFile);
Iterator<String> threads = switchboard.threadNames();
String threadName;
serverBusyThread thread;
@@ -130,7 +130,7 @@ public class PerformanceQueues_p {
}
prop.putHTML("table_" + c + "_longdescr", thread.getLongDescription());
queuesize = thread.getJobCount();
- prop.put("table_" + c + "_queuesize", (queuesize == Integer.MAX_VALUE) ? "unlimited" : yFormatter.number(queuesize, !xml));
+ prop.put("table_" + c + "_queuesize", (queuesize == Integer.MAX_VALUE) ? "unlimited" : Formatter.number(queuesize, !xml));
blocktime = thread.getBlockTime();
sleeptime = thread.getSleepTime();
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 137347729..1c655d747 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -45,12 +45,12 @@ import de.anomic.http.httpdProxyHandler;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.order.Digest;
-import de.anomic.kelondro.util.MemoryControl;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedUploader;
@@ -559,8 +559,8 @@ public class SettingsAck_p {
// everything is ok
prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :DateFormatter.formatInterval(crawlerTimeout));
- prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":MemoryControl.bytesToString(maxHttpSize));
- prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":MemoryControl.bytesToString(maxFtpSize));
+ prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":Formatter.bytesToString(maxHttpSize));
+ prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":Formatter.bytesToString(maxFtpSize));
prop.put("info", "28");
return prop;
}
diff --git a/htroot/Status.java b/htroot/Status.java
index 324f1733d..8172b785f 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -42,7 +42,7 @@ import de.anomic.server.serverDomains;
import de.anomic.server.serverObjects;
import de.anomic.server.serverProcessor;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyVersion;
@@ -130,7 +130,7 @@ public class Status {
// free disk space
if ((adminaccess) && (!sb.observer.getDisksOK()))
{
- final String minFree = MemoryControl.bytesToString(sb.observer.getMinFreeDiskSpace());
+ final String minFree = Formatter.bytesToString(sb.observer.getMinFreeDiskSpace());
prop.put("warningDiskSpaceLow", "1");
prop.put("warningDiskSpaceLow_minSpace", minFree);
}
@@ -191,9 +191,9 @@ public class Status {
prop.putNum("peerStatistics_pagesperminute", sb.webIndex.seedDB.mySeed().getPPM());
prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * sb.webIndex.seedDB.mySeed().getQPM()) / 100d);
prop.putNum("peerStatistics_links", sb.webIndex.seedDB.mySeed().getLinkCount());
- prop.put("peerStatistics_words", yFormatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.ICOUNT, "0")));
+ prop.put("peerStatistics_words", Formatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.ICOUNT, "0")));
prop.putNum("peerStatistics_disconnects", sb.webIndex.peerActions.disconnects);
- prop.put("peerStatistics_connects", yFormatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.CCOUNT, "0")));
+ prop.put("peerStatistics_connects", Formatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.CCOUNT, "0")));
thisHash = sb.webIndex.seedDB.mySeed().hash;
if (sb.webIndex.seedDB.mySeed().getPublicAddress() == null) {
prop.put("peerAddress", "0"); // not assigned + instructions
@@ -271,15 +271,15 @@ public class Status {
}
// memory usage and system attributes
- prop.put("freeMemory", MemoryControl.bytesToString(MemoryControl.free()));
- prop.put("totalMemory", MemoryControl.bytesToString(MemoryControl.total()));
- prop.put("maxMemory", MemoryControl.bytesToString(MemoryControl.max()));
+ prop.put("freeMemory", Formatter.bytesToString(MemoryControl.free()));
+ prop.put("totalMemory", Formatter.bytesToString(MemoryControl.total()));
+ prop.put("maxMemory", Formatter.bytesToString(MemoryControl.max()));
prop.put("processors", serverProcessor.availableCPU);
// proxy traffic
//prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));
- prop.put("trafficProxy", MemoryControl.bytesToString(httpdByteCountOutputStream.getAccountCount("PROXY")));
- prop.put("trafficCrawler", MemoryControl.bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));
+ prop.put("trafficProxy", Formatter.bytesToString(httpdByteCountOutputStream.getAccountCount("PROXY")));
+ prop.put("trafficCrawler", Formatter.bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));
// connection information
final serverCore httpd = (serverCore) sb.getThread("10_httpd");
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.java
index f3c284276..8193e9002 100644
--- a/htroot/Threaddump_p.java
+++ b/htroot/Threaddump_p.java
@@ -39,8 +39,8 @@ import java.util.HashMap;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.nxTools;
@@ -226,7 +226,7 @@ public class Threaddump_p {
// find class
if (!file.exists()) return "";
try {
- final String lineString = nxTools.line(serverFileUtils.read(file), line);
+ final String lineString = nxTools.line(FileUtils.read(file), line);
if (lineString == null) return "@ERROR";
return lineString;
} catch (final IOException e) {
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index 21cfef6c2..06fc45971 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -41,13 +41,13 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpResponseHeader;
import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexURLReference;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyURL;
@@ -219,7 +219,7 @@ public class ViewFile {
// TODO: how to handle very large files here ?
String content;
try {
- content = new String(serverFileUtils.read(resource), "UTF-8");
+ content = new String(FileUtils.read(resource), "UTF-8");
} catch (final Exception e) {
prop.put("error", "4");
prop.putHTML("error_errorText", e.getMessage());
diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java
index a95a49021..3fc7f3e0c 100644
--- a/htroot/ViewImage.java
+++ b/htroot/ViewImage.java
@@ -31,9 +31,9 @@ import java.util.HashMap;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyURL;
@@ -91,7 +91,7 @@ public class ViewImage {
if (urlString.endsWith(".ico")) {
// load default favicon dfltfvcn.ico
try {
- imgb = serverFileUtils.read(new File(sb.getRootPath(), defaulticon));
+ imgb = FileUtils.read(new File(sb.getRootPath(), defaulticon));
} catch (final IOException e) {
return null;
}
@@ -104,7 +104,7 @@ public class ViewImage {
// read image data
try {
- imgb = serverFileUtils.read(imgStream);
+ imgb = FileUtils.read(imgStream);
} catch (final IOException e) {
return null;
} finally {
diff --git a/htroot/WatchCrawler_p.java b/htroot/WatchCrawler_p.java
index 78576ff8c..6417de0be 100644
--- a/htroot/WatchCrawler_p.java
+++ b/htroot/WatchCrawler_p.java
@@ -45,9 +45,9 @@ import de.anomic.data.listManager;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyNewsPool;
@@ -329,7 +329,7 @@ public class WatchCrawler_p {
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(new yacyURL(file));
//OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
final Writer writer = new htmlFilterWriter(null,null,scraper,null,false);
- serverFileUtils.copy(fileString, writer);
+ FileUtils.copy(fileString, writer);
writer.close();
//String headline = scraper.getHeadline();
diff --git a/htroot/api/util/getpageinfo_p.java b/htroot/api/util/getpageinfo_p.java
index 883bbb1c0..e22c39344 100755
--- a/htroot/api/util/getpageinfo_p.java
+++ b/htroot/api/util/getpageinfo_p.java
@@ -9,8 +9,8 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyURL;
@@ -55,7 +55,7 @@ public class getpageinfo_p {
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(u);
//OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
final Writer writer = new htmlFilterWriter(null,null,scraper,null,false);
- serverFileUtils.copy(contentString,writer);
+ FileUtils.copy(contentString,writer);
writer.close();
// put the document title
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index b6ee983b6..0b1f33171 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -43,10 +43,10 @@ import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.nxTools;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
@@ -139,7 +139,7 @@ public class sharedBlacklist_p {
// get List
yacyURL u = new yacyURL(downloadURLOld, null);
- otherBlacklist = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 1000), "UTF-8");
+ otherBlacklist = FileUtils.strings(HttpClient.wget(u.toString(), reqHeader, 1000), "UTF-8");
} catch (final Exception e) {
prop.put("status", STATUS_PEER_UNKNOWN);
prop.putHTML("status_name", Hash);
@@ -158,7 +158,7 @@ public class sharedBlacklist_p {
final yacyURL u = new yacyURL(downloadURL, null);
final httpRequestHeader reqHeader = new httpRequestHeader();
reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
- otherBlacklist = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8"); //get List
+ otherBlacklist = FileUtils.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8"); //get List
} catch (final Exception e) {
prop.put("status", STATUS_URL_PROBLEM);
prop.putHTML("status_address",downloadURL);
@@ -175,7 +175,7 @@ public class sharedBlacklist_p {
if (fileString != null) {
try {
- otherBlacklist = nxTools.strings(fileString.getBytes("UTF-8"), "UTF-8");
+ otherBlacklist = FileUtils.strings(fileString.getBytes("UTF-8"), "UTF-8");
} catch (IOException ex) {
prop.put("status", STATUS_FILE_ERROR);
}
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 15deb11c9..e33c3b910 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -37,8 +37,8 @@ import java.util.Date;
import de.anomic.data.messageBoard;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
@@ -142,7 +142,7 @@ public final class message {
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");
try {
- serverFileUtils.copy(notifierSource, notifierDest);
+ FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
Log.logSevere("MESSAGE", "NEW MESSAGE ARRIVED! (error: " + e.getMessage() + ")");
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index d3e98d422..b7534c297 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -30,9 +30,9 @@ import java.io.IOException;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Digest;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaRankingDistribution;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyNetwork;
@@ -119,7 +119,7 @@ public final class transfer {
final File file = new File(path, filename);
try {
if (file.getCanonicalPath().startsWith(path.getCanonicalPath())){
- serverFileUtils.copy(fileString.getBytes(), file);
+ FileUtils.copy(fileString.getBytes(), file);
final String md5t = Digest.encodeMD5Hex(file);
if (md5t.equals(md5)) {
prop.put("response", "ok");
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index 2d2bdd7b7..4271934a9 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -34,13 +34,13 @@ import java.util.List;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexReferenceBlacklist;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.kelondro.util.Log;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.nxTools;
import de.anomic.xml.RSSFeed;
import de.anomic.xml.RSSMessage;
import de.anomic.yacy.yacyCore;
@@ -119,7 +119,7 @@ public final class transferRWI {
final long startProcess = System.currentTimeMillis();
// decode request
- final List<String> v = nxTools.strings(indexes, null);
+ final List<String> v = FileUtils.strings(indexes, null);
// free memory
indexes = null;
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index c7536e6d2..2e6e0a7ea 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -52,7 +52,7 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverProfiling;
import de.anomic.server.serverSwitch;
import de.anomic.tools.iso639;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
import de.anomic.xml.RSSFeed;
import de.anomic.xml.RSSMessage;
import de.anomic.yacy.yacyNewsPool;
@@ -408,12 +408,12 @@ public class yacysearch {
prop.put("num-results_offset", offset);
prop.put("num-results_itemscount", "0");
prop.put("num-results_itemsPerPage", itemsPerPage);
- prop.put("num-results_totalcount", yFormatter.number(totalcount, true));
+ prop.put("num-results_totalcount", Formatter.number(totalcount, true));
prop.put("num-results_globalresults", (globalsearch) ? "1" : "0");
- prop.put("num-results_globalresults_localResourceSize", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize(), true));
- prop.put("num-results_globalresults_remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));
- prop.put("num-results_globalresults_remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));
- prop.put("num-results_globalresults_remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
+ prop.put("num-results_globalresults_localResourceSize", Formatter.number(theSearch.getRankingResult().getLocalResourceSize(), true));
+ prop.put("num-results_globalresults_remoteResourceSize", Formatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));
+ prop.put("num-results_globalresults_remoteIndexCount", Formatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));
+ prop.put("num-results_globalresults_remotePeerCount", Formatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
// compose page navigation
final StringBuilder resnav = new StringBuilder();
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index dc54c707c..4c024f57a 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -42,7 +42,7 @@ import de.anomic.server.serverProfiling;
import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
import de.anomic.tools.nxTools;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
@@ -83,11 +83,11 @@ public class yacysearchitem {
final int offset = theQuery.neededResults() - theQuery.displayResults() + 1;
prop.put("offset", offset);
prop.put("itemscount", (item < 0) ? theQuery.neededResults() : item + 1);
- prop.put("totalcount", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize(), true));
- prop.put("localResourceSize", yFormatter.number(theSearch.getRankingResult().getLocalResourceSize(), true));
- prop.put("remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));
- prop.put("remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));
- prop.put("remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
+ prop.put("totalcount", Formatter.number(theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize(), true));
+ prop.put("localResourceSize", Formatter.number(theSearch.getRankingResult().getLocalResourceSize(), true));
+ prop.put("remoteResourceSize", Formatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));
+ prop.put("remoteIndexCount", Formatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));
+ prop.put("remotePeerCount", Formatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_TEXT) {
// text search
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index 98b9b4b53..d020d5f54 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -51,7 +51,7 @@ import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.util.ByteBuffer;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyURL;
public class RobotsTxt {
@@ -553,7 +553,7 @@ public class RobotsTxt {
// downloading the content
final ByteBuffer sbb = new ByteBuffer();
try {
- serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(sbb));
+ FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(sbb));
} finally {
res.closeStream();
}
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index de7a8b20d..4634e3da7 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -72,9 +72,9 @@ import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverBusyThread;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverInstantBusyThread;
import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacyNewsRecord;
@@ -781,7 +781,7 @@ public class bookmarksDB {
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL);
//OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
final Writer writer= new htmlFilterWriter(null,null,scraper, null, false);
- serverFileUtils.copy(input,writer);
+ FileUtils.copy(input,writer);
writer.close();
links = scraper.getAnchors();
} catch (final IOException e) { Log.logWarning("BOOKMARKS", "error during load of links: "+ e.getClass() +" "+ e.getMessage());}
diff --git a/source/de/anomic/data/translator.java b/source/de/anomic/data/translator.java
index 1109c8d4f..cf460b4b6 100644
--- a/source/de/anomic/data/translator.java
+++ b/source/de/anomic/data/translator.java
@@ -50,7 +50,7 @@ import java.util.regex.Pattern;
import de.anomic.kelondro.util.Log;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
/**
* Wordlist based translator
@@ -248,7 +248,7 @@ public class translator {
if(translator.translateFilesRecursive(sourceDir, destDir,
translationFile, "html,template,inc", "locale")){
env.setConfig("locale.language", lang.substring(0, lang.length() - 4));
- yFormatter.setLocale(env.getConfig("locale.language", "en"));
+ Formatter.setLocale(env.getConfig("locale.language", "en"));
try {
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
bw.write(env.getConfig("svnRevision", "Error getting Version"));
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
index 2953cdfef..7a739ad03 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
@@ -46,9 +46,9 @@ import javax.swing.event.EventListenerList;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParser;
import de.anomic.server.serverCharBuffer;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
import de.anomic.tools.iso639;
@@ -483,7 +483,7 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
public static htmlFilterContentScraper parseResource(final File file) throws IOException {
// load page
- final byte[] page = serverFileUtils.read(file);
+ final byte[] page = FileUtils.read(file);
if (page == null) throw new IOException("no content in file " + file.toString());
// scrape document to look up charset
@@ -493,7 +493,7 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
// scrape content
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(new yacyURL("http://localhost", null));
final Writer writer = new htmlFilterWriter(null, null, scraper, null, false);
- serverFileUtils.copy(new ByteArrayInputStream(page), writer, Charset.forName(charset));
+ FileUtils.copy(new ByteArrayInputStream(page), writer, Charset.forName(charset));
return scraper;
}
@@ -508,7 +508,7 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
// scrape content
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(location);
final Writer writer = new htmlFilterWriter(null, null, scraper, null, false);
- serverFileUtils.copy(new ByteArrayInputStream(page), writer, Charset.forName("UTF-8"));
+ FileUtils.copy(new ByteArrayInputStream(page), writer, Charset.forName("UTF-8"));
return scraper;
}
diff --git a/source/de/anomic/http/JakartaCommonsHttpResponse.java b/source/de/anomic/http/JakartaCommonsHttpResponse.java
index 89542ccbd..e2c607e8b 100644
--- a/source/de/anomic/http/JakartaCommonsHttpResponse.java
+++ b/source/de/anomic/http/JakartaCommonsHttpResponse.java
@@ -33,7 +33,7 @@ import java.util.zip.GZIPInputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethod;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
/**
* container for http-response data
@@ -94,7 +94,7 @@ public class JakartaCommonsHttpResponse {
try {
instream = getDataAsStream();
if (instream != null) {
- responseBody = serverFileUtils.read(instream);
+ responseBody = FileUtils.read(instream);
}
} finally {
if (instream != null) {
diff --git a/source/de/anomic/http/httpChunkedOutputStream.java b/source/de/anomic/http/httpChunkedOutputStream.java
index 3e4ef17df..c458ad3f2 100644
--- a/source/de/anomic/http/httpChunkedOutputStream.java
+++ b/source/de/anomic/http/httpChunkedOutputStream.java
@@ -30,8 +30,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import de.anomic.kelondro.util.ByteBuffer;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
public final class httpChunkedOutputStream extends FilterOutputStream {
private boolean finished = false;
@@ -95,7 +95,7 @@ public final class httpChunkedOutputStream extends FilterOutputStream {
this.out.write(Integer.toHexString(len).getBytes());
this.out.write(serverCore.CRLF);
- serverFileUtils.copy(b, out, len);
+ FileUtils.copy(b, out, len);
this.out.write(serverCore.CRLF);
this.out.flush();
}
diff --git a/source/de/anomic/http/httpTemplate.java b/source/de/anomic/http/httpTemplate.java
index 7d8bfb7ac..efaeec8b1 100644
--- a/source/de/anomic/http/httpTemplate.java
+++ b/source/de/anomic/http/httpTemplate.java
@@ -62,7 +62,7 @@ import java.util.List;
import de.anomic.kelondro.util.ByteBuffer;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
/**
* A template engine, which substitutes patterns in strings<br>
@@ -236,7 +236,7 @@ public final class httpTemplate {
public final static void writeTemplate(final InputStream in, final OutputStream out, final HashMap<String, String> pattern, final byte[] dflt) throws IOException {
if (pattern == null) {
- serverFileUtils.copy(in, out);
+ FileUtils.copy(in, out);
} else {
writeTemplate(in, out, pattern, dflt, new byte[0]);
}
@@ -416,10 +416,10 @@ public final class httpTemplate {
structure.append(replacement);
structure.append("</".getBytes()).append(key).append(">\n".getBytes());
- serverFileUtils.copy(replacement, out);
+ FileUtils.copy(replacement, out);
} else {
// inconsistency, simply finalize this
- serverFileUtils.copy(pis, out);
+ FileUtils.copy(pis, out);
return structure.getBytes();
}
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index aba18cf9f..ea3a7dae5 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -67,11 +67,11 @@ import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.ByteBuffer;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverHandler;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -751,7 +751,7 @@ public final class httpd implements serverHandler, Cloneable {
// parsing post request bodies which are gzip content-encoded
} else {
ByteArrayOutputStream bout = new ByteArrayOutputStream(512);
- serverFileUtils.copy(in,bout);
+ FileUtils.copy(in,bout);
buffer = bout.toByteArray();
bout.close(); bout = null;
}
@@ -924,7 +924,7 @@ public final class httpd implements serverHandler, Cloneable {
} else {
// file
args.put(item.getFieldName(), item.getName());
- final byte[] fileContent = serverFileUtils.read(item.getInputStream());
+ final byte[] fileContent = FileUtils.read(item.getInputStream());
item.getInputStream().close();
files.put(item.getFieldName(), fileContent);
}
@@ -1228,7 +1228,7 @@ public final class httpd implements serverHandler, Cloneable {
if (! method.equals(httpHeader.METHOD_HEAD)) {
// write the array to the client
- serverFileUtils.copy(result, respond);
+ FileUtils.copy(result, respond);
}
respond.flush();
} finally {
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index c0663a6af..bc009ce80 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -85,12 +85,12 @@ import de.anomic.htmlFilter.htmlFilterInputStream;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.util.ByteBuffer;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverClassLoader;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.servletProperties;
@@ -827,7 +827,7 @@ public final class httpdFileHandler {
// a byte array
templateCacheEntry = new TemplateCacheEntry();
templateCacheEntry.lastModified = targetFileDate;
- templateCacheEntry.content = serverFileUtils.read(targetFile);
+ templateCacheEntry.content = FileUtils.read(targetFile);
// storing the content into the cache
ref = new SoftReference<TemplateCacheEntry>(templateCacheEntry);
@@ -917,7 +917,7 @@ public final class httpdFileHandler {
httpVersion, 200, null, mimeType, result.length,
targetDate, null, (templatePatterns == null) ? new httpResponseHeader() : templatePatterns.getOutgoingHeader(),
contentEncoding, null, nocache);
- serverFileUtils.copy(result, out);
+ FileUtils.copy(result, out);
}
}
} else { // no html
@@ -935,7 +935,7 @@ public final class httpdFileHandler {
try {
if (targetMd5File.exists()) {
//String description = null;
- targetMD5 = new String(serverFileUtils.read(targetMd5File));
+ targetMD5 = new String(FileUtils.read(targetMd5File));
int pos = targetMD5.indexOf('\n');
if (pos >= 0) {
//description = targetMD5.substring(pos + 1);
@@ -991,7 +991,7 @@ public final class httpdFileHandler {
newOut = zipped;
}
- serverFileUtils.copyRange(targetFile, newOut, rangeStartOffset);
+ FileUtils.copyRange(targetFile, newOut, rangeStartOffset);
if (zipped != null) {
zipped.flush();
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index f99b12aa5..7ff317514 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -78,13 +78,13 @@ import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.yacy.yacyURL;
@@ -181,7 +181,7 @@ public final class httpdProxyHandler {
// load the yellow-list
final String f = sb.getConfig("proxyYellowList", null);
if (f != null) {
- yellowList = serverFileUtils.loadList(new File(f));
+ yellowList = FileUtils.loadList(new File(f));
theLogger.logConfig("loaded yellow-list from file " + f + ", " + yellowList.size() + " entries");
} else {
yellowList = new HashSet<String>();
@@ -554,7 +554,7 @@ public final class httpdProxyHandler {
final ByteArrayOutputStream byteStream = new ByteArrayOutputStream((l < 32) ? 32 : l);
final OutputStream toClientAndMemory = new MultiOutputStream(new OutputStream[] {outStream, byteStream});
- serverFileUtils.copy(res.getDataAsStream(), toClientAndMemory);
+ FileUtils.copy(res.getDataAsStream(), toClientAndMemory);
// cached bytes
byte[] cacheArray;
if(byteStream.size() > 0) {
@@ -590,7 +590,7 @@ public final class httpdProxyHandler {
" StoreHTCache=" + storeHTCache +
" SupportetContent=" + isSupportedContent);
- serverFileUtils.copy(res.getDataAsStream(), outStream);
+ FileUtils.copy(res.getDataAsStream(), outStream);
conProp.setProperty(httpHeader.CONNECTION_PROP_PROXY_RESPOND_CODE,"TCP_MISS");
}
@@ -701,7 +701,7 @@ public final class httpdProxyHandler {
// send also the complete body now from the cache
// simply read the file and transfer to out socket
- serverFileUtils.copy(cacheEntry, outStream);
+ FileUtils.copy(cacheEntry, outStream);
if (gzippedOut != null) gzippedOut.finish();
if (chunkedOut != null) chunkedOut.finish();
@@ -952,7 +952,7 @@ public final class httpdProxyHandler {
if (chunked != null) chunked.finish();
*/
final OutputStream outStream = (chunked != null) ? chunked : countedRespond;
- serverFileUtils.copy(res.getDataAsStream(), outStream);
+ FileUtils.copy(res.getDataAsStream(), outStream);
if (chunked != null) {
chunked.finish();
diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java
index 4648527ad..f1d1df131 100644
--- a/source/de/anomic/icap/icapd.java
+++ b/source/de/anomic/icap/icapd.java
@@ -43,11 +43,11 @@ import de.anomic.http.httpdProxyCacheEntry;
import de.anomic.index.indexDocumentMetadata;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverHandler;
import de.anomic.server.serverCore.Session;
import de.anomic.yacy.yacyURL;
@@ -389,7 +389,7 @@ public class icapd implements serverHandler, Cloneable {
// copy the response body into the file
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- serverFileUtils.copy(resBodyStream, baos);
+ FileUtils.copy(resBodyStream, baos);
if(resBodyStream != null) {
resBodyStream.close(); resBodyStream = null;
}
diff --git a/source/de/anomic/index/indexURLReference.java b/source/de/anomic/index/indexURLReference.java
index 169547f3f..6852c32ec 100644
--- a/source/de/anomic/index/indexURLReference.java
+++ b/source/de/anomic/index/indexURLReference.java
@@ -40,12 +40,12 @@ import de.anomic.kelondro.order.Bitfield;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.order.NaturalOrder;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.server.serverCharBuffer;
import de.anomic.server.serverCodings;
import de.anomic.tools.crypt;
-import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyURL;
public class indexURLReference {
@@ -342,7 +342,7 @@ public class indexURLReference {
}
public indexURLReference.Components comp() {
- final ArrayList<String> cl = nxTools.strings(this.entry.getCol("comp", null), "UTF-8");
+ final ArrayList<String> cl = FileUtils.strings(this.entry.getCol("comp", null), "UTF-8");
return new indexURLReference.Components(
(cl.size() > 0) ? (cl.get(0)).trim() : "",
hash(),
diff --git a/source/de/anomic/kelondro/index/RowCollection.java b/source/de/anomic/kelondro/index/RowCollection.java
index c5cc62009..8f6c1c806 100644
--- a/source/de/anomic/kelondro/index/RowCollection.java
+++ b/source/de/anomic/kelondro/index/RowCollection.java
@@ -41,10 +41,10 @@ import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.ByteOrder;
import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.util.MemoryControl;
+import de.anomic.kelondro.util.NamePrefixThreadFactory;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.NamePrefixThreadFactory;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.server.serverProcessor;
public class RowCollection implements Iterable<Row.Entry> {
@@ -179,7 +179,7 @@ public class RowCollection implements Iterable<Row.Entry> {
}
public void saveCollection(final File file) throws IOException {
- serverFileUtils.copy(exportCollection(), file);
+ FileUtils.copy(exportCollection(), file);
}
public Row row() {
diff --git a/source/de/anomic/kelondro/index/RowSet.java b/source/de/anomic/kelondro/index/RowSet.java
index a2e7a17a2..1ce374012 100644
--- a/source/de/anomic/kelondro/index/RowSet.java
+++ b/source/de/anomic/kelondro/index/RowSet.java
@@ -618,4 +618,5 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.E
public void deleteOnExit() {
// do nothing, there is no file
}
+
}
diff --git a/source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java b/source/de/anomic/kelondro/io/BufferedEcoFS.java
similarity index 96%
rename from source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java
rename to source/de/anomic/kelondro/io/BufferedEcoFS.java
index 963296bc5..e70ef168f 100644
--- a/source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java
+++ b/source/de/anomic/kelondro/io/BufferedEcoFS.java
@@ -37,13 +37,13 @@ import java.util.TreeMap;
* That means, each time, an entry is written to the end of the file, it is NOT buffered here,
* but possibly buffered in the enclosed kelondroEcoFS
*/
-public class kelondroBufferedEcoFS {
+public class BufferedEcoFS {
- private kelondroEcoFS efs;
+ private EcoFS efs;
private final int maxEntries;
private final TreeMap<Long, byte[]> buffer;
- public kelondroBufferedEcoFS(final kelondroEcoFS efs, final int maxEntries) {
+ public BufferedEcoFS(final EcoFS efs, final int maxEntries) {
this.efs = efs;
this.maxEntries = maxEntries;
this.buffer = new TreeMap<Long, byte[]>();
diff --git a/source/de/anomic/kelondro/io/kelondroEcoFS.java b/source/de/anomic/kelondro/io/EcoFS.java
similarity index 99%
rename from source/de/anomic/kelondro/io/kelondroEcoFS.java
rename to source/de/anomic/kelondro/io/EcoFS.java
index 620d98b3f..e22fa881f 100644
--- a/source/de/anomic/kelondro/io/kelondroEcoFS.java
+++ b/source/de/anomic/kelondro/io/EcoFS.java
@@ -48,7 +48,7 @@ import de.anomic.kelondro.util.MemoryControl;
* All access to the file is made with byte[] that are generated outside of this class
* This class only references byte[] that are handed over to methods of this class.
*/
-public class kelondroEcoFS {
+public class EcoFS {
private RandomAccessFile raf;
private final File tablefile;
@@ -71,7 +71,7 @@ public class kelondroEcoFS {
private static final int maxWriteBuffer = 256 * 1024;
- public kelondroEcoFS(final File tablefile, final int recordsize) throws IOException {
+ public EcoFS(final File tablefile, final int recordsize) throws IOException {
this.tablefile = tablefile;
this.recordsize = recordsize;
@@ -574,7 +574,7 @@ public class kelondroEcoFS {
final File f = new File(args[0]);
if (f.exists()) f.delete();
try {
- final kelondroEcoFS t = new kelondroEcoFS(f, 8);
+ final EcoFS t = new EcoFS(f, 8);
final byte[] b = new byte[8];
t.add("01234567".getBytes(), 0);
t.add("ABCDEFGH".getBytes(), 0);
diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java
index ac1c3ae90..18e7e9852 100644
--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java
+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java
@@ -59,7 +59,7 @@ import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.kelondroOutOfLimitsException;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyURL;
public class kelondroCollectionIndex {
@@ -133,7 +133,7 @@ public class kelondroCollectionIndex {
File cop = new File(path, filenameStub + "." + fillZ(Integer.toHexString(rowdef.objectsize).toUpperCase(), 4) + ".commons");
this.commonsPath = (useCommons) ? cop : null;
if (this.commonsPath == null) {
- serverFileUtils.deleteDirectory(cop);
+ FileUtils.deleteDirectory(cop);
} else {
this.commonsPath.mkdirs();
}
diff --git a/source/de/anomic/kelondro/table/EcoTable.java b/source/de/anomic/kelondro/table/EcoTable.java
index b9c71701f..d17b887e0 100644
--- a/source/de/anomic/kelondro/table/EcoTable.java
+++ b/source/de/anomic/kelondro/table/EcoTable.java
@@ -45,8 +45,8 @@ import de.anomic.kelondro.index.RowCollection;
import de.anomic.kelondro.index.RowSet;
import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.kelondro.index.Row.Entry;
-import de.anomic.kelondro.io.kelondroBufferedEcoFS;
-import de.anomic.kelondro.io.kelondroEcoFS;
+import de.anomic.kelondro.io.BufferedEcoFS;
+import de.anomic.kelondro.io.EcoFS;
import de.anomic.kelondro.order.CloneableIterator;
import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.util.MemoryControl;
@@ -76,7 +76,7 @@ public class EcoTable implements ObjectIndex {
private static final long minmemremaining = 20 * 1024 * 1024; // if less than this memory is remaininig, the memory copy of a table is abandoned
RowSet table;
BytesIntMap index;
- kelondroBufferedEcoFS file;
+ BufferedEcoFS file;
Row rowdef;
int fail;
@@ -170,7 +170,7 @@ public class EcoTable implements ObjectIndex {
// check consistency
//System.out.print(" -ordering- ..");
//System.out.flush();
- this.file = new kelondroBufferedEcoFS(new kelondroEcoFS(tablefile, rowdef.objectsize), this.buffersize);
+ this.file = new BufferedEcoFS(new EcoFS(tablefile, rowdef.objectsize), this.buffersize);
final ArrayList<Integer[]> doubles = index.removeDoubles();
//assert index.size() + doubles.size() + fail == i;
//System.out.println(" -removed " + doubles.size() + " doubles- done.");
@@ -224,7 +224,7 @@ public class EcoTable implements ObjectIndex {
public static long tableSize(final File tablefile, final int recordsize) {
// returns number of records in table
- return kelondroEcoFS.tableSize(tablefile, recordsize);
+ return EcoFS.tableSize(tablefile, recordsize);
}
public static final Iterator<String> filenames() {
@@ -551,7 +551,7 @@ public class EcoTable implements ObjectIndex {
// open an existing table file
try {
- this.file = new kelondroBufferedEcoFS(new kelondroEcoFS(f, rowdef.objectsize), this.buffersize);
+ this.file = new BufferedEcoFS(new EcoFS(f, rowdef.objectsize), this.buffersize);
} catch (final FileNotFoundException e) {
// should never happen
e.printStackTrace();
diff --git a/source/de/anomic/kelondro/table/FlexWidthArray.java b/source/de/anomic/kelondro/table/FlexWidthArray.java
index d517885d3..7e056edb3 100644
--- a/source/de/anomic/kelondro/table/FlexWidthArray.java
+++ b/source/de/anomic/kelondro/table/FlexWidthArray.java
@@ -27,7 +27,6 @@ package de.anomic.kelondro.table;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -39,7 +38,6 @@ import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
public class FlexWidthArray implements Array {
@@ -105,10 +103,11 @@ public class FlexWidthArray implements Array {
this.filename = tabledir.getCanonicalPath();
// save/check property file for this array
+ /*
final File propfile = new File(tabledir, "properties");
Map<String, String> props = new HashMap<String, String>();
if (propfile.exists()) {
- props = serverFileUtils.loadHashMap(propfile);
+ props = serverFileUtils.loadMap(propfile);
final String stored_rowdef = props.get("rowdef");
if ((stored_rowdef != null) && (!(rowdef.subsumes(new Row(stored_rowdef, rowdef.objectOrder, 0))))) {
System.out.println("FATAL ERROR: stored rowdef '" + stored_rowdef + "' does not match with new rowdef '" +
@@ -118,6 +117,7 @@ public class FlexWidthArray implements Array {
}
props.put("rowdef", rowdef.toString());
serverFileUtils.saveMap(propfile, props, "FlexWidthArray properties");
+ */
// open existing files
final String[] files = tabledir.list();
diff --git a/source/de/anomic/kelondro/table/SplitTable.java b/source/de/anomic/kelondro/table/SplitTable.java
index e15bbe188..ecc09f233 100644
--- a/source/de/anomic/kelondro/table/SplitTable.java
+++ b/source/de/anomic/kelondro/table/SplitTable.java
@@ -57,8 +57,7 @@ import de.anomic.kelondro.order.NaturalOrder;
import de.anomic.kelondro.order.MergeIterator;
import de.anomic.kelondro.order.Order;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.NamePrefixThreadFactory;
-import de.anomic.server.serverProcessor;
+import de.anomic.kelondro.util.NamePrefixThreadFactory;
public class SplitTable implements ObjectIndex {
@@ -89,7 +88,12 @@ public class SplitTable implements ObjectIndex {
public void init(final boolean resetOnFail) {
// init the thread pool for the keeperOf executor service
- this.executor = new ThreadPoolExecutor(serverProcessor.useCPU + 1, serverProcessor.useCPU + 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamePrefixThreadFactory(tablename));
+ this.executor = new ThreadPoolExecutor(
+ Runtime.getRuntime().availableProcessors() + 1,
+ Runtime.getRuntime().availableProcessors() + 1, 10,
+ TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ new NamePrefixThreadFactory(tablename));
// initialized tables map
this.tables = new HashMap<String, ObjectIndex>();
diff --git a/source/de/anomic/kelondro/table/Tree.java b/source/de/anomic/kelondro/table/Tree.java
index 5a796bb25..eb5c4e3c5 100644
--- a/source/de/anomic/kelondro/table/Tree.java
+++ b/source/de/anomic/kelondro/table/Tree.java
@@ -52,7 +52,6 @@ import de.anomic.kelondro.index.Row.Entry;
import de.anomic.kelondro.order.ByteOrder;
import de.anomic.kelondro.order.CloneableIterator;
import de.anomic.kelondro.order.NaturalOrder;
-import de.anomic.kelondro.table.CachedRecords.CacheNode;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
diff --git a/source/de/anomic/kelondro/util/AttrSeq.java b/source/de/anomic/kelondro/util/AttrSeq.java
index 18f472fc0..4c002eff1 100644
--- a/source/de/anomic/kelondro/util/AttrSeq.java
+++ b/source/de/anomic/kelondro/util/AttrSeq.java
@@ -47,7 +47,6 @@ import de.anomic.kelondro.index.Column;
import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.index.RowCollection;
import de.anomic.kelondro.order.Base64Order;
-import de.anomic.server.serverFileUtils;
public class AttrSeq {
@@ -186,9 +185,9 @@ public class AttrSeq {
sb.append((char) 13); sb.append((char) 10);
}
if (out.toString().endsWith(".gz")) {
- serverFileUtils.writeAndGZip((new String(sb)).getBytes(), out);
+ FileUtils.writeAndGZip((new String(sb)).getBytes(), out);
} else {
- serverFileUtils.copy((new String(sb)).getBytes(), out);
+ FileUtils.copy((new String(sb)).getBytes(), out);
}
}
diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/kelondro/util/FileUtils.java
similarity index 86%
rename from source/de/anomic/server/serverFileUtils.java
rename to source/de/anomic/kelondro/util/FileUtils.java
index d3d9b7e2f..671ffa19b 100644
--- a/source/de/anomic/server/serverFileUtils.java
+++ b/source/de/anomic/kelondro/util/FileUtils.java
@@ -19,7 +19,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.server;
+package de.anomic.kelondro.util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -37,15 +37,20 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.util.ArrayList;
import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
+import java.util.Vector;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
@@ -53,10 +58,8 @@ import java.util.zip.ZipOutputStream;
import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.index.RowSet;
-import de.anomic.kelondro.util.Log;
-import de.anomic.tools.nxTools;
-public final class serverFileUtils {
+public final class FileUtils {
private static final int DEFAULT_BUFFER_SIZE = 1024; // this is also the maximum chunk size
@@ -374,11 +377,11 @@ public final class serverFileUtils {
return set;
}
- public static Map<String, String> loadHashMap(final File f) {
+ public static Map<String, String> loadMap(final File f) {
// load props
try {
final byte[] b = read(f);
- return nxTools.table(nxTools.strings(b));
+ return table(strings(b));
} catch (final IOException e2) {
System.err.println("ERROR: " + f.toString() + " not found in settings path");
return null;
@@ -462,7 +465,7 @@ public final class serverFileUtils {
zos.putNextEntry(new ZipEntry(name + ".txt"));
os = zos;
}
- if(os != null) {
+ if (os != null) {
final Iterator<Row.Entry> i = set.iterator();
String key;
if (i.hasNext()) {
@@ -479,6 +482,92 @@ public final class serverFileUtils {
forceMove(tf, file);
}
+
+ public static HashMap<String, String> table(final Vector<String> list) {
+ final Enumeration<String> i = list.elements();
+ int pos;
+ String line;
+ final HashMap<String, String> props = new HashMap<String, String>(list.size());
+ while (i.hasMoreElements()) {
+ line = (i.nextElement()).trim();
+ pos = line.indexOf("=");
+ if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
+ }
+ return props;
+ }
+
+ public static HashMap<String, String> table(final byte[] a, final String encoding) {
+ return table(strings(a, encoding));
+ }
+
+ /**
+ * parse config files
+ *
+ * splits the lines in list into pairs sperarated by =, lines beginning with # are ignored
+ * ie:
+ * abc=123
+ * # comment
+ * fg=dcf
+ * => Map{abc => 123, fg => dcf}
+ * @param list
+ * @return
+ */
+ public static HashMap<String, String> table(final ArrayList<String> list) {
+ if (list == null) return new HashMap<String, String>();
+ final Iterator<String> i = list.iterator();
+ int pos;
+ String line;
+ final HashMap<String, String> props = new HashMap<String, String>(list.size());
+ while (i.hasNext()) {
+ line = (i.next()).trim();
+ if (line.startsWith("#")) continue; // exclude comments
+ //System.out.println("NXTOOLS_PROPS - LINE:" + line);
+ pos = line.indexOf("=");
+ if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
+ }
+ return props;
+ }
+
+ public static ArrayList<String> strings(final byte[] a) {
+ return strings(a, null);
+ }
+
+ public static ArrayList<String> strings(final byte[] a, final String encoding) {
+ if (a == null) return new ArrayList<String>();
+ int s = 0;
+ int e;
+ final ArrayList<String> v = new ArrayList<String>();
+ byte b;
+ while (s < a.length) {
+ // find eol
+ e = s;
+ while (e < a.length) {
+ b = a[e];
+ if ((b == 10) || (b == 13) || (b == 0)) break;
+ e++;
+ }
+
+ // read line
+ if (encoding == null) {
+ v.add(new String(a, s, e - s));
+ } else try {
+ v.add(new String(a, s, e - s, encoding));
+ } catch (final UnsupportedEncodingException xcptn) {
+ return v;
+ }
+
+ // eat up additional eol bytes
+ s = e + 1;
+ while (s < a.length) {
+ b = a[s];
+ if ((b != 10) && (b != 13)) break;
+ s++;
+ }
+ }
+ return v;
+ }
+
+
/**
* @param from
* @param to
diff --git a/source/de/anomic/kelondro/util/MemoryControl.java b/source/de/anomic/kelondro/util/MemoryControl.java
index 9fcd8514a..9fa700df8 100644
--- a/source/de/anomic/kelondro/util/MemoryControl.java
+++ b/source/de/anomic/kelondro/util/MemoryControl.java
@@ -25,7 +25,6 @@
package de.anomic.kelondro.util;
-import de.anomic.tools.yFormatter;
/**
* Use this to get information about memory usage or try to free some memory
@@ -53,7 +52,7 @@ public class MemoryControl {
System.gc();
//System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if you see this many times please report to forum");
lastGC = System.currentTimeMillis();
- if (log.isFine()) log.logInfo("[gc] before: " + bytesToString(free) + ", after: " + bytesToString(free()) + ", call: " + info);
+ if (log.isFine()) log.logInfo("[gc] before: " + free + ", after: " + free() + ", call: " + info);
} else if (log.isFine()) {
if (log.isFinest()) log.logFinest("[gc] no execute, last run: " + (elapsed / 1000) + " seconds ago, call: " + info);
}
@@ -175,35 +174,6 @@ public class MemoryControl {
return total() - free();
}
- /**
- * Formats a number if it are bytes to greatest unit (1024 based)
- * @param byteCount
- * @return formatted String with unit
- */
- public static String bytesToString(final long byteCount) {
- try {
- final StringBuilder byteString = new StringBuilder();
-
- if (byteCount > 1073741824) {
- byteString.append(yFormatter.number((double)byteCount / (double)1073741824 ))
- .append(" GB");
- } else if (byteCount > 1048576) {
- byteString.append(yFormatter.number((double)byteCount / (double)1048576))
- .append(" MB");
- } else if (byteCount > 1024) {
- byteString.append(yFormatter.number((double)byteCount / (double)1024))
- .append(" KB");
- } else {
- byteString.append(Long.toString(byteCount))
- .append(" Bytes");
- }
-
- return byteString.toString();
- } catch (final Exception e) {
- return "unknown";
- }
- }
-
/**
* main
* @param args
diff --git a/source/de/anomic/server/NamePrefixThreadFactory.java b/source/de/anomic/kelondro/util/NamePrefixThreadFactory.java
similarity index 98%
rename from source/de/anomic/server/NamePrefixThreadFactory.java
rename to source/de/anomic/kelondro/util/NamePrefixThreadFactory.java
index 7f942f62b..0ad9cbbc6 100644
--- a/source/de/anomic/server/NamePrefixThreadFactory.java
+++ b/source/de/anomic/kelondro/util/NamePrefixThreadFactory.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.server;
+package de.anomic.kelondro.util;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
diff --git a/source/de/anomic/net/natLib.java b/source/de/anomic/net/natLib.java
index accd55d13..e3413fcd8 100644
--- a/source/de/anomic/net/natLib.java
+++ b/source/de/anomic/net/natLib.java
@@ -30,6 +30,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import de.anomic.http.HttpClient;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDomains;
import de.anomic.tools.disorderHeap;
@@ -45,7 +46,7 @@ public class natLib {
rm status.htm
*/
try {
- ArrayList<String> x = nxTools.strings(HttpClient.wget("http://admin:"+password+"@192.168.0.1:80/status.htm", null, 10000));
+ ArrayList<String> x = FileUtils.strings(HttpClient.wget("http://admin:"+password+"@192.168.0.1:80/status.htm", null, 10000));
x = nxTools.grep(x, 1, "IP Address");
if ((x == null) || (x.size() == 0)) return null;
final String line = nxTools.tail1(x);
@@ -57,7 +58,7 @@ public class natLib {
private static String getWhatIsMyIP() {
try {
- ArrayList<String> x = nxTools.strings(HttpClient.wget("http://www.whatismyip.com/", null, 10000));
+ ArrayList<String> x = FileUtils.strings(HttpClient.wget("http://www.whatismyip.com/", null, 10000));
x = nxTools.grep(x, 0, "Your IP is");
final String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 4);
@@ -68,7 +69,7 @@ public class natLib {
private static String getStanford() {
try {
- ArrayList<String> x = nxTools.strings(HttpClient.wget("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl", null, 10000));
+ ArrayList<String> x = FileUtils.strings(HttpClient.wget("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl", null, 10000));
x = nxTools.grep(x, 0, "firewall protecting your browser");
final String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 7);
@@ -79,7 +80,7 @@ public class natLib {
private static String getIPID() {
try {
- ArrayList<String> x = nxTools.strings(HttpClient.wget("http://ipid.shat.net/", null, 10000), "UTF-8");
+ ArrayList<String> x = FileUtils.strings(HttpClient.wget("http://ipid.shat.net/", null, 10000), "UTF-8");
x = nxTools.grep(x, 2, "Your IP address");
final String line = nxTools.tail1(x);
return nxTools.awk(nxTools.awk(nxTools.awk(line, " ", 5), ">", 2), "<", 1);
diff --git a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
index 764f90f7e..bfabde8fc 100644
--- a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
+++ b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
@@ -37,12 +37,12 @@ import net.sf.jmimemagic.MagicMatchNotFoundException;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class mimeTypeParser extends AbstractParser implements Parser {
@@ -173,7 +173,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
File dstFile = null;
try {
dstFile = File.createTempFile("mimeTypeParser",".tmp");
- serverFileUtils.copy(source,dstFile);
+ FileUtils.copy(source,dstFile);
return parse(location,mimeType,charset,dstFile);
} catch (final IOException e) {
throw new ParserException("Unexpected error while detect mimetype of resource. " + e.getMessage(),location);
diff --git a/source/de/anomic/plasma/parser/mimeType/odtDetector.java b/source/de/anomic/plasma/parser/mimeType/odtDetector.java
index 088a35780..c010f5a7a 100644
--- a/source/de/anomic/plasma/parser/mimeType/odtDetector.java
+++ b/source/de/anomic/plasma/parser/mimeType/odtDetector.java
@@ -32,7 +32,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import net.sf.jmimemagic.MagicDetector;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
public class odtDetector implements MagicDetector {
@@ -61,7 +61,7 @@ public class odtDetector implements MagicDetector {
File dstFile = null;
try {
dstFile = File.createTempFile("mimeTypeParser",".tmp");
- serverFileUtils.copy(data,dstFile);
+ FileUtils.copy(data,dstFile);
return process(dstFile, offset, length, bitmask, comparator, mimeType, params);
} catch (final IOException e) {
return null;
@@ -82,7 +82,7 @@ public class odtDetector implements MagicDetector {
// read in the content of the file
final InputStream zippedContent = zipFile.getInputStream(mimeTypeInfo);
- final String realMimeType = new String(serverFileUtils.read(zippedContent, (int) mimeTypeInfo.getSize()));
+ final String realMimeType = new String(FileUtils.read(zippedContent, (int) mimeTypeInfo.getSize()));
return new String[]{realMimeType};
} catch (final Exception e) {
diff --git a/source/de/anomic/plasma/parser/odt/odtParser.java b/source/de/anomic/plasma/parser/odt/odtParser.java
index e7fa5d3e2..53921cbaf 100644
--- a/source/de/anomic/plasma/parser/odt/odtParser.java
+++ b/source/de/anomic/plasma/parser/odt/odtParser.java
@@ -46,12 +46,12 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverCharBuffer;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class odtParser extends AbstractParser implements Parser {
@@ -121,7 +121,7 @@ public class odtParser extends AbstractParser implements Parser {
// extract data
final InputStream zipFileEntryStream = zipFile.getInputStream(zipEntry);
final OpenDocumentTextInputStream odStream = new OpenDocumentTextInputStream(zipFileEntryStream);
- serverFileUtils.copy(odStream, writer, Charset.forName("UTF-8"));
+ FileUtils.copy(odStream, writer, Charset.forName("UTF-8"));
// close readers and writers
odStream.close();
@@ -211,7 +211,7 @@ public class odtParser extends AbstractParser implements Parser {
dest.deleteOnExit();
// copying the stream into a file
- serverFileUtils.copy(source, dest);
+ FileUtils.copy(source, dest);
// parsing the content
return parse(location, mimeType, charset, dest);
diff --git a/source/de/anomic/plasma/parser/pdf/pdfParser.java b/source/de/anomic/plasma/parser/pdf/pdfParser.java
index 7423e320b..490f74b1d 100644
--- a/source/de/anomic/plasma/parser/pdf/pdfParser.java
+++ b/source/de/anomic/plasma/parser/pdf/pdfParser.java
@@ -39,12 +39,12 @@ import org.pdfbox.pdmodel.encryption.AccessPermission;
import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
import org.pdfbox.util.PDFTextStripper;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverCharBuffer;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class pdfParser extends AbstractParser implements Parser {
@@ -232,7 +232,7 @@ public class pdfParser extends AbstractParser implements Parser {
System.out.println("\tParsed text with " + document.getTextLength() + " chars of text and " + document.getAnchors().size() + " anchors");
try {
// write file
- serverFileUtils.copy(document.getText(), new File("parsedPdf.txt"));
+ FileUtils.copy(document.getText(), new File("parsedPdf.txt"));
} catch (final IOException e) {
System.err.println("error saving parsed document");
e.printStackTrace();
diff --git a/source/de/anomic/plasma/parser/ps/psParser.java b/source/de/anomic/plasma/parser/ps/psParser.java
index 77717afcc..d6f4f0362 100644
--- a/source/de/anomic/plasma/parser/ps/psParser.java
+++ b/source/de/anomic/plasma/parser/ps/psParser.java
@@ -33,11 +33,11 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Hashtable;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class psParser extends AbstractParser implements Parser {
@@ -275,7 +275,7 @@ public class psParser extends AbstractParser implements Parser {
tempFile.deleteOnExit();
// copying inputstream into file
- serverFileUtils.copy(source,tempFile);
+ FileUtils.copy(source,tempFile);
// parsing the file
return parse(location,mimeType,charset,tempFile);
diff --git a/source/de/anomic/plasma/parser/rpm/rpmParser.java b/source/de/anomic/plasma/parser/rpm/rpmParser.java
index 4abaf1214..51b265bdc 100644
--- a/source/de/anomic/plasma/parser/rpm/rpmParser.java
+++ b/source/de/anomic/plasma/parser/rpm/rpmParser.java
@@ -36,11 +36,11 @@ import com.jguild.jrpm.io.datatype.DataTypeIf;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
/**
@@ -80,7 +80,7 @@ public class rpmParser extends AbstractParser implements Parser {
File dstFile = null;
try {
dstFile = File.createTempFile("rpmParser",".tmp");
- serverFileUtils.copy(source,dstFile);
+ FileUtils.copy(source,dstFile);
return parse(location,mimeType,charset,dstFile);
} catch (final Exception e) {
return null;
diff --git a/source/de/anomic/plasma/parser/rss/rssParser.java b/source/de/anomic/plasma/parser/rss/rssParser.java
index ff4c51b50..58dc41ac7 100644
--- a/source/de/anomic/plasma/parser/rss/rssParser.java
+++ b/source/de/anomic/plasma/parser/rss/rssParser.java
@@ -39,12 +39,12 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.kelondro.util.ByteBuffer;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverCharBuffer;
-import de.anomic.server.serverFileUtils;
import de.anomic.xml.RSSFeed;
import de.anomic.xml.RSSMessage;
import de.anomic.xml.RSSReader;
@@ -125,7 +125,7 @@ public class rssParser extends AbstractParser implements Parser {
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(itemURL);
final Writer writer = new htmlFilterWriter(null, null, scraper, null, false);
- serverFileUtils.copy(new ByteArrayInputStream(itemContent.getBytes("UTF-8")), writer, Charset.forName("UTF-8"));
+ FileUtils.copy(new ByteArrayInputStream(itemContent.getBytes("UTF-8")), writer, Charset.forName("UTF-8"));
final String itemHeadline = scraper.getTitle();
if ((itemHeadline != null) && (itemHeadline.length() > 0)) {
diff --git a/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java b/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java
index 4bf324896..474d65cfe 100644
--- a/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java
+++ b/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java
@@ -31,12 +31,12 @@ import java.util.Hashtable;
import SevenZip.IInStream;
import SevenZip.MyRandomAccessFile;
import SevenZip.Archive.SevenZip.Handler;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverCachedFileOutputStream;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class sevenzipParser extends AbstractParser implements Parser {
@@ -109,7 +109,7 @@ public class sevenzipParser extends AbstractParser implements Parser {
final InputStream source) throws ParserException, InterruptedException {
try {
final serverCachedFileOutputStream cfos = new serverCachedFileOutputStream(Parser.MAX_KEEP_IN_MEMORY_SIZE);
- serverFileUtils.copy(source, cfos);
+ FileUtils.copy(source, cfos);
if (cfos.isFallback()) {
return parse(location, mimeType, charset, cfos.getContentFile());
}
diff --git a/source/de/anomic/plasma/parser/tar/tarParser.java b/source/de/anomic/plasma/parser/tar/tarParser.java
index 358ecdc40..e56e1688c 100644
--- a/source/de/anomic/plasma/parser/tar/tarParser.java
+++ b/source/de/anomic/plasma/parser/tar/tarParser.java
@@ -42,12 +42,12 @@ import com.ice.tar.TarInputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.kelondro.util.ByteBuffer;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class tarParser extends AbstractParser implements Parser {
@@ -142,7 +142,7 @@ public class tarParser extends AbstractParser implements Parser {
subDocTempFile = createTempFile(entryName);
// copy the data into the file
- serverFileUtils.copy(tin,subDocTempFile,entry.getSize());
+ FileUtils.copy(tin,subDocTempFile,entry.getSize());
// check for interruption
checkInterruption();
@@ -170,7 +170,7 @@ public class tarParser extends AbstractParser implements Parser {
if (subDoc.getTextLength() > 0) {
if (docTextLength > 0) docText.write('\n');
- docTextLength += serverFileUtils.copy(subDoc.getText(), docText);
+ docTextLength += FileUtils.copy(subDoc.getText(), docText);
}
docAnchors.putAll(subDoc.getAnchors());
diff --git a/source/de/anomic/plasma/parser/zip/zipParser.java b/source/de/anomic/plasma/parser/zip/zipParser.java
index 9d42f2ded..e0e8f9c2c 100644
--- a/source/de/anomic/plasma/parser/zip/zipParser.java
+++ b/source/de/anomic/plasma/parser/zip/zipParser.java
@@ -40,12 +40,12 @@ import java.util.zip.ZipInputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.kelondro.util.ByteBuffer;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class zipParser extends AbstractParser implements Parser {
@@ -128,7 +128,7 @@ public class zipParser extends AbstractParser implements Parser {
subDocTempFile = createTempFile(entryName);
// copy the data into the file
- serverFileUtils.copy(zippedContent,subDocTempFile,entry.getSize());
+ FileUtils.copy(zippedContent,subDocTempFile,entry.getSize());
// parsing the zip file entry
subDoc = theParser.parseSource(yacyURL.newURL(location,"#" + entryName),entryMime,null, subDocTempFile);
@@ -153,7 +153,7 @@ public class zipParser extends AbstractParser implements Parser {
if (subDoc.getTextLength() > 0) {
if (docTextLength > 0) docText.write('\n');
- docTextLength += serverFileUtils.copy(subDoc.getText(), docText);
+ docTextLength += FileUtils.copy(subDoc.getText(), docText);
}
docAnchors.putAll(subDoc.getAnchors());
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 9260f9d6f..0806dca75 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -50,7 +50,7 @@ import de.anomic.kelondro.blob.BLOBHeap;
import de.anomic.kelondro.blob.MapView;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
@@ -98,7 +98,7 @@ public final class plasmaHTCache {
object.getName().equals("yacy") ||
object.getName().equals("https") ||
object.getName().equals("ftp")) {
- serverFileUtils.deleteDirectory(cachePath);
+ FileUtils.deleteDirectory(cachePath);
}
}
}
diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.java
index f3c61f4ab..419cf408d 100644
--- a/source/de/anomic/plasma/plasmaParser.java
+++ b/source/de/anomic/plasma/plasmaParser.java
@@ -59,10 +59,10 @@ import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.parser.Parser;
import de.anomic.plasma.parser.ParserException;
import de.anomic.plasma.parser.ParserInfo;
-import de.anomic.server.serverFileUtils;
import de.anomic.tools.ListDirs;
import de.anomic.yacy.yacyURL;
@@ -706,7 +706,7 @@ public final class plasmaParser {
// parsing the content
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(location);
final htmlFilterWriter writer = new htmlFilterWriter(null,null,scraper,null,false);
- serverFileUtils.copy(htmlFilter, writer, Charset.forName(charset));
+ FileUtils.copy(htmlFilter, writer, Charset.forName(charset));
writer.close();
//OutputStream hfos = new htmlFilterOutputStream(null, scraper, null, false);
//serverFileUtils.copy(sourceFile, hfos);
diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.java
index 4794d2e59..54878d402 100644
--- a/source/de/anomic/plasma/plasmaParserDocument.java
+++ b/source/de/anomic/plasma/plasmaParserDocument.java
@@ -41,9 +41,9 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.parser.Parser;
import de.anomic.server.serverCachedFileOutputStream;
-import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
public class plasmaParserDocument {
@@ -253,13 +253,13 @@ dc_rights
if (this.text == null) return new byte[0];
if (this.text instanceof File) {
- return serverFileUtils.read((File)this.text);
+ return FileUtils.read((File)this.text);
} else if (this.text instanceof byte[]) {
return (byte[])this.text;
} else if (this.text instanceof serverCachedFileOutputStream) {
final serverCachedFileOutputStream ffbaos = (serverCachedFileOutputStream)this.text;
if (ffbaos.isFallback()) {
- return serverFileUtils.read(ffbaos.getContent());
+ return FileUtils.read(ffbaos.getContent());
}
return ffbaos.getContentBAOS();
}
@@ -416,9 +416,9 @@ dc_rights
if (!(this.text instanceof serverCachedFileOutputStream)) {
this.text = new serverCachedFileOutputStream(Parser.MAX_KEEP_IN_MEMORY_SIZE);
- serverFileUtils.copy(getText(), (serverCachedFileOutputStream)this.text);
+ FileUtils.copy(getText(), (serverCachedFileOutputStream)this.text);
}
- serverFileUtils.copy(doc.getText(), (serverCachedFileOutputStream)this.text);
+ FileUtils.copy(doc.getText(), (serverCachedFileOutputStream)this.text);
anchors.putAll(doc.getAnchors());
htmlFilterContentScraper.addAllImages(images, doc.getImages());
diff --git a/source/de/anomic/plasma/plasmaRankingCRProcess.java b/source/de/anomic/plasma/plasmaRankingCRProcess.java
index 791e6f9f6..5b979e790 100644
--- a/source/de/anomic/plasma/plasmaRankingCRProcess.java
+++ b/source/de/anomic/plasma/plasmaRankingCRProcess.java
@@ -41,7 +41,7 @@ import de.anomic.kelondro.order.MicroDate;
import de.anomic.kelondro.table.EcoTable;
import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.AttrSeq;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
public class plasmaRankingCRProcess {
@@ -299,11 +299,11 @@ public class plasmaRankingCRProcess {
to_file.delete();
tmp_file.renameTo(to_file);
}
- serverFileUtils.moveAll(tmp_dir, bkp_dir);
+ FileUtils.moveAll(tmp_dir, bkp_dir);
} catch (final IOException e) {
// move previously processed files back
e.printStackTrace();
- serverFileUtils.moveAll(tmp_dir, from_dir);
+ FileUtils.moveAll(tmp_dir, from_dir);
}
}
@@ -436,7 +436,7 @@ public class plasmaRankingCRProcess {
if (!(err_dir.exists())) err_dir.mkdirs();
if (!(acc_dir.exists())) acc_dir.mkdirs();
if (!(to_file.getParentFile().exists())) to_file.getParentFile().mkdirs();
- serverFileUtils.moveAll(from_dir, ready_dir);
+ FileUtils.moveAll(from_dir, ready_dir);
final long start = System.currentTimeMillis();
final int files = ready_dir.list().length;
accumulate(ready_dir, tmp_dir, err_dir, acc_dir, to_file, 1000, true);
@@ -468,7 +468,7 @@ public class plasmaRankingCRProcess {
} else {
// file is fresh, it is duplicated and moved to be transferred to other peers again
System.out.println("file " + f.getName() + " is fresh (" + d + " hours old), recycled and moved to backup");
- serverFileUtils.copy(f, new File(own_dir, list[i]));
+ FileUtils.copy(f, new File(own_dir, list[i]));
f.renameTo(new File(bkp_dir, list[i]));
}
} catch (final IOException e) {
diff --git a/source/de/anomic/plasma/plasmaRankingDistribution.java b/source/de/anomic/plasma/plasmaRankingDistribution.java
index e31837ab4..759311205 100644
--- a/source/de/anomic/plasma/plasmaRankingDistribution.java
+++ b/source/de/anomic/plasma/plasmaRankingDistribution.java
@@ -31,7 +31,7 @@ import java.util.Random;
import java.util.StringTokenizer;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyClient;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
@@ -175,7 +175,7 @@ public final class plasmaRankingDistribution {
final long starttime = System.currentTimeMillis();
String result = "unknown";
try {
- final byte[] b = serverFileUtils.read(crfile);
+ final byte[] b = FileUtils.read(crfile);
result = yacyClient.transfer(address, crfile.getName(), b);
if (result == null) {
log.logInfo("RankingDistribution - transmitted file " + crfile + " to " + address + " successfully in " + ((System.currentTimeMillis() - starttime) / 1000) + " seconds");
diff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
index 3f2cae60d..78391e27c 100644
--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
@@ -37,7 +37,7 @@ import java.util.TreeSet;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.AttrSeq;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyURL;
public class plasmaRankingRCIEvaluation {
@@ -150,7 +150,7 @@ public class plasmaRankingRCIEvaluation {
}
public static HashMap<String, String> genReverseDomHash(final File domlist) {
- final HashSet<String> domset = serverFileUtils.loadList(domlist);
+ final HashSet<String> domset = FileUtils.loadList(domlist);
final HashMap<String, String> dommap = new HashMap<String, String>();
final Iterator<String> i = domset.iterator();
String dom;
@@ -170,7 +170,7 @@ public class plasmaRankingRCIEvaluation {
if (!(tablePath.exists())) tablePath.mkdirs();
for (int i = 0; i < ranking.length - 1; i++) {
filename = "YBR-4-" + Digest.encodeHex(i, 2) + ".idx";
- serverFileUtils.saveSet(new File(tablePath, filename), "plain", ranking[i], "");
+ FileUtils.saveSet(new File(tablePath, filename), "plain", ranking[i], "");
}
}
diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.java
index 317b6b5b2..4ef35e0df 100644
--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java
+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java
@@ -47,7 +47,7 @@ import de.anomic.kelondro.index.BinSearch;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.ScoreCluster;
import de.anomic.kelondro.util.SortStack;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.server.serverProfiling;
import de.anomic.yacy.yacyURL;
@@ -403,7 +403,7 @@ public final class plasmaSearchRankingProcess {
ybrName = "YBR-4-" + Digest.encodeHex(i, 2) + ".idx";
f = new File(rankingPath, ybrName);
if (f.exists()) {
- ybrTables[i] = new BinSearch(serverFileUtils.read(f), 6);
+ ybrTables[i] = new BinSearch(FileUtils.read(f), 6);
} else {
ybrTables[i] = null;
}
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 95825d12a..9450383c3 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -150,12 +150,12 @@ import de.anomic.kelondro.table.CachedRecords;
import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.SetTools;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverAbstractSwitch;
import de.anomic.server.serverBusyThread;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverInstantBusyThread;
import de.anomic.server.serverObjects;
import de.anomic.server.serverProcessor;
@@ -165,7 +165,6 @@ import de.anomic.server.serverSemaphore;
import de.anomic.server.serverSwitch;
import de.anomic.server.serverThread;
import de.anomic.tools.crypt;
-import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyClient;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNewsPool;
@@ -505,7 +504,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
final File notifierSource = new File(getRootPath(), getConfig(plasmaSwitchboardConstants.HTROOT_PATH, plasmaSwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");
final File notifierDest = new File(getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT), "notifier.gif");
try {
- serverFileUtils.copy(notifierSource, notifierDest);
+ FileUtils.copy(notifierSource, notifierDest);
} catch (final IOException e) {
}
@@ -669,7 +668,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
} else {
final File networkUnitDefinitionFile = (networkUnitDefinition.startsWith("/")) ? new File(networkUnitDefinition) : new File(getRootPath(), networkUnitDefinition);
if (networkUnitDefinitionFile.exists()) {
- initProps = serverFileUtils.loadHashMap(networkUnitDefinitionFile);
+ initProps = FileUtils.loadMap(networkUnitDefinitionFile);
setConfig(initProps);
}
}
@@ -680,7 +679,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
} else {
final File networkGroupDefinitionFile = new File(getRootPath(), networkGroupDefinition);
if (networkGroupDefinitionFile.exists()) {
- initProps = serverFileUtils.loadHashMap(networkGroupDefinitionFile);
+ initProps = FileUtils.loadMap(networkGroupDefinitionFile);
setConfig(initProps);
}
}
@@ -2204,7 +2203,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
} else {
ssc++;
final byte[] content = HttpClient.wget(url.toString(), reqHeader, (int) getConfigLong("bootstrapLoadTimeout", 20000));
- seedList = nxTools.strings(content, "UTF-8");
+ seedList = FileUtils.strings(content, "UTF-8");
enu = seedList.iterator();
lc = 0;
while (enu.hasNext()) {
@@ -2270,7 +2269,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// sending request
final httpRequestHeader reqHeader = new httpRequestHeader();
reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
- final HashMap<String, String> result = nxTools.table(HttpClient.wget(url.toString(), reqHeader, 10000), "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(HttpClient.wget(url.toString(), reqHeader, 10000), "UTF-8");
if (result == null) return new HashMap<String, String>();
return result;
} catch (final Exception e) {
diff --git a/source/de/anomic/plasma/plasmaWebStructure.java b/source/de/anomic/plasma/plasmaWebStructure.java
index 070dd31d7..e06c69d9b 100644
--- a/source/de/anomic/plasma/plasmaWebStructure.java
+++ b/source/de/anomic/plasma/plasmaWebStructure.java
@@ -41,7 +41,7 @@ import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.order.MicroDate;
import de.anomic.kelondro.util.Log;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyURL;
public class plasmaWebStructure {
@@ -68,7 +68,7 @@ public class plasmaWebStructure {
this.structureFile = structureFile;
// load web structure
- final Map<String, String> loadedStructure = (this.structureFile.exists()) ? serverFileUtils.loadHashMap(this.structureFile) : new TreeMap<String, String>();
+ final Map<String, String> loadedStructure = (this.structureFile.exists()) ? FileUtils.loadMap(this.structureFile) : new TreeMap<String, String>();
if (loadedStructure != null) this.structure_old.putAll(loadedStructure);
// delete out-dated entries in case the structure is too big
@@ -166,7 +166,7 @@ public class plasmaWebStructure {
header.append("# ---"); header.append((char) 13); header.append((char) 10);
crg.insert(0, header.toString());
try {
- serverFileUtils.writeAndGZip(crg.toString().getBytes(), file);
+ FileUtils.writeAndGZip(crg.toString().getBytes(), file);
if (this.log.isFine()) log.logFine("wrote citation reference dump " + file.toString());
} catch (final IOException e) {
e.printStackTrace();
@@ -366,7 +366,7 @@ public class plasmaWebStructure {
joinOldNew();
try {
synchronized(structure_old) {
- serverFileUtils.saveMap(this.structureFile, this.structure_old, "Web Structure Syntax: <b64hash(6)>','<host> to <date-yyyymmdd(8)>{<target-b64hash(6)><target-count-hex(4)>}*");
+ FileUtils.saveMap(this.structureFile, this.structure_old, "Web Structure Syntax: <b64hash(6)>','<host> to <date-yyyymmdd(8)>{<target-b64hash(6)><target-count-hex(4)>}*");
}
} catch (final IOException e) {
e.printStackTrace();
diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java
index a12432b1f..4767fed46 100644
--- a/source/de/anomic/server/serverAbstractSwitch.java
+++ b/source/de/anomic/server/serverAbstractSwitch.java
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {
@@ -71,7 +72,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {
// predefine init's
Map<String, String> initProps;
if (initFile.exists())
- initProps = serverFileUtils.loadHashMap(initFile);
+ initProps = FileUtils.loadMap(initFile);
else
initProps = new HashMap<String, String>();
@@ -98,7 +99,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {
// load config's from last save
if (configFile.exists())
- configProps = serverFileUtils.loadHashMap(configFile);
+ configProps = FileUtils.loadMap(configFile);
else
configProps = new HashMap<String, String>();
@@ -340,7 +341,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {
private void saveConfig() {
try {
synchronized (configProps) {
- serverFileUtils.saveMap(configFile, configProps, configComment);
+ FileUtils.saveMap(configFile, configProps, configComment);
}
} catch (final IOException e) {
System.out.println("ERROR: cannot write config file " + configFile.toString() + ": " + e.getMessage());
diff --git a/source/de/anomic/server/serverCachedFileOutputStream.java b/source/de/anomic/server/serverCachedFileOutputStream.java
index 7be8550eb..25f3687be 100644
--- a/source/de/anomic/server/serverCachedFileOutputStream.java
+++ b/source/de/anomic/server/serverCachedFileOutputStream.java
@@ -34,6 +34,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import de.anomic.kelondro.util.FileUtils;
+
public class serverCachedFileOutputStream extends ByteArrayOutputStream {
protected File fallbackFile;
@@ -91,7 +93,7 @@ public class serverCachedFileOutputStream extends ByteArrayOutputStream {
}
final OutputStream os = new FileOutputStream(this.fallbackFile);
this.fallback = (this.buffered) ? new BufferedOutputStream(os) : os;
- serverFileUtils.copy(new ByteArrayInputStream(super.buf), this.fallback);
+ FileUtils.copy(new ByteArrayInputStream(super.buf), this.fallback);
super.buf = new byte[0];
super.count = 0;
super.reset();
diff --git a/source/de/anomic/server/serverClassLoader.java b/source/de/anomic/server/serverClassLoader.java
index 9267e053f..a7b69607e 100644
--- a/source/de/anomic/server/serverClassLoader.java
+++ b/source/de/anomic/server/serverClassLoader.java
@@ -25,6 +25,8 @@ import java.io.File;
import java.io.IOException;
import java.util.HashMap;
+import de.anomic.kelondro.util.FileUtils;
+
public final class serverClassLoader extends ClassLoader {
/**
* directory of class files
@@ -59,7 +61,7 @@ public final class serverClassLoader extends ClassLoader {
byte[] b;
try {
//System.out.println("*** DEBUG CLASSLOADER: " + classfile + "; file " + (classfile.exists() ? "exists": "does not exist"));
- b = serverFileUtils.read(classfile);
+ b = FileUtils.read(classfile);
// make a class out of the stream
c = this.defineClass(null, b, 0, b.length);
resolveClass(c);
diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java
index 892f5594d..b0927ba1a 100644
--- a/source/de/anomic/server/serverObjects.java
+++ b/source/de/anomic/server/serverObjects.java
@@ -55,7 +55,7 @@ import java.util.Map;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
public class serverObjects extends HashMap<String, String> implements Cloneable {
@@ -165,14 +165,14 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
/**
* Add a byte/long/integer to the map. The number will be encoded into a String using
- * a localized format specified by {@link yFormatter} and {@link #setLocalized(boolean)}.
+ * a localized format specified by {@link Formatter} and {@link #setLocalized(boolean)}.
* @param key key name as String.
* @param value integer type value to be added to the map in its formatted String
* representation.
* @return the String value added to the map.
*/
public String putNum(final String key, final long value) {
- return this.put(key, yFormatter.number(value, this.localized));
+ return this.put(key, Formatter.number(value, this.localized));
}
/**
@@ -180,7 +180,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
* @see #putNum(String, long)
*/
public String putNum(final String key, final double value) {
- return this.put(key, yFormatter.number(value, this.localized));
+ return this.put(key, Formatter.number(value, this.localized));
}
/**
@@ -188,7 +188,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
* @see #putNum(String, long)
*/
public String putNum(final String key, final String value) {
- return this.put(key, yFormatter.number(value));
+ return this.put(key, Formatter.number(value));
}
@@ -322,7 +322,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
* Currently it is used for numbers added with the putNum() methods only.
* @param loc if <code>true</code> store numbers in a localized format, otherwise
* use a default english locale without grouping.
- * @see yFormatter#setLocale(String)
+ * @see Formatter#setLocale(String)
*/
public void setLocalized(final boolean loc) {
this.localized = loc;
diff --git a/source/de/anomic/server/serverProcessor.java b/source/de/anomic/server/serverProcessor.java
index 2e628bba4..92d96494b 100644
--- a/source/de/anomic/server/serverProcessor.java
+++ b/source/de/anomic/server/serverProcessor.java
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.NamePrefixThreadFactory;
public class serverProcessor<J extends serverProcessorJob> {
diff --git a/source/de/anomic/server/serverSystem.java b/source/de/anomic/server/serverSystem.java
index 1eec0f659..29dc7bafe 100644
--- a/source/de/anomic/server/serverSystem.java
+++ b/source/de/anomic/server/serverSystem.java
@@ -32,6 +32,7 @@ import java.util.Properties;
import java.util.Vector;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
public final class serverSystem {
@@ -325,7 +326,7 @@ public final class serverSystem {
}
public static void deployScript(final File scriptFile, final String theScript) throws IOException {
- serverFileUtils.copy(theScript.getBytes(), scriptFile);
+ FileUtils.copy(theScript.getBytes(), scriptFile);
if(!isWindows){ // set executable
try {
Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
diff --git a/source/de/anomic/tools/yFormatter.java b/source/de/anomic/tools/Formatter.java
similarity index 79%
rename from source/de/anomic/tools/yFormatter.java
rename to source/de/anomic/tools/Formatter.java
index 246eac1f2..7dc40efcf 100644
--- a/source/de/anomic/tools/yFormatter.java
+++ b/source/de/anomic/tools/Formatter.java
@@ -35,7 +35,7 @@ import java.util.Locale;
* At the moment yFormatter can be used to format numbers according
* to the locale set for YaCy.
*/
-public final class yFormatter {
+public final class Formatter {
// default formatter
private static NumberFormat numForm = NumberFormat.getInstance(new Locale("en"));
@@ -106,4 +106,30 @@ public final class yFormatter {
return (ret == null ? "-" : ret);
}
+
+
+ /**
+ * Formats a number if it are bytes to greatest unit (1024 based)
+ * @param byteCount
+ * @return formatted String with unit
+ */
+ public static String bytesToString(final long byteCount) {
+ try {
+ final StringBuilder byteString = new StringBuilder();
+
+ if (byteCount > 1073741824) {
+ byteString.append(number((double)byteCount / (double)1073741824 )).append(" GB");
+ } else if (byteCount > 1048576) {
+ byteString.append(number((double)byteCount / (double)1048576)).append(" MB");
+ } else if (byteCount > 1024) {
+ byteString.append(number((double)byteCount / (double)1024)).append(" KB");
+ } else {
+ byteString.append(Long.toString(byteCount)).append(" Bytes");
+ }
+
+ return byteString.toString();
+ } catch (final Exception e) {
+ return "unknown";
+ }
+ }
}
diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.java
index ce2b86ef1..02e0f26df 100644
--- a/source/de/anomic/tools/loaderThreads.java
+++ b/source/de/anomic/tools/loaderThreads.java
@@ -28,6 +28,7 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpRequestHeader;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.yacy.yacyURL;
public class loaderThreads {
@@ -177,7 +178,7 @@ public class loaderThreads {
int line = 0;
String s, key, value;
int p;
- final ArrayList<String> lines = nxTools.strings(v);
+ final ArrayList<String> lines = FileUtils.strings(v);
try {
while ((this.run) && (line < lines.size())) {
// parse line and construct a property
diff --git a/source/de/anomic/tools/nxTools.java b/source/de/anomic/tools/nxTools.java
index 9fc2986e6..b9dc6391a 100644
--- a/source/de/anomic/tools/nxTools.java
+++ b/source/de/anomic/tools/nxTools.java
@@ -47,61 +47,13 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
-import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
public class nxTools {
-
- public static HashMap<String, String> table(final Vector<String> list) {
- final Enumeration<String> i = list.elements();
- int pos;
- String line;
- final HashMap<String, String> props = new HashMap<String, String>(list.size());
- while (i.hasMoreElements()) {
- line = (i.nextElement()).trim();
- pos = line.indexOf("=");
- if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
- }
- return props;
- }
-
- public static HashMap<String, String> table(final byte[] a, final String encoding) {
- return table(strings(a, encoding));
- }
-
- /**
- * parse config files
- *
- * splits the lines in list into pairs sperarated by =, lines beginning with # are ignored
- * ie:
- * abc=123
- * # comment
- * fg=dcf
- * => Map{abc => 123, fg => dcf}
- * @param list
- * @return
- */
- public static HashMap<String, String> table(final ArrayList<String> list) {
- if (list == null) return new HashMap<String, String>();
- final Iterator<String> i = list.iterator();
- int pos;
- String line;
- final HashMap<String, String> props = new HashMap<String, String>(list.size());
- while (i.hasNext()) {
- line = (i.next()).trim();
- if (line.startsWith("#")) continue; // exclude comments
- //System.out.println("NXTOOLS_PROPS - LINE:" + line);
- pos = line.indexOf("=");
- if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
- }
- return props;
- }
-
public static Vector<String> grep(final Vector<String> list, final int afterContext, final String pattern) {
final Enumeration<String> i = list.elements();
int ac = 0;
@@ -166,45 +118,6 @@ public class nxTools {
return null;
}
- public static ArrayList<String> strings(final byte[] a) {
- return strings(a, null);
- }
-
- public static ArrayList<String> strings(final byte[] a, final String encoding) {
- if (a == null) return new ArrayList<String>();
- int s = 0;
- int e;
- final ArrayList<String> v = new ArrayList<String>();
- byte b;
- while (s < a.length) {
- // find eol
- e = s;
- while (e < a.length) {
- b = a[e];
- if ((b == 10) || (b == 13) || (b == 0)) break;
- e++;
- }
-
- // read line
- if (encoding == null) {
- v.add(new String(a, s, e - s));
- } else try {
- v.add(new String(a, s, e - s, encoding));
- } catch (final UnsupportedEncodingException xcptn) {
- return v;
- }
-
- // eat up additional eol bytes
- s = e + 1;
- while (s < a.length) {
- b = a[s];
- if ((b != 10) && (b != 13)) break;
- s++;
- }
- }
- return v;
- }
-
public static String line(final byte[] a, final int lineNr) {
final InputStreamReader r = new InputStreamReader(new ByteArrayInputStream(a));
final LineNumberReader lnr = new LineNumberReader(r);
diff --git a/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java b/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java
new file mode 100644
index 000000000..fe7bbe75f
--- /dev/null
+++ b/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java
@@ -0,0 +1,181 @@
+//ConsoleOutErrHandler.java
+//-------------------------------------
+//part of YACY
+//(C) by Michael Peter Christen; [email protected]
+//first published on http://www.anomic.de
+//Frankfurt, Germany, 2004
+//
+//This file ist contributed by Martin Thelian
+//last major change: $LastChangedDate: 2008-08-02 14:12:04 +0200 (Sa, 02 Aug 2008) $ by $LastChangedBy: danielr $
+//Revision: $LastChangedRevision: 5030 $
+//
+//This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; either version 2 of the License, or
+//(at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.yacy.logging;
+
+import java.io.UnsupportedEncodingException;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Filter;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+
+public final class ConsoleOutErrHandler extends Handler {
+
+ private boolean ignoreCtrlChr = false;
+ private Level splitLevel = Level.WARNING;
+ private final Handler stdOutHandler = new ConsoleOutHandler();
+ private final Handler stdErrHandler = new ConsoleHandler();
+
+ public ConsoleOutErrHandler() {
+ this.stdOutHandler.setLevel(Level.FINEST);
+ this.stdErrHandler.setLevel(Level.WARNING);
+ configure();
+ }
+
+ /**
+ * Get any configuration properties set
+ */
+ private void configure() {
+ final LogManager manager = LogManager.getLogManager();
+ final String className = getClass().getName();
+
+ final String level = manager.getProperty(className + ".level");
+ setLevel((level == null) ? Level.INFO : Level.parse(level));
+
+ final Level levelStdOut = parseLevel(manager.getProperty(className + ".levelStdOut"));
+ final Level levelSplit = parseLevel(manager.getProperty(className + ".levelSplit"));
+ final Level levelStdErr = parseLevel(manager.getProperty(className + ".levelStdErr"));
+ setLevels(levelStdOut,levelSplit,levelStdErr);
+
+ final String filter = manager.getProperty(className + ".filter");
+ setFilter(makeFilter(filter));
+
+ final String formatter = manager.getProperty(className + ".formatter");
+ setFormatter(makeFormatter(formatter));
+
+ final String encoding = manager.getProperty(className + ".encoding");
+ try {
+ this.stdOutHandler.setEncoding(encoding);
+ this.stdErrHandler.setEncoding(encoding);
+ } catch (final UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+
+ final String ignoreCtrlChrStr = manager.getProperty(className + ".ignoreCtrlChr");
+ this.ignoreCtrlChr = (ignoreCtrlChrStr==null)?false:ignoreCtrlChrStr.equalsIgnoreCase("true");
+
+ }
+
+ private Level parseLevel(final String levelName) {
+ try {
+ return (levelName == null) ? Level.INFO : Level.parse(levelName);
+ } catch (final Exception e) {
+ return Level.ALL;
+ }
+ }
+
+ private Filter makeFilter(final String name) {
+ if (name == null) return null;
+
+ Filter f = null;
+ try {
+ final Class<?> c = Class.forName(name);
+ f = (Filter)c.newInstance();
+ } catch (final Exception e) {
+ if (name != null) {
+ System.err.println("Unable to load filter: " + name);
+ }
+ }
+ return f;
+ }
+
+ private Formatter makeFormatter(final String name) {
+ if (name == null) return null;
+
+ Formatter f = null;
+ try {
+ final Class<?> c = Class.forName(name);
+ f = (Formatter)c.newInstance();
+ } catch (final Exception e) {
+ f = new SimpleFormatter();
+ }
+ return f;
+ }
+
+
+ public void publish(final LogRecord record) {
+ if (!isLoggable(record)) return;
+
+ if (this.ignoreCtrlChr) {
+ String msg = record.getMessage();
+ if (msg != null) {
+ msg = msg.replaceAll("[\u0000-\u0008\u000B\u000C\u000E-\u001F]"," ");
+ }
+ record.setMessage(msg);
+ }
+
+ if (record.getLevel().intValue() >= splitLevel.intValue()) {
+ this.stdErrHandler.publish(record);
+ } else {
+ this.stdOutHandler.publish(record);
+ }
+ }
+
+ public void flush() {
+ this.stdOutHandler.flush();
+ this.stdErrHandler.flush();
+ }
+
+ public void close() throws SecurityException {
+ this.stdOutHandler.close();
+ this.stdErrHandler.close();
+ }
+
+ public synchronized void setLevel(final Level newLevel) throws SecurityException {
+ super.setLevel(newLevel);
+ }
+
+ public void setLevels(final Level stdOutLevel, final Level splitLevel, final Level stdErrLevel) throws SecurityException {
+ this.stdOutHandler.setLevel(stdOutLevel);
+ this.splitLevel = splitLevel;
+ this.stdErrHandler.setLevel(stdErrLevel);
+ }
+
+ public void setFormatter(final Formatter newFormatter) throws SecurityException {
+ super.setFormatter(newFormatter);
+ if (newFormatter == null) return;
+ try {
+ this.stdOutHandler.setFormatter(newFormatter.getClass().newInstance());
+ this.stdErrHandler.setFormatter(newFormatter.getClass().newInstance());
+ } catch (final Exception e) {
+ throw new SecurityException(e.getMessage());
+ }
+ }
+
+ public void setFilter(final Filter newFilter) throws SecurityException {
+ super.setFilter(newFilter);
+ if (newFilter == null) return;
+ try {
+ this.stdOutHandler.setFilter(newFilter.getClass().newInstance());
+ this.stdErrHandler.setFilter(newFilter.getClass().newInstance());
+ } catch (final Exception e) {
+ throw new SecurityException(e.getMessage());
+ }
+ }
+}
diff --git a/source/de/anomic/yacy/logging/ConsoleOutHandler.java b/source/de/anomic/yacy/logging/ConsoleOutHandler.java
new file mode 100644
index 000000000..983a48047
--- /dev/null
+++ b/source/de/anomic/yacy/logging/ConsoleOutHandler.java
@@ -0,0 +1,49 @@
+//ConsoleOutHandler.java
+//-------------------------------------
+//part of YACY
+//(C) by Michael Peter Christen; [email protected]
+//first published on http://www.anomic.de
+//Frankfurt, Germany, 2004
+//
+//This file ist contributed by Martin Thelian
+//last major change: $LastChangedDate: 2008-08-02 14:12:04 +0200 (Sa, 02 Aug 2008) $ by $LastChangedBy: danielr $
+//Revision: $LastChangedRevision: 5030 $
+//
+//This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; either version 2 of the License, or
+//(at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.yacy.logging;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+import java.util.logging.StreamHandler;
+
+public final class ConsoleOutHandler extends StreamHandler{
+
+ public ConsoleOutHandler() {
+ setLevel(Level.FINEST);
+ setFormatter(new SimpleFormatter());
+ setOutputStream(System.out);
+ }
+
+ public synchronized void publish(final LogRecord record) {
+ super.publish(record);
+ flush();
+ }
+
+ public synchronized void close() {
+ flush();
+ }
+}
diff --git a/source/de/anomic/yacy/logging/LogalizerHandler.java b/source/de/anomic/yacy/logging/LogalizerHandler.java
index 860f12d8d..a7a88577c 100644
--- a/source/de/anomic/yacy/logging/LogalizerHandler.java
+++ b/source/de/anomic/yacy/logging/LogalizerHandler.java
@@ -68,30 +68,31 @@ public class LogalizerHandler extends Handler {
if(parserDirFiles.size() == 0 && debug) {
System.out.println("Can't find any parsers in "+parserDir.toString());
}
- for(final String filename: parserDirFiles) {
- final Pattern patternGetClassName = Pattern.compile(".*\\"+ File.separator +"([^\\"+ File.separator +"]+)\\.class");
- final Matcher matcherClassName = patternGetClassName.matcher(filename);
- matcherClassName.find();
- final String className = matcherClassName.group(1);
- final Class<?> tempClass = Class.forName(logParserPackage+"."+className);
- if (tempClass.isInterface()) {
- if (debug) System.out.println(tempClass.getName() + " is an Interface");
- } else {
- final Object theParser = tempClass.newInstance();
- if (theParser instanceof LogParser) {
- final LogParser theLogParser = (LogParser) theParser;
- //System.out.println(bla.getName() + " is a logParser");
- logParsers.put(theLogParser.getParserType(), theParser);
-
- if (debug) System.out.println("Added " + theLogParser.getClass().getName() + " as " + theLogParser.getParserType() + " Parser.");
- }
- else {
- //System.out.println(bla.getName() + " is not a logParser");
- if (debug) System.out.println("Rejected " + tempClass.getName() + ". Class does not implement the logParser-Interface");
-
- }
- }
- }
+ for (final String filename: parserDirFiles) {
+ if (filename.endsWith("LogalizerHandler.class")) continue;
+ final Pattern patternGetClassName = Pattern.compile(".*\\"+ File.separator +"([^\\"+ File.separator +"]+)\\.class");
+ final Matcher matcherClassName = patternGetClassName.matcher(filename);
+ matcherClassName.find();
+ final String className = matcherClassName.group(1);
+ final Class<?> tempClass = Class.forName(logParserPackage+"."+className);
+ if (tempClass.isInterface()) {
+ if (debug) System.out.println(tempClass.getName() + " is an Interface");
+ } else {
+ final Object theParser = tempClass.newInstance();
+ if (theParser instanceof LogParser) {
+ final LogParser theLogParser = (LogParser) theParser;
+ //System.out.println(bla.getName() + " is a logParser");
+ logParsers.put(theLogParser.getParserType(), theParser);
+
+ if (debug) System.out.println("Added " + theLogParser.getClass().getName() + " as " + theLogParser.getParserType() + " Parser.");
+ }
+ else {
+ //System.out.println(bla.getName() + " is not a logParser");
+ if (debug) System.out.println("Rejected " + tempClass.getName() + ". Class does not implement the logParser-Interface");
+
+ }
+ }
+ }
} catch (final ClassNotFoundException e) {
e.printStackTrace();
} catch (final InstantiationException e) {
diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java
index 4374ad481..c625c32f9 100644
--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java
+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java
@@ -27,7 +27,7 @@ package de.anomic.yacy.seedUpload;
import java.io.File;
-import de.anomic.server.serverFileUtils;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacySeedUploader;
@@ -44,7 +44,7 @@ public class yacySeedUploadFile implements yacySeedUploader {
if (seedFilePath.length() == 0) throw new Exception("Path to seed file is not configured properly");
final File publicSeedFile = new File(seedFilePath);
- serverFileUtils.copy(seedFile,publicSeedFile);
+ FileUtils.copy(seedFile,publicSeedFile);
return "Seed-List file stored successfully";
} catch (final Exception e) {
diff --git a/source/de/anomic/yacy/yacyAccessible.java b/source/de/anomic/yacy/yacyAccessible.java
index 4572c9345..45707e466 100644
--- a/source/de/anomic/yacy/yacyAccessible.java
+++ b/source/de/anomic/yacy/yacyAccessible.java
@@ -30,8 +30,8 @@ package de.anomic.yacy;
import java.io.File;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverFileUtils;
public class yacyAccessible {
public long lastUpdated;
@@ -46,7 +46,7 @@ public class yacyAccessible {
final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
final File shortcut = new File(sb.getRootPath() + "/addon/YaCy-Search.html".replace("/", File.separator));
final String content = "<meta http-equiv=\"refresh\" content=\"0;url=http://localhost:" + newPort + "/\">";
- serverFileUtils.copy(content.getBytes(), shortcut);
+ FileUtils.copy(content.getBytes(), shortcut);
} catch (final Exception e) {
return;
}
@@ -61,7 +61,7 @@ public class yacyAccessible {
final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
final File shortcut = new File(sb.getRootPath() + "/addon/YaCy-Search.bat".replace("/", File.separator));
final String content = "rundll32 url.dll,FileProtocolHandler \"http://localhost:" + newPort + "\"";
- serverFileUtils.copy(content.getBytes(), shortcut);
+ FileUtils.copy(content.getBytes(), shortcut);
} catch (final Exception e) {
return;
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 34d06f3a2..1a07ca157 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -77,6 +77,7 @@ import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Bitfield;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.ByteBuffer;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSearchRankingProcess;
import de.anomic.plasma.plasmaSearchRankingProfile;
import de.anomic.plasma.plasmaSnippetCache;
@@ -86,7 +87,6 @@ import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
import de.anomic.tools.crypt;
-import de.anomic.tools.nxTools;
import de.anomic.xml.RSSFeed;
import de.anomic.xml.RSSReader;
@@ -127,7 +127,7 @@ public final class yacyClient {
final long start = System.currentTimeMillis();
final byte[] content = wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post, 15000, false);
yacyCore.log.logInfo("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' contacted peer at " + address + ", received " + ((content == null) ? "null" : content.length) + " bytes, time = " + (System.currentTimeMillis() - start) + " milliseconds");
- result = nxTools.table(content, "UTF-8");
+ result = FileUtils.table(content, "UTF-8");
break;
} catch (final Exception e) {
if (Thread.currentThread().isInterrupted()) {
@@ -314,7 +314,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 10000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
if (result == null || result.size() == 0) { return null; }
//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time
@@ -336,7 +336,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 5000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
if (result == null || result.size() == 0) { return -1; }
return Integer.parseInt(result.get("response"));
@@ -359,7 +359,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 5000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
if ((result == null) || (result.size() == 0)) return -1;
final String resp = result.get("response");
@@ -478,7 +478,7 @@ public final class yacyClient {
// send request
HashMap<String, String> result = null;
try {
- result = nxTools.table(wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000), "UTF-8");
+ result = FileUtils.table(wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000), "UTF-8");
} catch (final IOException e) {
yacyCore.log.logInfo("SEARCH failed, Peer: " + target.hash + ":" + target.getName() + " (" + e.getMessage() + "), score=" + target.selectscore + ", DHTdist=" + yacySeed.dhtDistance(wordhashes.substring(0, 12), target));
//yacyCore.peerActions.peerDeparture(target, "search request to peer created io exception: " + e.getMessage());
@@ -677,7 +677,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 5000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
return result;
} catch (final Exception e) {
// most probably a network time-out exception
@@ -704,7 +704,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 20000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
return result;
} catch (final Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
@@ -740,7 +740,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", targetAddress, post, 10000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
return result;
} catch (final Exception e) {
// most probably a network time-out exception
@@ -764,7 +764,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", targetAddress, post, 20000);
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
return result;
} catch (final Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
@@ -839,7 +839,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = wput("http://" + address + "/yacy/crawlReceipt.html", target.getHexHash() + ".yacyh", post, 10000);
- return nxTools.table(content, "UTF-8");
+ return FileUtils.table(content, "UTF-8");
} catch (final Exception e) {
// most probably a network time-out exception
yacyCore.log.logSevere("yacyClient.crawlReceipt error:" + e.getMessage());
@@ -978,13 +978,13 @@ public final class yacyClient {
post.add(new DefaultCharsetStringPart("indexes", entrypost.toString()));
try {
final byte[] content = wput("http://" + address + "/yacy/transferRWI.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);
- final ArrayList<String> v = nxTools.strings(content, "UTF-8");
+ final ArrayList<String> v = FileUtils.strings(content, "UTF-8");
// this should return a list of urlhashes that are unknown
if ((v != null) && (v.size() > 0)) {
seedDB.mySeed().incSI(indexcount);
}
- final HashMap<String, String> result = nxTools.table(v);
+ final HashMap<String, String> result = FileUtils.table(v);
// return the transfered index data in bytes (for debugging only)
result.put("indexPayloadSize", Integer.toString(entrypost.length()));
return result;
@@ -1024,13 +1024,13 @@ public final class yacyClient {
post.add(new DefaultCharsetStringPart("urlc", Integer.toString(urlc)));
try {
final byte[] content = wput("http://" + address + "/yacy/transferURL.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);
- final ArrayList<String> v = nxTools.strings(content, "UTF-8");
+ final ArrayList<String> v = FileUtils.strings(content, "UTF-8");
if ((v != null) && (v.size() > 0)) {
seedDB.mySeed().incSU(urlc);
}
- final HashMap<String, String> result = nxTools.table(v);
+ final HashMap<String, String> result = FileUtils.table(v);
// return the transfered url data in bytes (for debugging only)
result.put("urlPayloadSize", Integer.toString(urlPayloadSize));
return result;
@@ -1050,7 +1050,7 @@ public final class yacyClient {
if (address == null) { address = "localhost:8080"; }
try {
final byte[] content = wput("http://" + address + "/yacy/profile.html", targetSeed.getHexHash() + ".yacyh", post, 5000);
- return nxTools.table(content, "UTF-8");
+ return FileUtils.table(content, "UTF-8");
} catch (final Exception e) {
yacyCore.log.logSevere("yacyClient.getProfile error:" + e.getMessage());
return null;
@@ -1089,7 +1089,7 @@ public final class yacyClient {
"&query=" + wordhashe +
"&network.unit.name=" + plasmaSwitchboard.getSwitchboard().getConfig(plasmaSwitchboardConstants.NETWORK_NAME, yacySeed.DFLT_NETWORK_UNIT),
reqHeader, 10000, target.getHexHash() + ".yacyh");
- final HashMap<String, String> result = nxTools.table(content, "UTF-8");
+ final HashMap<String, String> result = FileUtils.table(content, "UTF-8");
System.out.println("Result=" + result.toString());
} catch (final Exception e) {
e.printStackTrace();
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 46e481c2c..3fd25e89a 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -51,12 +51,11 @@ import de.anomic.kelondro.blob.MapDataMining;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.util.kelondroException;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSwitch;
-import de.anomic.tools.nxTools;
public final class yacySeedDB implements httpdAlternativeDomainNames {
@@ -827,10 +826,10 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
try {
// uncompress it if it is gzipped
- content = serverFileUtils.uncompressGZipArray(content);
+ content = FileUtils.uncompressGZipArray(content);
// convert it into an array
- return nxTools.strings(content,"UTF-8");
+ return FileUtils.strings(content,"UTF-8");
} catch (final Exception e) {
throw new IOException("Unable to download seed file '" + seedURL + "'. " + e.getMessage());
}
diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java
index 5be80802d..78fdd73b3 100644
--- a/source/de/anomic/yacy/yacyVersion.java
+++ b/source/de/anomic/yacy/yacyVersion.java
@@ -49,9 +49,9 @@ import de.anomic.http.JakartaCommonsHttpResponse;
import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSystem;
import de.anomic.tools.tarTools;
@@ -358,7 +358,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya
download = new File(storagePath, name);
}
try {
- serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(new FileOutputStream(download)));
+ FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(new FileOutputStream(download)));
} catch(IOException ie) {
// Saving file failed, abort download
res.abort();
diff --git a/source/migration.java b/source/migration.java
index 4b72b9a18..014bd8f9e 100644
--- a/source/migration.java
+++ b/source/migration.java
@@ -27,9 +27,9 @@ import de.anomic.http.httpd;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.server.serverFileUtils;
public class migration {
//SVN constants
@@ -87,7 +87,7 @@ public class migration {
for(String skinFile : skinFiles){
if(skinFile.endsWith(".css")){
try{
- serverFileUtils.copy(new File(defaultSkinsPath, skinFile), new File(skinsPath, skinFile));
+ FileUtils.copy(new File(defaultSkinsPath, skinFile), new File(skinsPath, skinFile));
}catch(final IOException e){}
}
}
@@ -109,7 +109,7 @@ public class migration {
}else{
try {
mkdirs(styleFile.getParentFile());
- serverFileUtils.copy(skinFile, styleFile);
+ FileUtils.copy(skinFile, styleFile);
Log.logInfo("MIGRATION", "copied new Skinfile");
} catch (final IOException e) {
Log.logSevere("MIGRATION", "Cannot copy skinfile.");
@@ -151,7 +151,7 @@ public class migration {
sb.wikiDB.close();
file2 = new File(sb.workPath, "wiki.db");
try {
- serverFileUtils.copy(file, file2);
+ FileUtils.copy(file, file2);
file.delete();
} catch (final IOException e) {
}
@@ -161,7 +161,7 @@ public class migration {
Log.logInfo("MIGRATION", "Migrating wiki-bkp.db to "+ sb.workPath);
file2 = new File(sb.workPath, "wiki-bkp.db");
try {
- serverFileUtils.copy(file, file2);
+ FileUtils.copy(file, file2);
file.delete();
} catch (final IOException e) {}
}
@@ -175,7 +175,7 @@ public class migration {
sb.messageDB.close();
file2=new File(sb.workPath, "message.db");
try {
- serverFileUtils.copy(file, file2);
+ FileUtils.copy(file, file2);
file.delete();
} catch (final IOException e) {}
sb.initMessages();
diff --git a/source/yacy.java b/source/yacy.java
index fca237521..1bca4e67d 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -67,15 +67,15 @@ import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.ScoreCluster;
import de.anomic.kelondro.util.Log;
+import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverCore;
-import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSemaphore;
import de.anomic.server.serverSystem;
import de.anomic.tools.enumerateFiles;
-import de.anomic.tools.yFormatter;
+import de.anomic.tools.Formatter;
import de.anomic.yacy.yacyClient;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyTray;
@@ -187,7 +187,7 @@ public final class yacy {
mkdirsIfNeseccary(f);
f = new File(homePath, "DATA/LOG/yacy.logging");
if (!f.exists()) try {
- serverFileUtils.copy(new File(homePath, "yacy.logging"), f);
+ FileUtils.copy(new File(homePath, "yacy.logging"), f);
} catch (final IOException e){
System.out.println("could not copy yacy.logging");
}
@@ -281,12 +281,12 @@ public final class yacy {
// create default notifier picture
//TODO: Use templates instead of copying images ...
if (!((new File(htDocsPath, "notifier.gif")).exists())) try {
- serverFileUtils.copy(new File(htRootPath, "env/grafics/empty.gif"),
+ FileUtils.copy(new File(htRootPath, "env/grafics/empty.gif"),
new File(htDocsPath, "notifier.gif"));
} catch (final IOException e) {}
final File htdocsReadme = new File(htDocsPath, "readme.txt");
- if (!(htdocsReadme.exists())) try {serverFileUtils.copy((
+ if (!(htdocsReadme.exists())) try {FileUtils.copy((
"This is your root directory for individual Web Content\r\n" +
"\r\n" +
"Please place your html files into the www subdirectory.\r\n" +
@@ -364,7 +364,7 @@ public final class yacy {
target = new File(locale_work, locale_source_files[i].getName());
if (locale_source_files[i].getName().endsWith(".lng")) {
if (target.exists()) delete(target);
- serverFileUtils.copy(locale_source_files[i], target);
+ FileUtils.copy(locale_source_files[i], target);
}
}
Log.logInfo("STARTUP", "Copied the default locales to " + locale_work.toString());
@@ -396,7 +396,7 @@ public final class yacy {
} catch (final IOException e) {}
}
// initialize number formatter with this locale
- yFormatter.setLocale(lang);
+ Formatter.setLocale(lang);
// registering shutdown hook
Log.logConfig("STARTUP", "Registering Shutdown Hook");
@@ -579,7 +579,7 @@ public final class yacy {
Log.logConfig("REMOTE-SHUTDOWN", "Stand by for termination, which may last some seconds.");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
- serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(bos));
+ FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(bos));
} finally {
res.closeStream();
}
@@ -820,7 +820,7 @@ public final class yacy {
private static void transferCR(final String targetaddress, final String crfile) {
final File f = new File(crfile);
try {
- final byte[] b = serverFileUtils.read(f);
+ final byte[] b = FileUtils.read(f);
final String result = yacyClient.transfer(targetaddress, f.getName(), b);
if (result == null)
Log.logInfo("TRANSFER-CR", "transmitted file " + crfile + " to " + targetaddress + " successfully");
diff --git a/yacy.logging b/yacy.logging
index b043c361d..affee27ac 100644
--- a/yacy.logging
+++ b/yacy.logging
@@ -29,9 +29,9 @@ java.awt.level = OFF
# List of global handlers
handlers = java.util.logging.FileHandler,\
- de.anomic.server.logging.GuiHandler,\
- de.anomic.server.logging.ConsoleOutErrHandler,\
- de.anomic.server.logging.LogalizerHandler
+ de.anomic.yacy.logging.GuiHandler,\
+ de.anomic.yacy.logging.ConsoleOutErrHandler,\
+ de.anomic.yacy.logging.LogalizerHandler
# Properties for the FileHandler
java.util.logging.FileHandler.limit = 1048576
@@ -42,17 +42,17 @@ java.util.logging.FileHandler.formatter=de.anomic.server.logging.serverSimpleLog
java.util.logging.FileHandler.encoding=UTF-8
# Properties for the GuiHandler
-de.anomic.server.logging.GuiHandler.level = ALL
-de.anomic.server.logging.GuiHandler.formatter=de.anomic.server.logging.serverSimpleLogFormatter
-de.anomic.server.logging.GuiHandler.size = 400
+de.anomic.yacy.logging.GuiHandler.level = ALL
+de.anomic.yacy.logging.GuiHandler.formatter=de.anomic.server.logging.serverSimpleLogFormatter
+de.anomic.yacy.logging.GuiHandler.size = 400
# Properties for the ConsoleOutErrHandler
-de.anomic.server.logging.ConsoleOutErrHandler.level = ALL
-de.anomic.server.logging.ConsoleOutErrHandler.levelStdOut = ALL
-de.anomic.server.logging.ConsoleOutErrHandler.levelSplit = WARNING
-de.anomic.server.logging.ConsoleOutErrHandler.levelStdErr = ALL
-de.anomic.server.logging.ConsoleOutErrHandler.formatter=de.anomic.server.logging.serverSimpleLogFormatter
-#de.anomic.server.logging.ConsoleOutErrHandler.ignoreCtrlChr=true
+de.anomic.yacy.logging.ConsoleOutErrHandler.level = ALL
+de.anomic.yacy.logging.ConsoleOutErrHandler.levelStdOut = ALL
+de.anomic.yacy.logging.ConsoleOutErrHandler.levelSplit = WARNING
+de.anomic.yacy.logging.ConsoleOutErrHandler.levelStdErr = ALL
+de.anomic.yacy.logging.ConsoleOutErrHandler.formatter=de.anomic.server.logging.serverSimpleLogFormatter
+#de.anomic.yacy.logging.ConsoleOutErrHandler.ignoreCtrlChr=true
# Properties for the proxy access logger
de.anomic.http.httpdProxyHandler.logging.enabled = TRUE
@@ -61,6 +61,6 @@ de.anomic.http.httpdProxyHandler.logging.FileHandler.count = 20
de.anomic.http.httpdProxyHandler.logging.FileHandler.pattern = DATA/LOG/proxyAccess%u%g.log
# Properties for the LogalizerHandler
-de.anomic.server.logging.LogalizerHandler.enabled = false
-de.anomic.server.logging.LogalizerHandler.debug = false
-de.anomic.server.logging.LogalizerHandler.parserPackage = de.anomic.server.logging.logParsers
+de.anomic.yacy.logging.LogalizerHandler.enabled = false
+de.anomic.yacy.logging.LogalizerHandler.debug = false
+de.anomic.yacy.logging.LogalizerHandler.parserPackage = de.anomic.yacy.logging