Skip to content

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

tried to fix principal bug .. not succeeded

orbiter85877413a0fe
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index cc446a28c..638f7e5ae 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -345,59 +345,51 @@ public class SettingsAck_p {
}
if (post.containsKey("seedUploadRetry")) {
- try {
- // trying to upload the seed-list file
- yacyCore.saveSeedList(env);
+ String error;
+ if ((error = yacyCore.saveSeedList(env)) == null) {
+ // trying to upload the seed-list file
prop.put("info", 13);
prop.put("info_success",1);
- } catch (Exception e) {
+ } else {
prop.put("info",14);
- prop.put("info_errormsg",e.getMessage().replaceAll("\n","<br>"));
+ prop.put("info_errormsg",error.replaceAll("\n","<br>"));
env.setConfig("seedUploadMethod","none");
}
return prop;
}
- if (post.containsKey("seedSettings")) {
- try {
- // getting the currently used uploading method
- String oldSeedUploadMethod = env.getConfig("seedUploadMethod","none");
- String newSeedUploadMethod = (String)post.get("seedUploadMethod");
- String oldSeedURLStr = env.getConfig("seedURL","");
- String newSeedURLStr = (String)post.get("seedURL");
- new URL(newSeedURLStr);
+ if (post.containsKey("seedSettings")) {
+ // getting the currently used uploading method
+ String oldSeedUploadMethod = env.getConfig("seedUploadMethod","none");
+ String newSeedUploadMethod = (String)post.get("seedUploadMethod");
+ String oldSeedURLStr = env.getConfig("seedURL","");
+ String newSeedURLStr = (String)post.get("seedURL");
+
+ boolean seedUrlChanged = !oldSeedURLStr.equals(newSeedURLStr);
+ boolean uploadMethodChanged = !oldSeedUploadMethod.equals(newSeedUploadMethod);
+ if (uploadMethodChanged) {
+ uploadMethodChanged = yacyCore.changeSeedUploadMethod(newSeedUploadMethod);
+ }
+
+ if (seedUrlChanged || uploadMethodChanged) {
+ env.setConfig("seedUploadMethod", newSeedUploadMethod);
+ env.setConfig("seedURL", newSeedURLStr);
- boolean seedUrlChanged = !oldSeedURLStr.equals(newSeedURLStr);
- boolean uploadMethodChanged = !oldSeedUploadMethod.equals(newSeedUploadMethod);
- if (uploadMethodChanged) {
- uploadMethodChanged = yacyCore.changeSeedUploadMethod(newSeedUploadMethod);
- }
-
- if (seedUrlChanged || uploadMethodChanged) {
- env.setConfig("seedUploadMethod", newSeedUploadMethod);
- env.setConfig("seedURL", newSeedURLStr);
-
- // trying to upload the seed-list file
- yacyCore.saveSeedList(env);
-
+ // try an upload
+ String error;
+ if ((error = yacyCore.saveSeedList(env)) == null) {
// 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);
+ prop.put("info", 19);
} else {
- prop.put("info_seedUploadMethod",newSeedUploadMethod);
- prop.put("info_seedURL",newSeedURLStr);
- prop.put("info_success",0);
- prop.put("info", 19);
-
+ prop.put("info",14);
+ prop.put("info_errormsg",error.replaceAll("\n","<br>"));
+ env.setConfig("seedUploadMethod","none");
}
- } catch (Exception e) {
- prop.put("info",14);
- prop.put("info_errormsg",e.getMessage().replaceAll("\n","<br>"));
- env.setConfig("seedUploadMethod","none");
+ return prop;
}
- return prop;
}
/*
@@ -430,16 +422,16 @@ public class SettingsAck_p {
// 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);
+ String error;
+ if ((error = yacyCore.saveSeedList(env)) == null) {;
// we have successfully uploaded the seed file
prop.put("info", 13);
prop.put("info_success",1);
- } catch (Exception e) {
+ } else {
// if uploading failed we print out an error message
prop.put("info", 14);
- prop.put("info_errormsg",e.getMessage().replaceAll("\n","<br>"));
+ prop.put("info_errormsg",error.replaceAll("\n","<br>"));
env.setConfig("seedUploadMethod","none");
}
} else {
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index a30e3779d..8cca65f9b 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -607,24 +607,20 @@ public class yacyCore {
}
}
- public boolean saveSeedList() {
- try {
- saveSeedList(this.switchboard);
- return true;
- } catch (Exception e) {
- return false;
- }
+ public String saveSeedList() {
+ // return an error if this is not successful, and NULL if everything is fine
+ return saveSeedList(this.switchboard);
}
- public static void saveSeedList(serverSwitch sb)
- throws Exception {
+ public static String saveSeedList(serverSwitch sb) {
+ // return an error if this is not successful, and NULL if everything is fine
String logt;
// be shure that we have something to say
if (seedDB.mySeed.getAddress() == null) {
String errorMsg = "We have no valid IP address until now";
log.logWarning("SaveSeedList: " + errorMsg);
- throw new Exception (errorMsg);
+ return errorMsg;
}
// getting the configured seed uploader
@@ -648,14 +644,14 @@ public class yacyCore {
}
// determine the seed uploader that should be used ...
- if (seedUploadMethod.equalsIgnoreCase("none")) return;
+ if (seedUploadMethod.equalsIgnoreCase("none")) return "no uploader specified";
yacySeedUploader uploader = getSeedUploader(seedUploadMethod);
if (uploader == null) {
String errorMsg = "Unable to get the proper uploader-class for seed uploading method '" + seedUploadMethod + "'.";
log.logWarning("SaveSeedList: " + errorMsg);
- throw new Exception (errorMsg);
- }
+ return errorMsg;
+ }
// ensure that the seed file url is configured properly
URL seedURL;
@@ -667,7 +663,7 @@ public class yacyCore {
}catch(MalformedURLException e){
String errorMsg = "Malformed seed file URL '" + sb.getConfig("seedURL","") + "'. " + e.getMessage();
log.logWarning("SaveSeedList: " + errorMsg);
- throw new Exception(errorMsg);
+ return errorMsg;
}
// upload the seed-list using the configured uploader class
@@ -685,20 +681,22 @@ public class yacyCore {
if (logt != null) {
if (logt.indexOf("Error") >= 0) {
seedDB.mySeed.put("PeerType", prevStatus);
- log.logError("SaveSeedList: seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6));
- throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + logt.substring(logt.indexOf("Error") + 6));
+ String errorMsg = "SaveSeedList: seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6);
+ log.logError(errorMsg);
+ return errorMsg;
}
log.logInfo(logt);
}
// finally, set the principal status
sb.setConfig("yacyStatus","principal");
- return;
+ return null;
} catch (Exception e) {
seedDB.mySeed.put("PeerType", prevStatus);
sb.setConfig("yacyStatus", prevStatus);
- log.logInfo("SaveSeedList: Seed upload failed (IO error): " + e.getMessage());
- throw new Exception("Seed-list uploading failed using uploader '" + uploader.getClass().getName() + "'\n(error): " + e.getMessage());
+ String errorMsg = "SaveSeedList: Seed upload failed (IO error): " + e.getMessage();
+ log.logInfo(errorMsg);
+ return errorMsg;
}
}