From 3fa60445e020905e2a61ceefe35d7d9bbf00a996 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 6 Dec 2023 15:25:35 +0100 Subject: [PATCH] SEBSERV-487 preparation --- .../seb/sebserver/gbl/FeatureService.java | 27 ++++++++++++++----- .../seb/sebserver/gbl/FeatureServiceImpl.java | 4 +-- .../ch/ethz/seb/sebserver/gui/GuiInit.java | 7 +++++ .../seb/sebserver/gui/GuiServiceInfo.java | 11 ++++++++ .../sebserver/gui/GuiWebsecurityConfig.java | 2 +- .../seb/sebserver/gui/RAPSpringConfig.java | 2 +- .../sebserver/gui/content/exam/ExamForm.java | 6 +++-- .../monitoring/MonitoringRunningExam.java | 4 ++- .../page/impl/JitsiMeetProctoringView.java | 2 +- .../service/page/impl/ZoomProctoringView.java | 2 +- .../sebserver/webservice/WebserviceInfo.java | 13 ++++++++- .../sebserver/webservice/WebserviceInit.java | 5 ++++ .../config/application-gui.properties | 7 ----- .../resources/config/application.properties | 7 ++--- 14 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java index 1f804c51..6983e04a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java @@ -14,20 +14,33 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; public interface FeatureService { - String SCREEN_PROCTORING_FEATURE_NAME = "seb.screenProctoring"; - String INSTITUTION_FEATURE_NAME = "admin.institution"; - String REMOTE_PROCTORING_FEATURE_NAME = "seb.remoteProctoring"; - String TEST_LMS_FEATURE_NAME = "lms.testLMS"; - String EXAM_NO_LMS_FEATURE_NAME = "exam.noLMS"; - String FEATURE_SETTINGS_PREFIX = "sebserver.feature."; + enum ConfigurableFeature { + SCREEN_PROCTORING("seb.screenProctoring"), + INSTITUTION("admin.institution"), + REMOTE_PROCTORING("seb.remoteProctoring"), + TEST_LMS("lms.testLMS"), + EXAM_NO_LMS("exam.noLMS"), + LIGHT_SETUP("setup.light") + + ; + + final String namespace; + + ConfigurableFeature(final String namespace) { + this.namespace = namespace; + } + } + + boolean isEnabled(ConfigurableFeature feature); + boolean isEnabled(LmsType LmsType); boolean isEnabled(ProctoringServerType proctoringServerType); boolean isEnabled(CollectingStrategy collectingRoomStrategy); - boolean isEnabled(String featureSuffix); + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java index 96f41e9d..8e4a59c0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java @@ -56,9 +56,9 @@ public class FeatureServiceImpl implements FeatureService { } @Override - public boolean isEnabled(final String featureSuffix) { + public boolean isEnabled(final ConfigurableFeature feature) { return this.environment.getProperty(toConfigName( - FEATURE_SETTINGS_PREFIX + featureSuffix + ".enabled"), + FEATURE_SETTINGS_PREFIX + feature.namespace + ".enabled"), Boolean.class, Boolean.FALSE); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java b/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java index b66ad931..bf7af526 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java @@ -76,6 +76,13 @@ public class GuiInit implements ApplicationListener { SEBServerInit.INIT_LOGGER.info("---->"); SEBServerInit.INIT_LOGGER.info("----> Webservice admin API basic access: --" + webServiceAPIBasicAccess + "--"); + SEBServerInit.INIT_LOGGER.info("----> "); + if (this.guiServiceInfo.isDistributedSetup()) { + SEBServerInit.INIT_LOGGER.info("----> SEB Server GUI running on distributed setup"); + } else { + SEBServerInit.INIT_LOGGER.info("----> SEB Server GUI running on bundled setup"); + } + SEBServerInit.INIT_LOGGER.info("---->"); SEBServerInit.INIT_LOGGER.info("----> *********************************************************"); SEBServerInit.INIT_LOGGER.info("----> *** GUI Service successfully successfully started up! ***"); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/GuiServiceInfo.java b/src/main/java/ch/ethz/seb/sebserver/gui/GuiServiceInfo.java index 48a46e95..d1dbfd89 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/GuiServiceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/GuiServiceInfo.java @@ -8,6 +8,9 @@ package ch.ethz.seb.sebserver.gui; +import static ch.ethz.seb.sebserver.gbl.FeatureService.ConfigurableFeature.LIGHT_SETUP; + +import ch.ethz.seb.sebserver.gbl.FeatureService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -32,7 +35,10 @@ public class GuiServiceInfo { private final boolean distributedSetup; private final boolean multilingualGUI; + public final FeatureService featureService; + public GuiServiceInfo( + final FeatureService featureService, @Value("${sebserver.version:--}") final String sebServerVersion, @Value("${server.address}") final String internalServer, @Value("${server.port}") final String internalPort, @@ -44,6 +50,7 @@ public class GuiServiceInfo { @Value("${sebserver.webservice.distributed:false}") final boolean distributedSetup, @Value("${sebserver.gui.multilingual:false}") final boolean multilingualGUI) { + this.featureService = featureService; if (StringUtils.isBlank(externalScheme)) { throw new RuntimeException("Missing mandatory inital parameter sebserver.gui.http.external.servername"); } @@ -81,6 +88,10 @@ public class GuiServiceInfo { this.multilingualGUI = multilingualGUI; } + public boolean isLightSetup() { + return this.featureService.isEnabled(LIGHT_SETUP); + } + public String getExternalScheme() { return this.externalScheme; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/GuiWebsecurityConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/GuiWebsecurityConfig.java index 4adaaf05..7c4de56d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/GuiWebsecurityConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/GuiWebsecurityConfig.java @@ -38,7 +38,7 @@ public class GuiWebsecurityConfig extends WebSecurityConfigurerAdapter { private String guiEntryPoint; @Value("${sebserver.gui.remote.proctoring.entrypoint:/remote-proctoring}") private String remoteProctoringEndpoint; - @Value("${sebserver.gui.remote.proctoring.api-servler.endpoint:/remote-view-servlet}") + @Value("${sebserver.gui.remote.proctoring.api-servlet.endpoint:/remote-view-servlet}") private String remoteProctoringViewServletEndpoint; @Value("${springdoc.api-docs.enabled:false}") private boolean springDocsAPIEnabled; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java index b4c2df1d..ee355914 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java @@ -42,7 +42,7 @@ public class RAPSpringConfig { @Value("${sebserver.gui.remote.proctoring.entrypoint:/remote-proctoring}") private String remoteProctoringEndpoint; - @Value("${sebserver.gui.remote.proctoring.api-servler.endpoint:/remote-view-servlet}") + @Value("${sebserver.gui.remote.proctoring.api-servlet.endpoint:/remote-view-servlet}") private String remoteProctoringViewServletEndpoint; @Bean diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java index 178c08b4..feb2d947 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java @@ -8,6 +8,8 @@ package ch.ethz.seb.sebserver.gui.content.exam; +import static ch.ethz.seb.sebserver.gbl.FeatureService.ConfigurableFeature.SCREEN_PROCTORING; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -17,6 +19,7 @@ import java.util.Objects; import java.util.function.BooleanSupplier; import java.util.function.Function; +import ch.ethz.seb.sebserver.gbl.FeatureService; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.layout.GridData; @@ -27,7 +30,6 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.gbl.Constants; -import ch.ethz.seb.sebserver.gbl.FeatureService; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage; @@ -419,7 +421,7 @@ public class ExamForm implements TemplateComposer { .map(ProctoringServiceSettings::getEnableProctoring) .getOr(false); - final boolean spsFeatureEnabled = this.featureService.isEnabled(FeatureService.SCREEN_PROCTORING_FEATURE_NAME); + final boolean spsFeatureEnabled = this.featureService.isEnabled(SCREEN_PROCTORING); final boolean screenProctoringEnabled = spsFeatureEnabled && !importFromQuizData && this.restService .getBuilder(GetScreenProctoringSettings.class) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringRunningExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringRunningExam.java index 3062571a..48716126 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringRunningExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/monitoring/MonitoringRunningExam.java @@ -8,6 +8,8 @@ package ch.ethz.seb.sebserver.gui.content.monitoring; +import static ch.ethz.seb.sebserver.gbl.FeatureService.ConfigurableFeature.SCREEN_PROCTORING; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -319,7 +321,7 @@ public class MonitoringRunningExam implements TemplateComposer { final PageActionBuilder actionBuilder = this.pageService .pageActionBuilder(pageContext.clearEntityKeys()); - final boolean spsFeatureEnabled = this.featureService.isEnabled(FeatureService.SCREEN_PROCTORING_FEATURE_NAME); + final boolean spsFeatureEnabled = this.featureService.isEnabled(SCREEN_PROCTORING); final boolean proctoringEnabled = spsFeatureEnabled && proctoringSettings != null && BooleanUtils.toBoolean(proctoringSettings.enableProctoring); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/JitsiMeetProctoringView.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/JitsiMeetProctoringView.java index 2c58f42d..9d5e2b77 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/JitsiMeetProctoringView.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/JitsiMeetProctoringView.java @@ -47,7 +47,7 @@ public class JitsiMeetProctoringView extends AbstractProctoringView { final PageService pageService, final GuiServiceInfo guiServiceInfo, @Value("${sebserver.gui.remote.proctoring.entrypoint:/remote-proctoring}") final String remoteProctoringEndpoint, - @Value("${sebserver.gui.remote.proctoring.api-servler.endpoint:/remote-view-servlet}") final String remoteProctoringViewServletEndpoint) { + @Value("${sebserver.gui.remote.proctoring.api-servlet.endpoint:/remote-view-servlet}") final String remoteProctoringViewServletEndpoint) { super(pageService, guiServiceInfo, remoteProctoringEndpoint, remoteProctoringViewServletEndpoint); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ZoomProctoringView.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ZoomProctoringView.java index 33cf3cee..20cde0b0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ZoomProctoringView.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ZoomProctoringView.java @@ -47,7 +47,7 @@ public class ZoomProctoringView extends AbstractProctoringView { final PageService pageService, final GuiServiceInfo guiServiceInfo, @Value("${sebserver.gui.remote.proctoring.entrypoint:/remote-proctoring}") final String remoteProctoringEndpoint, - @Value("${sebserver.gui.remote.proctoring.api-servler.endpoint:/remote-view-servlet}") final String remoteProctoringViewServletEndpoint) { + @Value("${sebserver.gui.remote.proctoring.api-servlet.endpoint:/remote-view-servlet}") final String remoteProctoringViewServletEndpoint) { super(pageService, guiServiceInfo, remoteProctoringEndpoint, remoteProctoringViewServletEndpoint); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java index d05cdb7f..c6c3c5c9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java @@ -8,6 +8,8 @@ package ch.ethz.seb.sebserver.webservice; +import static ch.ethz.seb.sebserver.gbl.FeatureService.ConfigurableFeature.LIGHT_SETUP; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -18,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import ch.ethz.seb.sebserver.gbl.FeatureService; import ch.ethz.seb.sebserver.gbl.model.exam.SPSAPIAccessData; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; @@ -82,13 +85,17 @@ public class WebserviceInfo { @Value("${sebserver.webservice.api.exam.accessTokenValiditySeconds:43200}") private int examAPITokenValiditySeconds; + public final FeatureService featureService; + private final ScreenProctoringServiceBundle screenProctoringServiceBundle; public WebserviceInfo( final WebserviceInfoDAO webserviceInfoDAO, final Environment environment, - final Cryptor cryptor) { + final Cryptor cryptor, + final FeatureService featureService) { + this.featureService = featureService; this.webserviceInfoDAO = webserviceInfoDAO; this.sebServerVersion = environment.getRequiredProperty(VERSION_KEY); this.testProperty = environment.getProperty(WEB_SERVICE_TEST_PROPERTY, "NOT_AVAILABLE"); @@ -173,6 +180,10 @@ public class WebserviceInfo { } } + public boolean isLightSetup() { + return this.featureService.isEnabled(LIGHT_SETUP); + } + public boolean isMaster() { return this.isMaster; } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInit.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInit.java index 31723aa5..2bfe9696 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInit.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInit.java @@ -121,6 +121,11 @@ public class WebserviceInit implements ApplicationListener "); + SEBServerInit.INIT_LOGGER.info("----> SEB Server light setup enabled"); + } + SEBServerInit.INIT_LOGGER.info("----> "); SEBServerInit.INIT_LOGGER.info("----> Working with ping service: {}", this.environment.getProperty("sebserver.webservice.ping.service.strategy")); diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties index 300bc489..870a9fc8 100644 --- a/src/main/resources/config/application-gui.properties +++ b/src/main/resources/config/application-gui.properties @@ -41,13 +41,6 @@ sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb sebserver.gui.proctoring.zoom.websdk.version=2.8.0 sebserver.gui.filter.date.from.years=2 -# remote proctoring -sebserver.gui.remote.proctoring.entrypoint=/remote-proctoring -sebserver.gui.remote.proctoring.api-servler.endpoint=/remote-view-servlet - -# external libs / plugins -sebserver.gui.external.lib.aria.plugin.path= - # Webservice connection details sebserver.webservice.api.exam.endpoint=/exam-api sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index 8dff4181..3cb284b3 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -42,9 +42,9 @@ 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 +#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 ########################################################## ### Overall Security Settings @@ -64,6 +64,7 @@ sebserver.ssl.redirect.enabled=false sebserver.ssl.redirect.html.port=8080 # features +sebserver.feature.setup.light.enabled=false sebserver.feature.admin.institution.enabled=true sebserver.feature.seb.remoteProctoring.enabled=true sebserver.feature.lms.testLMS.enabled=true