From aea16bfc99dac6a6051a57ced07d8079fa9e5d9f Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 2 Feb 2022 14:13:32 +0100 Subject: [PATCH] SEBSERV-270 --- .../impl/proctoring/JitsiProctoringService.java | 10 ++++++++-- .../impl/proctoring/ZoomProctoringService.java | 13 ++++++++----- .../weblayer/api/ExamAdministrationController.java | 8 +++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/JitsiProctoringService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/JitsiProctoringService.java index 293c039e..1f6c4e79 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/JitsiProctoringService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/JitsiProctoringService.java @@ -150,11 +150,17 @@ public class JitsiProctoringService implements ExamProctoringService { final ResponseEntity result = restTemplate.getForEntity(proctoringSettings.serverURL, String.class); if (result.getStatusCode() != HttpStatus.OK) { - throw new APIMessageException(APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR); + throw new APIMessageException(Arrays.asList( + APIMessage.fieldValidationError(ProctoringServiceSettings.ATTR_SERVER_URL, + "proctoringSettings:serverURL:url.invalid"), + APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR.of())); } } catch (final Exception e) { log.error("Failed to access proctoring service: {}", e.getMessage()); - throw new APIMessageException(APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR, e.getMessage()); + throw new APIMessageException(Arrays.asList( + APIMessage.fieldValidationError(ProctoringServiceSettings.ATTR_SERVER_URL, + "proctoringSettings:serverURL:url.invalid"), + APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR.of(e))); } return true; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java index 690f25d2..02afee6a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java @@ -186,14 +186,17 @@ public class ZoomProctoringService implements ExamProctoringService { credentials); if (result.getStatusCode() != HttpStatus.OK) { - throw new APIMessageException( - APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR, - String.valueOf(result.getStatusCode())); + throw new APIMessageException(Arrays.asList( + APIMessage.fieldValidationError(ProctoringServiceSettings.ATTR_SERVER_URL, + "proctoringSettings:serverURL:url.invalid"), + APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR.of())); } - } catch (final Exception e) { log.error("Failed to access Zoom service at: {}", proctoringSettings.serverURL, e); - throw new APIMessageException(APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR, e.getMessage()); + throw new APIMessageException(Arrays.asList( + APIMessage.fieldValidationError(ProctoringServiceSettings.ATTR_SERVER_URL, + "proctoringSettings:serverURL:url.invalid"), + APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR.of())); } return true; 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 ec38c0f0..07985834 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 @@ -379,9 +379,11 @@ public class ExamAdministrationController extends EntityController { return this.entityDAO.byPK(examId) .flatMap(this.authorization::checkModify) .map(exam -> { - this.examAdminService.getExamProctoringService(proctoringServiceSettings.serverType) - .flatMap(service -> service.testExamProctoring(proctoringServiceSettings)) - .getOrThrow(); + if (proctoringServiceSettings.enableProctoring) { + this.examAdminService.getExamProctoringService(proctoringServiceSettings.serverType) + .flatMap(service -> service.testExamProctoring(proctoringServiceSettings)) + .getOrThrow(); + } this.examAdminService.saveProctoringServiceSettings(examId, proctoringServiceSettings); return exam; })