From 64fc026a57cf26d4528cdacded2eddfd611b0b2b Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 19 Jun 2023 16:26:56 +0200 Subject: [PATCH 01/11] increased SEB connection cache to 30000 --- src/main/resources/config/ehcache.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config/ehcache.xml b/src/main/resources/config/ehcache.xml index 74e0a0fae..f39f1aff6 100644 --- a/src/main/resources/config/ehcache.xml +++ b/src/main/resources/config/ehcache.xml @@ -34,7 +34,7 @@ 24 - 3000 + 30000 From b94f9169932121a7adcb0e9219400a603e90a702 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 17 Jul 2023 11:11:39 +0200 Subject: [PATCH 02/11] SEBSERV-450 cherry pick from UZH patch --- .../ethz/seb/sebserver/gui/table/EntityTable.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index 74a5d295e..4015b6cd1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -224,6 +224,9 @@ public class EntityTable { } this.table.addListener(SWT.Selection, event -> { if (this.multiselection != null && event.item != null) { + if (event.item == null || event.item.isDisposed()) { + return; + } handleMultiSelection((TableItem) event.item); event.doit = false; } @@ -527,6 +530,9 @@ private void updateTableRows( // first remove all rows if there are some this.table.removeAll(); + if (this.multiselection != null) { + this.multiselection.clear(); + } // get page data and create rows final Page page = this.pageSupplier.newBuilder() @@ -642,10 +648,19 @@ private void adaptColumnWidthChange(final Event event) { @SuppressWarnings("unchecked") private ROW getRowData(final TableItem item) { + if (item == null || item.isDisposed()) { + log.warn("Selected item is null or disposed: {}", item); + return null; + } return (ROW) item.getData(TABLE_ROW_DATA); } private EntityKey getEntityKey(final TableItem item) { + if (item == null || item.isDisposed()) { + log.warn("Selected item is null or disposed: {}", item); + return null; + } + final ROW rowData = getRowData(item); if (rowData instanceof Entity) { return ((Entity) rowData).getEntityKey(); From 460f0483ca7b1b997910a51a06c1fc9a594096da Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 28 Sep 2023 16:28:32 +0200 Subject: [PATCH 03/11] SEBSERV-468 fixed --- .../gui/content/exam/QuizLookupList.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/QuizLookupList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/QuizLookupList.java index 4ba770939..f89a62c82 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/QuizLookupList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/QuizLookupList.java @@ -18,6 +18,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -451,31 +452,28 @@ private String toAdditionalValue(final String name, final String value) { } } - private Composite warningPanel = null; - private void handelPageReload( final Composite notePanel, final EntityTable table) { if (table.isComplete()) { PageService.clearComposite(notePanel); - if (this.warningPanel != null) { - this.warningPanel.dispose(); - } - this.warningPanel = null; } else { - if (this.warningPanel != null && !this.warningPanel.isDisposed()) { - this.warningPanel.dispose(); + + final Control[] children = notePanel.getChildren(); + if (children != null && children.length > 0) { + return; } - this.warningPanel = this.widgetFactory.createWarningPanel(notePanel, 15, true); + final Composite warningPanel = this.widgetFactory.createWarningPanel(notePanel, 15, true); + warningPanel.setData("warningPanel", "TRUE"); this.widgetFactory.imageButton( ImageIcon.SWITCH, - this.warningPanel, + warningPanel, TEXT_FETCH_NOTE_TOOLTIP, event -> table.applyFilter()); - final Label text = new Label(this.warningPanel, SWT.NONE); + final Label text = new Label(warningPanel, SWT.NONE); text.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); text.setText(this.pageService.getI18nSupport().getText(TEXT_FETCH_NOTE)); final GridData gridData = new GridData(SWT.LEFT, SWT.FILL, true, true); From 77e861897534e454c16bea580b1332d5d554d0ca Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 28 Sep 2023 17:14:05 +0200 Subject: [PATCH 04/11] SEBSERV-464 fixed --- .../lms/impl/moodle/plugin/MoodlePluginCourseAccess.java | 6 +++++- .../servicelayer/session/impl/ExamUpdateHandler.java | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java index a55056741..20a5b5cbf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java @@ -536,6 +536,10 @@ private List getQuizzesForIds( lmsSetup); } + final Set qIdSet = internalIds.stream() + .map(MoodleUtils::getQuizId) + .collect(Collectors.toSet()); + return getCoursesForIds(restTemplate, moodleCourseIds) .stream() .filter(courseData -> !courseData.quizzes.isEmpty()) @@ -545,7 +549,7 @@ private List getQuizzesForIds( urlPrefix, this.prependShortCourseName) .stream() - .filter(q -> internalIds.contains(q.id))) + .filter(q -> qIdSet.contains(MoodleUtils.getQuizId(q.id)))) .collect(Collectors.toList()); } catch (final Exception e) { 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 033e7e5fc..1ab751a3b 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 @@ -356,7 +356,8 @@ private boolean hasChanges(final Exam exam, final QuizData quizData) { !Objects.equals(exam.startTime, quizData.startTime) || !Objects.equals(exam.endTime, quizData.endTime) || !Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description) || - !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { + !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL) || + !exam.externalId.equals(quizData.id)) { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) { log.info("Update name difference from LMS. Exam: {}, QuizData: {}", exam.name, quizData.name); @@ -376,6 +377,11 @@ private boolean hasChanges(final Exam exam, final QuizData quizData) { exam.getStartURL(), quizData.startURL); } + if (exam.externalId.equals(quizData.id)) { + log.info("Update quizId difference from LMS. Exam:{}, QuizData: {}", + exam.externalId, + quizData.id); + } return true; } From d6782075bcbabd8a013af3661442fc5220c70210 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 09:57:32 +0200 Subject: [PATCH 05/11] SEBSERV-466 fixed --- .../java/ch/ethz/seb/sebserver/gui/widget/PasswordInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordInput.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordInput.java index fc0965be5..2e1dfbd80 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordInput.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordInput.java @@ -98,7 +98,7 @@ private void changePasswordView() { final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); passwordInput.setLayoutData(gridData); passwordInput.setText(value != null - ? Utils.escapeHTML_XML_EcmaScript(value) + ? value : StringUtils.EMPTY); if (!buildPassword) { passwordInput.setEditable(false); From 1d2c88c971ae524a152bc13de5e5b60e58efd166 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 12:03:39 +0200 Subject: [PATCH 06/11] SEBSERV-467 fix plus added authentication to LMSSetup test --- .../lms/impl/olat/OlatLmsAPITemplate.java | 17 +++++++++++++++++ .../lms/impl/olat/OlatLmsRestTemplate.java | 9 +++++++-- .../config/application-dev-ws.properties | 2 +- src/main/resources/messages.properties | 1 + .../api/admin/OlatLmsAPITemplateTest.java | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsAPITemplate.java index 917ba0bc8..040942e83 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsAPITemplate.java @@ -163,6 +163,23 @@ private LmsSetupTestResult testLmsSetupSettings() { "lmsSetup:lmsClientsecret:notNull")); } + final Result restTemplateResult = getRestTemplate(); + if (restTemplateResult.hasError()) { + missingAttrs.add(APIMessage.fieldValidationError( + LMS_SETUP.ATTR_LMS_URL, + "lmsSetup:lmsUrl:url.noservice")); + } else { + final OlatLmsRestTemplate olatLmsRestTemplate = restTemplateResult.get(); + try { + olatLmsRestTemplate.testAuthentication(); + } catch (final Exception e) { + log.error("Failed to test Authentication: {}", e.getMessage()); + missingAttrs.add(APIMessage.fieldValidationError( + LMS_SETUP.ATTR_LMS_URL, + "lmsSetup:lmsUrl:url.noaccess")); + } + } + if (!missingAttrs.isEmpty()) { return LmsSetupTestResult.ofMissingAttributes(LmsType.OPEN_OLAT, missingAttrs); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java index 533a3acc3..5f0d36367 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java @@ -32,6 +32,10 @@ public class OlatLmsRestTemplate extends RestTemplate { private String token; private ClientCredentialsResourceDetails details; + public void testAuthentication() { + authenticate(); + } + public OlatLmsRestTemplate(final ClientCredentialsResourceDetails details) { super(); this.details = details; @@ -45,7 +49,6 @@ public synchronized ClientHttpResponse intercept( final ClientHttpRequestExecution execution) throws IOException { try { - // if there's no token, authenticate first if (OlatLmsRestTemplate.this.token == null) { authenticate(); @@ -59,6 +62,7 @@ else if (OlatLmsRestTemplate.this.token.equals("authenticating")) { return execution.execute(request, body); } + // otherwise, add the X-OLAT-TOKEN request.getHeaders().set("accept", "application/json"); request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token); @@ -85,6 +89,7 @@ else if (OlatLmsRestTemplate.this.token.equals("authenticating")) { log.debug("OLAT [retry API call]: URL {}", request.getURI()); } + response.close(); response = execution.execute(request, body); if (log.isDebugEnabled()) { @@ -97,7 +102,7 @@ else if (OlatLmsRestTemplate.this.token.equals("authenticating")) { } catch (final Exception e) { // TODO find a way to better deal with Olat temporary unavailability - log.error("Unexpected error: ", e); + log.error("Unexpected error: {}", e.getMessage()); throw e; } } diff --git a/src/main/resources/config/application-dev-ws.properties b/src/main/resources/config/application-dev-ws.properties index b49bad3b5..d2a040b4c 100644 --- a/src/main/resources/config/application-dev-ws.properties +++ b/src/main/resources/config/application-dev-ws.properties @@ -25,7 +25,7 @@ sebserver.webservice.clean-db-on-startup=false # webservice configuration sebserver.init.adminaccount.gen-on-init=false -sebserver.webservice.distributed=true +sebserver.webservice.distributed=false #sebserver.webservice.master.delay.threshold=10000 sebserver.webservice.http.external.scheme=http sebserver.webservice.http.external.servername=localhost diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 6af4ca760..3873d6c26 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -111,6 +111,7 @@ sebserver.form.validation.fieldError.serverNotAvailable=No service seems to be a sebserver.form.validation.fieldError.url.invalid=Invalid URL. The given URL cannot be reached. sebserver.form.validation.fieldError.typeInvalid=This type is not implemented yet and cannot be used. sebserver.form.validation.fieldError.url.noservice=The expected service is not available within the given URL and API access. +sebserver.form.validation.fieldError.url.noaccess=There has no access been granted by the service. Please check the given access credentials. sebserver.form.validation.fieldError.thresholdDuplicate=There are duplicate threshold values. sebserver.form.validation.fieldError.thresholdEmpty=There are missing values or colors for the threshold declaration sebserver.form.validation.fieldError.invalidIP=Invalid IP v4. Please enter a valid IP-address (v4) diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java index 2431220e1..5e2b5850a 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java @@ -41,6 +41,8 @@ public class OlatLmsAPITemplateTest extends AdministrationAPIIntegrationTester { private ExamConfigurationValueService examConfigurationValueService; @Autowired private CacheManager cacheManager; + @Autowired + private OlatLmsRestTemplate olatLmsRestTemplate; @Test public void testSetRestriction() throws Exception { From d2d72533faf0b3eeaf9239c8dbfaf263f1252704 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 12:09:12 +0200 Subject: [PATCH 07/11] fixed test --- .../integration/api/admin/OlatLmsAPITemplateTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java index 5e2b5850a..2431220e1 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/OlatLmsAPITemplateTest.java @@ -41,8 +41,6 @@ public class OlatLmsAPITemplateTest extends AdministrationAPIIntegrationTester { private ExamConfigurationValueService examConfigurationValueService; @Autowired private CacheManager cacheManager; - @Autowired - private OlatLmsRestTemplate olatLmsRestTemplate; @Test public void testSetRestriction() throws Exception { From 3465f5b836a429f55df7ff03ed89a5086b123c55 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 15:39:00 +0200 Subject: [PATCH 08/11] prepare for patch 1.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f4ea900e..9c987aba9 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.5.2-SNAPSHOT + 1.5.2 ${sebserver-version} ${sebserver-version} UTF-8 From f8706d26d4c4849eecdec0b25ef437b90c1c3cd6 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 15:53:31 +0200 Subject: [PATCH 09/11] fixed exam id change check --- .../servicelayer/session/impl/ExamUpdateHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 1ab751a3b..55b1d1c58 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 @@ -357,7 +357,7 @@ private boolean hasChanges(final Exam exam, final QuizData quizData) { !Objects.equals(exam.endTime, quizData.endTime) || !Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description) || !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL) || - !exam.externalId.equals(quizData.id)) { + !Objects.equals(exam.externalId, quizData.id)) { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) { log.info("Update name difference from LMS. Exam: {}, QuizData: {}", exam.name, quizData.name); @@ -377,7 +377,7 @@ private boolean hasChanges(final Exam exam, final QuizData quizData) { exam.getStartURL(), quizData.startURL); } - if (exam.externalId.equals(quizData.id)) { + if (!Objects.equals(exam.externalId, quizData.id)) { log.info("Update quizId difference from LMS. Exam:{}, QuizData: {}", exam.externalId, quizData.id); From ac8c7b034d0b772b260a5f4f8e2f323db8762115 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 16:17:49 +0200 Subject: [PATCH 10/11] SEBSERV-464 fix moodle course short name change recover --- .../session/impl/ExamUpdateHandler.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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 55b1d1c58..4cb062fef 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 @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import org.joda.time.DateTime; @@ -28,6 +29,7 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus; import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features; +import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gbl.util.Utils; @@ -38,6 +40,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle.MoodleUtils; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamFinishedEvent; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamResetEvent; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamStartedEvent; @@ -138,7 +141,12 @@ Result> updateExamFromLMS(final Long lmsSetupId, final Map { try { - final Exam exam = exams.get(quiz.id); + final Exam exam = getExamForQuizWithMoodleSpecialCase(exams, quiz); + + if (exam == null) { + log.warn("Failed to find map exam to fetched quiz-data: {}", quiz); + return; + } if (hasChanges(exam, quiz)) { @@ -485,4 +493,29 @@ private void recoverSuccess(final String updateId, final Exam exam, final QuizDa } } + private Exam getExamForQuizWithMoodleSpecialCase(final Map exams, final QuizData quiz) { + Exam exam = exams.get(quiz.id); + + if (exam == null) { + try { + final LmsAPITemplate lms = this.lmsAPIService + .getLmsAPITemplate(quiz.lmsSetupId) + .getOrThrow(); + + if (lms.getType() == LmsType.MOODLE || lms.getType() == LmsType.MOODLE_PLUGIN) { + final String quizId = MoodleUtils.getQuizId(quiz.id); + final Optional find = + exams.keySet().stream().filter(key -> key.startsWith(quizId)).findFirst(); + if (find.isPresent()) { + exam = exams.get(find.get()); + } + } + } catch (final Exception e) { + log.error("Failed to verify changed external Exam id from moodle course: {}", e.getMessage()); + } + } + + return exam; + } + } From 51033385fde476d94edc1fb116379e2339d24491 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 2 Oct 2023 17:02:41 +0200 Subject: [PATCH 11/11] SEBSERV-467 fixed only authenticate on testing if no token --- .../servicelayer/lms/impl/olat/OlatLmsRestTemplate.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java index 5f0d36367..bad59306c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java @@ -33,7 +33,9 @@ public class OlatLmsRestTemplate extends RestTemplate { private ClientCredentialsResourceDetails details; public void testAuthentication() { - authenticate(); + if (this.token == null) { + authenticate(); + } } public OlatLmsRestTemplate(final ClientCredentialsResourceDetails details) { @@ -49,6 +51,7 @@ public synchronized ClientHttpResponse intercept( final ClientHttpRequestExecution execution) throws IOException { try { + // if there's no token, authenticate first if (OlatLmsRestTemplate.this.token == null) { authenticate();