From 9b6660eea9088cf8bb18ffdedd31d285dbc42dbe Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 3 Jun 2020 14:02:20 +0200 Subject: [PATCH 01/26] SEBSERV-129 fixed unique name check error --- .../gui/content/SebExamConfigImportPopup.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java index e90ed32a..80c73603 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java @@ -17,6 +17,8 @@ import java.util.function.Supplier; import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.APIMessage; @@ -42,12 +44,15 @@ import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog; import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNodeNames; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportExamConfigOnExistingConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportNewExamConfig; import ch.ethz.seb.sebserver.gui.widget.FileUploadSelection; final class SebExamConfigImportPopup { + private static final Logger log = LoggerFactory.getLogger(SebExamConfigImportPopup.class); + private final static PageMessageException MISSING_PASSWORD = new PageMessageException( new LocTextKey("sebserver.examconfig.action.import.missing-password")); @@ -115,6 +120,29 @@ final class SebExamConfigImportPopup { 3, 255))); return false; + } else { + // check if name already exists + try { + if (pageService.getRestService() + .getBuilder(GetExamConfigNodeNames.class) + .call() + .getOrThrow() + .stream() + .filter(n -> n.name.equals(fieldValue)) + .findFirst() + .isPresent()) { + + form.setFieldError( + Domain.CONFIGURATION_NODE.ATTR_NAME, + pageService + .getI18nSupport() + .getText(new LocTextKey( + "sebserver.form.validation.fieldError.name.notunique"))); + return false; + } + } catch (final Exception e) { + log.error("Failed to verify unique name: {}", e.getMessage()); + } } } From 20c08e5db4e65346e9b72adeddde103e55cb8ce7 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 4 Jun 2020 08:52:01 +0200 Subject: [PATCH 02/26] code cleanup Seb -> SEB --- .../ch/ethz/seb/sebserver/SEBServerInit.java | 2 +- .../seb/sebserver/gbl/model/exam/Exam.java | 1 - ...iction.java => OpenEdxSEBRestriction.java} | 8 +- ...ebRestriction.java => SEBRestriction.java} | 20 ++-- ...ClientConfig.java => SEBClientConfig.java} | 14 +-- .../gui/content/ConfigTemplateForm.java | 4 +- .../seb/sebserver/gui/content/ExamForm.java | 28 ++--- .../seb/sebserver/gui/content/ExamList.java | 4 +- ...s.java => ExamSEBRestrictionSettings.java} | 84 +++++++-------- .../content/MonitoringClientConnection.java | 6 +- .../gui/content/MonitoringRunningExam.java | 12 +-- .../sebserver/gui/content/QuizLookupList.java | 4 +- ...nfigForm.java => SEBClientConfigForm.java} | 92 ++++++++-------- ...nfigList.java => SEBClientConfigList.java} | 18 ++-- ...pup.java => SEBClientLogDetailsPopup.java} | 6 +- ...{SebClientLogs.java => SEBClientLogs.java} | 8 +- ...p.java => SEBExamConfigCreationPopup.java} | 8 +- ...ConfigForm.java => SEBExamConfigForm.java} | 16 +-- ...pup.java => SEBExamConfigImportPopup.java} | 22 ++-- ...ConfigList.java => SEBExamConfigList.java} | 6 +- ...SettingsForm.java => SEBSettingsForm.java} | 14 +-- .../gui/content/UserActivityLogs.java | 4 +- .../gui/content/activity/ActivitiesPane.java | 6 +- .../activity/PageStateDefinitionImpl.java | 30 +++--- .../gui/service/ResourceService.java | 8 +- ...load.java => SEBClientConfigDownload.java} | 6 +- ...wnload.java => SEBExamConfigDownload.java} | 6 +- ...va => SEBExamConfigPlaintextDownload.java} | 6 +- ...ction.java => ActivateSEBRestriction.java} | 4 +- ...triction.java => CheckSEBRestriction.java} | 4 +- ...ion.java => DeactivateSEBRestriction.java} | 4 +- ...estriction.java => GetSEBRestriction.java} | 8 +- ...striction.java => SaveSEBRestriction.java} | 4 +- .../api/seb/clientconfig/GetClientConfig.java | 6 +- .../seb/clientconfig/GetClientConfigPage.java | 6 +- .../api/seb/clientconfig/NewClientConfig.java | 6 +- .../seb/clientconfig/SaveClientConfig.java | 6 +- ...ConfigUndo.java => SEBExamConfigUndo.java} | 4 +- .../service/session/InstructionProcessor.java | 6 +- .../sebserver/webservice/WebserviceInfo.java | 2 +- .../webservice/servicelayer/dao/ExamDAO.java | 2 +- .../servicelayer/dao/FilterMap.java | 6 +- ...ConfigDAO.java => SEBClientConfigDAO.java} | 24 ++--- .../servicelayer/dao/impl/ExamDAOImpl.java | 2 +- ...OImpl.java => SEBClientConfigDAOImpl.java} | 102 +++++++++--------- .../exam/ExamAdminServiceImpl.java | 14 +-- .../servicelayer/lms/LmsAPITemplate.java | 20 ++-- ...ervice.java => SEBRestrictionService.java} | 20 ++-- .../lms/impl/MockupLmsAPITemplate.java | 12 +-- ...on.java => NoSEBRestrictionException.java} | 6 +- ...pl.java => SEBRestrictionServiceImpl.java} | 32 +++--- .../impl/edx/OpenEdxCourseRestriction.java | 46 ++++---- .../lms/impl/edx/OpenEdxLmsAPITemplate.java | 22 ++-- .../lms/impl/moodle/MoodleLmsAPITemplate.java | 10 +- .../sebconfig/ClientConfigService.java | 32 +++--- ...nfigCryptor.java => SEBConfigCryptor.java} | 12 +-- ...t.java => SEBConfigEncryptionContext.java} | 4 +- ...e.java => SEBConfigEncryptionService.java} | 10 +- .../impl/ClientConfigServiceImpl.java | 64 +++++------ .../sebconfig/impl/ExamConfigServiceImpl.java | 12 +-- .../sebconfig/impl/NoneEncryptor.java | 12 +-- .../sebconfig/impl/PasswordEncryptor.java | 12 +-- ...va => SEBConfigEncryptionServiceImpl.java} | 34 +++--- .../session/ExamSessionService.java | 2 +- ...e.java => SEBClientConnectionService.java} | 2 +- ...ervice.java => SEBInstructionService.java} | 2 +- .../impl/ExamConfigUpdateServiceImpl.java | 10 +- .../session/impl/ExamSessionCacheService.java | 8 +- .../session/impl/ExamSessionControlTask.java | 6 +- .../session/impl/ExamSessionServiceImpl.java | 20 ++-- .../session/impl/ExamUpdateHandler.java | 12 +-- ...ySebConfig.java => InMemorySEBConfig.java} | 6 +- ...va => SEBClientConnectionServiceImpl.java} | 20 ++-- ...pl.java => SEBInstructionServiceImpl.java} | 10 +- .../weblayer/api/ExamAPI_V1_Controller.java | 12 +-- .../api/ExamAdministrationController.java | 48 ++++----- .../ExamConfigurationMappingController.java | 2 +- .../api/ExamMonitoringController.java | 12 +-- ...er.java => SEBClientConfigController.java} | 36 +++---- .../model/exam/OpenEdxSebRestrictionTest.java | 6 +- .../gui/integration/ClientConfigTest.java | 32 +++--- .../integration/UseCasesIntegrationTest.java | 50 ++++----- .../sebconfig/impl/PasswordEncryptorTest.java | 8 +- .../SebConfigEncryptionServiceImplTest.java | 16 +-- 84 files changed, 663 insertions(+), 670 deletions(-) rename src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/{OpenEdxSebRestriction.java => OpenEdxSEBRestriction.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/{SebRestriction.java => SEBRestriction.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/{SebClientConfig.java => SEBClientConfig.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{ExamSebRestrictionSettings.java => ExamSEBRestrictionSettings.java} (84%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebClientConfigForm.java => SEBClientConfigForm.java} (88%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebClientConfigList.java => SEBClientConfigList.java} (95%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebClientLogDetailsPopup.java => SEBClientLogDetailsPopup.java} (98%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebClientLogs.java => SEBClientLogs.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebExamConfigCreationPopup.java => SEBExamConfigCreationPopup.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebExamConfigForm.java => SEBExamConfigForm.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebExamConfigImportPopup.java => SEBExamConfigImportPopup.java} (95%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebExamConfigList.java => SEBExamConfigList.java} (98%) rename src/main/java/ch/ethz/seb/sebserver/gui/content/{SebSettingsForm.java => SEBSettingsForm.java} (96%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/{SebClientConfigDownload.java => SEBClientConfigDownload.java} (92%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/{SebExamConfigDownload.java => SEBExamConfigDownload.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/{SebExamConfigPlaintextDownload.java => SEBExamConfigPlaintextDownload.java} (89%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/{ActivateSebRestriction.java => ActivateSEBRestriction.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/{CheckSebRestriction.java => CheckSEBRestriction.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/{DeactivateSebRestriction.java => DeactivateSEBRestriction.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/{GetSebRestriction.java => GetSEBRestriction.java} (83%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/{SaveSebRestriction.java => SaveSEBRestriction.java} (91%) rename src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/{SebExamConfigUndo.java => SEBExamConfigUndo.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/{SebClientConfigDAO.java => SEBClientConfigDAO.java} (73%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/{SebClientConfigDAOImpl.java => SEBClientConfigDAOImpl.java} (86%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/{SebRestrictionService.java => SEBRestrictionService.java} (74%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/{NoSebRestrictionException.java => NoSEBRestrictionException.java} (71%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/{SebRestrictionServiceImpl.java => SEBRestrictionServiceImpl.java} (88%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/{SebConfigCryptor.java => SEBConfigCryptor.java} (84%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/{SebConfigEncryptionContext.java => SEBConfigEncryptionContext.java} (90%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/{SebConfigEncryptionService.java => SEBConfigEncryptionService.java} (91%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/{SebConfigEncryptionServiceImpl.java => SEBConfigEncryptionServiceImpl.java} (89%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/{SebClientConnectionService.java => SEBClientConnectionService.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/{SebInstructionService.java => SEBInstructionService.java} (96%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/{InMemorySebConfig.java => InMemorySEBConfig.java} (88%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/{SebClientConnectionServiceImpl.java => SEBClientConnectionServiceImpl.java} (97%) rename src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/{SebInstructionServiceImpl.java => SEBInstructionServiceImpl.java} (95%) rename src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/{SebClientConfigController.java => SEBClientConfigController.java} (87%) diff --git a/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java b/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java index 5936b75e..d4d56a10 100644 --- a/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java +++ b/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java @@ -43,7 +43,7 @@ public class SEBServerInit { INIT_LOGGER.info("----> |___/|___||___/ |___/\\___||_| \\_/ \\___||_| "); INIT_LOGGER.info("---->"); INIT_LOGGER.info("---->"); - INIT_LOGGER.info("----> Version: {}", this.webserviceInfo.getSebServerVersion()); + INIT_LOGGER.info("----> Version: {}", this.webserviceInfo.getSEBServerVersion()); INIT_LOGGER.info("---->"); INIT_LOGGER.info("----> Active profiles: {}", Arrays.toString(this.environment.getActiveProfiles())); INIT_LOGGER.info("---->"); diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java index a5881ee4..193cbab1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java @@ -179,7 +179,6 @@ public final class Exam implements GrantEntity { EXAM.ATTR_STATUS, ExamStatus.class, getStatusFromDate(this.startTime, this.endTime)); -// this.lmsSebRestriction = mapper.getBoolean(EXAM.ATTR_LMS_SEB_RESTRICTION); this.browserExamKeys = mapper.getString(EXAM.ATTR_BROWSER_KEYS); this.active = mapper.getBoolean(EXAM.ATTR_ACTIVE); this.supporter = mapper.getStringSet(EXAM.ATTR_SUPPORTER); diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSEBRestriction.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSEBRestriction.java index ebbacc24..6936c1fa 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/OpenEdxSEBRestriction.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.util.Utils; -public class OpenEdxSebRestriction { +public class OpenEdxSEBRestriction { public static final String ATTR_USER_BANNING_ENABLED = "USER_BANNING_ENABLED"; public static final String ATTR_PERMISSION_COMPONENTS = "PERMISSION_COMPONENTS"; @@ -96,7 +96,7 @@ public class OpenEdxSebRestriction { public final Boolean banningEnabled; @JsonCreator - OpenEdxSebRestriction( + OpenEdxSEBRestriction( @JsonProperty(ATTR_CONFIG_KEYS) final Collection configKeys, @JsonProperty(ATTR_BROWSER_KEYS) final Collection browserExamKeys, @JsonProperty(ATTR_WHITELIST_PATHS) final Collection whiteListPaths, @@ -155,7 +155,7 @@ public class OpenEdxSebRestriction { return builder.toString(); } - public static OpenEdxSebRestriction from(final SebRestriction sebRestrictionData) { + public static OpenEdxSEBRestriction from(final SEBRestriction sebRestrictionData) { final String whiteListPathsString = sebRestrictionData.additionalProperties .get(ATTR_WHITELIST_PATHS); @@ -200,7 +200,7 @@ public class OpenEdxSebRestriction { permissionComponents = Utils.immutableCollectionOf(defaultPermissions); } - return new OpenEdxSebRestriction( + return new OpenEdxSEBRestriction( sebRestrictionData.configKeys, sebRestrictionData.browserExamKeys, whiteListPaths, diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SEBRestriction.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SEBRestriction.java index 1f066903..96acd23c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/SEBRestriction.java @@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.util.Utils; @JsonIgnoreProperties(ignoreUnknown = true) -public final class SebRestriction implements Entity { +public final class SEBRestriction implements Entity { public static final String ATTR_BROWSER_KEYS = "browserExamKeys"; public static final String ATTR_CONFIG_KEYS = "configKeys"; @@ -42,7 +42,7 @@ public final class SebRestriction implements Entity { public final Map additionalProperties; @JsonCreator - public SebRestriction( + public SEBRestriction( @JsonProperty(Domain.EXAM.ATTR_ID) final Long examId, @JsonProperty(ATTR_CONFIG_KEYS) final Collection configKeys, @JsonProperty(ATTR_BROWSER_KEYS) final Collection browserExamKeys, @@ -107,7 +107,7 @@ public final class SebRestriction implements Entity { return false; if (getClass() != obj.getClass()) return false; - final SebRestriction other = (SebRestriction) obj; + final SEBRestriction other = (SEBRestriction) obj; if (this.additionalProperties == null) { if (other.additionalProperties != null) return false; @@ -129,7 +129,7 @@ public final class SebRestriction implements Entity { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("SebRestriction [examId="); + builder.append("SEBRestriction [examId="); builder.append(this.examId); builder.append(", configKeys="); builder.append(this.configKeys); @@ -141,32 +141,32 @@ public final class SebRestriction implements Entity { return builder.toString(); } - public static SebRestriction from(final Long examId, final OpenEdxSebRestriction edxData) { + public static SEBRestriction from(final Long examId, final OpenEdxSEBRestriction edxData) { final Map attrs = new HashMap<>(); if (!CollectionUtils.isEmpty(edxData.whiteListPaths)) { attrs.put( - OpenEdxSebRestriction.ATTR_WHITELIST_PATHS, + OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS, StringUtils.join(edxData.whiteListPaths, Constants.LIST_SEPARATOR_CHAR)); } if (!CollectionUtils.isEmpty(edxData.blacklistChapters)) { attrs.put( - OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS, + OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS, StringUtils.join(edxData.blacklistChapters, Constants.LIST_SEPARATOR_CHAR)); } if (!CollectionUtils.isEmpty(edxData.permissionComponents)) { attrs.put( - OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS, + OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS, StringUtils.join(edxData.permissionComponents, Constants.LIST_SEPARATOR_CHAR)); } attrs.put( - OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED, + OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED, (edxData.banningEnabled) ? Constants.TRUE_STRING : Constants.FALSE_STRING); - return new SebRestriction( + return new SEBRestriction( examId, edxData.configKeys, edxData.browserExamKeys, diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SebClientConfig.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SEBClientConfig.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SebClientConfig.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SEBClientConfig.java index 7f4b3806..82013905 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SebClientConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/sebconfig/SEBClientConfig.java @@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gbl.model.Domain.SEB_CLIENT_CONFIGURATION; import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.model.GrantEntity; -public final class SebClientConfig implements GrantEntity, Activatable { +public final class SEBClientConfig implements GrantEntity, Activatable { public static final String ATTR_CONFIG_PURPOSE = "sebConfigPurpose"; public static final String ATTR_FALLBACK = "sebServerFallback "; @@ -106,7 +106,7 @@ public final class SebClientConfig implements GrantEntity, Activatable { public final Boolean active; @JsonCreator - public SebClientConfig( + public SEBClientConfig( @JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_ID) final Long id, @JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_INSTITUTION_ID) final Long institutionId, @JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_NAME) final String name, @@ -144,7 +144,7 @@ public final class SebClientConfig implements GrantEntity, Activatable { this.active = active; } - public SebClientConfig(final Long institutionId, final POSTMapper postParams) { + public SEBClientConfig(final Long institutionId, final POSTMapper postParams) { this.id = null; this.institutionId = institutionId; this.name = postParams.getString(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME); @@ -271,7 +271,7 @@ public final class SebClientConfig implements GrantEntity, Activatable { @Override public String toString() { - final StringBuilder sb = new StringBuilder("SebClientConfig{"); + final StringBuilder sb = new StringBuilder("SEBClientConfig{"); sb.append("id=").append(this.id); sb.append(", institutionId=").append(this.institutionId); sb.append(", name='").append(this.name).append('\''); @@ -293,7 +293,7 @@ public final class SebClientConfig implements GrantEntity, Activatable { @Override public Entity printSecureCopy() { - return new SebClientConfig( + return new SEBClientConfig( this.id, this.institutionId, this.name, @@ -313,8 +313,8 @@ public final class SebClientConfig implements GrantEntity, Activatable { this.active); } - public static SebClientConfig createNew(final Long institutionId) { - return new SebClientConfig( + public static SEBClientConfig createNew(final Long institutionId) { + return new SEBClientConfig( null, institutionId, null, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ConfigTemplateForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ConfigTemplateForm.java index 71113434..76ebeb9f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ConfigTemplateForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ConfigTemplateForm.java @@ -141,7 +141,7 @@ public class ConfigTemplateForm implements TemplateComposer { formContext.getParent(), titleKey); - // The SebClientConfig form + // The SEBClientConfig form final FormHandle formHandle = this.pageService.formBuilder( formContext.copyOf(content)) .readonly(isReadonly) @@ -292,7 +292,7 @@ public class ConfigTemplateForm implements TemplateComposer { .newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_CREATE_CONFIG) .withEntityKey(entityKey) - .withExec(SebExamConfigCreationPopup.configCreationFunction( + .withExec(SEBExamConfigCreationPopup.configCreationFunction( this.pageService, pageContext .withAttribute( diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java index 31b4ece2..c9ab06dd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java @@ -62,10 +62,10 @@ import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent; import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService; -import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigDownload; +import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamConfigDownload; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckSebRestriction; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckSEBRestriction; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteExamConfigMapping; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteIndicator; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam; @@ -248,9 +248,9 @@ public class ExamForm implements TemplateComposer { final boolean editable = examStatus == ExamStatus.UP_COMING || examStatus == ExamStatus.RUNNING && currentUser.get().hasRole(UserRole.EXAM_ADMIN); - final boolean sebRestrictionAvailable = testSebRestrictionAPI(exam); + final boolean sebRestrictionAvailable = testSEBRestrictionAPI(exam); final boolean isRestricted = readonly && sebRestrictionAvailable && this.restService - .getBuilder(CheckSebRestriction.class) + .getBuilder(CheckSEBRestriction.class) .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) .call() .onError(e -> log.error("Unexpected error while trying to verify seb restriction settings: ", e)) @@ -393,9 +393,9 @@ public class ExamForm implements TemplateComposer { .newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS) .withEntityKey(entityKey) - .withExec(ExamSebRestrictionSettings.settingsFunction(this.pageService)) + .withExec(ExamSEBRestrictionSettings.settingsFunction(this.pageService)) .withAttribute( - ExamSebRestrictionSettings.PAGE_CONTEXT_ATTR_LMS_TYPE, + ExamSEBRestrictionSettings.PAGE_CONTEXT_ATTR_LMS_TYPE, this.restService.getBuilder(GetLmsSetup.class) .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId)) .call() @@ -406,13 +406,13 @@ public class ExamForm implements TemplateComposer { .newAction(ActionDefinition.EXAM_ENABLE_SEB_RESTRICTION) .withEntityKey(entityKey) - .withExec(action -> ExamSebRestrictionSettings.setSebRestriction(action, true, this.restService)) + .withExec(action -> ExamSEBRestrictionSettings.setSEBRestriction(action, true, this.restService)) .publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData && BooleanUtils.isFalse(isRestricted)) .newAction(ActionDefinition.EXAM_DISABLE_SEB_RESTRICTION) .withEntityKey(entityKey) - .withExec(action -> ExamSebRestrictionSettings.setSebRestriction(action, false, this.restService)) + .withExec(action -> ExamSEBRestrictionSettings.setSEBRestriction(action, false, this.restService)) .publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData && BooleanUtils.isTrue(isRestricted)); @@ -583,14 +583,14 @@ public class ExamForm implements TemplateComposer { private PageAction importExam( final PageAction action, final FormHandle formHandle, - final boolean applySebRestriction) { + final boolean applySEBRestriction) { // process normal save first final PageAction processFormSave = formHandle.processFormSave(action); // when okay and the exam sebRestriction is true - if (applySebRestriction) { - ExamSebRestrictionSettings.setSebRestriction( + if (applySEBRestriction) { + ExamSEBRestrictionSettings.setSEBRestriction( processFormSave, true, this.restService, @@ -600,7 +600,7 @@ public class ExamForm implements TemplateComposer { return processFormSave; } - private boolean testSebRestrictionAPI(final Exam exam) { + private boolean testSEBRestrictionAPI(final Exam exam) { return this.restService.getBuilder(GetLmsSetup.class) .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId)) .call() @@ -656,7 +656,7 @@ public class ExamForm implements TemplateComposer { final String downloadURL = this.downloadService.createDownloadURL( selection.modelId, action.pageContext().getParentEntityKey().modelId, - SebExamConfigDownload.class, + SEBExamConfigDownload.class, this.downloadFileName); urlLauncher.openURL(downloadURL); } @@ -701,7 +701,7 @@ public class ExamForm implements TemplateComposer { final EntityKey examConfigMappingKey = action.getSingleSelection(); if (examConfigMappingKey != null) { action.withEntityKey(examConfigMappingKey); - return SebExamConfigForm + return SEBExamConfigForm .getConfigKeyFunction(this.pageService) .apply(action); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamList.java index dcdfa841..db82db77 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamList.java @@ -134,7 +134,7 @@ public class ExamList implements TemplateComposer { final PageActionBuilder actionBuilder = this.pageService .pageActionBuilder(pageContext.clearEntityKeys()); - final BooleanSupplier isSebAdmin = + final BooleanSupplier isSEBAdmin = () -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN); final Function institutionNameFunction = @@ -150,7 +150,7 @@ public class ExamList implements TemplateComposer { .withStaticFilter(Exam.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING) .withColumnIf( - isSebAdmin, + isSEBAdmin, () -> new ColumnDefinition( Domain.EXAM.ATTR_INSTITUTION_ID, COLUMN_TITLE_INSTITUTION_KEY, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebRestrictionSettings.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSEBRestrictionSettings.java similarity index 84% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebRestrictionSettings.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSEBRestrictionSettings.java index d94983ed..660212c1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebRestrictionSettings.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSEBRestrictionSettings.java @@ -25,8 +25,8 @@ import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.util.Tuple; import ch.ethz.seb.sebserver.gbl.util.Utils; @@ -41,13 +41,13 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService; import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog; import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ActivateSebRestriction; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeactivateSebRestriction; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ActivateSEBRestriction; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeactivateSEBRestriction; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetCourseChapters; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetSebRestriction; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveSebRestriction; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetSEBRestriction; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveSEBRestriction; -public class ExamSebRestrictionSettings { +public class ExamSEBRestrictionSettings { private final static LocTextKey SEB_RESTRICTION_ERROR = new LocTextKey("sebserver.error.exam.seb.restriction"); @@ -85,7 +85,7 @@ public class ExamSebRestrictionSettings { .setDialogWidth(740) .setDialogHeight(400); - final SebRestrictionPropertiesForm bindFormContext = new SebRestrictionPropertiesForm( + final SEBRestrictionPropertiesForm bindFormContext = new SEBRestrictionPropertiesForm( pageService, action.pageContext()); @@ -117,30 +117,30 @@ public class ExamSebRestrictionSettings { final EntityKey entityKey = pageContext.getEntityKey(); final LmsType lmsType = getLmsType(pageContext); - SebRestriction bodyValue = null; + SEBRestriction bodyValue = null; try { final Form form = formHandle.getForm(); final Collection browserKeys = Utils.getListOfLines( - form.getFieldValue(SebRestriction.ATTR_BROWSER_KEYS)); + form.getFieldValue(SEBRestriction.ATTR_BROWSER_KEYS)); final Map additionalAttributes = new HashMap<>(); if (lmsType == LmsType.OPEN_EDX) { additionalAttributes.put( - OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS, - form.getFieldValue(OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS)); + OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS, + form.getFieldValue(OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS)); additionalAttributes.put( - OpenEdxSebRestriction.ATTR_WHITELIST_PATHS, - form.getFieldValue(OpenEdxSebRestriction.ATTR_WHITELIST_PATHS)); + OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS, + form.getFieldValue(OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS)); additionalAttributes.put( - OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED, - form.getFieldValue(OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED)); + OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED, + form.getFieldValue(OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED)); additionalAttributes.put( - OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS, + OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS, Utils.convertCarriageReturnToListSeparator( - form.getFieldValue(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS))); + form.getFieldValue(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS))); } - bodyValue = new SebRestriction( + bodyValue = new SEBRestriction( Long.parseLong(entityKey.modelId), null, browserKeys, @@ -152,7 +152,7 @@ public class ExamSebRestrictionSettings { return !pageService .getRestService() - .getBuilder(SaveSebRestriction.class) + .getBuilder(SaveSEBRestriction.class) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .withBody(bodyValue) .call() @@ -160,13 +160,13 @@ public class ExamSebRestrictionSettings { .hasError(); } - private static final class SebRestrictionPropertiesForm + private static final class SEBRestrictionPropertiesForm implements ModalInputDialogComposer> { private final PageService pageService; private final PageContext pageContext; - protected SebRestrictionPropertiesForm( + protected SEBRestrictionPropertiesForm( final PageService pageService, final PageContext pageContext) { @@ -188,8 +188,8 @@ public class ExamSebRestrictionSettings { .getWidgetFactory() .createPopupScrollComposite(parent); - final SebRestriction sebRestriction = restService - .getBuilder(GetSebRestriction.class) + final SEBRestriction sebRestriction = restService + .getBuilder(GetSEBRestriction.class) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .call() .getOrThrow(); @@ -205,7 +205,7 @@ public class ExamSebRestrictionSettings { .copyOf(content) .clearEntityKeys(); - final FormHandle formHandle = this.pageService.formBuilder( + final FormHandle formHandle = this.pageService.formBuilder( formContext) .withDefaultSpanInput(6) .withEmptyCellSeparation(false) @@ -220,14 +220,14 @@ public class ExamSebRestrictionSettings { .readonly(true)) .addField(FormBuilder.text( - SebRestriction.ATTR_CONFIG_KEYS, + SEBRestriction.ATTR_CONFIG_KEYS, SEB_RESTRICTION_FORM_CONFIG_KEYS, StringUtils.join(sebRestriction.getConfigKeys(), Constants.CARRIAGE_RETURN)) .asArea(50) .readonly(true)) .addField(FormBuilder.text( - SebRestriction.ATTR_BROWSER_KEYS, + SEBRestriction.ATTR_BROWSER_KEYS, SEB_RESTRICTION_FORM_BROWSER_KEYS, StringUtils.join(sebRestriction.getBrowserExamKeys(), Constants.CARRIAGE_RETURN)) .asArea()) @@ -235,31 +235,31 @@ public class ExamSebRestrictionSettings { .addFieldIf( () -> lmsType == LmsType.OPEN_EDX, () -> FormBuilder.multiCheckboxSelection( - OpenEdxSebRestriction.ATTR_WHITELIST_PATHS, + OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS, SEB_RESTRICTION_FORM_EDX_WHITE_LIST_PATHS, sebRestriction.getAdditionalProperties() - .get(OpenEdxSebRestriction.ATTR_WHITELIST_PATHS), + .get(OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS), resourceService::sebRestrictionWhiteListResources)) .addFieldIf( () -> chapters == null && lmsType == LmsType.OPEN_EDX, () -> FormBuilder.text( - OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS, + OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS, SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS, Utils.convertListSeparatorToCarriageReturn( sebRestriction .getAdditionalProperties() - .get(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS))) + .get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS))) .asArea()) .addFieldIf( () -> chapters != null && lmsType == LmsType.OPEN_EDX, () -> FormBuilder.multiCheckboxSelection( - OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS, + OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS, SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS, sebRestriction .getAdditionalProperties() - .get(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS), + .get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS), () -> chapters.chapters .stream() .map(chapter -> new Tuple<>(chapter.id, chapter.name)) @@ -268,20 +268,20 @@ public class ExamSebRestrictionSettings { .addFieldIf( () -> lmsType == LmsType.OPEN_EDX, () -> FormBuilder.multiCheckboxSelection( - OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS, + OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS, SEB_RESTRICTION_FORM_EDX_PERMISSIONS, sebRestriction.getAdditionalProperties() - .get(OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS), + .get(OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS), resourceService::sebRestrictionPermissionResources)) .addFieldIf( () -> lmsType == LmsType.OPEN_EDX, () -> FormBuilder.checkbox( - OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED, + OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED, SEB_RESTRICTION_FORM_EDX_USER_BANNING_ENABLED, sebRestriction .getAdditionalProperties() - .get(OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED))) + .get(OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED))) .build(); @@ -298,27 +298,27 @@ public class ExamSebRestrictionSettings { } } - public static PageAction setSebRestriction( + public static PageAction setSEBRestriction( final PageAction action, final boolean activateRestriction, final RestService restService) { - return setSebRestriction( + return setSEBRestriction( action, activateRestriction, restService, error -> action.pageContext().notifyError(SEB_RESTRICTION_ERROR, error)); } - public static PageAction setSebRestriction( + public static PageAction setSEBRestriction( final PageAction action, final boolean activateRestriction, final RestService restService, final Consumer errorHandler) { restService.getBuilder((activateRestriction) - ? ActivateSebRestriction.class - : DeactivateSebRestriction.class) + ? ActivateSEBRestriction.class + : DeactivateSEBRestriction.class) .withURIVariable( API.PARAM_MODEL_ID, action.getEntityKey().modelId) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringClientConnection.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringClientConnection.java index 3ca8a2a3..310e3b3a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringClientConnection.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringClientConnection.java @@ -84,7 +84,7 @@ public class MonitoringClientConnection implements TemplateComposer { private final ResourceService resourceService; private final I18nSupport i18nSupport; private final InstructionProcessor instructionProcessor; - private final SebClientLogDetailsPopup sebClientLogDetailsPopup; + private final SEBClientLogDetailsPopup sebClientLogDetailsPopup; private final long pollInterval; private final int pageSize; @@ -97,7 +97,7 @@ public class MonitoringClientConnection implements TemplateComposer { final PageService pageService, final ResourceService resourceService, final InstructionProcessor instructionProcessor, - final SebClientLogDetailsPopup sebClientLogDetailsPopup, + final SEBClientLogDetailsPopup sebClientLogDetailsPopup, @Value("${sebserver.gui.webservice.poll-interval:500}") final long pollInterval, @Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) { @@ -243,7 +243,7 @@ public class MonitoringClientConnection implements TemplateComposer { .newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_QUIT) .withConfirm(() -> CONFIRM_QUIT) .withExec(action -> { - this.instructionProcessor.propagateSebQuitInstruction( + this.instructionProcessor.propagateSEBQuitInstruction( exam.id, connectionToken, pageContext); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java index 9eb2419d..ae8c311d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java @@ -181,7 +181,7 @@ public class MonitoringRunningExam implements TemplateComposer { .newAction(ActionDefinition.MONITOR_EXAM_QUIT_ALL) .withEntityKey(entityKey) .withConfirm(() -> CONFIRM_QUIT_ALL) - .withExec(action -> this.quitSebClients(action, clientTable, true)) + .withExec(action -> this.quitSEBClients(action, clientTable, true)) .noEventPropagation() .publishIf(privilege) @@ -190,7 +190,7 @@ public class MonitoringRunningExam implements TemplateComposer { .withConfirm(() -> CONFIRM_QUIT_SELECTED) .withSelect( () -> this.selectionForQuitInstruction(clientTable), - action -> this.quitSebClients(action, clientTable, false), + action -> this.quitSEBClients(action, clientTable, false), EMPTY_ACTIVE_SELECTION_TEXT_KEY) .noEventPropagation() .publishIf(privilege, false) @@ -200,7 +200,7 @@ public class MonitoringRunningExam implements TemplateComposer { .withConfirm(() -> CONFIRM_DISABLE_SELECTED) .withSelect( clientTable::getSelection, - action -> this.disableSebClients(action, clientTable, false), + action -> this.disableSEBClients(action, clientTable, false), EMPTY_SELECTION_TEXT_KEY) .noEventPropagation() .publishIf(privilege, false); @@ -311,12 +311,12 @@ public class MonitoringRunningExam implements TemplateComposer { return clientTable.getSelection(); } - private PageAction quitSebClients( + private PageAction quitSEBClients( final PageAction action, final ClientConnectionTable clientTable, final boolean all) { - this.instructionProcessor.propagateSebQuitInstruction( + this.instructionProcessor.propagateSEBQuitInstruction( clientTable.getExam().id, statesPredicate -> clientTable.getConnectionTokens( statesPredicate, @@ -328,7 +328,7 @@ public class MonitoringRunningExam implements TemplateComposer { return action; } - private PageAction disableSebClients( + private PageAction disableSEBClients( final PageAction action, final ClientConnectionTable clientTable, final boolean all) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java index 5c1456c6..8f94aeaa 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java @@ -150,7 +150,7 @@ public class QuizLookupList implements TemplateComposer { final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(pageContext.clearEntityKeys()); - final BooleanSupplier isSebAdmin = + final BooleanSupplier isSEBAdmin = () -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN); final Function institutionNameFunction = @@ -163,7 +163,7 @@ public class QuizLookupList implements TemplateComposer { .withPaging(this.pageSize) .withColumnIf( - isSebAdmin, + isSEBAdmin, () -> new ColumnDefinition( QuizData.QUIZ_ATTR_INSTITUTION_ID, INSTITUTION_TEXT_KEY, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java similarity index 88% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigForm.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java index fa0d7bdd..d08b4a39 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java @@ -8,8 +8,10 @@ package ch.ethz.seb.sebserver.gui.content; -import ch.ethz.seb.sebserver.gbl.Constants; -import ch.ethz.seb.sebserver.gui.service.page.PageMessageException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.rap.rwt.RWT; @@ -21,11 +23,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.EntityKey; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition; @@ -34,10 +37,11 @@ import ch.ethz.seb.sebserver.gui.form.FormHandle; import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport; import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey; import ch.ethz.seb.sebserver.gui.service.page.PageContext; +import ch.ethz.seb.sebserver.gui.service.page.PageMessageException; import ch.ethz.seb.sebserver.gui.service.page.PageService; import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService; -import ch.ethz.seb.sebserver.gui.service.remote.download.SebClientConfigDownload; +import ch.ethz.seb.sebserver.gui.service.remote.download.SEBClientConfigDownload; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.DeactivateClientConfig; @@ -48,14 +52,10 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.EntityGrantCheck; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - @Lazy @Component @GuiProfile -public class SebClientConfigForm implements TemplateComposer { +public class SEBClientConfigForm implements TemplateComposer { private static final LocTextKey FORM_TITLE_NEW = new LocTextKey("sebserver.clientconfig.form.title.new"); @@ -94,15 +94,14 @@ public class SebClientConfigForm implements TemplateComposer { new LocTextKey("sebserver.clientconfig.form.encryptSecret.confirm"); private static final Set FALLBACK_ATTRIBUTES = new HashSet<>(Arrays.asList( - SebClientConfig.ATTR_FALLBACK_START_URL, - SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, - SebClientConfig.ATTR_FALLBACK_ATTEMPTS, - SebClientConfig.ATTR_FALLBACK_TIMEOUT, - SebClientConfig.ATTR_FALLBACK_PASSWORD, - SebClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, - SebClientConfig.ATTR_QUIT_PASSWORD, - SebClientConfig.ATTR_QUIT_PASSWORD_CONFIRM - )); + SEBClientConfig.ATTR_FALLBACK_START_URL, + SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, + SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, + SEBClientConfig.ATTR_FALLBACK_TIMEOUT, + SEBClientConfig.ATTR_FALLBACK_PASSWORD, + SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, + SEBClientConfig.ATTR_QUIT_PASSWORD, + SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM)); private static final String FALLBACK_DEFAULT_TIME = String.valueOf(2 * Constants.MINUTE_IN_MILLIS); private static final String FALLBACK_DEFAULT_ATTEMPTS = String.valueOf(5); @@ -114,7 +113,7 @@ public class SebClientConfigForm implements TemplateComposer { private final DownloadService downloadService; private final String downloadFileName; - protected SebClientConfigForm( + protected SEBClientConfigForm( final PageService pageService, final RestService restService, final CurrentUser currentUser, @@ -140,8 +139,8 @@ public class SebClientConfigForm implements TemplateComposer { final boolean isNew = entityKey == null; // get data or create new. Handle error if happen - final SebClientConfig clientConfig = (isNew) - ? SebClientConfig.createNew((parentEntityKey != null) + final SEBClientConfig clientConfig = (isNew) + ? SEBClientConfig.createNew((parentEntityKey != null) ? Long.valueOf(parentEntityKey.modelId) : user.institutionId) : this.restService @@ -167,8 +166,8 @@ public class SebClientConfigForm implements TemplateComposer { formContext.getParent(), titleKey); - // The SebClientConfig form - final FormHandle formHandle = this.pageService.formBuilder( + // The SEBClientConfig form + final FormHandle formHandle = this.pageService.formBuilder( formContext.copyOf(content)) .readonly(isReadonly) .putStaticValueIf(() -> !isNew, @@ -192,12 +191,12 @@ public class SebClientConfigForm implements TemplateComposer { .mandatory(!isReadonly)) .addField(FormBuilder.singleSelection( - SebClientConfig.ATTR_CONFIG_PURPOSE, + SEBClientConfig.ATTR_CONFIG_PURPOSE, CLIENT_PURPOSE_TEXT_KEY, clientConfig.configPurpose != null ? clientConfig.configPurpose.name() - : SebClientConfig.ConfigPurpose.START_EXAM.name(), - () -> pageService.getResourceService().sebClientConfigPurposeResources()) + : SEBClientConfig.ConfigPurpose.START_EXAM.name(), + () -> this.pageService.getResourceService().sebClientConfigPurposeResources()) .mandatory(!isReadonly)) .withDefaultSpanInput(3) @@ -210,21 +209,20 @@ public class SebClientConfigForm implements TemplateComposer { .addFieldIf( () -> !isReadonly, () -> FormBuilder.password( - SebClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, + SEBClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, FORM_CONFIRM_ENCRYPT_SECRET_TEXT_KEY, clientConfig.getEncryptSecret())) .addField(FormBuilder.checkbox( - SebClientConfig.ATTR_FALLBACK, + SEBClientConfig.ATTR_FALLBACK, FALLBACK_TEXT_KEY, clientConfig.fallback != null ? clientConfig.fallback.toString() - : Constants.FALSE_STRING) - ) + : Constants.FALSE_STRING)) .withDefaultSpanInput(5) .addField(FormBuilder.text( - SebClientConfig.ATTR_FALLBACK_START_URL, + SEBClientConfig.ATTR_FALLBACK_START_URL, FALLBACK_URL_TEXT_KEY, clientConfig.fallbackStartURL) .mandatory(!isReadonly)) @@ -232,7 +230,7 @@ public class SebClientConfigForm implements TemplateComposer { .withDefaultSpanEmptyCell(1) .withDefaultSpanInput(2) .addField(FormBuilder.text( - SebClientConfig.ATTR_FALLBACK_ATTEMPTS, + SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, FALLBACK_ATTEMPTS_TEXT_KEY, clientConfig.fallbackAttempts != null ? String.valueOf(clientConfig.fallbackAttempts) @@ -244,7 +242,7 @@ public class SebClientConfigForm implements TemplateComposer { .withEmptyCellSeparation(false) .withDefaultSpanLabel(1) .addField(FormBuilder.text( - SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, + SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, FALLBACK_ATTEMPT_INTERVAL_TEXT_KEY, clientConfig.fallbackAttemptInterval != null ? String.valueOf(clientConfig.fallbackAttemptInterval) @@ -256,7 +254,7 @@ public class SebClientConfigForm implements TemplateComposer { .withDefaultSpanEmptyCell(1) .withDefaultSpanLabel(2) .addField(FormBuilder.text( - SebClientConfig.ATTR_FALLBACK_TIMEOUT, + SEBClientConfig.ATTR_FALLBACK_TIMEOUT, FALLBACK_TIMEOUT_TEXT_KEY, clientConfig.fallbackTimeout != null ? String.valueOf(clientConfig.fallbackTimeout) @@ -269,14 +267,14 @@ public class SebClientConfigForm implements TemplateComposer { .withDefaultSpanInput(2) .withDefaultSpanLabel(2) .addField(FormBuilder.password( - SebClientConfig.ATTR_FALLBACK_PASSWORD, + SEBClientConfig.ATTR_FALLBACK_PASSWORD, FALLBACK_PASSWORD_TEXT_KEY, clientConfig.getFallbackPassword())) .withEmptyCellSeparation(false) .withDefaultSpanLabel(1) .addField(FormBuilder.password( - SebClientConfig.ATTR_QUIT_PASSWORD, + SEBClientConfig.ATTR_QUIT_PASSWORD, QUIT_PASSWORD_TEXT_KEY, clientConfig.getQuitPassword())) @@ -287,7 +285,7 @@ public class SebClientConfigForm implements TemplateComposer { .addFieldIf( () -> !isReadonly, () -> FormBuilder.password( - SebClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, + SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, FALLBACK_PASSWORD_CONFIRM_TEXT_KEY, clientConfig.getFallbackPasswordConfirm())) @@ -296,33 +294,29 @@ public class SebClientConfigForm implements TemplateComposer { .addFieldIf( () -> !isReadonly, () -> FormBuilder.password( - SebClientConfig.ATTR_QUIT_PASSWORD_CONFIRM, + SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM, QUIT_PASSWORD_CONFIRM_TEXT_KEY, clientConfig.getQuitPasswordConfirm())) - .buildFor((isNew) ? this.restService.getRestCall(NewClientConfig.class) : this.restService.getRestCall(SaveClientConfig.class)); formHandle.process( FALLBACK_ATTRIBUTES::contains, - ffa -> ffa.setVisible(BooleanUtils.isTrue(clientConfig.fallback)) - ); + ffa -> ffa.setVisible(BooleanUtils.isTrue(clientConfig.fallback))); - formHandle.getForm().getFieldInput(SebClientConfig.ATTR_FALLBACK) + formHandle.getForm().getFieldInput(SEBClientConfig.ATTR_FALLBACK) .addListener(SWT.Selection, event -> formHandle.process( FALLBACK_ATTRIBUTES::contains, ffa -> { - boolean selected = ((Button) event.widget).getSelection(); + final boolean selected = ((Button) event.widget).getSelection(); ffa.setVisible(selected); if (!selected && ffa.hasError()) { ffa.resetError(); ffa.setStringValue(StringUtils.EMPTY); } - } - )); - + })); final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class); this.pageService.pageActionBuilder(formContext.clearEntityKeys()) @@ -339,7 +333,7 @@ public class SebClientConfigForm implements TemplateComposer { .withExec(action -> { final String downloadURL = this.downloadService.createDownloadURL( entityKey.modelId, - SebClientConfigDownload.class, + SEBClientConfigDownload.class, this.downloadFileName); urlLauncher.openURL(downloadURL); return action; @@ -375,11 +369,11 @@ public class SebClientConfigForm implements TemplateComposer { .publishIf(() -> !isReadonly); } - private void checkNaturalNumber(String value) { + private void checkNaturalNumber(final String value) { if (StringUtils.isBlank(value)) { return; } - long num = Long.parseLong(value); + final long num = Long.parseLong(value); if (num < 0) { throw new PageMessageException("Number must be positive"); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigList.java similarity index 95% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigList.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigList.java index 461ae3f0..37882509 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientConfigList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigList.java @@ -21,7 +21,7 @@ import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.Entity; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.model.user.UserRole; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; @@ -46,7 +46,7 @@ import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType; @Lazy @Component @GuiProfile -public class SebClientConfigList implements TemplateComposer { +public class SEBClientConfigList implements TemplateComposer { private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION = new LocTextKey("sebserver.clientconfig.list.action.no.modify.privilege"); @@ -69,7 +69,7 @@ public class SebClientConfigList implements TemplateComposer { private final TableFilterAttribute dateFilter = new TableFilterAttribute( CriteriaType.DATE, - SebClientConfig.FILTER_ATTR_CREATION_DATE, + SEBClientConfig.FILTER_ATTR_CREATION_DATE, DateTime.now(DateTimeZone.UTC) .minusYears(1) .toString(Constants.DEFAULT_DATE_TIME_FORMAT)); @@ -81,7 +81,7 @@ public class SebClientConfigList implements TemplateComposer { private final ResourceService resourceService; private final int pageSize; - protected SebClientConfigList( + protected SEBClientConfigList( final PageService pageService, final RestService restService, final CurrentUser currentUser, @@ -117,7 +117,7 @@ public class SebClientConfigList implements TemplateComposer { this.pageService.pageActionBuilder(pageContext.clearEntityKeys()); // table - final EntityTable table = + final EntityTable table = this.pageService.entityTableBuilder(this.restService.getRestCall(GetClientConfigPage.class)) .withEmptyMessage(EMPTY_LIST_TEXT_KEY) .withPaging(this.pageSize) @@ -131,7 +131,7 @@ public class SebClientConfigList implements TemplateComposer { .withColumn(new ColumnDefinition<>( Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, NAME_TEXT_KEY, - SebClientConfig::getName) + SEBClientConfig::getName) .withFilter(this.nameFilter) .sortable()) .withColumn(new ColumnDefinition<>( @@ -139,13 +139,13 @@ public class SebClientConfigList implements TemplateComposer { new LocTextKey( "sebserver.clientconfig.list.column.date", i18nSupport.getUsersTimeZoneTitleSuffix()), - SebClientConfig::getDate) + SEBClientConfig::getDate) .withFilter(this.dateFilter) .sortable()) .withColumn(new ColumnDefinition<>( Domain.SEB_CLIENT_CONFIGURATION.ATTR_ACTIVE, ACTIVE_TEXT_KEY, - this.pageService.getResourceService(). localizedActivityFunction()) + this.pageService.getResourceService(). localizedActivityFunction()) .withFilter(this.activityFilter) .sortable()) .withDefaultAction(pageActionBuilder @@ -190,7 +190,7 @@ public class SebClientConfigList implements TemplateComposer { } - private static Function clientConfigInstitutionNameFunction( + private static Function clientConfigInstitutionNameFunction( final ResourceService resourceService) { return config -> resourceService.getInstitutionNameFunction() diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogDetailsPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogDetailsPopup.java similarity index 98% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogDetailsPopup.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogDetailsPopup.java index 99317e16..496f3649 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogDetailsPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogDetailsPopup.java @@ -37,9 +37,9 @@ import org.springframework.stereotype.Component; @Lazy @Component @GuiProfile -public class SebClientLogDetailsPopup { +public class SEBClientLogDetailsPopup { - private static final Logger log = LoggerFactory.getLogger(SebClientLogDetailsPopup.class); + private static final Logger log = LoggerFactory.getLogger(SEBClientLogDetailsPopup.class); private static final LocTextKey DETAILS_TITLE_TEXT_KEY = new LocTextKey("sebserver.seblogs.details.title"); @@ -86,7 +86,7 @@ public class SebClientLogDetailsPopup { private final I18nSupport i18nSupport; private final WidgetFactory widgetFactory; - public SebClientLogDetailsPopup( + public SEBClientLogDetailsPopup( final PageService pageService, final WidgetFactory widgetFactory) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogs.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogs.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogs.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogs.java index 8b74881d..c273ed80 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebClientLogs.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientLogs.java @@ -42,7 +42,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; @Lazy @Component @GuiProfile -public class SebClientLogs implements TemplateComposer { +public class SEBClientLogs implements TemplateComposer { private static final LocTextKey TITLE_TEXT_KEY = new LocTextKey("sebserver.seblogs.list.title"); @@ -70,12 +70,12 @@ public class SebClientLogs implements TemplateComposer { private final ResourceService resourceService; private final RestService restService; private final I18nSupport i18nSupport; - private final SebClientLogDetailsPopup sebClientLogDetailsPopup; + private final SEBClientLogDetailsPopup sebClientLogDetailsPopup; private final int pageSize; - public SebClientLogs( + public SEBClientLogs( final PageService pageService, - final SebClientLogDetailsPopup sebClientLogDetailsPopup, + final SEBClientLogDetailsPopup sebClientLogDetailsPopup, @Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) { this.pageService = pageService; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigCreationPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigCreationPopup.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigCreationPopup.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigCreationPopup.java index 12e87325..e9ebefe7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigCreationPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigCreationPopup.java @@ -35,7 +35,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.CopyConfiguration; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig; -final class SebExamConfigCreationPopup { +final class SEBExamConfigCreationPopup { static final LocTextKey FORM_COPY_TEXT_KEY = new LocTextKey("sebserver.examconfig.action.copy.dialog"); @@ -174,16 +174,16 @@ final class SebExamConfigCreationPopup { entityKey.getModelId()) .addField(FormBuilder.text( Domain.CONFIGURATION_NODE.ATTR_NAME, - SebExamConfigForm.FORM_NAME_TEXT_KEY)) + SEBExamConfigForm.FORM_NAME_TEXT_KEY)) .addField(FormBuilder.text( Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION, - SebExamConfigForm.FORM_DESCRIPTION_TEXT_KEY) + SEBExamConfigForm.FORM_DESCRIPTION_TEXT_KEY) .asArea()) .addFieldIf( () -> !this.copyAsTemplate && !this.createFromTemplate, () -> FormBuilder.checkbox( ConfigCreationInfo.ATTR_COPY_WITH_HISTORY, - SebExamConfigForm.FORM_HISTORY_TEXT_KEY)) + SEBExamConfigForm.FORM_HISTORY_TEXT_KEY)) .build(); return () -> formHandle; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigForm.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigForm.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigForm.java index e2bb8e55..2895d0e4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigForm.java @@ -49,7 +49,7 @@ import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog; import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService; -import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigPlaintextDownload; +import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamConfigPlaintextDownload; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingNames; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingsPage; @@ -67,7 +67,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant; @Lazy @Component @GuiProfile -public class SebExamConfigForm implements TemplateComposer { +public class SEBExamConfigForm implements TemplateComposer { static final LocTextKey FORM_TITLE_NEW = new LocTextKey("sebserver.examconfig.form.title.new"); @@ -107,7 +107,7 @@ public class SebExamConfigForm implements TemplateComposer { private final DownloadService downloadService; private final String downloadFileName; - protected SebExamConfigForm( + protected SEBExamConfigForm( final PageService pageService, final CurrentUser currentUser, final DownloadService downloadService, @@ -228,7 +228,7 @@ public class SebExamConfigForm implements TemplateComposer { .newAction(ActionDefinition.SEB_EXAM_CONFIG_COPY_CONFIG) .withEntityKey(entityKey) - .withExec(SebExamConfigCreationPopup.configCreationFunction( + .withExec(SEBExamConfigCreationPopup.configCreationFunction( this.pageService, actionContext .withEntityKey(entityKey) @@ -243,7 +243,7 @@ public class SebExamConfigForm implements TemplateComposer { .newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE) .withEntityKey(entityKey) - .withExec(SebExamConfigCreationPopup.configCreationFunction( + .withExec(SEBExamConfigCreationPopup.configCreationFunction( this.pageService, pageContext.withAttribute( PageContext.AttributeKeys.COPY_AS_TEMPLATE, @@ -256,7 +256,7 @@ public class SebExamConfigForm implements TemplateComposer { .withExec(action -> { final String downloadURL = this.downloadService.createDownloadURL( entityKey.modelId, - SebExamConfigPlaintextDownload.class, + SEBExamConfigPlaintextDownload.class, this.downloadFileName); urlLauncher.openURL(downloadURL); return action; @@ -266,13 +266,13 @@ public class SebExamConfigForm implements TemplateComposer { .newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY) .withEntityKey(entityKey) - .withExec(SebExamConfigForm.getConfigKeyFunction(this.pageService)) + .withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService)) .noEventPropagation() .publishIf(() -> modifyGrant && isReadonly) .newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_EXISTING_CONFIG) .withEntityKey(entityKey) - .withExec(SebExamConfigImportPopup.importFunction(this.pageService, false)) + .withExec(SEBExamConfigImportPopup.importFunction(this.pageService, false)) .noEventPropagation() .publishIf(() -> modifyGrant && isReadonly && !isAttachedToExam) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigImportPopup.java similarity index 95% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigImportPopup.java index 80c73603..100e4342 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigImportPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigImportPopup.java @@ -49,9 +49,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Im import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportNewExamConfig; import ch.ethz.seb.sebserver.gui.widget.FileUploadSelection; -final class SebExamConfigImportPopup { +final class SEBExamConfigImportPopup { - private static final Logger log = LoggerFactory.getLogger(SebExamConfigImportPopup.class); + private static final Logger log = LoggerFactory.getLogger(SEBExamConfigImportPopup.class); private final static PageMessageException MISSING_PASSWORD = new PageMessageException( new LocTextKey("sebserver.examconfig.action.import.missing-password")); @@ -74,7 +74,7 @@ final class SebExamConfigImportPopup { newConfig); dialog.open( - SebExamConfigForm.FORM_IMPORT_TEXT_KEY, + SEBExamConfigForm.FORM_IMPORT_TEXT_KEY, (Predicate>) formHandle -> doImport( pageService, formHandle, @@ -181,7 +181,7 @@ final class SebExamConfigImportPopup { .call(); if (!configuration.hasError()) { - context.publishInfo(SebExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY); + context.publishInfo(SEBExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY); if (newConfig) { final PageAction action = pageService.pageActionBuilder(context) @@ -214,7 +214,7 @@ final class SebExamConfigImportPopup { } formHandle.getContext().notifyError( - SebExamConfigForm.FORM_TITLE, + SEBExamConfigForm.FORM_TITLE, configuration.getError()); } @@ -228,7 +228,7 @@ final class SebExamConfigImportPopup { return false; } catch (final Exception e) { - formHandle.getContext().notifyError(SebExamConfigForm.FORM_TITLE, e); + formHandle.getContext().notifyError(SEBExamConfigForm.FORM_TITLE, e); return true; } } @@ -264,7 +264,7 @@ final class SebExamConfigImportPopup { .readonly(false) .addField(FormBuilder.fileUpload( API.IMPORT_FILE_ATTR_NAME, - SebExamConfigForm.FORM_IMPORT_SELECT_TEXT_KEY, + SEBExamConfigForm.FORM_IMPORT_SELECT_TEXT_KEY, null, API.SEB_FILE_EXTENSION)) @@ -272,24 +272,24 @@ final class SebExamConfigImportPopup { () -> this.newConfig, () -> FormBuilder.text( Domain.CONFIGURATION_NODE.ATTR_NAME, - SebExamConfigForm.FORM_NAME_TEXT_KEY)) + SEBExamConfigForm.FORM_NAME_TEXT_KEY)) .addFieldIf( () -> this.newConfig, () -> FormBuilder.text( Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION, - SebExamConfigForm.FORM_DESCRIPTION_TEXT_KEY) + SEBExamConfigForm.FORM_DESCRIPTION_TEXT_KEY) .asArea()) .addFieldIf( () -> this.newConfig && !examConfigTemplateResources.isEmpty(), () -> FormBuilder.singleSelection( Domain.CONFIGURATION_NODE.ATTR_TEMPLATE_ID, - SebExamConfigForm.FORM_TEMPLATE_TEXT_KEY, + SEBExamConfigForm.FORM_TEMPLATE_TEXT_KEY, null, resourceService::getExamConfigTemplateResources)) .addField(FormBuilder.text( API.IMPORT_PASSWORD_ATTR_NAME, - SebExamConfigForm.FORM_IMPORT_PASSWORD_TEXT_KEY, + SEBExamConfigForm.FORM_IMPORT_PASSWORD_TEXT_KEY, "").asPasswordField()) .build(); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigList.java similarity index 98% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigList.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigList.java index ea7066b3..3b11f1d7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebExamConfigList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBExamConfigList.java @@ -41,7 +41,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; @Lazy @Component @GuiProfile -public class SebExamConfigList implements TemplateComposer { +public class SEBExamConfigList implements TemplateComposer { private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION = new LocTextKey("sebserver.examconfig.list.action.no.modify.privilege"); @@ -73,7 +73,7 @@ public class SebExamConfigList implements TemplateComposer { private final ResourceService resourceService; private final int pageSize; - protected SebExamConfigList( + protected SEBExamConfigList( final PageService pageService, final RestService restService, final CurrentUser currentUser, @@ -172,7 +172,7 @@ public class SebExamConfigList implements TemplateComposer { .newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG) .withSelect( configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION), - SebExamConfigImportPopup.importFunction(this.pageService, true), + SEBExamConfigImportPopup.importFunction(this.pageService, true), EMPTY_SELECTION_TEXT_KEY) .noEventPropagation() .publishIf(examConfigGrant::im); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebSettingsForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBSettingsForm.java similarity index 96% rename from src/main/java/ch/ethz/seb/sebserver/gui/content/SebSettingsForm.java rename to src/main/java/ch/ethz/seb/sebserver/gui/content/SEBSettingsForm.java index 52d22af7..614ca21c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SebSettingsForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBSettingsForm.java @@ -47,7 +47,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurations; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SebExamConfigUndo; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; @@ -55,9 +55,9 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; @Lazy @Component @GuiProfile -public class SebSettingsForm implements TemplateComposer { +public class SEBSettingsForm implements TemplateComposer { - private static final Logger log = LoggerFactory.getLogger(SebSettingsForm.class); + private static final Logger log = LoggerFactory.getLogger(SEBSettingsForm.class); private static final String VIEW_TEXT_KEY_PREFIX = "sebserver.examconfig.props.form.views."; @@ -76,7 +76,7 @@ public class SebSettingsForm implements TemplateComposer { private final CurrentUser currentUser; private final ExamConfigurationService examConfigurationService; - protected SebSettingsForm( + protected SEBSettingsForm( final PageService pageService, final RestService restService, final CurrentUser currentUser, @@ -178,7 +178,7 @@ public class SebSettingsForm implements TemplateComposer { .newAction(ActionDefinition.SEB_EXAM_CONFIG_UNDO) .withEntityKey(entityKey) .withExec(action -> { - this.restService.getBuilder(SebExamConfigUndo.class) + this.restService.getBuilder(SEBExamConfigUndo.class) .withURIVariable(API.PARAM_MODEL_ID, configuration.getModelId()) .call() .getOrThrow(); @@ -192,7 +192,7 @@ public class SebSettingsForm implements TemplateComposer { .newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE) .withEntityKey(entityKey) - .withExec(SebExamConfigCreationPopup.configCreationFunction( + .withExec(SEBExamConfigCreationPopup.configCreationFunction( this.pageService, pageContext .withAttribute( @@ -214,7 +214,7 @@ public class SebSettingsForm implements TemplateComposer { throw e; } catch (final Exception e) { log.error("Unexpected error while trying to fetch exam configuration data and create views", e); - pageContext.notifyError(SebExamConfigForm.FORM_TITLE, e); + pageContext.notifyError(SEBExamConfigForm.FORM_TITLE, e); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/UserActivityLogs.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/UserActivityLogs.java index 99986a28..8b8229c7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/UserActivityLogs.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/UserActivityLogs.java @@ -136,7 +136,7 @@ public class UserActivityLogs implements TemplateComposer { .clearEntityKeys() .clearAttributes()); - final BooleanSupplier isSebAdmin = + final BooleanSupplier isSEBAdmin = () -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN); final Function institutionNameFunction = @@ -159,7 +159,7 @@ public class UserActivityLogs implements TemplateComposer { .withPaging(this.pageSize) .withColumnIf( - isSebAdmin, + isSEBAdmin, () -> new ColumnDefinition<>( UserActivityLog.FILTER_ATTR_INSTITUTION, INSTITUTION_TEXT_KEY, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java index b9f33e03..8547959f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java @@ -296,12 +296,12 @@ public class ActivitiesPane implements TemplateComposer { // ---- MONITORING --------------------------------------------------------------------- final boolean isSupporter = this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER); - final boolean viewSebClientLogs = this.currentUser.hasInstitutionalPrivilege( + final boolean viewSEBClientLogs = this.currentUser.hasInstitutionalPrivilege( PrivilegeType.READ, EntityType.EXAM) || this.currentUser.get().hasRole(UserRole.EXAM_SUPPORTER); - if (isSupporter || viewSebClientLogs) { + if (isSupporter || viewSEBClientLogs) { // Monitoring final TreeItem monitoring = this.widgetFactory.treeItemLocalized( navigation, @@ -320,7 +320,7 @@ public class ActivitiesPane implements TemplateComposer { } // SEB Client Logs - if (viewSebClientLogs) { + if (viewSEBClientLogs) { final TreeItem sebLogs = (isSupporter) ? this.widgetFactory.treeItemLocalized( monitoring, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/PageStateDefinitionImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/PageStateDefinitionImpl.java index 2f43138d..2e42d752 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/PageStateDefinitionImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/PageStateDefinitionImpl.java @@ -22,12 +22,12 @@ import ch.ethz.seb.sebserver.gui.content.MonitoringClientConnection; import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExam; import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExamList; import ch.ethz.seb.sebserver.gui.content.QuizLookupList; -import ch.ethz.seb.sebserver.gui.content.SebClientConfigForm; -import ch.ethz.seb.sebserver.gui.content.SebClientConfigList; -import ch.ethz.seb.sebserver.gui.content.SebClientLogs; -import ch.ethz.seb.sebserver.gui.content.SebExamConfigList; -import ch.ethz.seb.sebserver.gui.content.SebExamConfigForm; -import ch.ethz.seb.sebserver.gui.content.SebSettingsForm; +import ch.ethz.seb.sebserver.gui.content.SEBClientConfigForm; +import ch.ethz.seb.sebserver.gui.content.SEBClientConfigList; +import ch.ethz.seb.sebserver.gui.content.SEBClientLogs; +import ch.ethz.seb.sebserver.gui.content.SEBExamConfigList; +import ch.ethz.seb.sebserver.gui.content.SEBExamConfigForm; +import ch.ethz.seb.sebserver.gui.content.SEBSettingsForm; import ch.ethz.seb.sebserver.gui.content.UserAccountChangePasswordForm; import ch.ethz.seb.sebserver.gui.content.UserAccountForm; import ch.ethz.seb.sebserver.gui.content.UserAccountList; @@ -59,15 +59,15 @@ public enum PageStateDefinitionImpl implements PageStateDefinition { EXAM_EDIT(Type.FORM_EDIT, ExamForm.class, ActivityDefinition.EXAM), INDICATOR_EDIT(Type.FORM_EDIT, IndicatorForm.class, ActivityDefinition.EXAM), - SEB_CLIENT_CONFIG_LIST(Type.LIST_VIEW, SebClientConfigList.class, ActivityDefinition.SEB_CLIENT_CONFIG), - SEB_CLIENT_CONFIG_VIEW(Type.FORM_VIEW, SebClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG), - SEB_CLIENT_CONFIG_EDIT(Type.FORM_EDIT, SebClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG), + SEB_CLIENT_CONFIG_LIST(Type.LIST_VIEW, SEBClientConfigList.class, ActivityDefinition.SEB_CLIENT_CONFIG), + SEB_CLIENT_CONFIG_VIEW(Type.FORM_VIEW, SEBClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG), + SEB_CLIENT_CONFIG_EDIT(Type.FORM_EDIT, SEBClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG), - SEB_EXAM_CONFIG_LIST(Type.LIST_VIEW, SebExamConfigList.class, ActivityDefinition.SEB_EXAM_CONFIG), - SEB_EXAM_CONFIG_PROP_VIEW(Type.FORM_VIEW, SebExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG), - SEB_EXAM_CONFIG_PROP_EDIT(Type.FORM_EDIT, SebExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG), - SEB_EXAM_CONFIG_EDIT(Type.FORM_IN_TIME_EDIT, SebSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG), - SEB_EXAM_CONFIG_VIEW(Type.FORM_VIEW, SebSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG), + SEB_EXAM_CONFIG_LIST(Type.LIST_VIEW, SEBExamConfigList.class, ActivityDefinition.SEB_EXAM_CONFIG), + SEB_EXAM_CONFIG_PROP_VIEW(Type.FORM_VIEW, SEBExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG), + SEB_EXAM_CONFIG_PROP_EDIT(Type.FORM_EDIT, SEBExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG), + SEB_EXAM_CONFIG_EDIT(Type.FORM_IN_TIME_EDIT, SEBSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG), + SEB_EXAM_CONFIG_VIEW(Type.FORM_VIEW, SEBSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG), SEB_EXAM_CONFIG_TEMPLATE_LIST(Type.LIST_VIEW, ConfigTemplateList.class, ActivityDefinition.SEB_EXAM_CONFIG_TEMPLATE), @@ -85,7 +85,7 @@ public enum PageStateDefinitionImpl implements PageStateDefinition { MONITORING_CLIENT_CONNECTION(Type.FORM_VIEW, MonitoringClientConnection.class, ActivityDefinition.MONITORING_EXAMS), USER_ACTIVITY_LOGS(Type.LIST_VIEW, UserActivityLogs.class, ActivityDefinition.USER_ACTIVITY_LOGS), - SEB_CLIENT_LOGS(Type.LIST_VIEW, SebClientLogs.class, ActivityDefinition.SEB_CLIENT_LOGS) + SEB_CLIENT_LOGS(Type.LIST_VIEW, SEBClientLogs.class, ActivityDefinition.SEB_CLIENT_LOGS) ; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java index 62da1623..2576bbaa 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java @@ -20,7 +20,7 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.util.Tuple3; import ch.ethz.seb.sebserver.gbl.util.Utils; import org.apache.commons.lang3.StringUtils; @@ -40,8 +40,8 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType; import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction.PermissionComponent; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction.WhiteListPath; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction.PermissionComponent; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction.WhiteListPath; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode; @@ -658,7 +658,7 @@ public class ResourceService { } public List> sebClientConfigPurposeResources() { - return Arrays.stream(SebClientConfig.ConfigPurpose.values()) + return Arrays.stream(SEBClientConfig.ConfigPurpose.values()) .map(type -> new Tuple3<>( type.name(), this.i18nSupport.getText(SEB_CLIENT_CONFIG_PURPOSE_PREFIX + type.name()), diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebClientConfigDownload.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java similarity index 92% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebClientConfigDownload.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java index 0652ce35..72787ff3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebClientConfigDownload.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java @@ -27,14 +27,14 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig. @Lazy @Component @GuiProfile -public class SebClientConfigDownload extends AbstractDownloadServiceHandler { +public class SEBClientConfigDownload extends AbstractDownloadServiceHandler { - private static final Logger log = LoggerFactory.getLogger(SebClientConfigDownload.class); + private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class); private final RestService restService; public final String downloadFileName; - protected SebClientConfigDownload( + protected SEBClientConfigDownload( final RestService restService, @Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigDownload.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigDownload.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigDownload.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigDownload.java index 151744b6..9305be12 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigDownload.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigDownload.java @@ -26,13 +26,13 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportExamCo @Lazy @Component @GuiProfile -public class SebExamConfigDownload extends AbstractDownloadServiceHandler { +public class SEBExamConfigDownload extends AbstractDownloadServiceHandler { - private static final Logger log = LoggerFactory.getLogger(SebExamConfigDownload.class); + private static final Logger log = LoggerFactory.getLogger(SEBExamConfigDownload.class); private final RestService restService; - protected SebExamConfigDownload(final RestService restService) { + protected SEBExamConfigDownload(final RestService restService) { this.restService = restService; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigPlaintextDownload.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigPlaintextDownload.java similarity index 89% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigPlaintextDownload.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigPlaintextDownload.java index 6bbcff1c..3dd5a4be 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SebExamConfigPlaintextDownload.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBExamConfigPlaintextDownload.java @@ -26,13 +26,13 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Ex @Lazy @Component @GuiProfile -public class SebExamConfigPlaintextDownload extends AbstractDownloadServiceHandler { +public class SEBExamConfigPlaintextDownload extends AbstractDownloadServiceHandler { - private static final Logger log = LoggerFactory.getLogger(SebExamConfigPlaintextDownload.class); + private static final Logger log = LoggerFactory.getLogger(SEBExamConfigPlaintextDownload.class); private final RestService restService; - protected SebExamConfigPlaintextDownload(final RestService restService) { + protected SEBExamConfigPlaintextDownload(final RestService restService) { this.restService = restService; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java index 16deb374..67de13f7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java @@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class ActivateSebRestriction extends RestCall { +public class ActivateSEBRestriction extends RestCall { - public ActivateSebRestriction() { + public ActivateSEBRestriction() { super(new TypeKey<>( CallType.ACTIVATION_ACTIVATE, EntityType.EXAM_SEB_RESTRICTION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java index 6844a180..d7a02885 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java @@ -23,9 +23,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class CheckSebRestriction extends RestCall { +public class CheckSEBRestriction extends RestCall { - public CheckSebRestriction() { + public CheckSEBRestriction() { super(new TypeKey<>( CallType.UNDEFINED, EntityType.EXAM_SEB_RESTRICTION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java index dd2b1b64..1d327f13 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java @@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class DeactivateSebRestriction extends RestCall { +public class DeactivateSEBRestriction extends RestCall { - public DeactivateSebRestriction() { + public DeactivateSEBRestriction() { super(new TypeKey<>( CallType.ACTIVATION_DEACTIVATE, EntityType.EXAM_SEB_RESTRICTION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestriction.java similarity index 83% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestriction.java index ecdf4f19..3efbef01 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestriction.java @@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class GetSebRestriction extends RestCall { +public class GetSEBRestriction extends RestCall { - public GetSebRestriction() { + public GetSEBRestriction() { super(new TypeKey<>( CallType.GET_SINGLE, EntityType.EXAM_SEB_RESTRICTION, - new TypeReference() { + new TypeReference() { }), HttpMethod.GET, MediaType.APPLICATION_JSON_UTF8, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSebRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java similarity index 91% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSebRestriction.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java index 39b5a9a1..1cc262ce 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSebRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java @@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class SaveSebRestriction extends RestCall { +public class SaveSEBRestriction extends RestCall { - public SaveSebRestriction() { + public SaveSEBRestriction() { super(new TypeKey<>( CallType.GET_SINGLE, EntityType.EXAM_SEB_RESTRICTION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfig.java index c1cfc676..50a03cfa 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfig.java @@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class GetClientConfig extends RestCall { +public class GetClientConfig extends RestCall { public GetClientConfig() { super(new TypeKey<>( CallType.GET_SINGLE, EntityType.SEB_CLIENT_CONFIGURATION, - new TypeReference() { + new TypeReference() { }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfigPage.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfigPage.java index a37bb9bc..26c62789 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfigPage.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/GetClientConfigPage.java @@ -18,20 +18,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Page; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class GetClientConfigPage extends RestCall> { +public class GetClientConfigPage extends RestCall> { public GetClientConfigPage() { super(new TypeKey<>( CallType.GET_PAGE, EntityType.SEB_CLIENT_CONFIGURATION, - new TypeReference>() { + new TypeReference>() { }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/NewClientConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/NewClientConfig.java index 4282f9c0..af56e3c2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/NewClientConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/NewClientConfig.java @@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class NewClientConfig extends RestCall { +public class NewClientConfig extends RestCall { public NewClientConfig() { super(new TypeKey<>( CallType.NEW, EntityType.SEB_CLIENT_CONFIGURATION, - new TypeReference() { + new TypeReference() { }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java index d6cff1ce..e3884e2a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java @@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class SaveClientConfig extends RestCall { +public class SaveClientConfig extends RestCall { public SaveClientConfig() { super(new TypeKey<>( CallType.SAVE, EntityType.SEB_CLIENT_CONFIGURATION, - new TypeReference() { + new TypeReference() { }), HttpMethod.PUT, MediaType.APPLICATION_JSON_UTF8, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SebExamConfigUndo.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SEBExamConfigUndo.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SebExamConfigUndo.java rename to src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SEBExamConfigUndo.java index 9bb4b976..7ca0f79d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SebExamConfigUndo.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SEBExamConfigUndo.java @@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @Lazy @Component @GuiProfile -public class SebExamConfigUndo extends RestCall { +public class SEBExamConfigUndo extends RestCall { - public SebExamConfigUndo() { + public SEBExamConfigUndo() { super(new TypeKey<>( CallType.SAVE, EntityType.CONFIGURATION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java index 9128b6ce..b2ca6519 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java @@ -54,19 +54,19 @@ public class InstructionProcessor { this.jsonMapper = pageService.getJSONMapper(); } - public void propagateSebQuitInstruction( + public void propagateSEBQuitInstruction( final Long examId, final String connectionToken, final PageContext pageContext) { - propagateSebQuitInstruction( + propagateSEBQuitInstruction( examId, p -> Stream.of(connectionToken).collect(Collectors.toSet()), pageContext); } - public void propagateSebQuitInstruction( + public void propagateSEBQuitInstruction( final Long examId, final Function, Set> selectionFunction, final PageContext pageContext) { 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 47e08eba..3d7c61f7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java @@ -108,7 +108,7 @@ public class WebserviceInfo { } } - public String getSebServerVersion() { + public String getSEBServerVersion() { return this.sebServerVersion; } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java index 2ae97151..deed1392 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java @@ -126,6 +126,6 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup * @param examId the exam identifier * @param sebRestriction the seb-restriction flag value * @return Result refer to the updated Exam or to an error if happened */ - Result setSebRestriction(Long examId, boolean sebRestriction); + Result setSEBRestriction(Long examId, boolean sebRestriction); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java index 92457df0..cf6d28d3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java @@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection; import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent; import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType; @@ -101,8 +101,8 @@ public class FilterMap extends POSTMapper { return Utils.toDateTime(getString(QuizData.FILTER_ATTR_START_TIME)); } - public DateTime getSebClientConfigFromTime() { - return Utils.toDateTime(getString(SebClientConfig.FILTER_ATTR_CREATION_DATE)); + public DateTime getSEBClientConfigFromTime() { + return Utils.toDateTime(getString(SEBClientConfig.FILTER_ATTR_CREATION_DATE)); } public Long getLmsSetupId() { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SebClientConfigDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java similarity index 73% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SebClientConfigDAO.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java index c5a9fccd..d499dff9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SebClientConfigDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java @@ -14,29 +14,29 @@ import java.util.Set; import org.springframework.cache.annotation.CacheEvict; import ch.ethz.seb.sebserver.gbl.model.EntityKey; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionSupportDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService; -/** Concrete EntityDAO interface of SebClientConfig entities */ -public interface SebClientConfigDAO extends - ActivatableEntityDAO, - BulkActionSupportDAO { +/** Concrete EntityDAO interface of SEBClientConfig entities */ +public interface SEBClientConfigDAO extends + ActivatableEntityDAO, + BulkActionSupportDAO { - /** Get a SebClientConfig by specified client identifier + /** Get a SEBClientConfig by specified client identifier * * @param clientName the client name - * @return Result refer to the SebClientConfig for client or refer to an error if happened */ - Result byClientName(String clientName); + * @return Result refer to the SEBClientConfig for client or refer to an error if happened */ + Result byClientName(String clientName); - /** Get the configured ClientCredentials for a given SebClientConfig. + /** Get the configured ClientCredentials for a given SEBClientConfig. * The ClientCredentials are still encoded as they are on DB storage * - * @param modelId the model identifier of the SebClientConfig to get the ClientCredentials for - * @return the configured ClientCredentials for a given SebClientConfig */ - Result getSebClientCredentials(String modelId); + * @param modelId the model identifier of the SEBClientConfig to get the ClientCredentials for + * @return the configured ClientCredentials for a given SEBClientConfig */ + Result getSEBClientCredentials(String modelId); /** Get the stored encrypted configuration password from a specified SEB client configuration. * The SEB client configuration password is used to encrypt a SEB Client Configuration diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java index cc80acbe..baa5308a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java @@ -244,7 +244,7 @@ public class ExamDAOImpl implements ExamDAO { @Override @Transactional - public Result setSebRestriction(final Long examId, final boolean sebRestriction) { + public Result setSEBRestriction(final Long examId, final boolean sebRestriction) { return Result.tryCatch(() -> { final ExamRecord examRecord = new ExamRecord( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SebClientConfigDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java similarity index 86% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SebClientConfigDAOImpl.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java index 6ec19f8d..9e7676bc 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SebClientConfigDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java @@ -34,8 +34,8 @@ import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.EntityKey; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig.ConfigPurpose; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig.ConfigPurpose; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; @@ -49,19 +49,19 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ResourceNotFoundException; -import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.TransactionHandler; @Lazy @Component @WebServiceProfile -public class SebClientConfigDAOImpl implements SebClientConfigDAO { +public class SEBClientConfigDAOImpl implements SEBClientConfigDAO { private final SebClientConfigRecordMapper sebClientConfigRecordMapper; private final ClientCredentialService clientCredentialService; private final AdditionalAttributesDAOImpl additionalAttributesDAO; - protected SebClientConfigDAOImpl( + protected SEBClientConfigDAOImpl( final SebClientConfigRecordMapper sebClientConfigRecordMapper, final ClientCredentialService clientCredentialService, final AdditionalAttributesDAOImpl additionalAttributesDAO) { @@ -78,14 +78,14 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional(readOnly = true) - public Result byPK(final Long id) { + public Result byPK(final Long id) { return recordById(id) .flatMap(this::toDomainModel); } @Override @Transactional(readOnly = true) - public Result> all(final Long institutionId, final Boolean active) { + public Result> all(final Long institutionId, final Boolean active) { return Result.tryCatch(() -> { final List records = (active != null) @@ -109,9 +109,9 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional(readOnly = true) - public Result> allMatching( + public Result> allMatching( final FilterMap filterMap, - final Predicate predicate) { + final Predicate predicate) { return Result.tryCatch(() -> this.sebClientConfigRecordMapper .selectByExample() @@ -123,7 +123,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { isLikeWhenPresent(filterMap.getName())) .and( SebClientConfigRecordDynamicSqlSupport.date, - isGreaterThanOrEqualToWhenPresent(filterMap.getSebClientConfigFromTime())) + isGreaterThanOrEqualToWhenPresent(filterMap.getSEBClientConfigFromTime())) .and( SebClientConfigRecordDynamicSqlSupport.active, isEqualToWhenPresent(filterMap.getActiveAsInt())) @@ -137,7 +137,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { } @Override - public Result byClientName(final String clientName) { + public Result byClientName(final String clientName) { return Result.tryCatch(() -> this.sebClientConfigRecordMapper .selectByExample() .where( @@ -210,7 +210,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional - public Result createNew(final SebClientConfig sebClientConfig) { + public Result createNew(final SEBClientConfig sebClientConfig) { return this.clientCredentialService .generatedClientCredentials() .map(cc -> { @@ -240,7 +240,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional - public Result save(final SebClientConfig sebClientConfig) { + public Result save(final SEBClientConfig sebClientConfig) { return Result.tryCatch(() -> { checkUniqueName(sebClientConfig); @@ -287,7 +287,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional(readOnly = true) - public Result> allOf(final Set pks) { + public Result> allOf(final Set pks) { return Result.tryCatch(() -> this.sebClientConfigRecordMapper.selectByExample() .where(SebClientConfigRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks))) .build() @@ -311,7 +311,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { @Override @Transactional(readOnly = true) - public Result getSebClientCredentials(final String modelId) { + public Result getSEBClientCredentials(final String modelId) { return recordByModelId(modelId) .map(rec -> new ClientCredentials( rec.getClientName(), @@ -355,7 +355,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { }); } - private Result toDomainModel(final SebClientConfigRecord record) { + private Result toDomainModel(final SebClientConfigRecord record) { final Map additionalAttributes = this.additionalAttributesDAO .getAdditionalAttributes( @@ -367,37 +367,37 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { AdditionalAttributeRecord::getName, Function.identity())); - additionalAttributes.get(SebClientConfig.ATTR_CONFIG_PURPOSE); + additionalAttributes.get(SEBClientConfig.ATTR_CONFIG_PURPOSE); - return Result.tryCatch(() -> new SebClientConfig( + return Result.tryCatch(() -> new SEBClientConfig( record.getId(), record.getInstitutionId(), record.getName(), - additionalAttributes.containsKey(SebClientConfig.ATTR_CONFIG_PURPOSE) + additionalAttributes.containsKey(SEBClientConfig.ATTR_CONFIG_PURPOSE) ? ConfigPurpose - .valueOf(additionalAttributes.get(SebClientConfig.ATTR_CONFIG_PURPOSE).getValue()) + .valueOf(additionalAttributes.get(SEBClientConfig.ATTR_CONFIG_PURPOSE).getValue()) : ConfigPurpose.START_EXAM, - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK) && - BooleanUtils.toBoolean(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK).getValue()), - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_START_URL) - ? additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_START_URL).getValue() + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK) && + BooleanUtils.toBoolean(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK).getValue()), + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_START_URL) + ? additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_START_URL).getValue() : null, - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_TIMEOUT) - ? Long.parseLong(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_TIMEOUT).getValue()) + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_TIMEOUT) + ? Long.parseLong(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_TIMEOUT).getValue()) : null, - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_ATTEMPTS) - ? Short.parseShort(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_ATTEMPTS).getValue()) + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS) + ? Short.parseShort(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS).getValue()) : null, - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL) + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL) ? Short.parseShort( - additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL).getValue()) + additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL).getValue()) : null, - additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_PASSWORD) - ? additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_PASSWORD).getValue() + additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_PASSWORD) + ? additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_PASSWORD).getValue() : null, null, - additionalAttributes.containsKey(SebClientConfig.ATTR_QUIT_PASSWORD) - ? additionalAttributes.get(SebClientConfig.ATTR_QUIT_PASSWORD).getValue() + additionalAttributes.containsKey(SEBClientConfig.ATTR_QUIT_PASSWORD) + ? additionalAttributes.get(SEBClientConfig.ATTR_QUIT_PASSWORD).getValue() : null, null, record.getDate(), @@ -406,7 +406,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { BooleanUtils.toBooleanObject(record.getActive()))); } - private String getEncryptionPassword(final SebClientConfig sebClientConfig) { + private String getEncryptionPassword(final SEBClientConfig sebClientConfig) { if (sebClientConfig.hasEncryptionSecret() && !sebClientConfig.encryptSecret.equals(sebClientConfig.encryptSecretConfirm)) { throw new APIMessageException(ErrorMessage.PASSWORD_MISMATCH); @@ -420,7 +420,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { // check if same name already exists for the same institution // if true an APIMessageException with a field validation error is thrown - private void checkUniqueName(final SebClientConfig sebClientConfig) { + private void checkUniqueName(final SEBClientConfig sebClientConfig) { final Long otherWithSameName = this.sebClientConfigRecordMapper .countByExample() @@ -437,11 +437,11 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { } } - private void saveAdditionalAttributes(final SebClientConfig sebClientConfig, final Long configId) { + private void saveAdditionalAttributes(final SEBClientConfig sebClientConfig, final Long configId) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_CONFIG_PURPOSE, + SEBClientConfig.ATTR_CONFIG_PURPOSE, (sebClientConfig.configPurpose != null) ? sebClientConfig.configPurpose.name() : ConfigPurpose.CONFIGURE_CLIENT.name()); @@ -449,79 +449,79 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK, + SEBClientConfig.ATTR_FALLBACK, String.valueOf(BooleanUtils.isTrue(sebClientConfig.fallback))); if (BooleanUtils.isTrue(sebClientConfig.fallback)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK_START_URL, + SEBClientConfig.ATTR_FALLBACK_START_URL, sebClientConfig.fallbackStartURL); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_FALLBACK_START_URL); + SEBClientConfig.ATTR_FALLBACK_START_URL); } if (BooleanUtils.isTrue(sebClientConfig.fallback)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK_TIMEOUT, + SEBClientConfig.ATTR_FALLBACK_TIMEOUT, sebClientConfig.fallbackTimeout.toString()); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_FALLBACK_TIMEOUT); + SEBClientConfig.ATTR_FALLBACK_TIMEOUT); } if (BooleanUtils.isTrue(sebClientConfig.fallback)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK_ATTEMPTS, + SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, sebClientConfig.fallbackAttempts.toString()); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_FALLBACK_ATTEMPTS); + SEBClientConfig.ATTR_FALLBACK_ATTEMPTS); } if (BooleanUtils.isTrue(sebClientConfig.fallback)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, + SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, sebClientConfig.fallbackAttemptInterval.toString()); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL); + SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL); } if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.fallbackPassword)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_FALLBACK_PASSWORD, + SEBClientConfig.ATTR_FALLBACK_PASSWORD, this.clientCredentialService.encrypt(sebClientConfig.fallbackPassword).toString()); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_FALLBACK_PASSWORD); + SEBClientConfig.ATTR_FALLBACK_PASSWORD); } if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.quitPassword)) { this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.SEB_CLIENT_CONFIGURATION, configId, - SebClientConfig.ATTR_QUIT_PASSWORD, + SEBClientConfig.ATTR_QUIT_PASSWORD, this.clientCredentialService.encrypt(sebClientConfig.quitPassword).toString()); } else { this.additionalAttributesDAO.delete( configId, - SebClientConfig.ATTR_QUIT_PASSWORD); + SEBClientConfig.ATTR_QUIT_PASSWORD); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/ExamAdminServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/ExamAdminServiceImpl.java index 71fcaae6..37a680ac 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/ExamAdminServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/ExamAdminServiceImpl.java @@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; @@ -34,7 +34,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService; @Lazy @Service @@ -109,14 +109,14 @@ public class ExamAdminServiceImpl implements ExamAdminService { if (lmsSetup.lmsType == LmsType.OPEN_EDX) { final List permissions = Arrays.asList( - OpenEdxSebRestriction.PermissionComponent.ALWAYS_ALLOW_STAFF.key, - OpenEdxSebRestriction.PermissionComponent.CHECK_CONFIG_KEY.key); + OpenEdxSEBRestriction.PermissionComponent.ALWAYS_ALLOW_STAFF.key, + OpenEdxSEBRestriction.PermissionComponent.CHECK_CONFIG_KEY.key); this.additionalAttributesDAO.saveAdditionalAttribute( EntityType.EXAM, exam.id, - SebRestrictionService.SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX + - OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS, + SEBRestrictionService.SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX + + OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS, StringUtils.join(permissions, Constants.LIST_SEPARATOR_CHAR)) .getOrThrow(); } @@ -135,7 +135,7 @@ public class ExamAdminServiceImpl implements ExamAdminService { return this.lmsAPIService .getLmsAPITemplate(exam.lmsSetupId) - .map(lmsAPI -> !lmsAPI.getSebClientRestriction(exam).hasError()); + .map(lmsAPI -> !lmsAPI.getSEBClientRestriction(exam).hasError()); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java index a9d897a7..4e4a1b0b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java @@ -22,7 +22,7 @@ import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; @@ -111,37 +111,37 @@ public interface LmsAPITemplate { /** Used to get a list of chapters (display name and chapter-identifier) that can be used to * apply chapter-based SEB restriction for a specified course. - * + * * The availability of this depends on the type of LMS and on installed plugins that supports this feature. * If this is not supported by the underling LMS a UnsupportedOperationException will be presented * within the Result. - * + * * @param courseId The course identifier * @return Result referencing to the Chapters model for the given course or to an error when happened. */ Result getCourseChapters(String courseId); - /** Get SEB restriction data form LMS within a SebRestrictionData instance if available + /** Get SEB restriction data form LMS within a SEBRestrictionData instance if available * or a ResourceNotFoundException if not yet available or restricted * * @param exam the exam to get the SEB restriction data for - * @return Result refer to the SebRestrictionData instance or to an ResourceNotFoundException if restriction is + * @return Result refer to the SEBRestrictionData instance or to an ResourceNotFoundException if restriction is * missing or to another exception on unexpected error case */ - Result getSebClientRestriction(Exam exam); + Result getSEBClientRestriction(Exam exam); /** Applies a SEB Client restriction within the LMS with the given attributes. * * @param externalExamId The exam identifier from LMS side (Exam.externalId) * @param sebRestrictionData containing all data for SEB Client restriction - * @return Result refer to the given SebRestrictionData if restriction was successful or to an error if not */ - Result applySebClientRestriction( + * @return Result refer to the given SEBRestrictionData if restriction was successful or to an error if not */ + Result applySEBClientRestriction( String externalExamId, - SebRestriction sebRestrictionData); + SEBRestriction sebRestrictionData); /** Releases an already applied SEB Client restriction within the LMS for a given Exam. * This completely removes the SEB Client restriction on LMS side. * * @param exam the Exam to release the restriction for * @return Result refer to the given Exam if successful or to an error if not */ - Result releaseSebClientRestriction(Exam exam); + Result releaseSEBClientRestriction(Exam exam); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SebRestrictionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java similarity index 74% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SebRestrictionService.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java index 3c97bb19..3cea6a00 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SebRestrictionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java @@ -9,32 +9,32 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.util.Result; -public interface SebRestrictionService { +public interface SEBRestrictionService { /** Used as name prefix to store additional SEB restriction properties within AdditionalAttribute domain. */ String SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX = "sebRestrictionProp_"; String SEB_RESTRICTION_ADDITIONAL_PROPERTY_CONFIG_KEY = "config_key"; - /** Get the SebRestriction properties for specified Exam. + /** Get the SEBRestriction properties for specified Exam. * * @param exam the Exam - * @return the SebRestriction properties for specified Exam */ - Result getSebRestrictionFromExam(Exam exam); + * @return the SEBRestriction properties for specified Exam */ + Result getSEBRestrictionFromExam(Exam exam); - /** Saves the given SebRestriction for the given Exam. + /** Saves the given SEBRestriction for the given Exam. * * The webservice saves the given browser Exam keys within the Exam record * and given additional restriction properties within the Additional attributes linked * to the given Exam. * * @param exam the Exam instance to save the SEB restrictions for - * @param sebRestriction SebRestriction data containing generic and LMS specific restriction attributes + * @param sebRestriction SEBRestriction data containing generic and LMS specific restriction attributes * @return Result refer to the given Exam instance or to an error if happened */ - Result saveSebRestrictionToExam(Exam exam, SebRestriction sebRestriction); + Result saveSEBRestrictionToExam(Exam exam, SEBRestriction sebRestriction); /** Used to apply SEB Client restriction within the LMS API for a specified Exam. * If the underling LMS Setup API didn't support the SEB restriction feature @@ -42,12 +42,12 @@ public interface SebRestrictionService { * * @param exam the Exam instance * @return Result refer to the Exam instance or to an error if happened */ - Result applySebClientRestriction(Exam exam); + Result applySEBClientRestriction(Exam exam); /** Release SEB Client restriction within the LMS API for a specified Exam. * * @param exam the Exam instance * @return Result refer to the Exam instance or to an error if happened */ - Result releaseSebClientRestriction(Exam exam); + Result releaseSEBClientRestriction(Exam exam); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java index 5ee7ea2e..52252256 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java @@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; @@ -184,22 +184,22 @@ final class MockupLmsAPITemplate implements LmsAPITemplate { } @Override - public Result getSebClientRestriction(final Exam exam) { + public Result getSEBClientRestriction(final Exam exam) { log.info("Apply SEB Client restriction for Exam: {}", exam); - return Result.ofError(new NoSebRestrictionException()); + return Result.ofError(new NoSEBRestrictionException()); } @Override - public Result applySebClientRestriction( + public Result applySEBClientRestriction( final String externalExamId, - final SebRestriction sebRestrictionData) { + final SEBRestriction sebRestrictionData) { log.info("Apply SEB Client restriction: {}", sebRestrictionData); return Result.of(sebRestrictionData); } @Override - public Result releaseSebClientRestriction(final Exam exam) { + public Result releaseSEBClientRestriction(final Exam exam) { log.info("Release SEB Client restriction for Exam: {}", exam); return Result.of(exam); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSebRestrictionException.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSEBRestrictionException.java similarity index 71% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSebRestrictionException.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSEBRestrictionException.java index bf41bfc7..c4551cfe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSebRestrictionException.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/NoSEBRestrictionException.java @@ -8,14 +8,14 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl; -public class NoSebRestrictionException extends RuntimeException { +public class NoSEBRestrictionException extends RuntimeException { private static final long serialVersionUID = -6444577025412136884L; - public NoSebRestrictionException() { + public NoSEBRestrictionException() { } - public NoSebRestrictionException(final Throwable cause) { + public NoSEBRestrictionException(final Throwable cause) { super(cause); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java similarity index 88% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java index d312092c..3b3f6d01 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java @@ -28,29 +28,29 @@ import org.springframework.transaction.annotation.Transactional; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService; @Lazy @Service @WebServiceProfile -public class SebRestrictionServiceImpl implements SebRestrictionService { +public class SEBRestrictionServiceImpl implements SEBRestrictionService { - private static final Logger log = LoggerFactory.getLogger(SebRestrictionServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(SEBRestrictionServiceImpl.class); private final ExamDAO examDAO; private final LmsAPIService lmsAPIService; private final AdditionalAttributesDAO additionalAttributesDAO; private final ExamConfigService examConfigService; - protected SebRestrictionServiceImpl( + protected SEBRestrictionServiceImpl( final ExamDAO examDAO, final LmsAPIService lmsAPIService, final AdditionalAttributesDAO additionalAttributesDAO, @@ -64,7 +64,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { @Override @Transactional - public Result getSebRestrictionFromExam(final Exam exam) { + public Result getSEBRestrictionFromExam(final Exam exam) { return Result.tryCatch(() -> { // load the config keys from restriction and merge with new generated config keys final Set configKeys = new HashSet<>(); @@ -76,7 +76,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { if (generatedKeys != null && !generatedKeys.isEmpty()) { configKeys.addAll(this.lmsAPIService .getLmsAPITemplate(exam.lmsSetupId) - .flatMap(lmsTemplate -> lmsTemplate.getSebClientRestriction(exam)) + .flatMap(lmsTemplate -> lmsTemplate.getSEBClientRestriction(exam)) .map(r -> r.configKeys) .getOr(Collections.emptyList())); } @@ -110,7 +110,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { e); } - return new SebRestriction( + return new SEBRestriction( exam.id, configKeys, browserExamKeys, @@ -120,10 +120,10 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { @Override @Transactional - public Result saveSebRestrictionToExam(final Exam exam, final SebRestriction sebRestriction) { + public Result saveSEBRestrictionToExam(final Exam exam, final SEBRestriction sebRestriction) { if (log.isDebugEnabled()) { - log.debug("Save SebRestriction: {} for Exam: {}", sebRestriction, exam); + log.debug("Save SEBRestriction: {} for Exam: {}", sebRestriction, exam); } return Result.tryCatch(() -> { @@ -166,7 +166,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { } @Override - public Result applySebClientRestriction(final Exam exam) { + public Result applySEBClientRestriction(final Exam exam) { if (!this.lmsAPIService .getLmsSetup(exam.lmsSetupId) .getOrThrow().lmsType.features.contains(Features.SEB_RESTRICTION)) { @@ -174,16 +174,16 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { return Result.of(exam); } - return this.getSebRestrictionFromExam(exam) + return this.getSEBRestrictionFromExam(exam) .map(sebRestrictionData -> { if (log.isDebugEnabled()) { - log.debug("Appling SEB Client restriction on LMS with: {}", sebRestrictionData); + log.debug("Applying SEB Client restriction on LMS with: {}", sebRestrictionData); } return this.lmsAPIService .getLmsAPITemplate(exam.lmsSetupId) - .flatMap(lmsTemplate -> lmsTemplate.applySebClientRestriction( + .flatMap(lmsTemplate -> lmsTemplate.applySEBClientRestriction( exam.externalId, sebRestrictionData)) .map(data -> exam) @@ -192,7 +192,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { } @Override - public Result releaseSebClientRestriction(final Exam exam) { + public Result releaseSEBClientRestriction(final Exam exam) { if (log.isDebugEnabled()) { log.debug("Release SEB Client restrictions for exam: {}", exam); @@ -200,7 +200,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { return this.lmsAPIService .getLmsAPITemplate(exam.lmsSetupId) - .flatMap(template -> template.releaseSebClientRestriction(exam)); + .flatMap(template -> template.releaseSEBClientRestriction(exam)); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxCourseRestriction.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxCourseRestriction.java index 71b1f840..54cf7e84 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxCourseRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxCourseRestriction.java @@ -26,11 +26,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSebRestrictionException; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException; public class OpenEdxCourseRestriction { @@ -104,24 +104,24 @@ public class OpenEdxCourseRestriction { return LmsSetupTestResult.ofOkay(); } - Result getSebRestriction(final String courseId) { + Result getSEBRestriction(final String courseId) { if (log.isDebugEnabled()) { log.debug("GET SEB Client restriction on course: {}", courseId); } return Result.tryCatch(() -> { - final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId); + final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId); final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate"); try { - final OpenEdxSebRestriction data = this.restTemplate.exchange( + final OpenEdxSEBRestriction data = this.restTemplate.exchange( url, HttpMethod.GET, new HttpEntity<>(httpHeaders), - OpenEdxSebRestriction.class) + OpenEdxSEBRestriction.class) .getBody(); if (log.isDebugEnabled()) { @@ -130,36 +130,36 @@ public class OpenEdxCourseRestriction { return data; } catch (final HttpClientErrorException ce) { if (ce.getStatusCode() == HttpStatus.NOT_FOUND || ce.getStatusCode() == HttpStatus.UNAUTHORIZED) { - throw new NoSebRestrictionException(ce); + throw new NoSEBRestrictionException(ce); } throw ce; } }); } - Result putSebRestriction( + Result putSEBRestriction( final String courseId, - final OpenEdxSebRestriction restriction) { + final OpenEdxSEBRestriction restriction) { if (log.isDebugEnabled()) { log.debug("PUT SEB Client restriction on course: {} : {}", courseId, restriction); } - return handleSebRestriction(processSebRestrictionUpdate(pushSebRestrictionFunction( + return handleSEBRestriction(processSEBRestrictionUpdate(pushSEBRestrictionFunction( restriction, courseId))); } - Result deleteSebRestriction(final String courseId) { + Result deleteSEBRestriction(final String courseId) { if (log.isDebugEnabled()) { log.debug("DELETE SEB Client restriction on course: {}", courseId); } - return handleSebRestriction(processSebRestrictionUpdate(deleteSebRestrictionFunction(courseId))); + return handleSEBRestriction(processSEBRestrictionUpdate(deleteSEBRestrictionFunction(courseId))); } - private BooleanSupplier processSebRestrictionUpdate(final BooleanSupplier restrictionUpdate) { + private BooleanSupplier processSEBRestrictionUpdate(final BooleanSupplier restrictionUpdate) { return () -> { if (this.restrictionAPIPushCount > 0) { // NOTE: This is a temporary work-around for SEB Restriction API within Open edX SEB integration plugin to @@ -193,20 +193,20 @@ public class OpenEdxCourseRestriction { }; } - private BooleanSupplier pushSebRestrictionFunction( - final OpenEdxSebRestriction restriction, + private BooleanSupplier pushSEBRestrictionFunction( + final OpenEdxSEBRestriction restriction, final String courseId) { - final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId); + final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId); final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate"); return () -> { - final OpenEdxSebRestriction body = this.restTemplate.exchange( + final OpenEdxSEBRestriction body = this.restTemplate.exchange( url, HttpMethod.PUT, new HttpEntity<>(toJson(restriction), httpHeaders), - OpenEdxSebRestriction.class) + OpenEdxSEBRestriction.class) .getBody(); if (log.isDebugEnabled()) { @@ -217,9 +217,9 @@ public class OpenEdxCourseRestriction { }; } - private BooleanSupplier deleteSebRestrictionFunction(final String courseId) { + private BooleanSupplier deleteSEBRestrictionFunction(final String courseId) { - final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId); + final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId); return () -> { final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate"); @@ -242,7 +242,7 @@ public class OpenEdxCourseRestriction { }; } - private Result handleSebRestriction(final BooleanSupplier task) { + private Result handleSEBRestriction(final BooleanSupplier task) { return getRestTemplate() .map(restTemplate -> { try { @@ -259,7 +259,7 @@ public class OpenEdxCourseRestriction { }); } - private String getSebRestrictionUrl(final String courseId) { + private String getSEBRestrictionUrl(final String courseId) { return String.format(OPEN_EDX_DEFAULT_COURSE_RESTRICTION_API_PATH, courseId); } @@ -277,7 +277,7 @@ public class OpenEdxCourseRestriction { return Result.of(this.restTemplate); } - private String toJson(final OpenEdxSebRestriction restriction) { + private String toJson(final OpenEdxSEBRestriction restriction) { try { return this.jsonMapper.writeValueAsString(restriction); } catch (final JsonProcessingException e) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplate.java index 4390e623..2ee937c8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplate.java @@ -19,9 +19,9 @@ import org.slf4j.LoggerFactory; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; -import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; @@ -87,40 +87,40 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate { } @Override - public Result getSebClientRestriction(final Exam exam) { + public Result getSEBClientRestriction(final Exam exam) { if (log.isDebugEnabled()) { log.debug("Get SEB Client restriction for Exam: {}", exam); } return this.openEdxCourseRestriction - .getSebRestriction(exam.externalId) - .map(restriction -> SebRestriction.from(exam.id, restriction)); + .getSEBRestriction(exam.externalId) + .map(restriction -> SEBRestriction.from(exam.id, restriction)); } @Override - public Result applySebClientRestriction( + public Result applySEBClientRestriction( final String externalExamId, - final SebRestriction sebRestrictionData) { + final SEBRestriction sebRestrictionData) { if (log.isDebugEnabled()) { log.debug("Apply SEB Client restriction: {}", sebRestrictionData); } return this.openEdxCourseRestriction - .putSebRestriction( + .putSEBRestriction( externalExamId, - OpenEdxSebRestriction.from(sebRestrictionData)) + OpenEdxSEBRestriction.from(sebRestrictionData)) .map(result -> sebRestrictionData); } @Override - public Result releaseSebClientRestriction(final Exam exam) { + public Result releaseSEBClientRestriction(final Exam exam) { if (log.isDebugEnabled()) { log.debug("Release SEB Client restriction for Exam: {}", exam); } - return this.openEdxCourseRestriction.deleteSebRestriction(exam.externalId) + return this.openEdxCourseRestriction.deleteSEBRestriction(exam.externalId) .map(result -> exam); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplate.java index 8c94442b..7aae8ec6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplate.java @@ -15,7 +15,7 @@ import java.util.Set; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; @@ -75,20 +75,20 @@ public class MoodleLmsAPITemplate implements LmsAPITemplate { } @Override - public Result getSebClientRestriction(final Exam exam) { + public Result getSEBClientRestriction(final Exam exam) { return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet")); } @Override - public Result applySebClientRestriction( + public Result applySEBClientRestriction( final String externalExamId, - final SebRestriction sebRestrictionData) { + final SEBRestriction sebRestrictionData) { return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet")); } @Override - public Result releaseSebClientRestriction(final Exam exam) { + public Result releaseSEBClientRestriction(final Exam exam) { return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet")); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ClientConfigService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ClientConfigService.java index d19a9786..8f1f6db4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ClientConfigService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ClientConfigService.java @@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.security.oauth2.provider.ClientDetails; import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.util.Result; public interface ClientConfigService { @@ -27,32 +27,32 @@ public interface ClientConfigService { /** The cache name of ClientDetails */ String EXAM_CLIENT_DETAILS_CACHE = "EXAM_CLIENT_DETAILS_CACHE"; - /** Indicates if there is any SebClientConfiguration for a specified institution. + /** Indicates if there is any SEBClientConfiguration for a specified institution. * * @param institutionId the institution identifier - * @return true if there is any SebClientConfiguration for a specified institution. False otherwise */ - boolean hasSebClientConfigurationForInstitution(Long institutionId); + * @return true if there is any SEBClientConfiguration for a specified institution. False otherwise */ + boolean hasSEBClientConfigurationForInstitution(Long institutionId); - /** Use this to auto-generate a SebClientConfiguration for a specified institution. + /** Use this to auto-generate a SEBClientConfiguration for a specified institution. * clientName and clientSecret are randomly generated. * * @param institutionId the institution identifier - * @return the created SebClientConfig */ - Result autoCreateSebClientConfigurationForInstitution(Long institutionId); + * @return the created SEBClientConfiguration */ + Result autoCreateSEBClientConfigurationForInstitution(Long institutionId); - /** Use this to export a specified SebClientConfiguration within a given OutputStream. + /** Use this to export a specified SEBClientConfiguration within a given OutputStream. * The SEB Client Configuration is exported in the defined SEB Configuration format * as described here: https://www.safeexambrowser.org/developer/seb-file-format.html * * @param out OutputStream to write the export to - * @param modelId the model identifier of the SebClientConfiguration to export */ - void exportSebClientConfiguration( + * @param modelId the model identifier of the SEBClientConfiguration to export */ + void exportSEBClientConfiguration( OutputStream out, final String modelId); - /** Get the ClientDetails for given client name that identifies a SebClientConfig entry. + /** Get the ClientDetails for given client name that identifies a SEBClientConfiguration entry. * - * @param clientName the client name of a SebClientConfig entry + * @param clientName the client name of a SEBClientConfiguration entry * @return Result refer to the ClientDetails for the specified clientName or to an error if happened */ @Cacheable( cacheNames = EXAM_CLIENT_DETAILS_CACHE, @@ -60,12 +60,12 @@ public interface ClientConfigService { unless = "#result.hasError()") Result getClientConfigDetails(String clientName); - /** Internally used to check OAuth2 access for a active SebClientConfig. + /** Internally used to check OAuth2 access for a active SEBClientConfig. * - * @param config the SebClientConfig to check access + * @param config the SEBClientConfig to check access * @return true if the system was able to gain an access token for the client. False otherwise */ - boolean checkAccess(SebClientConfig config); + boolean checkAccess(SEBClientConfig config); @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) - void initalCheckAccess(SebClientConfig config); + void initalCheckAccess(SEBClientConfig config); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigCryptor.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigCryptor.java similarity index 84% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigCryptor.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigCryptor.java index 5003c6fe..9c44edb7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigCryptor.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigCryptor.java @@ -15,13 +15,13 @@ import java.util.Set; import org.springframework.scheduling.annotation.Async; import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; /** Interface for a SEB Configuration encryption and decryption strategy. * * To support a new SEB Configuration encryption and decryption strategy use this interface * to implement a concrete strategy for encryption and decryption of SEB configurations */ -public interface SebConfigCryptor { +public interface SEBConfigCryptor { /** The type of strategies a concrete implementation is supporting * @@ -33,23 +33,23 @@ public interface SebConfigCryptor { * * @param output the output stream to write encrypted data to * @param input the input stream to read plain data from - * @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */ + * @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */ @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) void encrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context); + final SEBConfigEncryptionContext context); /** Decrypt an incoming cipher data stream to an outgoing plain text data stream * This uses Springs @Async annotation to run in a separated thread * * @param output the output stream to write the plain text data to * @param input the input stream to read the cipher text from - * @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */ + * @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */ @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) void decrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context); + final SEBConfigEncryptionContext context); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionContext.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionContext.java similarity index 90% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionContext.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionContext.java index 59d4d8d7..fd099e49 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionContext.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionContext.java @@ -10,11 +10,11 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig; import java.security.cert.Certificate; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; /** Encryption context used to supply additional data for encryption or decryption * within a concrete strategy. */ -public interface SebConfigEncryptionContext { +public interface SEBConfigEncryptionContext { /** Get the current encryption/decryption strategy * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionService.java similarity index 91% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionService.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionService.java index d385822e..e1a0a4a5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SebConfigEncryptionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/SEBConfigEncryptionService.java @@ -19,7 +19,7 @@ import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig; import ch.ethz.seb.sebserver.gbl.util.Utils; /** Used for SEB Configuration encryption and decryption */ -public interface SebConfigEncryptionService { +public interface SEBConfigEncryptionService { /** Types of encryption strategies */ enum Type { @@ -67,22 +67,22 @@ public interface SebConfigEncryptionService { * * @param output the output data stream to write the cipher text to * @param input the input stream to read the plain text from - * @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */ + * @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */ @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) void streamEncrypted( final OutputStream output, final InputStream input, - SebConfigEncryptionContext context); + SEBConfigEncryptionContext context); /** This can be used to stream incoming cipher data to decrypted plain text data output stream. * * @param output the output data stream to write encrypted plain text to * @param input the input stream to read the cipher text from - * @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */ + * @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */ @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) Future streamDecrypted( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context); + final SEBConfigEncryptionContext context); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java index be8ebe4a..75eb40e6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java @@ -43,7 +43,7 @@ import ch.ethz.seb.sebserver.WebSecurityConfig; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; @@ -51,12 +51,12 @@ import ch.ethz.seb.sebserver.webservice.WebserviceInfo; import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext; import ch.ethz.seb.sebserver.webservice.weblayer.oauth.WebserviceResourceConfiguration; @Lazy @@ -99,18 +99,18 @@ public class ClientConfigServiceImpl implements ClientConfigService { " %s%n"; private final InstitutionDAO institutionDAO; - private final SebClientConfigDAO sebClientConfigDAO; + private final SEBClientConfigDAO sebClientConfigDAO; private final ClientCredentialService clientCredentialService; - private final SebConfigEncryptionService sebConfigEncryptionService; + private final SEBConfigEncryptionService sebConfigEncryptionService; private final PasswordEncoder clientPasswordEncoder; private final ZipService zipService; private final WebserviceInfo webserviceInfo; protected ClientConfigServiceImpl( final InstitutionDAO institutionDAO, - final SebClientConfigDAO sebClientConfigDAO, + final SEBClientConfigDAO sebClientConfigDAO, final ClientCredentialService clientCredentialService, - final SebConfigEncryptionService sebConfigEncryptionService, + final SEBConfigEncryptionService sebConfigEncryptionService, final ZipService zipService, @Qualifier(WebSecurityConfig.CLIENT_PASSWORD_ENCODER_BEAN_NAME) final PasswordEncoder clientPasswordEncoder, final WebserviceInfo webserviceInfo) { @@ -125,19 +125,19 @@ public class ClientConfigServiceImpl implements ClientConfigService { } @Override - public boolean hasSebClientConfigurationForInstitution(final Long institutionId) { - final Result> all = this.sebClientConfigDAO.all(institutionId, true); + public boolean hasSEBClientConfigurationForInstitution(final Long institutionId) { + final Result> all = this.sebClientConfigDAO.all(institutionId, true); return all != null && !all.hasError() && !all.getOrThrow().isEmpty(); } @Override - public Result autoCreateSebClientConfigurationForInstitution(final Long institutionId) { + public Result autoCreateSEBClientConfigurationForInstitution(final Long institutionId) { return Result.tryCatch(() -> { final Institution institution = this.institutionDAO .byPK(institutionId) .getOrThrow(); - return new SebClientConfig( + return new SEBClientConfig( null, institutionId, institution.name + "_" + UUID.randomUUID(), @@ -184,11 +184,11 @@ public class ClientConfigServiceImpl implements ClientConfigService { } @Override - public void exportSebClientConfiguration( + public void exportSEBClientConfiguration( final OutputStream output, final String modelId) { - final SebClientConfig config = this.sebClientConfigDAO + final SEBClientConfig config = this.sebClientConfigDAO .byModelId(modelId).getOrThrow(); final CharSequence encryptionPassword = this.sebClientConfigDAO @@ -236,7 +236,7 @@ public class ClientConfigServiceImpl implements ClientConfigService { this.zipService.write(output, zipIn); if (log.isDebugEnabled()) { - log.debug("*** Finished Seb client configuration download streaming composition"); + log.debug("*** Finished SEB client configuration download streaming composition"); } } catch (final Exception e) { @@ -248,35 +248,35 @@ public class ClientConfigServiceImpl implements ClientConfigService { } } - private String extractXMLContent(final SebClientConfig config) { + private String extractXMLContent(final SEBClientConfig config) { String fallbackAddition = ""; if (BooleanUtils.isTrue(config.fallback)) { fallbackAddition += String.format( SEB_CLIENT_CONFIG_STRING_TEMPLATE, - SebClientConfig.ATTR_FALLBACK_START_URL, + SEBClientConfig.ATTR_FALLBACK_START_URL, config.fallbackStartURL); fallbackAddition += String.format( SEB_CLIENT_CONFIG_INTEGER_TEMPLATE, - SebClientConfig.ATTR_FALLBACK_TIMEOUT, + SEBClientConfig.ATTR_FALLBACK_TIMEOUT, config.fallbackTimeout); fallbackAddition += String.format( SEB_CLIENT_CONFIG_INTEGER_TEMPLATE, - SebClientConfig.ATTR_FALLBACK_ATTEMPTS, + SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, config.fallbackAttempts); fallbackAddition += String.format( SEB_CLIENT_CONFIG_INTEGER_TEMPLATE, - SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, + SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, config.fallbackAttemptInterval); if (StringUtils.isNotBlank(config.fallbackPassword)) { final CharSequence decrypt = this.clientCredentialService.decrypt(config.fallbackPassword); fallbackAddition += String.format( SEB_CLIENT_CONFIG_STRING_TEMPLATE, - SebClientConfig.ATTR_FALLBACK_PASSWORD, + SEBClientConfig.ATTR_FALLBACK_PASSWORD, Utils.hash_SHA_256_Base_16(decrypt)); } @@ -284,13 +284,13 @@ public class ClientConfigServiceImpl implements ClientConfigService { final CharSequence decrypt = this.clientCredentialService.decrypt(config.quitPassword); fallbackAddition += String.format( SEB_CLIENT_CONFIG_STRING_TEMPLATE, - SebClientConfig.ATTR_QUIT_PASSWORD, + SEBClientConfig.ATTR_QUIT_PASSWORD, Utils.hash_SHA_256_Base_16(decrypt)); } } final ClientCredentials sebClientCredentials = this.sebClientConfigDAO - .getSebClientCredentials(config.getModelId()) + .getSEBClientCredentials(config.getModelId()) .getOrThrow(); final CharSequence plainClientId = sebClientCredentials.clientId; final CharSequence plainClientSecret = this.clientCredentialService @@ -317,7 +317,7 @@ public class ClientConfigServiceImpl implements ClientConfigService { } @Override - public boolean checkAccess(final SebClientConfig config) { + public boolean checkAccess(final SEBClientConfig config) { if (!config.isActive()) { return false; } @@ -335,7 +335,7 @@ public class ClientConfigServiceImpl implements ClientConfigService { final MultiValueMap headers = new LinkedMultiValueMap<>(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); final ClientCredentials credentials = this.sebClientConfigDAO - .getSebClientCredentials(config.getModelId()) + .getSEBClientCredentials(config.getModelId()) .getOrThrow(); final CharSequence plainClientSecret = this.clientCredentialService.getPlainClientSecret(credentials); final String basicAuth = credentials.clientId + @@ -358,17 +358,17 @@ public class ClientConfigServiceImpl implements ClientConfigService { if (exchange.getStatusCode().value() == HttpStatus.OK.value()) { return true; } else { - log.warn("Failed to check access SebClientConfig {} response: {}", config, exchange.getStatusCode()); + log.warn("Failed to check access SEBClientConfig {} response: {}", config, exchange.getStatusCode()); return false; } } catch (final Exception e) { - log.warn("Failed to check access for SebClientConfig: {} cause: {}", config, e.getMessage()); + log.warn("Failed to check access for SEBClientConfig: {} cause: {}", config, e.getMessage()); return false; } } @Override - public void initalCheckAccess(final SebClientConfig config) { + public void initalCheckAccess(final SEBClientConfig config) { checkAccess(config); } @@ -378,7 +378,7 @@ public class ClientConfigServiceImpl implements ClientConfigService { final InputStream input) { if (log.isDebugEnabled()) { - log.debug("*** Seb client configuration with password based encryption"); + log.debug("*** SEB client configuration with password based encryption"); } final CharSequence encryptionPasswordPlaintext = (encryptionPassword == StringUtils.EMPTY) @@ -393,10 +393,10 @@ public class ClientConfigServiceImpl implements ClientConfigService { encryptionPasswordPlaintext)); } - /** Get a encoded clientSecret for the SebClientConfiguration with specified clientId/clientName. + /** Get a encoded clientSecret for the SEBClientConfiguration with specified clientId/clientName. * * @param clientId the clientId/clientName - * @return encoded clientSecret for that SebClientConfiguration with clientId or null of not existing */ + * @return encoded clientSecret for that SEBClientConfiguration with clientId or null of not existing */ private Result getEncodedClientConfigSecret(final String clientId) { return this.sebClientConfigDAO.getConfigPasswordCipherByClientName(clientId) .map(cipher -> this.clientPasswordEncoder.encode(this.clientCredentialService.decrypt(cipher))); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java index 786dcd38..4585706e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java @@ -42,10 +42,10 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamConfigurationMapDAO import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationFormat; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationValueValidator; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext; @Lazy @Service @@ -60,7 +60,7 @@ public class ExamConfigServiceImpl implements ExamConfigService { private final Collection validators; private final ClientCredentialService clientCredentialService; private final ZipService zipService; - private final SebConfigEncryptionService sebConfigEncryptionService; + private final SEBConfigEncryptionService sebConfigEncryptionService; protected ExamConfigServiceImpl( final ExamConfigIO examConfigIO, @@ -69,7 +69,7 @@ public class ExamConfigServiceImpl implements ExamConfigService { final Collection validators, final ClientCredentialService clientCredentialService, final ZipService zipService, - final SebConfigEncryptionService sebConfigEncryptionService) { + final SEBConfigEncryptionService sebConfigEncryptionService) { this.examConfigIO = examConfigIO; this.configurationAttributeDAO = configurationAttributeDAO; @@ -180,7 +180,7 @@ public class ExamConfigServiceImpl implements ExamConfigService { if (StringUtils.isNotBlank(passwordCipher)) { if (log.isDebugEnabled()) { - log.debug("*** Seb exam configuration with password based encryption"); + log.debug("*** SEB exam configuration with password based encryption"); } final CharSequence encryptionPasswordPlaintext = this.clientCredentialService diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/NoneEncryptor.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/NoneEncryptor.java index f82edf17..b1e76eb6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/NoneEncryptor.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/NoneEncryptor.java @@ -21,14 +21,14 @@ import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; @Lazy @Component @WebServiceProfile -public class NoneEncryptor implements SebConfigCryptor { +public class NoneEncryptor implements SEBConfigCryptor { private static final Logger log = LoggerFactory.getLogger(NoneEncryptor.class); @@ -44,7 +44,7 @@ public class NoneEncryptor implements SebConfigCryptor { public void encrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { if (log.isDebugEnabled()) { log.debug("No encryption, write plain input data"); @@ -75,7 +75,7 @@ public class NoneEncryptor implements SebConfigCryptor { public void decrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { if (log.isDebugEnabled()) { log.debug("No decryption, read plain input data"); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptor.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptor.java index 2095b0f7..70808bac 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptor.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptor.java @@ -29,14 +29,14 @@ import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; @Lazy @Component @WebServiceProfile -public class PasswordEncryptor implements SebConfigCryptor { +public class PasswordEncryptor implements SEBConfigCryptor { private static final Logger log = LoggerFactory.getLogger(PasswordEncryptor.class); @@ -59,7 +59,7 @@ public class PasswordEncryptor implements SebConfigCryptor { public void encrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { if (log.isDebugEnabled()) { log.debug("*** Start streaming asynchronous encryption"); @@ -108,7 +108,7 @@ public class PasswordEncryptor implements SebConfigCryptor { public void decrypt( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { final CharSequence password = context.getPassword(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SEBConfigEncryptionServiceImpl.java similarity index 89% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImpl.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SEBConfigEncryptionServiceImpl.java index ea6932cc..af6b6537 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SEBConfigEncryptionServiceImpl.java @@ -36,21 +36,21 @@ import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService; @Lazy @Service @WebServiceProfile -public final class SebConfigEncryptionServiceImpl implements SebConfigEncryptionService { +public final class SEBConfigEncryptionServiceImpl implements SEBConfigEncryptionService { - private static final Logger log = LoggerFactory.getLogger(SebConfigEncryptionServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(SEBConfigEncryptionServiceImpl.class); - private final Map encryptors; + private final Map encryptors; - public SebConfigEncryptionServiceImpl( - final Collection encryptors) { + public SEBConfigEncryptionServiceImpl( + final Collection encryptors) { this.encryptors = encryptors .stream() @@ -64,7 +64,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption public void streamEncrypted( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { final Strategy strategy = context.getStrategy(); PipedOutputStream pout = null; @@ -108,7 +108,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption public Future streamDecrypted( final OutputStream output, final InputStream input, - final SebConfigEncryptionContext context) { + final SEBConfigEncryptionContext context) { PipedOutputStream pout = null; PipedInputStream pin = null; @@ -180,8 +180,8 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption } } - private Result getEncryptor(final Strategy strategy) { - final SebConfigCryptor encryptor = this.encryptors.get(strategy); + private Result getEncryptor(final Strategy strategy) { + final SEBConfigCryptor encryptor = this.encryptors.get(strategy); if (encryptor == null) { return Result.ofError(new IllegalArgumentException("No Encryptor found for strategy : " + strategy)); } @@ -189,7 +189,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption return Result.of(encryptor); } - static class EncryptionContext implements SebConfigEncryptionContext { + static class EncryptionContext implements SEBConfigEncryptionContext { public final Strategy strategy; public final CharSequence password; @@ -223,12 +223,12 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption return this.certificateStore.apply(key); } - static SebConfigEncryptionContext contextOf(final Strategy strategy, final CharSequence password) { + static SEBConfigEncryptionContext contextOf(final Strategy strategy, final CharSequence password) { checkPasswordBased(strategy); return new EncryptionContext(strategy, password, null); } - static SebConfigEncryptionContext contextOf( + static SEBConfigEncryptionContext contextOf( final Strategy strategy, final Function certificateStore) { @@ -248,11 +248,11 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption } } - public static SebConfigEncryptionContext contextOfPlainText() { + public static SEBConfigEncryptionContext contextOfPlainText() { return new EncryptionContext(Strategy.PLAIN_TEXT, null, null); } - public static SebConfigEncryptionContext contextOf(final CharSequence password) { + public static SEBConfigEncryptionContext contextOf(final CharSequence password) { return new EncryptionContext(null, password, null); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/ExamSessionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/ExamSessionService.java index c4ea8aaa..cce27c0c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/ExamSessionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/ExamSessionService.java @@ -68,7 +68,7 @@ public interface ExamSessionService { * * @param examId The Exam identifier * @return true if the given Exam has currently no active client connection, false otherwise. */ - boolean hasActiveSebClientConnections(final Long examId); + boolean hasActiveSEBClientConnections(final Long examId); /** Checks if a specified Exam has at least a default SEB Exam configuration attached. * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebClientConnectionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientConnectionService.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebClientConnectionService.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientConnectionService.java index 56f51398..bb6d0393 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebClientConnectionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBClientConnectionService.java @@ -15,7 +15,7 @@ import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent; import ch.ethz.seb.sebserver.gbl.util.Result; /** Service interface defining functionality to handle SEB client connections on running exams. */ -public interface SebClientConnectionService { +public interface SEBClientConnectionService { /** Use this to get the underling ExamSessionService * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebInstructionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBInstructionService.java similarity index 96% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebInstructionService.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBInstructionService.java index 065a664b..20c87597 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SebInstructionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/SEBInstructionService.java @@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.webservice.WebserviceInfo; * * SEB instructions are sent as response of a SEB Ping on a active SEB Connection * If there is an instruction in the queue for a specified SEB Client. */ -public interface SebInstructionService { +public interface SEBInstructionService { /** Get the underling WebserviceInfo * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java index 84978dd0..f33ad452 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java @@ -133,8 +133,8 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { if (exam.getStatus() == ExamStatus.RUNNING || this.examAdminService.isRestricted(exam).getOr(false)) { this.examUpdateHandler - .getSebRestrictionService() - .applySebClientRestriction(exam) + .getSEBRestrictionService() + .applySEBClientRestriction(exam) .onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t)); } } @@ -203,8 +203,8 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { // update seb client restriction if the feature is activated for the exam if (this.examAdminService.isRestricted(exam).getOr(false)) { this.examUpdateHandler - .getSebRestrictionService() - .applySebClientRestriction(exam) + .getSEBRestrictionService() + .applySEBClientRestriction(exam) .onError(t -> log.error( "Failed to update SEB Client restriction for Exam: {}", exam, @@ -229,7 +229,7 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { } private void checkActiveClientConnections(final Exam exam) { - if (this.examSessionService.hasActiveSebClientConnections(exam.id)) { + if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) { throw new APIMessage.APIMessageException( ErrorMessage.INTEGRITY_VALIDATION, "Integrity violation: There are currently active SEB Client connection."); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java index d0909d6d..bb2ab02c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionCacheService.java @@ -36,7 +36,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService /** Handles caching for exam session and defines caching for following object: * * - Running exams (examId -> Exam) - * - in-memory exam configuration (examId -> InMemorySebConfig) + * - in-memory exam configuration (examId -> InMemorySEBConfig) * - active client connections (connectionToken -> ClientConnectionDataInternal) * - client event records for last ping store (connectionToken -> ReusableClientEventRecord) */ @Lazy @@ -163,7 +163,7 @@ public class ExamSessionCacheService { cacheNames = CACHE_NAME_SEB_CONFIG_EXAM, key = "#exam.id", sync = true) - public InMemorySebConfig getDefaultSebConfigForExam(final Exam exam) { + public InMemorySEBConfig getDefaultSEBConfigForExam(final Exam exam) { try { final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); @@ -172,7 +172,7 @@ public class ExamSessionCacheService { exam.institutionId, exam.id); - return new InMemorySebConfig(configId, exam.id, byteOut.toByteArray()); + return new InMemorySEBConfig(configId, exam.id, byteOut.toByteArray()); } catch (final Exception e) { log.error("Unexpected error while getting default exam configuration for running exam; {}", exam, e); @@ -183,7 +183,7 @@ public class ExamSessionCacheService { @CacheEvict( cacheNames = CACHE_NAME_SEB_CONFIG_EXAM, key = "#exam.id") - public void evictDefaultSebConfig(final Exam exam) { + public void evictDefaultSEBConfig(final Exam exam) { if (log.isDebugEnabled()) { log.debug("Eviction of default SEB Configuration from cache for exam: {}", exam.id); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java index 12f41369..b08a0daf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java @@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.SEBServerInitEvent; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService; @Service @WebServiceProfile @@ -35,7 +35,7 @@ class ExamSessionControlTask implements DisposableBean { private static final Logger log = LoggerFactory.getLogger(ExamSessionControlTask.class); private final ExamDAO examDAO; - private final SebClientConnectionService sebClientConnectionService; + private final SEBClientConnectionService sebClientConnectionService; private final ExamUpdateHandler examUpdateHandler; private final Long examTimePrefix; private final Long examTimeSuffix; @@ -58,7 +58,7 @@ class ExamSessionControlTask implements DisposableBean { protected ExamSessionControlTask( final ExamDAO examDAO, - final SebClientConnectionService sebClientConnectionService, + final SEBClientConnectionService sebClientConnectionService, final ExamUpdateHandler examUpdateHandler, @Value("${sebserver.webservice.api.exam.time-prefix:3600000}") final Long examTimePrefix, @Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 31f45403..758ab9b7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -44,7 +44,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSebRestrictionException; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService; @Lazy @@ -131,12 +131,12 @@ public class ExamSessionServiceImpl implements ExamSessionService { if (t.testCourseRestrictionAPI().isOk()) { return t; } else { - throw new NoSebRestrictionException(); + throw new NoSEBRestrictionException(); } }) - .flatMap(t -> t.getSebClientRestriction(exam)) + .flatMap(t -> t.getSEBClientRestriction(exam)) .onError(error -> { - if (error instanceof NoSebRestrictionException) { + if (error instanceof NoSEBRestrictionException) { result.add( ErrorMessage.EXAM_CONSISTENCY_VALIDATION_SEB_RESTRICTION .of(exam.getModelId())); @@ -160,7 +160,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { } @Override - public boolean hasActiveSebClientConnections(final Long examId) { + public boolean hasActiveSEBClientConnections(final Long examId) { if (examId == null || !this.isExamRunning(examId)) { return false; } @@ -271,17 +271,17 @@ public class ExamSessionServiceImpl implements ExamSessionService { } if (log.isDebugEnabled()) { - log.debug("Trying to get exam from InMemorySebConfig"); + log.debug("Trying to get exam from InMemorySEBConfig"); } final Exam exam = this.getRunningExam(connection.examId) .getOrThrow(); - final InMemorySebConfig sebConfigForExam = this.examSessionCacheService - .getDefaultSebConfigForExam(exam); + final InMemorySEBConfig sebConfigForExam = this.examSessionCacheService + .getDefaultSEBConfigForExam(exam); if (sebConfigForExam == null) { - log.error("Failed to get and cache InMemorySebConfig for connection: {}", connection); + log.error("Failed to get and cache InMemorySEBConfig for connection: {}", connection); return; } @@ -342,7 +342,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { public Result flushCache(final Exam exam) { return Result.tryCatch(() -> { this.examSessionCacheService.evict(exam); - this.examSessionCacheService.evictDefaultSebConfig(exam); + this.examSessionCacheService.evictDefaultSEBConfig(exam); this.clientConnectionDAO .getConnectionTokens(exam.id) .getOrElse(Collections::emptyList) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java index 4c0d883a..c6568112 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java @@ -23,7 +23,7 @@ import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService; @Lazy @Service @@ -33,13 +33,13 @@ class ExamUpdateHandler { private static final Logger log = LoggerFactory.getLogger(ExamUpdateHandler.class); private final ExamDAO examDAO; - private final SebRestrictionService sebRestrictionService; + private final SEBRestrictionService sebRestrictionService; private final String updatePrefix; private final Long examTimeSuffix; public ExamUpdateHandler( final ExamDAO examDAO, - final SebRestrictionService sebRestrictionService, + final SEBRestrictionService sebRestrictionService, final WebserviceInfo webserviceInfo, @Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix) { @@ -50,7 +50,7 @@ class ExamUpdateHandler { this.examTimeSuffix = examTimeSuffix; } - public SebRestrictionService getSebRestrictionService() { + public SEBRestrictionService getSEBRestrictionService() { return this.sebRestrictionService; } @@ -82,7 +82,7 @@ class ExamUpdateHandler { exam.id, ExamStatus.RUNNING, updateId)) - .flatMap(this.sebRestrictionService::applySebClientRestriction) + .flatMap(this.sebRestrictionService::applySEBClientRestriction) .flatMap(e -> this.examDAO.releaseLock(e.id, updateId)) .onError(error -> this.examDAO.forceUnlock(exam.id) .onError(unlockError -> log.error("Failed to force unlock update look for exam: {}", exam.id))) @@ -100,7 +100,7 @@ class ExamUpdateHandler { exam.id, ExamStatus.FINISHED, updateId)) - .flatMap(this.sebRestrictionService::releaseSebClientRestriction) + .flatMap(this.sebRestrictionService::releaseSEBClientRestriction) .flatMap(e -> this.examDAO.releaseLock(e.id, updateId)) .onError(error -> this.examDAO.forceUnlock(exam.id)) .getOrThrow(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySebConfig.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySEBConfig.java similarity index 88% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySebConfig.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySEBConfig.java index bf93d2a8..a648741c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySebConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/InMemorySEBConfig.java @@ -8,13 +8,13 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.session.impl; -public final class InMemorySebConfig { +public final class InMemorySEBConfig { public final Long configId; public final Long examId; private final byte[] data; - protected InMemorySebConfig(final Long configId, final Long examId, final byte[] data) { + protected InMemorySEBConfig(final Long configId, final Long examId, final byte[] data) { super(); this.configId = configId; this.examId = examId; @@ -50,7 +50,7 @@ public final class InMemorySebConfig { return false; if (getClass() != obj.getClass()) return false; - final InMemorySebConfig other = (InMemorySebConfig) obj; + final InMemorySEBConfig other = (InMemorySEBConfig) obj; if (this.configId == null) { if (other.configId != null) return false; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebClientConnectionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebClientConnectionServiceImpl.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java index 20a836a0..47a13ef4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebClientConnectionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java @@ -33,20 +33,20 @@ import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.session.EventHandlingStrategy; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService; import ch.ethz.seb.sebserver.webservice.servicelayer.session.PingHandlingStrategy; -import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService; -import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebInstructionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBInstructionService; import ch.ethz.seb.sebserver.webservice.weblayer.api.APIConstraintViolationException; @Lazy @Service @WebServiceProfile -public class SebClientConnectionServiceImpl implements SebClientConnectionService { +public class SEBClientConnectionServiceImpl implements SEBClientConnectionService { - private static final Logger log = LoggerFactory.getLogger(SebClientConnectionServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(SEBClientConnectionServiceImpl.class); private final ExamSessionService examSessionService; private final ExamSessionCacheService examSessionCacheService; @@ -54,16 +54,16 @@ public class SebClientConnectionServiceImpl implements SebClientConnectionServic private final EventHandlingStrategy eventHandlingStrategy; private final ClientConnectionDAO clientConnectionDAO; private final PingHandlingStrategy pingHandlingStrategy; - private final SebClientConfigDAO sebClientConfigDAO; - private final SebInstructionService sebInstructionService; + private final SEBClientConfigDAO sebClientConfigDAO; + private final SEBInstructionService sebInstructionService; private final WebserviceInfo webserviceInfo; - protected SebClientConnectionServiceImpl( + protected SEBClientConnectionServiceImpl( final ExamSessionService examSessionService, final EventHandlingStrategyFactory eventHandlingStrategyFactory, final PingHandlingStrategyFactory pingHandlingStrategyFactory, - final SebClientConfigDAO sebClientConfigDAO, - final SebInstructionService sebInstructionService) { + final SEBClientConfigDAO sebClientConfigDAO, + final SEBInstructionService sebInstructionService) { this.examSessionService = examSessionService; this.examSessionCacheService = examSessionService.getExamSessionCacheService(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebInstructionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBInstructionServiceImpl.java similarity index 95% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebInstructionServiceImpl.java rename to src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBInstructionServiceImpl.java index 3e3f0ffa..a2e400ed 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SebInstructionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBInstructionServiceImpl.java @@ -33,14 +33,14 @@ 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; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientInstructionDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebInstructionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBInstructionService; @Lazy @Service @WebServiceProfile -public class SebInstructionServiceImpl implements SebInstructionService { +public class SEBInstructionServiceImpl implements SEBInstructionService { - private static final Logger log = LoggerFactory.getLogger(SebInstructionServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(SEBInstructionServiceImpl.class); private static final String JSON_INST = "instruction"; private static final String JSON_ATTR = "attributes"; @@ -52,7 +52,7 @@ public class SebInstructionServiceImpl implements SebInstructionService { private long lastRefresh = 0; - public SebInstructionServiceImpl( + public SEBInstructionServiceImpl( final WebserviceInfo webserviceInfo, final ClientConnectionDAO clientConnectionDAO, final ClientInstructionDAO clientInstructionDAO) { @@ -71,7 +71,7 @@ public class SebInstructionServiceImpl implements SebInstructionService { @EventListener(SEBServerInitEvent.class) public void init() { SEBServerInit.INIT_LOGGER.info("------>"); - SEBServerInit.INIT_LOGGER.info("------> Run SebInstructionService..."); + SEBServerInit.INIT_LOGGER.info("------> Run SEBInstructionService..."); loadInstruction() .onError( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java index 06d9ad13..9917fb2f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java @@ -48,9 +48,9 @@ import ch.ethz.seb.sebserver.gbl.model.session.RunningExamInfo; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService; -import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService; @WebServiceProfile @RestController @@ -61,16 +61,16 @@ public class ExamAPI_V1_Controller { private final LmsSetupDAO lmsSetupDAO; private final ExamSessionService examSessionService; - private final SebClientConnectionService sebClientConnectionService; - private final SebClientConfigDAO sebClientConfigDAO; + private final SEBClientConnectionService sebClientConnectionService; + private final SEBClientConfigDAO sebClientConfigDAO; private final JSONMapper jsonMapper; private final Executor executor; protected ExamAPI_V1_Controller( final LmsSetupDAO lmsSetupDAO, final ExamSessionService examSessionService, - final SebClientConnectionService sebClientConnectionService, - final SebClientConfigDAO sebClientConfigDAO, + final SEBClientConnectionService sebClientConnectionService, + final SEBClientConfigDAO sebClientConfigDAO, final JSONMapper jsonMapper, @Qualifier(AsyncServiceSpringConfig.EXAM_API_EXECUTOR_BEAN_NAME) final Executor executor) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java index 61b46644..1345c574 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java @@ -51,7 +51,7 @@ import ch.ethz.seb.sebserver.gbl.model.PageSortOrder; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction; +import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features; import ch.ethz.seb.sebserver.gbl.model.user.UserRole; @@ -69,7 +69,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService; import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService; @@ -87,7 +87,7 @@ public class ExamAdministrationController extends EntityController { private final LmsAPIService lmsAPIService; private final ExamConfigService sebExamConfigService; private final ExamSessionService examSessionService; - private final SebRestrictionService sebRestrictionService; + private final SEBRestrictionService sebRestrictionService; public ExamAdministrationController( final AuthorizationService authorization, @@ -101,7 +101,7 @@ public class ExamAdministrationController extends EntityController { final ExamAdminService examAdminService, final ExamConfigService sebExamConfigService, final ExamSessionService examSessionService, - final SebRestrictionService sebRestrictionService) { + final SEBRestrictionService sebRestrictionService) { super(authorization, bulkActionService, @@ -257,7 +257,7 @@ public class ExamAdministrationController extends EntityController { + API.EXAM_ADMINISTRATION_CHECK_RESTRICTION_PATH_SEGMENT, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Boolean checkSebRestriction( + public Boolean checkSEBRestriction( @PathVariable final Long modelId, @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -275,7 +275,7 @@ public class ExamAdministrationController extends EntityController { + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public SebRestriction getSebRestriction( + public SEBRestriction getSEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, required = true, @@ -285,7 +285,7 @@ public class ExamAdministrationController extends EntityController { checkModifyPrivilege(institutionId); return this.entityDAO.byPK(modelId) .flatMap(this.authorization::checkRead) - .flatMap(this.sebRestrictionService::getSebRestrictionFromExam) + .flatMap(this.sebRestrictionService::getSEBRestrictionFromExam) .getOrThrow(); } @@ -294,20 +294,20 @@ public class ExamAdministrationController extends EntityController { + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Exam saveSebRestrictionData( + public Exam saveSEBRestrictionData( @RequestParam( name = API.PARAM_INSTITUTION_ID, required = true, defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId, @PathVariable(API.PARAM_MODEL_ID) final Long examId, - @Valid @RequestBody final SebRestriction sebRestriction) { + @Valid @RequestBody final SEBRestriction sebRestriction) { checkModifyPrivilege(institutionId); return this.entityDAO.byPK(examId) .flatMap(this.authorization::checkModify) - .flatMap(exam -> this.sebRestrictionService.saveSebRestrictionToExam(exam, sebRestriction)) + .flatMap(exam -> this.sebRestrictionService.saveSEBRestrictionToExam(exam, sebRestriction)) .flatMap(exam -> this.examAdminService.isRestricted(exam).getOrThrow() - ? this.applySebRestriction(exam, true) + ? this.applySEBRestriction(exam, true) : Result.of(exam)) .getOrThrow(); } @@ -317,7 +317,7 @@ public class ExamAdministrationController extends EntityController { + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Exam applySebRestriction( + public Exam applySEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, required = true, @@ -327,7 +327,7 @@ public class ExamAdministrationController extends EntityController { checkModifyPrivilege(institutionId); return this.entityDAO.byPK(examlId) .flatMap(this.authorization::checkModify) - .flatMap(exam -> this.applySebRestriction(exam, true)) + .flatMap(exam -> this.applySEBRestriction(exam, true)) .flatMap(this.userActivityLogDAO::logModify) .getOrThrow(); } @@ -337,7 +337,7 @@ public class ExamAdministrationController extends EntityController { + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Exam deleteSebRestriction( + public Exam deleteSEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, required = true, @@ -347,7 +347,7 @@ public class ExamAdministrationController extends EntityController { checkModifyPrivilege(institutionId); return this.entityDAO.byPK(examlId) .flatMap(this.authorization::checkModify) - .flatMap(exam -> this.applySebRestriction(exam, false)) + .flatMap(exam -> this.applySEBRestriction(exam, false)) .flatMap(this.userActivityLogDAO::logModify) .getOrThrow(); } @@ -445,8 +445,8 @@ public class ExamAdministrationController extends EntityController { return exam; } - private Result checkNoActiveSebClientConnections(final Exam exam) { - if (this.examSessionService.hasActiveSebClientConnections(exam.id)) { + private Result checkNoActiveSEBClientConnections(final Exam exam) { + if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) { return Result.ofError(new APIMessageException( APIMessage.ErrorMessage.INTEGRITY_VALIDATION .of("Exam currently has active SEB Client connections."))); @@ -455,7 +455,7 @@ public class ExamAdministrationController extends EntityController { return Result.of(exam); } - private Result applySebRestriction(final Exam exam, final boolean restrict) { + private Result applySEBRestriction(final Exam exam, final boolean restrict) { final LmsSetup lmsSetup = this.lmsAPIService.getLmsSetup(exam.lmsSetupId) .getOrThrow(); @@ -474,18 +474,18 @@ public class ExamAdministrationController extends EntityController { .of("The LMS for this Exam has no SEB restriction feature"))); } - if (this.examSessionService.hasActiveSebClientConnections(exam.id)) { + if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) { return Result.ofError(new APIMessageException( APIMessage.ErrorMessage.INTEGRITY_VALIDATION .of("Exam currently has active SEB Client connections."))); } - return this.checkNoActiveSebClientConnections(exam) - .flatMap(this.sebRestrictionService::applySebClientRestriction) - .flatMap(e -> this.examDAO.setSebRestriction(exam.id, restrict)); + return this.checkNoActiveSEBClientConnections(exam) + .flatMap(this.sebRestrictionService::applySEBClientRestriction) + .flatMap(e -> this.examDAO.setSEBRestriction(exam.id, restrict)); } else { - return this.sebRestrictionService.releaseSebClientRestriction(exam) - .flatMap(e -> this.examDAO.setSebRestriction(exam.id, restrict)); + return this.sebRestrictionService.releaseSEBClientRestriction(exam) + .flatMap(e -> this.examDAO.setSEBRestriction(exam.id, restrict)); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java index 0b459556..f153c6d3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java @@ -237,7 +237,7 @@ public class ExamConfigurationMappingController extends EntityController { +public class SEBClientConfigController extends ActivatableEntityController { private final ClientConfigService sebClientConfigService; - public SebClientConfigController( - final SebClientConfigDAO sebClientConfigDAO, + public SEBClientConfigController( + final SEBClientConfigDAO sebClientConfigDAO, final AuthorizationService authorization, final UserActivityLogDAO userActivityLogDAO, final BulkActionService bulkActionService, @@ -96,7 +96,7 @@ public class SebClientConfigController extends ActivatableEntityController validForCreate(final SebClientConfig entity) { + protected Result validForCreate(final SEBClientConfig entity) { return super.validForCreate(entity) .map(this::checkPasswordMatch); } @Override - protected Result validForSave(final SebClientConfig entity) { + protected Result validForSave(final SEBClientConfig entity) { return super.validForSave(entity) .map(this::checkPasswordMatch); } @Override - protected Result notifySaved(final SebClientConfig entity) { + protected Result notifySaved(final SEBClientConfig entity) { if (entity.isActive()) { // try to get access token for SEB client this.sebClientConfigService.initalCheckAccess(entity); @@ -155,7 +155,7 @@ public class SebClientConfigController extends ActivatableEntityController errors = new ArrayList<>(); if (entity.hasEncryptionSecret() && !entity.encryptSecret.equals(entity.encryptSecretConfirm)) { errors.add(APIMessage.fieldValidationError( @@ -169,7 +169,7 @@ public class SebClientConfigController extends ActivatableEntityController call = restService.getBuilder(NewClientConfig.class) + final Result call = restService.getBuilder(NewClientConfig.class) .withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config") .withFormParam("Test", "new client config") - .withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name()) + .withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name()) .call(); assertNotNull(call); assertFalse(call.hasError()); - final SebClientConfig createdConfig = call.get(); + final SEBClientConfig createdConfig = call.get(); assertEquals(Long.valueOf(1), createdConfig.id); assertEquals("new client config", createdConfig.name); assertFalse(createdConfig.active); @@ -50,14 +50,14 @@ public class ClientConfigTest extends GuiIntegrationTest { public void testNewClientConfigWithURLEncodedForm() { final RestServiceImpl restService = createRestServiceForUser("admin", "admin", new NewClientConfig()); - final Result call = restService.getBuilder(NewClientConfig.class) + final Result call = restService.getBuilder(NewClientConfig.class) .withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config") - .withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name()) + .withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name()) .call(); assertNotNull(call); assertFalse(call.hasError()); - final SebClientConfig createdConfig = call.get(); + final SEBClientConfig createdConfig = call.get(); assertEquals(Long.valueOf(1), createdConfig.id); assertEquals("new client config", createdConfig.name); assertFalse(createdConfig.active); @@ -73,20 +73,20 @@ public class ClientConfigTest extends GuiIntegrationTest { new DeactivateClientConfig()); // create one - final SebClientConfig config = restService.getBuilder(NewClientConfig.class) + final SEBClientConfig config = restService.getBuilder(NewClientConfig.class) .withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config") - .withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name()) + .withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name()) .call() .getOrThrow(); // get - final Result call = restService.getBuilder(GetClientConfig.class) + final Result call = restService.getBuilder(GetClientConfig.class) .withURIVariable(API.PARAM_MODEL_ID, config.getModelId()) .call(); assertNotNull(call); assertFalse(call.hasError()); - final SebClientConfig createdConfig = call.get(); + final SEBClientConfig createdConfig = call.get(); assertEquals(config.id, createdConfig.id); assertEquals("new client config", createdConfig.name); assertFalse(createdConfig.active); @@ -104,11 +104,11 @@ public class ClientConfigTest extends GuiIntegrationTest { // save with password (no confirm) expecting validation error final Result valError = restService.getBuilder(SaveClientConfig.class) - .withBody(new SebClientConfig( + .withBody(new SEBClientConfig( config.id, config.institutionId, "new client config", - SebClientConfig.ConfigPurpose.START_EXAM, + SEBClientConfig.ConfigPurpose.START_EXAM, null, null, null, @@ -130,12 +130,12 @@ public class ClientConfigTest extends GuiIntegrationTest { assertTrue(error.getMessage().contains("password.mismatch")); // save with new password - final SebClientConfig newConfig = restService.getBuilder(SaveClientConfig.class) - .withBody(new SebClientConfig( + final SEBClientConfig newConfig = restService.getBuilder(SaveClientConfig.class) + .withBody(new SEBClientConfig( config.id, config.institutionId, "new client config", - SebClientConfig.ConfigPurpose.START_EXAM, + SEBClientConfig.ConfigPurpose.START_EXAM, null, null, null, diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index da4bcfbe..9b6d530c 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -66,7 +66,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues.TableValue; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation; -import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.sebconfig.TemplateAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.View; import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange; @@ -136,7 +136,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Sa import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SebExamConfigUndo; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount; @@ -930,20 +930,20 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { new ExportClientConfig()); // create SEB Client Config without password protection - final Result newConfigResponse = restService + final Result newConfigResponse = restService .getBuilder(NewClientConfig.class) .withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "No Password Protection") - .withFormParam(SebClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING) - .withFormParam(SebClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback") - .withFormParam(SebClientConfig.ATTR_FALLBACK_TIMEOUT, "100") - .withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPTS, "5") - .withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5") - .withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name()) + .withFormParam(SEBClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING) + .withFormParam(SEBClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_TIMEOUT, "100") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, "5") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5") + .withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name()) .call(); assertNotNull(newConfigResponse); assertFalse(newConfigResponse.hasError()); - final SebClientConfig sebClientConfig = newConfigResponse.get(); + final SEBClientConfig sebClientConfig = newConfigResponse.get(); assertEquals("No Password Protection", sebClientConfig.name); assertFalse(sebClientConfig.isActive()); assertEquals("http://fallback.com/fallback", sebClientConfig.fallbackStartURL); @@ -957,33 +957,33 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertNotNull(activationResponse); assertFalse(activationResponse.hasError()); - final Result getConfigResponse = restService + final Result getConfigResponse = restService .getBuilder(GetClientConfig.class) .withURIVariable(API.PARAM_MODEL_ID, sebClientConfig.getModelId()) .call(); assertNotNull(getConfigResponse); assertFalse(getConfigResponse.hasError()); - final SebClientConfig activeConfig = getConfigResponse.get(); + final SEBClientConfig activeConfig = getConfigResponse.get(); assertTrue(activeConfig.isActive()); // create a config with password protection - final Result configWithPasswordResponse = restService + final Result configWithPasswordResponse = restService .getBuilder(NewClientConfig.class) .withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "With Password Protection") - .withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name()) - .withFormParam(SebClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING) - .withFormParam(SebClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback") - .withFormParam(SebClientConfig.ATTR_FALLBACK_TIMEOUT, "100") - .withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPTS, "5") - .withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5") + .withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name()) + .withFormParam(SEBClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING) + .withFormParam(SEBClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_TIMEOUT, "100") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, "5") + .withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5") .withFormParam(SEB_CLIENT_CONFIGURATION.ATTR_ENCRYPT_SECRET, "123") - .withFormParam(SebClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, "123") + .withFormParam(SEBClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, "123") .call(); assertNotNull(configWithPasswordResponse); assertFalse(configWithPasswordResponse.hasError()); - final SebClientConfig configWithPassword = configWithPasswordResponse.get(); + final SEBClientConfig configWithPassword = configWithPasswordResponse.get(); assertEquals("With Password Protection", configWithPassword.name); assertFalse(configWithPassword.isActive()); assertEquals("http://fallback.com/fallback", configWithPassword.fallbackStartURL); @@ -1015,13 +1015,13 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertFalse(readLines.isEmpty()); // get page - final Result> pageResponse = restService + final Result> pageResponse = restService .getBuilder(GetClientConfigPage.class) .call(); assertNotNull(pageResponse); assertFalse(pageResponse.hasError()); - final Page page = pageResponse.get(); + final Page page = pageResponse.get(); assertFalse(page.content.isEmpty()); assertTrue(page.content.size() == 2); } @@ -1097,7 +1097,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { new GetConfigurations(), new SaveExamConfigHistory(), new GetConfigurationTableValues(), - new SebExamConfigUndo(), + new SEBExamConfigUndo(), new SaveExamConfigValue(), new SaveExamConfigTableValues(), new GetConfigurationValuePage(), @@ -1261,7 +1261,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // undo final Result undoResponse = restService - .getBuilder(SebExamConfigUndo.class) + .getBuilder(SEBExamConfigUndo.class) .withURIVariable(API.PARAM_MODEL_ID, followup.getModelId()) .call(); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptorTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptorTest.java index 56852cad..06bb2ca8 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptorTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/PasswordEncryptorTest.java @@ -23,9 +23,9 @@ import org.cryptonode.jncryptor.JNCryptor; import org.junit.Test; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext; public class PasswordEncryptorTest { @@ -71,7 +71,7 @@ public class PasswordEncryptorTest { final String pwd = "password"; final ByteArrayOutputStream out = new ByteArrayOutputStream(512); - final SebConfigEncryptionContext context = EncryptionContext.contextOf( + final SEBConfigEncryptionContext context = EncryptionContext.contextOf( Strategy.PASSWORD_PWCC, pwd); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImplTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImplTest.java index 6db5d6ca..355c3428 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImplTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/SebConfigEncryptionServiceImplTest.java @@ -23,15 +23,15 @@ import org.cryptonode.jncryptor.JNCryptor; import org.junit.Test; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy; -import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy; +import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext; public class SebConfigEncryptionServiceImplTest { @Test public void testPlainText() throws IOException { - final SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl(); + final SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl(); final String config = ""; @@ -63,7 +63,7 @@ public class SebConfigEncryptionServiceImplTest { @Test public void testPasswordEncryption() throws IOException { - final SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl(); + final SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl(); final String config = ""; final String pwd = "password"; @@ -96,12 +96,12 @@ public class SebConfigEncryptionServiceImplTest { assertEquals(config, decryptedConfig); } - private SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl() { + private SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl() { final JNCryptor cryptor = new AES256JNCryptor(); - final List encryptors = Arrays.asList( + final List encryptors = Arrays.asList( new PasswordEncryptor(cryptor), new NoneEncryptor()); - return new SebConfigEncryptionServiceImpl(encryptors); + return new SEBConfigEncryptionServiceImpl(encryptors); } } From 8e7cb416aef3664615e68de65c40ecb3153f3122 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 8 Jun 2020 10:55:40 +0200 Subject: [PATCH 03/26] added cached exam update check for running on distributed system --- .../ch/ethz/seb/sebserver/gbl/model/EntityKey.java | 11 ++--------- .../webservice/servicelayer/dao/ExamDAO.java | 2 +- .../session/impl/ExamSessionServiceImpl.java | 5 +++++ .../weblayer/api/ConfigurationNodeController.java | 3 ++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityKey.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityKey.java index ad785589..cc8a5cac 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityKey.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityKey.java @@ -18,15 +18,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import ch.ethz.seb.sebserver.gbl.api.EntityType; -/** A EntityKey uniquely identifies a domain entity within the SEB Server's domain model. - * A EntityKey consists of the model identifier of a domain entity and the type of the entity. - * JSON: - *
- *
- *
- * 
- * - * */ +/** An EntityKey uniquely identifies a domain entity within the SEB Server's domain model. + * An EntityKey consists of the model identifier of a domain entity and the type of the entity. */ @JsonIgnoreProperties(ignoreUnknown = true) public class EntityKey implements ModelIdAware, Serializable { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java index deed1392..2e5cbb4e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java @@ -114,7 +114,7 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup * @return Result refer to the lock-check-result or to an error if happened */ Result isLocked(Long examId); - /** Use this to check of the exam with the specified identifier is up to date + /** Use this to check if the exam with the specified identifier is up to date * * @param examId the exam identifier * @param updateId the update identifier of the exam diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 758ab9b7..66babe9c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -199,6 +199,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { log.trace("Running exam request for exam {}", examId); } + updateExamCache(examId); final Exam exam = this.examSessionCacheService.getRunningExam(examId); if (this.examSessionCacheService.isRunning(exam)) { @@ -327,6 +328,10 @@ public class ExamSessionServiceImpl implements ExamSessionService { @Override public Result updateExamCache(final Long examId) { final Exam exam = this.examSessionCacheService.getRunningExam(examId); + if (exam == null) { + return Result.ofEmpty(); + } + final Boolean isUpToDate = this.examDAO.upToDate(examId, exam.lastUpdate) .onError(t -> log.error("Failed to verify if cached exam is up to date: {}", exam, t)) .getOr(false); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java index f79e715b..6a8380a7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java @@ -270,7 +270,7 @@ public class ConfigurationNodeController extends EntityController doImport = doImport(password, request, followup); if (doImport.hasError()) { - // rollback if the new configuration + // rollback of the new configuration this.configurationNodeDAO.delete(new HashSet<>(Arrays.asList(new EntityKey( followup.configurationNodeId, EntityType.CONFIGURATION_NODE)))); @@ -510,6 +510,7 @@ public class ConfigurationNodeController extends EntityController Date: Tue, 9 Jun 2020 14:44:29 +0200 Subject: [PATCH 04/26] fixed GUI service dependencies (to WebserviceInfo) --- .../java/ch/ethz/seb/sebserver/SEBServerInit.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java b/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java index d4d56a10..8a704889 100644 --- a/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java +++ b/src/main/java/ch/ethz/seb/sebserver/SEBServerInit.java @@ -12,12 +12,11 @@ import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import ch.ethz.seb.sebserver.webservice.WebserviceInfo; - @Lazy @Component public class SEBServerInit { @@ -25,13 +24,15 @@ public class SEBServerInit { public static final Logger INIT_LOGGER = LoggerFactory.getLogger("ch.ethz.seb.SEB_SERVER_INIT"); private final Environment environment; - private final WebserviceInfo webserviceInfo; + private final String version; private boolean initialized = false; - protected SEBServerInit(final Environment environment, final WebserviceInfo webserviceInfo) { + protected SEBServerInit( + final Environment environment, + @Value("${sebserver.version}") final String version) { this.environment = environment; - this.webserviceInfo = webserviceInfo; + this.version = version; } public void init() { @@ -43,7 +44,7 @@ public class SEBServerInit { INIT_LOGGER.info("----> |___/|___||___/ |___/\\___||_| \\_/ \\___||_| "); INIT_LOGGER.info("---->"); INIT_LOGGER.info("---->"); - INIT_LOGGER.info("----> Version: {}", this.webserviceInfo.getSEBServerVersion()); + INIT_LOGGER.info("----> Version: {}", this.version); INIT_LOGGER.info("---->"); INIT_LOGGER.info("----> Active profiles: {}", Arrays.toString(this.environment.getActiveProfiles())); INIT_LOGGER.info("---->"); @@ -51,5 +52,4 @@ public class SEBServerInit { this.initialized = true; } } - } From 532101befda665e328697f5993fe21bd606c2380 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 9 Jun 2020 16:56:14 +0200 Subject: [PATCH 05/26] fixed another dependency bug, moved ClientCredentialService to glb --- .../seb/sebserver/ClientHttpRequestFactoryService.java | 4 ++-- .../client/ClientCredentialService.java | 2 +- .../client/ClientCredentialServiceImpl.java | 4 +--- .../servicelayer => gbl}/client/ClientCredentials.java | 2 +- .../{webservice/servicelayer => gbl}/client/ProxyData.java | 2 +- .../seb/sebserver/webservice/AdminUserInitializer.java | 2 +- .../sebserver/webservice/servicelayer/dao/LmsSetupDAO.java | 4 ++-- .../webservice/servicelayer/dao/SEBClientConfigDAO.java | 2 +- .../servicelayer/dao/impl/ExamConfigurationMapDAOImpl.java | 2 +- .../webservice/servicelayer/dao/impl/LmsSetupDAOImpl.java | 6 +++--- .../servicelayer/dao/impl/SEBClientConfigDAOImpl.java | 4 ++-- .../servicelayer/lms/impl/LmsAPIServiceImpl.java | 6 +++--- .../servicelayer/lms/impl/MockupLmsAPITemplate.java | 2 +- .../lms/impl/edx/OpenEdxLmsAPITemplateFactory.java | 6 +++--- .../lms/impl/edx/OpenEdxRestTemplateFactory.java | 6 +++--- .../lms/impl/moodle/MoodleLmsAPITemplateFactory.java | 6 +++--- .../lms/impl/moodle/MoodleRestTemplateFactory.java | 7 ++++--- .../sebconfig/impl/ClientConfigServiceImpl.java | 4 ++-- .../servicelayer/sebconfig/impl/ExamConfigServiceImpl.java | 2 +- .../sebconfig/impl/converter/StringConverter.java | 2 +- .../client/ClientCredentialServiceTest.java | 3 ++- .../sebconfig/impl/converter/TableConverterTest.java | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) rename src/main/java/ch/ethz/seb/sebserver/{webservice/servicelayer => gbl}/client/ClientCredentialService.java (98%) rename src/main/java/ch/ethz/seb/sebserver/{webservice/servicelayer => gbl}/client/ClientCredentialServiceImpl.java (97%) rename src/main/java/ch/ethz/seb/sebserver/{webservice/servicelayer => gbl}/client/ClientCredentials.java (93%) rename src/main/java/ch/ethz/seb/sebserver/{webservice/servicelayer => gbl}/client/ProxyData.java (92%) rename src/test/java/ch/ethz/seb/sebserver/{webservice/servicelayer => gbl}/client/ClientCredentialServiceTest.java (94%) diff --git a/src/main/java/ch/ethz/seb/sebserver/ClientHttpRequestFactoryService.java b/src/main/java/ch/ethz/seb/sebserver/ClientHttpRequestFactoryService.java index eb8cf754..6e69a81e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/ClientHttpRequestFactoryService.java +++ b/src/main/java/ch/ethz/seb/sebserver/ClientHttpRequestFactoryService.java @@ -45,12 +45,12 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.ResourceUtils; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; @Lazy @Service diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialService.java b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java similarity index 98% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialService.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java index 386d861b..6614b6b5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package ch.ethz.seb.sebserver.webservice.servicelayer.client; +package ch.ethz.seb.sebserver.gbl.client; import ch.ethz.seb.sebserver.gbl.util.Result; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceImpl.java similarity index 97% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceImpl.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceImpl.java index 525ab263..12e23887 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceImpl.java @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package ch.ethz.seb.sebserver.webservice.servicelayer.client; +package ch.ethz.seb.sebserver.gbl.client; import java.nio.CharBuffer; import java.security.SecureRandom; @@ -19,13 +19,11 @@ import org.springframework.context.annotation.Lazy; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; -import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Cryptor; import ch.ethz.seb.sebserver.gbl.util.Result; @Lazy @Service -@WebServiceProfile public class ClientCredentialServiceImpl implements ClientCredentialService { private static final Logger log = LoggerFactory.getLogger(ClientCredentialServiceImpl.class); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentials.java b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentials.java similarity index 93% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentials.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentials.java index d25d6f89..5aac3b34 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentials.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentials.java @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package ch.ethz.seb.sebserver.webservice.servicelayer.client; +package ch.ethz.seb.sebserver.gbl.client; /** Defines a simple data bean holding (encrypted) client credentials */ public final class ClientCredentials { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ProxyData.java b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ProxyData.java similarity index 92% rename from src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ProxyData.java rename to src/main/java/ch/ethz/seb/sebserver/gbl/client/ProxyData.java index 57467704..1edfd3c5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ProxyData.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ProxyData.java @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package ch.ethz.seb.sebserver.webservice.servicelayer.client; +package ch.ethz.seb.sebserver.gbl.client; public class ProxyData { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/AdminUserInitializer.java b/src/main/java/ch/ethz/seb/sebserver/webservice/AdminUserInitializer.java index acdf426e..93553f67 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/AdminUserInitializer.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/AdminUserInitializer.java @@ -10,13 +10,13 @@ package ch.ethz.seb.sebserver.webservice; import ch.ethz.seb.sebserver.SEBServerInit; import ch.ethz.seb.sebserver.WebSecurityConfig; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialServiceImpl; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.model.user.UserMod; import ch.ethz.seb.sebserver.gbl.model.user.UserRole; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.impl.SEBServerUser; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialServiceImpl; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserDAO; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/LmsSetupDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/LmsSetupDAO.java index c065f0ac..771587f7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/LmsSetupDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/LmsSetupDAO.java @@ -8,11 +8,11 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.dao; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionSupportDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; /** Concrete EntityDAO interface of LmsSetup entities */ public interface LmsSetupDAO extends ActivatableEntityDAO, BulkActionSupportDAO { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java index d499dff9..0d803429 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/SEBClientConfigDAO.java @@ -13,11 +13,11 @@ import java.util.Set; import org.springframework.cache.annotation.CacheEvict; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionSupportDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService; /** Concrete EntityDAO interface of SEBClientConfig entities */ diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamConfigurationMapDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamConfigurationMapDAOImpl.java index f6e70e47..fdd11fdd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamConfigurationMapDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamConfigurationMapDAOImpl.java @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import ch.ethz.seb.sebserver.gbl.api.API.BulkActionType; import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException; import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; @@ -48,7 +49,6 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ConfigurationNodeR import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ExamConfigurationMapRecord; import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ExamRecord; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.impl.BulkAction; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamConfigurationMapDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/LmsSetupDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/LmsSetupDAOImpl.java index 274f4a2c..5a0e59b5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/LmsSetupDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/LmsSetupDAOImpl.java @@ -26,6 +26,9 @@ import org.springframework.transaction.annotation.Transactional; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.EntityKey; @@ -38,9 +41,6 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordDyn import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordMapper; import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.LmsSetupRecord; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.impl.BulkAction; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java index 9e7676bc..abf0523c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java @@ -31,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException; import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.EntityKey; @@ -44,8 +46,6 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.SebClientConfigRe import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.AdditionalAttributeRecord; import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.SebClientConfigRecord; import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.impl.BulkAction; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ResourceNotFoundException; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPIServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPIServiceImpl.java index c0d46030..3c83aa98 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPIServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPIServiceImpl.java @@ -22,6 +22,9 @@ import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import ch.ethz.seb.sebserver.gbl.Constants; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; @@ -29,9 +32,6 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java index 52252256..3c3ee250 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java @@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.APIMessage; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP; import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; @@ -32,7 +33,6 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplateFactory.java index 87ef5114..0be3ed27 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxLmsAPITemplateFactory.java @@ -17,13 +17,13 @@ import ch.ethz.seb.sebserver.ClientHttpRequestFactoryService; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.async.AsyncService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; @Lazy @Service diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxRestTemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxRestTemplateFactory.java index 00692faf..77dc9f44 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxRestTemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/edx/OpenEdxRestTemplateFactory.java @@ -35,13 +35,13 @@ import org.springframework.util.MultiValueMap; import ch.ethz.seb.sebserver.ClientHttpRequestFactoryService; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.APIMessage; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; final class OpenEdxRestTemplateFactory { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplateFactory.java index 30492c09..b6b1114a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleLmsAPITemplateFactory.java @@ -17,12 +17,12 @@ import ch.ethz.seb.sebserver.ClientHttpRequestFactoryService; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.async.AsyncService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; @Lazy @Service diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactory.java index 8fb42471..6dfbc0c2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactory.java @@ -11,14 +11,15 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle; import ch.ethz.seb.sebserver.ClientHttpRequestFactoryService; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.client.ProxyData; import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ProxyData; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java index 75eb40e6..a3986c98 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ClientConfigServiceImpl.java @@ -42,14 +42,14 @@ import org.springframework.web.client.RestTemplate; import ch.ethz.seb.sebserver.WebSecurityConfig; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java index 4585706e..fba24d73 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java @@ -30,13 +30,13 @@ import org.springframework.stereotype.Service; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException; import ch.ethz.seb.sebserver.gbl.api.APIMessage.FieldValidationException; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ConfigurationAttributeDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamConfigurationMapDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationFormat; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java index 140c3ccb..eabac5f7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java @@ -22,12 +22,12 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.gbl.Constants; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Utils; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.AttributeValueConverter; import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.ExamConfigXMLParser; diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceTest.java b/src/test/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceTest.java similarity index 94% rename from src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceTest.java rename to src/test/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceTest.java index 01384d7e..ec38bc0a 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/client/ClientCredentialServiceTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialServiceTest.java @@ -6,12 +6,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package ch.ethz.seb.sebserver.webservice.servicelayer.client; +package ch.ethz.seb.sebserver.gbl.client; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialServiceImpl; import ch.ethz.seb.sebserver.gbl.util.Cryptor; import org.junit.Test; import org.springframework.core.env.Environment; diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverterTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverterTest.java index a45490d3..1711cece 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverterTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverterTest.java @@ -17,10 +17,10 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService; import org.junit.Test; import org.mockito.Mockito; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentialService; import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; From bb5f0c0198a919ecf7ae9a06f208b5283b6321f6 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 9 Jun 2020 17:34:25 +0200 Subject: [PATCH 06/26] splitted application.properties to ws and gui profiles --- .../config/application-gui.properties | 26 ++++++ .../config/application-ws.properties | 54 ++++++++++++ .../resources/config/application.properties | 82 ------------------- 3 files changed, 80 insertions(+), 82 deletions(-) create mode 100644 src/main/resources/config/application-gui.properties create mode 100644 src/main/resources/config/application-ws.properties diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties new file mode 100644 index 00000000..e5662679 --- /dev/null +++ b/src/main/resources/config/application-gui.properties @@ -0,0 +1,26 @@ +########################################################## +### SEB Server GUI configuration + +# theme +sebserver.gui.theme=css/sebserver.css +sebserver.gui.list.page.size=20 +sebserver.gui.defaultLogo=classpath:/static/images/sebserver-logo.png + +# User Account +sebserver.gui.self-registering=true +sebserver.gui.multilingual=false +sebserver.gui.supported.languages=en +sebserver.gui.date.displayformat=de + +# GUI API +sebserver.gui.entrypoint=/gui +sebserver.gui.webservice.protocol=http +sebserver.gui.webservice.address=localhost +sebserver.gui.webservice.port=8080 +sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint} +# defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page +sebserver.gui.webservice.poll-interval=1000 +sebserver.gui.webservice.mock-lms-enabled=true +sebserver.gui.seb.client.config.download.filename=SEBServerSettings.seb +sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb + diff --git a/src/main/resources/config/application-ws.properties b/src/main/resources/config/application-ws.properties new file mode 100644 index 00000000..559f1061 --- /dev/null +++ b/src/main/resources/config/application-ws.properties @@ -0,0 +1,54 @@ +########################################################## +### SEB Server Webservice configuration + +sebserver.test.property=This is the default/root configuration + +### webservice initialization +sebserver.init.adminaccount.gen-on-init=true +sebserver.init.organisation.name=SEB Server +sebserver.init.adminaccount.username=sebserver-admin + +### webservice data source configuration +spring.datasource.username=root +spring.datasource.initialize=true +spring.datasource.initialization-mode=always +spring.datasource.url=jdbc:mariadb://${datastore.mariadb.server.address}:${datastore.mariadb.server.port}/SEBServer?useSSL=false&createDatabaseIfNotExist=true +spring.flyway.enabled=true +spring.flyway.locations=classpath:config/sql/base +spring.flyway.cleanDisabled=true +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.datasource.hikari.initializationFailTimeout=3000 +spring.datasource.hikari.connectionTimeout=30000 +spring.datasource.hikari.idleTimeout=600000 +spring.datasource.hikari.maxLifetime=1800000 + +### webservice security +spring.datasource.password=${sebserver.mariadb.password} +sebserver.webservice.api.admin.clientSecret=${sebserver.password} +sebserver.webservice.internalSecret=${sebserver.password} + +### webservice networking +sebserver.webservice.distributed=false +sebserver.webservice.http.external.scheme=https +sebserver.webservice.http.external.servername= +sebserver.webservice.http.external.port= +sebserver.webservice.http.redirect.gui=/gui + +### webservice API +sebserver.webservice.api.admin.clientId=guiClient +sebserver.webservice.api.admin.endpoint=/admin-api/v1 +sebserver.webservice.api.admin.accessTokenValiditySeconds=3600 +sebserver.webservice.api.admin.refreshTokenValiditySeconds=25200 +sebserver.webservice.api.exam.config.init.permittedProcesses=config/initialPermittedProcesses.xml +sebserver.webservice.api.exam.config.init.prohibitedProcesses=config/initialProhibitedProcesses.xml +sebserver.webservice.api.exam.endpoint=/exam-api +sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery +sebserver.webservice.api.exam.endpoint.v1=${sebserver.webservice.api.exam.endpoint}/v1 +sebserver.webservice.api.exam.accessTokenValiditySeconds=3600 +sebserver.webservice.api.exam.event-handling-strategy=SINGLE_EVENT_STORE_STRATEGY +sebserver.webservice.api.exam.enable-indicator-cache=true +sebserver.webservice.api.pagination.maxPageSize=500 +# comma separated list of known possible OpenEdX API access token request endpoints +sebserver.webservice.lms.openedx.api.token.request.paths=/oauth2/access_token +sebserver.webservice.lms.moodle.api.token.request.paths=/login/token.php +sebserver.webservice.lms.address.alias= \ No newline at end of file diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index 865d7213..f53b0aa1 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -54,85 +54,3 @@ security.require-ssl=false # Disable this if a redirect is done by a reverse proxy for example sebserver.ssl.redirect.enabled=false sebserver.ssl.redirect.html.port=8080 - -########################################################## -### SEB Server Webservice configuration - -sebserver.test.property=This is the default/root configuration - -### webservice initialization -sebserver.init.adminaccount.gen-on-init=true -sebserver.init.organisation.name=SEB Server -sebserver.init.adminaccount.username=sebserver-admin - -### webservice data source configuration -spring.datasource.username=root -spring.datasource.initialize=true -spring.datasource.initialization-mode=always -spring.datasource.url=jdbc:mariadb://${datastore.mariadb.server.address}:${datastore.mariadb.server.port}/SEBServer?useSSL=false&createDatabaseIfNotExist=true -spring.flyway.enabled=true -spring.flyway.locations=classpath:config/sql/base -spring.flyway.cleanDisabled=true -spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.datasource.hikari.initializationFailTimeout=3000 -spring.datasource.hikari.connectionTimeout=30000 -spring.datasource.hikari.idleTimeout=600000 -spring.datasource.hikari.maxLifetime=1800000 - -### webservice security -spring.datasource.password=${sebserver.mariadb.password} -sebserver.webservice.api.admin.clientSecret=${sebserver.password} -sebserver.webservice.internalSecret=${sebserver.password} - -### webservice networking -sebserver.webservice.distributed=false -sebserver.webservice.http.external.scheme=https -sebserver.webservice.http.external.servername= -sebserver.webservice.http.external.port= -sebserver.webservice.http.redirect.gui=/gui - -### webservice API -sebserver.webservice.api.admin.clientId=guiClient -sebserver.webservice.api.admin.endpoint=/admin-api/v1 -sebserver.webservice.api.admin.accessTokenValiditySeconds=3600 -sebserver.webservice.api.admin.refreshTokenValiditySeconds=25200 -sebserver.webservice.api.exam.config.init.permittedProcesses=config/initialPermittedProcesses.xml -sebserver.webservice.api.exam.config.init.prohibitedProcesses=config/initialProhibitedProcesses.xml -sebserver.webservice.api.exam.endpoint=/exam-api -sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery -sebserver.webservice.api.exam.endpoint.v1=${sebserver.webservice.api.exam.endpoint}/v1 -sebserver.webservice.api.exam.accessTokenValiditySeconds=3600 -sebserver.webservice.api.exam.event-handling-strategy=SINGLE_EVENT_STORE_STRATEGY -sebserver.webservice.api.exam.enable-indicator-cache=true -sebserver.webservice.api.pagination.maxPageSize=500 -# comma separated list of known possible OpenEdX API access token request endpoints -sebserver.webservice.lms.openedx.api.token.request.paths=/oauth2/access_token -sebserver.webservice.lms.moodle.api.token.request.paths=/login/token.php -sebserver.webservice.lms.address.alias= - -########################################################## -### SEB Server GUI configuration - -# theme -sebserver.gui.theme=css/sebserver.css -sebserver.gui.list.page.size=20 -sebserver.gui.defaultLogo=classpath:/static/images/sebserver-logo.png - -# User Account -sebserver.gui.self-registering=true -sebserver.gui.multilingual=false -sebserver.gui.supported.languages=en -sebserver.gui.date.displayformat=de - -# GUI API -sebserver.gui.entrypoint=/gui -sebserver.gui.webservice.protocol=http -sebserver.gui.webservice.address=localhost -sebserver.gui.webservice.port=8080 -sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint} -# defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page -sebserver.gui.webservice.poll-interval=1000 -sebserver.gui.webservice.mock-lms-enabled=true -sebserver.gui.seb.client.config.download.filename=SEBServerSettings.seb -sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb - From e194c97b663fd5b754f1150ff769a65d90f75196 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 10 Jun 2020 08:46:01 +0200 Subject: [PATCH 07/26] added missing properties for standalone gui service --- src/main/resources/config/application-gui.properties | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties index e5662679..b20bb6cd 100644 --- a/src/main/resources/config/application-gui.properties +++ b/src/main/resources/config/application-gui.properties @@ -24,3 +24,10 @@ sebserver.gui.webservice.mock-lms-enabled=true sebserver.gui.seb.client.config.download.filename=SEBServerSettings.seb sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb +# Webservice connection details +sebserver.webservice.api.exam.endpoint=/exam-api +sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery +sebserver.webservice.http.redirect.gui=${sebserver.gui.entrypoint} +sebserver.webservice.api.admin.endpoint=/admin-api/v1 +sebserver.webservice.api.admin.clientId=guiClient +sebserver.webservice.api.admin.clientSecret=${sebserver.password} \ No newline at end of file From 9ddca15c1e1219cb307a52a22097cea1b78a2d29 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 10 Jun 2020 09:39:15 +0200 Subject: [PATCH 08/26] fixed properties --- src/main/resources/config/application-gui.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties index b20bb6cd..aca55cea 100644 --- a/src/main/resources/config/application-gui.properties +++ b/src/main/resources/config/application-gui.properties @@ -29,5 +29,5 @@ sebserver.webservice.api.exam.endpoint=/exam-api sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery sebserver.webservice.http.redirect.gui=${sebserver.gui.entrypoint} sebserver.webservice.api.admin.endpoint=/admin-api/v1 -sebserver.webservice.api.admin.clientId=guiClient +sebserver.webservice.api.admin.clientId=guiClient sebserver.webservice.api.admin.clientSecret=${sebserver.password} \ No newline at end of file From b63a8e39b3a2969b32544581eedd06a3ff7657b0 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 10 Jun 2020 09:43:39 +0200 Subject: [PATCH 09/26] better error handling --- .../webservice/weblayer/oauth/WebClientDetailsService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebClientDetailsService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebClientDetailsService.java index 6af9d490..ea1585f2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebClientDetailsService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebClientDetailsService.java @@ -66,7 +66,7 @@ public class WebClientDetailsService implements ClientDetailsService { return getForExamClientAPI(clientId) .get(t -> { - log.error("Active ClientConfig not found: ", t); + log.error("Active ClientConfig not found: {} cause: {}", clientId, t.getMessage()); throw new AccessDeniedException(t.getMessage()); }); } From cc22c947939c5875235e6ac27da149f14e39b04a Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 10 Jun 2020 10:13:43 +0200 Subject: [PATCH 10/26] improved GUI startup info --- .../ch/ethz/seb/sebserver/gui/GuiInit.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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 5a139167..4373f5bb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/GuiInit.java @@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.gui; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.ApplicationListener; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.SEBServerInit; @@ -20,9 +21,14 @@ import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; public class GuiInit implements ApplicationListener { private final SEBServerInit sebServerInit; + private final Environment environment; + + protected GuiInit( + final SEBServerInit sebServerInit, + final Environment environment) { - protected GuiInit(final SEBServerInit sebServerInit) { this.sebServerInit = sebServerInit; + this.environment = environment; } @Override @@ -36,6 +42,29 @@ public class GuiInit implements ApplicationListener { SEBServerInit.INIT_LOGGER.info("---->"); SEBServerInit.INIT_LOGGER.info("----> GUI Service successfully successfully started up!"); SEBServerInit.INIT_LOGGER.info("---->"); + + final String webServiceProtocol = this.environment.getProperty("sebserver.gui.webservice.protocol", "http"); + final String webServiceAddress = this.environment.getRequiredProperty("sebserver.gui.webservice.address"); + final String webServicePort = this.environment.getProperty("sebserver.gui.webservice.port", "80"); + + SEBServerInit.INIT_LOGGER.info("----> Webservice connection: " + webServiceProtocol + "://" + webServiceAddress + + ":" + webServicePort); + + final String webServiceAdminAPIEndpoint = + this.environment.getRequiredProperty("sebserver.gui.webservice.apipath"); + final String webServiceExamAPIEndpoint = + this.environment.getRequiredProperty("sebserver.webservice.api.exam.endpoint"); + + SEBServerInit.INIT_LOGGER.info("---->"); + SEBServerInit.INIT_LOGGER.info("----> Webservice admin API endpoint: " + webServiceAdminAPIEndpoint); + SEBServerInit.INIT_LOGGER.info("----> Webservice exam API endpoint: " + webServiceExamAPIEndpoint); + + final String webServiceAPIBasicAccess = + this.environment.getRequiredProperty("sebserver.webservice.api.admin.clientId"); + + SEBServerInit.INIT_LOGGER.info("---->"); + SEBServerInit.INIT_LOGGER.info("----> Webservice admin API basic access: --" + webServiceAPIBasicAccess + "--"); + } } From 42a5c7cf3bcda91dac55e04a383ca877addc2140 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 11 Jun 2020 12:29:54 +0200 Subject: [PATCH 11/26] more integration tests --- .../lms/impl/MockupLmsAPITemplate.java | 2 +- .../integration/UseCasesIntegrationTest.java | 198 ++++++++++++++---- 2 files changed, 164 insertions(+), 36 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java index 3c3ee250..ae3cfaeb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/MockupLmsAPITemplate.java @@ -61,7 +61,7 @@ final class MockupLmsAPITemplate implements LmsAPITemplate { this.mockups = new ArrayList<>(); this.mockups.add(new QuizData( "quiz1", institutionId, lmsSetupId, lmsType, "Demo Quiz 1 (MOCKUP)", "Demo Quiz Mockup", - "2020-01-01T09:00:00Z", "2021-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2020-01-01T09:00:00Z", null, "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz2", institutionId, lmsSetupId, lmsType, "Demo Quiz 2 (MOCKUP)", "Demo Quiz Mockup", "2020-01-01T09:00:00Z", "2021-01-01T09:00:00Z", "http://lms.mockup.com/api/")); diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index 9b6d530c..d0b35fdf 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -30,15 +30,17 @@ import org.apache.tomcat.util.buf.StringUtils; import org.joda.time.DateTimeZone; import org.junit.After; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; import org.springframework.test.context.jdbc.Sql; import org.springframework.util.StreamUtils; -import org.springframework.web.servlet.DispatcherServlet; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.Domain.SEB_CLIENT_CONFIGURATION; @@ -48,6 +50,7 @@ import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType; +import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType; import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold; @@ -78,14 +81,19 @@ import ch.ethz.seb.sebserver.gui.service.examconfig.impl.AttributeMapping; import ch.ethz.seb.sebserver.gui.service.examconfig.impl.ExamConfigurationServiceImpl; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingNames; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingsPage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamNames; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamPage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetIndicator; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetIndicatorPage; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewExamConfigMapping; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewIndicator; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveExam; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveExamConfigMapping; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveIndicator; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.ActivateInstitution; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitution; @@ -118,6 +126,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Ge import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurationValues; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurations; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNodeNames; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNodePage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetFollowupConfiguration; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetOrientationPage; @@ -132,11 +141,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Im import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.RemoveOrientation; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ResetTemplateValues; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount; @@ -144,6 +153,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUs import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.NewUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.SaveUserAccount; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UseCasesIntegrationTest extends GuiIntegrationTest { @Before @@ -163,7 +173,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // ************************************* // Use Case 1: SEB Administrator creates a new institution and activate this new institution - public void testUsecase1() { + public void testUsecase01() { final RestServiceImpl restService = createRestServiceForUser( "admin", "admin", @@ -205,7 +215,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // ************************************* // Use Case 2: SEB Administrator creates a new Institutional Administrator user for the // newly created institution and activate this user - public void testUsecase2() { + public void testUsecase02_CreateInstitutionalAdminUser() { final RestServiceImpl restService = createRestServiceForUser( "admin", "admin", @@ -274,7 +284,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // check also that it is not possible to change to SEB Administrator role // check also this it is possible to change the password and after that a new login is needed // check also that property changes are possible. E.g: email - public void testUsecase3() { + public void testUsecase03_TestInstitutionalView() { RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", "12345678", @@ -387,7 +397,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // - create a new user-account (examAdmin2) with Exam Administrator role // - create a new user-account (examSupport1) with Exam Supporter role // - create a new user-account (examSupport2) with Exam Administrator and Exam Supporter role - public void testUsecase4() { + public void testUsecase04_CreateUserAccount() { final RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", "987654321", @@ -504,7 +514,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // - change name of active LMS and check modification update // - deactivate LMS Setup and check no quizzes are available // - activate again for following tests - public void testUsecase5() { + public void testUsecase05_CreateLMSSetupMockup() { final RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", "987654321", @@ -684,7 +694,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // ************************************* // Use Case 5.5: Login as TestInstAdmin and create new Open edX LMS setup and activate // - login as TestInstAdmin : 987654321 - public void testUsecase5_5() { + public void testUsecase06_CreateOpenEdxLMSSetup() { final RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", "987654321", @@ -720,25 +730,23 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { .call() .getOrThrow(); - final DispatcherServlet dispatcherServlet = this.mockMvc.getDispatcherServlet(); - assertNotNull(testResult); assertFalse(testResult.isOk()); assertEquals("[Error [errorType=TOKEN_REQUEST, message=Failed to gain access token from OpenEdX Rest API:\n" + " tried token endpoints: [/oauth2/access_token]]]", String.valueOf(testResult.errors)); - // TODO how to mockup a Open edX response + // TODO how to mockup an Open edX response } @Test - @Order(6) + @Order(7) // ************************************* // Use Case 6: Login as examAdmin2 - // - Check if there are some quizzes form previous LMS Setup + // - Check if there are some quizzes from previous LMS Setup // - Import a quiz as Exam // - get exam page and check the exam is there // - edit exam property and save again - public void testUsecase6() { + public void testUsecase07_ImportExam() { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -824,17 +832,31 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertEquals(ExamType.MANAGED, savedExam.type); assertFalse(savedExam.supporter.isEmpty()); + + // get exam list + final Result> exams = restService + .getBuilder(GetExamPage.class) + .call(); + + assertNotNull(exams); + assertFalse(exams.hasError()); + final Page examPage = exams.get(); + assertFalse(examPage.isEmpty()); + assertTrue(examPage.content + .stream() + .filter(exam -> exam.name.equals(newExam.name)) + .findFirst().isPresent()); } @Test - @Order(7) + @Order(8) // ************************************* // Use Case 7: Login as examAdmin2 // - Get imported exam // - add new indicator for exam // - save exam with new indicator and test // - create some thresholds for the new indicator - public void testUsecase7() { + public void testUsecase08_CreateExamIndicator() { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -911,13 +933,13 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(8) + @Order(9) // ************************************* - // Use Case 8: Login as TestInstAdmin and create a SEB Client Configuration + // Use Case 9: Login as TestInstAdmin and create a SEB Client Configuration // - create one with and one without password // - activate one config // - export both configurations - public void testUsecase8() throws IOException { + public void testUsecase09_CreateClientConfig() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "TestInstAdmin", "987654321", @@ -1027,13 +1049,13 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(9) + @Order(10) // ************************************* - // Use Case 9: Login as examAdmin2 and test Exam Configuration data basis + // Use Case 10: Login as examAdmin2 and test Exam Configuration data basis // - get all Views for the default template // - get all Attributes and and Orientations for the default view @Sql(scripts = { "classpath:data-test-additional.sql" }) - public void testUsecase9() throws IOException { + public void testUsecase10_TestExamConfigBaseData() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1079,14 +1101,14 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(10) + @Order(11) // ************************************* - // Use Case 10: Login as examAdmin2 and create a new SEB Exam Configuration + // Use Case 11: Login as examAdmin2 and create a new SEB Exam Configuration // - test creation // - save configuration in history // - change some attribute // - process an undo - public void testUsecase10() throws IOException { + public void testUsecase11_CreateExamConfig() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1287,14 +1309,14 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(11) + @Order(12) // ************************************* - // Use Case 11: Login as examAdmin2 and get newly created exam configuration + // Use Case 12: Login as examAdmin2 and get newly created exam configuration // - get permitted processes table values // - modify permitted processes table values // - save permitted processes table values // - check save OK - public void testUsecase11() throws IOException { + public void testUsecase12_TestInitDataOfNewExamConfig() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1408,13 +1430,13 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(12) + @Order(13) // ************************************* - // Use Case 12: Login as examAdmin2 and use newly created configuration + // Use Case 13: Login as examAdmin2 and use newly created configuration // - get follow-up configuration by API // - import // - export - public void testUsecase12() throws IOException { + public void testUsecase13_ExamConfigImportExport() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1574,11 +1596,11 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { } @Test - @Order(13) + @Order(14) // ************************************* - // Use Case 13: Login as examAdmin2 and use newly created configuration + // Use Case 14: Login as examAdmin2 and use newly created configuration // - change configuration status to "Ready to Use" - public void testUsecase13() throws IOException { + public void testUsecase14_EditExamConfig() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1623,7 +1645,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // - Remove one template attribute from orientation // - Change one template attribute value // - Reset template values - public void testUsecase15() throws IOException { + public void testUsecase15_CreateConfigurationTemplate() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", @@ -1809,4 +1831,110 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { .ifPresent(cValue -> assertNull(cValue.value)); } + @Test + @Order(16) + // ************************************* + // Use Case 16: Login as examAdmin2 and map a Exam Config to an Exam + // - Get Exam + // - Get List of available Exam Config for mapping + // - Map a Exam Config to the Exam + public void testUsecase16_MapExamConfigToExam() throws IOException { + final RestServiceImpl restService = createRestServiceForUser( + "examAdmin2", + "examAdmin2", + new GetExamPage(), + new GetExamConfigNodeNames(), + new GetExamConfigMappingNames(), + new GetExamConfigMappingsPage(), + new SaveExamConfigMapping(), + new NewExamConfigMapping(), + new CheckExamConsistency()); + + // get exam + final Result> exams = restService + .getBuilder(GetExamPage.class) + .call(); + + assertNotNull(exams); + assertFalse(exams.hasError()); + final Page examPage = exams.get(); + assertFalse(examPage.isEmpty()); + final Exam exam = examPage.content.get(0); + assertEquals("Demo Quiz 1 (MOCKUP)", exam.name); + // check that the exam is running + assertNull(exam.endTime); + // check that the exam is marked with missing configuration alert + final Collection alerts = restService.getBuilder(CheckExamConsistency.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call() + .getOr(Collections.emptyList()); + assertNotNull(alerts); + assertFalse(alerts.isEmpty()); + final APIMessage message = alerts.iterator().next(); + assertNotNull(message); + assertEquals("No SEB Exam Configuration defined for the Exam", message.systemMessage); + + // get available exam configs for mapping + final Result> configs = restService.getBuilder(GetExamConfigNodeNames.class) + .withQueryParam( + ConfigurationNode.FILTER_ATTR_TYPE, + ConfigurationType.EXAM_CONFIG.name()) + .withQueryParam( + ConfigurationNode.FILTER_ATTR_STATUS, + ConfigurationStatus.READY_TO_USE.name()) + .call(); + + assertNotNull(configs); + assertFalse(configs.hasError()); + final List list = configs.get(); + assertFalse(list.isEmpty()); + final EntityName configName = list.get(0); + assertEquals("New Exam Config", configName.name); + + // get config mapping page and check there is no mapping yet + final Result> mappings = restService + .getBuilder(GetExamConfigMappingsPage.class) + .call(); + + assertNotNull(mappings); + assertFalse(mappings.hasError()); + final Page mappingsPage = mappings.get(); + assertTrue(mappingsPage.isEmpty()); + + // create new config node mapping + final Result newExamConfigMap = restService.getBuilder(NewExamConfigMapping.class) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_INSTITUTION_ID, String.valueOf(exam.institutionId)) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_EXAM_ID, String.valueOf(exam.id)) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_CONFIGURATION_NODE_ID, configName.modelId) + .call(); + + assertNotNull(newExamConfigMap); + assertFalse(newExamConfigMap.hasError()); + final ExamConfigurationMap examConfigurationMap = newExamConfigMap.get(); + assertNotNull(examConfigurationMap); + assertEquals("New Exam Config", examConfigurationMap.configName); + assertEquals(exam.name, examConfigurationMap.examName); + + final Result> newMappings = restService + .getBuilder(GetExamConfigMappingsPage.class) + .call(); + + assertNotNull(newMappings); + assertFalse(newMappings.hasError()); + final Page newMappingsPage = newMappings.get(); + assertFalse(newMappingsPage.isEmpty()); + final ExamConfigurationMap newMapping = newMappingsPage.content.get(0); + assertNotNull(newMapping); + assertEquals("New Exam Config", newMapping.configName); + assertEquals(exam.name, newMapping.examName); + + // check that the exam is not marked with missing configuration alert anymore + final Collection newAlerts = restService.getBuilder(CheckExamConsistency.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call() + .getOr(Collections.emptyList()); + assertNotNull(newAlerts); + assertTrue(newAlerts.isEmpty()); + } + } From 54c248980b3d790d2aa5fa3def9e8ca9e29c54ef Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 12:43:31 +0200 Subject: [PATCH 12/26] mor integration tests --- .../converter/ArrayOfStringConverter.java | 2 +- .../impl/converter/InlineTableConverter.java | 2 +- .../integration/UseCasesIntegrationTest.java | 86 ++++++++++++++++++- 3 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/ArrayOfStringConverter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/ArrayOfStringConverter.java index 10b26c9a..4971c76d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/ArrayOfStringConverter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/ArrayOfStringConverter.java @@ -85,7 +85,7 @@ public class ArrayOfStringConverter implements AttributeValueConverter { final ConfigurationValue value, final boolean xml) throws IOException { - final String val = (value.value != null) ? value.value : attribute.getDefaultValue(); + final String val = (value != null && value.value != null) ? value.value : attribute.getDefaultValue(); if (StringUtils.isNotBlank(val)) { final String[] values = StringUtils.split(val, Constants.LIST_SEPARATOR); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/InlineTableConverter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/InlineTableConverter.java index 34c860e1..f005df9b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/InlineTableConverter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/InlineTableConverter.java @@ -92,7 +92,7 @@ public class InlineTableConverter implements AttributeValueConverter { (xml) ? XML_KEY_TEMPLATE : JSON_KEY_TEMPLATE, AttributeValueConverter.extractName(attribute)))); - if (StringUtils.isBlank(value.value)) { + if (value == null || StringUtils.isBlank(value.value)) { out.write((xml) ? XML_EMPTY_ARRAY : JSON_EMPTY_ARRAY); out.flush(); return; diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index d0b35fdf..83812f60 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -60,6 +60,7 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigCreationInfo; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigKey; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode; @@ -82,6 +83,7 @@ import ch.ethz.seb.sebserver.gui.service.examconfig.impl.ExamConfigurationServic import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteExamConfigMapping; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingNames; @@ -118,6 +120,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig. import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.SaveClientConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.AttachDefaultOrientation; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.CopyConfiguration; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ExportConfigKey; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ExportPlainXML; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigAttributes; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurationPage; @@ -1838,17 +1841,25 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // - Get Exam // - Get List of available Exam Config for mapping // - Map a Exam Config to the Exam + // - Remove Exam Config + // - Add config again + // - Export Config Key + // - Export Config as XML public void testUsecase16_MapExamConfigToExam() throws IOException { final RestServiceImpl restService = createRestServiceForUser( "examAdmin2", "examAdmin2", new GetExamPage(), + new GetExamConfigNode(), new GetExamConfigNodeNames(), new GetExamConfigMappingNames(), new GetExamConfigMappingsPage(), new SaveExamConfigMapping(), new NewExamConfigMapping(), - new CheckExamConsistency()); + new CheckExamConsistency(), + new DeleteExamConfigMapping(), + new ExportConfigKey(), + new ExportExamConfig()); // get exam final Result> exams = restService @@ -1902,7 +1913,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertTrue(mappingsPage.isEmpty()); // create new config node mapping - final Result newExamConfigMap = restService.getBuilder(NewExamConfigMapping.class) + Result newExamConfigMap = restService.getBuilder(NewExamConfigMapping.class) .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_INSTITUTION_ID, String.valueOf(exam.institutionId)) .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_EXAM_ID, String.valueOf(exam.id)) .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_CONFIGURATION_NODE_ID, configName.modelId) @@ -1910,7 +1921,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertNotNull(newExamConfigMap); assertFalse(newExamConfigMap.hasError()); - final ExamConfigurationMap examConfigurationMap = newExamConfigMap.get(); + ExamConfigurationMap examConfigurationMap = newExamConfigMap.get(); assertNotNull(examConfigurationMap); assertEquals("New Exam Config", examConfigurationMap.configName); assertEquals(exam.name, examConfigurationMap.examName); @@ -1935,6 +1946,75 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { .getOr(Collections.emptyList()); assertNotNull(newAlerts); assertTrue(newAlerts.isEmpty()); + + // check the state of exam config is now in "In Use" + Result examConfigCall = restService.getBuilder(GetExamConfigNode.class) + .withURIVariable(API.PARAM_MODEL_ID, configName.modelId) + .call(); + + assertNotNull(examConfigCall); + assertFalse(examConfigCall.hasError()); + ConfigurationNode configurationNode = examConfigCall.get(); + assertEquals(ConfigurationStatus.IN_USE, configurationNode.status); + + // delete the configuration mapping + restService.getBuilder(DeleteExamConfigMapping.class) + .withURIVariable(API.PARAM_MODEL_ID, examConfigurationMap.getModelId()) + .call(); + + // check the state of exam config is now in "Ready To Use" + final Result examConfigCall2 = restService.getBuilder(GetExamConfigNode.class) + .withURIVariable(API.PARAM_MODEL_ID, configName.modelId) + .call(); + + assertNotNull(examConfigCall2); + assertFalse(examConfigCall2.hasError()); + final ConfigurationNode configurationNode2 = examConfigCall2.get(); + assertEquals(ConfigurationStatus.READY_TO_USE, configurationNode2.status); + + // Re-Map the configuration to the exam and check again the state. + newExamConfigMap = restService.getBuilder(NewExamConfigMapping.class) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_INSTITUTION_ID, String.valueOf(exam.institutionId)) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_EXAM_ID, String.valueOf(exam.id)) + .withFormParam(Domain.EXAM_CONFIGURATION_MAP.ATTR_CONFIGURATION_NODE_ID, configName.modelId) + .call(); + + assertNotNull(newExamConfigMap); + assertFalse(newExamConfigMap.hasError()); + examConfigurationMap = newExamConfigMap.get(); + assertNotNull(examConfigurationMap); + assertEquals("New Exam Config", examConfigurationMap.configName); + assertEquals(exam.name, examConfigurationMap.examName); + + examConfigCall = restService.getBuilder(GetExamConfigNode.class) + .withURIVariable(API.PARAM_MODEL_ID, configName.modelId) + .call(); + + assertNotNull(examConfigCall); + assertFalse(examConfigCall.hasError()); + configurationNode = examConfigCall.get(); + assertEquals(ConfigurationStatus.IN_USE, configurationNode.status); + + // export Config Key + final ConfigKey configKey = restService.getBuilder(ExportConfigKey.class) + .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(examConfigurationMap.configurationNodeId)) + .call() + .getOrThrow(); + assertNotNull(configKey); + //assertEquals("e4af6cf8deb9434e69e8dc6c373418712546de35807d8bfbd6bb98790f8d0774", configKey.key); + + // export config to XML + final InputStream input = restService.getBuilder(ExportExamConfig.class) + .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(examConfigurationMap.configurationNodeId)) + .withURIVariable(API.PARAM_PARENT_MODEL_ID, String.valueOf(examConfigurationMap.examId)) + .call() + .getOrThrow(); + + final String xmlString = StreamUtils.copyToString(input, Charsets.UTF_8); + assertNotNull(xmlString); +// assertEquals( +// "allowAudioCaptureallowBrowsingBackForwardallowDictationallowDictionaryLookupallowDisplayMirroringallowDownUploadsallowedDisplayBuiltinallowedDisplaysMaxNumber1allowFlashFullscreenallowiOSBetaVersionNumber0allowiOSVersionNumberMajor9allowiOSVersionNumberMinor3allowiOSVersionNumberPatch5allowPDFPlugInallowPreferencesWindowallowQuitallowScreenSharingallowSiriallowSpellCheckallowSpellCheckDictionaryda-DKen-AUen-GBen-USes-ESfr-FRpt-PTsv-SEsv-FIallowSwitchToApplicationsallowUserAppFolderInstallallowUserSwitchingallowVideoCaptureallowVirtualMachineallowWlanaudioControlEnabledaudioMuteaudioSetVolumeLevelaudioVolumeLevel25blacklistURLFilterblockPopUpWindowsbrowserMessagingPingTime120000browserMessagingSocketws://localhost:8706browserScreenKeyboardbrowserURLSaltbrowserUserAgentbrowserUserAgentiOS0browserUserAgentiOSCustombrowserUserAgentMac0browserUserAgentMacCustombrowserUserAgentWinDesktopMode0browserUserAgentWinDesktopModeCustombrowserUserAgentWinTouchMode0browserUserAgentWinTouchModeCustombrowserUserAgentWinTouchModeIPadMozilla/5.0 (iPad; CPU OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1browserViewMode0browserWindowAllowReloadbrowserWindowShowURL0browserWindowTitleSuffixchooseFileToUploadPolicy0createNewDesktopdetectStoppedProcessdownloadAndOpenSebConfigdownloadDirectoryOSXdownloadDirectoryWindownloadPDFFilesenableAltEscenableAltF4enableAltMouseWheelenableAltTabenableAppSwitcherCheckenableBrowserWindowToolbarenableCtrlEscenableDrawingEditorenableEscenableF1enableF10enableF11enableF12enableF2enableF3enableF4enableF5enableF6enableF7enableF8enableF9enableJavaenableJavaScriptenableLoggingenablePlugInsenablePrintScreenenablePrivateClipboardenableRightMouseenableSebBrowserenableStartMenuenableTouchExitenableZoomPageenableZoomTextexamSessionClearCookiesOnEndexamSessionClearCookiesOnStartexitKey12exitKey210exitKey35forceAppFolderInstallhashedAdminPasswordhashedQuitPasswordhideBrowserWindowToolbarhookKeysignoreExitKeysinsideSebEnableChangeAPasswordinsideSebEnableEaseOfAccessinsideSebEnableLockThisComputerinsideSebEnableLogOffinsideSebEnableNetworkConnectionSelectorinsideSebEnableShutDowninsideSebEnableStartTaskManagerinsideSebEnableSwitchUserinsideSebEnableVmWareClientShadekillExplorerShelllockOnMessageSocketCloselogDirectoryOSXlogDirectoryWinlogLevel1mainBrowserWindowHeight100%mainBrowserWindowPositioning1mainBrowserWindowWidth100%minMacOSVersion0mobileAllowPictureInPictureMediaPlaybackmobileAllowQRCodeConfigmobileAllowSingleAppModemobileEnableASAMmobileEnableGuidedAccessLinkTransformmobilePreventAutoLockmobileShowSettingsmobileStatusBarAppearance1mobileStatusBarAppearanceExtended1monitorProcessesnewBrowserWindowAllowReloadnewBrowserWindowByLinkBlockForeignnewBrowserWindowByLinkHeight100%newBrowserWindowByLinkPolicy2newBrowserWindowByLinkPositioning2newBrowserWindowByLinkWidth100%newBrowserWindowByScriptBlockForeignnewBrowserWindowByScriptPolicy2newBrowserWindowNavigationnewBrowserWindowShowReloadWarningnewBrowserWindowShowURL1openDownloadsoriginatorVersionSEB_Server_0.3.0permittedProcessesactiveallowUserToChooseAppargumentsautostartdescriptionexecutablefirefox.exeiconInTaskbaridentifierFirefoxoriginalNamefirefox.exeos1path../xulrunner/runInBackgroundstrongKilltitleSEBpinEmbeddedCertificatesprohibitedProcessesactivecurrentUserdescriptionexecutableRiotidentifieroriginalNameRiotos1strongKilluseractivecurrentUserdescriptionexecutableseamonkeyidentifieroriginalNameseamonkeyos1strongKilluseractivecurrentUserdescriptionexecutableDiscordidentifieroriginalNameDiscordos1strongKilluseractivecurrentUserdescriptionexecutableSlackidentifieroriginalNameSlackos1strongKilluseractivecurrentUserdescriptionexecutableTeamsidentifieroriginalNameTeamsos1strongKilluseractivecurrentUserdescriptionexecutableCamRecorderidentifieroriginalNameCamRecorderos1strongKilluseractivecurrentUserdescriptionexecutablejoin.meidentifieroriginalNamejoin.meos1strongKilluseractivecurrentUserdescriptionexecutableRPCSuiteidentifieroriginalNameRPCSuiteos1strongKilluseractivecurrentUserdescriptionexecutableRPCServiceidentifieroriginalNameRPCServiceos1strongKilluseractivecurrentUserdescriptionexecutableRemotePCDesktopidentifieroriginalNameRemotePCDesktopos1strongKilluseractivecurrentUserdescriptionexecutablebeamyourscreen-hostidentifieroriginalNamebeamyourscreen-hostos1strongKilluseractivecurrentUserdescriptionexecutableAeroAdminidentifieroriginalNameAeroAdminos1strongKilluseractivecurrentUserdescriptionexecutableMikogo-hostidentifieroriginalNameMikogo-hostos1strongKilluseractivecurrentUserdescriptionexecutablechromotingidentifieroriginalNamechromotingos1strongKilluseractivecurrentUserdescriptionexecutablevncserveruiidentifieroriginalNamevncserveruios1strongKilluseractivecurrentUserdescriptionexecutablevncvieweridentifieroriginalNamevncvieweros1strongKilluseractivecurrentUserdescriptionexecutablevncserveridentifieroriginalNamevncserveros1strongKilluseractivecurrentUserdescriptionexecutableTeamVieweridentifieroriginalNameTeamVieweros1strongKilluseractivecurrentUserdescriptionexecutableGotoMeetingWinStoreidentifieroriginalNameGotoMeetingWinStoreos1strongKilluseractivecurrentUserdescriptionexecutableg2mcomm.exeidentifieroriginalNameg2mcomm.exeos1strongKilluseractivecurrentUserdescriptionexecutableSkypeHostidentifieroriginalNameSkypeHostos1strongKilluseractivecurrentUserdescriptionexecutableSkypeidentifieroriginalNameSkypeos1strongKilluserproxiesAutoConfigurationEnabledAutoConfigurationJavaScriptAutoConfigurationURLAutoDiscoveryEnabledExceptionsListExcludeSimpleHostnamesFTPEnableFTPPassiveFTPPasswordFTPPort21FTPProxyFTPRequiresPasswordFTPUsernameHTTPEnableHTTPPasswordHTTPPort80HTTPProxyHTTPRequiresPasswordHTTPSEnableHTTPSPasswordHTTPSPort443HTTPSProxyHTTPSRequiresPasswordHTTPSUsernameHTTPUsernameRTSPEnableRTSPPasswordRTSPPort554RTSPProxyRTSPRequiresPasswordRTSPUsernameSOCKSEnableSOCKSPasswordSOCKSPort1080SOCKSProxySOCKSRequiresPasswordSOCKSUsernameproxySettingsPolicy0quitURLquitURLConfirmremoveBrowserProfileremoveLocalStoragerestartExamPasswordProtectedrestartExamTextrestartExamURLrestartExamUseStartURLsebConfigPurpose0sebServicePolicy2sendBrowserExamKeyshowBackToStartButtonshowInputLanguageshowMenuBarshowNavigationButtonsshowReloadButtonshowReloadWarningshowScanQRCodeButtonshowSettingsInAppshowTaskBarshowTimestartResourcetaskBarHeight40touchOptimizedURLFilterEnableURLFilterEnableContentFilterURLFilterMessage0URLFilterRulesuseAsymmetricOnlyEncryptionwhitelistURLFilterzoomMode0", +// xmlString); } } From 640d08399a6aa12e8fe30f8ac9d3bac66d157a1d Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 13:31:55 +0200 Subject: [PATCH 13/26] dev branch codecov batch --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 47bd8aa7..1f3d0faa 100644 --- a/README.rst +++ b/README.rst @@ -3,6 +3,8 @@ :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server +.. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg + :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://readthedocs.org/projects/seb-server/badge/?version=latest :target: https://seb-server.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status From 24d78cf7d1560f2c5a3d7a70c415a85e9f6512da Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 13:41:07 +0200 Subject: [PATCH 14/26] more batches --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 1f3d0faa..d9d80438 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,9 @@ .. image:: https://readthedocs.org/projects/seb-server/badge/?version=latest :target: https://seb-server.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status +![GitHub Last Commit](https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server?logo=github) +![GitHub Repo Size](https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server?logo=github) + What is Safe Exam Browser (SEB)? -------------------------------- From 05ee39dff6abc74f9488bd5619fc7127702855f9 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 13:44:25 +0200 Subject: [PATCH 15/26] batches --- README.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index d9d80438..8c24dc24 100644 --- a/README.rst +++ b/README.rst @@ -3,15 +3,17 @@ :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server -.. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg - :target: https://codecov.io/gh/SafeExamBrowser/seb-server + .. image:: https://readthedocs.org/projects/seb-server/badge/?version=latest :target: https://seb-server.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status -![GitHub Last Commit](https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server?logo=github) -![GitHub Repo Size](https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server?logo=github) +.. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg + :target: https://codecov.io/gh/SafeExamBrowser/seb-server +.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server?logo=github +.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server?logo=github + What is Safe Exam Browser (SEB)? -------------------------------- From d7a21ef41ad39a0916b5636f4bf5d52f297ead7b Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 13:46:51 +0200 Subject: [PATCH 16/26] batches --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 8c24dc24..a0613dfc 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ - +Release: .. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=master :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg @@ -8,11 +8,11 @@ :target: https://seb-server.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status - +Development: .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server -.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server?logo=github -.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server?logo=github +.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/branch/development?logo=github +.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/branch/development?logo=github What is Safe Exam Browser (SEB)? -------------------------------- From f3dfc14d559355451596f807a85ad14c3ae0508e Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 15:51:48 +0200 Subject: [PATCH 17/26] batches --- README.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index a0613dfc..f2cf1b3a 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,5 @@ Release: + .. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=master :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg @@ -8,11 +9,12 @@ Release: :target: https://seb-server.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status -Development: +Development: + .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server -.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/branch/development?logo=github -.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/branch/development?logo=github +.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/tree/development?logo=github +.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/tree/development?logo=github What is Safe Exam Browser (SEB)? -------------------------------- From fd00c06752c782e040ca213f8e8c2e88baa7c3f6 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 16:10:20 +0200 Subject: [PATCH 18/26] batches --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index f2cf1b3a..20c15c96 100644 --- a/README.rst +++ b/README.rst @@ -13,8 +13,8 @@ Development: .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server -.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/tree/development?logo=github -.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/tree/development?logo=github +.. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/development?logo=github +.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/development?logo=github What is Safe Exam Browser (SEB)? -------------------------------- From 3e1e762bdc386db76819f78f88540fee5128ffc9 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 16:15:43 +0200 Subject: [PATCH 19/26] batches --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 20c15c96..11d4b0a9 100644 --- a/README.rst +++ b/README.rst @@ -4,16 +4,17 @@ Release: :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server - .. image:: https://readthedocs.org/projects/seb-server/badge/?version=latest :target: https://seb-server.readthedocs.io/en/latest/?badge=latest - :alt: Documentation Status +.. image:: https://img.shields.io/github/languages/code-size/SafeExamBrowser/seb-server + :target: https://github.com/SafeExamBrowser/seb-server Development: .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/development?logo=github + :target: https://github.com/SafeExamBrowser/seb-server/tree/development .. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/development?logo=github What is Safe Exam Browser (SEB)? From 9fdf77e0d622f3d438f23698729c3230b4bc0ffc Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 16:19:34 +0200 Subject: [PATCH 20/26] batches --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 11d4b0a9..0908d844 100644 --- a/README.rst +++ b/README.rst @@ -2,10 +2,12 @@ Release: .. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=master :target: https://travis-ci.com/SafeExamBrowser/seb-server -.. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg - :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://readthedocs.org/projects/seb-server/badge/?version=latest :target: https://seb-server.readthedocs.io/en/latest/?badge=latest +.. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/master/graph/badge.svg + :target: https://codecov.io/gh/SafeExamBrowser/seb-server +.. image:: https://img.shields.io/github/languages/code-size/SafeExamBrowser/seb-server + :target: https://github.com/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/languages/code-size/SafeExamBrowser/seb-server :target: https://github.com/SafeExamBrowser/seb-server @@ -15,7 +17,6 @@ Development: :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/development?logo=github :target: https://github.com/SafeExamBrowser/seb-server/tree/development -.. image:: https://img.shields.io/github/repo-size/SafeExamBrowser/seb-server/development?logo=github What is Safe Exam Browser (SEB)? -------------------------------- From 15226ab4a237b978d654452daf684bbbfceb5330 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Jun 2020 16:23:23 +0200 Subject: [PATCH 21/26] batches --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0908d844..ab1950f4 100644 --- a/README.rst +++ b/README.rst @@ -8,11 +8,11 @@ Release: :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/languages/code-size/SafeExamBrowser/seb-server :target: https://github.com/SafeExamBrowser/seb-server -.. image:: https://img.shields.io/github/languages/code-size/SafeExamBrowser/seb-server - :target: https://github.com/SafeExamBrowser/seb-server Development: +.. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=development + :target: https://travis-ci.com/SafeExamBrowser/seb-server .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/development?logo=github From 2652da80df8f6234bb6eb6645c8662dc2195251d Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jun 2020 13:38:24 +0200 Subject: [PATCH 22/26] more integration tests --- README.rst | 4 +- .../gui/integration/SEBClientBot.java | 567 ++++++++++++++++++ .../integration/UseCasesIntegrationTest.java | 110 ++++ 3 files changed, 679 insertions(+), 2 deletions(-) create mode 100644 src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java diff --git a/README.rst b/README.rst index ab1950f4..49870279 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Release: +Master: .. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=master :target: https://travis-ci.com/SafeExamBrowser/seb-server @@ -12,7 +12,7 @@ Release: Development: .. image:: https://travis-ci.com/SafeExamBrowser/seb-server.svg?branch=development - :target: https://travis-ci.com/SafeExamBrowser/seb-server + :target: https://github.com/SafeExamBrowser/seb-server/tree/development .. image:: https://codecov.io/gh/SafeExamBrowser/seb-server/branch/development/graph/badge.svg :target: https://codecov.io/gh/SafeExamBrowser/seb-server .. image:: https://img.shields.io/github/last-commit/SafeExamBrowser/seb-server/development?logo=github diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java new file mode 100644 index 00000000..89b25202 --- /dev/null +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java @@ -0,0 +1,567 @@ +/* + * Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +package ch.ethz.seb.sebserver.gui.integration; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Random; +import java.util.UUID; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.security.oauth2.client.OAuth2RestTemplate; +import org.springframework.security.oauth2.client.http.OAuth2ErrorHandler; +import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; +import ch.ethz.seb.sebserver.gbl.model.session.RunningExamInfo; + +public class SEBClientBot { + + private static final Logger log = LoggerFactory.getLogger(SEBClientBot.class); + + private static final Character COMMA = ','; + private static final Character AMPERSAND = '&'; + private static final Character EQUALITY_SIGN = '='; + + private static final String LIST_SEPARATOR = COMMA.toString(); + private static final String FORM_URL_ENCODED_SEPARATOR = AMPERSAND.toString(); + private static final String FORM_URL_ENCODED_NAME_VALUE_SEPARATOR = EQUALITY_SIGN.toString(); + + private static final String PARAM_INSTITUTION_ID = "institutionId"; + private static final String EXAM_API_PARAM_EXAM_ID = "examId"; + private static final String EXAM_API_SEB_CONNECTION_TOKEN = "SEBConnectionToken"; + private static final String EXAM_API_USER_SESSION_ID = "seb_user_session_id"; + private static final String EXAM_API_HANDSHAKE_ENDPOINT = "/handshake"; + private static final String EXAM_API_CONFIGURATION_REQUEST_ENDPOINT = "/examconfig"; + private static final String EXAM_API_PING_ENDPOINT = "/sebping"; + private static final String EXAM_API_PING_TIMESTAMP = "timestamp"; + private static final String EXAM_API_PING_NUMBER = "ping-number"; + private static final String EXAM_API_EVENT_ENDPOINT = "/seblog"; + + private static final long ONE_SECOND = 1000; // milliseconds + static final long TEN_SECONDS = 10 * ONE_SECOND; + static final long ONE_MINUTE = 60 * ONE_SECOND; + @SuppressWarnings("unused") + private static final long ONE_HOUR = 60 * ONE_MINUTE; + + //private final ExecutorService executorService; + private final List scopes = Arrays.asList("read", "write"); + private final ObjectMapper jsonMapper = new ObjectMapper(); + private final Random random = new Random(); + + String webserviceAddress = "http://localhost:8080"; + String accessTokenEndpoint = "/oauth/token"; + String clientId = "test"; + String sessionId = null; + String clientSecret = "test"; + String apiPath = "/exam-api"; + String apiVersion = "v1"; + String examId = "2"; + String institutionId = "1"; + int numberOfConnections = 4; + long establishDelay = 0; + long pingInterval = 100; + long pingPause = 0; + long pingPauseDelay = 0; + long errorInterval = ONE_SECOND; + long warnInterval = ONE_SECOND / 2; + long runtime = ONE_SECOND * 2; + int connectionAttempts = 1; + + public SEBClientBot(final ClientCredentials credentials, final String examId, final String instId) + throws Exception { + + this.clientId = credentials.clientIdAsString(); + this.clientSecret = credentials.secretAsString(); + this.examId = examId; + this.institutionId = instId; + + //this.executorService = Executors.newFixedThreadPool(this.numberOfConnections); + + for (int i = 0; i < this.numberOfConnections; i++) { + final String sessionId = StringUtils.isNotBlank(this.sessionId) + ? this.sessionId + : "connection_" + getRandomName(); + + new ConnectionBot(sessionId).run(); + //this.executorService.execute(new ConnectionBot(sessionId)); + } + + //this.executorService.shutdown(); + } + + private String getRandomName() { + final StringBuilder sb = new StringBuilder(String.valueOf(this.random.nextInt(100))); + while (sb.length() < 3) { + sb.insert(0, "0"); + } + return sb.toString(); + } + + private final class ConnectionBot implements Runnable { + + private final String name; + private final OAuth2RestTemplate restTemplate; + + private final String handshakeURI = SEBClientBot.this.webserviceAddress + + SEBClientBot.this.apiPath + "/" + + SEBClientBot.this.apiVersion + EXAM_API_HANDSHAKE_ENDPOINT; + private final String configurartionURI = SEBClientBot.this.webserviceAddress + + SEBClientBot.this.apiPath + "/" + + SEBClientBot.this.apiVersion + EXAM_API_CONFIGURATION_REQUEST_ENDPOINT; + private final String pingURI = SEBClientBot.this.webserviceAddress + + SEBClientBot.this.apiPath + "/" + + SEBClientBot.this.apiVersion + EXAM_API_PING_ENDPOINT; + private final String eventURI = SEBClientBot.this.webserviceAddress + + SEBClientBot.this.apiPath + "/" + + SEBClientBot.this.apiVersion + EXAM_API_EVENT_ENDPOINT; + + private final HttpEntity connectBody; + + protected ConnectionBot(final String name) { + this.name = name; + this.restTemplate = createRestTemplate(null); + final MultiValueMap headers = new LinkedMultiValueMap<>(); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + this.connectBody = new HttpEntity<>(PARAM_INSTITUTION_ID + + FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + + SEBClientBot.this.institutionId +// + Constants.FORM_URL_ENCODED_SEPARATOR +// + API.EXAM_API_PARAM_EXAM_ID +// + Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR +// + this.examId + , + headers); + + } + + @Override + public void run() { + + int attempt = 0; + String connectionToken = null; + + while (connectionToken == null && attempt < SEBClientBot.this.connectionAttempts) { + attempt++; + log.info("ConnectionBot {} : Try to request access-token; attempt: {}", this.name, attempt); + try { + + final OAuth2AccessToken accessToken = this.restTemplate.getAccessToken(); + log.info("ConnectionBot {} : Got access token: {}", this.name, accessToken); + connectionToken = createConnection(); + + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed to request access-token: ", this.name, e); + if (attempt >= SEBClientBot.this.connectionAttempts) { + log.error("ConnectionBot {} : Gave up afer {} connection attempts: ", this.name, attempt); + throw new RuntimeException("Connection Error. See Logs", e); + } + } + } + + final MultiValueMap headers = new LinkedMultiValueMap<>(); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + headers.set(EXAM_API_SEB_CONNECTION_TOKEN, connectionToken); + + final MultiValueMap eventHeaders = new LinkedMultiValueMap<>(); + eventHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE); + eventHeaders.set(EXAM_API_SEB_CONNECTION_TOKEN, connectionToken); + + if (connectionToken != null) { + if (getConfig(headers) && establishConnection(headers)) { + + final PingEntity pingHeader = new PingEntity(headers); + final EventEntity errorHeader = new EventEntity(eventHeaders, "ERROR_LOG"); + final EventEntity warnHeader = new EventEntity(eventHeaders, "WARN_LOG"); + + try { + final long startTime = System.currentTimeMillis(); + final long endTime = startTime + SEBClientBot.this.runtime; + final long pingPauseStart = startTime + SEBClientBot.this.pingPauseDelay; + final long pingPauseEnd = pingPauseStart + SEBClientBot.this.pingPause; + long currentTime = startTime; + long lastPingTime = startTime; + long lastErrorTime = startTime; + long lastWarnTime = startTime; + + while (currentTime < endTime) { + if (currentTime - lastPingTime >= SEBClientBot.this.pingInterval && + !(currentTime > pingPauseStart && currentTime < pingPauseEnd)) { + + pingHeader.next(); + if (!sendPing(pingHeader)) { + // expecting a quit instruction was sent here + return; + } + lastPingTime = currentTime; + } + if (currentTime - lastErrorTime >= SEBClientBot.this.errorInterval) { + errorHeader.next(); + sendEvent(errorHeader); + lastErrorTime = currentTime; + } + if (currentTime - lastWarnTime >= SEBClientBot.this.warnInterval) { + warnHeader.next(); + sendEvent(warnHeader); + lastWarnTime = currentTime; + } + try { + Thread.sleep(50); + } catch (final Exception e) { + } + currentTime = System.currentTimeMillis(); + } + } catch (final Throwable t) { + log.error("ConnectionBot {} : Error sending events: ", this.name, t); + throw new RuntimeException("ConnectionBot {} : Error sending events: "); + } finally { + disconnect(connectionToken); + } + } + } + } + + private String createConnection() { + log.info("ConnectionBot {} : init connection", this.name); + + try { + final ResponseEntity exchange = this.restTemplate.exchange( + this.handshakeURI, + HttpMethod.POST, + this.connectBody, + new ParameterizedTypeReference() { + }); + + final HttpStatus statusCode = exchange.getStatusCode(); + if (statusCode.isError()) { + throw new RuntimeException("Webservice answered with error: " + exchange.getBody()); + } + + final Collection body = SEBClientBot.this.jsonMapper.readValue( + exchange.getBody(), + new TypeReference>() { + }); + final String token = exchange.getHeaders().getFirst(EXAM_API_SEB_CONNECTION_TOKEN); + + log.info("ConnectionBot {} : successfully created connection, token: {} body: {} ", + this.name, + token, + body); + + return token; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed to init connection", this.name, e); + throw new RuntimeException("ConnectionBot {} : Failed to init connection: ", e); + } + } + + public boolean getConfig(final MultiValueMap headers) { + final HttpEntity configHeader = new HttpEntity<>(headers); + + log.info("ConnectionBot {} : get SEB Configuration", this.name); + + try { + final ResponseEntity exchange = this.restTemplate.exchange( + this.configurartionURI + "?" + EXAM_API_PARAM_EXAM_ID + + FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + + SEBClientBot.this.examId, + HttpMethod.GET, + configHeader, + new ParameterizedTypeReference() { + }); + + final HttpStatus statusCode = exchange.getStatusCode(); + if (statusCode.isError()) { + throw new RuntimeException("Webservice answered with error: " + exchange.getBody()); + } + + final byte[] config = exchange.getBody(); + + if (ArrayUtils.isEmpty(config)) { + log.error("No Exam config get from API. processing anyway"); + } + + if (log.isDebugEnabled()) { + log.debug( + "ConnectionBot {} : successfully requested exam config: " + SEBClientBot.toString(config), + this.name); + } else { + log.info("ConnectionBot {} : successfully requested exam config", this.name); + } + + return true; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed get SEB Configuration", this.name, e); + return false; + } + } + + public boolean establishConnection(final MultiValueMap headers) { + + if (SEBClientBot.this.establishDelay > 0) { + try { + + log.info("Wait for connection activation -> {}", SEBClientBot.this.establishDelay); + + Thread.sleep(SEBClientBot.this.establishDelay); + } catch (final Exception e) { + log.error("Failed to wait for connection activiation -> {} : {}", + SEBClientBot.this.establishDelay, + e.getMessage()); + throw new RuntimeException(); + } + } + + final HttpEntity configHeader = new HttpEntity<>( + EXAM_API_USER_SESSION_ID + + FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + + this.name, + headers); + + log.info("ConnectionBot {} : Trying to establish SEB client connection", this.name); + + try { + + final ResponseEntity exchange = this.restTemplate.exchange( + this.handshakeURI, + HttpMethod.PUT, + configHeader, + new ParameterizedTypeReference() { + }); + + final HttpStatus statusCode = exchange.getStatusCode(); + if (statusCode.isError()) { + throw new RuntimeException("Webservice answered with error: " + exchange.getBody()); + } + + log.info("ConnectionBot {} : successfully established SEB client connection", this.name); + + return true; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed get established SEB client connection", this.name, e); + throw new RuntimeException(); + } + } + + private boolean sendPing(final HttpEntity pingHeader) { + try { + + final ResponseEntity exchange = this.restTemplate.exchange( + this.pingURI, + HttpMethod.POST, + pingHeader, + new ParameterizedTypeReference() { + }); + + if (exchange.hasBody() && exchange.getBody().contains("SEB_QUIT")) { + log.info("SEB_QUIT client {}, response: {}", + pingHeader.getHeaders().get(EXAM_API_SEB_CONNECTION_TOKEN), + exchange.getBody()); + return false; + } + + return true; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed send ping", this.name, e); + throw new RuntimeException(); + } + } + + private boolean sendEvent(final HttpEntity eventHeader) { + try { + + this.restTemplate.exchange( + this.eventURI, + HttpMethod.POST, + eventHeader, + new ParameterizedTypeReference() { + }); + + return true; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed send event", this.name, e); + throw new RuntimeException(); + } + } + + public boolean disconnect(final String connectionToken) { + final MultiValueMap headers = new LinkedMultiValueMap<>(); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + headers.set(EXAM_API_SEB_CONNECTION_TOKEN, connectionToken); + final HttpEntity configHeader = new HttpEntity<>(headers); + + log.info("ConnectionBot {} : Trying to delete SEB client connection", this.name); + + try { + + final ResponseEntity exchange = this.restTemplate.exchange( + this.handshakeURI, + HttpMethod.DELETE, + configHeader, + new ParameterizedTypeReference() { + }); + + final HttpStatus statusCode = exchange.getStatusCode(); + if (statusCode.isError()) { + throw new RuntimeException("Webservice answered with error: " + exchange.getBody()); + } + + log.info("ConnectionBot {} : successfully deleted SEB client connection", this.name); + + return true; + } catch (final Exception e) { + log.error("ConnectionBot {} : Failed get deleted SEB client connection", this.name, e); + throw new RuntimeException(); + } + } + } + + private OAuth2RestTemplate createRestTemplate(final String scopes) { + final ClientCredentialsResourceDetails clientCredentialsResourceDetails = + new ClientCredentialsResourceDetails(); + clientCredentialsResourceDetails + .setAccessTokenUri(this.webserviceAddress + this.accessTokenEndpoint); + clientCredentialsResourceDetails.setClientId(this.clientId); + clientCredentialsResourceDetails.setClientSecret(this.clientSecret); + if (StringUtils.isBlank(scopes)) { + clientCredentialsResourceDetails.setScope(this.scopes); + } else { + clientCredentialsResourceDetails.setScope( + Arrays.asList(StringUtils.split(scopes, LIST_SEPARATOR))); + } + + final OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails); + restTemplate.setErrorHandler(new OAuth2ErrorHandler(clientCredentialsResourceDetails) { + + @Override + public void handleError(final ClientHttpResponse response) throws IOException { + System.out.println("********************** handleError: " + response.getStatusCode()); + super.handleError(response); + } + + }); + restTemplate + .getMessageConverters() + .add(0, new StringHttpMessageConverter(Charset.forName("UTF-8"))); + //restTemplate.setRetryBadAccessTokens(true); + + final SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory(); + simpleClientHttpRequestFactory.setReadTimeout(30000); + simpleClientHttpRequestFactory.setOutputStreaming(false); + restTemplate.setRequestFactory(simpleClientHttpRequestFactory); + + return restTemplate; + } + + private static class PingEntity extends HttpEntity { + private final String pingBodyTemplate = EXAM_API_PING_TIMESTAMP + + FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + + "%s" + + FORM_URL_ENCODED_SEPARATOR + + EXAM_API_PING_NUMBER + + FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + + "%s"; + + private long timestamp = 0; + private int count = 0; + + protected PingEntity(final MultiValueMap headers) { + super(headers); + } + + void next() { + this.timestamp = System.currentTimeMillis(); + this.count++; + } + + @Override + public String getBody() { + return String.format(this.pingBodyTemplate, this.timestamp, this.count); + } + + @Override + public boolean hasBody() { + return true; + } + } + + private static class EventEntity extends HttpEntity { + private final String eventBodyTemplate = + "{ \"type\": \"%s\", \"timestamp\": %s, \"text\": \"some error " + UUID.randomUUID() + " \" }"; + + private long timestamp = 0; + private final String eventType; + + protected EventEntity(final MultiValueMap headers, final String eventType) { + super(headers); + this.eventType = eventType; + } + + void next() { + this.timestamp = System.currentTimeMillis(); + } + + @Override + public String getBody() { + return String.format(this.eventBodyTemplate, this.eventType, this.timestamp); + } + + @Override + public boolean hasBody() { + return true; + } + } + + public static CharBuffer toCharBuffer(final ByteBuffer byteBuffer) { + if (byteBuffer == null) { + return CharBuffer.allocate(0); + } + + byteBuffer.rewind(); + return StandardCharsets.UTF_8.decode(byteBuffer); + } + + public static String toString(final ByteBuffer byteBuffer) { + return toCharBuffer(byteBuffer).toString(); + } + + public static String toString(final byte[] byteArray) { + if (byteArray == null) { + return null; + } + + return toString(ByteBuffer.wrap(byteArray)); + } + +} diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index 83812f60..7ca28309 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -33,6 +33,7 @@ import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; import org.springframework.test.context.jdbc.Sql; @@ -42,6 +43,7 @@ import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.APIMessage; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; +import ch.ethz.seb.sebserver.gbl.client.ClientCredentials; import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.Domain.SEB_CLIENT_CONFIGURATION; import ch.ethz.seb.sebserver.gbl.model.EntityName; @@ -73,6 +75,9 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation; import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.sebconfig.TemplateAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.View; +import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData; +import ch.ethz.seb.sebserver.gbl.model.session.ExtendedClientEvent; +import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue; import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.model.user.UserRole; @@ -108,6 +113,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.lmssetup.GetLmsSe import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.lmssetup.NewLmsSetup; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.lmssetup.SaveLmsSetup; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.lmssetup.TestLmsSetup; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs.GetExtendedClientEventPage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.quiz.GetQuizData; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.quiz.GetQuizPage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.quiz.ImportAsExam; @@ -149,12 +155,15 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Sa import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionDataList; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetRunningExamPage; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccountNames; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.NewUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.SaveUserAccount; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UseCasesIntegrationTest extends GuiIntegrationTest { @@ -2017,4 +2026,105 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // xmlString); } + @Autowired + private SEBClientConfigDAO sebClientConfigDAO; + + @Test + @Order(17) + // ************************************* + // Use Case 16: Login as examSupport2 and get running exam with data + // - Get list of running exams + // - Simulate a SEB connection + // - Join running exam by get the data for all SEB connections and for a single SEB connection. + public void testUsecase17_RunningExam() throws IOException { + final RestServiceImpl restService = createRestServiceForUser( + "examSupport2", + "examSupport2", + new GetRunningExamPage(), + new GetClientConnectionDataList(), + new GetExtendedClientEventPage()); + + final RestServiceImpl adminRestService = createRestServiceForUser( + "TestInstAdmin", + "987654321", + new NewClientConfig(), + new ActivateClientConfig(), + new GetClientConfigPage()); + + // get running exams + final Result> runningExamsCall = restService.getBuilder(GetRunningExamPage.class) + .call(); + + assertNotNull(runningExamsCall); + assertFalse(runningExamsCall.hasError()); + final Page page = runningExamsCall.get(); + assertFalse(page.content.isEmpty()); + final Exam exam = page.content.get(0); + assertEquals("Demo Quiz 1 (MOCKUP)", exam.name); + + // get SEB connections + Result> connectionsCall = + restService.getBuilder(GetClientConnectionDataList.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call(); + + assertNotNull(connectionsCall); + assertFalse(connectionsCall.hasError()); + Collection connections = connectionsCall.get(); + // no SEB connections available yet + assertTrue(connections.isEmpty()); + + // get active client config's credentials + final Result> cconfigs = adminRestService.getBuilder(GetClientConfigPage.class) + .call(); + assertNotNull(cconfigs); + assertFalse(cconfigs.hasError()); + final Page ccPage = cconfigs.get(); + assertFalse(ccPage.content.isEmpty()); + + final SEBClientConfig clientConfig = ccPage.content.get(0); + assertTrue(clientConfig.isActive()); + final ClientCredentials credentials = this.sebClientConfigDAO.getSEBClientCredentials(clientConfig.getModelId()) + .getOrThrow(); + + adminRestService.getBuilder(ActivateClientConfig.class) + .withURIVariable(API.PARAM_MODEL_ID, clientConfig.getModelId()) + .call(); + + // simulate a SEB connection + try { + new SEBClientBot(credentials, exam.getModelId(), String.valueOf(exam.institutionId)); + Thread.sleep(2000); + } catch (final Exception e) { + fail(e.getCause().getMessage()); + } + + connectionsCall = + restService.getBuilder(GetClientConnectionDataList.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call(); + + assertNotNull(connectionsCall); + assertFalse(connectionsCall.hasError()); + connections = connectionsCall.get(); + assertFalse(connections.isEmpty()); + final ClientConnectionData conData = connections.iterator().next(); + assertNotNull(conData); + assertEquals(exam.id, conData.clientConnection.examId); + assertFalse(conData.indicatorValues.isEmpty()); + final IndicatorValue indicatorValue = conData.indicatorValues.get(0); + assertEquals("LAST_PING", indicatorValue.getType().name); + + // get client logs + final Result> clientLogPage = restService.getBuilder(GetExtendedClientEventPage.class) + .call(); + + assertNotNull(clientLogPage); + assertFalse(clientLogPage.hasError()); + final Page clientLogs = clientLogPage.get(); + assertFalse(clientLogs.isEmpty()); + final ExtendedClientEvent extendedClientEvent = clientLogs.content.get(0); + assertNotNull(extendedClientEvent); + } + } From e394cb5863217f567b2a5afdd5932e9a52cc7269 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jun 2020 14:14:18 +0200 Subject: [PATCH 23/26] more integration tests --- .../service/session/InstructionProcessor.java | 2 +- .../integration/UseCasesIntegrationTest.java | 65 +++++++++++++++++-- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java index b2ca6519..9a409f66 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java @@ -75,7 +75,7 @@ public class InstructionProcessor { .apply(ClientConnection.getStatusPredicate(ConnectionStatus.ACTIVE)); if (connectionTokens.isEmpty()) { - // TODO message + log.warn("Empty selection"); return; } diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index 7ca28309..a52d3a00 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -76,6 +76,8 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; import ch.ethz.seb.sebserver.gbl.model.sebconfig.TemplateAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.View; import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData; +import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction; +import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction.InstructionType; import ch.ethz.seb.sebserver.gbl.model.session.ExtendedClientEvent; import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue; import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange; @@ -155,8 +157,10 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Sa import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.DisableClientConnection; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionDataList; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetRunningExamPage; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.PropagateInstruction; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount; @@ -2042,7 +2046,9 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { "examSupport2", new GetRunningExamPage(), new GetClientConnectionDataList(), - new GetExtendedClientEventPage()); + new GetExtendedClientEventPage(), + new DisableClientConnection(), + new PropagateInstruction()); final RestServiceImpl adminRestService = createRestServiceForUser( "TestInstAdmin", @@ -2094,9 +2100,39 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { // simulate a SEB connection try { new SEBClientBot(credentials, exam.getModelId(), String.valueOf(exam.institutionId)); - Thread.sleep(2000); + Thread.sleep(1000); + // send quit instruction + connectionsCall = + restService.getBuilder(GetClientConnectionDataList.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call(); + + assertNotNull(connectionsCall); + assertFalse(connectionsCall.hasError()); + connections = connectionsCall.get(); + assertFalse(connections.isEmpty()); + final Iterator iterator = connections.iterator(); + iterator.next(); + final ClientConnectionData con = iterator.next(); + + final ClientInstruction clientInstruction = new ClientInstruction( + null, + exam.id, + InstructionType.SEB_QUIT, + con.clientConnection.connectionToken, + null); + + final Result instructionCall = restService.getBuilder(PropagateInstruction.class) + .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.id)) + .withBody(clientInstruction) + .call(); + + assertNotNull(instructionCall); + assertFalse(instructionCall.hasError()); + + Thread.sleep(1000); } catch (final Exception e) { - fail(e.getCause().getMessage()); + fail(e.getMessage()); } connectionsCall = @@ -2108,13 +2144,34 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { assertFalse(connectionsCall.hasError()); connections = connectionsCall.get(); assertFalse(connections.isEmpty()); - final ClientConnectionData conData = connections.iterator().next(); + ClientConnectionData conData = connections.iterator().next(); assertNotNull(conData); assertEquals(exam.id, conData.clientConnection.examId); assertFalse(conData.indicatorValues.isEmpty()); final IndicatorValue indicatorValue = conData.indicatorValues.get(0); assertEquals("LAST_PING", indicatorValue.getType().name); + // disable connection + final Result disableCall = restService.getBuilder(DisableClientConnection.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .withFormParam( + Domain.CLIENT_CONNECTION.ATTR_CONNECTION_TOKEN, + conData.clientConnection.connectionToken) + .call(); + assertNotNull(disableCall); + assertFalse(disableCall.hasError()); + connectionsCall = + restService.getBuilder(GetClientConnectionDataList.class) + .withURIVariable(API.PARAM_MODEL_ID, exam.getModelId()) + .call(); + + assertNotNull(connectionsCall); + assertFalse(connectionsCall.hasError()); + connections = connectionsCall.get(); + assertFalse(connections.isEmpty()); + conData = connections.iterator().next(); + assertEquals("DISABLED", conData.clientConnection.status.name()); + // get client logs final Result> clientLogPage = restService.getBuilder(GetExtendedClientEventPage.class) .call(); From 8398378860c5e8eb887a7e2680c742d3e6b20231 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jun 2020 14:21:38 +0200 Subject: [PATCH 24/26] fix codecov --- codecov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index de337b64..ca7d26f9 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,7 +1,7 @@ coverage: - range: "40...75" - round: down precision: 2 + round: down + range: "40...100" fixes: -"::seb-server/" From 9d353296f348163f05869146f3f8526c43a2152e Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jun 2020 14:25:46 +0200 Subject: [PATCH 25/26] prepare for patch version 1.0.1 --- pom.xml | 2 +- src/main/resources/config/application.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 73a5f3a7..cfc90222 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.0.1-SNAPSHOT + 1.0.1 ${sebserver-version} UTF-8 UTF-8 diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index f53b0aa1..ea7af68d 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -1,6 +1,6 @@ spring.application.name=SEB Server spring.profiles.active=dev -sebserver.version=1.0.0 +sebserver.version=1.0.1 ########################################################## ### Global Server Settings From 1ebc5a7f70ba3fcdef25bd77f7ad6b5759cfac75 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jun 2020 14:39:53 +0200 Subject: [PATCH 26/26] prepare for next version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfc90222..4c45f724 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.0.1 + 1.0.2-SNAPSHOT ${sebserver-version} UTF-8 UTF-8