Replaced part of the files according to Arbel Peled CR and remove unnessesry files

Voter-Registry
Vladimir Eliezer Tokarev 2016-02-25 21:56:46 -08:00
parent 20d2b3e68c
commit 16a3102ca4
10 changed files with 27 additions and 43 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
package util;
package meerkat.Registry;
import java.sql.Timestamp;
import java.text.ParseException;

View File

@ -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;
}

View File

@ -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);
}

View File

@ -1,4 +1,4 @@
package util;
package meerkat.Registry;
/**
* Created by Vladimir Eliezer Tokarev on 1/9/2016.

View File

@ -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();
}
}

View File

@ -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) {

View File

@ -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;

View File

@ -1,18 +0,0 @@
package util;
import meerkat.VoterRegistry;
/**
* Handles the return value of the AddVoter method of
*/
public class VoterAdded implements VoterRegistry.RegistryCallBack<Boolean> {
public boolean Data;
@Override
public void HandleResult(Boolean result) {
Data = result;
}
}

View File

@ -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
*/