diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java index be328b3f..5eba6fe6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java @@ -324,7 +324,7 @@ public final class Result { } } - public static Result tryCatch(final Runnable runnable) { + public static Result tryCatch(final TryCatchRunnable runnable) { try { runnable.run(); return Result.EMPTY; @@ -389,4 +389,8 @@ public final class Result { T get() throws Exception; } + public interface TryCatchRunnable { + void run() throws Exception; + } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index f3fae144..cf76fcdf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -587,35 +587,6 @@ public final class Utils { return (hexString.length() < 2) ? "0" + hexString : hexString; } - public static String toJsonObject(final Map attributes) { - if (attributes == null || attributes.isEmpty()) { - return StringUtils.EMPTY; - } - - final StringBuilder builder = attributes - .entrySet() - .stream() - .reduce( - new StringBuilder(Constants.CURLY_BRACE_OPEN), - (sb, entry) -> sb - .append(Constants.DOUBLE_QUOTE) - .append(entry.getKey()) - .append(Constants.DOUBLE_QUOTE) - .append(Constants.COLON) - .append(getJSONValue(entry.getValue())) - .append(Constants.COMMA), - StringBuilder::append) - .append(Constants.CURLY_BRACE_CLOSE); - - if (builder.length() > 0) { - return builder - .deleteCharAt(builder.length() - 1) - .toString(); - } else { - return StringUtils.EMPTY; - } - } - private static String getJSONValue(final String value) { if (Constants.TRUE_STRING.equalsIgnoreCase(value) || Constants.FALSE_STRING.equalsIgnoreCase(value)) { return value.toLowerCase(); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringClientConnection.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringClientConnection.java index 3420e5f3..df65fc81 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringClientConnection.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringClientConnection.java @@ -262,7 +262,6 @@ public class MonitoringClientConnection implements TemplateComposer { NOTIFICATION_LIST_NO_SELECTION_KEY) .noEventPropagation() - .publishIf(() -> currentUser.get().hasRole(UserRole.EXAM_SUPPORTER), false); _notificationTableSupplier = () -> notificationTable; @@ -396,15 +395,6 @@ public class MonitoringClientConnection implements TemplateComposer { .publish(); } -// actionBuilder -// .newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_EXAM_ROOM_PROCTORING) -// .withEntityKey(parentEntityKey) -// .withExec(action -> this.monitoringProctoringService.openExamCollectionProctorScreen( -// action, -// connectionData)) -// .noEventPropagation() -// .publish(); - clientConnectionDetails.setStatusChangeListener(ccd -> { this.pageService.firePageEvent( new ActionActivationEvent( @@ -426,6 +416,11 @@ public class MonitoringClientConnection implements TemplateComposer { final EntityKey entityKey = table.getSingleSelection(); final EntityKey parentEntityKey = pageAction.getParentEntityKey(); + if (entityKey == null) { + pageAction.pageContext().publishInfo(NOTIFICATION_LIST_NO_SELECTION_KEY); + return pageAction; + } + this.pageService.getRestService() .getBuilder(ConfirmPendingClientNotification.class) .withURIVariable(API.PARAM_PARENT_MODEL_ID, parentEntityKey.modelId) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java index b663ae96..c1bc7ffe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java @@ -143,7 +143,14 @@ public abstract class AbstractCourseAccess { public Result getExamineeAccountDetails(final String examineeSessionId) { final Supplier accountDetailsSupplier = accountDetailsSupplier(examineeSessionId); - return this.accountDetailRequest.protectedRun(accountDetailsSupplier); + return this.accountDetailRequest.protectedRun(() -> { + try { + return accountDetailsSupplier.get(); + } catch (final Exception e) { + log.error("Unexpected error while trying to get examinee account details: ", e); + throw e; + } + }); } /** Default implementation that uses getExamineeAccountDetails to geht the examinee name diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientInstructionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientInstructionServiceImpl.java index 988490d1..ef061cf4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientInstructionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientInstructionServiceImpl.java @@ -34,7 +34,6 @@ import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction.InstructionType import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.SizedArrayNonBlockingQueue; -import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientInstructionRecord; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO; @@ -143,7 +142,7 @@ public class SEBClientInstructionServiceImpl implements SEBClientInstructionServ return Result.tryCatch(() -> { - final String attributesString = Utils.toJsonObject(attributes); + final String attributesString = this.jsonMapper.writeValueAsString(attributes); final Set activeConnections = this.clientConnectionDAO .filterForInstructionStatus(examId, connectionTokens) .getOrElse(Collections::emptySet); diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index aa543423..2f6bd64a 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -35,6 +35,7 @@ logging.level.ch=INFO # logging.file=/sebserver/log/sebserver.log ### spring actuator configuration +management.endpoints.jmx.exposure.include=metrics,logfile,loggers,heapdump,health management.endpoints.web.base-path=/mprofile management.endpoints.web.exposure.include=metrics,logfile,loggers,heapdump,health