Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Org Migration & User Profile Approval and Update Changes #6

Open
wants to merge 7 commits into
base: workflow-dev-sb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public class Configuration {
@Value("${hub.profile.update}")
private String hubProfileUpdateEndPoint;

@Value("${lms.user.read}")
private String userProfileReadEndPoint;

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

@Value("${lms.user.migrate}")
private String userProfileMigrateEndPoint;

@Value("${lms.service.host}")
private String lmsServiceHost;

Expand Down Expand Up @@ -82,6 +91,30 @@ public void setDefaultOffset(Integer defaultOffset) {
this.defaultOffset = defaultOffset;
}

public String getUserProfileReadEndPoint() {
return userProfileReadEndPoint;
}

public void setUserProfileReadEndPoint(String userProfileReadEndPoint) {
this.userProfileReadEndPoint = userProfileReadEndPoint;
}

public String getUserProfileUpdateEndPoint() {
return userProfileUpdateEndPoint;
}

public void setUserProfileUpdateEndPoint(String userProfileUpdateEndPoint) {
this.userProfileUpdateEndPoint = userProfileUpdateEndPoint;
}

public String getUserProfileMigrateEndPoint() {
return userProfileMigrateEndPoint;
}

public void setUserProfileMigrateEndPoint(String userProfileMigrateEndPoint) {
this.userProfileMigrateEndPoint = userProfileMigrateEndPoint;
}

public Integer getMaxLimit() {
return maxLimit;
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,32 @@ private Constants() {
public static final String RESPONSE = "response";
public static final String CONTENT = "content";
public static final String PROFILE_DETAILS = "profileDetails";
public static final String REQUEST = "request";
public static final String PERSONAL_DETAILS = "personalDetails";
public static final String USER_REGISTRATION_SERVICE_NAME = "user_registration";
public static final String WF_APPROVED_STATE = "WF_APPROVED";
public static final String OSID = "osid";
public static final String FIELD_KEY = "fieldKey";
public static final String TO_VALUE = "TO_VALUE";
public static final String PROFESSIONAL_DETAILS = "professionalDetails";
public static final String CHANNEL = "channel";
public static final String FORCE_MIGRATION = "forceMigration";
public static final String SOFT_DELETE_OLD_GROUP = "softDeleteOldOrg";
public static final String NOTIFY_MIGRATION = "notifyMigration";
public static final String X_AUTH_USER_ID = "x-authenticated-userid";
public static final String ORG_NAME = "orgName";
public static final String OK = "OK";
public static final String FAILED = "FAILED";
public static final String PARAMS = "params";
public static final String ERROR_MESSAGE = "errmsg";
public static final String CONTENT_TYPE = "Content-Type";
public static final String APPLICATION_JSON = "application/json";
public static final String REJECTED = "REJECTED";








Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.sunbird.workflow.config.Constants;
import org.sunbird.workflow.models.Response;
import org.sunbird.workflow.models.SearchCriteria;
import org.sunbird.workflow.models.WfRequest;
Expand All @@ -19,8 +20,8 @@ public class WorkFlowController {

@PostMapping("/transition")
public ResponseEntity<Response> wfTransition(@RequestHeader String rootOrg, @RequestHeader String org,
@RequestBody WfRequest wfRequest) {
Response response = workflowService.workflowTransition(rootOrg, org, wfRequest);
@RequestBody WfRequest wfRequest, @RequestHeader(Constants.X_AUTH_USER_ID) String userId) {
Response response = workflowService.workflowTransition(rootOrg, org, wfRequest, userId);
return new ResponseEntity<>(response, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface Workflowservice {

public Response workflowTransition(String rootOrg, String org, WfRequest wfRequest);
public Response workflowTransition(String rootOrg, String org, WfRequest wfRequest, String userId);

public Response getWfApplication(String rootOrg, String org, String wfId, String applicationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.sunbird.workflow.config.Configuration;
import org.sunbird.workflow.config.Constants;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -84,7 +82,7 @@ public Object fetchResultUsingPost(StringBuilder uri, Object request, Class obje
String message = str.toString();
log.info(message);
HttpHeaders headers = new HttpHeaders();
if (!CollectionUtils.isEmpty(headersValue)) {
if (!ObjectUtils.isEmpty(headersValue)) {
for (Map.Entry<String, String> map : headersValue.entrySet()) {
headers.set(map.getKey(), map.getValue());
}
Expand All @@ -100,4 +98,31 @@ public Object fetchResultUsingPost(StringBuilder uri, Object request, Class obje
return response;
}

public Object fetchResultUsingPatch(StringBuilder uri, Object request, Class objectType,HashMap<String, String> headersValue) {
sreeragksgh marked this conversation as resolved.
Show resolved Hide resolved
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
Object response = null;
StringBuilder str = new StringBuilder(this.getClass().getCanonicalName()).append(".fetchResult:")
.append(System.lineSeparator());
str.append("URI: ").append(uri.toString()).append(System.lineSeparator());
try {
str.append("Request: ").append(mapper.writeValueAsString(request)).append(System.lineSeparator());
log.debug(str.toString());
HttpHeaders headers = new HttpHeaders();
if (!ObjectUtils.isEmpty(headersValue)) {
for (Map.Entry<String, String> map : headersValue.entrySet()) {
headers.set(map.getKey(), map.getValue());
}
}
HttpEntity<Object> entity = new HttpEntity<>(request, headers);
response = restTemplate.patchForObject(uri.toString(), entity, objectType);
} catch (HttpClientErrorException e) {
log.error("External Service threw an Exception: ", e);
} catch (Exception e) {
log.error("Exception occured while calling the external service: ", e);
}
return response;
}


}
Loading