fix Blacklist.remove by using pattern.toString to find pattern to remove,

parameter String path did never equal Pattern.
+ delete unused removeAll, as it does not persist changes after restart
pull/66/head
reger 9 years ago
parent 1843ea7e69
commit 5e9e871192

@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -256,17 +257,27 @@ public class Blacklist {
loadList(blFile, sep);
}
public final void removeAll(final BlacklistType blacklistType, final String host) {
getBlacklistMap(blacklistType, true).remove(host);
getBlacklistMap(blacklistType, false).remove(host);
}
/**
* remove the host/path from internal blacklist maps for given blacklistType
* !! and removes the entry from source blacklist file !!
* @param blacklistType
* @param blacklistToUse
* @param host
* @param path
*/
public final void remove(final BlacklistType blacklistType, final String blacklistToUse, final String host, final String path) {
final Map<String, Set<Pattern>> blacklistMap = getBlacklistMap(blacklistType, true);
Set<Pattern> hostList = blacklistMap.get(host);
if (hostList != null) {
hostList.remove(path);
// remove pattern from list (by comparing patternstring with path, remove(path) will not match path)
for (Pattern hp : hostList) {
String hpxs = hp.pattern();
if (hpxs.equals(path)) {
hostList.remove(hp);
break;
}
}
if (hostList.isEmpty()) {
blacklistMap.remove(host);
}
@ -275,12 +286,21 @@ public class Blacklist {
final Map<String, Set<Pattern>> blacklistMapNotMatch = getBlacklistMap(blacklistType, false);
hostList = blacklistMapNotMatch.get(host);
if (hostList != null) {
hostList.remove(path);
// remove pattern from list
for (Pattern hp : hostList) {
String hpxs = hp.pattern();
if (hpxs.equals(path)) {
hostList.remove(hp);
break;
}
}
if (hostList.isEmpty()) {
blacklistMapNotMatch.remove(host);
}
}
//TODO: check if delete from blacklist is desired, on reload entry will not be available in any blacklist
// even if remove (above) from internal maps (at runtime) is only done for given blacklistType
// load blacklist data from file
final List<String> list = FileUtils.getListArray(new File(ListManager.listsPath, blacklistToUse));

Loading…
Cancel
Save