From 646824de44a90c04420d6309b1bf869bc0f7164a Mon Sep 17 00:00:00 2001 From: Laura Radaelli Date: Thu, 27 Apr 2017 16:32:12 +0300 Subject: [PATCH] parse ScannedData serial number --- .../pollingstation/PollingStationMainController.java | 5 +++-- .../meerkat/pollingstation/ReceiverScanHandler.java | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/polling-station/src/main/java/meerkat/pollingstation/PollingStationMainController.java b/polling-station/src/main/java/meerkat/pollingstation/PollingStationMainController.java index 5990b5a..d6c6f5a 100644 --- a/polling-station/src/main/java/meerkat/pollingstation/PollingStationMainController.java +++ b/polling-station/src/main/java/meerkat/pollingstation/PollingStationMainController.java @@ -22,6 +22,7 @@ public class PollingStationMainController implements PollingStationControllerInt private static final String SUB_ADDRESS = ""; private static final int PORT = 8080; + public PollingStationMainController() { queue = new LinkedBlockingQueue(); shutDownHasBeenCalled = false; @@ -80,7 +81,7 @@ public class PollingStationMainController implements PollingStationControllerInt private void doProcessScan(ReceivedScanCommand command) { logger.info("The Polling Station starts processing the data..."); - logger.info("BallotID = "+command.getBallotSerialNumber()); + logger.info("Ballot Serial Number = "+command.getBallotSerialNumber()); } /** @@ -92,7 +93,7 @@ public class PollingStationMainController implements PollingStationControllerInt } @Override - // TODO: 4/16/2017 Implemet the shutdown behavior + // TODO: 4/16/2017 Implement the shutdown behavior public void callShutDown() { } diff --git a/polling-station/src/main/java/meerkat/pollingstation/ReceiverScanHandler.java b/polling-station/src/main/java/meerkat/pollingstation/ReceiverScanHandler.java index 55a694e..4343d1c 100644 --- a/polling-station/src/main/java/meerkat/pollingstation/ReceiverScanHandler.java +++ b/polling-station/src/main/java/meerkat/pollingstation/ReceiverScanHandler.java @@ -16,6 +16,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletContainer; import java.nio.ByteBuffer; +import java.time.Instant; import java.util.LinkedList; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; @@ -115,12 +116,13 @@ public class ReceiverScanHandler implements PollingStationScanner.Consumer, Runn } } - // TODO: 4/16/2017 Parse protobuf fields properly + // TODO: 4/27/2017 set requestID properly private void doScannedData(ScanDataCallback cb) { PollingStation.ScannedData scan = cb.getScannedData(); - int channel = ByteBuffer.wrap(scan.getChannel().toByteArray()).getInt(); - long channelLong = 12345678910L; - controllerQueue.add(new ReceivedScanCommand(channel, channelLong)); +// String channel = scan.getChannel().toStringUtf8(); + int requestID = 1; + long serialNumber = scan.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber(); + controllerQueue.add(new ReceivedScanCommand(requestID, serialNumber)); } private void doScanError(ScanErrorCallback cb) {