SEBSERV-270

This commit is contained in:
anhefti 2022-02-02 14:13:32 +01:00
parent c66a59223e
commit aea16bfc99
3 changed files with 21 additions and 10 deletions

View file

@ -150,11 +150,17 @@ public class JitsiProctoringService implements ExamProctoringService {
final ResponseEntity<String> result = final ResponseEntity<String> result =
restTemplate.getForEntity(proctoringSettings.serverURL, String.class); restTemplate.getForEntity(proctoringSettings.serverURL, String.class);
if (result.getStatusCode() != HttpStatus.OK) { 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) { } catch (final Exception e) {
log.error("Failed to access proctoring service: {}", e.getMessage()); 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; return true;

View file

@ -186,14 +186,17 @@ public class ZoomProctoringService implements ExamProctoringService {
credentials); credentials);
if (result.getStatusCode() != HttpStatus.OK) { if (result.getStatusCode() != HttpStatus.OK) {
throw new APIMessageException( throw new APIMessageException(Arrays.asList(
APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR, APIMessage.fieldValidationError(ProctoringServiceSettings.ATTR_SERVER_URL,
String.valueOf(result.getStatusCode())); "proctoringSettings:serverURL:url.invalid"),
APIMessage.ErrorMessage.EXTERNAL_SERVICE_BINDING_ERROR.of()));
} }
} catch (final Exception e) { } catch (final Exception e) {
log.error("Failed to access Zoom service at: {}", proctoringSettings.serverURL, 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; return true;

View file

@ -379,9 +379,11 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
return this.entityDAO.byPK(examId) return this.entityDAO.byPK(examId)
.flatMap(this.authorization::checkModify) .flatMap(this.authorization::checkModify)
.map(exam -> { .map(exam -> {
if (proctoringServiceSettings.enableProctoring) {
this.examAdminService.getExamProctoringService(proctoringServiceSettings.serverType) this.examAdminService.getExamProctoringService(proctoringServiceSettings.serverType)
.flatMap(service -> service.testExamProctoring(proctoringServiceSettings)) .flatMap(service -> service.testExamProctoring(proctoringServiceSettings))
.getOrThrow(); .getOrThrow();
}
this.examAdminService.saveProctoringServiceSettings(examId, proctoringServiceSettings); this.examAdminService.saveProctoringServiceSettings(examId, proctoringServiceSettings);
return exam; return exam;
}) })