diff --git a/bulletin-board-server/meerkat b/bulletin-board-server/meerkat index ecd7fd3..9709e18 100644 Binary files a/bulletin-board-server/meerkat and b/bulletin-board-server/meerkat differ diff --git a/voter-registry/src/main/java/util/AccurateTimestamp.java b/voter-registry/src/main/java/meerkat/Registry/AccurateTimestamp.java similarity index 97% rename from voter-registry/src/main/java/util/AccurateTimestamp.java rename to voter-registry/src/main/java/meerkat/Registry/AccurateTimestamp.java index e4cbd98..dd67a22 100644 --- a/voter-registry/src/main/java/util/AccurateTimestamp.java +++ b/voter-registry/src/main/java/meerkat/Registry/AccurateTimestamp.java @@ -1,4 +1,4 @@ -package util; +package meerkat.Registry; import java.sql.Timestamp; import java.text.ParseException; diff --git a/voter-registry/src/main/java/meerkat/BooleanHandler.java b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java similarity index 81% rename from voter-registry/src/main/java/meerkat/BooleanHandler.java rename to voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java index 3710fdd..dbf6239 100644 --- a/voter-registry/src/main/java/meerkat/BooleanHandler.java +++ b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java @@ -1,19 +1,20 @@ -package meerkat; +package meerkat.Registry; +import meerkat.VoterRegistry; import meerkat.bulletinboard.BulletinBoardClient; /** * Created by Vladimir Eliezer Tokarev on 2/19/2016. * Handles the the after post state of VoterRegistry methods (that uses bulletinBoardClient to communicate with the server) */ -public class BooleanHandler implements BulletinBoardClient.ClientCallback { +public class BooleanCallBack implements BulletinBoardClient.ClientCallback { public VoterRegistry.RegistryCallBack callback; /** - * Init BooleanHandler + * Init BooleanCallBack * @param callback voter registry callback object */ - public BooleanHandler(VoterRegistry.RegistryCallBack callback) { + public BooleanCallBack(VoterRegistry.RegistryCallBack callback) { this.callback = callback; } diff --git a/voter-registry/src/main/java/util/CollectionMessagesUtils.java b/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java similarity index 98% rename from voter-registry/src/main/java/util/CollectionMessagesUtils.java rename to voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java index 24c1c87..2904050 100644 --- a/voter-registry/src/main/java/util/CollectionMessagesUtils.java +++ b/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java @@ -1,4 +1,4 @@ -package util; +package meerkat.Registry; import meerkat.VoterRegistryMessage; import meerkat.protobuf.BulletinBoardAPI; @@ -18,7 +18,7 @@ import java.util.stream.Collectors; */ public abstract class CollectionMessagesUtils { - static class EmptyListException extends Exception { + public static class EmptyListException extends Exception { public EmptyListException(String message) { super(message); } diff --git a/voter-registry/src/main/java/util/RegistryTags.java b/voter-registry/src/main/java/meerkat/Registry/RegistryTags.java similarity index 95% rename from voter-registry/src/main/java/util/RegistryTags.java rename to voter-registry/src/main/java/meerkat/Registry/RegistryTags.java index e70043b..9b2ea32 100644 --- a/voter-registry/src/main/java/util/RegistryTags.java +++ b/voter-registry/src/main/java/meerkat/Registry/RegistryTags.java @@ -1,4 +1,4 @@ -package util; +package meerkat.Registry; /** * Created by Vladimir Eliezer Tokarev on 1/9/2016. diff --git a/voter-registry/src/main/java/meerkat/RelevantDataCallBack.java b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java similarity index 87% rename from voter-registry/src/main/java/meerkat/RelevantDataCallBack.java rename to voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java index b91428b..6442b27 100644 --- a/voter-registry/src/main/java/meerkat/RelevantDataCallBack.java +++ b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java @@ -1,14 +1,15 @@ -package meerkat; +package meerkat.Registry; +import meerkat.VoterRegistry; +import meerkat.VoterRegistryMessage; import meerkat.bulletinboard.BulletinBoardClient; import meerkat.protobuf.BulletinBoardAPI; -import util.RegistryTags; import java.text.ParseException; import java.util.List; import java.util.Map; -import static util.CollectionMessagesUtils.*; +import static meerkat.Registry.CollectionMessagesUtils.*; /** * Created by Vladimir Eliezer Tokarev on 2/19/2016. @@ -18,7 +19,7 @@ public class RelevantDataCallBack implements BulletinBoardClient.ClientCallback< public VoterRegistry.RegistryCallBack callback; /** - * Init BooleanHandler + * Init BooleanCallBack * @param callback voter registry callback object */ public RelevantDataCallBack(VoterRegistry.RegistryCallBack callback) { @@ -61,9 +62,11 @@ public class RelevantDataCallBack implements BulletinBoardClient.ClientCallback< } } try { - callback.HandleResult(GetLatestMessage(messages)); + callback.HandleResult(CollectionMessagesUtils.GetLatestMessage(messages)); } catch (ParseException e) { e.printStackTrace(); + } catch (CollectionMessagesUtils.EmptyListException e) { + e.printStackTrace(); } } diff --git a/voter-registry/src/main/java/meerkat/SimpleRegistry.java b/voter-registry/src/main/java/meerkat/SimpleRegistry.java index c9fd287..556fdd6 100644 --- a/voter-registry/src/main/java/meerkat/SimpleRegistry.java +++ b/voter-registry/src/main/java/meerkat/SimpleRegistry.java @@ -1,13 +1,11 @@ package meerkat; +import meerkat.Registry.*; import meerkat.bulletinboard.BulletinBoardClient; import meerkat.crypto.DigitalSignature; import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage; import meerkat.protobuf.BulletinBoardAPI.UnsignedBulletinBoardMessage; import meerkat.protobuf.Crypto; -import util.AccurateTimestamp; -import util.CollectionMessagesUtils; -import util.RegistryTags; import java.security.SignatureException; import java.util.ArrayList; @@ -72,7 +70,7 @@ public class SimpleRegistry implements VoterRegistry{ basicMessage.setData(voterInfo.getInfoBytes()); - SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanHandler(callback)); + SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback)); } public void AddToGroup(RegistryMessages.VoterGroup voterGroup, RegistryCallBack callback) { @@ -83,7 +81,7 @@ public class SimpleRegistry implements VoterRegistry{ .addTag(RegistryTags.GROUP_ACTION_TAG .toString() + RegistryTags.ADD_TO_GROUP_TAG) .addTag(RegistryTags.ACTION_TIMESTAMP_TAG + AccurateTimestamp.GetCurrentTimestampString()); - SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanHandler(callback)); + SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback)); } public void SetVoted(RegistryMessages.VoterID voterId, RegistryCallBack callback) { @@ -93,7 +91,7 @@ public class SimpleRegistry implements VoterRegistry{ .addTag(RegistryTags.VOTE_ACTION_TAG.toString()) .addTag(RegistryTags.ACTION_TIMESTAMP_TAG + AccurateTimestamp.GetCurrentTimestampString()); - SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanHandler(callback)); + SafePost(CreateBulletinBoardMessage(basicMessage.build()), new BooleanCallBack(callback)); } public void GetGroups(RegistryMessages.GroupID groupID, RegistryCallBack callback) { diff --git a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java b/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java index f7f4ddc..5252159 100644 --- a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java +++ b/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java @@ -1,8 +1,8 @@ package meerkat; import meerkat.protobuf.BulletinBoardAPI; -import util.AccurateTimestamp; -import util.RegistryTags; +import meerkat.Registry.AccurateTimestamp; +import meerkat.Registry.RegistryTags; import java.sql.Timestamp; import java.text.ParseException; diff --git a/voter-registry/src/main/java/util/VoterAdded.java b/voter-registry/src/main/java/util/VoterAdded.java deleted file mode 100644 index 36ce74b..0000000 --- a/voter-registry/src/main/java/util/VoterAdded.java +++ /dev/null @@ -1,18 +0,0 @@ -package util; - - -import meerkat.VoterRegistry; - -/** - * Handles the return value of the AddVoter method of - */ -public class VoterAdded implements VoterRegistry.RegistryCallBack { - public boolean Data; - - @Override - public void HandleResult(Boolean result) { - Data = result; - } -} - - diff --git a/voter-registry/src/test/java/SimpleRegistryTest.java b/voter-registry/src/test/java/SimpleRegistryTest.java index e2fa751..fb1a251 100644 --- a/voter-registry/src/test/java/SimpleRegistryTest.java +++ b/voter-registry/src/test/java/SimpleRegistryTest.java @@ -9,8 +9,8 @@ import meerkat.bulletinboard.ThreadedBulletinBoardClient; import meerkat.crypto.concrete.ECDSASignature; import meerkat.protobuf.BulletinBoardAPI; import meerkat.protobuf.Voting; -import util.CollectionMessagesUtils; -import util.RegistryTags; +import meerkat.Registry.CollectionMessagesUtils; +import meerkat.Registry.RegistryTags; import java.io.InputStream; import java.math.BigInteger; @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Semaphore; -import static util.CollectionMessagesUtils.ConvertToVoterRegistryMessages; +import static meerkat.Registry.CollectionMessagesUtils.ConvertToVoterRegistryMessages; /** * TODO: add logs prints for the tests to be clear what they are @@ -29,7 +29,7 @@ import static util.CollectionMessagesUtils.ConvertToVoterRegistryMessages; /** * Created by Vladimir Eliezer Tokarev on 1/16/2016. - * Tests the Simple Registry contents + * Tests the Simple meerkat.Registry contents * NOTE: for most of this tests to pass there should run BulletinBoardServer * that should be reachable on BULLETIN_BOARD_SERVER_ADDRESS */