From 666288bf0c8526868017194cf160c293df1678c8 Mon Sep 17 00:00:00 2001 From: Marco Villeneuve Date: Thu, 23 Nov 2023 10:21:23 -0800 Subject: [PATCH] Fix for started saga --- .../api/edx/controller/v1/EdxSagaController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/edx/controller/v1/EdxSagaController.java b/api/src/main/java/ca/bc/gov/educ/api/edx/controller/v1/EdxSagaController.java index cac72c27..edea8f03 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/edx/controller/v1/EdxSagaController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/edx/controller/v1/EdxSagaController.java @@ -139,7 +139,7 @@ public ResponseEntity moveSchool(MoveSchoolData moveSchoolData) { public OnboardingFileProcessResponse processOnboardingFile(OnboardingFileUpload fileUpload) { List sagaEntities = this.edxFileOnboardingService.processOnboardingFile(Base64.getDecoder().decode(fileUpload.getFileContents()), fileUpload.getCreateUser()); log.info("Number of onboarded sagas stored is: " + sagaEntities.size()); - sagaEntities.forEach(sagaEntity -> processServicesSaga(sagaEntity.getSagaName().equals(ONBOARD_SCHOOL_USER_SAGA.toString()) ? ONBOARD_SCHOOL_USER_SAGA : ONBOARD_DISTRICT_USER_SAGA, sagaEntity)); + sagaEntities.forEach(sagaEntity -> startServicesSaga(sagaEntity.getSagaName().equals(ONBOARD_SCHOOL_USER_SAGA.toString()) ? ONBOARD_SCHOOL_USER_SAGA : ONBOARD_DISTRICT_USER_SAGA, sagaEntity)); OnboardingFileProcessResponse response = new OnboardingFileProcessResponse(); response.setProcessedCount(Integer.toString(sagaEntities.size())); return response; @@ -240,4 +240,14 @@ private ResponseEntity processServicesSaga(final SagaEnum sagaName, Saga throw new SagaRuntimeException(e.getMessage()); } } + + private void startServicesSaga(final SagaEnum sagaName, SagaEntity sagaEntity) { + try { + this.getOrchestratorMap() + .get(sagaName.toString()) + .startSaga(sagaEntity); + } catch (final Exception e) { + throw new SagaRuntimeException(e.getMessage()); + } + } }