Changed the SimpleRegistry

The new Simple Registry works according to the RegistryInstance interface
Voter-Registry
Vladimir Eliezer Tokarev 2016-01-23 05:51:41 -08:00
parent c30ea072f2
commit 68caeee114
3 changed files with 20 additions and 16 deletions

View File

@ -14,7 +14,7 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleVoterAdded will be called * @param callBack when the adding voter done callBack.HandleVoterAdded will be called
* @return void * @return void
*/ */
abstract void AddVoter(String voterID, String personalData, RegistryCallBack callBack); void AddVoter(String voterID, String personalData, RegistryCallBack callBack);
/** /**
* Adding given voter to given group * Adding given voter to given group
@ -24,7 +24,7 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleVoterAddedToGroup will be called * @param callBack when the adding voter done callBack.HandleVoterAddedToGroup will be called
* @return true if the adding action succeeded else return false * @return true if the adding action succeeded else return false
*/ */
abstract void AddToGroup(String voterID, String groupID, RegistryCallBack callBack); void AddToGroup(String voterID, String groupID, RegistryCallBack callBack);
/** /**
* Removes given voter from given group * Removes given voter from given group
@ -34,7 +34,7 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleVoterRemovedFromGroup will be called * @param callBack when the adding voter done callBack.HandleVoterRemovedFromGroup will be called
* @return true if the removing action succeeded else return false * @return true if the removing action succeeded else return false
*/ */
abstract void RemoveFromGroup(String voterID, String groupID, RegistryCallBack callBack); void RemoveFromGroup(String voterID, String groupID, RegistryCallBack callBack);
/** /**
* Sets that the voter have voted * Sets that the voter have voted
@ -43,7 +43,7 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleSetVoted will be called * @param callBack when the adding voter done callBack.HandleSetVoted will be called
* @return true if the set voted succeed else false * @return true if the set voted succeed else false
*/ */
abstract void SetVoted(String id, RegistryCallBack callBack); void SetVoted(String id, RegistryCallBack callBack);
/** /**
* Requests all the groups that the given id voter is in * Requests all the groups that the given id voter is in
@ -52,7 +52,7 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleVoterGroups will be called * @param callBack when the adding voter done callBack.HandleVoterGroups will be called
* @return list of groups ids (or names), if the method fails its empty * @return list of groups ids (or names), if the method fails its empty
*/ */
abstract void GetGroups(String id, RegistryCallBack callBack); void GetGroups(String id, RegistryCallBack callBack);
/** /**
* Retrieves list of strings that represents voter * Retrieves list of strings that represents voter
@ -61,6 +61,6 @@ public interface RegistryInstance {
* @param callBack when the adding voter done callBack.HandleVoterInfo will be called * @param callBack when the adding voter done callBack.HandleVoterInfo will be called
* @return list of strings (empty list if the lookup failed) * @return list of strings (empty list if the lookup failed)
*/ */
abstract void GetPersonIDDetails(String id, RegistryCallBack callBack); void GetPersonIDDetails(String id, RegistryCallBack callBack);
} }

View File

@ -23,7 +23,6 @@ import static util.CollectionMessagesUtils.*;
public class SimpleRegistry implements RegistryInstance{ public class SimpleRegistry implements RegistryInstance{
protected Encryption signatory; protected Encryption signatory;
protected SimpleBulletinBoardClient communicator; protected SimpleBulletinBoardClient communicator;
public SimpleRegistry(Encryption signatory, SimpleBulletinBoardClient communicator) { public SimpleRegistry(Encryption signatory, SimpleBulletinBoardClient communicator) {
@ -31,8 +30,12 @@ public class SimpleRegistry implements RegistryInstance{
this.communicator = communicator; this.communicator = communicator;
} }
private List<String> wantedInformation;
private boolean methodSucceeded;
/** /**
* Creates BulletinBoardMessage with signed basicMessage and UnsignedBulletinBoardMessage that contains the basic message * Creates BulletinBoardMessage with signed basicMessage and UnsignedBulletinBoardMessage that contains the basic message
*
* @param basicMessage BasicMessage * @param basicMessage BasicMessage
* @return BulletinBoardAPI.BulletinBoardMessage * @return BulletinBoardAPI.BulletinBoardMessage
*/ */

View File

@ -18,11 +18,12 @@ import java.util.stream.Collectors;
public abstract class CollectionMessagesUtils { public abstract class CollectionMessagesUtils {
/** /**
* Converts lost of UnsignedBulletinBoardMessage to VoterRegistryMessags * Converts lost of UnsignedBulletinBoardMessage to VoterRegistryMessages
* @param messages list<VoterRegistryMessage> * @param messages list<VoterRegistryMessage>
* @return List<VoterRegistryMessage> * @return List<VoterRegistryMessage>
*/ */
public static List<VoterRegistryMessage> ConvertToVoterRegistryMessages(List<BulletinBoardAPI.UnsignedBulletinBoardMessage> messages){ public static List<VoterRegistryMessage> ConvertToVoterRegistryMessages(
List<BulletinBoardAPI.UnsignedBulletinBoardMessage> messages){
return messages.stream().map(VoterRegistryMessage::new).collect(Collectors.toList()); return messages.stream().map(VoterRegistryMessage::new).collect(Collectors.toList());
} }