From 4abc04dac0ec838e31d09038b1ee406aaf8a9484 Mon Sep 17 00:00:00 2001 From: theli Date: Sat, 12 Aug 2006 12:03:44 +0000 Subject: [PATCH] *) make Blacklist_p.html more failsafe if no blacklist file is available of the user has entered empty strings git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2394 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Blacklist_p.html | 20 ++++++++++---------- htroot/Blacklist_p.java | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/htroot/Blacklist_p.html b/htroot/Blacklist_p.html index 3ceeb3d0b..f1d0a6489 100644 --- a/htroot/Blacklist_p.html +++ b/htroot/Blacklist_p.html @@ -33,7 +33,7 @@ collect blacklist entries from other peers.

- +
@@ -45,11 +45,11 @@ collect blacklist entries from other peers.

#{/currentActiveFor}# - +
-
-
+
+
@@ -70,7 +70,7 @@ collect blacklist entries from other peers.

-

Active list: #[currentBlacklist]#

+

Active list: #[currentBlacklist]##(disabled)#::No blacklist selected#(/disabled)#

@@ -94,7 +94,7 @@ collect blacklist entries from other peers.

#{/Itemlist}#

- + @@ -113,7 +113,7 @@ collect blacklist entries from other peers.

-

+

@@ -140,7 +140,7 @@ collect blacklist entries from other peers.

#{/otherHosts}#

- + @@ -156,7 +156,7 @@ collect blacklist entries from other peers.

URL:

- + @@ -172,7 +172,7 @@ collect blacklist entries from other peers.

File:

- + diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java index dc2a77980..23af91473 100644 --- a/htroot/Blacklist_p.java +++ b/htroot/Blacklist_p.java @@ -85,6 +85,7 @@ public class Blacklist_p { if (post.containsKey("selectList")) { blacklistToUse = (String)post.get("selectedListName"); + if (blacklistToUse != null && blacklistToUse.length() == 0) blacklistToUse = null; } if (post.containsKey("createNewList")) { /* =========================================================== @@ -92,6 +93,11 @@ public class Blacklist_p { * =========================================================== */ blacklistToUse = (String)post.get("newListName"); + if (blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } + if (!blacklistToUse.endsWith(".black")) blacklistToUse += ".black"; try { @@ -113,6 +119,10 @@ public class Blacklist_p { * =========================================================== */ blacklistToUse = (String)post.get("selectedListName"); + if (blacklistToUse == null || blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } File BlackListFile = new File(listManager.listsPath, blacklistToUse); BlackListFile.delete(); @@ -135,6 +145,10 @@ public class Blacklist_p { * =========================================================== */ blacklistToUse = (String)post.get("selectedListName"); + if (blacklistToUse == null || blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) { if (post.containsKey("activateList4" + supportedBlacklistTypes[blTypes])) { @@ -153,6 +167,10 @@ public class Blacklist_p { * =========================================================== */ blacklistToUse = (String)post.get("selectedListName"); + if (blacklistToUse == null || blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } if (listManager.ListInListslist(BLACKLIST_SHARED, blacklistToUse)) { // Remove from shared BlackLists @@ -168,9 +186,17 @@ public class Blacklist_p { // get the current selected blacklist name blacklistToUse = (String)post.get("currentBlacklist"); + if (blacklistToUse == null || blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } // get the entry that should be deleted String oldEntry = (String)post.get("selectedEntry"); + if (oldEntry.trim().length() == 0) { + prop.put("LOCATION",header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse); + return prop; + } // load blacklist data from file ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse)); @@ -205,9 +231,17 @@ public class Blacklist_p { * Add a new blacklist entry * =========================================================== */ - blacklistToUse = (String)post.get("currentBlacklist"); + blacklistToUse = (String)post.get("currentBlacklist"); + if (blacklistToUse == null || blacklistToUse.trim().length() == 0) { + prop.put("LOCATION",""); + return prop; + } String newEntry = (String)post.get("newEntry"); + if (newEntry.trim().length() == 0) { + prop.put("LOCATION",header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse); + return prop; + } // TODO: ignore empty entries @@ -334,7 +368,8 @@ public class Blacklist_p { } prop.put("blackLists", blacklistCount); - prop.put("currentBlacklist", blacklistToUse); + prop.put("currentBlacklist", (blacklistToUse==null)?"":blacklistToUse); + prop.put("disabled", (blacklistToUse==null)?1:0); return prop; }