Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) shrinking httpc linebuffer when httpc is returned to pool. This is done to free memory *) Making Seed-Upload configuration more verbose. *) Some Changes in SOAP Search API (not finished yet).
theli0e1d9e972210
diff --git a/htroot/SettingsAck_p.html b/htroot/SettingsAck_p.htmlindex c0ac16f1f..fbaf69bcb 100644--- a/htroot/SettingsAck_p.html+++ b/htroot/SettingsAck_p.html@@ -55,6 +55,7 @@ You are now permanently <b>online</b>. After a short while you should see the ef<b>Seed Settings changed.#(success)#::You are now a principal peer.#(/success)#</b><br>::<p><b>Seed Settings changed, but something is wrong.</b></p>+<p><font color="red">#[errormsg]#</font></p>Seed Uploading was deactivated automatically.Please return to the settings page and modify the data.<br>::diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex 45c6b54a4..896a01e4d 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -275,16 +275,14 @@ public class SettingsAck_p {env.setConfig("seedUploadMethod", newSeedUploadMethod);env.setConfig("seedURL", newSeedURLStr);- boolean success = yacyCore.saveSeedList(env);- if (!success) {- prop.put("info", 14);- env.setConfig("seedUploadMethod","none");- } else {- prop.put("info_seedUploadMethod",newSeedUploadMethod);- prop.put("info_seedURL",newSeedURLStr);- prop.put("info_success",(newSeedUploadMethod.equalsIgnoreCase("none")?0:1));- prop.put("info", 19);- }+ // trying to upload the seed-list file+ yacyCore.saveSeedList(env);++ // we have successfully uploaded the seed-list file+ prop.put("info_seedUploadMethod",newSeedUploadMethod);+ prop.put("info_seedURL",newSeedURLStr);+ prop.put("info_success",(newSeedUploadMethod.equalsIgnoreCase("none")?0:1));+ prop.put("info", 19);} else {prop.put("info_seedUploadMethod",newSeedUploadMethod);prop.put("info_seedURL",newSeedURLStr);@@ -294,6 +292,8 @@ public class SettingsAck_p {}} catch (Exception e) {prop.put("info",14);+ prop.put("info_errormsg",e.getMessage().replaceAll("\n","<br>"));+ env.setConfig("seedUploadMethod","none");}return prop;}@@ -308,6 +308,7 @@ public class SettingsAck_p {// getting the uploader module nameString uploaderName = (String) uploaderKeys.nextElement();+// determining if the user has reconfigured the settings of this uploaderif (post.containsKey("seed" + uploaderName + "Settings")) {nothingChanged = true;@@ -324,15 +325,21 @@ public class SettingsAck_p {}}if (!nothingChanged) {- if (env.getConfig("seedUploadMethod","none").equals(theUploader)) {- boolean success = yacyCore.saveSeedList(env);- if (!success) {- prop.put("info", 14);- env.setConfig("seedUploadMethod","none");- } else {+ // if the seed upload method is equal to the seed uploader whose settings+ // were changed, we now try to upload the seed list with the new settings+ if (env.getConfig("seedUploadMethod","none").equalsIgnoreCase(uploaderName)) {+ try {+ yacyCore.saveSeedList(env);++ // we have successfully uploaded the seed fileprop.put("info", 13);prop.put("info_success",1);- }+ } catch (Exception e) {+ // if uploading failed we print out an error message+ prop.put("info", 14);+ prop.put("info_errormsg",e.getMessage().replaceAll("\n","<br>"));+ env.setConfig("seedUploadMethod","none");+ }} else {prop.put("info", 13);prop.put("info_success",0);diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.javaindex 22a26aceb..65c2d559e 100644--- a/source/de/anomic/http/httpc.java+++ b/source/de/anomic/http/httpc.java@@ -285,6 +285,10 @@ public final class httpc {this.remoteProxyUse = false;this.savedRemoteHost = null;this.requestPath = null;+++ // shrink readlinebuffer if it is to large+ this.readLineBuffer.reset(80);} catch (Exception e) {// we could ignore this ...}@@ -303,31 +307,32 @@ public final class httpc {void init(String server, int port, int timeout, boolean ssl) throws IOException {handle = System.currentTimeMillis();//serverLog.logDebug("HTTPC", handle + " initialized");- this.remoteProxyUse = false;- this.timeout = timeout;- this.savedRemoteHost = server;- try {- this.host = server + ((port == 80) ? "" : (":" + port));- String hostip;- if ((server.equals("localhost")) || (server.equals("127.0.0.1")) || (server.startsWith("192.168.")) || (server.startsWith("10."))) {+ this.remoteProxyUse = false;+ this.timeout = timeout;+ this.savedRemoteHost = server;++ try {+ this.host = server + ((port == 80) ? "" : (":" + port));+ String hostip;+ if ((server.equals("localhost")) || (server.equals("127.0.0.1")) || (server.startsWith("192.168.")) || (server.startsWith("10."))) {hostip = server;- } else {- hostip = dnsResolve(server);- if (hostip == null) throw new UnknownHostException(server);- }- if (ssl)- socket = SSLSocketFactory.getDefault().createSocket(hostip, port);- else- socket = new Socket(hostip, port);- socket.setSoTimeout(timeout); // waiting time for write- //socket.setSoLinger(true, timeout); // waiting time for read- socket.setKeepAlive(true); //- clientInput = new PushbackInputStream(socket.getInputStream());- clientOutput = socket.getOutputStream();- // if we reached this point, we should have a connection- } catch (UnknownHostException e) {- throw new IOException("unknown host: " + server);- }+ } else {+ hostip = dnsResolve(server);+ if (hostip == null) throw new UnknownHostException(server);+ }+ if (ssl)+ socket = SSLSocketFactory.getDefault().createSocket(hostip, port);+ else+ socket = new Socket(hostip, port);+ socket.setSoTimeout(timeout); // waiting time for write+ //socket.setSoLinger(true, timeout); // waiting time for read+ socket.setKeepAlive(true); //+ clientInput = new PushbackInputStream(socket.getInputStream());+ clientOutput = socket.getOutputStream();+ // if we reached this point, we should have a connection+ } catch (UnknownHostException e) {+ throw new IOException("unknown host: " + server);+ }}// provide HTTP date handling static methodsdiff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.javaindex d10719b7f..c5889e1af 100644--- a/source/de/anomic/http/httpd.java+++ b/source/de/anomic/http/httpd.java@@ -52,6 +52,7 @@ package de.anomic.http;import java.io.IOException;import java.io.InputStream;import java.io.PushbackInputStream;+import java.lang.reflect.Constructor;import java.net.InetAddress;import java.net.NetworkInterface;import java.util.Arrays;@@ -262,7 +263,9 @@ public final class httpd implements serverHandler {if (this.prop.containsKey("PATH") && this.prop.getProperty("PATH").startsWith("/soap")) {if (soapHandler == null) {try {- soapHandler = (httpdHandler) Class.forName("de.anomic.soap.httpdSoapHandler").newInstance();+ Class soapHandlerClass = Class.forName("de.anomic.soap.httpdSoapHandler");+ Constructor classConstructor = soapHandlerClass.getConstructor( new Class[] { serverSwitch.class } );+ soapHandler = (httpdHandler) classConstructor.newInstance(new Object[] { this.switchboard });} catch (Exception e) {throw new IOException("Unable to load the soap handler");}diff --git a/source/de/anomic/http/httpdHandler.java b/source/de/anomic/http/httpdHandler.javaindex 968a25d6b..5995ec607 100644--- a/source/de/anomic/http/httpdHandler.java+++ b/source/de/anomic/http/httpdHandler.java@@ -57,6 +57,8 @@ import java.io.OutputStream;import java.io.PushbackInputStream;import java.util.Properties;+import de.anomic.server.serverSwitch;+public interface httpdHandler {void doGet(Properties conProp, httpHeader header, OutputStream response) throws IOException;diff --git a/source/de/anomic/server/serverByteBuffer.java b/source/de/anomic/server/serverByteBuffer.javaindex 6d5488385..450fd34ab 100644--- a/source/de/anomic/server/serverByteBuffer.java+++ b/source/de/anomic/server/serverByteBuffer.java@@ -307,6 +307,18 @@ public final class serverByteBuffer extends OutputStream {this.offset = 0;}+ public void reset(int newSize) {+ this.resize(newSize);+ this.reset();+ }++ public void resize(int newSize) {+ if(newSize < 0) throw new IllegalArgumentException("Illegal array size: " + newSize);+ byte[] v = new byte[newSize];+ System.arraycopy(this.buffer,0,v,0,newSize > this.buffer.length ? this.buffer.length : newSize);+ this.buffer = v;+ }+public byte toByteArray()[] {byte newbuf[] = new byte[this.length];System.arraycopy(this.buffer, 0, newbuf, 0, this.length);diff --git a/source/de/anomic/soap/httpdSoapHandler.java b/source/de/anomic/soap/httpdSoapHandler.javaindex aba633c47..4f4307e9d 100644--- a/source/de/anomic/soap/httpdSoapHandler.java+++ b/source/de/anomic/soap/httpdSoapHandler.java@@ -60,7 +60,7 @@ import de.anomic.server.serverSwitch;** @author Martin Thelian*/-final class httpdSoapHandler extends httpdAbstractHandler implements httpdHandler+public final class httpdSoapHandler extends httpdAbstractHandler implements httpdHandler{/* ===============================================================@@ -431,7 +431,7 @@ final class httpdSoapHandler extends httpdAbstractHandler implements httpdHandlemsgContext.setProperty(Constants.MC_RELATIVE_PATH, path.toString());msgContext.setProperty(Constants.MC_JWS_CLASSDIR, "jwsClasses");msgContext.setProperty(Constants.MC_HOME_DIR, ".");- msgContext.setProperty(MessageContext.TRANS_URL, "http://" + requestHeader.get("Host") + this.switchboard.getConfig("port","8080") + "/soap/index");+ msgContext.setProperty(MessageContext.TRANS_URL, "http://" + requestHeader.get("Host") + ((((String)requestHeader.get("Host")).indexOf(":") > -1)?"":this.switchboard.getConfig("port","8080")) + "/soap/index");msgContext.setProperty(MESSAGE_CONTEXT_HTTP_ROOT_PATH ,this.htRootPath.toString());msgContext.setProperty(MESSAGE_CONTEXT_SERVER_SWITCH,this.switchboard);diff --git a/source/de/anomic/soap/httpdSoapService.java b/source/de/anomic/soap/httpdSoapService.javaindex 4068486da..0037443e5 100644--- a/source/de/anomic/soap/httpdSoapService.java+++ b/source/de/anomic/soap/httpdSoapService.java@@ -4,21 +4,26 @@ import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.IOException;+import java.io.StringReader;import java.lang.reflect.Method;import java.util.Arrays;import java.util.HashMap;import java.util.HashSet;+import javax.xml.parsers.DocumentBuilder;+import javax.xml.parsers.DocumentBuilderFactory;+import org.apache.axis.AxisFault;import org.apache.axis.Message;import org.apache.axis.MessageContext;import org.apache.axis.message.SOAPEnvelope;import org.apache.axis.message.SOAPHeaderElement;+import org.w3c.dom.Document;+import org.xml.sax.InputSource;import de.anomic.http.httpHeader;import de.anomic.http.httpTemplate;import de.anomic.server.serverClassLoader;-import de.anomic.server.serverCodings;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -27,7 +32,7 @@ import de.anomic.server.serverSwitch;** @author Martin Thelian*/-final public class httpdSoapService+public class httpdSoapService{/* ================================================================* Constants needed to set the template that should be used to@@ -36,7 +41,7 @@ final public class httpdSoapService/*** Constant: template for searching*/- private static final String TEMPLATE_SEARCH = "index.rss";+ private static final String TEMPLATE_SEARCH = "index.soap";/*** Constant: template for the network status page*/@@ -81,7 +86,14 @@ final public class httpdSoapService** @throws AxisFault if the service could not be executed propery.*/- public String search(String searchString)+ public Document search(+ String searchString,+ String searchMode,+ String searchOrder,+ int maxSearchCount,+ int maxSearchTime,+ String urlMaskFilter+ )throws AxisFault{try@@ -89,14 +101,20 @@ final public class httpdSoapService// extracting the message contextextractMessageContext();+ if ((searchMode == null) || !(searchMode.equalsIgnoreCase("global") || searchMode.equalsIgnoreCase("locale"))) {+ searchMode = "global";+ }++ if (urlMaskFilter == null) urlMaskFilter = ".*";+// setting the searching propertiesserverObjects args = new serverObjects();args.put("order","Quality-Date");args.put("Enter","Search");- args.put("count","10");+ args.put("count",Integer.toString(maxSearchCount));args.put("resource","global");- args.put("time","10");- args.put("urlmaskfilter",".*");+ args.put("time",Integer.toString(maxSearchTime));+ args.put("urlmaskfilter",urlMaskFilter);args.put("search",searchString);@@ -104,7 +122,7 @@ final public class httpdSoapServiceString result = writeTemplate(TEMPLATE_SEARCH, args);// sending back the result to the client- return result;+ return this.convertContentToXML(result);}catch (Exception e){@@ -336,4 +354,25 @@ final public class httpdSoapServicereturn m;}+ private Document convertContentToXML(String contentString)+ throws Exception+ {+ Document doc = null;+ try+ {+ DocumentBuilderFactory newDocBuilderFactory = DocumentBuilderFactory.newInstance();+ DocumentBuilder newDocBuilder = newDocBuilderFactory.newDocumentBuilder();++ InputSource is = new InputSource(new StringReader(contentString));+ doc = newDocBuilder.parse(is);+ }+ catch (Exception e)+ {+ String errorMessage = "Unable to parse the search result XML data. " + e.getClass().getName() + ". " + e.getMessage();+ throw new Exception(errorMessage);+ }++ return doc;+ }+}diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.javaindex b63de716c..a128ba26f 100644--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadFile.java@@ -12,19 +12,19 @@ public class yacySeedUploadFile implements yacySeedUploader {public static final String CONFIG_FILE_PATH = "seedFilePath";- public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile) {+ public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile) throws Exception {- String logt;+ String logt, seedFilePath = "";try {- String seedFilePath = sb.getConfig(CONFIG_FILE_PATH,null);- if (seedFilePath == null) return "Error: Path to seed file is not configured properly";+ seedFilePath = sb.getConfig(CONFIG_FILE_PATH,"");+ if (seedFilePath.length() == 0) throw new Exception("Path to seed file is not configured properly");File publicSeedFile = new File(seedFilePath);serverFileUtils.copy(seedFile,publicSeedFile);return "Seed-List file stored successfully";} catch (Exception e) {- return "Error: " + e.getMessage();+ throw new Exception("Unable to store the seed-list file into the filesystem using path '" + seedFilePath + "'. " + e.getMessage());}}diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.javaindex c662dc027..5cf04cedd 100644--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java@@ -18,13 +18,13 @@ import de.anomic.yacy.yacySeedDB;import de.anomic.yacy.yacySeedUploader;public class yacySeedUploadScp implements yacySeedUploader {-+public static final String CONFIG_SCP_SERVER = "seedScpServer";public static final String CONFIG_SCP_ACCOUNT = "seedScpAccount";public static final String CONFIG_SCP_PASSWORD = "seedScpPassword";public static final String CONFIG_SCP_PATH = "seedScpPath";- public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile) {+ public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile) throws Exception {try {if (sb == null) throw new NullPointerException("Reference to serverSwitch nut not be null.");if (seedDB == null) throw new NullPointerException("Reference to seedDB must not be null.");@@ -34,112 +34,107 @@ public class yacySeedUploadScp implements yacySeedUploader {String seedScpAccount = sb.getConfig(CONFIG_SCP_ACCOUNT,null);String seedScpPassword = sb.getConfig(CONFIG_SCP_PASSWORD,null);String seedScpPath = sb.getConfig(CONFIG_SCP_PATH,null);-+if ((seedScpServer != null) && (seedScpAccount != null) && (seedScpPassword != null) && (seedScpPath != null)) {- String log = sshc.put(seedScpServer, seedFile, seedScpPath, seedScpAccount, seedScpPassword);- return "Seed file uploaded successfully using scp. " + log;+ return sshc.put(seedScpServer, seedFile, seedScpPath, seedScpAccount, seedScpPassword);}return "Seed upload settings not configured properly. password-len=" +seedScpPassword.length() + ", filePath=" +seedScpPath;} catch (Exception e) {- return "Error: " + e.getMessage();+ throw e;}}-+public String[] getConfigurationOptions() {return new String[] {CONFIG_SCP_SERVER,CONFIG_SCP_ACCOUNT,CONFIG_SCP_PASSWORD,CONFIG_SCP_PATH};}-+public String[] getLibxDependences() {return new String[]{"jsch-0.1.19.jar"};}-+}class sshc {public static String put(String host,- File localFile, String remoteName,- String account, String password) {-- Session session = null;- try {- // Creating a new secure channel object- JSch jsch=new JSch();-- // setting hostname, username, userpassword- session = jsch.getSession(account, host, 22);- session.setPassword(password);-- /*- * Setting the StrictHostKeyChecking to ignore unknown- * hosts because of a missing known_hosts file ...- */- java.util.Properties config = new java.util.Properties();- config.put("StrictHostKeyChecking","no");- session.setConfig(config);-- /*- * we need this user interaction interface to support- * the interactive-keyboard mode- */- UserInfo ui=new SchUserInfo(password);- session.setUserInfo(ui);+ File localFile, String remoteName,+ String account, String password) throws Exception {- // trying to connect ...- session.connect();-- String command="scp -p -t " + remoteName;- Channel channel = session.openChannel("exec");- ((ChannelExec)channel).setCommand(command);-- // get I/O streams for remote scp- OutputStream out=channel.getOutputStream();- InputStream in=channel.getInputStream();-- channel.connect();-- byte[] tmp=new byte[1];- checkAck(in);-- // send "C0644 filesize filename", where filename should not include '/'- int filesize=(int)(localFile).length();- command="C0644 "+filesize+" ";- if(localFile.toString().lastIndexOf('/')>0){- command+=localFile.toString().substring(localFile.toString().lastIndexOf('/')+1);- }- else{- command+=localFile.toString();- }- command+="\n";- out.write(command.getBytes()); out.flush();-- checkAck(in);-- // send a content of lfile- FileInputStream fis=new FileInputStream(localFile);- byte[] buf=new byte[1024];- while(true){- int len=fis.read(buf, 0, buf.length);- if(len<=0) break;- out.write(buf, 0, len); out.flush();+ Session session = null;+ try {+ // Creating a new secure channel object+ JSch jsch=new JSch();++ // setting hostname, username, userpassword+ session = jsch.getSession(account, host, 22);+ session.setPassword(password);++ /*+ * Setting the StrictHostKeyChecking to ignore unknown+ * hosts because of a missing known_hosts file ...+ */+ java.util.Properties config = new java.util.Properties();+ config.put("StrictHostKeyChecking","no");+ session.setConfig(config);++ /*+ * we need this user interaction interface to support+ * the interactive-keyboard mode+ */+ UserInfo ui=new SchUserInfo(password);+ session.setUserInfo(ui);++ // trying to connect ...+ session.connect();++ String command="scp -p -t " + remoteName;+ Channel channel = session.openChannel("exec");+ ((ChannelExec)channel).setCommand(command);++ // get I/O streams for remote scp+ OutputStream out=channel.getOutputStream();+ InputStream in=channel.getInputStream();++ channel.connect();++ byte[] tmp=new byte[1];+ checkAck(in);++ // send "C0644 filesize filename", where filename should not include '/'+ int filesize=(int)(localFile).length();+ command="C0644 "+filesize+" ";+ if(localFile.toString().lastIndexOf('/')>0){+ command+=localFile.toString().substring(localFile.toString().lastIndexOf('/')+1);+ }+ else{+ command+=localFile.toString();+ }+ command+="\n";+ out.write(command.getBytes()); out.flush();++ checkAck(in);++ // send a content of lfile+ FileInputStream fis=new FileInputStream(localFile);+ byte[] buf=new byte[1024];+ while(true){+ int len=fis.read(buf, 0, buf.length);+ if(len<=0) break;+ out.write(buf, 0, len); out.flush();+ }++ // send '\0'+ buf[0]=0; out.write(buf, 0, 1); out.flush();++ checkAck(in);++ return "SCP: File uploaded successfully.";+ } catch (Exception e) {+ throw new Exception("SCP: File uploading failed: " + e.getMessage());+ } finally {+ if ((session != null) && (session.isConnected())) session.disconnect();}-- // send '\0'- buf[0]=0; out.write(buf, 0, 1); out.flush();-- checkAck(in);-- return "";- } catch (Exception e) {- System.out.println("ERROR: scp put failed:" + e.getMessage());- e.printStackTrace();- return "";- } finally- {- if ((session != null) && (session.isConnected()))- session.disconnect();- }}static int checkAck(InputStream in) throws IOException{@@ -150,25 +145,25 @@ class sshc {// -1if(b==0) return b;if(b==-1) return b;-+if(b==1 || b==2){- StringBuffer sb=new StringBuffer();- int c;- do {- c=in.read();- sb.append((char)c);- }- while(c!='\n');-- if(b==1){ // error- throw new IOException(sb.toString());- }- if(b==2){ // fatal error- throw new IOException(sb.toString());- }+ StringBuffer sb=new StringBuffer();+ int c;+ do {+ c=in.read();+ sb.append((char)c);+ }+ while(c!='\n');++ if(b==1){ // error+ throw new IOException(sb.toString());+ }+ if(b==2){ // fatal error+ throw new IOException(sb.toString());+ }}return b;- }+ }}@@ -180,75 +175,75 @@ implements UserInfo, UIKeyboardInteractive {this.passwd = password;}- public String getPassword() {- return this.passwd;- }-- public boolean promptYesNo(String str){- System.err.println("User was prompted from: " + str);- return true;- }-- public String getPassphrase() {- return null;- }-- public boolean promptPassphrase(String message) {- System.out.println("promptPassphrase : " + message);- return false;- }-- public boolean promptPassword(String message) {- System.out.println("promptPassword : " + message);- return true;- }-- /**- * @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String)- */- public void showMessage(String message) {- System.out.println("Sch has tried to show the following message to the user: " + message);- }-- public String[] promptKeyboardInteractive(String destination,- String name,- String instruction,- String[] prompt,- boolean[] echo) {- System.out.println("User was prompted using interactive-keyboard: " +- "\n\tDestination: " + destination +- "\n\tName: " + name +- "\n\tInstruction: " + instruction +- "\n\tPrompt: " + arrayToString2(prompt,"|") +- "\n\techo: " + arrayToString2(echo,"|"));-- if ((prompt.length >= 1) && (prompt[0].startsWith("Password")))- return new String[]{this.passwd};+ public String getPassword() {+ return this.passwd;+ }++ public boolean promptYesNo(String str){+ System.err.println("User was prompted from: " + str);+ return true;+ }++ public String getPassphrase() {+ return null;+ }++ public boolean promptPassphrase(String message) {+ System.out.println("promptPassphrase : " + message);+ return false;+ }++ public boolean promptPassword(String message) {+ System.out.println("promptPassword : " + message);+ return true;+ }++ /**+ * @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String)+ */+ public void showMessage(String message) {+ System.out.println("Sch has tried to show the following message to the user: " + message);+ }++ public String[] promptKeyboardInteractive(String destination,+ String name,+ String instruction,+ String[] prompt,+ boolean[] echo) {+ System.out.println("User was prompted using interactive-keyboard: " ++ "\n\tDestination: " + destination ++ "\n\tName: " + name ++ "\n\tInstruction: " + instruction ++ "\n\tPrompt: " + arrayToString2(prompt,"|") ++ "\n\techo: " + arrayToString2(echo,"|"));++ if ((prompt.length >= 1) && (prompt[0].startsWith("Password")))+ return new String[]{this.passwd};return new String[]{};- }-- String arrayToString2(String[] a, String separator) {- StringBuffer result = new StringBuffer();// start with first element- if (a.length > 0) {- result.append(a[0]);- for (int i=1; i<a.length; i++) {- result.append(separator);- result.append(a[i]);- }- }- return result.toString();-}-- String arrayToString2(boolean[] a, String separator) {- StringBuffer result = new StringBuffer();// start with first element- if (a.length > 0) {- result.append(a[0]);- for (int i=1; i<a.length; i++) {- result.append(separator);- result.append(a[i]);- }- }- return result.toString();-}+ }++ String arrayToString2(String[] a, String separator) {+ StringBuffer result = new StringBuffer();// start with first element+ if (a.length > 0) {+ result.append(a[0]);+ for (int i=1; i<a.length; i++) {+ result.append(separator);+ result.append(a[i]);+ }+ }+ return result.toString();+ }++ String arrayToString2(boolean[] a, String separator) {+ StringBuffer result = new StringBuffer();// start with first element+ if (a.length > 0) {+ result.append(a[0]);+ for (int i=1; i<a.length; i++) {+ result.append(separator);+ result.append(a[i]);+ }+ }+ return result.toString();+ }}diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex b8537f31d..05a4bd670 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -483,14 +483,22 @@ public class yacyCore {}public boolean saveSeedList() {- return saveSeedList(this.switchboard);+ try {+ saveSeedList(this.switchboard);+ return true;+ } catch (Exception e) {+ return false;+ }}- public static boolean saveSeedList(serverSwitch sb) {+ public static void saveSeedList(serverSwitch sb)+ throws Exception {String logt;// be shure that we have something to say- if (seedDB.mySeed.getAddress() == null) return false;+ if (seedDB.mySeed.getAddress() == null) {+ throw new Exception ("We have no valid IP address until now");+ }// getting the configured seed uploaderString seedUploadMethod = sb.getConfig("seedUploadMethod","");@@ -505,17 +513,22 @@ public class yacyCore {}// determine the seed uploader that should be used ...- if (seedUploadMethod.equalsIgnoreCase("none")) return true;+ if (seedUploadMethod.equalsIgnoreCase("none")) return;yacySeedUploader uploader = getSeedUploader(seedUploadMethod);- if (uploader == null) return false;+ if (uploader == null) {+ throw new Exception("Unable to get the proper uploader-class for seed uploading method '" + seedUploadMethod + "'.");+ }// ensure that the seed file url is configured properlyURL seedURL;try{- seedURL = new URL(sb.getConfig("seedURL",""));+ String seedURLStr = sb.getConfig("seedURL","");+ if (seedURLStr.length() == 0) throw new MalformedURLException("The seed-file url must not be empty.");+ if (!seedURLStr.toLowerCase().startsWith("http://")) throw new MalformedURLException("Unsupported protocol.");+ seedURL = new URL(seedURLStr);}catch(MalformedURLException e){- return false;+ throw new Exception("Malformed seed file URL '" + sb.getConfig("seedURL","") + "'. " + e.getMessage());}// upload the seed-list using the configured uploader class@@ -531,19 +544,19 @@ public class yacyCore {if (logt.indexOf("Error") >= 0) {seedDB.mySeed.put("PeerType", prevStatus);log.logError("seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6));- return false;+ throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + logt.substring(logt.indexOf("Error") + 6));}log.logInfo(logt);}// finally, set the principal statussb.setConfig("yacyStatus","principal");- return true;+ return;} catch (Exception e) {seedDB.mySeed.put("PeerType", prevStatus);sb.setConfig("yacyStatus", prevStatus);- log.logInfo("seed upload failed (IO error): " + e.getMessage());- return false;+ log.logInfo("Seed upload failed (IO error): " + e.getMessage());+ throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + e.getMessage());}}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex f05dbf402..f50b2a082 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -514,13 +514,13 @@ public class yacySeedDB {}public String uploadCache(yacySeedUploader uploader,- serverSwitch sb,- yacySeedDB seedDB,-// String seedFTPServer,-// String seedFTPAccount,-// String seedFTPPassword,-// File seedFTPPath,- URL seedURL) throws IOException {+ serverSwitch sb,+ yacySeedDB seedDB,+// String seedFTPServer,+// String seedFTPAccount,+// String seedFTPPassword,+// File seedFTPPath,+ URL seedURL) throws Exception {// upload a seed file, if possibleif (seedURL == null) throw new NullPointerException("UPLOAD - Error: URL not given");@@ -538,10 +538,9 @@ public class yacySeedDB {// check also if the result can be retrieved againif (checkCache(uv, seedURL))log = log + "UPLOAD CHECK - Success: the result vectors are equal" + serverCore.crlfString;- else- log = log + "UPLOAD CHECK - Error: the result vector is different" + serverCore.crlfString;- } catch (IOException e) {- log = log + "UPLOAD CHECK - Error: IO problem " + e.getMessage() + serverCore.crlfString;+ else {+ throw new Exception("UPLOAD CHECK - Error: the result vector is different" + serverCore.crlfString);+ }} finally {if (seedFile != null) seedFile.delete();}diff --git a/source/de/anomic/yacy/yacySeedUploader.java b/source/de/anomic/yacy/yacySeedUploader.javaindex a1fa3802c..566eaacf7 100644--- a/source/de/anomic/yacy/yacySeedUploader.java+++ b/source/de/anomic/yacy/yacySeedUploader.java@@ -5,7 +5,7 @@ import java.io.File;import de.anomic.server.serverSwitch;public interface yacySeedUploader {- public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile);+ public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB, File seedFile) throws Exception;public String[] getConfigurationOptions();public String[] getLibxDependences();}