Skip to content

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

cleaned, finals, Properties

borg-030064acb46a91de
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index 9bc59d63e..254e8255e 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -61,26 +61,26 @@ import de.anomic.yacy.yacyVersion;
public final class hello {
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
- final serverObjects prop = new serverObjects(); // return variable that accumulates replacements
- if ((post == null) ||
- (env == null) ||
- (yacyCore.seedDB == null) ||
- (yacyCore.seedDB.mySeed == null)) { return new serverObjects(); }
-
- // final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
- // final String pattern = (String) post.get("pattern", ""); //
- // final String mytime = (String) post.get(STR_MYTIME, ""); //
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
+ if (post == null || ss == null || yacyCore.seedDB == null || yacyCore.seedDB.mySeed == null) { return new serverObjects(); }
+
+ // return variable that accumulates replacements
+ final serverObjects prop = new serverObjects();
+ if (prop == null) { return new serverObjects(); }
+
+// final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
+// final String pattern = (String) post.get("pattern", ""); //
+// final String mytime = (String) post.get(STR_MYTIME, ""); //
final String key = (String) post.get("key", ""); // transmission key for response
final String seed = (String) post.get(yacySeed.STR_SEED, ""); //
final String countStr = (String) post.get("count", "0"); //
int i;
int count = 0;
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}
- //final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(STR_MYTIME)); // read remote time
+// final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(STR_MYTIME)); // read remote time
final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key);
- //System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
+// System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
if (remoteSeed == null) { return new serverObjects(); }
// we easily know the caller's IP:
@@ -189,5 +189,4 @@ public final class hello {
return prop;
}
-}
-
+}
\ No newline at end of file
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index fe8b1dedd..5f991e387 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -1,55 +1,56 @@
-//message.java
-//-----------------------
-//part of the AnomicHTTPD caching proxy
-//(C) by Michael Peter Christen; [email protected]
-//first published on http://www.anomic.de
-//Frankfurt, Germany, 2004
-//last major change: 29.06.2003
+// message.java
+// -----------------------
+// part of the AnomicHTTPD caching proxy
+// (C) by Michael Peter Christen; [email protected]
+// first published on http://www.anomic.de
+// Frankfurt, Germany, 2004
//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-//GNU General Public License for more details.
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
//
-//Using this software in any meaning (reading, learning, copying, compiling,
-//running) means that you agree that the Author(s) is (are) not responsible
-//for cost, loss of data or any harm that may be caused directly or indirectly
-//by usage of this softare or this documentation. The usage of this software
-//is on your own risk. The installation and usage (starting/running) of this
-//software may allow other people or application to access your computer and
-//any attached devices and is highly dependent on the configuration of the
-//software which must be done by the user of the software; the author(s) is
-//(are) also not responsible for proper configuration and usage of the
-//software, even if provoked by documentation provided together with
-//the software.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-//Any changes to this file according to the GPL as documented in the file
-//gpl.txt aside this file in the shipment you received can be done to the
-//lines that follows this copyright notice here, but changes must not be
-//done inside the copyright notive above. A re-distribution must contain
-//the intact and unchanged copyright notice.
-//Contributions and changes to the program code must be marked as such.
-
+// Using this software in any meaning (reading, learning, copying, compiling,
+// running) means that you agree that the Author(s) is (are) not responsible
+// for cost, loss of data or any harm that may be caused directly or indirectly
+// by usage of this softare or this documentation. The usage of this software
+// is on your own risk. The installation and usage (starting/running) of this
+// software may allow other people or application to access your computer and
+// any attached devices and is highly dependent on the configuration of the
+// software which must be done by the user of the software; the author(s) is
+// (are) also not responsible for proper configuration and usage of the
+// software, even if provoked by documentation provided together with
+// the software.
+//
+// Any changes to this file according to the GPL as documented in the file
+// gpl.txt aside this file in the shipment you received can be done to the
+// lines that follows this copyright notice here, but changes must not be
+// done inside the copyright notive above. A re-distribution must contain
+// the intact and unchanged copyright notice.
+// Contributions and changes to the program code must be marked as such.
-//You must compile this file with
-//javac -classpath .:../../Classes message.java
-//if the shell's current path is HTROOT/yacy
+// You must compile this file with
+// javac -classpath .:../../classes message.java
+// if the shell's current path is HTROOT/yacy
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
-
import de.anomic.data.messageBoard;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
@@ -59,55 +60,54 @@ import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
-import de.anomic.yacy.yacySeedDB;
public final class message {
-
+
private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public static String dateString(Date date) {
return SimpleFormatter.format(date);
}
-
-
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
+
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
+ if (post == null || ss == null) { return new serverObjects(); }
+
// return variable that accumulates replacements
- plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
+ plasmaSwitchboard sb = (plasmaSwitchboard) ss;
serverObjects prop = new serverObjects();
-
- //System.out.println("yacy/message:post=" + post.toString());
-
- if ((post == null) || (env == null)) return new serverObjects();
-
+ if (prop == null || sb == null) { return new serverObjects(); }
+
+// System.out.println("yacy/message:post=" + post.toString());
+
String process = (String) post.get("process", "permission");
String key = (String) post.get("key", "");
-
+
int messagesize = 10240;
int attachmentsize = 0;
-
+
prop.put("messagesize", "0");
prop.put("attachmentsize", "0");
-
- //System.out.println("DEBUG yacy/message: message post values = " + post.toString());
-
+
+// System.out.println("DEBUG yacy/message: message post values = " + post.toString());
+
String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
// check if we are the right target and requester has correct information about this peer
if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
// this request has a wrong target
- //System.out.println("DEBUG yacy/message: authenticate failed");
+// System.out.println("DEBUG yacy/message: authenticate failed");
prop.put("response", "-1"); // request rejected
return prop;
}
-
+
prop.put("messagesize", Integer.toString(messagesize));
prop.put("attachmentsize", Integer.toString(attachmentsize));
-
+
if (process.equals("permission")) {
// permission: respond with accceptabeale message and attachment size
- String iam = (String) post.get("iam", ""); // seed hash of requester
+// String iam = (String) post.get("iam", ""); // seed hash of requester
prop.put("response", "Welcome to my peer!");
// that's it!
}
-
+
if (process.equals("post")) {
// post: post message to message board
String otherSeedString = (String) post.get("myseed", "");
@@ -117,57 +117,56 @@ public final class message {
}
//Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key);
-
+
String subject = crypt.simpleDecode((String) post.get("subject", ""), key); // message's subject
String message = crypt.simpleDecode((String) post.get("message", ""), key); // message body
-
+
prop.put("response", "Thank you!");
-
+
// save message
messageBoard.entry msgEntry = null;
- switchboard.messageDB.write(msgEntry = switchboard.messageDB.newEntry(
+ sb.messageDB.write(msgEntry = sb.messageDB.newEntry(
"remote",
otherSeed.get("Name", "anonymous"), otherSeed.hash,
yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,
subject, message.getBytes()));
-
- messageForwardingViaEmail(env,msgEntry);
-
+
+ messageForwardingViaEmail(ss, msgEntry);
+
// finally write notification
- File notifierSource = new File(switchboard.getRootPath(), switchboard.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
- File notifierDest = new File(switchboard.getRootPath(), switchboard.getConfig("htRootPath","htroot") + "/env/grafics/notifier.gif");
+ File notifierSource = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
+ File notifierDest = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/notifier.gif");
try {
serverFileUtils.copy(notifierSource, notifierDest);
} catch (IOException e) {
System.out.println("NEW MESSAGE ARRIVED! (error: " + e.getMessage() + ")");
};
}
- //System.out.println("respond = " + prop.toString());
-
+// System.out.println("respond = " + prop.toString());
+
// return rewrite properties
return prop;
}
-
-
+
/*
* To: #[to]#
From: #[from]#
Subject: #[subject]#
Date: #[date]#
-
+
#[message]#
*/
private static void messageForwardingViaEmail(serverSwitch env, messageBoard.entry msgEntry) {
try {
if (!Boolean.valueOf(env.getConfig("msgForwardingEnabled","false")).booleanValue()) return;
-
+
// getting the sendmail configuration
String sendMailStr = env.getConfig("msgForwardingCmd","/usr/bin/sendmail -t");
String[] sendMail = sendMailStr.trim().split(" ");
-
+
// getting the recipient address
String sendMailTo = env.getConfig("msgForwardingTo","root@localhost").trim();
-
+
// building the message text
StringBuffer emailTxt = new StringBuffer();
emailTxt.append("To: ")
@@ -192,7 +191,7 @@ public final class message {
.append(msgEntry.category())
.append("\n===================================================================\n")
.append(new String(msgEntry.message()));
-
+
Process process=Runtime.getRuntime().exec(sendMail);
PrintWriter email = new PrintWriter(process.getOutputStream());
email.print(emailTxt.toString());
@@ -200,35 +199,34 @@ public final class message {
} catch (Exception e) {
yacyCore.log.logWarning("message: message forwarding via email failed. ",e);
}
-
+
}
-
-
+
/*
on 83
DEBUG: message post values = {youare=Ty2F86ekSWM5, key=pPQSZaXD, iam=WSjicAx1hRio, process=permission}
von 93 wurde gesendet:
DEBUG: PUT BODY=------------1090394265522
Content-Disposition: form-data; name="youare"
-
+
Ty2F86ekSWM5
------------1090394265522
Content-Disposition: form-data; name="key"
-
+
pPQSZaXD
------------1090394265522
Content-Disposition: form-data; name="iam"
-
+
WSjicAx1hRio
------------1090394265522
Content-Disposition: form-data; name="process"
-
+
permission
------------1090394265522
-
-
+
+
on 93
DEBUG: message post values = {youare=WSjicAx1hRio, key=YJZLwaNS, iam=Ty2F86ekSWM5, process=permission}
-
+
*/
-}
+}
\ No newline at end of file
diff --git a/htroot/yacy/profile.java b/htroot/yacy/profile.java
index 2bba3d776..356514848 100644
--- a/htroot/yacy/profile.java
+++ b/htroot/yacy/profile.java
@@ -6,7 +6,10 @@
// Frankfurt, Germany, 2004, 2005
//
// This file ist contributed by Alexander Schier
-// last major change: 27.02.2005
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -58,37 +61,39 @@ import de.anomic.server.serverSwitch;
public final class profile {
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
- serverObjects prop = new serverObjects(); // return variable that accumulates replacements
- Properties profile = new Properties();
- int count=0;
- String key="";
- String value="";
-
- FileInputStream fileIn = null;
- try{
- fileIn = new FileInputStream(new File("DATA/SETTINGS/profile.txt"));
- profile.load(fileIn);
- }catch(IOException e){}
- finally {
- if (fileIn!=null) try{fileIn.close(); fileIn=null;}catch(Exception e) {}
- }
-
- Iterator it = ((Map)profile).keySet().iterator();
- while(it.hasNext()){
- key=(String)it.next();
- value=profile.getProperty(key, "").replaceAll("\r","").replaceAll("\n","\\\\n");
- if( !(key.equals("")) && !(value.equals("")) ){
- prop.put("list_"+count+"_key", key);
- prop.put("list_"+count+"_value", value);
- count++;
- }
- }
- prop.put("list", count);
-
-
- // return rewrite properties
- return prop;
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
+ // return variable that accumulates replacements
+ serverObjects prop = new serverObjects();
+ if (prop == null) { return new serverObjects(); }
+
+ Properties profile = new Properties();
+ int count=0;
+ String key="";
+ String value="";
+
+ FileInputStream fileIn = null;
+ try {
+ fileIn = new FileInputStream(new File("DATA/SETTINGS/profile.txt"));
+ profile.load(fileIn);
+ } catch(IOException e) {
+ } finally {
+ if (fileIn != null) try { fileIn.close(); fileIn = null; } catch (Exception e) {}
+ }
+
+ Iterator it = ((Map)profile).keySet().iterator();
+ while (it.hasNext()) {
+ key=(String)it.next();
+ value=profile.getProperty(key, "").replaceAll("\r","").replaceAll("\n","\\\\n");
+ if( !(key.equals("")) && !(value.equals("")) ){
+ prop.put("list_"+count+"_key", key);
+ prop.put("list_"+count+"_value", value);
+ count++;
+ }
+ }
+ prop.put("list", count);
+
+ // return rewrite properties
+ return prop;
}
-}
+}
\ No newline at end of file
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index d326b7345..5a0925946 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -1,10 +1,13 @@
-// query.java
+// query.java
// -----------------------
// part of the AnomicHTTPD caching proxy
// (C) by Michael Peter Christen; [email protected]
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
-// last change: 15.05.2004
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -40,12 +43,11 @@
// Contributions and changes to the program code must be marked as such.
// You must compile this file with
-// javac -classpath .:../../Classes query.java
+// javac -classpath .:../../classes query.java
// if the shell's current path is HTROOT
import java.util.Date;
import java.io.IOException;
-
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -54,93 +56,92 @@ import de.anomic.yacy.yacyCore;
public final class query {
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {
- // return variable that accumulates replacements
- serverObjects prop = new serverObjects();
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
+ if (post == null || ss == null) { return new serverObjects(); }
+
+ // return variable that accumulates replacements
+ final serverObjects prop = new serverObjects();
+ final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
+ if (prop == null || sb == null) { return new serverObjects(); }
- plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
- // System.out.println("YACYQUERY: RECEIVED POST = " + ((post == null) ? "NULL" : post.toString()));
+// System.out.println("YACYQUERY: RECEIVED POST = " + ((post == null) ? "NULL" : post.toString()));
- if ((post == null) || (switchboard == null)) return new serverObjects();
+// final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
+ final String youare = (String) post.get("youare", ""); // seed hash of the target peer, used for testing network stability
+// final String key = (String) post.get("key", ""); // transmission key for response
+ final String obj = (String) post.get("object", ""); // keyword for query subject
+ final String env = (String) post.get("env", ""); // argument to query
- String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
- String youare = (String) post.get("youare", ""); // seed hash of the target peer, used for testing network stability
- String key = (String) post.get("key", ""); // transmission key for response
- String obj = (String) post.get("object", ""); // keyword for query subject
- String env = (String) post.get("env", ""); // argument to query
-
prop.put("mytime", yacyCore.universalDateShortString(new Date()));
-
- // check if we are the right target and requester has correct information about this peer
- if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
- // this request has a wrong target
- prop.put("response", "-1"); // request rejected
- return prop;
- }
-
- // requests about environment
-
- if (obj.equals("rwiurlcount")) {
- // the total number of different urls in the rwi is returned
+
+ // check if we are the right target and requester has correct information about this peer
+ if (yacyCore.seedDB.mySeed == null || !yacyCore.seedDB.mySeed.hash.equals(youare)) {
+ // this request has a wrong target
+ prop.put("response", "-1"); // request rejected
+ return prop;
+ }
+
+ // requests about environment
+ if (obj.equals("rwiurlcount")) {
+ // the total number of different urls in the rwi is returned
// <env> shall contain a word hash, the number of assigned lurls to this hash is returned
de.anomic.plasma.plasmaWordIndexEntity entity = null;
try {
- entity = switchboard.wordIndex.getEntity(env, true);
+ entity = sb.wordIndex.getEntity(env, true);
prop.put("response", entity.size());
entity.close();
} catch (IOException e) {
prop.put("response", -1);
} finally {
- if (entity != null) try { entity.close(); } catch (Exception e) {}
+ if (entity != null) try { entity.close(); } catch (Exception e) {}
}
return prop;
- }
-
- if (obj.equals("rwicount")) {
- // return the total number of available word indexes
- prop.put("response", switchboard.wordIndex.size());
- return prop;
- }
-
- if (obj.equals("lurlcount")) {
- // return the number of all available l-url's
- prop.put("response", switchboard.urlPool.loadedURL.size());
- return prop;
- }
-
- // requests about requirements
-
- if (obj.equals("wantedlurls")) {
- prop.put("response", "0"); // dummy response
- return prop;
- }
-
- if (obj.equals("wantedpurls")) {
- prop.put("response", "0"); // dummy response
- return prop;
- }
-
- if (obj.equals("wantedword")) {
- // response returns a list of wanted word hashes
- prop.put("response", "0"); // dummy response
- return prop;
- }
-
- if (obj.equals("wantedrwi")) {
- // <env> shall contain a word hash, the number of wanted lurls for this hash is returned
- prop.put("response", "0"); // dummy response
- return prop;
- }
-
- if (obj.equals("wantedseeds")) {
- // return a number of wanted seed
- prop.put("response", "0"); // dummy response
- return prop;
- }
-
-
- // return rewrite properties
- return prop;
+ }
+
+ if (obj.equals("rwicount")) {
+ // return the total number of available word indexes
+ prop.put("response", sb.wordIndex.size());
+ return prop;
+ }
+
+ if (obj.equals("lurlcount")) {
+ // return the number of all available l-url's
+ prop.put("response", sb.urlPool.loadedURL.size());
+ return prop;
+ }
+
+ // requests about requirements
+
+ if (obj.equals("wantedlurls")) {
+ prop.put("response", "0"); // dummy response
+ return prop;
+ }
+
+ if (obj.equals("wantedpurls")) {
+ prop.put("response", "0"); // dummy response
+ return prop;
+ }
+
+ if (obj.equals("wantedword")) {
+ // response returns a list of wanted word hashes
+ prop.put("response", "0"); // dummy response
+ return prop;
+ }
+
+ if (obj.equals("wantedrwi")) {
+ // <env> shall contain a word hash, the number of wanted lurls for this hash is returned
+ prop.put("response", "0"); // dummy response
+ return prop;
+ }
+
+ if (obj.equals("wantedseeds")) {
+ // return a number of wanted seed
+ prop.put("response", "0"); // dummy response
+ return prop;
+ }
+
+ // return rewrite properties
+ return prop;
}
-}
+}
\ No newline at end of file
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index afcecaadb..59726ea35 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -1,10 +1,13 @@
-// transferURL.java
+// transferURL.java
// -----------------------
// part of the AnomicHTTPD caching proxy
// (C) by Michael Peter Christen; [email protected]
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004, 2005
-// last change: 24.01.2005
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -42,7 +45,6 @@
// You must compile this file with
// javac -classpath .:../classes transferRWI.java
-
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaCrawlLURL;
@@ -53,33 +55,33 @@ import de.anomic.yacy.yacySeed;
public final class transferURL {
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
- long start = System.currentTimeMillis();
-
- // return variable that accumulates replacements
- plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
- serverObjects prop = new serverObjects();
-
- if ((post == null) || (env == null)) return prop;
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
+ if (post == null || ss == null) { return new serverObjects(); }
+ long start = System.currentTimeMillis();
- // request values
- String iam = (String) post.get("iam", ""); // seed hash of requester
- String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
- String key = (String) post.get("key", ""); // transmission key
- int urlc = Integer.parseInt((String) post.get("urlc", "")); // number of transported urls
- boolean granted = switchboard.getConfig("allowReceiveIndex", "false").equals("true");
- boolean blockBlacklist = switchboard.getConfig("indexReceiveBlockBlacklist", "false").equals("true");
+ // return variable that accumulates replacements
+ final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
+ final serverObjects prop = new serverObjects();
+ if (prop == null || sb == null) { return new serverObjects(); }
+
+ // request values
+ final String iam = (String) post.get("iam", ""); // seed hash of requester
+// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
+// final String key = (String) post.get("key", ""); // transmission key
+ final int urlc = Integer.parseInt((String) post.get("urlc", "")); // number of transported urls
+ final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
+ final boolean blockBlacklist = sb.getConfig("indexReceiveBlockBlacklist", "false").equals("true");
// response values
String result = "";
String doublevalues = "0";
-
- yacySeed otherPeer = yacyCore.seedDB.get(iam);
- String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
-
+
+ final yacySeed otherPeer = yacyCore.seedDB.get(iam);
+ final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
+
if (granted) {
int received = 0;
- int sizeBefore = switchboard.urlPool.loadedURL.size();
+ final int sizeBefore = sb.urlPool.loadedURL.size();
// read the urls from the other properties and store
String urls;
plasmaCrawlLURL.Entry lEntry;
@@ -88,38 +90,36 @@ public final class transferURL {
if (urls == null) {
yacyCore.log.logFine("transferURL: got null URL-string from peer " + otherPeerName);
} else {
- lEntry = switchboard.urlPool.loadedURL.newEntry(urls, true);
- if ((lEntry != null) && (blockBlacklist)) {
- if (plasmaSwitchboard.urlBlacklist.isListed(lEntry.url().getHost().toLowerCase(), lEntry.url().getPath())) {
- yacyCore.log.logFine("transferURL: blocked blacklisted URL '" + lEntry.url() + "' from peer " + otherPeerName);
- lEntry = null;
- }
+ lEntry = sb.urlPool.loadedURL.newEntry(urls, true);
+ if (lEntry != null && blockBlacklist &&
+ sb.urlBlacklist.isListed(lEntry.url().getHost().toLowerCase(), lEntry.url().getPath())) {
+ yacyCore.log.logFine("transferURL: blocked blacklisted URL '" + lEntry.url() + "' from peer " + otherPeerName);
+ lEntry = null;
}
if (lEntry != null) {
- switchboard.urlPool.loadedURL.addEntry(lEntry, iam, iam, 3);
+ sb.urlPool.loadedURL.addEntry(lEntry, iam, iam, 3);
yacyCore.log.logFine("transferURL: received URL '" + lEntry.url() + "' from peer " + otherPeerName);
received++;
}
}
}
-
+
yacyCore.seedDB.mySeed.incRU(received);
-
+
// return rewrite properties
- int more = switchboard.urlPool.loadedURL.size() - sizeBefore;
+ final int more = sb.urlPool.loadedURL.size() - sizeBefore;
doublevalues = Integer.toString(received - more);
- switchboard.getLog().logInfo("Received " + received + " URLs from peer " + otherPeerName +
- " in " + (System.currentTimeMillis() - start) + " ms.");
- if ((received - more) > 0) switchboard.getLog().logSevere("Received " + doublevalues + " double URLs from peer " + otherPeerName);
+ sb.getLog().logInfo("Received " + received + " URLs from peer " + otherPeerName + " in " + (System.currentTimeMillis() - start) + " ms.");
+ if ((received - more) > 0) sb.getLog().logSevere("Received " + doublevalues + " double URLs from peer " + otherPeerName);
result = "ok";
} else {
- switchboard.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Not granted.");
+ sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Not granted.");
result = "error_not_granted";
}
-
+
prop.put("double", doublevalues);
prop.put("result", result);
- return prop;
+ return prop;
}
-}
+}
\ No newline at end of file