From d96e779d360a1d290158d7e75e995fdef2242c94 Mon Sep 17 00:00:00 2001 From: Anil Gupta Date: Fri, 27 Oct 2023 10:57:05 +0530 Subject: [PATCH] Issue #LR-583 merge: release-5.4.0 to master (#1228) --- .circleci/config.yml | 2 +- .gitignore | 2 +- Dockerfile.Build | 2 +- Jenkinsfile | 4 +- README.md | 2 +- auto_build_deploy | 2 +- controller/pom.xml | 6 +- .../OrganisationControllerTest.java | 121 +++++------------- core/actor-core/pom.xml | 4 +- core/cassandra-utils/pom.xml | 2 +- core/es-utils/pom.xml | 2 +- .../dependency-reduced-pom.xml | 2 +- core/notification-utils/pom.xml | 4 +- .../notification/utils/SmsTemplateUtil.java | 3 +- core/platform-common/pom.xml | 22 ++-- .../main/java/org/sunbird/keys/JsonKey.java | 11 +- .../sunbird/operations/ActorOperations.java | 1 + .../sunbird/sso/impl/KeyCloakServiceImpl.java | 17 ++- .../org/sunbird/util/CloudStorageUtil.java | 12 +- .../java/org/sunbird/util/ProjectUtil.java | 48 ++----- .../resources/externalresource.properties | 11 +- .../org/sunbird/util/ProjectUtilTest.java | 2 - helm/learner/templates/configmap.yaml | 13 -- helm/learner/values.yaml | 5 - pom.xml | 8 +- .../OrganisationManagementActor.java | 26 ++-- .../user/UserExternalIdManagementActor.java | 6 +- .../impl/BulkUploadProcessDaoImpl.java | 3 +- .../impl/BulkUploadProcessTaskDaoImpl.java | 5 +- .../dao/location/impl/LocationDaoImpl.java | 6 +- .../sunbird/dao/notes/impl/NotesDaoImpl.java | 2 +- .../impl/EmailTemplateDaoImpl.java | 3 +- .../dao/organisation/impl/OrgDaoImpl.java | 4 +- .../organisation/impl/OrgExternalDaoImpl.java | 3 +- .../org/sunbird/dao/otp/impl/OTPDaoImpl.java | 9 +- .../dao/ratelimit/RateLimitDaoImpl.java | 5 +- .../sunbird/dao/role/impl/RoleDaoImpl.java | 3 +- .../dao/role/impl/RoleGroupDaoImpl.java | 3 +- .../impl/SystemSettingDaoImpl.java | 3 +- .../impl/TenantPreferenceDaoImpl.java | 7 +- .../dao/urlaction/impl/UrlActionDaoImpl.java | 3 +- .../sunbird/dao/user/impl/UserDaoImpl.java | 2 +- .../impl/UserExternalIdentityDaoImpl.java | 5 +- .../sunbird/dao/user/impl/UserOrgDaoImpl.java | 13 +- .../dao/user/impl/UserRoleDaoImpl.java | 8 +- .../user/impl/UserSelfDeclarationDaoImpl.java | 13 +- .../userconsent/impl/UserConsentDaoImpl.java | 5 +- .../user/ShadowUserMigrationService.java | 9 +- .../org/sunbird/util/DataCacheHandler.java | 15 +-- .../src/main/java/org/sunbird/util/Util.java | 2 +- .../notification/EmailServiceActorTest.java | 1 + .../SendNotificationActorTest.java | 1 + .../organisation/OrgManagementActorTest.java | 31 ++--- .../SystemSettingsActorTest.java | 3 +- .../actor/user/CheckUserExistActorTest.java | 7 +- .../actor/user/ResetPasswordActorTest.java | 6 +- .../actor/user/TenantMigrationActorTest.java | 22 ++-- .../actor/user/UserProfileReadActorTest.java | 6 +- .../EmailTemplateDaoImplTest.java | 6 +- .../org/sunbird/dao/role/RoleDaoImplTest.java | 4 +- .../dao/role/RoleGroupDaoImplTest.java | 4 +- .../user/UserProfileReadServiceTest.java | 12 +- .../util/user/GetUserOrgDetailsTest.java | 4 +- .../util/user/SetUserDefaultValueTest.java | 6 +- .../user/ShadowUserMigrationServiceTest.java | 16 ++- .../org/sunbird/util/user/UserUtilTest.java | 8 +- .../resources/externalresource.properties | 112 ++++++++++++++++ setup.md | 2 +- 68 files changed, 410 insertions(+), 312 deletions(-) create mode 100644 service/src/test/resources/externalresource.properties diff --git a/.circleci/config.yml b/.circleci/config.yml index db987e5c40..62ff1e9373 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: - checkout - restore_cache: key: userorg-dependency-cache-{{ checksum "pom.xml" }} - - run: mvn clean install + - run: mvn clean install -DCLOUD_STORE_GROUP_ID=$CLOUD_STORE_GROUP_ID -DCLOUD_STORE_ARTIFACT_ID=$CLOUD_STORE_ARTIFACT_ID -DCLOUD_STORE_VERSION=$CLOUD_STORE_VERSION - run: cd controller && mvn play2:dist - save_cache: key: userorg-dependency-cache-{{ checksum "pom.xml" }} diff --git a/.gitignore b/.gitignore index 7e99a28fe9..a66e8a21f2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ RUNNING_PID /.target/ /bin/ /logs -.vscode +.vscode/** diff --git a/Dockerfile.Build b/Dockerfile.Build index febcdfbece..1bb3764d49 100644 --- a/Dockerfile.Build +++ b/Dockerfile.Build @@ -10,6 +10,6 @@ ENV M2_HOME /opt/apache-maven-3.3.9 ENV PATH ${M2_HOME}/bin:${PATH} COPY userorg /opt/userorg/ WORKDIR /opt/userorg/services -RUN mvn clean install -DskipTests +RUN mvn clean install -DskipTests -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 WORKDIR /opt/userorg/services/userorg-service CMD ["mvn", "play2:dist"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 698c9a1386..08f7c76929 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,11 +26,11 @@ node('build-slave') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" sh 'git log -1' - sh 'mvn clean install -U -DskipTests=true ' + sh "mvn clean install -DskipTests=true -DCLOUD_STORE_GROUP_ID=${params.cloud_store_group_id} -DCLOUD_STORE_ARTIFACT_ID=${params.cloud_store_artifact_id} -DCLOUD_STORE_VERSION=${params.cloud_store_version}" } stage('Unit Tests') { - sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false" + sh "mvn clean install '-Dtest=!%regex[io.opensaber.registry.client.*]' -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" } stage('Package') { dir('controller') { diff --git a/README.md b/README.md index 1cd5306adc..3adf2aab7b 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ git clone https://github.com/Sunbird-Lern/sunbird-lms-service.git 3. Build the application using the following maven command in the path `/sunbird-lms-service`: ```shell -mvn clean install -DskipTests +mvn clean install -DskipTests -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6 ``` Make sure the build is successful before proceeding to the next step. If the build is not successful, fix any configuration issues and rebuild the application. diff --git a/auto_build_deploy b/auto_build_deploy index 639e29b7f8..579067d9b6 100644 --- a/auto_build_deploy +++ b/auto_build_deploy @@ -28,7 +28,7 @@ node('build-slave') { // stage Build env.NODE_ENV = "build" - sh 'mvn clean install -U -DskipTests=false ' + sh "mvn clean install -U -DskipTests=false -DCLOUD_STORE_GROUP_ID=${params.cloud_store_group_id} -DCLOUD_STORE_ARTIFACT_ID=${params.cloud_store_artifact_id} -DCLOUD_STORE_VERSION=${params.cloud_store_version}" // stage Package dir('controller') { diff --git a/controller/pom.xml b/controller/pom.xml index ba0d5c375b..15542e2cad 100644 --- a/controller/pom.xml +++ b/controller/pom.xml @@ -47,7 +47,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 @@ -96,7 +96,7 @@ com.typesafe.play play-netty-server_2.11 - 2.7.2 + ${play2.version} runtime @@ -212,7 +212,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java index 157a89a225..18525c98c2 100644 --- a/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java +++ b/controller/test/controllers/organisationmanagement/OrganisationControllerTest.java @@ -1,26 +1,12 @@ package controllers.organisationmanagement; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.when; - import akka.stream.javadsl.FileIO; import akka.stream.javadsl.Source; import akka.util.ByteString; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import controllers.BaseApplicationTest; import controllers.DummyActor; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import modules.OnRequestHandler; -import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -29,15 +15,24 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.sunbird.exception.ResponseCode; import org.sunbird.keys.JsonKey; -import org.sunbird.response.Response; -import org.sunbird.response.ResponseParams; -import play.libs.Json; import play.mvc.Http; import play.mvc.Result; import play.test.Helpers; import util.ACTORS; import util.RequestInterceptor; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.powermock.api.mockito.PowerMockito.when; + @PrepareForTest(OnRequestHandler.class) @PowerMockIgnore({"javax.management.*", "jdk.internal.reflect.*", "javax.crypto.*"}) // @Ignore @@ -63,7 +58,7 @@ public void testCreateOrgSuccess() { "POST", createOrUpdateOrganisationRequest(orgName, null, false, null, null)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -73,7 +68,7 @@ public void testCreateSubOrgWithLicenseSuccess() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, "Test MIT license"); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -83,7 +78,7 @@ public void testCreateRootOrgWithLicenseSuccess() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, "Test MIT license"); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -93,7 +88,7 @@ public void testCreateRootOrgWithLicenseEmptyFailure() { ((Map) reqMap.get(JsonKey.REQUEST)).put(JsonKey.LICENSE, ""); Result result = performTest("/v1/org/create", "POST", reqMap); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -104,7 +99,7 @@ public void testCreateOrgFailureWithoutOrgName() { "POST", createOrUpdateOrganisationRequest(null, null, false, null, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -115,7 +110,7 @@ public void testCreateOrgFailureWithRootOrgWithoutChannel() { "POST", createOrUpdateOrganisationRequest(orgName, null, true, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -126,7 +121,7 @@ public void testUpdateOrgSuccess() { "PATCH", createOrUpdateOrganisationRequest(null, orgId, false, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -137,7 +132,7 @@ public void testUpdateOrgFailureWithoutOrgId() { "PATCH", createOrUpdateOrganisationRequest(null, null, false, rootOrgId, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -148,7 +143,7 @@ public void testUpdateOrgStatusSuccess() { "PATCH", createOrUpdateOrganisationRequest(null, orgId, false, null, status)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -159,21 +154,21 @@ public void testUpdateOrgStatusFailureWithoutOrgId() { "PATCH", createOrUpdateOrganisationRequest(null, null, false, null, status)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test public void testGetOrgDetailsSuccess() { Result result = performTest("/v1/org/read", "POST", getOrganisationRequest(orgId, status)); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test public void testGetOrgDetailsFailureWithoutOrgId() { Result result = performTest("/v1/org/read", "POST", getOrganisationRequest(null, status)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test @@ -181,7 +176,7 @@ public void testSearchOrgSuccess() { Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, new HashMap<>())); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test @@ -189,21 +184,22 @@ public void testSearchOrgV2Success() { Result result = performTest("/v2/org/search", "POST", searchOrganisationRequest(status, new HashMap<>())); assertEquals(getResponseCode(result), ResponseCode.SUCCESS.name()); - assertTrue(getResponseStatus(result) == 200); + assertEquals(200, getResponseStatus(result)); } @Test public void testSearchOrgFailureWithoutFilters() { Result result = performTest("/v1/org/search", "POST", searchOrganisationRequest(status, null)); assertEquals(getResponseCode(result), ResponseCode.CLIENT_ERROR.name()); - assertTrue(getResponseStatus(result) == 400); + assertEquals(400, getResponseStatus(result)); } @Test public void testAddEncyptionKeyPublicPem() throws IOException { + String controllerPath = (Paths.get("").toAbsolutePath().toString().endsWith("controller"))?Paths.get("").toAbsolutePath().toString():Paths.get("").toAbsolutePath().toString()+File.separator +"controller"; File file = new File( - Paths.get("").toAbsolutePath() + File.separator + "test/resources/samplepublic.pem"); + controllerPath + File.separator + "test/resources/samplepublic.pem"); Http.MultipartFormData.Part> part = new Http.MultipartFormData.FilePart<>( "fileName", @@ -227,8 +223,9 @@ public void testAddEncyptionKeyPublicPem() throws IOException { @Test public void testAddEncyptionKeyPDF() throws IOException { + String controllerPath = (Paths.get("").toAbsolutePath().toString().endsWith("controller"))?Paths.get("").toAbsolutePath().toString():Paths.get("").toAbsolutePath().toString()+File.separator +"controller"; File file = - new File(Paths.get("").toAbsolutePath() + File.separator + "test/resources/sample.pdf"); + new File(controllerPath + File.separator + "test/resources/sample.pdf"); Http.MultipartFormData.Part> part = new Http.MultipartFormData.FilePart<>( "fileName", @@ -280,7 +277,7 @@ private Map createOrUpdateOrganisationRequest( innerMap.put(JsonKey.IS_TENANT, isRootOrg); innerMap.put(JsonKey.ORG_TYPE, "board"); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); @@ -292,7 +289,7 @@ private Map getOrganisationRequest(String orgId, String status) { Map innerMap = new HashMap<>(); innerMap.put(JsonKey.ORGANISATION_ID, orgId); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); @@ -304,60 +301,10 @@ private Map searchOrganisationRequest(String status, HashMap fil Map innerMap = new HashMap<>(); innerMap.put(JsonKey.FILTERS, filterMap); - if (status != null) innerMap.put(JsonKey.STATUS, new Integer(status)); + if (status != null) innerMap.put(JsonKey.STATUS, Integer.valueOf(status)); requestMap.put(JsonKey.REQUEST, innerMap); return requestMap; } - - public Result performTest(String url, String method, Map map) { - String data = mapToJson(map); - Http.RequestBuilder req; - if (StringUtils.isNotBlank(data)) { - JsonNode json = Json.parse(data); - req = new Http.RequestBuilder().bodyJson(json).uri(url).method(method); - } else { - req = new Http.RequestBuilder().uri(url).method(method); - } - // req.headers(new Http.Headers(headerMap)); - Result result = Helpers.route(application, req); - return result; - } - - public String mapToJson(Map map) { - ObjectMapper mapperObj = new ObjectMapper(); - String jsonResp = ""; - - if (map != null) { - try { - jsonResp = mapperObj.writeValueAsString(map); - } catch (IOException e) { - e.printStackTrace(); - } - } - return jsonResp; - } - - public String getResponseCode(Result result) { - String responseStr = Helpers.contentAsString(result); - ObjectMapper mapper = new ObjectMapper(); - - try { - Response response = mapper.readValue(responseStr, Response.class); - ResponseParams params = response.getParams(); - if (result.status() != 200) { - return response.getResponseCode().name(); - } else { - return params.getStatus(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return ""; - } - - public int getResponseStatus(Result result) { - return result.status(); - } } diff --git a/core/actor-core/pom.xml b/core/actor-core/pom.xml index 45557b15eb..c0aa98090a 100644 --- a/core/actor-core/pom.xml +++ b/core/actor-core/pom.xml @@ -54,12 +54,12 @@ com.fasterxml.jackson.core jackson-core - 2.10.1 + 2.10.5 com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 diff --git a/core/cassandra-utils/pom.xml b/core/cassandra-utils/pom.xml index 7c6ba6fd93..32564d93cb 100644 --- a/core/cassandra-utils/pom.xml +++ b/core/cassandra-utils/pom.xml @@ -54,7 +54,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 org.sunbird diff --git a/core/es-utils/pom.xml b/core/es-utils/pom.xml index f975e40a9d..d501570052 100644 --- a/core/es-utils/pom.xml +++ b/core/es-utils/pom.xml @@ -34,7 +34,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/notification-utils/dependency-reduced-pom.xml b/core/notification-utils/dependency-reduced-pom.xml index ec20fac3d2..be370caaaa 100644 --- a/core/notification-utils/dependency-reduced-pom.xml +++ b/core/notification-utils/dependency-reduced-pom.xml @@ -40,7 +40,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/core/notification-utils/pom.xml b/core/notification-utils/pom.xml index f1e7c9f9cc..daeacaac14 100644 --- a/core/notification-utils/pom.xml +++ b/core/notification-utils/pom.xml @@ -29,7 +29,7 @@ junit junit - 4.12 + 4.13.1 test @@ -53,7 +53,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.5 + 2.10.5.1 org.sunbird diff --git a/core/notification-utils/src/main/java/org/sunbird/notification/utils/SmsTemplateUtil.java b/core/notification-utils/src/main/java/org/sunbird/notification/utils/SmsTemplateUtil.java index 2042e64f02..39b1680fac 100644 --- a/core/notification-utils/src/main/java/org/sunbird/notification/utils/SmsTemplateUtil.java +++ b/core/notification-utils/src/main/java/org/sunbird/notification/utils/SmsTemplateUtil.java @@ -10,6 +10,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.logging.LoggerUtil; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class SmsTemplateUtil { private static final LoggerUtil logger = new LoggerUtil(SmsTemplateUtil.class); @@ -18,7 +19,7 @@ public class SmsTemplateUtil { public static Map> getSmsTemplateConfigMap() { Response response = cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.SYSTEM_SETTINGS_DB, JsonKey.SMS_TEMPLATE_CONFIG, null); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.SYSTEM_SETTINGS_DB, JsonKey.SMS_TEMPLATE_CONFIG, null); List> responseList = (List>) response.get(JsonKey.RESPONSE); if (null != responseList && !responseList.isEmpty()) { diff --git a/core/platform-common/pom.xml b/core/platform-common/pom.xml index 01d7b5acf3..d6cd701690 100644 --- a/core/platform-common/pom.xml +++ b/core/platform-common/pom.xml @@ -20,6 +20,10 @@ 11 UTF-8 2.5.19 + 2.7.2 + org.sunbird + cloud-store-sdk + 1.4.6 @@ -47,17 +51,17 @@ com.fasterxml.jackson.core jackson-core - 2.10.1 + 2.10.5 com.fasterxml.jackson.core jackson-databind - 2.10.1 + 2.10.5.1 com.fasterxml.jackson.core jackson-annotations - 2.10.1 + 2.10.5 com.typesafe.akka @@ -83,7 +87,7 @@ junit junit - 4.12 + 4.13.1 test @@ -112,9 +116,9 @@ 7.0.1 - org.sunbird - cloud-store-sdk - 1.4.4 + ${CLOUD_STORE_GROUP_ID} + ${CLOUD_STORE_ARTIFACT_ID} + ${CLOUD_STORE_VERSION} com.sun.jersey @@ -145,7 +149,7 @@ org.apache.kafka kafka-clients - 0.10.0.1 + 0.10.2.2 org.jboss.resteasy @@ -195,7 +199,7 @@ com.typesafe.play play_2.11 - 2.7.2 + ${play2.version} compile diff --git a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java index 5805d83e07..c4ab7bf5aa 100644 --- a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java +++ b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java @@ -16,6 +16,8 @@ public final class JsonKey { public static final String IS_FORM_VALIDATION_REQUIRED = "isFormValidationRequired"; public static final String USER_PROFILE_CONFIG_MAP = "userProfileConfigMap"; public static final String ACCOUNT_NAME = "sunbird_account_name"; + + public static final String ACCOUNT_ENDPOINT = "sunbird_account_endpoint"; public static final String DOWNLOAD_LINK_EXPIRY_TIMEOUT = "download_link_expiry_timeout"; public static final String ACTION_GROUP = "action_group"; public static final String ACTION_GROUPS = "actionGroups"; @@ -412,8 +414,6 @@ public final class JsonKey { public static final String SUNBIRD_GZIP_ENABLE = "sunbird_gzip_enable"; public static final String SUNBIRD_SYNC_READ_WAIT_TIME = "sunbird_sync_read_wait_time"; public static final String SUNBIRD_GZIP_SIZE_THRESHOLD = "sunbird_gzip_size_threshold"; - public static final String ANALYTICS_ACCOUNT_NAME = "sunbird_analytics_blob_account_name"; - public static final String ANALYTICS_ACCOUNT_KEY = "sunbird_analytics_blob_account_key"; public static final String SIGNUP_TYPE = "signupType"; public static final String REQUEST_SOURCE = "source"; @@ -644,6 +644,13 @@ public final class JsonKey { public static final String DATA_SECURITY_POLICY = "dataSecurityPolicy"; public static final String JOB = "job"; public static final String USER_PRIVATE_FIELDS = "userPrivateFields"; + //Release 5.4.0 LR-102 + public static final String SUNBIRD_KEYSPACE = "sunbird_keyspace"; + public static final String ES_LOCATION_INDEX = "es_location_index"; + public static final String ES_USER_FEED_INDEX = "es_user_feed_index"; + public static final String ES_USER_NOTES_INDEX = "es_user_notes_index"; + public static final String ES_USER_INDEX_ALIAS = "user_index_alias"; + public static final String ES_ORG_INDEX_INDEX = "org_index_alias"; private JsonKey() {} } diff --git a/core/platform-common/src/main/java/org/sunbird/operations/ActorOperations.java b/core/platform-common/src/main/java/org/sunbird/operations/ActorOperations.java index ae578fb9af..728d71d3fb 100644 --- a/core/platform-common/src/main/java/org/sunbird/operations/ActorOperations.java +++ b/core/platform-common/src/main/java/org/sunbird/operations/ActorOperations.java @@ -12,6 +12,7 @@ * @author Manzarul */ public enum ActorOperations { + CREATE_USER("createUser", "USRCRT"), CREATE_SSO_USER("createSSOUser", "USRCRT"), diff --git a/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java b/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java index 9230501628..778adcfc36 100644 --- a/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java +++ b/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java @@ -145,15 +145,30 @@ public String activateUser(Map request, RequestContext context) private void makeUserActiveOrInactive(String userId, boolean status, RequestContext context) { try { String fedUserId = getFederatedUserId(userId); - logger.info(context, "makeUserActiveOrInactive: fedration id formed: " + fedUserId); + logger.info(context, "makeUserActiveOrInactive: federation id formed: " + fedUserId); validateUserId(fedUserId); + logger.info(context, "makeUserActiveOrInactive: user validated: "); Keycloak keycloak = KeyCloakConnectionProvider.getConnection(); + + logger.info( + context, + "makeUserActiveOrInactive: keycloak: " + + keycloak.toString() + + " || " + + keycloak.serverInfo()); UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); + logger.info("makeUserActiveOrInactive: resource: " + resource.toString()); UserRepresentation ur = resource.toRepresentation(); + logger.info("makeUserActiveOrInactive: ur: " + ur.isEnabled()); ur.setEnabled(status); resource.update(ur); } catch (Exception e) { + logger.info( + "makeUserActiveOrInactive:error occurred while blocking or unblocking user: " + + e.getCause() + + " || " + + e.getMessage()); logger.error( context, "makeUserActiveOrInactive:error occurred while blocking or unblocking user: ", diff --git a/core/platform-common/src/main/java/org/sunbird/util/CloudStorageUtil.java b/core/platform-common/src/main/java/org/sunbird/util/CloudStorageUtil.java index 5e67ffcf8d..b9e8b1ea4a 100644 --- a/core/platform-common/src/main/java/org/sunbird/util/CloudStorageUtil.java +++ b/core/platform-common/src/main/java/org/sunbird/util/CloudStorageUtil.java @@ -36,16 +36,22 @@ public static void deleteFile(String storageType, String container, String objec private static IStorageService getStorageService(String storageType) { String storageKey = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_NAME); String storageSecret = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_KEY); - return getStorageService(storageType, storageKey, storageSecret); + scala.Option storageEndpoint = scala.Option.apply(PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_ENDPOINT)); + scala.Option storageRegion = scala.Option.apply(""); + return getStorageService(storageType, storageKey, storageSecret,storageEndpoint,storageRegion); } - private static IStorageService getStorageService(String storageType, String storageKey, String storageSecret) { + + private static IStorageService getStorageService( + String storageType, String storageKey, String storageSecret,scala.Option storageEndpoint, scala.Option storageRegion ) { String compositeKey = storageType + "-" + storageKey; if (storageServiceMap.containsKey(compositeKey)) { return storageServiceMap.get(compositeKey); } synchronized (CloudStorageUtil.class) { - StorageConfig storageConfig = new StorageConfig(storageType, storageKey, storageSecret); + + StorageConfig storageConfig = + new StorageConfig(storageType, storageKey, storageSecret, storageEndpoint, storageRegion); IStorageService storageService = StorageServiceFactory.getStorageService(storageConfig); storageServiceMap.put(compositeKey, storageService); } diff --git a/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java b/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java index 47d4b15b2e..156d5fd4a4 100644 --- a/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java +++ b/core/platform-common/src/main/java/org/sunbird/util/ProjectUtil.java @@ -4,20 +4,6 @@ import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber; -import java.io.IOException; -import java.text.MessageFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.apache.velocity.VelocityContext; import org.sunbird.exception.ProjectCommonException; @@ -27,6 +13,15 @@ import org.sunbird.request.Request; import org.sunbird.request.RequestContext; +import java.io.IOException; +import java.text.MessageFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * This class will contains all the common utility methods. * @@ -261,11 +256,11 @@ public String getIndexName() { * @author Manzarul */ public enum EsType { - user(getConfigValue("user_index_alias")), - organisation(getConfigValue("org_index_alias")), - usernotes("usernotes"), - location("location"), - userfeed("userfeed"); + user(getConfigValue(JsonKey.ES_USER_INDEX_ALIAS)), + organisation(getConfigValue(JsonKey.ES_ORG_INDEX_INDEX)), + usernotes(getConfigValue(JsonKey.ES_USER_NOTES_INDEX)), + location(getConfigValue(JsonKey.ES_LOCATION_INDEX)), + userfeed(getConfigValue(JsonKey.ES_USER_FEED_INDEX)); private String typeName; @@ -288,21 +283,6 @@ public static SimpleDateFormat getDateFormatter() { return simpleDateFormat; } - /** @author Manzarul */ - public enum AzureContainer { - userProfileImg("userprofileimg"), - orgImage("orgimg"); - private String name; - - private AzureContainer(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - public static VelocityContext getContext(Map map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); diff --git a/core/platform-common/src/main/resources/externalresource.properties b/core/platform-common/src/main/resources/externalresource.properties index 0f4f0d02a9..27f55802bd 100644 --- a/core/platform-common/src/main/resources/externalresource.properties +++ b/core/platform-common/src/main/resources/externalresource.properties @@ -61,8 +61,6 @@ sunbird_rate_limit_enabled=true sunbird_health_check_enable=true sunbird_sync_read_wait_time=1500 sunbird_gzip_size_threshold=262144 -sunbird_analytics_blob_account_name= -sunbird_analytics_blob_account_key= kafka_urls=localhost:9092 sunbird_fuzzy_search_threshold=0.5 sunbird_state_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212938260643843.png @@ -89,9 +87,14 @@ enable_captcha=true consent_expiry_in_days=100 feed_limit=30 learner_in_memory_cache_ttl=14400 +#alias is actually referring the user and org index so no need to mention separately user_index_alias=user_alias -defaultMonthDate = -12-31 org_index_alias=org_alias +#Release 5.4.0 LR-102 +es_user_notes_index=usernotes +es_location_index=location +es_user_feed_index=userfeed +defaultMonthDate = -12-31 nic_sms_gateway_provider_base_url=https://smsgw.sms.gov.in/failsafe/HttpLink sms_gateway_provider=91SMS stacktrace_char_length=2500 @@ -105,4 +108,4 @@ channel_registration_disabled=false sunbird_password_reset_login_page_url=/resources isFormValidationRequired=true userProfileConfigMap={\"type\":\"profileconfig\",\"subtype\":\"28\",\"action\":\"get\",\"component\":\"*\",\"framework\":\"*\",\"data\":{\"templateName\":\"profileConfig_v2\",\"action\":\"get\",\"fields\":[{\"code\":\"persona\",\"children\":{\"administrator\":[{\"code\":\"district\"},{\"code\":\"state\"},{\"code\":\"subPersona\",\"type\":\"select\",\"default\":null,\"templateOptions\":{\"options\":[{\"label\":\"Headmaster\",\"value\":\"hm\"},{\"label\":\"Cluster Resource Person\",\"value\":\"crp\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"teacher\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"student\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"parent\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"other\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"subPersona\",\"templateOptions\":{\"options\":[{\"value\":\"Doctor (Allopathy)\",\"label\":\"Doctor (Allopathy)\"},{\"value\":\"AYUSH Professional\",\"label\":\"AYUSH Professional\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}]}}]},\"created_on\":\"2022-02-10T14:16:51.852Z\",\"last_modified_on\":\"2022-11-14T05:45:02.685Z\",\"rootOrgId\":\"*\"} -sunbird_cloud_service_provider=azure +sunbird_keyspace=sunbird diff --git a/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java b/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java index dc222e6a70..0787134263 100644 --- a/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java +++ b/core/platform-common/src/test/java/org/sunbird/util/ProjectUtilTest.java @@ -241,8 +241,6 @@ public void testStatusSuccess() { assertEquals(0, ProjectUtil.Status.INACTIVE.getValue()); assertFalse(ProjectUtil.ActiveStatus.INACTIVE.getValue()); assertTrue(ProjectUtil.ActiveStatus.ACTIVE.getValue()); - assertEquals("orgimg", ProjectUtil.AzureContainer.orgImage.getName()); - assertEquals("userprofileimg", ProjectUtil.AzureContainer.userProfileImg.getName()); assertEquals("username", ProjectUtil.UserLookupType.USERNAME.getType()); assertEquals("email", ProjectUtil.UserLookupType.EMAIL.getType()); diff --git a/helm/learner/templates/configmap.yaml b/helm/learner/templates/configmap.yaml index f5ab89b07d..f39a2e88c4 100644 --- a/helm/learner/templates/configmap.yaml +++ b/helm/learner/templates/configmap.yaml @@ -67,18 +67,6 @@ data: {{- printf "ERROR | %s | Please provide a value for \"cloud_public_storage_secret\"" .Chart.Name | fail }} {{- end }} - sunbird_analytics_blob_account_name: {{ if .Values.cloud_private_storage_accountname }} - {{- .Values.cloud_private_storage_accountname }} - {{- else -}} - {{- printf "ERROR | %s | Please provide a value for \"cloud_private_storage_accountname\"" .Chart.Name | fail }} - {{- end }} - - sunbird_analytics_blob_account_key: {{ if .Values.cloud_private_storage_secret }} - {{- .Values.cloud_private_storage_secret }} - {{- else -}} - {{- printf "ERROR | %s | Please provide a value for \"cloud_private_storage_secret\"" .Chart.Name | fail }} - {{- end }} - sunbird_cloud_service_provider: {{ if eq (include "common.csp.validation" .Values.cloud_service_provider) "true" }} {{- .Values.cloud_service_provider }} {{- else -}} @@ -220,7 +208,6 @@ data: sunbird_cassandra_port: {{ .Values.sunbird_cassandra_port | quote }} sunbird_cassandra_username: {{ .Values.sunbird_cassandra_username }} sunbird_cert_service_base_url: {{ .Values.sunbird_cert_service_base_url }} - sunbird_content_azure_storage_container: {{ .Values.sunbird_content_azure_storage_container }} sunbird_course_batch_notification_enabled: {{ .Values.sunbird_course_batch_notification_enabled | quote }} sunbird_course_batch_notification_signature: {{ .Values.sunbird_course_batch_notification_signature }} sunbird_cs_search_path: {{ .Values.sunbird_cs_search_path }} diff --git a/helm/learner/values.yaml b/helm/learner/values.yaml index 403a271a58..32d03df656 100644 --- a/helm/learner/values.yaml +++ b/helm/learner/values.yaml @@ -91,7 +91,6 @@ sunbird_cassandra_port: 9042 sunbird_cassandra_username: admin sunbird_cert_service_base_url: http://cert-service.lern.svc.cluster.local:9000 ## Storage bucket name where the contents are stores -sunbird_content_azure_storage_container: contents sunbird_course_batch_notification_enabled: true sunbird_course_batch_notification_signature: sunbird sunbird_cs_search_path: /v1/content/search @@ -314,10 +313,6 @@ initcontainer_resources: # sunbird_account_name: "" # sunbird_account_key: "" -## Refers to private storage bucket details -# sunbird_analytics_blob_account_name: "" -# sunbird_analytics_blob_account_key: "" - ## Uses the keycloak lms client from sunbird realm #sunbird_sso_client_id: lms #sunbird_sso_realm: sunbird \ No newline at end of file diff --git a/pom.xml b/pom.xml index c84980b4ae..2be0a632ab 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ junit junit - 4.12 + 4.13.1 test @@ -32,9 +32,9 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.0.0 - + 0 false @@ -55,7 +55,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 ${basedir}/target/jacoco-unit.exec ${basedir}/target/jacoco-unit.exec diff --git a/service/src/main/java/org/sunbird/actor/organisation/OrganisationManagementActor.java b/service/src/main/java/org/sunbird/actor/organisation/OrganisationManagementActor.java index 5c014e57a6..8cc6414e88 100644 --- a/service/src/main/java/org/sunbird/actor/organisation/OrganisationManagementActor.java +++ b/service/src/main/java/org/sunbird/actor/organisation/OrganisationManagementActor.java @@ -550,6 +550,19 @@ private String uploadEncryptionFile( sender().tell(exception, self()); } String container = ProjectUtil.getConfigValue(JsonKey.CLOUD_SERVICE_CONTAINER); + if (fetchedKeys != null + && fetchedKeys.containsKey(JsonKey.EXHAUST_ENCRYPTION_KEY) + && !fetchedKeys.get(JsonKey.EXHAUST_ENCRYPTION_KEY).isEmpty()) { + String oldKey = + fetchedKeys + .get(JsonKey.EXHAUST_ENCRYPTION_KEY) + .get(0) + .substring( + fetchedKeys.get(JsonKey.EXHAUST_ENCRYPTION_KEY).get(0).indexOf(container) + + container.length() + + 1); + CloudStorageUtil.deleteFile(cspProvider, container, oldKey); + } publicKeyUrl = CloudStorageUtil.upload( cspProvider, @@ -560,19 +573,6 @@ private String uploadEncryptionFile( + File.separator + fileName, file.getAbsolutePath()); - if (fetchedKeys != null - && fetchedKeys.containsKey(JsonKey.EXHAUST_ENCRYPTION_KEY) - && !fetchedKeys.get(JsonKey.EXHAUST_ENCRYPTION_KEY).isEmpty()) { - String oldKey = - fetchedKeys - .get(JsonKey.EXHAUST_ENCRYPTION_KEY) - .get(0) - .substring( - fetchedKeys.get(JsonKey.EXHAUST_ENCRYPTION_KEY).get(0).indexOf(container) - + container.length() - + 1); - CloudStorageUtil.deleteFile(cspProvider, container, oldKey); - } return publicKeyUrl; } catch (IOException e) { throw new ProjectCommonException( diff --git a/service/src/main/java/org/sunbird/actor/user/UserExternalIdManagementActor.java b/service/src/main/java/org/sunbird/actor/user/UserExternalIdManagementActor.java index 6e42bf9e6e..bf8eb71947 100644 --- a/service/src/main/java/org/sunbird/actor/user/UserExternalIdManagementActor.java +++ b/service/src/main/java/org/sunbird/actor/user/UserExternalIdManagementActor.java @@ -161,7 +161,7 @@ private List> getUserExternalIds( Map req = new HashMap<>(); req.put(JsonKey.USER_ID, requestMap.get(JsonKey.USER_ID)); Response response = - cassandraOperation.getRecordById(JsonKey.SUNBIRD, JsonKey.USR_EXT_IDNT_TABLE, req, context); + cassandraOperation.getRecordById(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USR_EXT_IDNT_TABLE, req, context); if (null != response && null != response.getResult()) { dbResExternalIds = (List>) response.getResult().get(JsonKey.RESPONSE); } @@ -178,7 +178,7 @@ private void deleteUserExternalId(Map map, RequestContext contex map.remove(JsonKey.ORIGINAL_ID_TYPE); map.remove(JsonKey.ORIGINAL_PROVIDER); // map.remove(JsonKey.STATUS); - cassandraOperation.deleteRecord(JsonKey.SUNBIRD, JsonKey.USR_EXT_IDNT_TABLE, map, context); + cassandraOperation.deleteRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USR_EXT_IDNT_TABLE, map, context); } private void throwExternalIDNotFoundException(String externalId, String idType, String provider) { @@ -210,7 +210,7 @@ private Map upsertUserExternalIdentityData( map.put(JsonKey.LAST_UPDATED_BY, requestMap.get(JsonKey.UPDATED_BY)); map.put(JsonKey.LAST_UPDATED_ON, new Timestamp(Calendar.getInstance().getTime().getTime())); } - cassandraOperation.upsertRecord(JsonKey.SUNBIRD, JsonKey.USR_EXT_IDNT_TABLE, map, context); + cassandraOperation.upsertRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USR_EXT_IDNT_TABLE, map, context); return map; } } diff --git a/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessDaoImpl.java b/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessDaoImpl.java index b459c7482c..89fee01de2 100644 --- a/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessDaoImpl.java @@ -15,13 +15,14 @@ import org.sunbird.model.bulkupload.BulkUploadProcess; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; /** Created by arvind on 24/4/18. */ public class BulkUploadProcessDaoImpl implements BulkUploadProcessDao { private final LoggerUtil logger = new LoggerUtil(BulkUploadProcessDaoImpl.class); private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ObjectMapper mapper = new ObjectMapper(); - private static final String KEYSPACE_NAME = "sunbird"; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String TABLE_NAME = "bulk_upload_process"; public static BulkUploadProcessDao bulkUploadProcessDao = null; diff --git a/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessTaskDaoImpl.java b/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessTaskDaoImpl.java index 132a5a0823..f5065c2bc5 100644 --- a/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessTaskDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/bulkupload/impl/BulkUploadProcessTaskDaoImpl.java @@ -16,6 +16,7 @@ import org.sunbird.model.bulkupload.BulkUploadProcessTask; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; /** * Data access implementation for BulkUploadProcessTask entity. @@ -26,7 +27,7 @@ public class BulkUploadProcessTaskDaoImpl implements BulkUploadProcessTaskDao { private final LoggerUtil logger = new LoggerUtil(BulkUploadProcessTaskDaoImpl.class); private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ObjectMapper mapper = new ObjectMapper(); - private final String KEYSPACE_NAME = "sunbird"; + private final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private final String TABLE_NAME = "bulk_upload_process_task"; public static BulkUploadProcessTaskDao bulkUploadProcessTaskDao = null; @@ -49,7 +50,7 @@ public String update(BulkUploadProcessTask bulkUploadProcessTask, RequestContext Map> map = CassandraUtil.batchUpdateQuery(bulkUploadProcessTask); Response response = cassandraOperation.updateRecord( - KEYSPACE_NAME, + KEYSPACE_NAME, TABLE_NAME, map.get(JsonKey.NON_PRIMARY_KEY), map.get(JsonKey.PRIMARY_KEY), diff --git a/service/src/main/java/org/sunbird/dao/location/impl/LocationDaoImpl.java b/service/src/main/java/org/sunbird/dao/location/impl/LocationDaoImpl.java index 1abc94afd7..9bc23b077e 100644 --- a/service/src/main/java/org/sunbird/dao/location/impl/LocationDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/location/impl/LocationDaoImpl.java @@ -26,7 +26,7 @@ public class LocationDaoImpl implements LocationDao { private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ElasticSearchService esUtil = EsClientFactory.getInstance(JsonKey.REST); private final ObjectMapper mapper = new ObjectMapper(); - private static final String KEYSPACE_NAME = "sunbird"; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String LOCATION_TABLE_NAME = "location"; @Override @@ -73,14 +73,14 @@ public Response search(Map searchQueryMap, RequestContext contex @Override public Response read(String locationId, RequestContext context) { return cassandraOperation.getRecordById( - KEYSPACE_NAME, LOCATION_TABLE_NAME, locationId, context); + KEYSPACE_NAME, LOCATION_TABLE_NAME, locationId, context); } @Override public Response getLocationsByIds( List locationIds, List locationFields, RequestContext context) { return cassandraOperation.getPropertiesValueById( - KEYSPACE_NAME, LOCATION_TABLE_NAME, locationIds, locationFields, context); + KEYSPACE_NAME, LOCATION_TABLE_NAME, locationIds, locationFields, context); } @Override diff --git a/service/src/main/java/org/sunbird/dao/notes/impl/NotesDaoImpl.java b/service/src/main/java/org/sunbird/dao/notes/impl/NotesDaoImpl.java index b6cb71d7cc..9766cab19c 100644 --- a/service/src/main/java/org/sunbird/dao/notes/impl/NotesDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/notes/impl/NotesDaoImpl.java @@ -21,7 +21,7 @@ public class NotesDaoImpl implements NotesDao { private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ElasticSearchService esService = EsClientFactory.getInstance(JsonKey.REST); - private static final String KEYSPACE_NAME = JsonKey.SUNBIRD; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String TABLE_NAME = "user_notes"; private static NotesDao notesDao; diff --git a/service/src/main/java/org/sunbird/dao/notification/impl/EmailTemplateDaoImpl.java b/service/src/main/java/org/sunbird/dao/notification/impl/EmailTemplateDaoImpl.java index 89b1ff8e30..fea78cfd6a 100644 --- a/service/src/main/java/org/sunbird/dao/notification/impl/EmailTemplateDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/notification/impl/EmailTemplateDaoImpl.java @@ -12,6 +12,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class EmailTemplateDaoImpl implements EmailTemplateDao { @@ -38,7 +39,7 @@ public String getTemplate(String templateName, RequestContext context) { Response response = getCassandraOperation() .getRecordsByPrimaryKeys( - JsonKey.SUNBIRD, EMAIL_TEMPLATE, idList, JsonKey.NAME, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), EMAIL_TEMPLATE, idList, JsonKey.NAME, context); List> emailTemplateList = (List>) response.get(JsonKey.RESPONSE); Map map = Collections.emptyMap(); diff --git a/service/src/main/java/org/sunbird/dao/organisation/impl/OrgDaoImpl.java b/service/src/main/java/org/sunbird/dao/organisation/impl/OrgDaoImpl.java index a3bad155f7..8393b11ed9 100644 --- a/service/src/main/java/org/sunbird/dao/organisation/impl/OrgDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/organisation/impl/OrgDaoImpl.java @@ -31,7 +31,7 @@ public class OrgDaoImpl implements OrgDao { private final ObjectMapper mapper = new ObjectMapper(); private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private static OrgDao orgDao; - private static final String KEYSPACE_NAME = JsonKey.SUNBIRD; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String ORG_TABLE_NAME = JsonKey.ORGANISATION; public static OrgDao getInstance() { @@ -68,7 +68,7 @@ public List> getOrgByIds( if (CollectionUtils.isNotEmpty(orgIds)) { Response response = cassandraOperation.getPropertiesValueById( - KEYSPACE_NAME, ORG_TABLE_NAME, orgIds, fields, context); + KEYSPACE_NAME, ORG_TABLE_NAME, orgIds, fields, context); List> responseList = (List>) response.get(JsonKey.RESPONSE); if (CollectionUtils.isNotEmpty(responseList)) { diff --git a/service/src/main/java/org/sunbird/dao/organisation/impl/OrgExternalDaoImpl.java b/service/src/main/java/org/sunbird/dao/organisation/impl/OrgExternalDaoImpl.java index 852becb698..8346bae787 100644 --- a/service/src/main/java/org/sunbird/dao/organisation/impl/OrgExternalDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/organisation/impl/OrgExternalDaoImpl.java @@ -11,11 +11,12 @@ import org.sunbird.keys.JsonKey; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class OrgExternalDaoImpl implements OrgExternalDao { private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); - private static final String KEYSPACE_NAME = JsonKey.SUNBIRD; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String ORG_EXT_TABLE_NAME = JsonKey.ORG_EXT_ID_DB; @Override diff --git a/service/src/main/java/org/sunbird/dao/otp/impl/OTPDaoImpl.java b/service/src/main/java/org/sunbird/dao/otp/impl/OTPDaoImpl.java index bd0e5245c4..1896eb8cfa 100644 --- a/service/src/main/java/org/sunbird/dao/otp/impl/OTPDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/otp/impl/OTPDaoImpl.java @@ -10,6 +10,7 @@ import org.sunbird.logging.LoggerUtil; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.PropertiesCache; public class OTPDaoImpl implements OTPDao { @@ -45,7 +46,7 @@ public Map getOTPDetails(String type, String key, RequestContext ttlFields.add(JsonKey.OTP); Response result = cassandraOperation.getRecordWithTTLById( - JsonKey.SUNBIRD, TABLE_NAME, request, ttlFields, fields, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, request, ttlFields, fields, context); List> otpMapList = (List>) result.get(JsonKey.RESPONSE); if (CollectionUtils.isEmpty(otpMapList)) { return null; @@ -64,7 +65,7 @@ public void insertOTPDetails(String type, String key, String otp, RequestContext String expirationInSeconds = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_OTP_EXPIRATION); int ttl = Integer.valueOf(expirationInSeconds); - cassandraOperation.insertRecordWithTTL(JsonKey.SUNBIRD, TABLE_NAME, request, ttl, context); + cassandraOperation.insertRecordWithTTL(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, request, ttl, context); } @Override @@ -72,7 +73,7 @@ public void deleteOtp(String type, String key, RequestContext context) { Map compositeKeyMap = new HashMap<>(); compositeKeyMap.put(JsonKey.TYPE, type); compositeKeyMap.put(JsonKey.KEY, key); - cassandraOperation.deleteRecord(JsonKey.SUNBIRD, TABLE_NAME, compositeKeyMap, context); + cassandraOperation.deleteRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, compositeKeyMap, context); logger.debug(context, "OTPDaoImpl:deleteOtp:otp deleted"); } @@ -88,6 +89,6 @@ public void updateAttemptCount(Map otpDetails, RequestContext co compositeKey.put(JsonKey.TYPE, otpDetails.get(JsonKey.TYPE)); compositeKey.put(JsonKey.KEY, otpDetails.get(JsonKey.KEY)); cassandraOperation.updateRecordWithTTL( - JsonKey.SUNBIRD, TABLE_NAME, request, compositeKey, ttl, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, request, compositeKey, ttl, context); } } diff --git a/service/src/main/java/org/sunbird/dao/ratelimit/RateLimitDaoImpl.java b/service/src/main/java/org/sunbird/dao/ratelimit/RateLimitDaoImpl.java index 4167075d46..1a16b21912 100644 --- a/service/src/main/java/org/sunbird/dao/ratelimit/RateLimitDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/ratelimit/RateLimitDaoImpl.java @@ -11,6 +11,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.ratelimit.RateLimit; public class RateLimitDaoImpl implements RateLimitDao { @@ -40,7 +41,7 @@ public void insertRateLimits(List rateLimits, RequestContext context) List> records = rateLimits.stream().map(rateLimit -> rateLimit.getRecord()).collect(Collectors.toList()); - cassandraOperation.batchInsertWithTTL(JsonKey.SUNBIRD, TABLE_NAME, records, ttl, context); + cassandraOperation.batchInsertWithTTL(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, records, ttl, context); } @Override @@ -56,7 +57,7 @@ public List> getRateLimits(String key, RequestContext contex Response response = cassandraOperation.getRecordsByIdsWithSpecifiedColumnsAndTTL( - JsonKey.SUNBIRD, TABLE_NAME, partitionKey, properties, ttlPropsWithAlias, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, partitionKey, properties, ttlPropsWithAlias, context); return (List>) response.get(JsonKey.RESPONSE); } diff --git a/service/src/main/java/org/sunbird/dao/role/impl/RoleDaoImpl.java b/service/src/main/java/org/sunbird/dao/role/impl/RoleDaoImpl.java index 0bc70ee086..aedde00a1a 100644 --- a/service/src/main/java/org/sunbird/dao/role/impl/RoleDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/role/impl/RoleDaoImpl.java @@ -11,6 +11,7 @@ import org.sunbird.model.role.Role; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class RoleDaoImpl implements RoleDao { @@ -29,7 +30,7 @@ public static RoleDao getInstance() { @Override public List getRoles(RequestContext context) { Response roleResults = - getCassandraOperation().getAllRecords(JsonKey.SUNBIRD, TABLE_NAME, context); + getCassandraOperation().getAllRecords(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, context); TypeReference> roleMapType = new TypeReference<>() {}; List> roleMapList = (List>) roleResults.get(JsonKey.RESPONSE); diff --git a/service/src/main/java/org/sunbird/dao/role/impl/RoleGroupDaoImpl.java b/service/src/main/java/org/sunbird/dao/role/impl/RoleGroupDaoImpl.java index 8d668c8342..0828d5af4b 100644 --- a/service/src/main/java/org/sunbird/dao/role/impl/RoleGroupDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/role/impl/RoleGroupDaoImpl.java @@ -11,6 +11,7 @@ import org.sunbird.model.role.RoleGroup; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class RoleGroupDaoImpl implements RoleGroupDao { @@ -27,7 +28,7 @@ public static RoleGroupDao getInstance() { @SuppressWarnings("unchecked") @Override public List getRoleGroups(RequestContext context) { - String KEYSPACE_NAME = "sunbird"; + String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); String TABLE_NAME = "role_group"; Response roleGroupResults = getCassandraOperation().getAllRecords(KEYSPACE_NAME, TABLE_NAME, context); diff --git a/service/src/main/java/org/sunbird/dao/systemsettings/impl/SystemSettingDaoImpl.java b/service/src/main/java/org/sunbird/dao/systemsettings/impl/SystemSettingDaoImpl.java index 99966a9ec7..4c00f1579b 100644 --- a/service/src/main/java/org/sunbird/dao/systemsettings/impl/SystemSettingDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/systemsettings/impl/SystemSettingDaoImpl.java @@ -12,12 +12,13 @@ import org.sunbird.model.systemsettings.SystemSetting; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class SystemSettingDaoImpl implements SystemSettingDao { private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ObjectMapper mapper = new ObjectMapper(); - private static final String KEYSPACE_NAME = JsonKey.SUNBIRD; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String TABLE_NAME = JsonKey.SYSTEM_SETTINGS_DB; @Override diff --git a/service/src/main/java/org/sunbird/dao/tenantpreference/impl/TenantPreferenceDaoImpl.java b/service/src/main/java/org/sunbird/dao/tenantpreference/impl/TenantPreferenceDaoImpl.java index 64b9589fc4..f70b7bb768 100644 --- a/service/src/main/java/org/sunbird/dao/tenantpreference/impl/TenantPreferenceDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/tenantpreference/impl/TenantPreferenceDaoImpl.java @@ -9,6 +9,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class TenantPreferenceDaoImpl implements TenantPreferenceDao { @@ -30,7 +31,7 @@ public List> getTenantPreferenceById( properties.put(JsonKey.KEY, key); Response tenantPreferences = cassandraOperation.getRecordsByProperties( - JsonKey.SUNBIRD, JsonKey.TENANT_PREFERENCE_V2_DB, properties, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.TENANT_PREFERENCE_V2_DB, properties, context); return (List>) tenantPreferences.get(JsonKey.RESPONSE); } @@ -38,7 +39,7 @@ public List> getTenantPreferenceById( public Response insertTenantPreference( Map tenantPreference, RequestContext context) { return cassandraOperation.insertRecord( - JsonKey.SUNBIRD, JsonKey.TENANT_PREFERENCE_V2_DB, tenantPreference, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.TENANT_PREFERENCE_V2_DB, tenantPreference, context); } @Override @@ -47,7 +48,7 @@ public Response updateTenantPreference( Map clusteringKeys, RequestContext context) { return cassandraOperation.updateRecord( - JsonKey.SUNBIRD, + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.TENANT_PREFERENCE_V2_DB, tenantPreference, clusteringKeys, diff --git a/service/src/main/java/org/sunbird/dao/urlaction/impl/UrlActionDaoImpl.java b/service/src/main/java/org/sunbird/dao/urlaction/impl/UrlActionDaoImpl.java index d3ea7861fc..f005588779 100644 --- a/service/src/main/java/org/sunbird/dao/urlaction/impl/UrlActionDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/urlaction/impl/UrlActionDaoImpl.java @@ -10,6 +10,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.model.urlaction.UrlAction; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class UrlActionDaoImpl implements UrlActionDao { @@ -26,7 +27,7 @@ public static UrlActionDao getInstance() { @Override public List getUrlActions() { - String KEYSPACE_NAME = "sunbird"; + String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); String TABLE_NAME = "url_action"; Response urlActionResults = cassandraOperation.getAllRecords(KEYSPACE_NAME, TABLE_NAME, null); TypeReference> urlActionType = new TypeReference<>() {}; diff --git a/service/src/main/java/org/sunbird/dao/user/impl/UserDaoImpl.java b/service/src/main/java/org/sunbird/dao/user/impl/UserDaoImpl.java index 6f785214f6..e1aad8ec86 100644 --- a/service/src/main/java/org/sunbird/dao/user/impl/UserDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/user/impl/UserDaoImpl.java @@ -32,7 +32,7 @@ public class UserDaoImpl implements UserDao { private final LoggerUtil logger = new LoggerUtil(UserDaoImpl.class); private static final String TABLE_NAME = JsonKey.USER; - private static final String KEY_SPACE_NAME = JsonKey.SUNBIRD; + private static final String KEY_SPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private final ElasticSearchService esService = EsClientFactory.getInstance(JsonKey.REST); private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private final ObjectMapper mapper = new ObjectMapper(); diff --git a/service/src/main/java/org/sunbird/dao/user/impl/UserExternalIdentityDaoImpl.java b/service/src/main/java/org/sunbird/dao/user/impl/UserExternalIdentityDaoImpl.java index 6d4d0298dd..4f1d04b2f5 100644 --- a/service/src/main/java/org/sunbird/dao/user/impl/UserExternalIdentityDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/user/impl/UserExternalIdentityDaoImpl.java @@ -14,6 +14,7 @@ import org.sunbird.logging.LoggerUtil; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class UserExternalIdentityDaoImpl implements UserExternalIdentityDao { @@ -49,7 +50,7 @@ public List> getUserExternalIds(String userId, RequestContex Map req = new HashMap<>(); req.put(JsonKey.USER_ID, userId); Response response = - cassandraOperation.getRecordById(JsonKey.SUNBIRD, JsonKey.USR_EXT_IDNT_TABLE, req, context); + cassandraOperation.getRecordById(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USR_EXT_IDNT_TABLE, req, context); if (null != response && null != response.getResult()) { dbResExternalIds = (List>) response.getResult().get(JsonKey.RESPONSE); } @@ -64,7 +65,7 @@ public List> getUserSelfDeclaredDetails( req.put(JsonKey.USER_ID, userId); Response response = cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, req, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, req, context); if (null != response && null != response.getResult()) { dbResExternalIds = (List>) response.getResult().get(JsonKey.RESPONSE); } diff --git a/service/src/main/java/org/sunbird/dao/user/impl/UserOrgDaoImpl.java b/service/src/main/java/org/sunbird/dao/user/impl/UserOrgDaoImpl.java index 25e550132c..e5c106ac35 100644 --- a/service/src/main/java/org/sunbird/dao/user/impl/UserOrgDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/user/impl/UserOrgDaoImpl.java @@ -12,6 +12,7 @@ import org.sunbird.model.user.UserOrg; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public final class UserOrgDaoImpl implements UserOrgDao { @@ -42,20 +43,20 @@ public Response updateUserOrg(UserOrg userOrg, RequestContext context) { compositeKey.put(JsonKey.USER_ID, request.remove(JsonKey.USER_ID)); compositeKey.put(JsonKey.ORGANISATION_ID, request.remove(JsonKey.ORGANISATION_ID)); return cassandraOperation.updateRecord( - JsonKey.SUNBIRD, TABLE_NAME, request, compositeKey, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, request, compositeKey, context); } @Override public Response createUserOrg(UserOrg userOrg, RequestContext context) { return cassandraOperation.insertRecord( - JsonKey.SUNBIRD, TABLE_NAME, mapper.convertValue(userOrg, Map.class), context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, mapper.convertValue(userOrg, Map.class), context); } @Override public Response getUserOrgListByUserId(String userId, RequestContext context) { Map compositeKey = new LinkedHashMap<>(2); compositeKey.put(JsonKey.USER_ID, userId); - return cassandraOperation.getRecordById(JsonKey.SUNBIRD, TABLE_NAME, compositeKey, context); + return cassandraOperation.getRecordById(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, compositeKey, context); } @Override @@ -66,12 +67,12 @@ public Response getUserOrgDetails(String userId, String organisationId, RequestC searchMap.put(JsonKey.ORGANISATION_ID, organisationId); } return cassandraOperation.getRecordsByCompositeKey( - JsonKey.SUNBIRD, JsonKey.USER_ORG, searchMap, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_ORG, searchMap, context); } @Override public Response insertRecord(Map reqMap, RequestContext context) { - return cassandraOperation.insertRecord(JsonKey.SUNBIRD, JsonKey.USER_ORG, reqMap, context); + return cassandraOperation.insertRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_ORG, reqMap, context); } public void deleteUserOrgMapping(List> userOrgList, RequestContext context) { @@ -79,7 +80,7 @@ public void deleteUserOrgMapping(List> userOrgList, RequestC Map compositeKey = new LinkedHashMap<>(2); compositeKey.put(JsonKey.USER_ID, (String) userOrg.get(JsonKey.USER_ID)); compositeKey.put(JsonKey.ORGANISATION_ID, (String) userOrg.get(JsonKey.ORGANISATION_ID)); - cassandraOperation.deleteRecord(JsonKey.SUNBIRD, JsonKey.USER_ORG, compositeKey, context); + cassandraOperation.deleteRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_ORG, compositeKey, context); } } } diff --git a/service/src/main/java/org/sunbird/dao/user/impl/UserRoleDaoImpl.java b/service/src/main/java/org/sunbird/dao/user/impl/UserRoleDaoImpl.java index 5575ade974..babc0982d5 100644 --- a/service/src/main/java/org/sunbird/dao/user/impl/UserRoleDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/user/impl/UserRoleDaoImpl.java @@ -35,7 +35,7 @@ public static UserRoleDao getInstance() { @Override public Response assignUserRole(List> userRoleMap, RequestContext context) { - return cassandraOperation.batchInsert(JsonKey.SUNBIRD, TABLE_NAME, userRoleMap, context); + return cassandraOperation.batchInsert(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, userRoleMap, context); } @Override @@ -47,7 +47,7 @@ public Response updateRoleScope(List> userRoleMap, RequestCo compositeKey.put(JsonKey.ROLE, dataMap.remove(JsonKey.ROLE)); result = cassandraOperation.updateRecord( - JsonKey.SUNBIRD, TABLE_NAME, dataMap, compositeKey, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, dataMap, compositeKey, context); } return result; } @@ -55,7 +55,7 @@ public Response updateRoleScope(List> userRoleMap, RequestCo @Override public void deleteUserRole(List> userRoleMap, RequestContext context) { for (Map dataMap : userRoleMap) { - cassandraOperation.deleteRecord(JsonKey.SUNBIRD, TABLE_NAME, dataMap, context); + cassandraOperation.deleteRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, dataMap, context); } } @@ -68,7 +68,7 @@ public List> getUserRoles( compositeKeyMap.put(JsonKey.ROLE, role); } Response existingRecord = - cassandraOperation.getRecordById(JsonKey.SUNBIRD, TABLE_NAME, compositeKeyMap, context); + cassandraOperation.getRecordById(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, compositeKeyMap, context); List> responseList = (List>) existingRecord.get(JsonKey.RESPONSE); diff --git a/service/src/main/java/org/sunbird/dao/user/impl/UserSelfDeclarationDaoImpl.java b/service/src/main/java/org/sunbird/dao/user/impl/UserSelfDeclarationDaoImpl.java index 7c36410eab..b929ec1ef6 100644 --- a/service/src/main/java/org/sunbird/dao/user/impl/UserSelfDeclarationDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/user/impl/UserSelfDeclarationDaoImpl.java @@ -14,6 +14,7 @@ import org.sunbird.model.user.UserDeclareEntity; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class UserSelfDeclarationDaoImpl implements UserSelfDeclarationDao { private final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); @@ -29,7 +30,7 @@ public static UserSelfDeclarationDao getInstance() { public void insertSelfDeclaredFields(Map extIdMap, RequestContext context) { cassandraOperation.insertRecord( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, extIdMap, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, extIdMap, context); } public List> getUserSelfDeclaredFields( @@ -41,7 +42,7 @@ public List> getUserSelfDeclaredFields( properties.put(JsonKey.PERSONA, userDeclareEntity.getPersona()); Response response = cassandraOperation.getRecordsByProperties( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, properties, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, properties, context); if (null != response && null != response.getResult()) { dbResExternalIds = (List>) response.getResult().get(JsonKey.RESPONSE); } @@ -64,7 +65,7 @@ public UserDeclareEntity upsertUserSelfDeclaredFields( updateFieldsMap.put( JsonKey.UPDATED_ON, new Timestamp(Calendar.getInstance().getTime().getTime())); cassandraOperation.updateRecord( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, updateFieldsMap, compositeKey, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, updateFieldsMap, compositeKey, context); return userDeclareEntity; } @@ -75,7 +76,7 @@ public List> getUserSelfDeclaredFields( properties.put(JsonKey.USER_ID, userId); Response response = cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, properties, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, properties, context); if (null != response && null != response.getResult()) { dbResExternalIds = (List>) response.getResult().get(JsonKey.RESPONSE); } @@ -89,7 +90,7 @@ public void deleteUserSelfDeclaredDetails( properties.put(JsonKey.ORG_ID, orgId); properties.put(JsonKey.PERSONA, persona); cassandraOperation.deleteRecord( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, properties, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, properties, context); } public Response updateUserSelfDeclaredFields( @@ -97,6 +98,6 @@ public Response updateUserSelfDeclaredFields( Map compositeKey, RequestContext context) { return cassandraOperation.updateRecord( - JsonKey.SUNBIRD, JsonKey.USER_DECLARATION_DB, updateFieldsMap, compositeKey, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.USER_DECLARATION_DB, updateFieldsMap, compositeKey, context); } } diff --git a/service/src/main/java/org/sunbird/dao/userconsent/impl/UserConsentDaoImpl.java b/service/src/main/java/org/sunbird/dao/userconsent/impl/UserConsentDaoImpl.java index a9fdbbc9d9..ffaa3d66fb 100644 --- a/service/src/main/java/org/sunbird/dao/userconsent/impl/UserConsentDaoImpl.java +++ b/service/src/main/java/org/sunbird/dao/userconsent/impl/UserConsentDaoImpl.java @@ -8,6 +8,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class UserConsentDaoImpl implements UserConsentDao { private final String TABLE_NAME = "user_consent"; @@ -24,7 +25,7 @@ public static UserConsentDao getInstance() { @Override public Response updateConsent(Map consent, RequestContext context) { - return cassandraOperation.upsertRecord(JsonKey.SUNBIRD, TABLE_NAME, consent, context); + return cassandraOperation.upsertRecord(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, consent, context); } @Override @@ -32,7 +33,7 @@ public List> getConsent( Map consentReq, RequestContext context) { Response response = cassandraOperation.getRecordsByCompositeKey( - JsonKey.SUNBIRD, TABLE_NAME, consentReq, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), TABLE_NAME, consentReq, context); return (List>) response.get(JsonKey.RESPONSE); } } diff --git a/service/src/main/java/org/sunbird/service/user/ShadowUserMigrationService.java b/service/src/main/java/org/sunbird/service/user/ShadowUserMigrationService.java index 435556aec3..7a72f00799 100644 --- a/service/src/main/java/org/sunbird/service/user/ShadowUserMigrationService.java +++ b/service/src/main/java/org/sunbird/service/user/ShadowUserMigrationService.java @@ -11,6 +11,7 @@ import org.sunbird.model.ShadowUser; import org.sunbird.request.RequestContext; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; public class ShadowUserMigrationService { private static final LoggerUtil logger = new LoggerUtil(ShadowUserMigrationService.class); @@ -29,7 +30,7 @@ public static ShadowUser getRecordByUserId(String userId, RequestContext context ShadowUser shadowUser = null; Response response = cassandraOperation.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, context); if (!((List) response.getResult().get(JsonKey.RESPONSE)).isEmpty()) { shadowUser = mapper.convertValue( @@ -53,7 +54,7 @@ public static boolean updateRecord( compositeKeysMap.put(JsonKey.CHANNEL, channel); Response response = cassandraOperation.updateRecord( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, propertiesMap, compositeKeysMap, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.SHADOW_USER, propertiesMap, compositeKeysMap, context); logger.info( context, "MigrationUtils:updateRecord:update in cassandra with userExtId" @@ -116,7 +117,7 @@ public static List getEligibleUsersById( List shadowUsersList = new ArrayList<>(); Response response = cassandraOperation.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, propsMap, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, propsMap, context); if (!((List) response.getResult().get(JsonKey.RESPONSE)).isEmpty()) { ((List) response.getResult().get(JsonKey.RESPONSE)) .stream() @@ -142,7 +143,7 @@ public static List getEligibleUsersById(String userId, RequestContex List shadowUsersList = new ArrayList<>(); Response response = cassandraOperation.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, context); + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE), JsonKey.SHADOW_USER, JsonKey.USERIDS, userId, context); if (!((List) response.getResult().get(JsonKey.RESPONSE)).isEmpty()) { ((List) response.getResult().get(JsonKey.RESPONSE)) .stream() diff --git a/service/src/main/java/org/sunbird/util/DataCacheHandler.java b/service/src/main/java/org/sunbird/util/DataCacheHandler.java index c847ccedef..c70e0ca18f 100644 --- a/service/src/main/java/org/sunbird/util/DataCacheHandler.java +++ b/service/src/main/java/org/sunbird/util/DataCacheHandler.java @@ -1,15 +1,7 @@ package org.sunbird.util; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Collectors; - -import com.microsoft.azure.storage.core.Logger; import org.apache.commons.collections.MapUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -23,6 +15,11 @@ import org.sunbird.response.Response; import org.sunbird.service.role.RoleService; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Collectors; + /** * This class will handle the data cache. * @@ -44,7 +41,7 @@ public class DataCacheHandler implements Runnable { private static Map> formApiDataConfigMap = new ConcurrentHashMap<>(); private static List> roleList = new CopyOnWriteArrayList<>(); private CassandraOperation cassandraOperation = ServiceFactory.getInstance(); - private static final String KEY_SPACE_NAME = JsonKey.SUNBIRD; + private static final String KEY_SPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static Response roleCacheResponse; private static Map orderMap; public static String[] bulkUserAllowedFields = { diff --git a/service/src/main/java/org/sunbird/util/Util.java b/service/src/main/java/org/sunbird/util/Util.java index 7a10a881a5..5134590109 100644 --- a/service/src/main/java/org/sunbird/util/Util.java +++ b/service/src/main/java/org/sunbird/util/Util.java @@ -19,7 +19,7 @@ public final class Util { public static final Map dbInfoMap = new HashMap<>(); - private static final String KEY_SPACE_NAME = "sunbird"; + private static final String KEY_SPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final CassandraOperation cassandraOperation = ServiceFactory.getInstance(); private static final DecryptionService decService = org.sunbird.datasecurity.impl.ServiceFactory.getDecryptionServiceInstance(); diff --git a/service/src/test/java/org/sunbird/actor/notification/EmailServiceActorTest.java b/service/src/test/java/org/sunbird/actor/notification/EmailServiceActorTest.java index 581283b45c..7fde626913 100644 --- a/service/src/test/java/org/sunbird/actor/notification/EmailServiceActorTest.java +++ b/service/src/test/java/org/sunbird/actor/notification/EmailServiceActorTest.java @@ -76,6 +76,7 @@ public void beforeTest() { when(cassandraOperation.getRecordById( Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())) .thenReturn(cassandraGetRecordById()); + when(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE)).thenReturn("sunbird"); } private static Response cassandraGetRecordById() { diff --git a/service/src/test/java/org/sunbird/actor/notification/SendNotificationActorTest.java b/service/src/test/java/org/sunbird/actor/notification/SendNotificationActorTest.java index 3841052349..aa074a68d8 100644 --- a/service/src/test/java/org/sunbird/actor/notification/SendNotificationActorTest.java +++ b/service/src/test/java/org/sunbird/actor/notification/SendNotificationActorTest.java @@ -84,6 +84,7 @@ public void beforeTest() { Mockito.anyList(), Mockito.any())) .thenReturn(cassandraGetRecordById()); + when(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE)).thenReturn("sunbird"); } private static Response cassandraGetRecordById() { diff --git a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java index 75ca5552aa..652986e860 100644 --- a/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java +++ b/service/src/test/java/org/sunbird/actor/organisation/OrgManagementActorTest.java @@ -1,23 +1,11 @@ package org.sunbird.actor.organisation; -import static akka.testkit.JavaTestKit.duration; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.*; - import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Props; import akka.dispatch.Futures; import akka.testkit.javadsl.TestKit; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; @@ -56,6 +44,19 @@ import scala.Option; import scala.concurrent.Promise; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static akka.testkit.JavaTestKit.duration; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.mockito.PowerMockito.*; + @RunWith(PowerMockRunner.class) @PrepareForTest({ ServiceFactory.class, @@ -516,11 +517,11 @@ private boolean testScenario(Request request, ResponseCode errorCode) { subject.tell(request, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(duration("100 second"), Response.class); + Response res = probe.expectMsgClass(duration("5 second"), Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { ProjectCommonException res = - probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); + probe.expectMsgClass(ProjectCommonException.class); return res.getResponseCode().name().equals(errorCode.name()) || res.getErrorResponseCode() == errorCode.getResponseCode(); } @@ -549,7 +550,7 @@ private byte[] getFileAsBytes() { new File( Paths.get("").toAbsolutePath() + File.separator - + "src/test/resources/samplepublic.pem"); + + "service/src/test/resources/samplepublic.pem"); Path path = Paths.get(file.getPath()); bytes = Files.readAllBytes(path); } catch (Exception e) { diff --git a/service/src/test/java/org/sunbird/actor/systemsettings/SystemSettingsActorTest.java b/service/src/test/java/org/sunbird/actor/systemsettings/SystemSettingsActorTest.java index 36d841d166..8c6889af45 100644 --- a/service/src/test/java/org/sunbird/actor/systemsettings/SystemSettingsActorTest.java +++ b/service/src/test/java/org/sunbird/actor/systemsettings/SystemSettingsActorTest.java @@ -32,6 +32,7 @@ import org.sunbird.operations.ActorOperations; import org.sunbird.request.Request; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; import scala.concurrent.duration.FiniteDuration; @RunWith(PowerMockRunner.class) @@ -60,7 +61,7 @@ public class SystemSettingsActorTest { private static String FIELD = "someField"; private static String VALUE = "someValue"; private ElasticSearchRestHighImpl esUtil; - private static final String KEYSPACE_NAME = JsonKey.SUNBIRD; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private static final String TABLE_NAME = JsonKey.SYSTEM_SETTINGS_DB; @Before diff --git a/service/src/test/java/org/sunbird/actor/user/CheckUserExistActorTest.java b/service/src/test/java/org/sunbird/actor/user/CheckUserExistActorTest.java index 2a20cd6c75..bdc475b518 100644 --- a/service/src/test/java/org/sunbird/actor/user/CheckUserExistActorTest.java +++ b/service/src/test/java/org/sunbird/actor/user/CheckUserExistActorTest.java @@ -43,6 +43,7 @@ ServiceFactory.class, EsClientFactory.class, ElasticSearchRestHighImpl.class, + CassandraOperationImpl.class, UserService.class, UserServiceImpl.class }) @@ -150,12 +151,12 @@ private boolean testScenario(Request reqObj, ResponseCode errorCode) { ActorRef subject = system.actorOf(props); subject.tell(reqObj, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(duration("10 second"), Response.class); + Response res = probe.expectMsgClass(duration("100 second"), Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { ProjectCommonException res = - probe.expectMsgClass(duration("10 second"), ProjectCommonException.class); + probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); return res.getErrorCode().equals(errorCode.getErrorCode()) || res.getErrorResponseCode() == errorCode.getResponseCode(); } @@ -169,7 +170,7 @@ public void testWithInvalidRequest() { request.setOperation("invalidOperation"); subject.tell(request, probe.getRef()); ProjectCommonException exception = - probe.expectMsgClass(duration("10 second"), ProjectCommonException.class); + probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); Assert.assertNotNull(exception); } } diff --git a/service/src/test/java/org/sunbird/actor/user/ResetPasswordActorTest.java b/service/src/test/java/org/sunbird/actor/user/ResetPasswordActorTest.java index 5d99e7b420..44ceb46533 100644 --- a/service/src/test/java/org/sunbird/actor/user/ResetPasswordActorTest.java +++ b/service/src/test/java/org/sunbird/actor/user/ResetPasswordActorTest.java @@ -35,6 +35,7 @@ import org.sunbird.sso.KeycloakUtil; import org.sunbird.sso.SSOManager; import org.sunbird.sso.SSOServiceFactory; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.UserUtility; @RunWith(PowerMockRunner.class) @@ -60,6 +61,7 @@ public class ResetPasswordActorTest { private CassandraOperation cassandraOperation = null; Props props = Props.create(ResetPasswordActor.class); ActorSystem system = ActorSystem.create("ResetPasswordActor"); + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); private void getRecordByIdNonEmptyResponse() { Response response = new Response(); @@ -78,7 +80,7 @@ private void getRecordByIdNonEmptyResponse() { userList.add(user); response.getResult().put(JsonKey.RESPONSE, userList); PowerMockito.when( - cassandraOperation.getRecordById(JsonKey.SUNBIRD, JsonKey.USER, "ValidUserId", null)) + cassandraOperation.getRecordById(KEYSPACE_NAME, JsonKey.USER, "ValidUserId", null)) .thenReturn(response); } @@ -86,7 +88,7 @@ private void getRecordByIdEmptyResponse() { Response response = new Response(); PowerMockito.when( cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.USER, "invalidParameter", null)) + KEYSPACE_NAME, JsonKey.USER, "invalidParameter", null)) .thenReturn(response); } diff --git a/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java b/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java index 57c05a4391..dbf5b8cdec 100644 --- a/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java +++ b/service/src/test/java/org/sunbird/actor/user/TenantMigrationActorTest.java @@ -1,17 +1,10 @@ package org.sunbird.actor.user; -import static akka.testkit.JavaTestKit.duration; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Props; import akka.dispatch.Futures; import akka.testkit.javadsl.TestKit; -import java.util.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -43,6 +36,13 @@ import org.sunbird.util.ProjectUtil; import scala.concurrent.Promise; +import java.util.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; + @RunWith(PowerMockRunner.class) @PrepareForTest({ ServiceFactory.class, @@ -216,11 +216,10 @@ public boolean testScenario(Request reqObj, ResponseCode errorCode, Props props) ActorRef subject = system.actorOf(props); subject.tell(reqObj, probe.getRef()); if (errorCode == null) { - Response res = probe.expectMsgClass(duration("100 second"), Response.class); + Response res = probe.expectMsgClass(Response.class); return null != res && res.getResponseCode() == ResponseCode.OK; } else { - ProjectCommonException res = - probe.expectMsgClass(duration("100 second"), ProjectCommonException.class); + ProjectCommonException res = probe.expectMsgClass(ProjectCommonException.class); return res.getResponseCode().name().equals(errorCode.name()) || res.getErrorResponseCode() == errorCode.getResponseCode(); } @@ -284,8 +283,7 @@ public void testWithInvalidRequest() { Request request = new Request(); request.setOperation("invalidOperation"); subject.tell(request, probe.getRef()); - ProjectCommonException exception = - probe.expectMsgClass(duration("10 second"), ProjectCommonException.class); + ProjectCommonException exception = probe.expectMsgClass(ProjectCommonException.class); Assert.assertNotNull(exception); } diff --git a/service/src/test/java/org/sunbird/actor/user/UserProfileReadActorTest.java b/service/src/test/java/org/sunbird/actor/user/UserProfileReadActorTest.java index 5d852e6f0d..980f79f308 100644 --- a/service/src/test/java/org/sunbird/actor/user/UserProfileReadActorTest.java +++ b/service/src/test/java/org/sunbird/actor/user/UserProfileReadActorTest.java @@ -49,6 +49,7 @@ import org.sunbird.sso.SSOServiceFactory; import org.sunbird.sso.impl.KeyCloakServiceImpl; import org.sunbird.util.DataCacheHandler; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.UserUtility; import org.sunbird.util.Util; import org.sunbird.util.user.UserUtil; @@ -100,6 +101,7 @@ public class UserProfileReadActorTest { private static final String INVALID_PHONE = "000"; private static final String VALID_USERNAME = "USERNAME"; private static ElasticSearchService esService; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Before public void beforeEachTest() { @@ -389,7 +391,7 @@ public void testGetUserProfileSuccessV3WithFieldDeclarationAndExternalIds() thro Map req = new HashMap<>(); req.put(JsonKey.USER_ID, VALID_USER_ID); when(cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.USR_DECLARATION_TABLE, req, null)) + KEYSPACE_NAME, JsonKey.USR_DECLARATION_TABLE, req, null)) .thenReturn(getUserDeclarationResponse(true)); boolean result = testScenario(reqObj, null); assertTrue(result); @@ -489,7 +491,7 @@ public void testGetUserByEmailKey() throws Exception { Map req = new HashMap<>(); req.put(JsonKey.USER_ID, VALID_USER_ID); when(cassandraOperation.getRecordById( - JsonKey.SUNBIRD, JsonKey.USR_DECLARATION_TABLE, req, null)) + KEYSPACE_NAME, JsonKey.USR_DECLARATION_TABLE, req, null)) .thenReturn(getUserDeclarationResponse(true)); reqMap = getUserProfileByKeyRequest(JsonKey.EMAIL, INVALID_EMAIL); setCassandraResponse(getCassandraResponse(false)); diff --git a/service/src/test/java/org/sunbird/dao/notification/EmailTemplateDaoImplTest.java b/service/src/test/java/org/sunbird/dao/notification/EmailTemplateDaoImplTest.java index ebf7cd0b18..41d2288442 100644 --- a/service/src/test/java/org/sunbird/dao/notification/EmailTemplateDaoImplTest.java +++ b/service/src/test/java/org/sunbird/dao/notification/EmailTemplateDaoImplTest.java @@ -22,6 +22,7 @@ import org.sunbird.helper.ServiceFactory; import org.sunbird.keys.JsonKey; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; @RunWith(PowerMockRunner.class) @PrepareForTest({ @@ -42,6 +43,7 @@ public class EmailTemplateDaoImplTest { private static final String DEFAULT_EMAIL_TEMPLATE_NAME = "default"; private static final String TEMPLATE = "template"; private EmailTemplateDao emailTemplateDao = new EmailTemplateDaoImpl(); + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Before public void setUp() throws Exception { @@ -61,7 +63,7 @@ public void testGetTemplateWithBlankTemplateName() { orgList.add(map); response.put(JsonKey.RESPONSE, orgList); when(cassandraOperation.getRecordsByPrimaryKeys( - JsonKey.SUNBIRD, EMAIL_TEMPLATE, idList, JsonKey.NAME, null)) + KEYSPACE_NAME, EMAIL_TEMPLATE, idList, JsonKey.NAME, null)) .thenReturn(response); String resp = emailTemplateDao.getTemplate(StringUtils.EMPTY, null); Assert.assertEquals(null, resp); @@ -78,7 +80,7 @@ public void testGetTemplateWithTemplateName() { orgList.add(map); response.put(JsonKey.RESPONSE, orgList); when(cassandraOperation.getRecordsByPrimaryKeys( - JsonKey.SUNBIRD, EMAIL_TEMPLATE, idList, JsonKey.NAME, null)) + KEYSPACE_NAME, EMAIL_TEMPLATE, idList, JsonKey.NAME, null)) .thenReturn(response); String resp = emailTemplateDao.getTemplate("Sunbird_email_template", null); Assert.assertEquals("Course is Been completed", resp); diff --git a/service/src/test/java/org/sunbird/dao/role/RoleDaoImplTest.java b/service/src/test/java/org/sunbird/dao/role/RoleDaoImplTest.java index 0635550d12..e2dde6186c 100644 --- a/service/src/test/java/org/sunbird/dao/role/RoleDaoImplTest.java +++ b/service/src/test/java/org/sunbird/dao/role/RoleDaoImplTest.java @@ -22,6 +22,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.model.role.Role; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; @RunWith(PowerMockRunner.class) @PrepareForTest({ @@ -41,6 +42,7 @@ public class RoleDaoImplTest { private CassandraOperation cassandraOperation; private Response response; private RoleDao roleDao; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Before public void setUp() throws Exception { @@ -59,7 +61,7 @@ public void testGetRoles() { cassandraOperation = PowerMockito.mock(CassandraOperation.class); PowerMockito.mockStatic(ServiceFactory.class); when(ServiceFactory.getInstance()).thenReturn(cassandraOperation); - when(cassandraOperation.getAllRecords(JsonKey.SUNBIRD, TABLE_NAME, null)) + when(cassandraOperation.getAllRecords(KEYSPACE_NAME, TABLE_NAME, null)) .thenReturn(response); List roleList = roleDao.getRoles(null); Assert.assertEquals("TEACHER", roleList.get(0).getName()); diff --git a/service/src/test/java/org/sunbird/dao/role/RoleGroupDaoImplTest.java b/service/src/test/java/org/sunbird/dao/role/RoleGroupDaoImplTest.java index a600d9b928..cdfb9ff12b 100644 --- a/service/src/test/java/org/sunbird/dao/role/RoleGroupDaoImplTest.java +++ b/service/src/test/java/org/sunbird/dao/role/RoleGroupDaoImplTest.java @@ -22,6 +22,7 @@ import org.sunbird.keys.JsonKey; import org.sunbird.model.role.RoleGroup; import org.sunbird.response.Response; +import org.sunbird.util.ProjectUtil; @RunWith(PowerMockRunner.class) @PrepareForTest({ @@ -41,6 +42,7 @@ public class RoleGroupDaoImplTest { private CassandraOperation cassandraOperation; private Response response; private RoleGroupDao roleGroupDao; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Before public void setUp() { @@ -59,7 +61,7 @@ public void testGetRoles() { cassandraOperation = PowerMockito.mock(CassandraOperation.class); PowerMockito.mockStatic(ServiceFactory.class); when(ServiceFactory.getInstance()).thenReturn(cassandraOperation); - when(cassandraOperation.getAllRecords(JsonKey.SUNBIRD, TABLE_NAME, null)) + when(cassandraOperation.getAllRecords(KEYSPACE_NAME, TABLE_NAME, null)) .thenReturn(response); List roleGroups = roleGroupDao.getRoleGroups(null); Assert.assertEquals("Flag Reviewer", roleGroups.get(0).getName()); diff --git a/service/src/test/java/org/sunbird/service/user/UserProfileReadServiceTest.java b/service/src/test/java/org/sunbird/service/user/UserProfileReadServiceTest.java index b05c7a12ab..e22cdcb088 100644 --- a/service/src/test/java/org/sunbird/service/user/UserProfileReadServiceTest.java +++ b/service/src/test/java/org/sunbird/service/user/UserProfileReadServiceTest.java @@ -13,8 +13,10 @@ import java.util.Map; import org.junit.Assert; import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -76,6 +78,7 @@ "jdk.internal.reflect.*", "javax.crypto.*" }) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserProfileReadServiceTest { private String tncConfig = @@ -337,7 +340,7 @@ public void getLockedUserProfileTest() throws JsonProcessingException { Assert.assertEquals(ex.getErrorCode(), ResponseCode.userAccountlocked.getErrorCode()); } } - + @Test public void getUserIdByExternalIdTest() { UserProfileReadService userProfileReadService = new UserProfileReadService(); @@ -345,9 +348,12 @@ public void getUserIdByExternalIdTest() { request.getContext().put(JsonKey.PROVIDER, "4578963210"); request.getContext().put(JsonKey.ID_TYPE, "4578963210"); PowerMockito.mockStatic(UserExternalIdentityServiceImpl.class); - UserExternalIdentityServiceImpl userExternalIdentityService = PowerMockito.mock(UserExternalIdentityServiceImpl.class); + UserExternalIdentityServiceImpl userExternalIdentityService = + PowerMockito.mock(UserExternalIdentityServiceImpl.class); when(UserExternalIdentityServiceImpl.getInstance()).thenReturn(userExternalIdentityService); - when(userExternalIdentityService.getUserV1(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(""); + when(userExternalIdentityService.getUserV1( + Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())) + .thenReturn(""); try { userProfileReadService.getUserProfileData(request); } catch (ProjectCommonException ex) { diff --git a/service/src/test/java/org/sunbird/util/user/GetUserOrgDetailsTest.java b/service/src/test/java/org/sunbird/util/user/GetUserOrgDetailsTest.java index 50bc88d668..9f98a090f5 100644 --- a/service/src/test/java/org/sunbird/util/user/GetUserOrgDetailsTest.java +++ b/service/src/test/java/org/sunbird/util/user/GetUserOrgDetailsTest.java @@ -17,6 +17,7 @@ import org.sunbird.cassandraimpl.CassandraOperationImpl; import org.sunbird.helper.ServiceFactory; import org.sunbird.keys.JsonKey; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.Util; import org.sunbird.response.Response; @@ -30,6 +31,7 @@ "javax.crypto.*" }) public class GetUserOrgDetailsTest { + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Test public void testGetUserOrgDetails() { @@ -49,7 +51,7 @@ public void testGetUserOrgDetails() { ids.add("123-456-789"); when(ServiceFactory.getInstance()).thenReturn(cassandraOperationImpl); when(cassandraOperationImpl.getRecordsByPrimaryKeys( - JsonKey.SUNBIRD, "user_organisation", ids, JsonKey.USER_ID, null)) + KEYSPACE_NAME, "user_organisation", ids, JsonKey.USER_ID, null)) .thenReturn(response1); List> res = UserUtil.getActiveUserOrgDetails("123-456-789", null); Assert.assertNotNull(res); diff --git a/service/src/test/java/org/sunbird/util/user/SetUserDefaultValueTest.java b/service/src/test/java/org/sunbird/util/user/SetUserDefaultValueTest.java index d2a23e3fbe..175f2a9dd6 100644 --- a/service/src/test/java/org/sunbird/util/user/SetUserDefaultValueTest.java +++ b/service/src/test/java/org/sunbird/util/user/SetUserDefaultValueTest.java @@ -28,6 +28,7 @@ import org.sunbird.service.user.impl.UserLookUpServiceImpl; import org.sunbird.service.user.impl.UserServiceImpl; import org.sunbird.util.DataCacheHandler; +import org.sunbird.util.ProjectUtil; import org.sunbird.util.Util; @RunWith(PowerMockRunner.class) @@ -57,6 +58,7 @@ public class SetUserDefaultValueTest { private static Response response; public static CassandraOperationImpl cassandraOperationImpl; private static ElasticSearchService esService; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); public void beforeEachTest() { PowerMockito.mockStatic(DataCacheHandler.class); @@ -76,13 +78,13 @@ public void beforeEachTest() { reqMap.put(JsonKey.TYPE, JsonKey.EMAIL); reqMap.put(JsonKey.VALUE, "test@test.com"); when(cassandraOperationImpl.getRecordsByCompositeKey( - JsonKey.SUNBIRD, JsonKey.USER_LOOKUP, reqMap, null)) + KEYSPACE_NAME, JsonKey.USER_LOOKUP, reqMap, null)) .thenReturn(response); Map reqMapPhone = new HashMap<>(); reqMap.put(JsonKey.TYPE, JsonKey.PHONE); reqMap.put(JsonKey.VALUE, "9663890400"); when(cassandraOperationImpl.getRecordsByCompositeKey( - JsonKey.SUNBIRD, JsonKey.USER_LOOKUP, reqMapPhone, null)) + KEYSPACE_NAME, JsonKey.USER_LOOKUP, reqMapPhone, null)) .thenReturn(existResponse); when(DataCacheHandler.getConfigSettings()).thenReturn(settingMap); diff --git a/service/src/test/java/org/sunbird/util/user/ShadowUserMigrationServiceTest.java b/service/src/test/java/org/sunbird/util/user/ShadowUserMigrationServiceTest.java index 296ebc75a5..67d2ae250d 100644 --- a/service/src/test/java/org/sunbird/util/user/ShadowUserMigrationServiceTest.java +++ b/service/src/test/java/org/sunbird/util/user/ShadowUserMigrationServiceTest.java @@ -25,6 +25,7 @@ import org.sunbird.response.Response; import org.sunbird.service.user.ShadowUserMigrationService; import org.sunbird.service.user.impl.UserServiceImpl; +import org.sunbird.util.ProjectUtil; @RunWith(PowerMockRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -40,6 +41,7 @@ public class ShadowUserMigrationServiceTest { private static Response response; public static CassandraOperationImpl cassandraOperationImpl; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); @Before public void beforeEachTest() { @@ -48,16 +50,16 @@ public void beforeEachTest() { cassandraOperationImpl = mock(CassandraOperationImpl.class); when(ServiceFactory.getInstance()).thenReturn(cassandraOperationImpl); when(cassandraOperationImpl.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "EFG", null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "EFG", null)) .thenReturn(getRecordsById(false)); when(cassandraOperationImpl.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "DEF", null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "DEF", null)) .thenReturn(getRecordsById(true)); when(cassandraOperationImpl.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "ABC", new HashMap<>(), null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "ABC", new HashMap<>(), null)) .thenReturn(getRecordsById(false)); when(cassandraOperationImpl.searchValueInList( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "XYZ", new HashMap<>(), null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, JsonKey.USER_IDs, "XYZ", new HashMap<>(), null)) .thenReturn(getRecordsById(true)); } @@ -79,7 +81,7 @@ public void testUpdateRecord() { compositeKeysMap.put(JsonKey.USER_EXT_ID, "anyUserExtId"); compositeKeysMap.put(JsonKey.CHANNEL, "anyChannel"); when(cassandraOperationImpl.updateRecord( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) .thenReturn(response); boolean isRecordUpdated = ShadowUserMigrationService.updateRecord(new HashMap<>(), "anyChannel", "anyUserExtId", null); @@ -97,7 +99,7 @@ public void testmarkUserAsRejected() { compositeKeysMap.put(JsonKey.USER_EXT_ID, "anyUserExtId"); compositeKeysMap.put(JsonKey.CHANNEL, "anyChannel"); when(cassandraOperationImpl.updateRecord( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) .thenReturn(response); boolean isRecordUpdated = ShadowUserMigrationService.markUserAsRejected(shadowUser, null); Assert.assertEquals(true, isRecordUpdated); @@ -114,7 +116,7 @@ public void testUpdateClaimStatus() { compositeKeysMap.put(JsonKey.USER_EXT_ID, "anyUserExtId"); compositeKeysMap.put(JsonKey.CHANNEL, "anyChannel"); when(cassandraOperationImpl.updateRecord( - JsonKey.SUNBIRD, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) + KEYSPACE_NAME, JsonKey.SHADOW_USER, new HashMap<>(), compositeKeysMap, null)) .thenReturn(response); boolean isRecordUpdated = ShadowUserMigrationService.updateClaimStatus(shadowUser, ClaimStatus.ELIGIBLE.getValue(), null); diff --git a/service/src/test/java/org/sunbird/util/user/UserUtilTest.java b/service/src/test/java/org/sunbird/util/user/UserUtilTest.java index 868fbb81c3..54f2ce1ea6 100644 --- a/service/src/test/java/org/sunbird/util/user/UserUtilTest.java +++ b/service/src/test/java/org/sunbird/util/user/UserUtilTest.java @@ -12,8 +12,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -56,10 +58,12 @@ "jdk.internal.reflect.*", "javax.crypto.*" }) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserUtilTest { private static Response response; public static CassandraOperationImpl cassandraOperationImpl; private static ElasticSearchService esService; + private static final String KEYSPACE_NAME = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYSPACE); public void beforeEachTest() { PowerMockito.mockStatic(DataCacheHandler.class); @@ -79,13 +83,13 @@ public void beforeEachTest() { reqMap.put(JsonKey.TYPE, JsonKey.EMAIL); reqMap.put(JsonKey.VALUE, "test@test.com"); when(cassandraOperationImpl.getRecordsByCompositeKey( - JsonKey.SUNBIRD, JsonKey.USER_LOOKUP, reqMap, null)) + KEYSPACE_NAME, JsonKey.USER_LOOKUP, reqMap, null)) .thenReturn(response); Map reqMapPhone = new HashMap<>(); reqMap.put(JsonKey.TYPE, JsonKey.PHONE); reqMap.put(JsonKey.VALUE, "9663890400"); when(cassandraOperationImpl.getRecordsByCompositeKey( - JsonKey.SUNBIRD, JsonKey.USER_LOOKUP, reqMapPhone, null)) + KEYSPACE_NAME, JsonKey.USER_LOOKUP, reqMapPhone, null)) .thenReturn(existResponse); when(DataCacheHandler.getConfigSettings()).thenReturn(settingMap); diff --git a/service/src/test/resources/externalresource.properties b/service/src/test/resources/externalresource.properties new file mode 100644 index 0000000000..97112d3c4b --- /dev/null +++ b/service/src/test/resources/externalresource.properties @@ -0,0 +1,112 @@ +sunbird_authorization= +ekstep.tag.api.url=/tag/register +sunbird_installation=sunbird +sunbird_analytics_api_base_url=http://analytics-service:9000 +sunbird_mail_server_host= +sunbird_mail_server_port= +sunbird_mail_server_username= +sunbird_mail_server_password= +sunbird_mail_server_from_email=support@open-sunbird.org +sunbird_username_num_digits=4 +sunbird_account_name= +sunbird_account_key= +download_link_expiry_timeout=300 +sunbird_encryption_key=SunBird +sunbird_encryption=ON +sunbird_allowed_login=You can use your cellphone number to login +#size of bulk upload data is 1001 including header in csv file +sunbird_user_bulk_upload_size=1001 +bulk_upload_org_data_size=300 +sunbird_web_url=https://dev.sunbirded.org +sunbird_framework_read_api=/v1/framework/read +fcm.url=https://fcm.googleapis.com/fcm/send +sunbird_default_country_code=+91 +#put the default evn logo url here or System Env variable with +#same key. code will first search from EVN then here. +sunbird_env_logo_url=http://via.placeholder.com/100x50 +system_settings_properties=phoneUnique,emailUnique +sunbird_default_welcome_sms=Welcome to DIKSHA. +sunbird_url_shortner_base_url=https://api-ssl.bitly.com/v3/shorten?access_token= +sunbird_url_shortner_access_token= +sunbird_content_service_api_base_url=http://content-service:9000 +sunbird.channel.create.api.url=/channel/v3/create +sunbird.channel.update.api.url=/channel/v3/update +sunbird_otp_allowed_attempt=2 + +#Telemetry producer related info +telemetry_pdata_id=local.sunbird.learning.service +telemetry_pdata_pid=learning-service +telemetry_pdata_ver=5.3.0 +#elastic search top n result count for telemetry +searchTopN=5 +sunbird_valid_location_types=state,district,block,cluster,school; +# Bulk upload file max size in MB +file_upload_max_size=10 +sunbird_default_channel= +# Batch size for cassandra batch operation +cassandra_write_batch_size=100 +sunbird_sso_client_id= +sunbird_sso_username= +sunbird_sso_password= +sunbird_sso_url= +sunbird_sso_realm= +sunbird_keycloak_required_action_link_expiration_seconds=155520000 +sunbird_url_shortner_enable=false +sunbird_api_request_lower_case_fields=source,externalId,userName,provider,loginId,email,prevUsedEmail +sunbird_otp_expiration=1800 +sunbird_otp_length=6 +sunbird_otp_hour_rate_limit=5 +sunbird_otp_day_rate_limit=20 +sunbird_rate_limit_enabled=true +sunbird_health_check_enable=true +sunbird_sync_read_wait_time=1500 +sunbird_gzip_size_threshold=262144 +kafka_urls=localhost:9092 +sunbird_fuzzy_search_threshold=0.5 +sunbird_state_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212938260643843.png +sunbird_diksha_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212989820190722.png +sunbird_cert_completion_img_url=https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212919987568641.png +sunbird_reset_pass_msg=Your have requested to reset password. Click on the link to set a password: {0} +sunbird_reset_pass_mail_subject=Reset Password +sunbird_subdomain_keycloak_base_url=https://merge.dev.sunbirded.org/auth/ +kafka_linger_ms=5 +sunbird_user_upload_error_visualization_threshold=20001 +migrate_user_template=You can now access your {0} state teacher account using {1}. Please log out and login once again to see updated details. +sunbird_account_merge_subject=Account merged successfully +sunbird_pass_regex=(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!\"#$%&'()*+,-./:;<=>?@\\[\\]^_`{|}~])(?=\\S+$).{8,} +sunbird_user_create_sync_type=ES +sunbird_user_create_sync_topic=local.user.events +sigterm_stop_delay=40 +limit_managed_user_creation=true +managed_user_limit=30 +adminutil_base_url = http://adminutil:4000/ +adminutil_sign_endpoint = v1/sign/payload +self_declared_mandatory_fields = Diksha UUID,Status,State provided ext. ID,Channel,Persona +self_declared_optional_fields = School Name,School UDISE ID,Email ID,Phone number,Error Type +enable_captcha=true +consent_expiry_in_days=100 +feed_limit=30 +learner_in_memory_cache_ttl=14400 +#alias is actually referring the user and org index so no need to mention separately +user_index_alias=user_alias +org_index_alias=org_alias +#Release 5.4.0 LR-102 +es_user_notes_index=usernotes +es_location_index=location +es_user_feed_index=userfeed +defaultMonthDate = -12-31 +nic_sms_gateway_provider_base_url=https://smsgw.sms.gov.in/failsafe/HttpLink +sms_gateway_provider=91SMS +stacktrace_char_length=2500 +notification_service_base_url= +notification_service_v2_send_url=/private/v2/notification/send +notification_service_v1_update_url=/private/v1/notification/feed/update +notification_service_v1_read_url=/private/v1/notification/feed/read +notification_service_v1_delete_url=/private/v1/notification/feed/delete +channel_registration_disabled=false +#Login Page URL used as redirect URL in Password set / reset action. This will be suffixed with sunbird_web_url value. +sunbird_password_reset_login_page_url=/resources +isFormValidationRequired=true +userProfileConfigMap={\"type\":\"profileconfig\",\"subtype\":\"28\",\"action\":\"get\",\"component\":\"*\",\"framework\":\"*\",\"data\":{\"templateName\":\"profileConfig_v2\",\"action\":\"get\",\"fields\":[{\"code\":\"persona\",\"children\":{\"administrator\":[{\"code\":\"district\"},{\"code\":\"state\"},{\"code\":\"subPersona\",\"type\":\"select\",\"default\":null,\"templateOptions\":{\"options\":[{\"label\":\"Headmaster\",\"value\":\"hm\"},{\"label\":\"Cluster Resource Person\",\"value\":\"crp\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"teacher\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"student\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"parent\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}],\"other\":[{\"code\":\"state\"},{\"code\":\"district\"},{\"code\":\"subPersona\",\"templateOptions\":{\"options\":[{\"value\":\"Doctor (Allopathy)\",\"label\":\"Doctor (Allopathy)\"},{\"value\":\"AYUSH Professional\",\"label\":\"AYUSH Professional\"}]}},{\"code\":\"block\"},{\"code\":\"cluster\"},{\"code\":\"school\"}]}}]},\"created_on\":\"2022-02-10T14:16:51.852Z\",\"last_modified_on\":\"2022-11-14T05:45:02.685Z\",\"rootOrgId\":\"*\"} +sunbird_keyspace=sunbird +sunbird_cloud_service_provider=azure \ No newline at end of file diff --git a/setup.md b/setup.md index 174bf1cc62..341f2abe3c 100644 --- a/setup.md +++ b/setup.md @@ -78,7 +78,7 @@ ## Build 1. Run "git submodule foreach git pull origin master" to pull the latest sunbird-common submodule. -2. Run "mvn clean install" to build the services. +2. Run "mvn clean install -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk -DCLOUD_STORE_VERSION=1.4.6" to build the services. 2. Go to "controller" and run the command "mvn play2:dist" to generate the dist file for controller. 3. The build file "controller-1.0-SNAPSHOT-dist.zip" is generated in "userorg-service/controller/target" folder.