mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
*) items from one blacklist can be moved to another now, comes in handy if you have several blacklists or want to split one blacklist into several lists
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3850 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
4a1bc4743a
commit
c9702a106f
|
@ -81,6 +81,14 @@
|
|||
</select>
|
||||
<br />
|
||||
<input type="submit" name="deleteBlacklistEntry" value="Delete URL pattern" />
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" name="moveBlacklistEntry" value="Move URL pattern to" />
|
||||
<select name="targetBlacklist" size="1">
|
||||
#{blackLists}#
|
||||
<option value="#[name]#">#[name]#</option>
|
||||
#{/blackLists}#
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
<form action="Blacklist_p.html" method="post" enctype="multipart/form-data">
|
||||
|
|
|
@ -277,12 +277,102 @@ public class Blacklist_p {
|
|||
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
|
||||
if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists",blacklistToUse)) {
|
||||
plasmaSwitchboard.urlBlacklist.add(supportedBlacklistTypes[blTypes],newEntry.substring(0, pos), newEntry.substring(pos + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (post.containsKey("moveBlacklistEntry")) {
|
||||
|
||||
/* ===========================================================
|
||||
* First add entry to blacklist item moves to
|
||||
* =========================================================== */
|
||||
|
||||
blacklistToUse = (String)post.get("targetBlacklist");
|
||||
if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
|
||||
prop.put("LOCATION","");
|
||||
return prop;
|
||||
}
|
||||
|
||||
String entry = (String)post.get("selectedEntry");
|
||||
if (entry == null || entry.trim().length() == 0) {
|
||||
prop.put("LOCATION",header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse);
|
||||
return prop;
|
||||
}
|
||||
|
||||
// TODO: ignore empty entries
|
||||
|
||||
if (entry.startsWith("http://") ){
|
||||
entry = entry.substring(7);
|
||||
}
|
||||
|
||||
int pos = entry.indexOf("/");
|
||||
if (pos < 0) {
|
||||
// add default empty path pattern
|
||||
pos = entry.length();
|
||||
entry = entry + "/.*";
|
||||
}
|
||||
|
||||
// append the line to the file
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
pw = new PrintWriter(new FileWriter(new File(listManager.listsPath, blacklistToUse), true));
|
||||
pw.println(entry);
|
||||
pw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (pw != null) try { pw.close(); } catch (Exception e){ /* */}
|
||||
}
|
||||
|
||||
// add to blacklist
|
||||
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
|
||||
if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists",blacklistToUse)) {
|
||||
plasmaSwitchboard.urlBlacklist.add(supportedBlacklistTypes[blTypes],entry.substring(0, pos), entry.substring(pos + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================================================
|
||||
* Then delete item from blacklist it is moved away from
|
||||
* =========================================================== */
|
||||
|
||||
// get the current selected blacklist name
|
||||
blacklistToUse = (String)post.get("currentBlacklist");
|
||||
if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
|
||||
prop.put("LOCATION","");
|
||||
return prop;
|
||||
}
|
||||
|
||||
// load blacklist data from file
|
||||
ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
|
||||
|
||||
// delete the old entry from file
|
||||
if (list != null) {
|
||||
for (int i=0; i < list.size(); i++) {
|
||||
if (((String)list.get(i)).equals(entry)) {
|
||||
list.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
listManager.writeList(new File(listManager.listsPath, blacklistToUse), (String[])list.toArray(new String[list.size()]));
|
||||
}
|
||||
|
||||
// remove the entry from the running blacklist engine
|
||||
pos = entry.indexOf("/");
|
||||
if (pos < 0) {
|
||||
// add default empty path pattern
|
||||
pos = entry.length();
|
||||
entry = entry + "/.*";
|
||||
}
|
||||
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
|
||||
if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists",blacklistToUse)) {
|
||||
plasmaSwitchboard.urlBlacklist.remove(supportedBlacklistTypes[blTypes],entry.substring(0, pos), entry.substring(pos + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// loading all blacklist files located in the directory
|
||||
String[] dirlist = listManager.getDirListing(listManager.listsPath);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user