From 5a5f614c4dd17cfbe88617b5708fe19f5ccdf75b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 17 Aug 2008 13:52:45 +0000 Subject: Client: Modified old Verification ID deletion Fixes #42 --- .../com/fourisland/instadisc/Database/Wrapper.java | 24 ++++++++-------------- .../fourisland/instadisc/Item/Verification.java | 2 +- .../fourisland/instadisc/Item/WellFormedItem.java | 4 ---- 3 files changed, 9 insertions(+), 21 deletions(-) (limited to 'client/trunk') diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java index 86b22d8..5945e9b 100644 --- a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java +++ b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java @@ -8,7 +8,6 @@ import com.sleepycat.je.DatabaseException; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.Transaction; -import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.EntityStore; import com.sleepycat.persist.PrimaryIndex; import com.sleepycat.persist.StoreConfig; @@ -120,21 +119,15 @@ public class Wrapper { } } - public static void emptyOldVerID() { + public static void addOldVerID(Integer id) { synchronized (oldVerID) { try { Transaction t = e.beginTransaction(null, null); try { - EntityCursor ec = oldVerID.entities(); - try { - Iterator i = ec.iterator(); - while (i.hasNext()) { - oldVerID.delete(t, i.next().getID()); - } - } finally { - ec.close(); - } + OldVerID temp = new OldVerID(); + temp.setID(id); + oldVerID.put(t, temp); t.commit(); } catch (Exception ex) { @@ -145,16 +138,15 @@ public class Wrapper { } } } - - public static void addOldVerID(Integer id) { + + public static void dropFromTopOldVerID() { synchronized (oldVerID) { try { Transaction t = e.beginTransaction(null, null); try { - OldVerID temp = new OldVerID(); - temp.setID(id); - oldVerID.put(t, temp); + Iterator> i = oldVerID.map().entrySet().iterator(); + oldVerID.delete(t, i.next().getKey()); t.commit(); } catch (Exception ex) { diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Verification.java b/client/trunk/src/com/fourisland/instadisc/Item/Verification.java index dc4c4a7..3b99c4b 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/Verification.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/Verification.java @@ -32,7 +32,7 @@ public class Verification { throw new VerificationIDReusedException(); } else { if (Wrapper.countOldVerID() == Integer.decode(Wrapper.getConfig("verIDBufferSize"))) { - Wrapper.emptyOldVerID(); + Wrapper.dropFromTopOldVerID(); } Wrapper.addOldVerID(id); } diff --git a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java index f04e2ad..82211e0 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java @@ -174,10 +174,6 @@ public class WellFormedItem { return good; } - private boolean checkForLegalCategory(String string, boolean good) { - return (good ? true : Wrapper.getSubscription(aThis.headerMap.get("Subscription")).getCategory().equals(string)); - } - private boolean checkForProperVerification() { boolean good = false; try { -- cgit 1.4.1