Skip to content

Commit

Permalink
Added private update path for user
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed Nov 28, 2023
1 parent b6a7ea9 commit 45ceaaf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
31 changes: 21 additions & 10 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class CbExtServerProperties {
@Value("${lms.system.settings.path}")
private String lmsSystemSettingsPath;

@Value("${lms.user.update.path}")
private String lmsUserUpdatePath;
@Value("${lms.user.update.private.path}")
private String lmsUserUpdatePrivatePath;

@Value("${lms.user.read.path}")
private String lmsUserReadPath;
Expand Down Expand Up @@ -476,11 +476,11 @@ public class CbExtServerProperties {
@Value("${report.download.folder.name}")
private String reportDownloadFolderName;

@Value("${progress.api.update.endpoint}")
private String progressUpdateEndPoint;
@Value("${progress.api.update.endpoint}")
private String progressUpdateEndPoint;

@Value("${kafka.topic.update.content.progress}")
private String updateContentProgressKafkaTopic;
@Value("${kafka.topic.update.content.progress}")
private String updateContentProgressKafkaTopic;

@Value("${sb.es.user.profile.index.type}")
private String sbEsProfileIndexType;
Expand Down Expand Up @@ -536,6 +536,9 @@ public void setRedisQuestionsReadTimeOut(Integer redisQuestionsReadTimeOut) {
@Value("${batch.enrolment.return.size}")
private Integer batchEnrolmentReturnSize;

@Value("${lms.user.update.path}")
private String lmsUserUpdatePath;

public Integer getBatchEnrolmentReturnSize() {
return batchEnrolmentReturnSize;
}
Expand Down Expand Up @@ -596,12 +599,12 @@ public void setWfServiceTransitionPath(String wfServiceTransitionPath) {
this.wfServiceTransitionPath = wfServiceTransitionPath;
}

public String getLmsUserUpdatePath() {
return lmsUserUpdatePath;
public String getLmsUserUpdatePrivatePath() {
return lmsUserUpdatePrivatePath;
}

public void setLmsUserUpdatePath(String lmsUserUpdatePath) {
this.lmsUserUpdatePath = lmsUserUpdatePath;
public void setLmsUserUpdatePrivatePath(String lmsUserUpdatePrivatePath) {
this.lmsUserUpdatePrivatePath = lmsUserUpdatePrivatePath;
}

public String getLmsSystemSettingsPath() {
Expand Down Expand Up @@ -1902,4 +1905,12 @@ public String getMdoAdminUpdateUsers() {
public void setMdoAdminUpdateUsers(String mdoAdminUpdateUsers) {
this.mdoAdminUpdateUsers = mdoAdminUpdateUsers;
}

public String getLmsUserUpdatePath() {
return lmsUserUpdatePath;
}

public void setLmsUserUpdatePath(String lmsUserUpdatePath) {
this.lmsUserUpdatePath = lmsUserUpdatePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public SBApiResponse profileUpdate(Map<String, Object> request, String userToken
String deptName = (String) responseMap.get(Constants.CHANNEL);
Map<String, Object> existingProfileDetails = (Map<String, Object>) responseMap
.get(Constants.PROFILE_DETAILS);
StringBuilder url = new StringBuilder();
HashMap<String, String> headerValues = new HashMap<>();
headerValues.put(Constants.AUTH_TOKEN, authToken);
headerValues.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON);
Expand Down Expand Up @@ -189,7 +188,6 @@ public SBApiResponse profileUpdate(Map<String, Object> request, String userToken
updateRequestValue.put(Constants.PROFILE_DETAILS, existingProfileDetails);
Map<String, Object> updateRequest = new HashMap<>();
updateRequest.put(Constants.REQUEST, updateRequestValue);
url.append(serverConfig.getSbUrl()).append(serverConfig.getLmsUserUpdatePath());
updateResponse = outboundRequestHandlerService.fetchResultUsingPatch(
serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePath(), updateRequest, headerValues);
if (Constants.OK.equalsIgnoreCase((String) updateResponse.get(Constants.RESPONSE_CODE))) {
Expand Down Expand Up @@ -297,8 +295,6 @@ public SBApiResponse profileUpdate(Map<String, Object> request, String userToken
transitionRequests.put(Constants.DEPT_NAME, deptName);
}
transitionRequests.put(Constants.UPDATE_FIELD_VALUES, finalTransitionList);
url = new StringBuilder();
url.append(serverConfig.getWfServiceHost()).append(serverConfig.getWfServiceTransitionPath());
headerValues.put(Constants.ROOT_ORG_CONSTANT, Constants.IGOT);
headerValues.put(Constants.ORG_CONSTANT, Constants.DOPT);
if (headerValues.containsKey(Constants.X_AUTH_TOKEN)) {
Expand Down Expand Up @@ -1075,7 +1071,7 @@ private String updateUserProfile(Map<String, Object> request) {
updateRequest.put(Constants.REQUEST, updateReqBody);

Map<String, Object> updateResponse = outboundRequestHandlerService.fetchResultUsingPatch(
serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePath(), updateRequest, MapUtils.EMPTY_MAP);
serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePrivatePath(), updateRequest, MapUtils.EMPTY_MAP);
if (!updateResponse.get(Constants.RESPONSE_CODE).equals(Constants.OK)) {
Map<String, Object> params = (Map<String, Object>) updateResponse.get(Constants.PARAMS);
errMsg = String.format("Failed to update user profile. Error: %s", params.get("errmsg"));
Expand Down Expand Up @@ -1241,7 +1237,7 @@ private boolean updateUser(Map<String, Object> requestObject) {
updateRequestBody.put(Constants.PROFILE_DETAILS, profileDetails);
updateRequest.put(Constants.REQUEST, updateRequestBody);
Map<String, Object> updateReadData = (Map<String, Object>) outboundRequestHandlerService.fetchResultUsingPatch(
serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePath(), updateRequest,
serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePrivatePath(), updateRequest,
ProjectUtil.getDefaultHeaders());
if (Constants.OK.equalsIgnoreCase((String) updateReadData.get(Constants.RESPONSE_CODE))) {
Map<String, Object> roleMap = new HashMap<>();
Expand Down Expand Up @@ -1679,7 +1675,6 @@ public SBApiResponse profileMDOAdminUpdate(Map<String, Object> request, String u
Map<String, Object> responseMap = userUtilityService.getUsersReadData(userId, StringUtils.EMPTY,
StringUtils.EMPTY);
Map<String, Object> existingProfileDetails = (Map<String, Object>) responseMap.get(Constants.PROFILE_DETAILS);
StringBuilder url = new StringBuilder();
if (!profileDetailsMap.isEmpty()) {
{
List<String> listOfChangedDetails = new ArrayList<>();
Expand Down Expand Up @@ -1714,8 +1709,7 @@ public SBApiResponse profileMDOAdminUpdate(Map<String, Object> request, String u
HashMap<String, String> headerValue = new HashMap<>();
headerValues.put(Constants.AUTH_TOKEN, authToken);
headerValues.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON);
String updatedUrl = serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePath();
url.append(serverConfig.getSbUrl()).append(serverConfig.getLmsUserUpdatePath());
String updatedUrl = serverConfig.getSbUrl() + serverConfig.getLmsUserUpdatePrivatePath();
Map<String, Object> updateRequestValue = requestData;
updateRequestValue.put(Constants.PROFILE_DETAILS, existingProfileDetails);
Map<String, Object> updateRequest = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public boolean updateUser(UserRegistration userRegistration) {
requestBody.put(Constants.PROFILE_DETAILS, profileDetails);
request.put(Constants.REQUEST, requestBody);
Map<String, Object> readData = (Map<String, Object>) outboundRequestHandlerService.fetchResultUsingPatch(
props.getSbUrl() + props.getLmsUserUpdatePath(), request, ProjectUtil.getDefaultHeaders());
props.getSbUrl() + props.getLmsUserUpdatePrivatePath(), request, ProjectUtil.getDefaultHeaders());
if (Constants.OK.equalsIgnoreCase((String) readData.get(Constants.RESPONSE_CODE))) {
retValue = assignRole(userRegistration.getSbOrgId(), userRegistration.getUserId(),
userRegistration.toMininumString());
Expand Down Expand Up @@ -657,7 +657,7 @@ public String updateBulkUploadUser(UserRegistration userRegistration) {
requestBody.put(Constants.PROFILE_DETAILS, profileDetails);
request.put(Constants.REQUEST, requestBody);
Map<String, Object> readData = (Map<String, Object>) outboundRequestHandlerService.fetchResultUsingPatch(
props.getSbUrl() + props.getLmsUserUpdatePath(), request, ProjectUtil.getDefaultHeaders());
props.getSbUrl() + props.getLmsUserUpdatePrivatePath(), request, ProjectUtil.getDefaultHeaders());
if (readData != null && !Constants.OK.equalsIgnoreCase((String) readData.get(Constants.RESPONSE_CODE))) {
Map<String, Object> params = (Map<String, Object>) readData.get(Constants.PARAMS);
if (!MapUtils.isEmpty(params)) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ spring.data.cassandra.sb.password=cassandra
sunbird.course.service.host=http://lms-service:9000/
lms.system.settings.path=v1/system/settings/get/PatchConfig
lms.user.read.path=/private/user/v1/read/
lms.user.update.path=/private/user/v1/update
lms.user.update.path=/user/v1/update
lms.user.update.private.path=/private/user/v1/update
progress.api.endpoint=v1/content/state/read
participants.api.endpoint=v1/batch/participants/list
sb.api.key=apiKey
Expand Down

0 comments on commit 45ceaaf

Please sign in to comment.