diff --git a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java index bf759182b..82b04b79e 100644 --- a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java +++ b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java @@ -350,10 +350,11 @@ public SBApiResponse userBasicInfo(String userId) { // Get Email from personalDetails if (profileData.containsKey(Constants.PERSONAL_DETAILS)) { - Map personalDetail = (Map) profileData.get(Constants.PERSONAL_DETAILS); + Map personalDetail = (Map) profileData + .get(Constants.PERSONAL_DETAILS); responseMap.put(Constants.EMAIL, personalDetail.get(Constants.PRIMARY_EMAIL)); } - + responseMap.put(Constants.FIRSTNAME, userData.get(Constants.FIRSTNAME)); responseMap.put(Constants.LASTNAME, userData.get(Constants.LASTNAME)); responseMap.put(Constants.ROLES, userData.get(Constants.ROLES)); @@ -450,7 +451,7 @@ private void getModifiedPersonalDetails(Object personalDetailsObj, Map personalDetailsMap = (Map) personalDetailsObj; if (!ObjectUtils.isEmpty(personalDetailsMap)) { for (String paramName : personalDetailsMap.keySet()) { - if(Constants.FIRST_NAME_LOWER_CASE.equalsIgnoreCase(paramName)) { + if (Constants.FIRST_NAME_LOWER_CASE.equalsIgnoreCase(paramName)) { updatedRequest.put(Constants.FIRSTNAME, (String) personalDetailsMap.get(paramName)); } else if (Constants.SURNAME.equalsIgnoreCase(paramName)) { updatedRequest.put(Constants.FIRSTNAME, (String) personalDetailsMap.get(paramName)); @@ -684,6 +685,19 @@ private String updateUserProfile(Map request) { empDetails.put(Constants.DEPARTMENTNAME, request.get(Constants.CHANNEL)); Map updateReqBody = new HashMap(); + + Map existingPersonalDetail = (Map) existingProfile + .get(Constants.PERSONAL_DETAILS); + if (!ObjectUtils.isEmpty(existingPersonalDetail)) { + if (StringUtils.isNotBlank((String) request.get(Constants.FIRSTNAME))) { + existingPersonalDetail.put(Constants.FIRSTNAME.toLowerCase(), request.get(Constants.FIRSTNAME)); + updateReqBody.put(Constants.FIRSTNAME, request.get(Constants.FIRSTNAME)); + } + if (StringUtils.isNotBlank((String) request.get(Constants.LASTNAME))) { + existingPersonalDetail.put(Constants.SURNAME, request.get(Constants.LASTNAME)); + updateReqBody.put(Constants.LASTNAME, request.get(Constants.LASTNAME)); + } + } updateReqBody.put(Constants.PROFILE_DETAILS, existingProfile); updateReqBody.put(Constants.USER_ID, request.get(Constants.USER_ID)); Map updateRequest = new HashMap<>(); @@ -706,7 +720,7 @@ private String assignUserRole(Map requestBody, List exis Map assignRoleReqBody = new HashMap(); assignRoleReqBody.put(Constants.ORGANIZATION_ID, requestBody.get(Constants.SB_ORG_ID)); assignRoleReqBody.put(Constants.USER_ID, requestBody.get(Constants.USER_ID)); - if(existingRoles == null) { + if (existingRoles == null) { existingRoles = new ArrayList(); } if (existingRoles.size() == 0) {