Skip to content

Commit

Permalink
Fix for started saga
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Nov 23, 2023
1 parent cb1bf9b commit 666288b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public ResponseEntity<String> moveSchool(MoveSchoolData moveSchoolData) {
public OnboardingFileProcessResponse processOnboardingFile(OnboardingFileUpload fileUpload) {
List<SagaEntity> 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;
Expand Down Expand Up @@ -240,4 +240,14 @@ private ResponseEntity<String> 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());
}
}
}

0 comments on commit 666288b

Please sign in to comment.