From 568113003d31e20f112575f201cec7271421b589 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 22 Apr 2024 10:56:21 +0200 Subject: [PATCH] SEBSERV-417 access token for Moodle --- .../lms/impl/moodle/MoodleRestTemplateFactoryImpl.java | 2 +- .../lms/impl/moodle/plugin/MoodlePluginFullIntegration.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactoryImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactoryImpl.java index f11d2d87..93069042 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactoryImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactoryImpl.java @@ -392,7 +392,7 @@ public class MoodleRestTemplateFactoryImpl implements MoodleRestTemplateFactory // NOTE: for some unknown reason, Moodles API error responses come with a 200 OK response HTTP Status // So this is a special Moodle specific error handling here... - if (body.startsWith("{exception") || body.contains("\"exception\":")) { + if (body != null && (body.startsWith("{exception") || body.contains("\"exception\":"))) { // if no courses has been found for this page, just return (Plugin) if (body.contains("nocoursefound")) { return body; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginFullIntegration.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginFullIntegration.java index 62533838..64cd638d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginFullIntegration.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginFullIntegration.java @@ -82,9 +82,9 @@ public class MoodlePluginFullIntegration implements FullLmsIntegrationAPI { if (StringUtils.isBlank( data.access_token)) { throw new APIMessage.FieldValidationException("lmsFullIntegration:access_token", "access_token is mandatory"); } - if (data.exam_templates.isEmpty()) { - throw new APIMessage.FieldValidationException("lmsFullIntegration:exam_templates", "exam_templates is mandatory"); - } +// if (data.exam_templates.isEmpty()) { +// throw new APIMessage.FieldValidationException("lmsFullIntegration:exam_templates", "exam_templates is mandatory"); +// } // apply final LmsSetup lmsSetup = this.restTemplateFactory.getApiTemplateDataSupplier().getLmsSetup();