From 69f8d6cd4ae5cfa02297ba96fda1e80dc1a5af1e Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 17 Dec 2020 19:34:48 +0100 Subject: [PATCH] handle another error caused by invalid LMS Setup access --- .../lms/impl/LmsAPIServiceImpl.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 058d0b38..dfdc2fd4 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 @@ -157,17 +157,22 @@ public class LmsAPIServiceImpl implements LmsAPIService { // case 1. if lmsSetupId is available only get quizzes from specified LmsSetup final Long lmsSetupId = filterMap.getLmsSetupId(); if (lmsSetupId != null) { - final Long institutionId = filterMap.getInstitutionId(); + try { + final Long institutionId = filterMap.getInstitutionId(); - final LmsAPITemplate template = getLmsAPITemplate(lmsSetupId) - .getOrThrow(); + final LmsAPITemplate template = getLmsAPITemplate(lmsSetupId) + .getOrThrow(); - if (institutionId != null && template.lmsSetup().institutionId != institutionId) { + if (institutionId != null && template.lmsSetup().institutionId != institutionId) { + return Collections.emptyList(); + } + return template + .getQuizzes(filterMap) + .getOrThrow(); + } catch (final Exception e) { + log.error("Failed to get quizzes from LMS Setup: {}", lmsSetupId, e); return Collections.emptyList(); } - return template - .getQuizzes(filterMap) - .getOrThrow(); } // case 2. get quizzes from all LmsSetups of specified institution