From 6d388bb7bfa79454ef63a1e227924fdab105b807 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sun, 2 Oct 2022 22:26:53 +0200 Subject: [PATCH] refactoring - moved htroot/yacy classes --- source/net/yacy/htroot/Wiki.java | 11 ++-- .../net/yacy/htroot}/api/trail_p.java | 4 +- .../net/yacy/htroot}/yacy/crawlReceipt.java | 2 + .../net/yacy/htroot}/yacy/hello.java | 18 +++--- .../net/yacy/htroot}/yacy/idx.java | 2 + .../net/yacy/htroot}/yacy/list.java | 4 +- .../net/yacy/htroot}/yacy/message.java | 8 ++- .../net/yacy/htroot}/yacy/profile.java | 2 + .../net/yacy/htroot}/yacy/query.java | 2 + .../net/yacy/htroot}/yacy/search.java | 16 ++--- .../net/yacy/htroot}/yacy/seedlist.java | 60 ++++++++++--------- .../net/yacy/htroot}/yacy/transferRWI.java | 9 +-- .../net/yacy/htroot}/yacy/transferURL.java | 10 ++-- .../net/yacy/htroot}/yacy/urls.java | 6 +- .../http/servlets/YaCyDefaultServlet.java | 4 +- 15 files changed, 91 insertions(+), 67 deletions(-) rename {htroot => source/net/yacy/htroot}/api/trail_p.java (93%) rename {htroot => source/net/yacy/htroot}/yacy/crawlReceipt.java (97%) rename {htroot => source/net/yacy/htroot}/yacy/hello.java (95%) rename {htroot => source/net/yacy/htroot}/yacy/idx.java (99%) rename {htroot => source/net/yacy/htroot}/yacy/list.java (99%) rename {htroot => source/net/yacy/htroot}/yacy/message.java (97%) rename {htroot => source/net/yacy/htroot}/yacy/profile.java (96%) rename {htroot => source/net/yacy/htroot}/yacy/query.java (97%) rename {htroot => source/net/yacy/htroot}/yacy/search.java (97%) rename {htroot => source/net/yacy/htroot}/yacy/seedlist.java (76%) rename {htroot => source/net/yacy/htroot}/yacy/transferRWI.java (95%) rename {htroot => source/net/yacy/htroot}/yacy/transferURL.java (95%) rename {htroot => source/net/yacy/htroot}/yacy/urls.java (97%) diff --git a/source/net/yacy/htroot/Wiki.java b/source/net/yacy/htroot/Wiki.java index c4fc8c3b8..f4a137b26 100644 --- a/source/net/yacy/htroot/Wiki.java +++ b/source/net/yacy/htroot/Wiki.java @@ -1,4 +1,3 @@ -package net.yacy.htroot; // Wiki.java // ----------------------- // part of the AnomicHTTPD caching proxy @@ -31,6 +30,8 @@ package net.yacy.htroot; // javac -classpath .:../classes Wiki.java // if the shell's current path is HTROOT +package net.yacy.htroot; + import java.io.IOException; import java.util.Arrays; import java.util.Date; @@ -126,7 +127,7 @@ public class Wiki { prop.putHTML(serverObjects.ACTION_LOCATION, "Wiki.html?page=" + pagename); prop.put(serverObjects.ACTION_LOCATION, prop.get(serverObjects.ACTION_LOCATION)); } - + if (post != null && post.containsKey("edit")) { if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) { // check access right for admin @@ -146,7 +147,7 @@ public class Wiki { prop.putHTML("mode_pagename", pagename); prop.putHTML("mode_author", author); prop.put("mode_date", dateString(new Date())); - /* We do not fill hostport parameter : relative links should stay relative as it is more reliable + /* We do not fill hostport parameter : relative links should stay relative as it is more reliable * when the peer is behind any kind of reverse Proxy */ prop.putWiki("mode_page", post.get("content", "")); prop.putHTML("mode_page-code", post.get("content", "")); @@ -238,7 +239,7 @@ public class Wiki { prop.putHTML("mode_versioning_pagename", pagename); prop.putHTML("mode_versioning_author", oentry.author()); prop.put("mode_versioning_date", dateString(oentry.date())); - /* We do not fill hostport parameter : relative links should stay relative as it is more reliable + /* We do not fill hostport parameter : relative links should stay relative as it is more reliable * when the peer is behind any kind of reverse Proxy */ prop.putWiki("mode_versioning_page", oentry.page()); prop.putHTML("mode_versioning_page-code", UTF8.String(oentry.page())); @@ -255,7 +256,7 @@ public class Wiki { prop.putHTML("mode_pagename", pagename); prop.putHTML("mode_author", page.author()); prop.put("mode_date", dateString(page.date())); - /* We do not fill hostport parameter : relative links should stay relative as it is more reliable + /* We do not fill hostport parameter : relative links should stay relative as it is more reliable * when the peer is behind any kind of reverse Proxy */ prop.putWiki("mode_page", page.page()); diff --git a/htroot/api/trail_p.java b/source/net/yacy/htroot/api/trail_p.java similarity index 93% rename from htroot/api/trail_p.java rename to source/net/yacy/htroot/api/trail_p.java index 8ab6addfd..8e59e70b4 100644 --- a/htroot/api/trail_p.java +++ b/source/net/yacy/htroot/api/trail_p.java @@ -22,6 +22,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package net.yacy.htroot.api; + import net.yacy.cora.protocol.RequestHeader; import net.yacy.search.Switchboard; import net.yacy.server.serverObjects; @@ -34,7 +36,7 @@ public class trail_p { final serverObjects prop = new serverObjects(); int c = 0; - for (String t: sb.trail) { + for (final String t: sb.trail) { prop.put("trails_" + c++ + "_trail", t); // don't put in putHTML or putXML in, this is wrong! } prop.put("trails", c); diff --git a/htroot/yacy/crawlReceipt.java b/source/net/yacy/htroot/yacy/crawlReceipt.java similarity index 97% rename from htroot/yacy/crawlReceipt.java rename to source/net/yacy/htroot/yacy/crawlReceipt.java index 9bb321f96..8b778fe60 100644 --- a/htroot/yacy/crawlReceipt.java +++ b/source/net/yacy/htroot/yacy/crawlReceipt.java @@ -26,8 +26,10 @@ // You must compile this file with // javac -classpath .:../classes crawlOrder.java +package net.yacy.htroot.yacy; import java.io.IOException; + import net.yacy.cora.document.encoding.ASCII; import net.yacy.cora.federate.solr.FailCategory; import net.yacy.cora.protocol.RequestHeader; diff --git a/htroot/yacy/hello.java b/source/net/yacy/htroot/yacy/hello.java similarity index 95% rename from htroot/yacy/hello.java rename to source/net/yacy/htroot/yacy/hello.java index a153204e9..ccf62b3e7 100644 --- a/htroot/yacy/hello.java +++ b/source/net/yacy/htroot/yacy/hello.java @@ -27,6 +27,8 @@ // javac -classpath .:../../classes hello.java // if the shell's current path is HTROOT +package net.yacy.htroot.yacy; + import java.io.IOException; import java.net.InetAddress; import java.net.MalformedURLException; @@ -38,8 +40,8 @@ import net.yacy.cora.document.id.MultiProtocolURL; import net.yacy.cora.protocol.Domains; import net.yacy.cora.protocol.HeaderFramework; import net.yacy.cora.protocol.RequestHeader; -import net.yacy.peers.Network; import net.yacy.peers.DHTSelection; +import net.yacy.peers.Network; import net.yacy.peers.Protocol; import net.yacy.peers.Seed; import net.yacy.peers.graphics.ProfilingGraph; @@ -51,7 +53,7 @@ import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; public final class hello { - + // example: // http://localhost:8090/yacy/hello.html?count=1&seed=p|{Hash=sCJ6Tq8T0N9x,Port=8090,PeerType=junior} // http://localhost:8090/yacy/hello.html?count=10&seed=z|H4sIAAAAAAAAADWQW2vDMAyF_81eJork3GyGX-YxGigly2WFvZTQijbQJsHx1pWx_z7nMj1J4ug7B_2s6-GsP5q3G-G6vBz2e0iz8t6zfuBr7-5PUNanQfulhqyzTkuUCFXvmitrBJtq4ed3tkPTtRpXhIiRDAmq0uhHFIiQMduJ-NXYU9NCbrrP1vnjIdUqgk09uIK51V6rMBRIilAo2NajwzfhGcx8QUKsEIp5iCJo-eaTVUXPfPQ4k5dm4pp8NzaESsLzS-14QVNIMlA-ka2m1JuZJJWIBRwPo0GIIiYp4zCSkC5GQSLiJIah0p6X_rvlS-MTbWdhkCSBIni9jA_rfP3-Ae1Oye9dAQAA @@ -162,8 +164,8 @@ public final class hello { int callbackRemain = Math.min(5, reportedips.size()); final long callbackStart = System.currentTimeMillis(); if (callbackRemain > 0 && reportedips.size() > 0) { - for (String reportedip: reportedips) { - int partialtimeout = ((int) (callbackStart + totalTimeout - System.currentTimeMillis())) / callbackRemain; // bad hack until a concurrent version is implemented + for (final String reportedip: reportedips) { + final int partialtimeout = ((int) (callbackStart + totalTimeout - System.currentTimeMillis())) / callbackRemain; // bad hack until a concurrent version is implemented if (partialtimeout <= 0) break; //ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " is handled"); if (Seed.isProperIP(reportedip)) { @@ -174,7 +176,7 @@ public final class hello { try { MultiProtocolURL remoteBaseURL = remoteSeed.getPublicMultiprotocolURL(reportedip, preferHttps); callback = Protocol.queryRWICount(remoteBaseURL, remoteSeed, partialtimeout); - if (callback[0] < 0 && remoteBaseURL.isHTTPS()) { + if (callback[0] < 0 && remoteBaseURL.isHTTPS()) { /* Failed using https : retry using http */ remoteBaseURL = remoteSeed.getPublicMultiprotocolURL(reportedip, false); callback = Protocol.queryRWICount(remoteBaseURL, remoteSeed, partialtimeout); @@ -185,9 +187,9 @@ public final class hello { //ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " returns callback " + (callback == null ? "NULL" : callback[0])); time_backping = System.currentTimeMillis() - time; backping_method = "reportedip=" + reportedip; - if (callback[0] >= 0) { - success = true; - break; + if (callback[0] >= 0) { + success = true; + break; } if (--callbackRemain <= 0) break; // no more tries left / restrict to a limited number of ips } diff --git a/htroot/yacy/idx.java b/source/net/yacy/htroot/yacy/idx.java similarity index 99% rename from htroot/yacy/idx.java rename to source/net/yacy/htroot/yacy/idx.java index 7662a6b08..44b979e25 100644 --- a/htroot/yacy/idx.java +++ b/source/net/yacy/htroot/yacy/idx.java @@ -22,6 +22,8 @@ * If not, see . */ +package net.yacy.htroot.yacy; + import java.util.Iterator; import net.yacy.cora.document.encoding.ASCII; diff --git a/htroot/yacy/list.java b/source/net/yacy/htroot/yacy/list.java similarity index 99% rename from htroot/yacy/list.java rename to source/net/yacy/htroot/yacy/list.java index 60d4544eb..da412e83b 100644 --- a/htroot/yacy/list.java +++ b/source/net/yacy/htroot/yacy/list.java @@ -25,21 +25,21 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package net.yacy.htroot.yacy; import java.io.File; import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.util.CommonPattern; import net.yacy.kelondro.util.FileUtils; -import net.yacy.peers.Seed; import net.yacy.peers.Protocol; +import net.yacy.peers.Seed; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; - public final class list { public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { diff --git a/htroot/yacy/message.java b/source/net/yacy/htroot/yacy/message.java similarity index 97% rename from htroot/yacy/message.java rename to source/net/yacy/htroot/yacy/message.java index 59a07e3ca..1ccdaacad 100644 --- a/htroot/yacy/message.java +++ b/source/net/yacy/htroot/yacy/message.java @@ -27,12 +27,16 @@ // javac -classpath .:../../classes message.java // if the shell's current path is HTROOT/yacy +package net.yacy.htroot.yacy; + import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.net.InetAddress; import java.util.Date; +import com.google.common.io.Files; + import net.yacy.cora.date.GenericFormatter; import net.yacy.cora.document.encoding.UTF8; import net.yacy.cora.protocol.Domains; @@ -49,8 +53,6 @@ import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; import net.yacy.utils.crypt; -import com.google.common.io.Files; - public final class message { @@ -67,7 +69,7 @@ public final class message { prop.put("messagesize", "0"); prop.put("attachmentsize", "0"); prop.put("response", "-1"); // request rejected - + if ((post == null) || (env == null)) return prop; if (!Protocol.authentifyRequest(post, env)) return prop; diff --git a/htroot/yacy/profile.java b/source/net/yacy/htroot/yacy/profile.java similarity index 96% rename from htroot/yacy/profile.java rename to source/net/yacy/htroot/yacy/profile.java index f0e0eb1dd..9301278db 100644 --- a/htroot/yacy/profile.java +++ b/source/net/yacy/htroot/yacy/profile.java @@ -29,6 +29,8 @@ // javac -classpath .:../../Classes hello.java // if the shell's current path is HTROOT +package net.yacy.htroot.yacy; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; diff --git a/htroot/yacy/query.java b/source/net/yacy/htroot/yacy/query.java similarity index 97% rename from htroot/yacy/query.java rename to source/net/yacy/htroot/yacy/query.java index cd4c90ec4..1c42fdb35 100644 --- a/htroot/yacy/query.java +++ b/source/net/yacy/htroot/yacy/query.java @@ -27,6 +27,8 @@ // javac -classpath .:../../classes query.java // if the shell's current path is HTROOT +package net.yacy.htroot.yacy; + import java.io.IOException; import net.yacy.cora.date.GenericFormatter; diff --git a/htroot/yacy/search.java b/source/net/yacy/htroot/yacy/search.java similarity index 97% rename from htroot/yacy/search.java rename to source/net/yacy/htroot/yacy/search.java index 612ebb13d..499ab6776 100644 --- a/htroot/yacy/search.java +++ b/source/net/yacy/htroot/yacy/search.java @@ -28,6 +28,8 @@ // javac -classpath .:../../Classes search.java // if the shell's current path is htroot/yacy +package net.yacy.htroot.yacy; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -119,7 +121,7 @@ public final class search { final boolean strictContentDom = post.getBoolean("strictContentDom"); final String filter = post.get("filter", ".*"); // a filter on the url final int timezoneOffset = post.getInt("timezoneOffset", 0); - QueryModifier modifier = new QueryModifier(timezoneOffset); + final QueryModifier modifier = new QueryModifier(timezoneOffset); modifier.sitehost = post.get("sitehost", ""); if (modifier.sitehost.isEmpty()) modifier.sitehost = null; modifier.sitehash = post.get("sitehash", ""); if (modifier.sitehash.isEmpty()) modifier.sitehash = null; modifier.author = post.get("author", ""); if (modifier.author.isEmpty()) modifier.author = null; @@ -225,7 +227,7 @@ public final class search { if (query.isEmpty() && abstractSet != null) { // this is _not_ a normal search, only a request for index abstracts final Segment indexSegment = sb.index; - QueryGoal qg = new QueryGoal(abstractSet, new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0)); + final QueryGoal qg = new QueryGoal(abstractSet, new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0)); theQuery = new QueryParams( qg, modifier, @@ -287,10 +289,10 @@ public final class search { } else { // retrieve index containers from search request - RowHandleSet allHashes = new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0); + final RowHandleSet allHashes = new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0); try {allHashes.putAll(queryhashes);} catch (final SpaceExceededException e) {} try {allHashes.putAll(excludehashes);} catch (final SpaceExceededException e) {} - QueryGoal qg = new QueryGoal(queryhashes, excludehashes); + final QueryGoal qg = new QueryGoal(queryhashes, excludehashes); theQuery = new QueryParams( qg, modifier, @@ -325,7 +327,7 @@ public final class search { Network.log.info("INIT HASH SEARCH (query-" + abstracts + "): " + QueryParams.anonymizedQueryHashes(theQuery.getQueryGoal().getIncludeHashes()) + " - " + theQuery.itemsPerPage() + " links"); EventChannel.channels(EventChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.getQueryGoal().getIncludeHashes()), "")); if (sb.getConfigBool(SwitchboardConstants.DECORATION_AUDIO, false)) Audio.Soundclip.remotesearch.play(-10.0f); - + // make event theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.tables, null, abstracts.length() > 0, sb.loader, count, maxtime); if (theSearch.rwiProcess != null && theSearch.rwiProcess.isAlive()) try {theSearch.rwiProcess.join();} catch (final InterruptedException e) {} @@ -384,7 +386,7 @@ public final class search { final long timer = System.currentTimeMillis(); //final ScoreMap topicNavigator = sb.index.connectedRWI() ? theSearch.getTopics(5, 100) : new ConcurrentScoreMap(); final ScoreMap topicNavigator = theSearch.getTopics(); // as there is currently no index interaction in getTopics(), we can use it by default - + final StringBuilder refstr = new StringBuilder(6000); final Iterator navigatorIterator = topicNavigator.keys(false); int i = 0; @@ -400,7 +402,7 @@ public final class search { prop.put("indexabstract", indexabstract.toString()); // prepare result - int resultCount = theSearch == null ? 0 : theSearch.getResultCount(); // theSearch may be null if we searched only for abstracts + final int resultCount = theSearch == null ? 0 : theSearch.getResultCount(); // theSearch may be null if we searched only for abstracts if (resultCount == 0 || accu == null || accu.isEmpty()) { // no results diff --git a/htroot/yacy/seedlist.java b/source/net/yacy/htroot/yacy/seedlist.java similarity index 76% rename from htroot/yacy/seedlist.java rename to source/net/yacy/htroot/yacy/seedlist.java index dc640eaa9..613937d31 100644 --- a/htroot/yacy/seedlist.java +++ b/source/net/yacy/htroot/yacy/seedlist.java @@ -19,6 +19,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package net.yacy.htroot.yacy; + import java.util.ArrayList; import java.util.Map; import java.util.Set; @@ -45,38 +47,38 @@ import net.yacy.server.serverSwitch; public final class seedlist { private static final int LISTMAX = 1000; - + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements final Switchboard sb = (Switchboard) env; - int maxcount = Math.min(LISTMAX, post == null ? Integer.MAX_VALUE : post.getInt("maxcount", Integer.MAX_VALUE)); - float minversion = Math.min(LISTMAX, post == null ? 0.0f : post.getFloat("minversion", 0.0f)); - boolean nodeonly = post == null || !post.containsKey("node") ? false : post.getBoolean("node"); - boolean includeme = post == null || !post.containsKey("me") ? true : post.getBoolean("me"); - boolean addressonly = post == null || !post.containsKey("address") ? false : post.getBoolean("address"); - String peername = post == null ? null : post.containsKey("my") ? sb.peers.myName() : post.get("peername"); + final int maxcount = Math.min(LISTMAX, post == null ? Integer.MAX_VALUE : post.getInt("maxcount", Integer.MAX_VALUE)); + final float minversion = Math.min(LISTMAX, post == null ? 0.0f : post.getFloat("minversion", 0.0f)); + final boolean nodeonly = post == null || !post.containsKey("node") ? false : post.getBoolean("node"); + final boolean includeme = post == null || !post.containsKey("me") ? true : post.getBoolean("me"); + final boolean addressonly = post == null || !post.containsKey("address") ? false : post.getBoolean("address"); + final String peername = post == null ? null : post.containsKey("my") ? sb.peers.myName() : post.get("peername"); final ArrayList v; if (post != null && post.containsKey("my")) { v = new ArrayList(1); v.add(sb.peers.mySeed()); } else if (post != null && post.containsKey("id")) { v = new ArrayList(1); - Seed s = sb.peers.get(post.get("id")); + final Seed s = sb.peers.get(post.get("id")); if (s != null) v.add(s); } else if (post != null && post.containsKey("name")) { v = new ArrayList(1); - Seed s = sb.peers.lookupByName(post.get("name")); + final Seed s = sb.peers.lookupByName(post.get("name")); if (s != null) v.add(s); } else { v= sb.peers.getSeedlist(maxcount, includeme, nodeonly, minversion); } final serverObjects prop = new serverObjects(); - + // write simple-encoded seed lines or json - String EXT = header.get(HeaderFramework.CONNECTION_PROP_EXT); - boolean json = EXT != null && EXT.equals("json"); - boolean xml = EXT != null && EXT.equals("xml"); - + final String EXT = header.get(HeaderFramework.CONNECTION_PROP_EXT); + final boolean json = EXT != null && EXT.equals("json"); + final boolean xml = EXT != null && EXT.equals("xml"); + if (json) { // check for JSONP if ( post != null && post.containsKey("callback") ) { @@ -89,17 +91,17 @@ public final class seedlist { // construct json property lists int count = 0; for (int i = 0; i < v.size(); i++) { - Seed seed = v.get(i); + final Seed seed = v.get(i); if (peername != null && !peername.equals(seed.getName())) continue; - Set ips = seed.getIPs(); + final Set ips = seed.getIPs(); if (ips == null || ips.size() == 0) continue; prop.putJSON("peers_" + count + "_map_0_k", Seed.HASH); prop.put("peers_" + count + "_map_0_v", JSONObject.quote(seed.hash)); prop.put("peers_" + count + "_map_0_c", 1); - Map map = seed.getMap(); + final Map map = seed.getMap(); int c = 1; if (!addressonly) { - for (Map.Entry m: map.entrySet()) { + for (final Map.Entry m: map.entrySet()) { prop.putJSON("peers_" + count + "_map_" + c + "_k", m.getKey()); prop.put("peers_" + count + "_map_" + c + "_v", JSONObject.quote(m.getValue())); prop.put("peers_" + count + "_map_" + c + "_c", 1); @@ -107,9 +109,9 @@ public final class seedlist { } } // construct a list of ips - StringBuilder a = new StringBuilder(); + final StringBuilder a = new StringBuilder(); a.append('['); - for (String ip: ips) a.append(JSONObject.quote(seed.getPublicAddress(ip))).append(','); + for (final String ip: ips) a.append(JSONObject.quote(seed.getPublicAddress(ip))).append(','); a.setCharAt(a.length()-1, ']'); prop.putJSON("peers_" + count + "_map_" + c + "_k", "Address"); prop.put("peers_" + count + "_map_" + c + "_v", a.toString()); @@ -124,22 +126,22 @@ public final class seedlist { } else if (xml) { int count = 0; for (int i = 0; i < v.size(); i++) { - Seed seed = v.get(i); + final Seed seed = v.get(i); if (peername != null && !peername.equals(seed.getName())) continue; - Set ips = seed.getIPs(); + final Set ips = seed.getIPs(); if (ips == null || ips.size() == 0) continue; prop.putXML("peers_" + count + "_map_0_k", Seed.HASH); prop.putXML("peers_" + count + "_map_0_v", seed.hash); - Map map = seed.getMap(); + final Map map = seed.getMap(); int c = 1; if (!addressonly) { - for (Map.Entry m: map.entrySet()) { + for (final Map.Entry m: map.entrySet()) { prop.putXML("peers_" + count + "_map_" + c + "_k", m.getKey()); prop.putXML("peers_" + count + "_map_" + c + "_v", m.getValue()); c++; } } - for (String ip: ips) { + for (final String ip: ips) { prop.putXML("peers_" + count + "_map_" + c + "_k", "Address"); prop.putXML("peers_" + count + "_map_" + c + "_v", seed.getPublicAddress(ip)); c++; @@ -147,17 +149,17 @@ public final class seedlist { prop.put("peers_" + count + "_map", c); count++; } - + prop.put("peers_" + (count - 1) + "_c", 0); prop.put("peers", count); } else { final StringBuilder encoded = new StringBuilder(1024); - for (Seed seed: v) { + for (final Seed seed: v) { encoded.append(seed.genSeedStr(null)).append(serverCore.CRLF_STRING); - } + } prop.put("encoded", encoded.toString()); } - + // return rewrite properties return prop; } diff --git a/htroot/yacy/transferRWI.java b/source/net/yacy/htroot/yacy/transferRWI.java similarity index 95% rename from htroot/yacy/transferRWI.java rename to source/net/yacy/htroot/yacy/transferRWI.java index a5182305e..aaab64a52 100644 --- a/htroot/yacy/transferRWI.java +++ b/source/net/yacy/htroot/yacy/transferRWI.java @@ -26,6 +26,7 @@ // You must compile this file with // javac -classpath .:../classes transferRWI.java +package net.yacy.htroot.yacy; import java.util.ArrayList; import java.util.HashSet; @@ -126,8 +127,8 @@ public final class transferRWI { result = "ok"; final StringBuilder unknownURLs = new StringBuilder(6000); - double load = Memory.getSystemLoadAverage(); - float maxload = sb.getConfigFloat(SwitchboardConstants.INDEX_DIST_LOADPREREQ, 2.0f); + final double load = Memory.getSystemLoadAverage(); + final float maxload = sb.getConfigFloat(SwitchboardConstants.INDEX_DIST_LOADPREREQ, 2.0f); if (load > maxload) { // too high local load. this is bad but we must reject this to protect ourself! sb.getLog().info("Rejecting RWIs from peer " + otherPeerName + ", system has too high load = " + load + ", maxload = " + maxload); @@ -187,7 +188,7 @@ public final class transferRWI { int received = 0; int blocked = 0; int count = 0; - Set testids = new HashSet(); + final Set testids = new HashSet(); while (it.hasNext()) { estring = it.next(); count++; @@ -231,7 +232,7 @@ public final class transferRWI { testids.add(ASCII.String(urlHash)); received++; } - for (String id: testids) { + for (final String id: testids) { try { if (!sb.index.fulltext().exists(id)) { unknownURL.put(ASCII.getBytes(id)); diff --git a/htroot/yacy/transferURL.java b/source/net/yacy/htroot/yacy/transferURL.java similarity index 95% rename from htroot/yacy/transferURL.java rename to source/net/yacy/htroot/yacy/transferURL.java index c0d7a4f1b..b9c9e2f82 100644 --- a/htroot/yacy/transferURL.java +++ b/source/net/yacy/htroot/yacy/transferURL.java @@ -26,6 +26,8 @@ // You must compile this file with // javac -classpath .:../classes transferRWI.java +package net.yacy.htroot.yacy; + import java.io.IOException; import java.text.ParseException; import java.util.HashMap; @@ -91,7 +93,7 @@ public final class transferURL { // read the urls from the other properties and store String urls; URIMetadataNode lEntry; - Map lEm = new HashMap(); + final Map lEm = new HashMap(); for (int i = 0; i < urlc; i++) { // read new lurl-entry @@ -143,9 +145,9 @@ public final class transferURL { lEm.put(ASCII.String(lEntry.hash()), lEntry); } - + doublecheck = 0; - for (String id : lEm.keySet()) { + for (final String id : lEm.keySet()) { if (sb.index.exists(id)) { doublecheck++; } else { @@ -170,7 +172,7 @@ public final class transferURL { Network.log.info("Received " + received + " URLs from peer " + otherPeerName + " in " + (System.currentTimeMillis() - start) + " ms, blocked " + blocked + " URLs"); EventChannel.channels(EventChannel.DHTRECEIVE).addMessage(new RSSMessage("Received " + received + ", blocked " + blocked + " URLs from peer " + otherPeerName, "", otherPeer.hash)); if (sb.getConfigBool(SwitchboardConstants.DECORATION_AUDIO, false)) Audio.Soundclip.dhtin.play(-10.0f); - + if (doublecheck > 0) { Network.log.warn("Received " + doublecheck + "/" + urlc + " double URLs from peer " + otherPeerName); // double should not happen because we demanded only documents which we do not have yet doublevalues = Integer.toString(doublecheck); diff --git a/htroot/yacy/urls.java b/source/net/yacy/htroot/yacy/urls.java similarity index 97% rename from htroot/yacy/urls.java rename to source/net/yacy/htroot/yacy/urls.java index 85cba5275..4e14b0f6d 100644 --- a/htroot/yacy/urls.java +++ b/source/net/yacy/htroot/yacy/urls.java @@ -24,6 +24,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package net.yacy.htroot.yacy; + import java.io.IOException; import net.yacy.cora.date.GenericFormatter; @@ -77,7 +79,7 @@ public class urls { // find referrer, if there is one try { referrerURL = sb.getURL(entry.referrerhash()); - } catch (IOException e) { + } catch (final IOException e) { referrerURL = null; ConcurrentLog.logException(e); } @@ -123,7 +125,7 @@ public class urls { prop.put("item_" + c + "_pubDate", GenericFormatter.SHORT_SECOND_FORMATTER.format(entry.moddate())); prop.put("item_" + c + "_guid", ASCII.String(entry.hash())); c++; - } catch (IOException e) { + } catch (final IOException e) { ConcurrentLog.logException(e); } } diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java index 430a06786..10a97af9b 100644 --- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java +++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java @@ -778,9 +778,9 @@ public class YaCyDefaultServlet extends HttpServlet { if (p < 0) { return null; } - target = target.substring(1, p); + target = "net.yacy.htroot" + target.substring(0, p).replace('/', '.'); - final Class servletClass = Class.forName("net.yacy.htroot." + target); + final Class servletClass = Class.forName(target); return servletClass; } catch (final ClassNotFoundException e) {