Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
This is a large bugfix and enhancement commit to support a better location detection for data - fixes to http file server session handling - fixes and enhancements to metadata date/time handling - added dc:publisher metadata field and updated all document parser - fixed bug in metdata read procedure - enhanced dublin core and rss parser to understand more fields more properly - enhanced url selection in case that multiple urls are given in surrogates - fix for condenser; failure when last word does not end with termination symbol
orbitercf43bdc87e47
diff --git a/defaults/httpd.mime b/defaults/httpd.mimeindex 0717448d9..9dabb1c70 100644--- a/defaults/httpd.mime+++ b/defaults/httpd.mime@@ -40,6 +40,7 @@ jpeg = image/jpegjpg = image/jpegjs = text/javascriptjsp = text/html+kml = application/vnd.google-earth.kml+xmllha = application/x-lzhlzh = application/x-lzhm4v = video/x-m4vdiff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.javaindex 85c01ec40..98157cb36 100644--- a/htroot/AccessTracker_p.java+++ b/htroot/AccessTracker_p.java@@ -36,6 +36,7 @@ import java.util.TreeSet;import java.util.Map.Entry;import java.text.SimpleDateFormat;+import de.anomic.http.server.HeaderFramework;import de.anomic.http.server.RequestHeader;import de.anomic.net.natLib;import de.anomic.search.QueryParams;@@ -64,7 +65,7 @@ public class AccessTracker_p {// return variable that accumulates replacementsfinal serverObjects prop = new serverObjects();- prop.setLocalized(!(header.get("PATH")).endsWith(".xml"));+ prop.setLocalized(!(header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml"));int page = 0;if (post != null) page = post.getInt("page", 0);prop.put("page", page);diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.javaindex c3c76a968..c90ed636f 100644--- a/htroot/Blacklist_p.java+++ b/htroot/Blacklist_p.java@@ -45,6 +45,7 @@ import net.yacy.repository.Blacklist;import de.anomic.data.WorkTables;import de.anomic.data.listManager;+import de.anomic.http.server.HeaderFramework;import de.anomic.http.server.RequestHeader;import de.anomic.search.SearchEventCache;import de.anomic.search.Switchboard;@@ -525,7 +526,7 @@ public class Blacklist_p {}if (newEntry == null || newEntry.length() == 0) {- return header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse;+ return header.get(HeaderFramework.CONNECTION_PROP_PATH) + "?selectList=&selectedListName=" + blacklistToUse;}addBlacklistEntry(listManager.listsPath, blacklistToUse, newEntry, supportedBlacklistTypes);@@ -553,7 +554,7 @@ public class Blacklist_p {}if (oldEntry == null || oldEntry.length() == 0) {- return header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse;+ return header.get(HeaderFramework.CONNECTION_PROP_PATH) + "?selectList=&selectedListName=" + blacklistToUse;}deleteBlacklistEntry(listManager.listsPath, blacklistToUse, oldEntry, supportedBlacklistTypes);diff --git a/htroot/Connections_p.java b/htroot/Connections_p.javaindex 59ffec827..4205bed78 100644--- a/htroot/Connections_p.java+++ b/htroot/Connections_p.java@@ -30,7 +30,6 @@import java.io.UnsupportedEncodingException;import java.net.InetAddress;import java.net.URLEncoder;-import java.util.Properties;import java.util.Set;import net.yacy.kelondro.logging.Log;@@ -39,12 +38,9 @@ import net.yacy.kelondro.workflow.WorkflowThread;import de.anomic.http.client.ConnectionInfo;import de.anomic.http.client.Client;-import de.anomic.http.server.HTTPDemon;-import de.anomic.http.server.HeaderFramework;import de.anomic.http.server.RequestHeader;import de.anomic.search.Switchboard;import de.anomic.server.serverCore;-import de.anomic.server.serverHandler;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.serverCore.Session;@@ -100,24 +96,8 @@ public final class Connections_p {final int userPort = s.getUserPort();if (userAddress == null) continue;- final boolean isSSL = s.isSSL();-String dest = null;String prot = null;- final serverHandler cmdObj = s.getCommandObj();- if (cmdObj instanceof HTTPDemon) {- prot = isSSL ? "https":"http";-- // get the http command object- final HTTPDemon currentHttpd = (HTTPDemon)cmdObj;-- // get the connection properties of this session- final Properties conProp = (Properties) currentHttpd.getConProp().clone();-- // get the destination host- dest = conProp.getProperty(HeaderFramework.CONNECTION_PROP_HOST);- if (dest==null)continue;- }if ((dest != null) && (dest.equals(virtualHost))) dest = sb.peers.mySeed().getName() + ".yacy";diff --git a/htroot/Network.java b/htroot/Network.javaindex 886a13eb4..705d0316a 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -41,6 +41,7 @@ import net.yacy.kelondro.util.MapTools;import de.anomic.crawler.retrieval.HTTPLoader;import de.anomic.http.client.Client;+import de.anomic.http.server.HeaderFramework;import de.anomic.http.server.RequestHeader;import de.anomic.search.Switchboard;import de.anomic.search.SwitchboardConstants;@@ -62,7 +63,7 @@ public class Network {// return variable that accumulates replacementsfinal serverObjects prop = new serverObjects();- prop.setLocalized(!(requestHeader.get("PATH")).endsWith(".xml"));+ prop.setLocalized(!(requestHeader.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml"));prop.putHTML("page_networkTitle", sb.getConfig("network.unit.description", "unspecified"));prop.putHTML("page_networkName", sb.getConfig(SwitchboardConstants.NETWORK_NAME, "unspecified"));final boolean overview = (post == null) || (post.get("page", "0").equals("0"));diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.javaindex 58edf2e9b..3dd7c16ac 100644--- a/htroot/PerformanceQueues_p.java+++ b/htroot/PerformanceQueues_p.java@@ -35,6 +35,7 @@ import net.yacy.kelondro.util.MemoryControl;import net.yacy.kelondro.util.OS;import net.yacy.kelondro.workflow.BusyThread;import net.yacy.kelondro.workflow.WorkflowThread;+import de.anomic.http.server.HeaderFramework;import de.anomic.http.server.RequestHeader;import de.anomic.search.Segment;import de.anomic.search.Segments;@@ -115,7 +116,7 @@ public class PerformanceQueues_p {String threadName;BusyThread thread;- final boolean xml = (header.get("PATH")).endsWith(".xml");+ final boolean xml = (header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml");prop.setLocalized(!xml);// calculate totalsdiff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.javaindex a6f485bdd..da8de0e12 100644--- a/htroot/api/yacydoc.java+++ b/htroot/api/yacydoc.java@@ -96,7 +96,7 @@ public class yacydoc {prop.putXML("dc_creator", metadata.dc_creator());prop.putXML("dc_description", ""); // this is the fulltext part in the surrogateprop.putXML("dc_subject", metadata.dc_subject());- prop.putXML("dc_publisher", "");+ prop.putXML("dc_publisher", metadata.dc_publisher());prop.putXML("dc_contributor", "");prop.putXML("dc_date", entry.moddate().toString());prop.putXML("dc_type", String.valueOf(entry.doctype()));diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 95b810ade..900e771a3 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -560,7 +560,7 @@ public class yacysearch {}// find geographic info- Set<Location> coordinates = LibraryProvider.geoDB.find(originalquerystring);+ Set<Location> coordinates = LibraryProvider.geoDB.find(originalquerystring, false);if (coordinates == null || coordinates.isEmpty() || offset > 0) {prop.put("geoinfo", "0");} else {diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 94a184624..705398054 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -137,7 +137,9 @@ public class yacysearchitem {prop.putHTML("content_file", result.url().getFile());prop.putHTML("content_path", result.url().getPath());prop.put("content_nl", (item == 0) ? 0 : 1);-+ prop.putHTML("content_publisher", result.publisher());+ prop.putHTML("content_creator", result.creator());// author+ prop.putHTML("content_subject", result.subject());final TreeSet<String>[] query = theQuery.queryWords();try {prop.putHTML("content_words", URLEncoder.encode(query[0].toString(),"UTF-8"));diff --git a/htroot/yacysearchitem.xml b/htroot/yacysearchitem.xmlindex 12ce3701d..28c868a7b 100644--- a/htroot/yacysearchitem.xml+++ b/htroot/yacysearchitem.xml@@ -3,6 +3,9 @@<link>#[link]#</link><description>#[description-xml]#</description><pubDate>#[date822]#</pubDate>+<dc:publisher>#[publisher]#</dc:publisher>+<dc:creator>#[creator]#</dc:creator>+<dc:subject>#[subject]#</dc:subject><yacy:size>#[size]#</yacy:size><yacy:sizename>#[sizename]#</yacy:sizename><yacy:host>#[host]#</yacy:host>diff --git a/source/de/anomic/crawler/retrieval/Request.java b/source/de/anomic/crawler/retrieval/Request.javaindex aae032a1c..229b3b84f 100755--- a/source/de/anomic/crawler/retrieval/Request.java+++ b/source/de/anomic/crawler/retrieval/Request.java@@ -65,7 +65,7 @@ public class Request extends WorkflowJob {private byte[] refhash; // the url's referrer hashprivate DigestURI url; // the url as stringprivate String name; // the name of the url, from anchor tag <a>name</a>- private long appdate; // the time when the url was first time appeared+ private long appdate; // the time when the url was first time appeared. may be negative in case that the date is before epoch (1970)!private long imsdate; // the time of a ifModifiedSince requestprivate String profileHandle; // the name of the fetch profileprivate int depth; // the prefetch depth so far, starts at 0diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.javaindex 2d6ec199f..5bba6422d 100644--- a/source/de/anomic/http/server/HTTPDFileHandler.java+++ b/source/de/anomic/http/server/HTTPDFileHandler.java@@ -443,7 +443,7 @@ public final class HTTPDFileHandler {File f;String size;long sz;- String headline, author, description;+ String headline, author, description, publisher;int images, links;ContentScraper scraper;for (int i = 0; i < list.length; i++) {@@ -455,12 +455,14 @@ public final class HTTPDFileHandler {scraper = ContentScraper.parseResource(f);headline = scraper.getTitle();author = scraper.getAuthor();+ publisher = scraper.getPublisher();description = scraper.getDescription();images = scraper.getImages().size();links = scraper.getAnchors().size();} else {headline = null;author = null;+ publisher = null;description = null;images = 0;links = 0;@@ -474,10 +476,11 @@ public final class HTTPDFileHandler {size = (sz / 1024 / 1024) + " MB";}aBuffer.append(" <li>");- if ((headline != null) && (headline.length() > 0)) aBuffer.append("<a href=\"" + list[i] + "\"><b>" + headline + "</b></a><br>");+ if (headline != null && headline.length() > 0) aBuffer.append("<a href=\"" + list[i] + "\"><b>" + headline + "</b></a><br>");aBuffer.append("<a href=\"" + path + list[i] + "\">" + list[i] + "</a><br>");- if ((author != null) && (author.length() > 0)) aBuffer.append("Author: " + author + "<br>");- if ((description != null) && (description.length() > 0)) aBuffer.append("Description: " + description + "<br>");+ if (author != null && author.length() > 0) aBuffer.append("Author: " + author + "<br>");+ if (publisher != null && publisher.length() > 0) aBuffer.append("Publisher: " + publisher + "<br>");+ if (description != null && description.length() > 0) aBuffer.append("Description: " + description + "<br>");aBuffer.append(DateFormatter.formatShortDay(new Date(f.lastModified())) + ", " + size + ((images > 0) ? ", " + images + " images" : "") + ((links > 0) ? ", " + links + " links" : "") + "<br></li>\n");}}@@ -514,6 +517,7 @@ public final class HTTPDFileHandler {try {requestHeader.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, conProp.getProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP));requestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, path);+ requestHeader.put(HeaderFramework.CONNECTION_PROP_EXT, "png");// in case that there are no args given, args = null or empty hashmapimg = invokeServlet(targetClass, requestHeader, args);} catch (final InvocationTargetException e) {@@ -707,6 +711,7 @@ public final class HTTPDFileHandler {// call rewrite-classrequestHeader.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, conProp.getProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP));requestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, path);+ requestHeader.put(HeaderFramework.CONNECTION_PROP_EXT, "stream");//requestHeader.put(httpHeader.CONNECTION_PROP_INPUTSTREAM, body);//requestHeader.put(httpHeader.CONNECTION_PROP_OUTPUTSTREAM, out);@@ -732,6 +737,7 @@ public final class HTTPDFileHandler {path.endsWith("pac") ||path.endsWith("src") ||path.endsWith("vcf") ||+ path.endsWith("kml") ||path.endsWith("/") ||path.equals("/robots.txt")) {@@ -750,6 +756,8 @@ public final class HTTPDFileHandler {try {requestHeader.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, conProp.getProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP));requestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, path);+ int ep = path.lastIndexOf(".");+ requestHeader.put(HeaderFramework.CONNECTION_PROP_EXT, path.substring(ep + 1));// in case that there are no args given, args = null or empty hashmapfinal Object tmp = invokeServlet(targetClass, requestHeader, args);if (tmp == null) {@@ -760,7 +768,7 @@ public final class HTTPDFileHandler {} else {templatePatterns = new servletProperties((serverObjects) tmp);}- // check if the servlets requests authentification+ // check if the servlets requests authenticationif (templatePatterns.containsKey(servletProperties.ACTION_AUTHENTICATE)) {// handle brute-force protectionif (authorization != null) {diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.javaindex c4a725dc2..59faf7d71 100644--- a/source/de/anomic/http/server/HTTPDemon.java+++ b/source/de/anomic/http/server/HTTPDemon.java@@ -77,6 +77,7 @@ import de.anomic.server.serverCore;import de.anomic.server.serverHandler;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;+import de.anomic.server.serverCore.Session;/**@@ -90,7 +91,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {/*** <p><code>public static final String <strong>ADMIN_ACCOUNT_B64MD5</strong> = "adminAccountBase64MD5"</code></p>- * <p>Name of the setting holding the authentification hash for the static <code>admin</code>-account. It is calculated+ * <p>Name of the setting holding the authentication hash for the static <code>admin</code>-account. It is calculated* by first encoding <code>username:password</code> as Base64 and hashing it using {@link MapTools#encodeMD5Hex(String)}.</p>*/public static final String ADMIN_ACCOUNT_B64MD5 = "adminAccountBase64MD5";@@ -126,20 +127,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {private static HashMap<String, Long> YaCyHopAccessRequester = new HashMap<String, Long>();private static HashMap<String, Long> YaCyHopAccessTargets = new HashMap<String, Long>();- // class objects- private serverCore.Session session; // holds the session object of the calling class- private InetAddress userAddress; // the address of the client-// for authenticationprivate boolean use_proxyAccounts = false;private boolean proxyAccounts_init = false; // is use_proxyAccounts set?- private String clientIP;- private boolean allowProxy;- private boolean allowServer;- private boolean allowYaCyHop;-- // the connection properties- private final Properties prop = new Properties();private int emptyRequestCount = 0;private int keepAliveRequestCount = 0;@@ -155,64 +145,37 @@ public final class HTTPDemon implements serverHandler, Cloneable {// authentication: by default nonethis.proxyAccounts_init = false;- this.clientIP = null;// configuring keep alive supportkeepAliveSupport = Boolean.parseBoolean(switchboard.getConfig("connectionKeepAliveSupport","false"));}- public Properties getConProp() {- return this.prop;- }-/*** Can be used to reset this {@link serverHandler} oject so that* it can be reused for further connections* @see de.anomic.server.serverHandler#reset()*/public void reset() {- this.session = null;- this.userAddress = null;- this.allowProxy = false;- this.allowServer = false;- this.allowYaCyHop = false;this.proxyAccounts_init = false;- this.clientIP = null;- this.prop.clear();this.emptyRequestCount = 0;this.keepAliveRequestCount = 0;- }--- /**- * Must be called at least once, but can be called again to re-use the object.- * @see de.anomic.server.serverHandler#initSession(de.anomic.server.serverCore.Session)- */- public void initSession(final serverCore.Session newsession) throws IOException {- this.session = newsession;- this.userAddress = session.userAddress; // client InetAddress- this.clientIP = this.userAddress.getHostAddress();- if (this.userAddress.isAnyLocalAddress()) this.clientIP = "localhost";- if (this.clientIP.startsWith("0:0:0:0:0:0:0:1")) this.clientIP = "localhost";- if (this.clientIP.startsWith("127.")) this.clientIP = "localhost";+ }++ private static boolean allowProxy(Session session) {final String proxyClient = switchboard.getConfig("proxyClient", "*");+ return (proxyClient.equals("*")) ? true : match(session.userAddress.getHostAddress(), proxyClient);+ }++ private static boolean allowServer(Session session) {final String serverClient = switchboard.getConfig("serverClient", "*");-- this.allowProxy = (proxyClient.equals("*")) ? true : match(this.clientIP, proxyClient);- this.allowServer = (serverClient.equals("*")) ? true : match(this.clientIP, serverClient);- this.allowYaCyHop = switchboard.getConfigBool("YaCyHop", false);-- // check if we want to allow this socket to connect us- if (!(this.allowProxy || this.allowServer || this.allowYaCyHop)) {- final String errorMsg = "CONNECTION FROM " + this.clientIP + " FORBIDDEN";- log.logWarning(errorMsg);- throw new IOException(errorMsg);- }-- this.proxyAccounts_init = false;+ return (serverClient.equals("*")) ? true : match(session.userAddress.getHostAddress(), serverClient);}-++ private static boolean allowYaCyHop(Session session) {+ return switchboard.getConfigBool("YaCyHop", false);+ }+private static boolean match(final String key, final String latch) {// the latch is a comma-separated list of patterns// each pattern may contain one wildcard-character '*' which matches anything@@ -256,15 +219,15 @@ public final class HTTPDemon implements serverHandler, Cloneable {* @param header the received http-headers* @return <code>true</code> if a persistent connection was requested or <code>false</code> otherwise*/- private boolean handlePersistentConnection(final RequestHeader header) {+ private boolean handlePersistentConnection(final RequestHeader header, Properties prop) {if (!keepAliveSupport) {- this.prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,"close");+ prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,"close");return false;}// getting the http version that is used by the client- final String httpVersion = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");+ final String httpVersion = prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");// managing keep-alive: in HTTP/0.9 and HTTP/1.0 every connection is closed// afterwards. In HTTP/1.1 (and above, in the future?) connections are@@ -277,15 +240,15 @@ public final class HTTPDemon implements serverHandler, Cloneable {}final String transferEncoding = header.get(HeaderFramework.TRANSFER_ENCODING, "identity");- final boolean isPostRequest = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_METHOD).equals(HeaderFramework.METHOD_POST);+ final boolean isPostRequest = prop.getProperty(HeaderFramework.CONNECTION_PROP_METHOD).equals(HeaderFramework.METHOD_POST);final boolean hasContentLength = header.containsKey(HeaderFramework.CONTENT_LENGTH);final boolean hasTransferEncoding = header.containsKey(HeaderFramework.TRANSFER_ENCODING) && !transferEncoding.equalsIgnoreCase("identity");// if the request does not contain a content-length we have to close the connection// independently of the value of the connection headerif (persistent && isPostRequest && !(hasContentLength || hasTransferEncoding))- this.prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,"close");- else this.prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,persistent?"keep-alive":"close");+ prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,"close");+ else prop.put(HeaderFramework.CONNECTION_PROP_PERSISTENT,persistent?"keep-alive":"close");return persistent;}@@ -300,14 +263,14 @@ public final class HTTPDemon implements serverHandler, Cloneable {return 1;}- private boolean handleYaCyHopAuthentication(final RequestHeader header) {+ private boolean handleYaCyHopAuthentication(final RequestHeader header, Properties prop, Session session) {// check if the user has allowed that his/her peer is used for hops- if (!this.allowYaCyHop) return false;+ if (!allowYaCyHop(session)) return false;// proxy hops must identify with 4 criteria:// the accessed port must not be port 80- final String host = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST);+ final String host = prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST);if (host == null) return false;int pos;if ((pos = host.indexOf(':')) < 0) {@@ -317,7 +280,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {if (Integer.parseInt(host.substring(pos + 1)) == 80) return false;// the access path must be into the yacy protocol path; it must start with 'yacy'- if (!(this.prop.getProperty(HeaderFramework.CONNECTION_PROP_PATH, "").startsWith("/yacy/"))) return false;+ if (!(prop.getProperty(HeaderFramework.CONNECTION_PROP_PATH, "").startsWith("/yacy/"))) return false;// the accessing client must identify with user:password, where// user = addressed peer name@@ -334,7 +297,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {// furthermore, YaCy hops must not exceed a specific access frequency// check access requester frequency: protection against DoS against this peer- final String requester = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP);+ final String requester = prop.getProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP);if (requester == null) return false;if (lastAccessDelta(YaCyHopAccessRequester, requester) < 10000) return false;YaCyHopAccessRequester.put(requester, Long.valueOf(System.currentTimeMillis()));@@ -353,9 +316,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {return System.currentTimeMillis() - lastAccess.longValue();}- private boolean handleProxyAuthentication(final RequestHeader header) throws IOException {+ private boolean handleProxyAuthentication(final RequestHeader header, Properties prop, Session session) throws IOException {// getting the http version that is used by the client- final String httpVersion = this.prop.getProperty("HTTP", "HTTP/0.9");+ final String httpVersion = prop.getProperty("HTTP", "HTTP/0.9");// reading the authentication settings from switchboardif (!this.proxyAccounts_init) {@@ -365,9 +328,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {if (this.use_proxyAccounts) {final String auth = header.get(RequestHeader.PROXY_AUTHORIZATION,"xxxxxx");- userDB.Entry entry=switchboard.userDB.ipAuth(this.clientIP);+ userDB.Entry entry=switchboard.userDB.ipAuth(session.userAddress.getHostAddress());if(entry == null){- entry=switchboard.userDB.proxyAuth(auth, this.clientIP);+ entry=switchboard.userDB.proxyAuth(auth, session.userAddress.getHostAddress());}if(entry != null){final int returncode=entry.surfRight();@@ -378,27 +341,33 @@ public final class HTTPDemon implements serverHandler, Cloneable {if(returncode==userDB.Entry.PROXY_TIMELIMIT_REACHED){tp.put("limit", "1");//time per daytp.put("limit_timelimit", entry.getTimeLimit());- sendRespondError(this.prop, this.session.out, 403, "Internet-Timelimit reached", new File("proxymsg/proxylimits.inc"), tp, null);+ sendRespondError(prop, session.out, 403, "Internet-Timelimit reached", new File("proxymsg/proxylimits.inc"), tp, null);}else if(returncode==userDB.Entry.PROXY_NORIGHT){tp.put("limit", "0");- sendRespondError(this.prop, this.session.out, 403, "Proxy use forbidden", new File("proxymsg/proxylimits.inc"), tp, null);+ sendRespondError(prop, session.out, 403, "Proxy use forbidden", new File("proxymsg/proxylimits.inc"), tp, null);}return false;}// ask for authenticate- this.session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.CRLF_STRING ++ session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.CRLF_STRING +RequestHeader.PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.CRLF_STRING).getBytes());- this.session.out.write((HeaderFramework.CONTENT_LENGTH + ": 0\r\n").getBytes());- this.session.out.write("\r\n".getBytes());- this.session.out.flush();+ session.out.write((HeaderFramework.CONTENT_LENGTH + ": 0\r\n").getBytes());+ session.out.write("\r\n".getBytes());+ session.out.flush();return false;}return true;}- public Boolean UNKNOWN(final String requestLine) throws IOException {-+ public Boolean EMPTY(final String arg, Session session) throws IOException {+ if (++this.emptyRequestCount > 10) return serverCore.TERMINATE_CONNECTION;+ return serverCore.RESUME_CONNECTION;+ }++ public Boolean UNKNOWN(final String requestLine, Session session) throws IOException {++ Properties prop = parseRequestLine(HeaderFramework.METHOD_GET, requestLine, session);int pos;String unknownCommand = null, args = null;if ((pos = requestLine.indexOf(' ')) > 0) {@@ -409,116 +378,100 @@ public final class HTTPDemon implements serverHandler, Cloneable {args = "";}- parseRequestLine(unknownCommand, args);+ parseRequestLine(unknownCommand, args, session);- sendRespondError(this.prop,this.session.out,4,501,null,unknownCommand + " method not implemented",null);- return serverCore.TERMINATE_CONNECTION;- }-- public Boolean EMPTY(final String arg) throws IOException {- if (++this.emptyRequestCount > 10) return serverCore.TERMINATE_CONNECTION;- return serverCore.RESUME_CONNECTION;- }-- public Boolean TRACE() throws IOException {- sendRespondError(this.prop,this.session.out,4,501,null,"TRACE method not implemented",null);+ sendRespondError(prop, session.out, 4, 501, null, unknownCommand + " method not implemented", null);return serverCore.TERMINATE_CONNECTION;}-- public Boolean OPTIONS() throws IOException {- sendRespondError(this.prop,this.session.out,4,501,null,"OPTIONS method not implemented",null);- return serverCore.TERMINATE_CONNECTION;- }--- public Boolean GET(final String arg) {++ public Boolean GET(final String arg, Session session) {try {// parsing the http request line- parseRequestLine(HeaderFramework.METHOD_GET,arg);+ Properties prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);// we now know the HTTP version. depending on that, we read the header- final String httpVersion = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);+ final String httpVersion = prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);final RequestHeader header = (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9))? new RequestHeader(reverseMappingCache)- : RequestHeader.readHeader(this.prop,this.session);+ : RequestHeader.readHeader(prop, session);// handling transparent proxy support- HeaderFramework.handleTransparentProxySupport(header, this.prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);+ HeaderFramework.handleTransparentProxySupport(header, prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);// determines if the connection should be kept alive- handlePersistentConnection(header);+ handlePersistentConnection(header, prop);- if (this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST).equals(virtualHost)) {+ if (prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST).equals(virtualHost)) {// pass to server- if (this.allowServer) {- HTTPDFileHandler.doGet(this.prop, header, this.session.out);+ if (allowServer(session)) {+ HTTPDFileHandler.doGet(prop, header, session.out);} else {// not authorized through firewall blocking (ip does not match filter)- this.session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this server, because you are using a non-granted IP. allowed are only connections that match with the following filter: " + switchboard.getConfig("serverClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this server, because you are using a non-granted IP. allowed are only connections that match with the following filter: " + switchboard.getConfig("serverClient", "*") + serverCore.CRLF_STRING).getBytes());return serverCore.TERMINATE_CONNECTION;}} else {// pass to proxy- if (((this.allowYaCyHop) && (handleYaCyHopAuthentication(header))) ||- ((this.allowProxy) && (handleProxyAuthentication(header)))) {- HTTPDProxyHandler.doGet(this.prop, header, this.session.out);+ if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||+ ((allowProxy(session)) && (handleProxyAuthentication(header, prop, session)))) {+ HTTPDProxyHandler.doGet(prop, header, session.out);} else {// not authorized through firewall blocking (ip does not match filter)- this.session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using a non-granted IP. allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using a non-granted IP. allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());return serverCore.TERMINATE_CONNECTION;}}- return this.prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;+ return prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;} catch (final Exception e) {- logUnexpectedError(e);+ logUnexpectedError(e, session.userAddress.getHostAddress());return serverCore.TERMINATE_CONNECTION;}}- private void logUnexpectedError(final Exception e) {+ private void logUnexpectedError(final Exception e, String address) {if (e instanceof InterruptedException) {log.logInfo("Interruption detected");} else {final String errorMsg = e.getMessage();if (errorMsg != null) {if (errorMsg.startsWith("Socket closed")) {- log.logInfo("httpd shutdown detected ... (" + e.getMessage() + "), client = " + userAddress.getHostAddress());+ log.logInfo("httpd shutdown detected ... (" + e.getMessage() + "), client = " +address);} else if ((errorMsg.startsWith("Broken pipe") || errorMsg.startsWith("Connection reset"))) {// client closed the connection, so we just end silently- log.logInfo("Client unexpectedly closed connection... (" + e.getMessage() + "), client = " + userAddress.getHostAddress());+ log.logInfo("Client unexpectedly closed connection... (" + e.getMessage() + "), client = " + address);} else if (errorMsg.equals("400 Bad request")) {- log.logInfo("Bad client request ... (" + e.getMessage() + "), client = " + userAddress.getHostAddress());+ log.logInfo("Bad client request ... (" + e.getMessage() + "), client = " + address);} else {- log.logSevere("Unexpected Error ... (" + e.getMessage() + "), client = " + userAddress.getHostAddress(),e);+ log.logSevere("Unexpected Error ... (" + e.getMessage() + "), client = " + address,e);}} else {- log.logSevere("Unexpected Error ... (" + e.getMessage() + "), client = " + userAddress.getHostAddress(),e);+ log.logSevere("Unexpected Error ... (" + e.getMessage() + "), client = " + address,e);}}}- public Boolean HEAD(final String arg) {+ public Boolean HEAD(final String arg, Session session) {try {- parseRequestLine(HeaderFramework.METHOD_HEAD,arg);+ Properties prop = parseRequestLine(HeaderFramework.METHOD_HEAD, arg, session);// we now know the HTTP version. depending on that, we read the headerRequestHeader header;- final String httpVersion = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);+ final String httpVersion = prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);if (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9)) header = new RequestHeader(reverseMappingCache);- else header = RequestHeader.readHeader(this.prop,this.session);+ else header = RequestHeader.readHeader(prop,session);// handle transparent proxy support- HeaderFramework.handleTransparentProxySupport(header, this.prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);+ HeaderFramework.handleTransparentProxySupport(header, prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);// determines if the connection should be kept alive- handlePersistentConnection(header);+ handlePersistentConnection(header, prop);// return multi-line message- if (this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST).equals(virtualHost)) {+ if (prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST).equals(virtualHost)) {// pass to server- if (allowServer) {- HTTPDFileHandler.doHead(prop, header, this.session.out);+ if (allowServer(session)) {+ HTTPDFileHandler.doHead(prop, header, session.out);} else {// not authorized through firewall blocking (ip does not match filter)session.out.write((httpVersion + " 403 refused (IP not granted)" +@@ -527,9 +480,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {}} else {// pass to proxy- if (((this.allowYaCyHop) && (handleYaCyHopAuthentication(header))) ||- ((this.allowProxy) && (handleProxyAuthentication(header)))) {- HTTPDProxyHandler.doHead(prop, header, this.session.out);+ if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||+ ((allowProxy(session)) && (handleProxyAuthentication(header, prop, session)))) {+ HTTPDProxyHandler.doHead(prop, header, session.out);} else {// not authorized through firewall blocking (ip does not match filter)session.out.write((httpVersion + " 403 refused (IP not granted)" +@@ -537,22 +490,22 @@ public final class HTTPDemon implements serverHandler, Cloneable {return serverCore.TERMINATE_CONNECTION;}}- return this.prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;+ return prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;} catch (final Exception e) {- logUnexpectedError(e);+ logUnexpectedError(e, session.userAddress.getHostAddress());return serverCore.TERMINATE_CONNECTION;}}- public Boolean POST(final String arg) {+ public Boolean POST(final String arg, Session session) {try {- parseRequestLine(HeaderFramework.METHOD_POST,arg);+ Properties prop = parseRequestLine(HeaderFramework.METHOD_POST, arg, session);// we now know the HTTP version. depending on that, we read the headerRequestHeader header;- final String httpVersion = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);+ final String httpVersion = prop.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);if (httpVersion.equals(HeaderFramework.HTTP_VERSION_0_9)) header = new RequestHeader(reverseMappingCache);- else header = RequestHeader.readHeader(this.prop,this.session);+ else header = RequestHeader.readHeader(prop, session);// handle transfer-codingfinal InputStream sessionIn;@@ -562,7 +515,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {log.logWarning("client "+ session.getName() +" uses transfer-coding with HTTP version "+ httpVersion +"!");}if("chunked".equalsIgnoreCase(header.get(HeaderFramework.TRANSFER_ENCODING))) {- sessionIn = new ChunkedInputStream(this.session.in);+ sessionIn = new ChunkedInputStream(session.in);} else {// "A server which receives an entity-body with a transfer-coding it does// not understand SHOULD return 501 (Unimplemented), and close the@@ -571,47 +524,47 @@ public final class HTTPDemon implements serverHandler, Cloneable {return serverCore.TERMINATE_CONNECTION;}} else {- sessionIn = this.session.in;+ sessionIn = session.in;}// handle transparent proxy support- HeaderFramework.handleTransparentProxySupport(header, this.prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);+ HeaderFramework.handleTransparentProxySupport(header, prop, virtualHost, HTTPDProxyHandler.isTransparentProxy);// determines if the connection should be kept alive- handlePersistentConnection(header);+ handlePersistentConnection(header, prop);// return multi-line messageif (prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST).equals(virtualHost)) {// pass to server- if (allowServer) {- HTTPDFileHandler.doPost(prop, header, this.session.out, sessionIn);+ if (allowServer(session)) {+ HTTPDFileHandler.doPost(prop, header, session.out, sessionIn);} else {// not authorized through firewall blocking (ip does not match filter)- session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this server, because you are using the non-granted IP " + clientIP + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("serverClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this server, because you are using the non-granted IP " + session.userAddress.getHostAddress() + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("serverClient", "*") + serverCore.CRLF_STRING).getBytes());return serverCore.TERMINATE_CONNECTION;}} else {// pass to proxy- if (((this.allowYaCyHop) && (handleYaCyHopAuthentication(header))) ||- ((this.allowProxy) && (handleProxyAuthentication(header)))) {- HTTPDProxyHandler.doPost(prop, header, this.session.out, sessionIn);+ if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||+ ((allowProxy(session)) && (handleProxyAuthentication(header, prop, session)))) {+ HTTPDProxyHandler.doPost(prop, header, session.out, sessionIn);} else {// not authorized through firewall blocking (ip does not match filter)- session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + clientIP + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + session.userAddress.getHostAddress() + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());return serverCore.TERMINATE_CONNECTION;}}if (sessionIn instanceof ChunkedInputStream) sessionIn.close(); // read to end, but do not close the stream (maybe HTTP/1.1 persistent)//return serverCore.RESUME_CONNECTION;- return this.prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;+ return prop.getProperty(HeaderFramework.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;} catch (final Exception e) {- logUnexpectedError(e);+ logUnexpectedError(e, session.userAddress.getHostAddress());return serverCore.TERMINATE_CONNECTION;}}- public Boolean CONNECT(String arg) throws IOException {+ public Boolean CONNECT(String arg, Session session) throws IOException {// establish a ssh-tunneled http connection// this is to support https@@ -622,6 +575,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {httpVersion = arg.substring(pos + 1);arg = arg.substring(0, pos);}+ Properties prop = new Properties();prop.setProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER, httpVersion);// parse hostname and port@@ -634,18 +588,18 @@ public final class HTTPDemon implements serverHandler, Cloneable {}// setting other connection properties- prop.setProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP, this.clientIP);+ prop.setProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP, session.userAddress.isAnyLocalAddress() ? "localhost" : session.userAddress.getHostAddress());prop.setProperty(HeaderFramework.CONNECTION_PROP_METHOD, HeaderFramework.METHOD_CONNECT);prop.setProperty(HeaderFramework.CONNECTION_PROP_PATH, "/");prop.setProperty(HeaderFramework.CONNECTION_PROP_EXT, "");prop.setProperty(HeaderFramework.CONNECTION_PROP_URL, "");// parse remaining lines- final RequestHeader header = RequestHeader.readHeader(this.prop,this.session);+ final RequestHeader header = RequestHeader.readHeader(prop,session);- if (!(allowProxy)) {+ if (!(allowProxy(session))) {// not authorized through firewall blocking (ip does not match filter)- session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + clientIP + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + session.userAddress.getHostAddress() + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());return serverCore.TERMINATE_CONNECTION;}@@ -658,35 +612,37 @@ public final class HTTPDemon implements serverHandler, Cloneable {}// pass to proxy- if (((this.allowYaCyHop) && (handleYaCyHopAuthentication(header))) ||- ((this.allowProxy) && (this.handleProxyAuthentication(header)))) {- HTTPDProxyHandler.doConnect(prop, header, this.session.in, this.session.out);+ if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||+ ((allowProxy(session)) && (this.handleProxyAuthentication(header, prop, session)))) {+ HTTPDProxyHandler.doConnect(prop, header, session.in, session.out);} else {// not authorized through firewall blocking (ip does not match filter)- session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + clientIP + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());+ session.out.write((httpVersion + " 403 refused (IP not granted)" + serverCore.CRLF_STRING + serverCore.CRLF_STRING + "you are not allowed to connect to this proxy, because you are using the non-granted IP " + session.userAddress.getHostAddress() + ". allowed are only connections that match with the following filter: " + switchboard.getConfig("proxyClient", "*") + serverCore.CRLF_STRING).getBytes());}return serverCore.TERMINATE_CONNECTION;}- private final void parseRequestLine(final String cmd, final String s) {+ private final Properties parseRequestLine(final String cmd, final String s, Session session) {// parsing the header- RequestHeader.parseRequestLine(cmd,s,this.prop,virtualHost);+ Properties p = RequestHeader.parseRequestLine(cmd, s, virtualHost);// track the request- final String path = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_URL);- final String args = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_ARGS, "");- switchboard.track(this.userAddress.getHostAddress(), (args.length() > 0) ? path + "?" + args : path);+ final String path = p.getProperty(HeaderFramework.CONNECTION_PROP_URL);+ final String args = p.getProperty(HeaderFramework.CONNECTION_PROP_ARGS, "");+ switchboard.track(session.userAddress.getHostAddress(), (args.length() > 0) ? path + "?" + args : path);// reseting the empty request counterthis.emptyRequestCount = 0;// counting the amount of received requests within this permanent connection- this.prop.setProperty(HeaderFramework.CONNECTION_PROP_KEEP_ALIVE_COUNT, Integer.toString(++this.keepAliveRequestCount));+ p.setProperty(HeaderFramework.CONNECTION_PROP_KEEP_ALIVE_COUNT, Integer.toString(++this.keepAliveRequestCount));// setting the client-IP- this.prop.setProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP, this.clientIP);+ p.setProperty(HeaderFramework.CONNECTION_PROP_CLIENTIP, session.userAddress.getHostAddress());++ return p;}// some static methods that needs to be used from any CGI@@ -1305,7 +1261,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {// adding some yacy specific headersresponseHeader.put(HeaderFramework.X_YACY_KEEP_ALIVE_REQUEST_COUNT,conProp.getProperty(HeaderFramework.CONNECTION_PROP_KEEP_ALIVE_COUNT));responseHeader.put(HeaderFramework.X_YACY_ORIGINAL_REQUEST_LINE,conProp.getProperty(HeaderFramework.CONNECTION_PROP_REQUESTLINE));- responseHeader.put(HeaderFramework.X_YACY_PREVIOUS_REQUEST_LINE,conProp.getProperty(HeaderFramework.CONNECTION_PROP_PREV_REQUESTLINE));+ //responseHeader.put(HeaderFramework.X_YACY_PREVIOUS_REQUEST_LINE,conProp.getProperty(HeaderFramework.CONNECTION_PROP_PREV_REQUESTLINE));//read custom headers/*diff --git a/source/de/anomic/http/server/HeaderFramework.java b/source/de/anomic/http/server/HeaderFramework.javaindex 57d34ce94..10a2d7d1a 100644--- a/source/de/anomic/http/server/HeaderFramework.java+++ b/source/de/anomic/http/server/HeaderFramework.java@@ -106,7 +106,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stripublic static final String X_FORWARDED_FOR = "X-Forwarded-For";public static final String X_YACY_INDEX_CONTROL = "X-YACY-Index-Control";- public static final String X_YACY_PREVIOUS_REQUEST_LINE = "X-Previous-Request-Line";+ //public static final String X_YACY_PREVIOUS_REQUEST_LINE = "X-Previous-Request-Line";public static final String X_YACY_KEEP_ALIVE_REQUEST_COUNT = "X-Keep-Alive-Request-Count";public static final String X_YACY_ORIGINAL_REQUEST_LINE = "X-Original-Request-Line";@@ -196,7 +196,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stripublic static final String CONNECTION_PROP_PERSISTENT = "PERSISTENT";public static final String CONNECTION_PROP_KEEP_ALIVE_COUNT = "KEEP-ALIVE_COUNT";public static final String CONNECTION_PROP_REQUESTLINE = "REQUESTLINE";- public static final String CONNECTION_PROP_PREV_REQUESTLINE = "PREVREQUESTLINE";+ //public static final String CONNECTION_PROP_PREV_REQUESTLINE = "PREVREQUESTLINE";public static final String CONNECTION_PROP_REQUEST_START = "REQUEST_START";public static final String CONNECTION_PROP_REQUEST_END = "REQUEST_END";//public static final String CONNECTION_PROP_INPUTSTREAM = "INPUTSTREAM";diff --git a/source/de/anomic/http/server/RequestHeader.java b/source/de/anomic/http/server/RequestHeader.javaindex 06bf9c79f..b9c0a7f8e 100755--- a/source/de/anomic/http/server/RequestHeader.java+++ b/source/de/anomic/http/server/RequestHeader.java@@ -125,29 +125,13 @@ public class RequestHeader extends HeaderFramework {((get(ACCEPT_ENCODING)).toUpperCase().indexOf("GZIP")) != -1);}- public static Properties parseRequestLine(final String s, final Properties prop, final String virtualHost) {- final int p = s.indexOf(' ');- if (p >= 0) {- final String cmd = s.substring(0,p);- final String args = s.substring(p+1);- return parseRequestLine(cmd,args, prop,virtualHost);- }- return prop;- }-- public static Properties parseRequestLine(final String cmd, String args, final Properties prop, final String virtualHost) {+ public static Properties parseRequestLine(final String cmd, String args, final String virtualHost) {- // getting the last request line for debugging purposes- final String prevRequestLine = prop.containsKey(CONNECTION_PROP_REQUESTLINE)?- prop.getProperty(CONNECTION_PROP_REQUESTLINE) : "";+ final Properties prop = new Properties();- // reset property from previous run- prop.clear();-// storing informations about the requestprop.setProperty(CONNECTION_PROP_METHOD, cmd);prop.setProperty(CONNECTION_PROP_REQUESTLINE, cmd + " " + args);- prop.setProperty(CONNECTION_PROP_PREV_REQUESTLINE, prevRequestLine);// this parses a whole URLif (args.length() == 0) {diff --git a/source/de/anomic/search/ResultEntry.java b/source/de/anomic/search/ResultEntry.javaindex b916a26cb..7d1590c2c 100644--- a/source/de/anomic/search/ResultEntry.java+++ b/source/de/anomic/search/ResultEntry.java@@ -129,6 +129,18 @@ public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEnpublic String title() {return urlcomps.dc_title();}+ public String publisher() {+ // dc:publisher+ return urlcomps.dc_publisher();+ }+ public String creator() {+ // dc:creator, the author+ return urlcomps.dc_creator();+ }+ public String subject() {+ // dc:subject, keywords+ return urlcomps.dc_subject();+ }public TextSnippet textSnippet() {return this.textSnippet;}diff --git a/source/de/anomic/search/Segment.java b/source/de/anomic/search/Segment.javaindex aeee8a76b..a2c60ca87 100644--- a/source/de/anomic/search/Segment.java+++ b/source/de/anomic/search/Segment.java@@ -241,7 +241,7 @@ public class Segment {public URIMetadataRow storeDocument(final DigestURI url,final DigestURI referrerURL,- final Date modDate,+ Date modDate,final Date loadDate,final long sourcesize,final Document document,@@ -296,13 +296,13 @@ public class Segment {}// create a new loaded URL db entry- assert modDate.getTime() <= loadDate.getTime() : "modDate = " + modDate + ", loadDate = " + loadDate;+ if (modDate.getTime() > loadDate.getTime()) modDate = loadDate;final URIMetadataRow newEntry = new URIMetadataRow(url, // URLdc_title, // document descriptiondocument.dc_creator(), // authordocument.dc_subject(' '), // tags- "", // ETag+ document.dc_publisher(), // publisher (may be important to get location data)modDate, // modification dateloadDate, // loaded datenew Date(loadDate.getTime() + Math.max(0, loadDate.getTime() - modDate.getTime()) / 2), // freshdate, computed with Proxy-TTL formuladiff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex beacb2314..d41d76a53 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -91,7 +91,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {public static final byte[] CRLF = {CR, LF};public static final String CRLF_STRING = new String(CRLF);public static final String LF_STRING = new String(new byte[]{LF});- public static final Class<?>[] stringType = {"".getClass()}; // set up some reflection+ public static final Class<?>[] sessionCallType = {String.class, Session.class}; // set up some reflectionpublic static final long startupTime = System.currentTimeMillis();static final ThreadGroup sessionThreadGroup = new ThreadGroup("sessionThreadGroup");static final HashMap<String, Object> commandObjMethodCache = new HashMap<String, Object>(5);@@ -663,7 +663,6 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {boolean terminate = false;String reqCmd;String reqProtocol = "HTTP";- final Object[] stringParameter = new String[1];long situationDependentKeepAliveTimeout = keepAliveTimeout;while (this.in != null &&this.controlSocket != null &&@@ -682,15 +681,18 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {// of the commandObjectif (this.request.trim().length() == 0) this.request = "EMPTY";- // getting the rest of the request parameters+ final Object[] parameter = new Object[2];++ // get the rest of the request parametersfinal int pos = this.request.indexOf(' ');if (pos < 0) {reqCmd = this.request.trim().toUpperCase();- stringParameter[0] = "";+ parameter[0] = "";} else {reqCmd = this.request.substring(0, pos).trim().toUpperCase();- stringParameter[0] = this.request.substring(pos).trim();+ parameter[0] = this.request.substring(pos).trim();}+ parameter[1] = this;// now we need to initialize the sessionif (this.commandCounter == 0) {@@ -702,9 +704,6 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {if (reqProtocol.equals("HTTP")) {this.commandObj = handlerPrototype.clone();}-- // initializing the session- this.commandObj.initSession(this);}// count the amount of requests that were processed by this session until yet@@ -717,15 +716,15 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {Object commandMethod = commandObjMethodCache.get(reqProtocol + "_" + reqCmd);if (commandMethod == null) {try {- commandMethod = this.commandObj.getClass().getMethod(reqCmd, stringType);+ commandMethod = this.commandObj.getClass().getMethod(reqCmd, sessionCallType);commandObjMethodCache.put(reqProtocol + "_" + reqCmd, commandMethod);} catch (final NoSuchMethodException noMethod) {- commandMethod = this.commandObj.getClass().getMethod("UNKNOWN", stringType);- stringParameter[0] = this.request.trim();+ commandMethod = this.commandObj.getClass().getMethod("UNKNOWN", sessionCallType);+ parameter[0] = this.request.trim();}}//long commandStart = System.currentTimeMillis();- Object result = ((Method)commandMethod).invoke(this.commandObj, stringParameter);+ Object result = ((Method)commandMethod).invoke(this.commandObj, parameter);//announceMoreExecTime(commandStart - System.currentTimeMillis()); // shall be negative!//this.log.logDebug("* session " + handle + " completed command '" + request + "'. time = " + (System.currentTimeMillis() - handle));this.out.flush();diff --git a/source/de/anomic/server/serverHandler.java b/source/de/anomic/server/serverHandler.javaindex 2af1a2203..9ed6758c2 100644--- a/source/de/anomic/server/serverHandler.java+++ b/source/de/anomic/server/serverHandler.java@@ -63,20 +63,10 @@ package de.anomic.server;import java.io.IOException;+import de.anomic.server.serverCore.Session;-public interface serverHandler {- // init method for static variables of the handler- // this method shall be called only once- // information that is passed here is cloned for every new instance- //public void initHandler(serverSwitch switchboard) throws java.io.IOException;-- // an init method that the server calls to provide hooks and- // information to the session's sockets and information- // the Switchboard allowes to trigger events through all sessions- // and an supervision process.- // this method shall be called only once- public void initSession(serverCore.Session session) throws java.io.IOException;+public interface serverHandler {// a response line upon connection is send to client// if no response line is wanted, return "" or null@@ -103,12 +93,12 @@ public interface serverHandler {* if the whole request line is empty and therefore no function of this* serverHandlerClass can be called because of the missing command name*/- public Boolean EMPTY(String arg) throws IOException;+ public Boolean EMPTY(String arg, Session session) throws IOException;/*** This function will be called by the {@link serverCore}.listen() function* if no corresponding funktion of the serverHandler class can be* found for the received command.*/- public Boolean UNKNOWN(String requestLine) throws IOException;+ public Boolean UNKNOWN(String requestLine, Session session) throws IOException;}diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.javaindex e7661d1c3..72e5f131c 100644--- a/source/de/anomic/server/serverSwitch.java+++ b/source/de/anomic/server/serverSwitch.java@@ -468,7 +468,7 @@ public class serverSwitch {return workerThreads.keySet().iterator();}- // authentification routines:+ // authentication routines:public void setAuthentify(final InetAddress host, final String user, final String rights) {// sets access attributes according to host addresses@@ -501,10 +501,10 @@ public class serverSwitch {public void addAuthentifyRight(final InetAddress host, final String right) {final String rights = getAuthentifyRights(host);if (rights == null) {- // create new authentification+ // create new authenticationsetAuthentify(host, "unknown", right);} else {- // add more authentification+ // add more authenticationfinal String user = getAuthentifyUser(host);setAuthentify(host, user, rights + right);}diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 759977ef2..6dadc4f04 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -54,10 +54,14 @@ import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.TreeMap;+import java.util.concurrent.BlockingQueue;+import java.util.concurrent.LinkedBlockingQueue;import java.util.regex.Pattern;+import net.yacy.document.content.RSSMessage;import net.yacy.document.parser.xml.RSSFeed;import net.yacy.document.parser.xml.RSSReader;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.data.meta.URIMetadataRow;import net.yacy.kelondro.data.word.Word;import net.yacy.kelondro.data.word.WordReference;@@ -422,6 +426,122 @@ public final class yacyClient {}}++ public static BlockingQueue<RSSMessage> search(String urlBase, String query, boolean verify, boolean global, long timeout, int maximumRecords) {+ if (urlBase == null) {+ urlBase = "http://localhost:" + Switchboard.getSwitchboard().getConfig("port", "8080") + "/yacysearch.rss";+ }+ BlockingQueue<RSSMessage> queue = new LinkedBlockingQueue<RSSMessage>();+ searchJob job = new searchJob(urlBase, query, verify, global, timeout, maximumRecords, queue);+ job.start();+ return queue;+ }++ private final static int recordsPerSession = 10;++ public static class searchJob extends Thread {++ String urlBase, query;+ boolean verify, global;+ long timeout;+ int startRecord, maximumRecords;+ BlockingQueue<RSSMessage> queue;++ public searchJob(String urlBase, String query, boolean verify, boolean global, long timeout, int maximumRecords, BlockingQueue<RSSMessage> queue) {+ this.urlBase = urlBase;+ this.query = query;+ this.verify = verify;+ this.global = global;+ this.timeout = timeout;+ this.startRecord = 0;+ this.maximumRecords = maximumRecords;+ this.queue = queue;+ }++ public void run() {+ RSSMessage message;+ while (timeout > 0 && maximumRecords > 0) {+ long st = System.currentTimeMillis();+ RSSFeed feed = search(urlBase, query, verify, global, timeout, startRecord, recordsPerSession);+ if (feed == null || feed.isEmpty()) {+ try { queue.put(RSSMessage.POISON); } catch (InterruptedException e) {}+ return;+ }+ maximumRecords -= feed.size();+ loop: while (!feed.isEmpty()) {+ message = feed.pollMessage();+ if (message == null) break loop;+ try {+ queue.put(message);+ } catch (InterruptedException e) {+ break loop;+ }+ }+ startRecord += recordsPerSession;+ timeout -= System.currentTimeMillis() - st;+ }+ }+ }++ /**+ * send a query to a yacy public search interface+ * @param urlBase the target url base (everything before the ? that follows the SRU request syntax properties). can null, then the local peer is used+ * @param query the query as string+ * @param startRecord number of first record+ * @param maximumRecords maximum number of records+ * @param verify if true, result entries are verified using the snippet fetch (slow); if false simply the result is returned+ * @param global if true also search results from other peers are included+ * @param timeout milliseconds that are waited at maximum for a search result+ * @return+ */+ public static RSSFeed search(String urlBase, String query, boolean verify, boolean global, long timeout, int startRecord, int maximumRecords) {+ // returns a search result from a peer+ if (urlBase == null) {+ urlBase = "http://localhost:" + Switchboard.getSwitchboard().getConfig("port", "8080") + "/yacysearch.rss";+ }+ DigestURI uri = null;+ try {+ uri = new DigestURI(urlBase, null);+ } catch (MalformedURLException e) {+ yacyCore.log.logWarning("yacyClient.search failed asking peer '" + urlBase + "': bad url, " + e.getMessage());+ return null;+ }++ // prepare request+ final List<Part> post = new ArrayList<Part>();+ post.add(new DefaultCharsetStringPart("query", query.replaceAll(" ", "+")));+ post.add(new DefaultCharsetStringPart("startRecord", Integer.toString(startRecord)));+ post.add(new DefaultCharsetStringPart("maximumRecords", Long.toString(maximumRecords)));+ post.add(new DefaultCharsetStringPart("verify", verify ? "true" : "false"));+ post.add(new DefaultCharsetStringPart("resource", global ? "global" : "local"));++ // send request+ try {+ final byte[] result = wput(urlBase, uri.getHost(), post, (int) timeout);+ final RSSReader reader = RSSReader.parse(result);+ if (reader == null) {+ yacyCore.log.logWarning("yacyClient.search failed asking peer '" + uri.getHost() + "': probably bad response from remote peer (1), reader == null");+ return null;+ }+ final RSSFeed feed = reader.getFeed();+ if (feed == null) {+ // case where the rss reader does not understand the content+ yacyCore.log.logWarning("yacyClient.search failed asking peer '" + uri.getHost() + "': probably bad response from remote peer (2)");+ return null;+ }+ return feed;+ } catch (final IOException e) {+ yacyCore.log.logSevere("yacyClient.search error asking peer '" + uri.getHost() + "':" + e.toString());+ return null;+ }+ }++ public static RSSFeed search(final yacySeed targetSeed, String query, boolean verify, boolean global, long timeout, int startRecord, int maximumRecords) {+ String address = (targetSeed == null || targetSeed == Switchboard.getSwitchboard().peers.mySeed()) ? "localhost:" + Switchboard.getSwitchboard().getConfig("port", "8080") : targetSeed.getClusterAddress();+ String urlBase = "http://" + address + "/yacysearch.rss";+ return search(urlBase, query, verify, global, timeout, startRecord, maximumRecords);+ }+@SuppressWarnings("unchecked")public static String[] search(final yacySeed mySeed,diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.javaindex 99a407a9b..0a61438a3 100644--- a/source/de/anomic/yacy/yacyNetwork.java+++ b/source/de/anomic/yacy/yacyNetwork.java@@ -53,28 +53,28 @@ public class yacyNetwork {return false;}- // check authentification method- final String authentificationControl = env.getConfig("network.unit.protocol.control", "uncontrolled");- if (authentificationControl.equals("uncontrolled")) return true;- final String authentificationMethod = env.getConfig("network.unit.protocol.request.authentification.method", "");- if (authentificationMethod.length() == 0) {+ // check authentication method+ final String authenticationControl = env.getConfig("network.unit.protocol.control", "uncontrolled");+ if (authenticationControl.equals("uncontrolled")) return true;+ final String authenticationMethod = env.getConfig("network.unit.protocol.request.authentication.method", "");+ if (authenticationMethod.length() == 0) {return false;}- if (authentificationMethod.equals("salted-magic-sim")) {- // authentify the peer using the md5-magic+ if (authenticationMethod.equals("salted-magic-sim")) {+ // authorize the peer using the md5-magicfinal String salt = post.get("key", "");final String iam = post.get("iam", "");- final String magic = env.getConfig("network.unit.protocol.request.authentification.essentials", "");+ final String magic = env.getConfig("network.unit.protocol.request.authentication.essentials", "");final String md5 = Digest.encodeMD5Hex(salt + iam + magic);return post.get("magicmd5", "").equals(md5);}- // unknown authentification method+ // unknown authentication methodreturn false;}public static final List<Part> basicRequestPost(final Switchboard sb, final String targetHash, final String salt) {- // put in all the essentials for routing and network authentification+ // put in all the essentials for routing and network authentication// generate a session keyfinal ArrayList<Part> post = new ArrayList<Part>();post.add(new DefaultCharsetStringPart("key", salt));@@ -90,13 +90,13 @@ public class yacyNetwork {// network identificationpost.add(new DefaultCharsetStringPart(SwitchboardConstants.NETWORK_NAME, Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, yacySeed.DFLT_NETWORK_UNIT)));- // authentification essentials- final String authentificationControl = sb.getConfig("network.unit.protocol.control", "uncontrolled");- final String authentificationMethod = sb.getConfig("network.unit.protocol.request.authentification.method", "");- if ((authentificationControl.equals("controlled")) && (authentificationMethod.length() > 0)) {- if (authentificationMethod.equals("salted-magic-sim")) {- // generate an authentification essential using the salt, the iam-hash and the network magic- final String magic = sb.getConfig("network.unit.protocol.request.authentification.essentials", "");+ // authentication essentials+ final String authenticationControl = sb.getConfig("network.unit.protocol.control", "uncontrolled");+ final String authenticationMethod = sb.getConfig("network.unit.protocol.request.authentication.method", "");+ if ((authenticationControl.equals("controlled")) && (authenticationMethod.length() > 0)) {+ if (authenticationMethod.equals("salted-magic-sim")) {+ // generate an authentication essential using the salt, the iam-hash and the network magic+ final String magic = sb.getConfig("network.unit.protocol.request.authentication.essentials", "");final String md5 = Digest.encodeMD5Hex(salt + sb.peers.mySeed().hash + magic);post.add(new DefaultCharsetStringPart("magicmd5", md5));}diff --git a/source/net/yacy/document/Condenser.java b/source/net/yacy/document/Condenser.javaindex 830a1178c..fc1228ab5 100644--- a/source/net/yacy/document/Condenser.java+++ b/source/net/yacy/document/Condenser.java@@ -134,15 +134,18 @@ public final class Condenser {// phrase 2 is <not used>// phrase 3 is the Document Abstract// phrase 4 is the Document Author- // phrase 5 are the tags specified in document+ // phrase 5 is the Document Publisher+ // phrase 6 are the tags specified in document// phrase 10 and above are the section headlines/titles (88 possible)// phrase 98 is taken from the embedded anchor/hyperlinks description (REMOVED!)// phrase 99 is taken from the media Link url and anchor description// phrase 100 and above are lines from the text- insertTextToWords(document.dc_title(), 1, WordReferenceRow.flag_app_dc_title, RESULT_FLAGS, true);+ insertTextToWords(document.dc_title(), 1, WordReferenceRow.flag_app_dc_title, RESULT_FLAGS, true);insertTextToWords(document.dc_description(), 3, WordReferenceRow.flag_app_dc_description, RESULT_FLAGS, true);- insertTextToWords(document.dc_creator(), 4, WordReferenceRow.flag_app_dc_creator, RESULT_FLAGS, true);+ insertTextToWords(document.dc_creator(), 4, WordReferenceRow.flag_app_dc_creator, RESULT_FLAGS, true);+ insertTextToWords(document.dc_publisher(), 5, WordReferenceRow.flag_app_dc_creator, RESULT_FLAGS, true);+ insertTextToWords(document.dc_subject(' '), 6, WordReferenceRow.flag_app_dc_description, RESULT_FLAGS, true);// missing: tags!final String[] titles = document.getSectionTitles();for (int i = 0; i < titles.length; i++) {@@ -236,7 +239,7 @@ public final class Condenser {while (wordenum.hasMoreElements()) {word = (wordenum.nextElement().toString()).toLowerCase(Locale.ENGLISH);if (useForLanguageIdentification) languageIdentificator.add(word);- if (word.length() < 3) continue;+ if (word.length() < 2) continue;wprop = words.get(word);if (wprop == null) wprop = new Word(0, pip, phrase);if (wprop.flags == null) wprop.flags = flagstemplate.clone();@@ -585,6 +588,10 @@ public final class Condenser {sb = sb.append(c);}}+ if (sb.length() > 0) {+ s.add(sb);+ sb = null;+ }}r = s.get(sIndex++);return r;diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.javaindex b59d69c5c..69ce288dc 100644--- a/source/net/yacy/document/Document.java+++ b/source/net/yacy/document/Document.java@@ -31,6 +31,7 @@ import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStreamWriter;+import java.io.UnsupportedEncodingException;import java.net.MalformedURLException;import java.util.Arrays;import java.util.Collection;@@ -60,6 +61,7 @@ public class Document {private final List<String> keywords; // most resources provide a keyword fieldprivate StringBuilder title; // a document title, taken from title or h1 tag; shall appear as headline of search resultprivate final StringBuilder creator; // author or copyright+ private final String publisher; // publisherprivate final List<String> sections; // if present: more titles/headlines appearing in the documentprivate final StringBuilder description; // an abstract, if present: short content descriptionprivate Object text; // the clear text, all that is visible@@ -78,7 +80,7 @@ public class Document {private boolean indexingDenied;public Document(final DigestURI location, final String mimeType, final String charset, final Set<String> languages,- final String[] keywords, final String title, final String author,+ final String[] keywords, final String title, final String author, final String publisher,final String[] sections, final String abstrct,final Object text, final Map<DigestURI, String> anchors, final HashMap<String, ImageEntry> images,boolean indexingDenied) {@@ -92,6 +94,7 @@ public class Document {this.description = (abstrct == null) ? new StringBuilder(0) : new StringBuilder(abstrct);this.anchors = (anchors == null) ? new HashMap<DigestURI, String>(0) : anchors;this.images = (images == null) ? new HashMap<String, ImageEntry>() : images;+ this.publisher = publisher;this.hyperlinks = null;this.audiolinks = null;this.videolinks = null;@@ -193,8 +196,7 @@ dc_rights}public String dc_publisher() {- // if we don't have a publisher, simply return the host/domain name- return this.source.getHost();+ return this.publisher;}public String dc_format() {@@ -536,32 +538,39 @@ dc_rightspublic void writeXML(OutputStreamWriter os, Date date) throws IOException {os.write("<record>\n");String title = this.dc_title();- if (title != null && title.length() > 0) os.write("<dc:Title><![CDATA[" + this.dc_title() + "]]></dc:Title>\n");- os.write("<dc:Identifier>" + this.dc_identifier() + "</dc:Identifier>\n");+ if (title != null && title.length() > 0) os.write("<dc:title><![CDATA[" + title + "]]></dc:title>\n");+ os.write("<dc:identifier>" + this.dc_identifier() + "</dc:identifier>\n");String creator = this.dc_creator();- if (creator != null && creator.length() > 0) os.write("<dc:Creator><![CDATA[" + this.dc_creator() + "]]></dc:Creator>\n");+ if (creator != null && creator.length() > 0) os.write("<dc:creator><![CDATA[" + creator + "]]></dc:creator>\n");+ String publisher = this.dc_publisher();+ if (publisher != null && publisher.length() > 0) os.write("<dc:publisher><![CDATA[" + publisher + "]]></dc:publisher>\n");+ String subject = this.dc_subject(';');+ if (subject != null && subject.length() > 0) os.write("<dc:subject><![CDATA[" + subject + "]]></dc:subject>\n");if (this.text != null) {- os.write("<dc:Description><![CDATA[");+ os.write("<dc:description><![CDATA[");byte[] buffer = new byte[1000];int c = 0;InputStream is = this.getText();while ((c = is.read(buffer)) > 0) os.write(new String(buffer, 0, c));is.close();- os.write("]]></dc:Description>\n");+ os.write("]]></dc:description>\n");}String language = this.dc_language();- if (language != null && language.length() > 0) os.write("<dc:Language>" + this.dc_language() + "</dc:Language>\n");- os.write("<dc:Date>" + DateFormatter.formatISO8601(date) + "</dc:Date>\n");+ if (language != null && language.length() > 0) os.write("<dc:language>" + this.dc_language() + "</dc:language>\n");+ os.write("<dc:date>" + DateFormatter.formatISO8601(date) + "</dc:date>\n");os.write("</record>\n");}public String toString() {ByteArrayOutputStream baos = new ByteArrayOutputStream();- OutputStreamWriter osw = new OutputStreamWriter(baos);+ OutputStreamWriter osw;try {+ osw = new OutputStreamWriter(baos, "UTF-8");writeXML(osw, new Date());osw.close();return new String(baos.toByteArray(), "UTF-8");+ } catch (UnsupportedEncodingException e1) {+ return "";} catch (IOException e) {return "";}diff --git a/source/net/yacy/document/content/DCEntry.java b/source/net/yacy/document/content/DCEntry.javaindex b388baee9..372e94f38 100644--- a/source/net/yacy/document/content/DCEntry.java+++ b/source/net/yacy/document/content/DCEntry.java@@ -143,6 +143,9 @@ public class DCEntry extends TreeMap<String, String> {}private String bestU(String[] urls) {+ for (String uu: urls) {+ if (uu.startsWith("http://") && (uu.endsWith(".html") || uu.endsWith(".htm") || uu.endsWith(".pdf") || uu.endsWith(".doc") || uu.endsWith(".rss") || uu.endsWith(".xml"))) return uu;+ }for (String uu: urls) {if (uu.startsWith("http://")) return uu;}@@ -248,6 +251,7 @@ public class DCEntry extends TreeMap<String, String> {getSubject(),getTitle(),getCreator(),+ getPublisher(),null,"",getDescription().getBytes("UTF-8"),diff --git a/source/net/yacy/document/content/RSSMessage.java b/source/net/yacy/document/content/RSSMessage.javaindex 8a777d640..63dcdc6a8 100644--- a/source/net/yacy/document/content/RSSMessage.java+++ b/source/net/yacy/document/content/RSSMessage.java@@ -30,30 +30,57 @@ package net.yacy.document.content;import java.util.Date;import java.util.HashMap;import java.util.HashSet;+import java.util.Map;+import java.util.Set;public class RSSMessage {// statics for item generation and automatic categorizationprivate static int guidcount = 0;- private static final String[] tagsDef = new String[] {- "author", //- "copyright", //- "category", //- "title", //- "link", //- "referrer", //- "language", //- "description", //- "creator", //- "pubDate", //- "guid", //- "docs" //- };+ public static enum Token {++ title("title"),+ link("link"),+ description("description"),+ pubDate("pubDate"),+ copyright("copyright,dc:publisher,publisher"),+ author("author,dc:creator,creator"),+ subject("subject,dc:subject"),+ category("category"),+ referrer("referrer,referer"),+ language("language"),+ guid("guid"),+ docs("docs");++ private Set<String> keys;++ private Token(String keylist) {+ String[] k = keylist.split(",");+ this.keys = new HashSet<String>();+ for (String s: k) this.keys.add(s);+ }++ public String valueFrom(Map<String, String> map) {+ String value;+ for (String key: this.keys) {+ value = map.get(key);+ if (value != null) return value;+ }+ return "";+ }++ public Set<String> keys() {+ return this.keys;+ }+ }++ public static final RSSMessage POISON = new RSSMessage("", "", "");+public static final HashSet<String> tags = new HashSet<String>();static {- for (int i = 0; i < tagsDef.length; i++) {- tags.add(tagsDef[i]);+ for (Token token: Token.values()) {+ tags.addAll(token.keys());}}@@ -77,72 +104,61 @@ public class RSSMessage {map.put(name, value);}- public String getAuthor() {- final String s = map.get("author");- return emptyStringOnNull(s);+ public String getTitle() {+ return Token.title.valueFrom(this.map);}- public String getCopyright() {- final String s = map.get("copyright");- return emptyStringOnNull(s);+ public String getLink() {+ return Token.link.valueFrom(this.map);}- public String getCategory() {- final String s = map.get("category");- return emptyStringOnNull(s);+ public String getDescription() {+ return Token.description.valueFrom(this.map);}- public String getTitle() {- final String s = map.get("title");- return emptyStringOnNull(s);+ public String getAuthor() {+ return Token.author.valueFrom(this.map);}- public String getLink() {- final String s = map.get("link");- return emptyStringOnNull(s);+ public String getCopyright() {+ return Token.copyright.valueFrom(this.map);}- public String getReferrer() {- final String s = map.get("referrer");- return emptyStringOnNull(s);+ public String getCategory() {+ return Token.category.valueFrom(this.map);}- public String getLanguage() {- final String s = map.get("language");- return emptyStringOnNull(s);+ public String[] getSubject() {+ String subject = Token.subject.valueFrom(this.map);+ if (subject.indexOf(',') >= 0) return subject.split(",");+ if (subject.indexOf(';') >= 0) return subject.split(";");+ if (subject.indexOf('|') >= 0) return subject.split("|");+ return subject.split(" ");}- public String getDescription() {- final String s = map.get("description");- return emptyStringOnNull(s);+ public String getReferrer() {+ return Token.referrer.valueFrom(this.map);}- public String getCreator() {- final String s = map.get("creator");- return emptyStringOnNull(s);+ public String getLanguage() {+ return Token.language.valueFrom(this.map);}public String getPubDate() {- final String s = map.get("pubDate");- return emptyStringOnNull(s);+ return Token.pubDate.valueFrom(this.map);}public String getGuid() {- final String s = map.get("guid");- return emptyStringOnNull(s);+ return Token.guid.valueFrom(this.map);}public String getDocs() {- final String s = map.get("docs");- return emptyStringOnNull(s);+ return Token.docs.valueFrom(this.map);}-- /**- * @param s- * @return- */- private String emptyStringOnNull(final String s) {- if (s == null) return "";- return s;++ public String getFulltext() {+ StringBuilder sb = new StringBuilder(300);+ for (String s: map.values()) sb.append(s).append(" ");+ return sb.toString();}}diff --git a/source/net/yacy/document/content/SurrogateReader.java b/source/net/yacy/document/content/SurrogateReader.javaindex cbaaee514..6a2e3da97 100644--- a/source/net/yacy/document/content/SurrogateReader.java+++ b/source/net/yacy/document/content/SurrogateReader.java@@ -29,7 +29,6 @@ import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;-import java.util.ArrayList;import java.util.concurrent.ArrayBlockingQueue;import java.util.concurrent.BlockingQueue;import java.util.zip.GZIPInputStream;@@ -97,7 +96,9 @@ public class SurrogateReader extends DefaultHandler implements Runnable {}}- public void startElement(final String uri, final String name, final String tag, final Attributes atts) throws SAXException {+ public void startElement(final String uri, final String name, String tag, final Attributes atts) throws SAXException {+ if (tag == null) return;+ tag = tag.toLowerCase();if ("record".equals(tag) || "document".equals(tag)) {this.surrogate = new DCEntry();} else if ("element".equals(tag)) {@@ -112,8 +113,9 @@ public class SurrogateReader extends DefaultHandler implements Runnable {}}- public void endElement(final String uri, final String name, final String tag) {+ public void endElement(final String uri, final String name, String tag) {if (tag == null) return;+ tag = tag.toLowerCase();if ("record".equals(tag) || "document".equals(tag)) {//System.out.println("A Title: " + this.surrogate.title());try {@@ -139,7 +141,7 @@ public class SurrogateReader extends DefaultHandler implements Runnable {this.parsingValue = false;} else if (tag.startsWith("dc:")) {final String value = buffer.toString().trim();- if (this.elementName != null) {+ if (this.elementName != null && tag.equals(this.elementName)) {value.replaceAll(";", ",");String oldcontent = this.surrogate.get(this.elementName);if (oldcontent == null) {@@ -182,6 +184,8 @@ public class SurrogateReader extends DefaultHandler implements Runnable {while ((s = sr.take()) != DCEntry.poison) {System.out.println("Title: " + s.getTitle());System.out.println("Date: " + s.getDate());+ System.out.println("Creator: " + s.getCreator());+ System.out.println("Publisher: " + s.getPublisher());System.out.println("URL: " + s.getIdentifier(true));System.out.println("Language: " + s.getLanguage());System.out.println("Body: " + s.getDescription());diff --git a/source/net/yacy/document/geolocalization/OpenGeoDB.java b/source/net/yacy/document/geolocalization/OpenGeoDB.javaindex 897ca242a..826a450e0 100644--- a/source/net/yacy/document/geolocalization/OpenGeoDB.java+++ b/source/net/yacy/document/geolocalization/OpenGeoDB.java@@ -173,13 +173,17 @@ public class OpenGeoDB {* @param anyname* @return*/- public HashSet<Location> find(String anyname) {+ public HashSet<Location> find(String anyname, boolean exact) {HashSet<Integer> r = new HashSet<Integer>();- SortedMap<String, List<Integer>> cities = this.locationName2ids.tailMap(anyname);- for (Map.Entry<String, List<Integer>> e: cities.entrySet()) {- if (e.getKey().toLowerCase().startsWith(anyname.toLowerCase())) r.addAll(e.getValue()); else break;- }List<Integer> c;+ if (exact) {+ c = this.locationName2ids.get(anyname); if (c != null) r.addAll(c);+ } else {+ SortedMap<String, List<Integer>> cities = this.locationName2ids.tailMap(anyname);+ for (Map.Entry<String, List<Integer>> e: cities.entrySet()) {+ if (e.getKey().toLowerCase().startsWith(anyname.toLowerCase())) r.addAll(e.getValue()); else break;+ }+ }c = this.kfz2ids.get(anyname); if (c != null) r.addAll(c);c = this.predial2ids.get(anyname); if (c != null) r.addAll(c);Integer i = this.zip2id.get(anyname); if (i != null) r.add(i);diff --git a/source/net/yacy/document/parser/csvParser.java b/source/net/yacy/document/parser/csvParser.javaindex 49e707068..0d556687a 100644--- a/source/net/yacy/document/parser/csvParser.java+++ b/source/net/yacy/document/parser/csvParser.java@@ -90,6 +90,7 @@ public class csvParser extends AbstractParser implements Idiom {null,concatRow(table.get(0)),"",+ "",null,null,sb.toString().getBytes(charset),diff --git a/source/net/yacy/document/parser/docParser.java b/source/net/yacy/document/parser/docParser.javaindex d87548ab8..7d2b14f4b 100644--- a/source/net/yacy/document/parser/docParser.java+++ b/source/net/yacy/document/parser/docParser.java@@ -105,6 +105,7 @@ public class docParser extends AbstractParser implements Idiom {null,title,"", // TODO: AUTHOR+ extractor.getDocSummaryInformation().getCompany(), // publishernull,null,contents.toString().getBytes("UTF-8"),diff --git a/source/net/yacy/document/parser/html/ContentScraper.java b/source/net/yacy/document/parser/html/ContentScraper.javaindex f8bf82112..e64006bda 100644--- a/source/net/yacy/document/parser/html/ContentScraper.java+++ b/source/net/yacy/document/parser/html/ContentScraper.java@@ -406,12 +406,18 @@ public class ContentScraper extends AbstractScraper implements Scraper {public String getAuthor() {String s = metas.get("author");- if (s == null) s = metas.get("copyright");if (s == null) s = metas.get("dc.creator");if (s == null) return "";return s;}+ public String getPublisher() {+ String s = metas.get("copyright");+ if (s == null) s = metas.get("dc.publisher");+ if (s == null) return "";+ return s;+ }+public HashSet<String> getContentLanguages() {// i.e. <meta name="DC.language" content="en" scheme="DCTERMS.RFC3066">// or <meta http-equiv="content-language" content="en">diff --git a/source/net/yacy/document/parser/htmlParser.java b/source/net/yacy/document/parser/htmlParser.javaindex c495c300d..e0fd10b18 100644--- a/source/net/yacy/document/parser/htmlParser.java+++ b/source/net/yacy/document/parser/htmlParser.java@@ -148,6 +148,7 @@ public class htmlParser extends AbstractParser implements Idiom {scraper.getKeywords(),scraper.getTitle(),scraper.getAuthor(),+ scraper.getPublisher(),sections,scraper.getDescription(),scraper.getText(),diff --git a/source/net/yacy/document/parser/images/genericImageParser.java b/source/net/yacy/document/parser/images/genericImageParser.javaindex da63dfb0a..890ad1734 100644--- a/source/net/yacy/document/parser/images/genericImageParser.java+++ b/source/net/yacy/document/parser/images/genericImageParser.java@@ -185,7 +185,8 @@ public class genericImageParser extends AbstractParser implements Idiom {languages,keywords == null ? new String[]{} : keywords.split(keywords.indexOf(',') > 0 ? "," : " "), // keywordstitle, // title- author == null ? location.getHost() : author, // author+ author == null ? "" : author, // author+ location.getHost(), // Publishernew String[]{}, // sectionsdescription == null ? "" : description, // descriptioninfoString.getBytes(), // content textdiff --git a/source/net/yacy/document/parser/odtParser.java b/source/net/yacy/document/parser/odtParser.javaindex a2ce7e2b1..026a532eb 100644--- a/source/net/yacy/document/parser/odtParser.java+++ b/source/net/yacy/document/parser/odtParser.java@@ -189,6 +189,7 @@ public class odtParser extends AbstractParser implements Idiom {docKeywords,docLongTitle,docAuthor,+ "",null,docDescription,contentBytes,@@ -204,6 +205,7 @@ public class odtParser extends AbstractParser implements Idiom {docKeywords,docLongTitle,docAuthor,+ "",null,docDescription,writerFile,diff --git a/source/net/yacy/document/parser/ooxmlParser.java b/source/net/yacy/document/parser/ooxmlParser.javaindex 3df4cf818..61e07c103 100644--- a/source/net/yacy/document/parser/ooxmlParser.java+++ b/source/net/yacy/document/parser/ooxmlParser.java@@ -176,6 +176,7 @@ public class ooxmlParser extends AbstractParser implements Idiom {docKeywords,docLongTitle,docAuthor,+ "",null,docDescription,contentBytes,@@ -191,6 +192,7 @@ public class ooxmlParser extends AbstractParser implements Idiom {docKeywords,docLongTitle,docAuthor,+ "",null,docDescription,writerFile,diff --git a/source/net/yacy/document/parser/pdfParser.java b/source/net/yacy/document/parser/pdfParser.javaindex b74830ab6..f3442b014 100644--- a/source/net/yacy/document/parser/pdfParser.java+++ b/source/net/yacy/document/parser/pdfParser.java@@ -123,11 +123,12 @@ public class pdfParser extends AbstractParser implements Idiom {// extracting some metadatafinal PDDocumentInformation theDocInfo = theDocument.getDocumentInformation();- String docTitle = null, docSubject = null, docAuthor = null, docKeywordStr = null;+ String docTitle = null, docSubject = null, docAuthor = null, docPublisher = null, docKeywordStr = null;if (theDocInfo != null) {docTitle = theDocInfo.getTitle();docSubject = theDocInfo.getSubject();docAuthor = theDocInfo.getAuthor();+ docPublisher = theDocInfo.getProducer();docKeywordStr = theDocInfo.getKeywords();}@@ -171,6 +172,7 @@ public class pdfParser extends AbstractParser implements Idiom {docKeywords,(docTitle == null) ? docSubject : docTitle,docAuthor,+ docPublisher,null,null,contentBytes,@@ -186,6 +188,7 @@ public class pdfParser extends AbstractParser implements Idiom {docKeywords,(docTitle == null) ? docSubject : docTitle,docAuthor,+ docPublisher,null,null,writerFile,diff --git a/source/net/yacy/document/parser/pptParser.java b/source/net/yacy/document/parser/pptParser.javaindex cb23b1364..9504f24e3 100644--- a/source/net/yacy/document/parser/pptParser.java+++ b/source/net/yacy/document/parser/pptParser.java@@ -101,6 +101,7 @@ public class pptParser extends AbstractParser implements Idiom {null,title,"", // TODO: AUTHOR+ pptExtractor.getDocSummaryInformation().getCompany(),null,null,contents.getBytes("UTF-8"),diff --git a/source/net/yacy/document/parser/psParser.java b/source/net/yacy/document/parser/psParser.javaindex 2fde30c1e..cef0dbc16 100644--- a/source/net/yacy/document/parser/psParser.java+++ b/source/net/yacy/document/parser/psParser.java@@ -120,19 +120,20 @@ public class psParser extends AbstractParser implements Idiom {// return resultfinal Document theDoc = new Document(- location,- mimeType,- "UTF-8",- null,- null,- null,- "",- null,- null,- outputFile,- null,- null,- false);+ location, // url+ mimeType, // mime+ "UTF-8", // charset+ null, // languages+ null, // keywords+ null, // title+ "", // author+ "", // publisher+ null, // sections+ null, // abstract+ outputFile, // fulltext+ null, // anchors+ null, // images+ false); // indexingdeniedreturn theDoc;} catch (final Exception e) {diff --git a/source/net/yacy/document/parser/rssParser.java b/source/net/yacy/document/parser/rssParser.javaindex 85ba34014..81687484e 100644--- a/source/net/yacy/document/parser/rssParser.java+++ b/source/net/yacy/document/parser/rssParser.java@@ -96,6 +96,8 @@ public class rssParser extends AbstractParser implements Idiom {String feedTitle = "";String feedDescription = "";+ String feedPublisher = "";+ String[] feedSubject = {""};if (feed.getChannel() != null) {//throw new ParserException("no channel in document",location);// get the rss feed title and description@@ -107,6 +109,12 @@ public class rssParser extends AbstractParser implements Idiom {// get the feed descriptionfeedDescription = feed.getChannel().getDescription();++ // the feed publisher+ feedPublisher = feed.getChannel().getCopyright();++ // the feed subject+ feedSubject = feed.getChannel().getSubject();}if (feed.getImage() != null) {@@ -129,7 +137,7 @@ public class rssParser extends AbstractParser implements Idiom {continue;}final String itemDescr = item.getDescription();- final String itemCreator = item.getCreator();+ final String itemCreator = item.getAuthor();if (itemCreator != null && itemCreator.length() > 0) authors.append(",").append(itemCreator);feedSections.add(itemTitle);@@ -180,9 +188,10 @@ public class rssParser extends AbstractParser implements Idiom {mimeType,"UTF-8",null,- null,+ feedSubject,feedTitle,(authors.length() > 0)?authors.toString(1,authors.length()):"",+ feedPublisher,feedSections.toArray(new String[feedSections.size()]),feedDescription,text.getBytes(),diff --git a/source/net/yacy/document/parser/rtfParser.java b/source/net/yacy/document/parser/rtfParser.javaindex d5f9240cf..adb5f6abc 100644--- a/source/net/yacy/document/parser/rtfParser.java+++ b/source/net/yacy/document/parser/rtfParser.java@@ -85,6 +85,7 @@ public class rtfParser extends AbstractParser implements Idiom {replaceAll("\r"," ").replaceAll("\t"," "),"", // TODO: AUTHOR+ "", // TODO: publishernull,null,bodyText.getBytes("UTF-8"),diff --git a/source/net/yacy/document/parser/sevenzipParser.java b/source/net/yacy/document/parser/sevenzipParser.javaindex d9f80511b..94c79de11 100644--- a/source/net/yacy/document/parser/sevenzipParser.java+++ b/source/net/yacy/document/parser/sevenzipParser.java@@ -70,7 +70,7 @@ public class sevenzipParser extends AbstractParser implements Idiom {}public Document parse(final DigestURI location, final String mimeType, final String charset, final IInStream source) throws ParserException, InterruptedException {- final Document doc = new Document(location, mimeType, charset, null, null, null, null, null, null, (Object)null, null, null, false);+ final Document doc = new Document(location, mimeType, charset, null, null, null, null, null, null, null, (Object)null, null, null, false);Handler archive;super.theLogger.logFine("opening 7zip archive...");try {diff --git a/source/net/yacy/document/parser/swfParser.java b/source/net/yacy/document/parser/swfParser.javaindex 374a3db09..c93e19fa4 100644--- a/source/net/yacy/document/parser/swfParser.java+++ b/source/net/yacy/document/parser/swfParser.java@@ -131,6 +131,7 @@ public class swfParser extends AbstractParser implements Idiom {replaceAll("\r"," ").replaceAll("\t"," "), // title"", // TODO: AUTHOR+ "",sections, // an array of section headlinesabstrct, // an abstractcontents.getBytes("UTF-8"), // the parsed document textdiff --git a/source/net/yacy/document/parser/tarParser.java b/source/net/yacy/document/parser/tarParser.javaindex 024225463..f8f6cbb1a 100644--- a/source/net/yacy/document/parser/tarParser.java+++ b/source/net/yacy/document/parser/tarParser.java@@ -187,6 +187,7 @@ public class tarParser extends AbstractParser implements Idiom {docKeywords.toString().split(" |,"),docLongTitle.toString(),"", // TODO: AUTHOR+ "", // TODO: publisherdocSections.toArray(new String[docSections.size()]),docAbstrct.toString(),((ByteBuffer)docText).getBytes(),@@ -202,6 +203,7 @@ public class tarParser extends AbstractParser implements Idiom {docKeywords.toString().split(" |,"),docLongTitle.toString(),"", // TODO: AUTHOR+ "", // TODO: publisherdocSections.toArray(new String[docSections.size()]),docAbstrct.toString(),outputFile,diff --git a/source/net/yacy/document/parser/torrentParser.java b/source/net/yacy/document/parser/torrentParser.javaindex 43ab25fd0..0f2b81ae8 100644--- a/source/net/yacy/document/parser/torrentParser.java+++ b/source/net/yacy/document/parser/torrentParser.java@@ -118,6 +118,7 @@ public class torrentParser extends AbstractParser implements Idiom {null,name, // titlecomment, // author+ location.getHost(),null,null,filenames.toString().getBytes(charset),diff --git a/source/net/yacy/document/parser/vcfParser.java b/source/net/yacy/document/parser/vcfParser.javaindex 08cb693f0..86567f820 100644--- a/source/net/yacy/document/parser/vcfParser.java+++ b/source/net/yacy/document/parser/vcfParser.java@@ -224,13 +224,14 @@ public class vcfParser extends AbstractParser implements Idiom {final String[] sections = parsedNames.toArray(new String[parsedNames.size()]);final byte[] text = parsedDataText.toString().getBytes();final Document theDoc = new Document(- url, // url of the source document+ url, // url of the source documentmimeType, // the documents mime type- null,+ null, // charset+ null, // set of languagesnull, // a list of extracted keywords- null, // the languageparsedTitle.toString(), // a long document title"", // TODO: AUTHOR+ "", // the publishersections, // an array of section headlines"vCard", // an abstracttext, // the parsed document textdiff --git a/source/net/yacy/document/parser/vsdParser.java b/source/net/yacy/document/parser/vsdParser.javaindex ff53d7d9b..03f96d9ab 100644--- a/source/net/yacy/document/parser/vsdParser.java+++ b/source/net/yacy/document/parser/vsdParser.java@@ -128,6 +128,7 @@ public class vsdParser extends AbstractParser implements Idiom {keywords,title,author,+ "",null, // an array of section headlinesabstrct, // an abstractcontents.getBytes("UTF-8"), // the parsed document textdiff --git a/source/net/yacy/document/parser/xlsParser.java b/source/net/yacy/document/parser/xlsParser.javaindex e9b942fd2..bfbdc34ca 100644--- a/source/net/yacy/document/parser/xlsParser.java+++ b/source/net/yacy/document/parser/xlsParser.java@@ -146,6 +146,7 @@ public class xlsParser extends AbstractParser implements Idiom {null,location.getFile(),"", // TODO: AUTHOR+ "", // TODO: publishernull,null,contents.getBytes("UTF-8"),diff --git a/source/net/yacy/document/parser/zipParser.java b/source/net/yacy/document/parser/zipParser.javaindex 650afe9c3..846161c25 100644--- a/source/net/yacy/document/parser/zipParser.java+++ b/source/net/yacy/document/parser/zipParser.java@@ -174,6 +174,7 @@ public class zipParser extends AbstractParser implements Idiom {docKeywords.toString().split(" |,"),docLongTitle.toString(),"", // TODO: AUTHOR+ "", // TODO: PublisherdocSections.toArray(new String[docSections.size()]),docAbstrct.toString(),((ByteBuffer)docText).getBytes(),@@ -189,6 +190,7 @@ public class zipParser extends AbstractParser implements Idiom {docKeywords.toString().split(" |,"),docLongTitle.toString(),"", // TODO: AUTHOR+ "", // TODO: PublisherdocSections.toArray(new String[docSections.size()]),docAbstrct.toString(),outputFile,diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.javaindex f3166f145..907e3a2b7 100644--- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java+++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java@@ -30,7 +30,7 @@ import java.io.UnsupportedEncodingException;import java.net.MalformedURLException;import java.text.ParseException;import java.util.Date;-import java.util.Iterator;+import java.util.List;import java.util.Properties;import java.util.regex.Pattern;@@ -43,8 +43,8 @@ import net.yacy.kelondro.order.Base64Order;import net.yacy.kelondro.order.Bitfield;import net.yacy.kelondro.order.Digest;import net.yacy.kelondro.order.NaturalOrder;+import net.yacy.kelondro.util.ByteBuffer;import net.yacy.kelondro.util.DateFormatter;-import net.yacy.kelondro.util.FileUtils;import net.yacy.kelondro.util.kelondroException;import net.yacy.kelondro.util.MapTools;@@ -58,7 +58,7 @@ public class URIMetadataRow implements URIMetadata {public static final Row rowdef = new Row("String hash-12, " + // the url's hash- "String comp-360, " + // components: the url, description, author and tags. As 5th element, an ETag is possible+ "String comp-360, " + // components: the url, description, author, tags and publisher"Cardinal mod-4 {b256}, " + // last-modified from the httpd"Cardinal load-4 {b256}, " + // time when the url was loaded"Cardinal fresh-4 {b256}, " + // time until this url is fresh@@ -120,7 +120,7 @@ public class URIMetadataRow implements URIMetadata {final String dc_title,final String dc_creator,final String dc_subject,- final String ETag,+ final String dc_publisher,final Date mod,final Date load,final Date fresh,@@ -140,7 +140,7 @@ public class URIMetadataRow implements URIMetadata {// create new entrythis.entry = rowdef.newEntry();this.entry.setCol(col_hash, url.hash());- this.entry.setCol(col_comp, encodeComp(url, dc_title, dc_creator, dc_subject, ETag));+ this.entry.setCol(col_comp, encodeComp(url, dc_title, dc_creator, dc_subject, dc_publisher));encodeDate(col_mod, mod);encodeDate(col_load, load);encodeDate(col_fresh, fresh);@@ -187,13 +187,13 @@ public class URIMetadataRow implements URIMetadata {*/}- public static byte[] encodeComp(final DigestURI url, final String dc_title, final String dc_creator, final String dc_subject, final String ETag) {- final CharBuffer s = new CharBuffer(200);+ public static byte[] encodeComp(final DigestURI url, final String dc_title, final String dc_creator, final String dc_subject, final String dc_publisher) {+ final CharBuffer s = new CharBuffer(360);s.append(url.toNormalform(false, true)).append(10);s.append(dc_title).append(10);s.append(dc_creator).append(10);s.append(dc_subject).append(10);- s.append(ETag).append(10);+ s.append(dc_publisher).append(10);try {return s.toString().getBytes("UTF-8");} catch (UnsupportedEncodingException e) {@@ -222,11 +222,11 @@ public class URIMetadataRow implements URIMetadata {String descr = crypt.simpleDecode(prop.getProperty("descr", ""), null); if (descr == null) descr = "";String dc_creator = crypt.simpleDecode(prop.getProperty("author", ""), null); if (dc_creator == null) dc_creator = "";String tags = crypt.simpleDecode(prop.getProperty("tags", ""), null); if (tags == null) tags = "";- String ETag = crypt.simpleDecode(prop.getProperty("ETag", ""), null); if (ETag == null) ETag = "";+ String dc_publisher = crypt.simpleDecode(prop.getProperty("publisher", ""), null); if (dc_publisher == null) dc_publisher = "";this.entry = rowdef.newEntry();this.entry.setCol(col_hash, url.hash()); // FIXME potential null pointer access- this.entry.setCol(col_comp, encodeComp(url, descr, dc_creator, tags, ETag));+ this.entry.setCol(col_comp, encodeComp(url, descr, dc_creator, tags, dc_publisher));try {encodeDate(col_mod, DateFormatter.parseShortDay(prop.getProperty("mod", "20000101")));} catch (final ParseException e) {@@ -303,7 +303,7 @@ public class URIMetadataRow implements URIMetadata {assert (s.toString().indexOf(0) < 0);s.append(",tags=").append(crypt.simpleEncode(metadata.dc_subject()));assert (s.toString().indexOf(0) < 0);- s.append(",ETag=").append(crypt.simpleEncode(metadata.ETag()));+ s.append(",publisher=").append(crypt.simpleEncode(metadata.dc_publisher()));assert (s.toString().indexOf(0) < 0);s.append(",mod=").append(DateFormatter.formatShortDay(moddate()));assert (s.toString().indexOf(0) < 0);@@ -373,15 +373,16 @@ public class URIMetadataRow implements URIMetadata {public Components metadata() {// avoid double computation of metadata elementsif (this.comp != null) return this.comp;- // parse elements from comp string;- final Iterator<String> cl = FileUtils.strings(this.entry.getColBytes(col_comp, true));+ // parse elements from comp field;+ byte[] c = this.entry.getColBytes(col_comp, true);+ List<byte[]> cl = ByteBuffer.split(c, (byte) 10);this.comp = new Components(- (cl.hasNext()) ? cl.next() : "",+ (cl.size() > 0) ? new String(cl.get(0)) : "",hash(),- (cl.hasNext()) ? cl.next() : "",- (cl.hasNext()) ? cl.next() : "",- (cl.hasNext()) ? cl.next() : "",- (cl.hasNext()) ? cl.next() : "");+ (cl.size() > 1) ? new String(cl.get(1)) : "",+ (cl.size() > 2) ? new String(cl.get(2)) : "",+ (cl.size() > 3) ? new String(cl.get(3)) : "",+ (cl.size() > 4) ? new String(cl.get(4)) : "");return this.comp;}@@ -532,25 +533,16 @@ public class URIMetadataRow implements URIMetadata {private DigestURI url;private String urlRaw;private byte[] urlHash;- private final String dc_title, dc_creator, dc_subject, ETag;+ private final String dc_title, dc_creator, dc_subject, dc_publisher;- public Components(final String urlRaw, final byte[] urlhash, final String title, final String author, final String tags, final String ETag) {+ public Components(final String urlRaw, final byte[] urlhash, final String title, final String author, final String tags, final String publisher) {this.url = null;this.urlRaw = urlRaw;this.urlHash = urlhash;this.dc_title = title;this.dc_creator = author;this.dc_subject = tags;- this.ETag = ETag;- }- public Components(final DigestURI url, final String descr, final String author, final String tags, final String ETag) {- this.url = url;- this.urlRaw = null;- this.urlHash = null;- this.dc_title = descr;- this.dc_creator = author;- this.dc_subject = tags;- this.ETag = ETag;+ this.dc_publisher = publisher;}public boolean matches(Pattern matcher) {if (this.urlRaw != null) return matcher.matcher(this.urlRaw).matches();@@ -571,8 +563,8 @@ public class URIMetadataRow implements URIMetadata {}public String dc_title() { return this.dc_title; }public String dc_creator() { return this.dc_creator; }+ public String dc_publisher() { return this.dc_publisher; }public String dc_subject() { return this.dc_subject; }- public String ETag() { return this.ETag; }}}diff --git a/source/net/yacy/kelondro/data/word/Word.java b/source/net/yacy/kelondro/data/word/Word.javaindex 21657fd0e..a7584ade2 100644--- a/source/net/yacy/kelondro/data/word/Word.java+++ b/source/net/yacy/kelondro/data/word/Word.java@@ -91,6 +91,12 @@ public class Word {return phrases.iterator();}+ public String toString() {+ // this is here for debugging+ return "{count=" + count + ", posInText=" + posInText + ", posInPhrase=" + posInPhrase + ", numOfPhrase=" + numOfPhrase + "}";+ }++// static methods// create a word hashdiff --git a/source/net/yacy/kelondro/util/ByteBuffer.java b/source/net/yacy/kelondro/util/ByteBuffer.javaindex 833f9a1a8..585157785 100644--- a/source/net/yacy/kelondro/util/ByteBuffer.java+++ b/source/net/yacy/kelondro/util/ByteBuffer.java@@ -27,7 +27,9 @@ import java.io.FileNotFoundException;import java.io.IOException;import java.io.OutputStream;import java.io.UnsupportedEncodingException;+import java.util.ArrayList;import java.util.Collection;+import java.util.List;import java.util.Properties;public final class ByteBuffer extends OutputStream {@@ -511,5 +513,31 @@ public final class ByteBuffer extends OutputStream {}return false;}++ public static List<byte[]> split(byte[] b, byte s) {+ ArrayList<byte[]> a = new ArrayList<byte[]>();+ int c = 0;+ loop: while (c < b.length) {+ int i = c;+ search: while (i < b.length) {+ if (b[i] == s) break search;+ i++;+ }+ if (i >= b.length) {+ // nothing found; this is the end of the search+ byte[] bb = new byte[b.length - c];+ System.arraycopy(b, c, bb, 0, bb.length);+ a.add(bb);+ break loop;+ } else {+ // found a separator+ byte[] bb = new byte[i - c];+ System.arraycopy(b, c, bb, 0, bb.length);+ a.add(bb);+ c = i + 1;+ }+ }+ return a;+ }}\ No newline at end of filediff --git a/source/net/yacy/kelondro/util/DateFormatter.java b/source/net/yacy/kelondro/util/DateFormatter.javaindex 66b5a649a..595de7caf 100644--- a/source/net/yacy/kelondro/util/DateFormatter.java+++ b/source/net/yacy/kelondro/util/DateFormatter.java@@ -182,7 +182,17 @@ public final class DateFormatter {* @return* @throws ParseException*/- public static Date parseISO8601(final String s) throws ParseException {+ public static Date parseISO8601(String s) throws ParseException {+ // do some lazy checks here+ s = s.trim();+ if (s.startsWith("{")) s = s.substring(1);+ if (s.endsWith("}")) s = s.substring(0, s.length() - 1);+ if (s.startsWith("[")) s = s.substring(1);+ if (s.endsWith("]")) s = s.substring(0, s.length() - 1);+ while (s.charAt(0) > '9' || s.charAt(0) < '0') s = s.substring(1);+ if (s.endsWith("--")) s = s.substring(0, s.length() - 2) + "00";++ // no go for exact parsingfinal Calendar cal = Calendar.getInstance(TZ_GMT, Locale.US);cal.clear();@@ -265,8 +275,8 @@ public final class DateFormatter {// in case we couldn't even parse a yearif (!cal.isSet(Calendar.YEAR))throw new ParseException("parseISO8601: Cannot parse '" + s + "'", 0);-- return cal.getTime();+ Date d = cal.getTime();+ return d;}/**diff --git a/source/net/yacy/kelondro/util/Domains.java b/source/net/yacy/kelondro/util/Domains.javaindex 0995b6f82..b122c888f 100644--- a/source/net/yacy/kelondro/util/Domains.java+++ b/source/net/yacy/kelondro/util/Domains.java@@ -612,5 +612,4 @@ public class Domains {// the address must be a global addressreturn false;}-}