From de947d5640a272583d36ae5c3cb7a1ea0208619b Mon Sep 17 00:00:00 2001 From: Karthikeyan Rajendran <70887864+karthik-tarento@users.noreply.github.com> Date: Mon, 6 Jun 2022 20:03:52 +0530 Subject: [PATCH] Updating ES object details after user account activation --- .../service/UserRegistrationServiceImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sunbird/user/registration/service/UserRegistrationServiceImpl.java b/src/main/java/org/sunbird/user/registration/service/UserRegistrationServiceImpl.java index 736f4527a..32e9957ae 100644 --- a/src/main/java/org/sunbird/user/registration/service/UserRegistrationServiceImpl.java +++ b/src/main/java/org/sunbird/user/registration/service/UserRegistrationServiceImpl.java @@ -207,11 +207,28 @@ public void initiateCreateUserFlow(String registrationCode) { * 5. Assign Role 6. Reset Password and get activation link */ LOGGER.info("Initiated User Creation flow for Reg. Code :: " + registrationCode); - if (userUtilityService.createUser(getUserRegistrationForRegCode(registrationCode))) { + UserRegistration userReg = getUserRegistrationForRegCode(registrationCode); + UserRegistrationStatus regStatus = UserRegistrationStatus.WF_APPROVED; + if (userUtilityService.createUser(userReg)) { LOGGER.info("Successfully completed user creation flow."); } else { LOGGER.error("Failed to create user for Reg.Code :: " + registrationCode); + regStatus = UserRegistrationStatus.FAILED; } + + userReg.setStatus(regStatus.name()); + RestStatus status = indexerService.updateEntity(serverProperties.getUserRegistrationIndex(), + serverProperties.getEsProfileIndexType(), userReg.getRegistrationCode(), + mapper.convertValue(userReg, Map.class)); + + StringBuilder strBuilder = new StringBuilder(); + strBuilder.append("UserRegistration Code :: '").append(userReg.getRegistrationCode()); + strBuilder.append("'. Create User Flow is ") + .append(regStatus == UserRegistrationStatus.WF_APPROVED ? " successful" : " failed"); + strBuilder.append(". ES object update operation is ") + .append(status == RestStatus.OK ? " successful." : " failed."); + + LOGGER.info(strBuilder.toString()); } catch (Exception e) { LOGGER.error("Failed to process user create flow.", e); }