Author: jflesch
Date: 2007-06-01 20:31:45 +0000 (Fri, 01 Jun 2007)
New Revision: 13459
Modified:
trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java
Log:
Should fix bug #1438 (Blacklist does not work) // needs testing
Modified: trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java 2007-06-01
20:26:52 UTC (rev 13458)
+++ trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java 2007-06-01
20:31:45 UTC (rev 13459)
@@ -239,25 +239,21 @@
PreparedStatement st;
st =
db.getConnection().prepareStatement("SELECT id, publicKey FROM indexBlackList
WHERE "+
-
"LOWER(publicKey) LIKE ?");
+
"LOWER(publicKey) LIKE ? LIMIT 1");
st.setString(1,
FreenetURIHelper.getComparablePart(key) +"%");
ResultSet res = st.executeQuery();
- while(res.next()) {
- String pubKey =
res.getString("publicKey").replaceAll(".xml", ".frdx");
+ if (!res.next())
+ return -1;
- if
(FreenetURIHelper.compareKeys(pubKey, key)) {
- return res.getInt("id");
- }
- }
+ return res.getInt("id");
}
} catch(SQLException e) {
Logger.error(new BlackList(), "Error while checking if
a given key is blacklisted : "+ e.toString());
return -1;
}
- return -1;
}
/**
@@ -288,20 +284,19 @@
st =
db.getConnection().prepareStatement("SELECT id, publicKey FROM links WHERE "+
-
"LOWER(publicKey) LIKE ?");
+
"LOWER(publicKey) LIKE ? LIMIT 1");
st.setString(1,
FreenetURIHelper.getComparablePart(key) +"%");
ResultSet res = st.executeQuery();
- while(res.next()) {
- String pubKey =
res.getString("publicKey").replaceAll(".xml", ".frdx");
- if
(FreenetURIHelper.compareKeys(pubKey, key)) {
- anotherSt.setInt(1,
res.getInt("id"));
- anotherSt.execute();
- }
+ if (!res.next()) {
+ return false;
}
+ anotherSt.setInt(1, res.getInt("id"));
+ anotherSt.execute();
+
}
} catch(SQLException e) {
Logger.error(new BlackList(), "Error while adding an
entry to the blacklist : "+e.toString());
@@ -334,12 +329,8 @@
ResultSet res = st.executeQuery();
while(res.next()) {
- String pubKey =
res.getString("publicKey").replaceAll(".xml", ".frdx");
-
- if
(FreenetURIHelper.compareKeys(pubKey, key)) {
- anotherSt.setInt(1,
res.getInt("id"));
- anotherSt.execute();
- }
+ anotherSt.setInt(1, res.getInt("id"));
+ anotherSt.execute();
}