From dfc5bf4b24416d9dc88e64530c81e75ebbda88f6 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Fri, 22 Jan 2016 08:03:52 -0800 Subject: [PATCH] Changed the VoterRegistryMessage to wrap UnsignedBulletinBoardMessage there is no need to wrap unused basic message when using UnsignedBulletinBoardMessage --- .../java/meerkat/VoterRegistryMessage.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java b/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java index 70162a0..40d770d 100644 --- a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java +++ b/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java @@ -1,5 +1,6 @@ package meerkat; +import meerkat.protobuf.BulletinBoardAPI; import util.AccurateTimestamp; import util.RegistryTags; @@ -12,10 +13,10 @@ import java.text.ParseException; */ public class VoterRegistryMessage { - public ProtobufsMessages.BasicMessage base; + public BulletinBoardAPI.UnsignedBulletinBoardMessage base; - public VoterRegistryMessage(ProtobufsMessages.BasicMessage message){ - base = ProtobufsMessages.BasicMessage.newBuilder().addAllTag(message.getTagList()).build(); + public VoterRegistryMessage(BulletinBoardAPI.UnsignedBulletinBoardMessage message){ + base = BulletinBoardAPI.UnsignedBulletinBoardMessage.newBuilder().addAllTag(message.getTagList()).build(); } /** @@ -24,9 +25,9 @@ public class VoterRegistryMessage { * @return string */ public String GetWantedTagFromBasicMessage(RegistryTags tagName){ - for (ProtobufsMessages.Tag tag : base.getTagList()) { - if ( tag.getContent().contains(tagName.toString())) { - return tag.getContent(); + for (String tag : base.getTagList()) { + if ( tag.contains(tagName.toString())) { + return tag; } } return null; @@ -38,9 +39,9 @@ public class VoterRegistryMessage { * @throws ParseException */ public Timestamp GetBasicMessageActionTimestamp() throws ParseException { - for (ProtobufsMessages.Tag tag : base.getTagList()) { - if ( tag.getContent().contains(RegistryTags.ACTION_TIMESTAMP_TAG.toString())) { - String[] tagParts = tag.getContent().split(" "); + for (String tag : base.getTagList()) { + if ( tag.contains(RegistryTags.ACTION_TIMESTAMP_TAG.toString())) { + String[] tagParts = tag.split(" "); String timestamp = tagParts[tagParts.length - 1]; return AccurateTimestamp.GetTimestampFromString(timestamp); } @@ -54,8 +55,8 @@ public class VoterRegistryMessage { * @return true when ADD_TO_GROUP_TAG exist else false */ public boolean IsGroupAdding() { - for (ProtobufsMessages.Tag tag : base.getTagList()) { - if ( tag.getContent().contains(RegistryTags.ADD_TO_GROUP_TAG.toString())) { + for (String tag : base.getTagList()) { + if ( tag.contains(RegistryTags.ADD_TO_GROUP_TAG.toString())) { return true; } }