From 8eaabb9600be011df7aab37fb9534e59167fa1b7 Mon Sep 17 00:00:00 2001 From: reger Date: Sun, 29 Dec 2013 02:00:44 +0100 Subject: [PATCH] remove dependency from old serverCore.java - remaining getPortNr not needed (as current release allows only to set plain integer as port, see ConfigBasic) --- htroot/Status.java | 3 +-- htroot/opensearchdescription.java | 3 +-- htroot/www/welcome.java | 3 +-- htroot/yacysearch.java | 5 ++--- htroot/yacysearch_location.java | 3 +-- source/net/yacy/search/Switchboard.java | 2 +- source/net/yacy/server/http/HTTPDemon.java | 7 +++---- source/net/yacy/server/serverCore.java | 9 --------- source/net/yacy/yacy.java | 3 +-- 9 files changed, 11 insertions(+), 27 deletions(-) diff --git a/htroot/Status.java b/htroot/Status.java index 6b16c4c91..e210cc382 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -44,7 +44,6 @@ import net.yacy.peers.Seed; import net.yacy.peers.operation.yacyBuildProperties; 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; @@ -185,7 +184,7 @@ public class Status // hostname and port final String extendedPortString = sb.getConfig("port", "8090"); final int pos = extendedPortString.indexOf(':', 0); - prop.put("port", serverCore.getPortNr(extendedPortString)); + prop.put("port", extendedPortString); if ( pos != -1 ) { prop.put("extPortFormat", "1"); prop.putHTML("extPortFormat_extPort", extendedPortString); diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.java index 8c2cb7c55..797d3fa4b 100644 --- a/htroot/opensearchdescription.java +++ b/htroot/opensearchdescription.java @@ -28,7 +28,6 @@ import net.yacy.cora.protocol.Domains; import net.yacy.cora.protocol.RequestHeader; 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; @@ -41,7 +40,7 @@ public class opensearchdescription { if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", ""); String thisaddress = header.get("Host", Domains.LOCALHOST); - if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8090")); + if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + env.getConfig("port", "8090"); final serverObjects prop = new serverObjects(); prop.put("compareyacy", post != null && post.getBoolean("compare_yacy") ? 1 : 0); diff --git a/htroot/www/welcome.java b/htroot/www/welcome.java index 1b48bfb0e..86aed58b3 100644 --- a/htroot/www/welcome.java +++ b/htroot/www/welcome.java @@ -35,7 +35,6 @@ import net.yacy.cora.protocol.HeaderFramework; import net.yacy.cora.protocol.RequestHeader; import net.yacy.peers.Seed; import net.yacy.search.Switchboard; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; @@ -55,7 +54,7 @@ public class welcome { prop.putHTML("peeraddress", sb.peers.mySeed().getPublicAddress()); prop.put("hostname", env.myPublicIP()); prop.put("hostip", Domains.dnsResolve(env.myPublicIP()).getHostAddress()); - prop.put("port", serverCore.getPortNr(env.getConfig("port","8090"))); + prop.put("port", env.getConfig("port","8090")); prop.put("clientip", header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")); final String peertype = (sb.peers.mySeed() == null) ? Seed.PEERTYPE_JUNIOR : sb.peers.mySeed().get(Seed.PEERTYPE, Seed.PEERTYPE_VIRGIN); diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 40c01c39a..1953e5f86 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -85,7 +85,6 @@ import net.yacy.search.query.SearchEvent; import net.yacy.search.query.SearchEventCache; import net.yacy.search.query.SearchEventType; import net.yacy.search.ranking.RankingProfile; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; import net.yacy.server.servletProperties; @@ -147,7 +146,7 @@ public class yacysearch { // adding some additional properties needed for the rss feed String hostName = header.get("Host", Domains.LOCALHOST); if ( hostName.indexOf(':', 0) == -1 ) { - hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8090")); + hostName += ":" + env.getConfig("port", "8090"); } prop.put("searchBaseURL", "http://" + hostName + "/yacysearch.html"); prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif"); @@ -982,7 +981,7 @@ public class yacysearch { // hostname and port (assume locahost if nothing helps) final InetAddress hostIP = Domains.myPublicLocalIP(); prop.put("myhost", hostIP != null ? hostIP.getHostAddress() : Domains.LOCALHOST); - prop.put("myport", serverCore.getPortNr(sb.getConfig("port", "8090"))); + prop.put("myport", sb.getConfig("port", "8090")); // return rewrite properties return prop; diff --git a/htroot/yacysearch_location.java b/htroot/yacysearch_location.java index e1a47b05e..2d12d32c3 100644 --- a/htroot/yacysearch_location.java +++ b/htroot/yacysearch_location.java @@ -33,7 +33,6 @@ import net.yacy.cora.protocol.RequestHeader; import net.yacy.document.LibraryProvider; 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; @@ -122,7 +121,7 @@ public class yacysearch_location { String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, ""); if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", ""); String hostName = header.get("Host", Domains.LOCALHOST); - if (hostName.indexOf(':',0) == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8090")); + if (hostName.indexOf(':',0) == -1) hostName += ":" + env.getConfig("port", "8090"); final String originalquerystring = (post == null) ? "" : post.get("query", post.get("search", "")).trim(); // SRU compliance final boolean global = post.get("kml_resource", "local").equals("global"); diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index f847e0f74..ebe9111e5 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -3632,7 +3632,7 @@ public final class Switchboard extends serverSwitch { private static long indeSizeCache = 0; private static long indexSizeTime = 0; public void updateMySeed() { - this.peers.mySeed().put(Seed.PORT, Integer.toString(serverCore.getPortNr(getConfig("port", "8090")))); + this.peers.mySeed().put(Seed.PORT, getConfig("port", "8090")); //the speed of indexing (pages/minute) of the peer final long uptime = (System.currentTimeMillis() - serverCore.startupTime) / 1000; diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java index 1137ad5d7..368ec6d9e 100644 --- a/source/net/yacy/server/http/HTTPDemon.java +++ b/source/net/yacy/server/http/HTTPDemon.java @@ -54,7 +54,6 @@ import net.yacy.cora.util.NumberTools; import net.yacy.kelondro.util.FileUtils; import net.yacy.kelondro.util.MemoryControl; import net.yacy.search.Switchboard; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; @@ -324,13 +323,13 @@ public final class HTTPDemon { final InetAddress hostAddress = Domains.dnsResolve(clientIP); if (hostAddress == null) { tp.put("host", Domains.myPublicLocalIP().getHostAddress()); - tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090")))); + tp.put("port", switchboard.getConfig("port", "8090")); } else if (hostAddress.isSiteLocalAddress() || hostAddress.isLoopbackAddress()) { tp.put("host", Domains.myPublicLocalIP().getHostAddress()); - tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090")))); + tp.put("port", switchboard.getConfig("port", "8090")); } else { tp.put("host", switchboard.myPublicIP()); - tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090")))); + tp.put("port", switchboard.getConfig("port", "8090")); } tp.put("peerName", (getAlternativeResolver() == null) ? "" : getAlternativeResolver().myName()); diff --git a/source/net/yacy/server/serverCore.java b/source/net/yacy/server/serverCore.java index dab2d4596..5da152543 100644 --- a/source/net/yacy/server/serverCore.java +++ b/source/net/yacy/server/serverCore.java @@ -41,13 +41,4 @@ public final class serverCore { public static boolean useStaticIP = false; - public static int getPortNr(String extendedPortString) { - int pos = -1; - if ((pos = extendedPortString.indexOf(':'))!= -1) { - extendedPortString = extendedPortString.substring(pos+1); - } - return Integer.parseInt(extendedPortString); - } - - } diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index 90fd9abc3..2a0a96700 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -63,7 +63,6 @@ import net.yacy.peers.operation.yacyRelease; import net.yacy.peers.operation.yacyVersion; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; -import net.yacy.server.serverCore; import com.google.common.io.Files; import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.federate.yacy.CacheStrategy; @@ -542,7 +541,7 @@ public final class yacy { final Properties config = configuration("COMMAND-STEERING", homePath); // read port - final int port = serverCore.getPortNr(config.getProperty("port", "8090")); + final int port = Integer.parseInt(config.getProperty("port", "8090")); // read password String encodedPassword = (String) config.get(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5);