From 070b851203dc8deb13e7194c889a58bd9f8e011a Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Fri, 8 Jan 2016 10:09:19 -0800 Subject: [PATCH] Created the SimpleRegistry file SimpleRegistry expose the ability of manging voters information (their groups, and personal data) --- voter-registry/build.gradle | 2 +- .../src/main/java/meerkat/Registry.java | 13 -- .../src/main/java/meerkat/SimpleRegistry.java | 137 ++++++++++++++++++ 3 files changed, 138 insertions(+), 14 deletions(-) delete mode 100644 voter-registry/src/main/java/meerkat/Registry.java create mode 100644 voter-registry/src/main/java/meerkat/SimpleRegistry.java diff --git a/voter-registry/build.gradle b/voter-registry/build.gradle index 008e9ce..5ccac88 100644 --- a/voter-registry/build.gradle +++ b/voter-registry/build.gradle @@ -30,7 +30,7 @@ ext { nexusPassword = project.hasProperty('nexusPassword') ? project.property('nexusPassword') : "" } -description = "Meerkat Voter Registry application" +description = "Meerkat Voter SimpleRegistry application" // Your project version version = "0.0" diff --git a/voter-registry/src/main/java/meerkat/Registry.java b/voter-registry/src/main/java/meerkat/Registry.java deleted file mode 100644 index d048846..0000000 --- a/voter-registry/src/main/java/meerkat/Registry.java +++ /dev/null @@ -1,13 +0,0 @@ -package meerkat; -import meerkat.ProtobufsMessages.*; - -/** - * Created by Vladimir Eliezer Tokarev on 1/8/2016. - * - */ -public class Registry { - - public boolean TryAddVoter(String voterID, String personalData) throws IllegalArgumentException{ - private - } -} diff --git a/voter-registry/src/main/java/meerkat/SimpleRegistry.java b/voter-registry/src/main/java/meerkat/SimpleRegistry.java new file mode 100644 index 0000000..c5317ae --- /dev/null +++ b/voter-registry/src/main/java/meerkat/SimpleRegistry.java @@ -0,0 +1,137 @@ +package meerkat; +import meerkat.ProtobufsMessages.*; +import meerkat.comm.CommunicationException; + +import java.util.List; + +/** + * Created by Vladimir Eliezer Tokarev on 1/8/2016. + * Gives the ability to manage voters information + * This object is synchronous (which meaning its method blocking) + */ +public class SimpleRegistry { + + public SimpleRegistry(){ + // inits the encoding object + // inits the connection data + } + + /** + * Tries to add new voter to the bulletin-board + * @param voterID + * @param personalData for example residence location + * @throws throws CommunicationException + * @return true if the adding action succeeded else return false + */ + public boolean AddVoter(String voterID, String personalData) throws CommunicationException { + /** + * try: + * Create basic message for adding new voter + * Create bulletin board message using CreateBulletinBoardMessage + * use SimpleBulletinBoardClient.PostMessage to send the message + * return true + * catch exception: + * return false + */ + } + + /** + * Tries adding given voter to given group + * @param voterID + * @param groupID + * @throws CommunicationException + * @return true if the adding action succeeded else return false + */ + public boolean AddToGroup(String voterID, String groupID) throws CommunicationException { + /** + * try: + * Create basic message for adding the given voter to the wanted group + * Create bulletin board message using CreateBulletinBoardMessage + * use SimpleBulletinBoardClient.PostMessage to send the message + * return true + * catch exception: + * return false + */ + } + + /** + * Tries remove given voter from given group + * @param voterID + * @param groupID + * @return true if the removing action succeeded else return false + * @throws CommunicationException + */ + public boolean RemoveFromGroup(String voterID, String groupID) throws CommunicationException { + /** + * try: + * Create basic message for removing the given voter from the wanted group + * Create bulletin board message using CreateBulletinBoardMessage + * use SimpleBulletinBoardClient.PostMessage to send the message + * return true + * catch exception: + * return false + */ + } + + /** + * Tries to set that the voter have voted + * @param id + * @return true if the set voted succeded else false + * @throws CommunicationException + */ + public boolean SetVoted(String id) throws CommunicationException { + /** + * try: + * Create basic message set voted + * Create bulletin board message using CreateBulletinBoardMessage + * use SimpleBulletinBoardClient.PostMessage to send the message + * return true + * catch exception: + * return false + */ + } + + /** + * Craetes bulletin board message from basic message (with the signatures parts) + * @param basicMessage array of bytes + * @return + */ + private byte[] CreateBulletinBoardMessage(byte[] basicMessage) { + /** + * encode the basic message + * create bulletin board message + * put the basic message in bulletin board message + * put the encoded messages signature into the bulletin board message + * return the bulletin board message + */ + } + + /** + * Requests all the groups that the given id voter is in + * @param ID + * @return list of groups ids (or names), if the method fails its empty + * @throws CommunicationException + */ + public List GetGroups(String ID) throws CommunicationException { + /** + * Retrieve all List that contains this id + * creates new list of strings with the names of the group + * Returns the created list + */ + } + + /** + * Retreives list of strings that represents voter + * @param id + * @return list of strings (empty list if the lookup failed) + * @throws CommunicationException + */ + public List GetPersonIDDetails(String id) throws CommunicationException { + /** + * Retreive all List that contains this id + * search for message with the wanted personal data + * Create list with personal data + * return the list + */ + } +}