From ae9cb1c6355309caf0381b45d59d5de13ea88031 Mon Sep 17 00:00:00 2001 From: ravisaurav-tarento <142487505+ravisaurav-tarento@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:53:27 +0530 Subject: [PATCH] Cbrelease 4.8.14 (#609) * added import statements * KB-4754:Modified validation error for employee Id * KB-4753:Changed error message format * KB:528:Handled error and returned error with proper format for existing email or phone --- .../java/org/sunbird/common/util/Constants.java | 4 ++-- .../profile/service/ProfileServiceImpl.java | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index fad4af775..430842e85 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -438,7 +438,7 @@ public class Constants { public static final String APPROVED = "approved"; public static final String DENIED = "denied"; - public static final String EMAIL_EXIST_ERROR = "Email id already registered"; + public static final String EMAIL_EXIST_ERROR = "Email id already registered with another User profile"; public static final String EMAIL_VERIFIED = "emailVerified"; public static final String USER_NAME = "userName"; public static final String USER_FULL_NAME = "fullName"; @@ -654,7 +654,7 @@ public class Constants { public static final String CHECKS = "checks"; public static final String CASSANDRA_DB = "cassandra db"; public static final String REDIS_CACHE = "redis cache"; - public static final String PHONE_NUMBER_EXIST_ERROR = "Phone number is already registered."; + public static final String PHONE_NUMBER_EXIST_ERROR = "Phone number is already registered with another User profile."; public static final String MOBILE_NUMBER_EXIST_ERROR = "Mobile number is already registered."; public static final String PHONE_VERIFIED = "phoneVerified"; public static final String QUERY = "query"; diff --git a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java index 6d8773328..5ece3838c 100644 --- a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java +++ b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java @@ -1758,8 +1758,6 @@ public SBApiResponse profileMDOAdminUpdate(Map request, String u adminUpdateMap.put(key, profileDetailsMap.get(key)); } } - - Map headerValues = new HashMap<>(); headerValues.put(Constants.AUTH_TOKEN, authToken); headerValues.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON); @@ -1905,14 +1903,22 @@ public SBApiResponse profileMDOAdminUpdate(Map request, String u response.getParams().setStatus(Constants.SUCCESS); } else { if (updateResponse != null && Constants.CLIENT_ERROR.equalsIgnoreCase((String) updateResponse.get(Constants.RESPONSE_CODE))) { + Map responseParams = (Map) updateResponse.get(Constants.PARAMS); + if(MapUtils.isNotEmpty(responseParams)){ + String errorMessage = (String) responseParams.get(Constants.ERROR_MESSAGE); + response.getParams().setErrmsg(errorMessage); + } response.setResponseCode(HttpStatus.BAD_REQUEST); } else { response.setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR); } response.getParams().setStatus(Constants.FAILED); - String errMsg = (String) ((Map) updateResponse.get(Constants.PARAMS)).get(Constants.ERROR_MESSAGE); - errMsg = PropertiesCache.getInstance().readCustomError(errMsg); - response.getParams().setErrmsg(errMsg); + String errMsg = response.getParams().getErrmsg(); + if(StringUtils.isEmpty(errMsg)){ + errMsg = (String) ((Map) updateResponse.get(Constants.PARAMS)).get(Constants.ERROR_MESSAGE); + errMsg = PropertiesCache.getInstance().readCustomError(errMsg); + response.getParams().setErrmsg(errMsg); + } log.error(errMsg, new Exception(errMsg)); return response; }