From 7360d8b99be4508817d80206263479290443c025 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 17 Jun 2021 08:49:51 +0200 Subject: [PATCH] code cleanup and docu --- .../session/SEBClientNotificationService.java | 17 +++++++++++++++++ .../impl/SEBClientNotificationServiceImpl.java | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientNotificationService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientNotificationService.java index 351f99e3..1461bc73 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientNotificationService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientNotificationService.java @@ -22,15 +22,32 @@ public interface SEBClientNotificationService { /** Indicates whether the client connection with the specified identifier has any * pending notification or not. Pending means a non-confirmed notification + * This will only check client connections in ACTIVE state. * * @param clientConnectionId the client connection identifier * @return true if there is any pending notification for the specified client connection */ Boolean hasAnyPendingNotification(final ClientConnection clientConnection); + /** This gets a list of all pending notification for a given client connection independently + * of it current status. + * + * @param clientConnectionId The identifier of the client connection + * @return Result refer to pending client notifications or to an error when happened */ Result> getPendingNotifications(Long clientConnectionId); + /** This is used to confirm a pending notification from SEB client side where + * a client event of type notification-confirm is involved + * + * @param event The notification confirmation event sent by a SEB client + * @param connectionToken the client connection token of the SEB client connection */ void confirmPendingNotification(ClientEvent event, String connectionToken); + /** This is used to confirm a pending client notification from the SEB Server side + * + * @param notificationId The identifier of the client notification event + * @param examId the exam identifier + * @param connectionToken the SEB client connection token + * @return Result refer to the confirmed client notification or to an error when happened */ Result confirmPendingNotification( Long notificationId, Long examId, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java index fe20b329..912e831d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.stereotype.Service; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection; +import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection.ConnectionStatus; import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent; import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction; import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction.InstructionType; @@ -59,6 +60,9 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe @Override public Boolean hasAnyPendingNotification(final ClientConnection clientConnection) { + if (clientConnection.status != ConnectionStatus.ACTIVE) { + return false; + } updateCache(clientConnection.examId); return this.pendingNotifications.contains(clientConnection.id); }