diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java index 6be32741..c0830352 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java @@ -315,7 +315,6 @@ public class FullLmsIntegrationServiceImpl implements FullLmsIntegrationService .getLmsSetupIdByConnectionId(lmsUUID) .flatMap(lmsAPITemplateCacheService::getLmsAPITemplate) .map(template -> getQuizData(template, courseId, quizId, examData)) - //.map(findQuizData(courseId, quizId)) .map(createExam(examTemplateId, quitPassword)) .map(exam -> applyExamData(exam, false)) .map(this::applyConnectionConfiguration); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java index 8bea0a64..7ffae6c1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java @@ -167,7 +167,7 @@ public class SEBRestrictionServiceImpl implements SEBRestrictionService { return this.applySEBClientRestriction(exam) .flatMap(e -> this.examDAO.setSEBRestriction(e.id, true)) .onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t)) - .getOr(exam); + .getOrThrow(); } @Override diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringAPIBinding.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringAPIBinding.java index 6b31def8..8da94edb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringAPIBinding.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringAPIBinding.java @@ -965,10 +965,20 @@ class ScreenProctoringAPIBinding { final JsonNode requestJSON = this.jsonMapper.readTree(getResponse.getBody()); final JsonNode content = requestJSON.get("content"); if (content.isArray()) { + final JsonNode sebConnection = content.get(0); - spsData.spsSEBAccessUUID = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_UUID).textValue(); - spsData.spsSEBAccessName = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_CLIENT_NAME).textValue(); - spsData.spsSEBAccessPWD = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_CLIENT_SECRET).textValue(); + + // TODO remove when tested + final JsonNode uuidNode = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_UUID); + final JsonNode sebClientNode = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_CLIENT_NAME); + final JsonNode sebSecretNode = sebConnection.get(SPS_API.SEB_ACCESS.ATTR_CLIENT_SECRET); + log.info(" uuidNode: {}", uuidNode); + log.info(" sebClientNode: {}", sebClientNode); + log.info(" sebSecretNode: {}", sebSecretNode); + + spsData.spsSEBAccessUUID = uuidNode.textValue(); + spsData.spsSEBAccessName = sebClientNode.textValue(); + spsData.spsSEBAccessPWD = sebSecretNode.textValue(); return; } } catch (final Exception e) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java index b5d8430d..a3e63155 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java @@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.util.Arrays; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.APIMessage; @@ -21,6 +22,7 @@ import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.webservice.WebserviceInfo; +import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.FullLmsIntegrationService; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; @@ -41,13 +43,16 @@ public class LmsIntegrationController { private final FullLmsIntegrationService fullLmsIntegrationService; private final WebserviceInfo webserviceInfo; + private final ExamDAO examDAO; public LmsIntegrationController( final FullLmsIntegrationService fullLmsIntegrationService, - final WebserviceInfo webserviceInfo) { + final WebserviceInfo webserviceInfo, + final ExamDAO examDAO) { this.fullLmsIntegrationService = fullLmsIntegrationService; this.webserviceInfo = webserviceInfo; + this.examDAO = examDAO; } @RequestMapping( @@ -72,9 +77,14 @@ public class LmsIntegrationController { quitPassword, quitLink, examData) - .onError(e -> log.error( - "Failed to create/import exam: lmsId:{}, courseId: {}, quizId: {}, templateId: {} error: {}", - lmsUUId, courseId, quizId, templateId, e.getMessage())) + .onError(e -> { + log.error( + "Failed to create/import exam: lmsId:{}, courseId: {}, quizId: {}, templateId: {} error: {}", + lmsUUId, courseId, quizId, templateId, e.getMessage()); + log.info("Rollback Exam creation..."); + fullLmsIntegrationService.deleteExam(lmsUUId, courseId, quizId) + .onError(error -> log.error("Failed to rollback auto Exam import: ", error)); + }) .getOrThrow(); log.info("Auto import of exam successful: {}", exam);