Skip to content

Commit

Permalink
Issue #LR-814 merge: merge release-7.0.0 to master (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitpriyadarshi authored Jul 1, 2024
1 parent 67d8534 commit f57bca0
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
import org.sunbird.actor.base.BaseActor;
import org.sunbird.common.exception.ProjectCommonException;
import org.sunbird.common.models.response.Response;
import org.sunbird.common.models.util.LoggerUtil;
import org.sunbird.common.models.util.JsonKey;
import org.sunbird.keys.*;
import org.sunbird.common.models.util.LoggerEnum;
import org.sunbird.common.models.util.ProjectLogger;
import org.sunbird.common.models.util.TelemetryEnvKey;
import org.sunbird.common.request.Request;
import org.sunbird.common.responsecode.ResponseCode;
Expand All @@ -26,7 +21,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static org.sunbird.common.models.util.JsonKey.EKSTEP_BASE_URL;
import static org.sunbird.common.models.util.JsonKey.CONTENT_SERVICE_BASE_URL;
import static org.sunbird.common.models.util.ProjectUtil.getConfigValue;

public class CourseManagementActor extends BaseActor {
Expand Down Expand Up @@ -57,9 +52,9 @@ private void createCourse(Request request) throws Exception {
if(!((Map<String, Object>) request.get(SunbirdKey.COURSE)).containsKey(SunbirdKey.COPY_SCHEME)) {
contentMap.put(SunbirdKey.COPY_SCHEME, SunbirdKey.TEXT_BOOK_TO_COURSE);
}
requestUrl = getConfigValue(EKSTEP_BASE_URL) + "/content/v3/copy/" + request.get(SunbirdKey.SOURCE) + "?type=deep";
requestUrl = getConfigValue(CONTENT_SERVICE_BASE_URL) + "/content/v3/copy/" + request.get(SunbirdKey.SOURCE) + "?type=deep";
} else {
requestUrl = getConfigValue(EKSTEP_BASE_URL) + "/content/v3/create";
requestUrl = getConfigValue(CONTENT_SERVICE_BASE_URL) + "/content/v3/create";
}
Map<String, String> headers = new HashMap<String, String>() {{
put(SunbirdKey.CONTENT_TYPE_HEADER, SunbirdKey.APPLICATION_JSON);
Expand Down Expand Up @@ -133,7 +128,7 @@ private void createCourse(Request request) throws Exception {

private void handleHierarchyData(Request request, String identifier, Map<String, String> headers) throws Exception {
if (request.getRequest().containsKey(SunbirdKey.HIERARCHY)) {
String url = getConfigValue(EKSTEP_BASE_URL) + "/content/v3/hierarchy/update";
String url = getConfigValue(CONTENT_SERVICE_BASE_URL) + "/content/v3/hierarchy/update";
HttpResponse<String> updateResponse =
Unirest.patch(url)
.headers(headers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static Map<String, Object> getContent(String courseId, List<String> field
Map<String, String> headers = new HashMap<>();
try {
String fieldsStr = StringUtils.join(fields, ",");
String baseContentreadUrl = ProjectUtil.getConfigValue(JsonKey.EKSTEP_BASE_URL) + PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_READ_URL) + courseId + "?fields=" + fieldsStr;
String baseContentreadUrl = ProjectUtil.getConfigValue(JsonKey.CONTENT_SERVICE_BASE_URL) + PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_READ_URL) + courseId + "?fields=" + fieldsStr;
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
headers.put(JsonKey.AUTHORIZATION, PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION));

Expand Down Expand Up @@ -183,7 +183,7 @@ public static Map<String, Object> getCourseObjectFromEkStep(
public static boolean updateCollection(RequestContext requestContext, String collectionId, Map<String, Object> data) {
String response = "";
try {
String contentUpdateBaseUrl = ProjectUtil.getConfigValue(JsonKey.LEARNING_SERVICE_BASE_URL);
String contentUpdateBaseUrl = ProjectUtil.getConfigValue(JsonKey.CONTENT_SERVICE_BASE_URL);
Request request = new Request();
request.put("content", data);
response =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.sunbird.helper.ServiceFactory;
import scala.concurrent.Future;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -166,7 +165,7 @@ public static int getUpdatedBatchCount(
public static boolean updateCourseContent(RequestContext requestContext, String courseId, String contentName, int val) {
String response = "";
try {
String contentUpdateBaseUrl = ProjectUtil.getConfigValue(JsonKey.LEARNING_SERVICE_BASE_URL);
String contentUpdateBaseUrl = ProjectUtil.getConfigValue(JsonKey.CONTENT_SERVICE_BASE_URL);
response =
HttpUtil.sendPatchRequest(
contentUpdateBaseUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private static Map<String, String> getdefaultHeaders() {
private static String readTemplate(RequestContext requestContext, String templateId) throws Exception {
String templateRelativeUrl = ProjectUtil.getConfigValue("sunbird_cert_template_url");
String certTemplateReadUrl = ProjectUtil.getConfigValue("sunbird_cert_template_read_url");
String contentServiceBaseUrl = ProjectUtil.getConfigValue("ekstep_api_base_url");
String contentServiceBaseUrl = ProjectUtil.getConfigValue(JsonKey.CONTENT_SERVICE_BASE_URL);
String certServiceBaseUrl = ProjectUtil.getConfigValue("sunbird_cert_service_base_url");
HttpResponse<String> httpResponse = null;
httpResponse = templateReadResponse(requestContext, contentServiceBaseUrl, templateRelativeUrl, templateId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void setUp() {
PowerMockito.mockStatic(ProjectUtil.class);
PowerMockito.mockStatic(Unirest.class);
system = ActorSystem.create("system");
when(ProjectUtil.getConfigValue(JsonKey.EKSTEP_BASE_URL))
.thenReturn("ekstep_api_base_url");
when(ProjectUtil.getConfigValue(JsonKey.CONTENT_SERVICE_BASE_URL))
.thenReturn("content_service_base_url");
when(ProjectUtil.getConfigValue(JsonKey.CONTENT_PROPS_TO_ADD))
.thenReturn("learning.content.props.to.add");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public final class JsonKey {
public static final String SEARCH_SERVICE_API_BASE_URL = "sunbird_search_service_api_base_url";
public static final String ANALYTICS_API_BASE_URL = "sunbird_analytics_api_base_url";
public static final String EKSTEP_AUTHORIZATION = "ekstep_authorization";
public static final String EKSTEP_BASE_URL = "ekstep_api_base_url";
public static final String CONTENT_SERVICE_BASE_URL = "content_service_base_url";
public static final String EKSTEP_CONTENT_SEARCH_URL = "ekstep_content_search_url";
public static final String EKSTEP_CONTENT_UPDATE_URL = "ekstep.content.update.url";
public static final String EKSTEP_SERVICE = "Content service";
Expand Down Expand Up @@ -521,7 +521,6 @@ public final class JsonKey {
public static final String SUNBIRD_PASS_REGEX = "sunbird_pass_regex";
public static final String NESTED_EXISTS = "nested_exists";
public static final String NESTED_NOT_EXISTS = "nested_not_exists";
public static final String LEARNING_SERVICE_BASE_URL = "learning_service_base_url";
public static final String CREATOR_DETAILS_FIELDS = "sunbird_user_search_cretordetails_fields";
public static final String SUNBIRD_QRCODE_COURSES_LIMIT ="sunbird_user_qrcode_courses_limit";
public static final String ACCESS_TOKEN_PUBLICKEY_BASEPATH = "accesstoken.publickey.basepath";
Expand Down Expand Up @@ -585,7 +584,7 @@ public final class JsonKey {
public static final String CONTENT_LENGTH = "Content-Length";

//#Release-5.4.0 - LR-511
public static final String SUNBIRD_KEYSPACE = "sunbird_keyspace";
public static final String SUNBIRD_KEYSPACE = "sunbird_userorg_keyspace";
public static final String SUNBIRD_COURSE_KEYSPACE ="sunbird_course_keyspace";
public static final String DIALCODE_KEYSPACE = "dialcode_keyspace";
public static final String REDIS_HOST_VALUE = "sunbird_redis_host";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ekstep_content_search_url=/v3/search
ekstep_authorization=
ekstep.tag.api.url=/tag/register
ekstep.content.update.url=/system/v3/content/update/
ekstep.content.update.url=/content/v4/system/update/
sunbird_installation=sunbird
sunbird_analytics_api_base_url=https://dev.ekstep.in/api/data/v3
sunbird_search_service_api_base_url=https://dev.sunbirded.org/action
ekstep_api_base_url=https://dev.sunbirded.org/action
content_service_base_url=https://dev.sunbirded.org/action
sunbird_user_org_api_base_url=https://dev.sunbirded.org/api
sunbird_search_organisation_api=/v1/org/search
sunbird_read_user_api=/private/user/v1/read
Expand Down Expand Up @@ -116,7 +116,7 @@ exhaust_api_submit_endpoint=/api/dataset/v1/request/submit
exhaust_api_list_endpoint=/api/dataset/v1/request/list

#Release-5.4.0 - LR-511
sunbird_keyspace=sunbird
sunbird_userorg_keyspace=sunbird
sunbird_course_keyspace=sunbird_courses
dialcode_keyspace=dialcodes
redis.dbIndex=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.sunbird.common.models.util.BaseHttpTest;
import org.sunbird.common.models.util.HttpUtil;
Expand All @@ -32,19 +31,19 @@ public void setup() {

@Test
public void testSendPostRequestSuccess() throws Exception {
String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
String ekStepBaseUrl = System.getenv(JsonKey.CONTENT_SERVICE_BASE_URL);
if (StringUtils.isBlank(ekStepBaseUrl)) {
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_SERVICE_BASE_URL);
}
String response = HttpUtil.sendPostRequest(ekStepBaseUrl + "/content/v3/list", data, headers);
Assert.assertNotNull(response);
}

@Test()
public void testSendPostRequestFailureWithWrongUrl() {
String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
String ekStepBaseUrl = System.getenv(JsonKey.CONTENT_SERVICE_BASE_URL);
if (StringUtils.isBlank(ekStepBaseUrl)) {
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_SERVICE_BASE_URL);
}
String response = null;
try {
Expand All @@ -61,9 +60,9 @@ public void testSendPostRequestFailureWithWrongUrl() {
public void testSendPatchRequestSuccess() {
String response = null;
try {
String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
String ekStepBaseUrl = System.getenv(JsonKey.CONTENT_SERVICE_BASE_URL);
if (StringUtils.isBlank(ekStepBaseUrl)) {
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_SERVICE_BASE_URL);
}
response =
HttpUtil.sendPatchRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ public void testIsEmailValidSuccess() {

@Test
public void testSendGetRequestSuccessWithEkStepBaseUrl() throws Exception {
String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
String ekStepBaseUrl = System.getenv(JsonKey.CONTENT_SERVICE_BASE_URL);
if (StringUtils.isBlank(ekStepBaseUrl)) {
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.CONTENT_SERVICE_BASE_URL);
}
String response = HttpUtil.sendGetRequest(ekStepBaseUrl + "/search/health", headers);
assertNotNull(response);
Expand Down
3 changes: 1 addition & 2 deletions scripts/lms-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ export actor_hostname=actor-service
export api_actor_provider=local
export export background_actor_provider=local
export bind_hostname=0.0.0.0
export export ekstep_api_base_url="https://dev.lern.sunbird.org"
export content_service_base_url="https://dev.lern.sunbird.org"
export content_read_url="/api/content/v1/read/"
export learning_content_props_to_add=mimeType,contentType,name,code,description,keywords,framework,copyright,topic
export learning_service_base_url="https://dev.lern.sunbird.org"
export redis_connection_idle_max=32
export redis_connection_idle_min=1
export redis_connection_max=64
Expand Down
2 changes: 1 addition & 1 deletion setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
15. sunbird_pg_user: postgres db user name
16. sunbird_pg_password: postgress db password
17. sunbird_installation
18. ekstep_api_base_url
18. content_service_base_url
19. sunbird_mail_server_host
20. sunbird_mail_server_port
21. sunbird_mail_server_username
Expand Down

0 comments on commit f57bca0

Please sign in to comment.