Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Servlet IndexBroser_p add button "Add to blacklist"
reger246a5f0b368444
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.javaindex 9d439522e..43751879c 100644--- a/htroot/Blacklist_p.java+++ b/htroot/Blacklist_p.java@@ -240,7 +240,7 @@ public class Blacklist_p {WorkTables.TABLE_API_TYPE_CONFIGURATION,"add to blacklist '" + blacklistToUse + "': " + blentry);- if(!BlacklistHelper.addBlacklistEntry(blacklistToUse, blentry, header)) {+ if(!BlacklistHelper.addBlacklistEntry(blacklistToUse, blentry)) {prop.put(DISABLED + EDIT + "addError", true);prop.put(DISABLED + EDIT + "addError_entry", blentry);}@@ -281,7 +281,7 @@ public class Blacklist_p {return prop;}- if (!BlacklistHelper.addBlacklistEntry(targetBlacklist, selectedBlacklistEntry, header)) {+ if (!BlacklistHelper.addBlacklistEntry(targetBlacklist, selectedBlacklistEntry)) {prop.put(DISABLED + EDIT + "moveError", true);break;}@@ -322,7 +322,7 @@ public class Blacklist_p {if (!normalizeEntry(selectedEntry.getValue()).equals(preparedNewEntry)) {/* Add first, to detect any eventual syntax errors before removing the old entry */- if (!BlacklistHelper.addBlacklistEntry(blacklistToUse, editedEntryValue, header)) {+ if (!BlacklistHelper.addBlacklistEntry(blacklistToUse, editedEntryValue)) {selected2EditedErrors.put(selectedEntry.getValue(), editedEntryValue);} else if ((temp = BlacklistHelper.deleteBlacklistEntry(blacklistToUse, selectedEntry.getValue(), header)) != null) {prop.put(serverObjects.ACTION_LOCATION, temp);diff --git a/htroot/IndexBrowser_p.html b/htroot/IndexBrowser_p.htmlindex c80319604..6843dba02 100644--- a/htroot/IndexBrowser_p.html+++ b/htroot/IndexBrowser_p.html@@ -166,9 +166,17 @@ var solr= $.getJSON("solr/collection1/select?q=*:*&start=0&rows=0&wt=json&facet=#(/hostanalysis)##(files)#::- <fieldset><legend>Browser for <a href="#[path]#" target="_blank">#[path]#</a></legend>- <p>documents stored for host: #[hostsize]#; documents stored for subpath: #[subpathloadsize]#; unloaded documents detected in subpath: #[subpathdetectedsize]# <!-- #(complete)#;<a href="IndexBrowser_p.html?complete=true&path=#[path]#">get complete list</a>::<a href="IndexBrowser_p.html?path=#[path]#">directory view</a>#(/complete)#-->- </p>+ <fieldset>+ <legend style="display: inline">Browser for <a href="#[path]#" target="_blank">#[path]#</a>+ <span style="padding-left: 25px">+ <form style="display: inline" action="IndexBrowser_p.html?path=#[path]#" id="searchform" method="get" role="search">+ <button type="submit" name="addtoblacklist" class="btn btn-xs btn-default">Add to blacklist</button>+ <input type="text" name="path" value="#[path]#" hidden="true"/>+ </form>+ </span>+ </legend>+ <p>documents stored for host: #[hostsize]#; documents stored for subpath: #[subpathloadsize]#; unloaded documents detected in subpath: #[subpathdetectedsize]# <!-- #(complete)#;<a href="IndexBrowser_p.html?complete=true&path=#[path]#">get complete list</a>::<a href="IndexBrowser_p.html?path=#[path]#">directory view</a>#(/complete)#-->+ </p><table class="sortable" style="float:left; border-width: 0"><thead><tr>diff --git a/htroot/IndexBrowser_p.java b/htroot/IndexBrowser_p.javaindex b16e2e0c7..48dbea414 100644--- a/htroot/IndexBrowser_p.java+++ b/htroot/IndexBrowser_p.java@@ -18,6 +18,7 @@* If not, see <http://www.gnu.org/licenses/>.*/+import java.io.File;import java.io.IOException;import java.net.MalformedURLException;import java.util.ArrayList;@@ -58,6 +59,8 @@ import net.yacy.crawler.data.NoticedURL.StackType;import net.yacy.crawler.retrieval.Request;import net.yacy.kelondro.data.meta.URIMetadataNode;import net.yacy.peers.graphics.WebStructureGraph.StructureEntry;+import net.yacy.repository.Blacklist;+import static net.yacy.repository.BlacklistHelper.addBlacklistEntry;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;import net.yacy.search.index.Fulltext;@@ -653,6 +656,17 @@ public class IndexBrowser_p {} catch (final Throwable e) {ConcurrentLog.logException(e);}++ // for addtoblacklist button+ if (post.containsKey("addtoblacklist") && sb != null) {+ final File blacklistsPath = sb.getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);+ String blacklistname = Blacklist.defaultBlacklist(blacklistsPath);+ if (blacklistname != null) {+ addBlacklistEntry(+ blacklistname,+ "*." + pathURI.getHost());+ }+ }}// return rewrite propertiesdiff --git a/htroot/api/blacklists/add_entry_p.java b/htroot/api/blacklists/add_entry_p.javaindex 6ad2cda2d..1ab0c8d40 100644--- a/htroot/api/blacklists/add_entry_p.java+++ b/htroot/api/blacklists/add_entry_p.java@@ -31,7 +31,7 @@ public class add_entry_p {WorkTables.TABLE_API_TYPE_CONFIGURATION,"add to blacklist '" + blacklistToUse + "': " + entry);- if (BlacklistHelper.addBlacklistEntry(blacklistToUse, entry, header)) {+ if (BlacklistHelper.addBlacklistEntry(blacklistToUse, entry)) {prop.put(XML_ITEM_STATUS, RESULT_SUCCESS);Switchboard.urlBlacklist.clear();diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.javaindex 08dcf5daf..a6ad4e039 100644--- a/source/net/yacy/repository/Blacklist.java+++ b/source/net/yacy/repository/Blacklist.java@@ -789,11 +789,24 @@ public class Blacklist {return BlacklistError.NO_ERROR;}+ /**+ * Returns the default blacklist name default is the first name which+ * contains ".default." (standard default list name is 'url.default.black')+ * or if no the first blacklist if no name containing ".default." exists.+ *+ * @param listsPath directory containig the blacklists+ * @return String blacklist name+ */public static String defaultBlacklist(final File listsPath) {final List<String> dirlist = FileUtils.getDirListing(listsPath, Blacklist.BLACKLIST_FILENAME_FILTER);if (dirlist.isEmpty()) {return null;}+ for (String name : dirlist) {+ if (name.contains(".default.")) {+ return name;+ }+ }return dirlist.get(0);}diff --git a/source/net/yacy/repository/BlacklistHelper.java b/source/net/yacy/repository/BlacklistHelper.javaindex 27b822e11..965306358 100644--- a/source/net/yacy/repository/BlacklistHelper.java+++ b/source/net/yacy/repository/BlacklistHelper.java@@ -58,18 +58,16 @@ public final class BlacklistHelper {* Adds a new entry to the chosen blacklist.* @param blacklistToUse the name of the blacklist the entry is to be added to* @param entry the entry that is to be added- * @param header the current HTTP request headers* @return true when no error occurred and the entry was successfully added*/- public static boolean addBlacklistEntry(- final String blacklistToUse,- final String entry,- final RequestHeader header) {- String newEntry = entry;+ public static boolean addBlacklistEntry(+ final String blacklistToUse,+ final String entry) {+ String newEntry = entry;- if (blacklistToUse == null || blacklistToUse.isEmpty() || newEntry == null || newEntry.isEmpty()) {- return false;- }+ if (blacklistToUse == null || blacklistToUse.isEmpty() || newEntry == null || newEntry.isEmpty()) {+ return false;+ }newEntry = prepareEntry(newEntry);@@ -77,7 +75,7 @@ public final class BlacklistHelper {String host = newEntry.substring(0, pos);String path = newEntry.substring(pos + 1);- boolean success = false;+ boolean success = false;for (final BlacklistType supportedBlacklistType : BlacklistType.values()) {if (ListManager.listSetContains(supportedBlacklistType + ".BlackLists", blacklistToUse)) {try {