Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) next step of restructuring for new crawlers - IndexCreate_p.java: correcting problems with ftp urls - URL.java does not cutout the userinfo anymore (needed to transport authentication info in ftp urls, e.g. ftp://username:[email protected]) - plasmaCrawlLoader.java: -- hack to re enable https urls -- adding function getSupportedProtocols
theli584749253780
diff --git a/htroot/IndexCreate_p.java b/htroot/IndexCreate_p.javaindex 486b43b74..8387e554a 100644--- a/htroot/IndexCreate_p.java+++ b/htroot/IndexCreate_p.java@@ -140,7 +140,8 @@ public class IndexCreate_p {crawlingStart = crawlingStart.trim();// adding the prefix http:// if necessary- if (!(crawlingStart.startsWith("http"))) crawlingStart = "http://" + crawlingStart;+ int pos = crawlingStart.indexOf("://");+ if (pos == -1) crawlingStart = "http://" + crawlingStart;// normalizing URLtry {crawlingStart = new URL(crawlingStart).toNormalform();} catch (MalformedURLException e1) {}diff --git a/source/de/anomic/net/URL.java b/source/de/anomic/net/URL.javaindex d5148c201..4654d2b89 100644--- a/source/de/anomic/net/URL.java+++ b/source/de/anomic/net/URL.java@@ -278,8 +278,8 @@ public class URL {matcher.reset(path);}- if (defaultPort) { return this.protocol + "://" + this.getHost().toLowerCase() + path; }- return this.protocol + "://" + this.getHost().toLowerCase() + ((defaultPort) ? "" : (":" + this.port)) + path;+ if (defaultPort) { return this.protocol + "://" + (this.userInfo!=null?this.userInfo+"@":"") + this.getHost().toLowerCase() + path; }+ return this.protocol + "://" + (this.userInfo!=null?this.userInfo+"@":"")+ this.getHost().toLowerCase() + ((defaultPort) ? "" : (":" + this.port)) + path;}public boolean equals(URL other) {diff --git a/source/de/anomic/plasma/plasmaCrawlLoader.java b/source/de/anomic/plasma/plasmaCrawlLoader.javaindex df4887a96..8601cb646 100644--- a/source/de/anomic/plasma/plasmaCrawlLoader.java+++ b/source/de/anomic/plasma/plasmaCrawlLoader.java@@ -44,6 +44,9 @@package de.anomic.plasma;+import java.util.Arrays;+import java.util.HashSet;+import org.apache.commons.pool.impl.GenericKeyedObjectPool;import org.apache.commons.pool.impl.GenericObjectPool;@@ -61,6 +64,8 @@ public final class plasmaCrawlLoader extends Thread {private final plasmaHTCache cacheManager;private final serverLog log;+ private HashSet supportedProtocols;+private final plasmaCrawlerMsgQueue theQueue;private final plasmaCrawlerPool crawlwerPool;private GenericKeyedObjectPool.Config crawlerPoolConfig = null;@@ -76,6 +81,10 @@ public final class plasmaCrawlLoader extends Thread {this.cacheManager = theCacheManager;this.log = theLog;+ // supported protocols+ // TODO: change this, e.g. by loading settings from file+ this.supportedProtocols = new HashSet(Arrays.asList(new String[]{"http","https","ftp"}));+// configuring the crawler messagequeuethis.theQueue = new plasmaCrawlerMsgQueue();@@ -124,11 +133,11 @@ public final class plasmaCrawlLoader extends Thread {public boolean isSupportedProtocol(String protocol) {if ((protocol == null) || (protocol.length() == 0)) return false;-- // TODO: read the supported protocols out from a config file- protocol = protocol.trim().toLowerCase();- return protocol.equals("http") ||- protocol.equals("https");+ return this.supportedProtocols.contains(protocol.trim().toLowerCase());+ }++ public HashSet getSupportedProtocols() {+ return (HashSet) this.supportedProtocols.clone();}public void close() {@@ -155,6 +164,9 @@ public final class plasmaCrawlLoader extends Thread {// getting the protocol of the next URLString protocol = theMsg.url.getProtocol();+ // TODO: remove this+ if (protocol.equals("https")) protocol = "http";+// getting a new crawler from the crawler poolplasmaCrawlWorker theWorker = (plasmaCrawlWorker) this.crawlwerPool.borrowObject(protocol);if (theWorker == null) {