diff --git a/README.md b/README.md index 774f7d4b5..5ca59846e 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,7 @@ Fork the below projects and clone it from git, ```shell git clone https://github.com/Sunbird-Lern/sunbird-utils/ ``` -Open a new Terminal In the path, -#### (Project base path)/sunbird-utils -Run the below command, -```shell -mvn clean install -DskipTests -``` -Make sure the build is success and then, + open a new Terminal In the path, #### (Project base path)/sunbird-utils/sunbird-cassandra-migration/cassandra-migration, Run below command, @@ -29,7 +23,7 @@ mvn clean install -DskipTests ### Command 1: ```shell java -jar \ --Dcassandra.migration.scripts.locations=filesystem:/db/migration/cassandra/ \ +-Dcassandra.migration.scripts.locations=filesystem:/db_migration/cassandra/ \ -Dcassandra.migration.cluster.contactpoints=localhost \ -Dcassandra.migration.cluster.port=9042 \ -Dcassandra.migration.cluster.username=username \ @@ -44,7 +38,7 @@ keyspace.name - specify keyspace for which you have to perform migration #### Sample Command: ```shell java -jar \ --Dcassandra.migration.scripts.locations=filesystem:src/main/resources/db/migration/cassandra/sunbird_groups \ +-Dcassandra.migration.scripts.locations=filesystem:src/main/resources/db_migration/cassandra/sunbird_groups \ -Dcassandra.migration.cluster.contactpoints=localhost \ -Dcassandra.migration.cluster.port=9042 \ -Dcassandra.migration.cluster.username=cassandra \ @@ -60,5 +54,5 @@ The system environment listed below is required for command 2. ### System Env ```shell sunbird_cassandra_keyspace= -sunbird_cassandra_migration_location="filesystem:/db/migration/cassandra" +sunbird_cassandra_migration_location="filesystem:/db_migration/cassandra" ``` \ No newline at end of file diff --git a/decryption-tool/README.md b/decryption-tool/README.md deleted file mode 100644 index c994df10b..000000000 --- a/decryption-tool/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# decryption-tool -This tool is used to decrypt the file encrypted by sunbird. - -### Supported OS -* Mac -* Ubuntu -* Windows -### System Requirements: -### Prerequisites: -* Python 3 - -# How to run -## Let us assume that B received files from A. -``` - bash decrypt.sh - # File to decrypt: path of the encrypted csv file that received. Tool will detect whether file is encryptes using security level TEXT_KEY_ENCRYPTED_DATASET or PUBLIC_KEY_ENCRYPTED_DATASET. Based on that it will promt the further steps to decrypt the file. - - # If security level is TEXT_KEY_ENCRYPTED_DATASET - # AES key: AES key, that used to encrypt the csv file. - - # If seccurity level is PUBLIC_KEY_ENCRYPTED_DATASET - # Private key path: Path od the private.pem file. - # Private key passphrase: Passphrase which is used to generate public private key pair -``` \ No newline at end of file diff --git a/decryption-tool/decrypt.sh b/decryption-tool/decrypt.sh deleted file mode 100644 index 0b8553133..000000000 --- a/decryption-tool/decrypt.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# To install the dependencies -python3 -m pip install --upgrade pip -pip3 install -r ./src/requirements.txt - -# Sample command to run the script -#sh decrypt.sh -# File to decrypt: sample.csv.dat -# shellcheck disable=SC2039 -# shellcheck disable=SC2162 -read -p 'File to decrypt: ' filename -level=$(head -1 "${filename}") -# echo "securityLevel=$level" -# shellcheck disable=SC2039 -if [ "$level" = "TEXT_KEY_ENCRYPTED_DATASET" ]; then - echo "securityLevel=$level" - # shellcheck disable=SC2162 - # shellcheck disable=SC2039 - read -sp 'AES key: ' aesKey - echo - python3 ./src/decrypt-l3.py "${filename}" "${aesKey}" -elif [ "$level" = "PUBLIC_KEY_ENCRYPTED_DATASET" ]; then - echo "securityLevel=$level" - # shellcheck disable=SC2039 - # shellcheck disable=SC2162 - read -p 'Private key path: ' privateKeyPath - # shellcheck disable=SC2039 - # shellcheck disable=SC2162 - read -sp 'Private key passphrase: ' privateKeyPassphrase - echo - python3 ./src/decrypt-l4.py "${filename}" "${privateKeyPath}" "${privateKeyPassphrase}" -else - echo "Not a valid file. Please provide the valid encrypted file." -fi diff --git a/decryption-tool/decryption-tool.zip b/decryption-tool/decryption-tool.zip deleted file mode 100644 index 15b173903..000000000 Binary files a/decryption-tool/decryption-tool.zip and /dev/null differ diff --git a/decryption-tool/src/decrypt-l3.py b/decryption-tool/src/decrypt-l3.py deleted file mode 100644 index 2a6a59231..000000000 --- a/decryption-tool/src/decrypt-l3.py +++ /dev/null @@ -1,33 +0,0 @@ -import base64 -import shutil -import sys -from os import remove - -from utils import * - -filename = sys.argv[1] -password = sys.argv[2] - -# Read the encrypted file (fIn) -with open(filename, 'rb') as fIn: - # Read the first line of the file that contains the security level - securityLevel = fIn.readline().decode('UTF-8') - - passwordLength = len(password) - - cipherText = fIn.readline().decode('UTF-8') - print("passargentered-" + cipherText) - password = generate_32_character_string(password) - aesKey = decryptDataUsingAESKey(base64.b64decode(cipherText), password.upper()) - print("aesKey-" + str(aesKey)) - - # Write the remaining content of the encrypted file to an intermediate file - with open(filename + '.cryptout', 'wb') as cipherOut: - shutil.copyfileobj(fIn, cipherOut) - - # Read the encrypted zip, decrypt it and write to a filename called retrieved.zip - with open(filename + '.cryptout', 'rb') as cipherIn: - with open(filename, "wb") as fOut: - decryptFileContentsWithAESKey(cipherIn, fOut, aesKey) - -remove(filename + '.cryptout') \ No newline at end of file diff --git a/decryption-tool/src/decrypt-l4.py b/decryption-tool/src/decrypt-l4.py deleted file mode 100644 index 191e15f7e..000000000 --- a/decryption-tool/src/decrypt-l4.py +++ /dev/null @@ -1,32 +0,0 @@ -import base64 -import shutil -import sys -from os import remove - -from utils import * - -filename = sys.argv[1] -privateKeyPath = sys.argv[2] -privateKeyPassphrase = sys.argv[3] - -# Read the encrypted file (fIn) -with open(filename, 'rb') as fIn: - # Read the first line of the file that contains the security level - securityLevel = fIn.readline().decode('UTF-8') - - # Read the second line of the file that contains the password encrypted using the - # equivalent public key and decrypt to retrieve the password - cipherText = fIn.readline().decode('UTF-8') - password = decryptDataUsingPrivateKey(base64.b64decode(cipherText), privateKeyPath, privateKeyPassphrase) - print("password-" + str(password)) - - # Write the remaining content of the encrypted file to an intermediate file - with open(filename + '.cryptout', 'wb') as cipherOut: - shutil.copyfileobj(fIn, cipherOut) - - # Read the encrypted zip, decrypt it and write to a filename called retrieved.zip - with open(filename + '.cryptout', 'rb') as cipherIn: - with open(filename, "wb") as fOut: - decryptFileContentsWithAESKey(cipherIn, fOut, password) - -remove(filename + '.cryptout') diff --git a/decryption-tool/src/requirements.txt b/decryption-tool/src/requirements.txt deleted file mode 100644 index c904d2c9c..000000000 --- a/decryption-tool/src/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -autopep8==2.0.2 -cffi==1.15.1 -cryptography==40.0.2 -pyAesCrypt==6.0.0 -pycodestyle==2.10.0 -pycparser==2.21 -pycryptodome==3.17 -six==1.16.0 \ No newline at end of file diff --git a/decryption-tool/src/utils.py b/decryption-tool/src/utils.py deleted file mode 100644 index 1659d1338..000000000 --- a/decryption-tool/src/utils.py +++ /dev/null @@ -1,48 +0,0 @@ -import hashlib - -from Crypto.Cipher import PKCS1_v1_5 -from Crypto.PublicKey import RSA -from Crypto.Cipher import AES -from Crypto.Util.Padding import unpad - -# Decrypt the data using the private key. The cipherText passed should have been generated using the -# corresponding public key. -def decryptDataUsingPrivateKey(cipherText, privateKeyPath, privateKeyPassphrase): - with open(privateKeyPath, 'rb') as privateKeyFile: - privateKey = RSA.importKey(privateKeyFile.read(), passphrase=privateKeyPassphrase) - decryptor = PKCS1_v1_5.new(privateKey) - clearText = decryptor.decrypt(cipherText, "Error while decrypting") - return clearText - -def decryptDataUsingAESKey(cipherText, aesKey): - try: - iv = "\x00" * AES.block_size - cipher = AES.new(aesKey.encode(), AES.MODE_CBC, iv.encode()) - return unpad(cipher.decrypt(cipherText), AES.block_size) - except ValueError: - # remove output file on error - print("Error while decrypt the file." + ValueError) - -def decryptFileContentsWithAESKey(fIn, fOut, password): - try: - iv = "\x00" * AES.block_size - cipher = AES.new(password, AES.MODE_CBC, iv.encode()) - fOut.write(unpad(cipher.decrypt(fIn.read()), AES.block_size)) - except ValueError: - # remove output file on error - print("Error while decrypt the file." + ValueError) - -def generate_32_character_string(input_string): - # Create an MD5 hash object - md5_hash = hashlib.md5() - - # Convert the input string to bytes and update the hash object - md5_hash.update(input_string.encode('utf-8')) - - # Get the hexadecimal representation of the hash digest - hash_digest = md5_hash.hexdigest() - - # Take the first 32 characters of the hash digest - result = hash_digest[:32] - - return result diff --git a/logstash/README.md b/logstash/README.md deleted file mode 100644 index 1706559ac..000000000 --- a/logstash/README.md +++ /dev/null @@ -1,17 +0,0 @@ -## Steps to run logstash in developer machine - -1. Download logstash-6.7.0 and unzip it - -2. Run kafka in localhost:9092 (default settings) - -3. Create a kafka topic - local.lms.audit.events - -4. Replace path of `/var/log/cassandra/triggerAuditLog.log` in `logstash.conf` file with the path of cassandra trigger log (if needed). - -5. Replace `sincedb_path` to a valid one in developer machine - -6. Navigate to logstash folder -```cd {logstash_home}``` - -7. Execute this command to run logstash -```bin/logstash -f {absolute path of logstash.conf} -w 1``` diff --git a/logstash/logstash.conf b/logstash/logstash.conf deleted file mode 100644 index d8ea926e8..000000000 --- a/logstash/logstash.conf +++ /dev/null @@ -1,26 +0,0 @@ -input { - file { - start_position =>"beginning" - path => ["/var/log/cassandra/triggerAuditLog.log"] - sincedb_path => "/var/log/cassandra/.triggerAuditLog" - } -} - -filter { - json { - source => "message" - } -} - -output { - kafka { - bootstrap_servers => "localhost:9092" - codec => plain { - format => "%{message}" - } - message_key => "%{identifier}" - topic_id => "local.lms.audit.events" - retries => 20 - retry_backoff_ms => 180000 - } -} diff --git a/migration/dependency-reduced-pom.xml b/migration/dependency-reduced-pom.xml deleted file mode 100644 index 11d835f22..000000000 --- a/migration/dependency-reduced-pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - sunbird-util - org.sunbird - 1.0-SNAPSHOT - - 4.0.0 - migration - - svg-migrator - - - maven-shade-plugin - 2.4.3 - - - package - - shade - - - - - - org.sunbird.MigrateSunbirdTemplate - 1.0 - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - MigrateSunbirdTemplate - 11 - 11 - - - diff --git a/migration/pom.xml b/migration/pom.xml deleted file mode 100644 index 26d66ff43..000000000 --- a/migration/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - sunbird-util - org.sunbird - 1.0-SNAPSHOT - - 4.0.0 - - migration - - - MigrateSunbirdTemplate - 11 - 11 - - - - - org.apache.tika - tika-core - 1.16 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.1 - - - - com.microsoft.azure - azure-storage - 5.4.0 - - - org.apache.httpcomponents - httpclient - 4.5 - - - org.apache.commons - commons-collections4 - 4.4 - - - - - svg-migrator - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.3 - - - package - - shade - - - - - - org.sunbird.MigrateSunbirdTemplate - 1.0 - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - \ No newline at end of file diff --git a/migration/src/main/java/org/sunbird/MigrateSunbirdTemplate.java b/migration/src/main/java/org/sunbird/MigrateSunbirdTemplate.java deleted file mode 100644 index 5f336c2f5..000000000 --- a/migration/src/main/java/org/sunbird/MigrateSunbirdTemplate.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.sunbird; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.sunbird.util.HttpClientUtil; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; - -public class MigrateSunbirdTemplate { - private static final String sunbirdRecepientName = "${recipientName}"; - private static final String sunbirdQrCodeImage = "${qrCodeImage}"; - private static final String sunbirdCourseName = "${courseName}"; - private static final String sunbirdIssuedDate = "${issuedDate}"; - private static final String sunbirdMaxFontSize = "${maxFontSize}"; - private static final String sunbirdMinFontSize = "${minFontSize}"; - private static final String rcRecepientName = "{{credentialSubject.recipientName}}"; - private static final String rcQrCodeImage = "{{qrCode}}"; - private static final String rcCourseName = "{{credentialSubject.trainingName}}"; - private static final String rcIssuedDate = "{{dateFormat issuanceDate \"DD MMMM YYYY\"}}"; - private static final String rcMaxFontSize = "{{maxFontSize}}"; - private static final String rcMinFontSize = "{{minFontSize}}"; - private static FileWriter fileWriter = null; - private static BufferedWriter bufferedWriter = null; - - public static void main(String[] args) { - String domain = args[0]; - String offset = args[1]; - String limit = args[2]; - - String processName = ""; - String oldFontUrl = ""; - String cnameUrl = ""; - if (args.length > 3) { - processName = args[3]; - oldFontUrl = args[4]; - cnameUrl = args[5]; - } - - try { - fileWriter = new FileWriter("config", true); - bufferedWriter = new BufferedWriter(fileWriter); - new HashMap(); - String uri = "https://" + domain + "/api/content/v1/search"; - Map req = new HashMap(); - Map request = new HashMap(); - Map filters = new HashMap(); - List certTypes = new ArrayList(); - certTypes.add("cert template layout"); - certTypes.add("cert template"); - filters.put("certType", certTypes); - filters.put("mediaType", "image"); - request.put("filters", filters); - String[] fields = new String[]{"artifactUrl", "identifier"}; - request.put("fields", fields); - request.put("offset", Integer.parseInt(offset)); - request.put("limit", Integer.parseInt(limit)); - req.put("request", request); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Accept", "application/json"); - Map response = post(req, headers, uri); - System.out.println("Response : " + response); - if (MapUtils.isNotEmpty(response)) { - Map result = (Map)response.get("result"); - if (MapUtils.isNotEmpty(result)) { - int count = (Integer)result.get("count"); - List> list = (List)result.get("content"); - if (count > 0 && CollectionUtils.isNotEmpty(list)) { - Iterator var15 = list.iterator(); - - while(var15.hasNext()) { - Map map = (Map)var15.next(); - String url = (String)map.get("artifactUrl"); - String identifier = (String)map.get("identifier"); - String[] strArray = url.split("/"); - String fileName = strArray[strArray.length - 1]; - migrate(identifier, fileName, url, processName, oldFontUrl, cnameUrl); - bufferedWriter.write(map.toString()); - bufferedWriter.write("\n"); - } - } - } - } - } catch (Exception var29) { - System.out.println("Exception while writing file"); - var29.printStackTrace(); - } finally { - try { - bufferedWriter.close(); - } catch (IOException var28) { - System.out.println("Exception while closing the file."); - } - - } - - } - - public static Map post(Map requestBody, Map headers, String uri) { - try { - ObjectMapper mapper = new ObjectMapper(); - HttpClientUtil client = HttpClientUtil.getInstance(); - String reqBody = mapper.writeValueAsString(requestBody); - System.out.println("Composite search api called."); - String response = client.post(uri, reqBody, headers); - System.out.println("Composite search api response." + response); - return (Map)mapper.readValue(response, new TypeReference>() { - }); - } catch (Exception var7) { - System.out.println("Composite search api call: Exception occurred = "); - var7.printStackTrace(); - return new HashMap(); - } - } - - private static void migrate(String identifier, String fileName, String url, String processName, String oldFontUrl, String cnameUrl) { - BufferedWriter bw = null; - - try { - File file = new File(identifier); - boolean isCreated = file.mkdir(); - if (isCreated) { - String var10002 = file.getAbsolutePath(); - File newFile = new File(var10002 + File.separator + fileName); - FileWriter myWriter = new FileWriter(newFile, true); - bw = new BufferedWriter(myWriter); - URL svg = new URL(url); - BufferedReader br = new BufferedReader(new InputStreamReader(svg.openStream())); - - String st; - while((st = br.readLine()) != null) { - - if (processName.contains("font_migration")) { - st = st.replace(oldFontUrl, cnameUrl); - } else { - - if (st.contains("${recipientName}")) { - st = st.replace("${recipientName}", "{{credentialSubject.recipientName}}"); - } - - if (st.contains("${qrCodeImage}")) { - st = st.replace("${qrCodeImage}", "{{qrCode}}"); - } - - if (st.contains("${courseName}")) { - st = st.replace("${courseName}", "{{credentialSubject.trainingName}}"); - } - - if (st.contains("${issuedDate}")) { - st = st.replace("${issuedDate}", "{{dateFormat issuanceDate \"DD MMMM YYYY\"}}"); - } - - if (st.contains("${maxFontSize}")) { - st = st.replace("${maxFontSize}", "{{maxFontSize}}"); - } - - if (st.contains("${minFontSize}")) { - st = st.replace("${minFontSize}", "{{minFontSize}}"); - } - } - - bw.write(st); - bw.newLine(); - } - } - } catch (Exception var19) { - var19.printStackTrace(); - System.out.println("Exception while writing svg file."); - } finally { - try { - bw.close(); - } catch (IOException var18) { - System.out.println("Exception while closing the file."); - } - - } - - } -} \ No newline at end of file diff --git a/migration/src/main/java/org/sunbird/util/HttpClientUtil.java b/migration/src/main/java/org/sunbird/util/HttpClientUtil.java deleted file mode 100644 index 7e74be8f3..000000000 --- a/migration/src/main/java/org/sunbird/util/HttpClientUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.sunbird.util; - -import java.io.PrintStream; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import org.apache.commons.collections4.MapUtils; -import org.apache.http.HeaderElement; -import org.apache.http.HttpEntity; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ConnectionKeepAliveStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.message.BasicHeaderElementIterator; -import org.apache.http.util.EntityUtils; - -public class HttpClientUtil { - private static CloseableHttpClient httpclient = null; - private static HttpClientUtil httpClientUtil; - - private HttpClientUtil() { - ConnectionKeepAliveStrategy keepAliveStrategy = (response, context) -> { - BasicHeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator("Keep-Alive")); - - String param; - String value; - do { - if (!it.hasNext()) { - return 180000L; - } - - HeaderElement he = it.nextElement(); - param = he.getName(); - value = he.getValue(); - } while(value == null || !param.equalsIgnoreCase("timeout")); - - return Long.parseLong(value) * 1000L; - }; - PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); - connectionManager.setMaxTotal(200); - connectionManager.setDefaultMaxPerRoute(150); - connectionManager.closeIdleConnections(180L, TimeUnit.SECONDS); - httpclient = HttpClients.custom().setConnectionManager(connectionManager).useSystemProperties().setKeepAliveStrategy(keepAliveStrategy).build(); - } - - public static HttpClientUtil getInstance() { - if (httpClientUtil == null) { - Class var0 = HttpClientUtil.class; - synchronized(HttpClientUtil.class) { - if (httpClientUtil == null) { - httpClientUtil = new HttpClientUtil(); - } - } - } - - return httpClientUtil; - } - - public String post(String requestURL, String params, Map headers) { - CloseableHttpResponse response = null; - - String var6; - try { - HttpPost httpPost = new HttpPost(requestURL); - if (MapUtils.isNotEmpty(headers)) { - Iterator var24 = headers.entrySet().iterator(); - - while(var24.hasNext()) { - Entry entry = (Entry)var24.next(); - httpPost.addHeader((String)entry.getKey(), (String)entry.getValue()); - } - } - - StringEntity entity = new StringEntity(params); - httpPost.setEntity(entity); - response = httpclient.execute(httpPost); - int status = response.getStatusLine().getStatusCode(); - if (status >= 200 && status < 300) { - HttpEntity httpEntity = response.getEntity(); - byte[] bytes = EntityUtils.toByteArray(httpEntity); - StatusLine sl = response.getStatusLine(); - PrintStream var10000 = System.out; - int var10001 = sl.getStatusCode(); - var10000.println("Response from post call : " + var10001 + " - " + sl.getReasonPhrase()); - String var11 = new String(bytes); - return var11; - } - - String var8 = ""; - return var8; - } catch (Exception var22) { - System.out.println("Exception occurred while calling post method"); - var22.printStackTrace(); - var6 = ""; - } finally { - if (null != response) { - try { - response.close(); - } catch (Exception var21) { - System.out.println("Exception occurred while closing post response object"); - } - } - - } - - return var6; - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 48d5ef036..adea776e5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,4 @@ 1.0-SNAPSHOT pom Sunbird Utils - - sunbird-es-utils - sunbird-platform-core - diff --git a/scripts/check-java-file-format b/scripts/check-java-file-format deleted file mode 100755 index 45b188378..000000000 --- a/scripts/check-java-file-format +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -FILES_TO_SKIP="^(src-gen|third-party|(test/.*\/testdata\/)).*\.java$" - -JAR_PATH=$1 -FILE_PATH=$2 - -# Test if the file is Java file -echo "${FILE_PATH}" | grep -Eqi "\.java$" || exit 1 - -# Test if the file should be skipped -echo "${FILE_PATH}" | grep -Eqi "${FILES_TO_SKIP}" && exit 0 - -# Try to format the file -java -jar "${JAR_PATH}" -i "${FILE_PATH}" - -exit 0 diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100755 index e0966cf58..000000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" - -cp "${REPO_ROOT_DIR}/git-hooks/pre-commit" "${REPO_ROOT_DIR}/.git/hooks/" diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIds.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIds.zip deleted file mode 100644 index f6f3340a8..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIds.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIdsBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIdsBin.zip deleted file mode 100644 index 28cc93c3b..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/IdentifyUnencryptedUserIdsBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/Sync.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/Sync.zip deleted file mode 100644 index 91edc11e7..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/Sync.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/SyncBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/SyncBin.zip deleted file mode 100644 index 436cea659..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/SyncBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryption.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryption.zip deleted file mode 100644 index d92ea8a00..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryption.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryptionBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryptionBin.zip deleted file mode 100644 index 069f7df17..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserEncryptionBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityReset.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityReset.zip deleted file mode 100644 index da8663095..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityReset.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityResetBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityResetBin.zip deleted file mode 100644 index 96f1b5bc9..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserProfileVisibilityResetBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSync.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSync.zip deleted file mode 100644 index 4fd557e3b..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSync.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSyncBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSyncBin.zip deleted file mode 100644 index 387a3afb9..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/common/UserSyncBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigration.zip deleted file mode 100644 index 2f7d49f83..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigrationBin.zip deleted file mode 100644 index 88123361e..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotCourseBatchMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigration.zip deleted file mode 100644 index 17172b77a..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigrationBin.zip deleted file mode 100644 index 89a8bcfef..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotOrgStatusMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigration.zip deleted file mode 100644 index 35be4ad6f..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigrationBin.zip deleted file mode 100644 index 71c937ed7..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigration.zip deleted file mode 100644 index fcc8bf61e..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigrationBin.zip deleted file mode 100644 index 5bfe20858..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/custom/rajasthan-pilot/RJPilotUserOrgMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigration.zip deleted file mode 100644 index 94d7696dd..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigrationBin.zip deleted file mode 100644 index 1736df2ed..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgExternalIdentityMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannel.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannel.zip deleted file mode 100644 index 6eb0a4c0e..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannel.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannelBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannelBin.zip deleted file mode 100644 index 63932524d..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgMigrationUpdateChannelBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSync.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSync.zip deleted file mode 100644 index c17b392e5..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSync.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSyncBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSyncBin.zip deleted file mode 100644 index 5e1b4dbb1..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.13/OrgSyncBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigration.zip deleted file mode 100644 index f0a8d618c..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigrationBin.zip deleted file mode 100644 index c22fa038e..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserEmailCaseChangeMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginId.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginId.zip deleted file mode 100644 index c92c34753..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginId.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginIdBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginIdBin.zip deleted file mode 100644 index 9937c30ad..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.14/UserMigrationSetLoginIdBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUser.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUser.zip deleted file mode 100644 index 70b1691c3..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUser.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUserBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUserBin.zip deleted file mode 100644 index 9000f78e2..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/DeleteKeycloakUserBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigration.zip deleted file mode 100644 index 0e28c4449..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigrationBin.zip deleted file mode 100644 index e5d35c307..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.15/maskEmailPhoneMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannel.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannel.zip deleted file mode 100644 index b17fc6636..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannel.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannelBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannelBin.zip deleted file mode 100644 index 54ce3adc0..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.7/UserMigrationUpdateChannelBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigration.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigration.zip deleted file mode 100644 index 321581ba4..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigration.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigrationBin.zip b/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigrationBin.zip deleted file mode 100644 index 5140f998f..000000000 Binary files a/sunbird-cassandra-migration/cassandra-migration-etl/r1.8/UserExternalIdentityMigrationBin.zip and /dev/null differ diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/V1.46_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/V1.46_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/V1.46_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/V1.46_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.26_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.26_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.26_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.26_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.31_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.31_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.31_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.31_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.33_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.33_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.33_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.33_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.37_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.37_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.37_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.37_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.40_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.40_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.40_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.40_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.41_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.41_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.41_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.41_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.50_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.50_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.50_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.50_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.51_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.51_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.51_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.51_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.52_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.52_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.52_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.52_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.57_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.57_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.57_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.57_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.59_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.59_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/qmzbm_form_service/V1.59_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/qmzbm_form_service/V1.59_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.0_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.0_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.0_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.0_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.100_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.100_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.100_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.100_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.101_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.101_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.101_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.101_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.104_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.104_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.104_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.104_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.105_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.105_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.105_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.105_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.106_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.106_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.106_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.106_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.107_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.107_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.107_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.107_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.10_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.10_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.10_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.10_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.110_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.110_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.110_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.110_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.111_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.111_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.111_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.111_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.113_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.113_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.113_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.113_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.116_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.116_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.116_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.116_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.117_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.117_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.117_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.117_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.118_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.118_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.118_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.118_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.119_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.119_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.119_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.119_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.11_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.11_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.11_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.11_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.120_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.120_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.120_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.120_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.121_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.121_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.121_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.121_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.122_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.122_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.122_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.122_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.123_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.123_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.123_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.123_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.124_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.124_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.124_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.124_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.127_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.127_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.127_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.127_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.12_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.12_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.12_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.12_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.133_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.133_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.133_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.133_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.134_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.134_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.134_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.134_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.135_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.135_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.135_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.135_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.137_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.137_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.137_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.137_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.139_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.139_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.139_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.139_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.13_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.13_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.13_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.13_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.143_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.143_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.143_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.143_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.144_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.144_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.144_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.144_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.146_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.146_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.146_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.146_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.14_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.14_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.14_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.14_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.15_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.15_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.15_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.15_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.16_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.16_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.16_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.16_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.17_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.17_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.17_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.17_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.18_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.18_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.18_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.18_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.19_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.19_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.19_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.19_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.1_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.1_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.1_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.1_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.20_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.20_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.20_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.20_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.21_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.21_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.21_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.21_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.22_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.22_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.22_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.22_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.23_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.23_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.23_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.23_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.24_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.24_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.24_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.24_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.25_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.25_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.25_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.25_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.26_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.26_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.26_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.26_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.27_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.27_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.27_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.27_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.29_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.29_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.29_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.29_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.30_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.30_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.30_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.30_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.31_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.31_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.31_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.31_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.32_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.32_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.32_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.32_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.33_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.33_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.33_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.33_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.34_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.34_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.34_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.34_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.35_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.35_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.35_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.35_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.36_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.36_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.36_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.36_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.37_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.37_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.37_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.37_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.38_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.38_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.38_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.38_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.39_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.39_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.39_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.39_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.3_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.3_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.3_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.3_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.40_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.40_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.40_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.40_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.42_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.42_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.42_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.42_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.43_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.43_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.43_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.43_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.44_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.44_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.44_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.44_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.45_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.45_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.45_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.45_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.46_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.46_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.46_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.46_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.47_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.47_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.47_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.47_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.48_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.48_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.48_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.48_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.49_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.49_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.49_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.49_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.4_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.4_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.4_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.4_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.53_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.53_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.53_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.53_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.54_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.54_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.54_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.54_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.55_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.55_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.55_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.55_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.56_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.56_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.56_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.56_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.58_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.58_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.58_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.58_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.5_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.5_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.5_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.5_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.60_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.60_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.60_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.60_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.61_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.61_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.61_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.61_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.62_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.62_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.62_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.62_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.63_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.63_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.63_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.63_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.64_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.64_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.64_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.64_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.65_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.65_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.65_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.65_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.67_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.67_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.67_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.67_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.68_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.68_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.68_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.68_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.69_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.69_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.69_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.69_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.6_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.6_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.6_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.6_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.70_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.70_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.70_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.70_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.71_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.71_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.71_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.71_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.72_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.72_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.72_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.72_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.74_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.74_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.74_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.74_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.75_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.75_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.75_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.75_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.76_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.76_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.76_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.76_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.78_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.78_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.78_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.78_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.79_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.79_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.79_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.79_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.7_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.7_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.7_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.7_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.80_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.80_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.80_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.80_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.83_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.83_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.83_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.83_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.84_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.84_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.84_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.84_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.85_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.85_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.85_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.85_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.88_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.88_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.88_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.88_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.89_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.89_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.89_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.89_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.8_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.8_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.8_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.8_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.90_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.90_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.90_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.90_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.91_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.91_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.91_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.91_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.92_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.92_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.92_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.92_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.93_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.93_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.93_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.93_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.94_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.94_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.94_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.94_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.95_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.95_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.95_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.95_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.96_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.96_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.96_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.96_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.97_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.97_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.97_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.97_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.98_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.98_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.98_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.98_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.99_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.99_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.99_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.99_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.9_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.9_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/V1.9_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/V1.9_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/v1.115_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/v1.115_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/v1.115_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/v1.115_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/v1.28_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/v1.28_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird/v1.28_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird/v1.28_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.102_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.102_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.102_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.102_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.103_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.103_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.103_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.103_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.108_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.108_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.108_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.108_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.109_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.109_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.109_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.109_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.112_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.112_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.112_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.112_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.114_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.114_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.114_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.114_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.118_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.118_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.118_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.118_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.120_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.120_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.120_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.120_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.125_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.125_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.125_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.125_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.138_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.138_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.138_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.138_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.140_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.140_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.140_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.140_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.141_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.141_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.141_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.141_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.145_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.145_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.145_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.145_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.66_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.66_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.66_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.66_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.73_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.73_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.73_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.73_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.77_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.77_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.77_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.77_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.81_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.81_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.81_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.81_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.82_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.82_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.82_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.82_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.86_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.86_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.86_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.86_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.87_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.87_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_courses/V1.87_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_courses/V1.87_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_groups/V1.110_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_groups/V1.110_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_groups/V1.110_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_groups/V1.110_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_groups/V1.111_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_groups/V1.111_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_groups/V1.111_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_groups/V1.111_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.126_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.126_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.126_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.126_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.128_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.128_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.128_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.128_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.129_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.129_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.129_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.129_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.130_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.130_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.130_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.130_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.131_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.131_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.131_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.131_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.132_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.132_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.132_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.132_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.136_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.136_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.136_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.136_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.142_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.142_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_notifications/V1.142_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_notifications/V1.142_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_programs/V1.1_cassandra.cql b/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_programs/V1.1_cassandra.cql similarity index 100% rename from sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/sunbird_programs/V1.1_cassandra.cql rename to sunbird-cassandra-migration/cassandra-migration/src/main/resources/db_migration/cassandra/sunbird_programs/V1.1_cassandra.cql diff --git a/sunbird-cassandra-migration/cassandra-trigger/README.md b/sunbird-cassandra-migration/cassandra-trigger/README.md deleted file mode 100644 index 682be31d8..000000000 --- a/sunbird-cassandra-migration/cassandra-trigger/README.md +++ /dev/null @@ -1,36 +0,0 @@ -Steps to enable Cassandra Triggers: - -1. Compile cassandra-trigger module with all dependency. - -``` -cd cassandra-trigger -mvn clean compile assembly:single -``` - -2. Copy the compiled JAR (i.e. cassandra-trigger-1.0.jar) to cassandra triggers (e.g. /etc/cassandra/triggers) folder. - -3. Restart Cassandra. - -``` -sudo service cassandra stop -sudo service cassandra start -``` - -4. Trigger can be applied on a table using below command. - -``` -CREATE TRIGGER ON USING 'org.sunbird.cassandra.Trigger'; -``` - -e.g. -``` -CREATE TRIGGER location_trigger ON sunbird.location USING 'org.sunbird.cassandra.Trigger'; -``` - -5. After trigger is created on a table, any modification of data in table will result in a corresponding audit event to be written into the audit log file. The default location of audit log file is "/var/log/cassandra/triggerAuditLog.log". - -6. To customise the log file path, edit JVM_OPTS in /etc/cassandra/cassandra-env.sh as mentioned below and restart Cassandra. - -``` -JVM_OPTS="$JVM_OPTS -Dsunbird_cassandra_audit_file_path=" -``` diff --git a/sunbird-cassandra-migration/cassandra-trigger/pom.xml b/sunbird-cassandra-migration/cassandra-trigger/pom.xml deleted file mode 100644 index 42ec5787f..000000000 --- a/sunbird-cassandra-migration/cassandra-trigger/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - 4.0.0 - org.sunbird - cassandra-trigger - 1.0 - cassandra-trigger - - UTF-8 - 1.8 - 1.8 - - - - junit - junit - 4.11 - test - - - commons-lang - commons-lang - 2.6 - - - org.slf4j - slf4j-jdk14 - 1.7.25 - - - org.cassandraunit - cassandra-unit - 3.1.3.2 - - - com.datastax.cassandra - cassandra-driver-core - 3.1.0 - shaded - - - - io.netty - * - - - - - com.datastax.cassandra - cassandra-driver-mapping - 3.1.0 - - - log4j - log4j - 1.2.17 - - - com.fasterxml.jackson.core - jackson-databind - 2.9.5 - - - - - - - maven-clean-plugin - 3.1.0 - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - maven-assembly-plugin - - - - fully.qualified.MainClass - - - - jar-with-dependencies - - false - - - - - - diff --git a/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/cassandra/Trigger.java b/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/cassandra/Trigger.java deleted file mode 100644 index eb0ca8a6d..000000000 --- a/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/cassandra/Trigger.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.sunbird.cassandra; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.config.ColumnDefinition; -import org.apache.cassandra.db.Clustering; -import org.apache.cassandra.db.ClusteringPrefix; -import org.apache.cassandra.db.DecoratedKey; -import org.apache.cassandra.db.DeletionTime; -import org.apache.cassandra.db.Mutation; -import org.apache.cassandra.db.marshal.AbstractType; -import org.apache.cassandra.db.marshal.CompositeType; -import org.apache.cassandra.db.marshal.ListType; -import org.apache.cassandra.db.marshal.MapType; -import org.apache.cassandra.db.marshal.SetType; -import org.apache.cassandra.db.partitions.Partition; -import org.apache.cassandra.db.rows.Cell; -import org.apache.cassandra.db.rows.CellPath; -import org.apache.cassandra.db.rows.Row; -import org.apache.cassandra.db.rows.Unfiltered; -import org.apache.cassandra.db.rows.UnfilteredRowIterator; -import org.apache.cassandra.triggers.ITrigger; -import org.sunbird.common.audit.AuditUtil; - -public class Trigger implements ITrigger { - - private static final String OBJECT_TYPE = "objectType"; - private static final String OPERATION_TYPE = "operationType"; - private static final String UPDATE_ROW = "UPSERT"; - private static final String DELETE_ROW = "DELETE"; - private static final String FILE_TO_WRITE; - private static ObjectMapper mapper = new ObjectMapper(); - - static { - String filePath = System.getProperty("sunbird_cassandra_audit_file_path"); - if (filePath == null) { - filePath = "/var/log/cassandra/triggerAuditLog.log"; - } - FILE_TO_WRITE = filePath; - } - - @Override - public Collection augment(Partition update) { - Map resultMap = processEvent(update); - Map auditEventMap = AuditUtil.getAuditEvent(resultMap); - BufferedWriter out = null; - try { - out = new BufferedWriter(new FileWriter(FILE_TO_WRITE, true)); - out.write(mapper.writeValueAsString(auditEventMap) + "\n"); - } catch (IOException e) { - System.out.println( - "Trigger:augment: IOException occurred with error message = " + e.getMessage()); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - System.out.println( - "Trigger:augment: Exception occured with error message = " + e.getMessage()); - } - } - } - return null; - } - - private Map getPartitionKeyData(ByteBuffer keyValueBuffer, CFMetaData metadata) { - List partitionKeyColumns = metadata.partitionKeyColumns(); - Map partitionKeyValueMap = new HashMap<>(); - - // This is only for handling partition key of size = 1 - if (partitionKeyColumns.size() == 1) { - - AbstractType pkColumnType = partitionKeyColumns.get(0).type; - Object pkValue = pkColumnType.compose(keyValueBuffer); - - if (pkValue != null) { - partitionKeyValueMap.put(partitionKeyColumns.get(0).name.toString(), pkValue); - } - } else { - // This is handling composite partition key. Cassandra have CompositeType class for handling - // this - for (int index = 0; index < partitionKeyColumns.size(); index++) { - String pkColumnName = partitionKeyColumns.get(index).name.toString(); - AbstractType pkColumnType = partitionKeyColumns.get(index).type; - - ByteBuffer valueBuffer = CompositeType.extractComponent(keyValueBuffer, index); - Object pkValue = pkColumnType.compose(valueBuffer); - - if (pkValue != null) { - partitionKeyValueMap.put(pkColumnName, pkValue); - } - } - } - return partitionKeyValueMap; - } - - private Map getClusterKeyData(Partition update, Unfiltered next) { - Map clusterKeyValueMap = new HashMap<>(); - - List clusteringColumns = update.metadata().clusteringColumns(); - ClusteringPrefix clustering = next.clustering(); - - for (int index = 0; index < clustering.size(); index++) { - ColumnDefinition columnDefinition = clusteringColumns.get(index); - - String columnName = columnDefinition.name.toString(); - AbstractType columnType = columnDefinition.type; - - Object ckValue = columnType.compose(clustering.get(index)); - clusterKeyValueMap.put(columnName, ckValue); - } - - return clusterKeyValueMap; - } - - public Map processEvent(Partition partition) { - try { - DecoratedKey partitionKey = partition.partitionKey(); - - Map partitionKeyData = - getPartitionKeyData(partitionKey.getKey(), partition.metadata()); - - UnfilteredRowIterator unfilteredIterator = partition.unfilteredIterator(); - - // Is delete operation? - DeletionTime levelDeletion = partition.partitionLevelDeletion(); - if (!levelDeletion.isLive()) { - Map eventMap = new HashMap<>(); - eventMap.put(OPERATION_TYPE, DELETE_ROW); - eventMap.put(OBJECT_TYPE, partition.metadata().cfName); - eventMap.putAll(partitionKeyData); - return eventMap; - } - while (unfilteredIterator.hasNext()) { - Unfiltered next = unfilteredIterator.next(); - Map clusterKeyData = getClusterKeyData(partition, next); - - ClusteringPrefix clustering = next.clustering(); - Row row = partition.getRow((Clustering) clustering); - - Iterable cells = row.cells(); - - Map eventMap = new HashMap<>(); - Map updateColumnCollectionInfo = new HashMap<>(); - Map deletedDataMap = new HashMap<>(); - for (Cell cell : cells) { - AbstractType columnType = getColumnType(cell); - if (columnType instanceof MapType) { - processMapDataType(eventMap, updateColumnCollectionInfo, cell); - } else if (columnType instanceof SetType) { - processSetDataType(eventMap, deletedDataMap, cell); - } else if (columnType instanceof ListType) { - processListDataType(eventMap, updateColumnCollectionInfo, cell); - } else { - String columnName = getColumnName(cell); - if (cell.isLive(0)) { - eventMap.put(columnName, getCellValue(cell)); - } else { - eventMap.put(columnName, null); - } - } - } - eventMap.put(OPERATION_TYPE, UPDATE_ROW); - eventMap.put(OBJECT_TYPE, partition.metadata().cfName); - eventMap.putAll(partitionKeyData); - eventMap.putAll(clusterKeyData); - return eventMap; - } - } catch (RuntimeException e) { - System.out.println( - "Trigger:processEvent: RuntimeException occurred with error message = " + e.getMessage()); - } - - return null; - } - - private void processMapDataType( - Map dataMap, Map updateColumnCollectionInfo, Cell cell) { - String columnName = getColumnName(cell); - AbstractType columnType = getColumnType(cell); - Object cellValue = getCellValue(cell); - MapType mapType = (MapType) columnType; - - AbstractType keysType = mapType.getKeysType(); - CellPath path = cell.path(); - int size = path.size(); - for (int i = 0; i < size; i++) { - ByteBuffer byteBuffer = path.get(i); - Object cellKey = keysType.compose(byteBuffer); - Map map = new HashMap(); - if (!dataMap.containsKey(columnName)) { - dataMap.put(columnName, map); - } else { - map = (Map) dataMap.get(columnName); - } - if (cell.isLive(0)) { - map.put(cellKey.toString(), cellValue); - } else { - if (!updateColumnCollectionInfo.containsKey(columnName)) { - updateColumnCollectionInfo.put(columnName, columnType.getClass().getName()); - } - map.put(cellKey.toString(), null); - } - } - } - - private void processSetDataType( - Map dataMap, Map deletedDataMap, Cell cell) { - String columnName = getColumnName(cell); - Object cellValue = getCellValue(cell); - AbstractType columnType = getColumnType(cell); - MapType mapType = (MapType) columnType; - CellPath path = cell.path(); - int size = path.size(); - for (int i = 0; i < size; i++) { - ByteBuffer byteBuffer = path.get(i); - AbstractType keysType = ((SetType) columnType).getElementsType(); - cellValue = keysType.compose(byteBuffer); - } - if (cell.isLive(0)) { - if (!dataMap.containsKey(columnName)) { - ArrayList arrayList = new ArrayList(); - arrayList.add(cellValue); - dataMap.put(columnName, arrayList); - } else { - ArrayList arrayList = (ArrayList) dataMap.get(columnName); - if (!arrayList.contains(cellValue)) { - arrayList.add(cellValue); - } - } - } else { - if (!deletedDataMap.containsKey(columnName)) { - ArrayList arrayList = new ArrayList(); - arrayList.add(cellValue); - deletedDataMap.put(columnName, arrayList); - } else { - ArrayList arrayList = (ArrayList) deletedDataMap.get(columnName); - if (!arrayList.contains(cellValue)) { - arrayList.add(cellValue); - } - } - } - } - - private void processListDataType( - Map dataMap, Map updateColumnCollectionInfo, Cell cell) { - String columnName = getColumnName(cell); - Object cellValue = getCellValue(cell); - AbstractType columnType = getColumnType(cell); - updateColumnCollectionInfo.put(columnName, columnType.getClass().getName()); - if (cell.isLive(0)) { - if (!dataMap.containsKey(columnName)) { - ArrayList arrayList = new ArrayList(); - arrayList.add(cellValue); - dataMap.put(columnName, arrayList); - } else { - ArrayList arrayList = (ArrayList) dataMap.get(columnName); - if (!arrayList.contains(cellValue)) { - arrayList.add(cellValue); - } - } - } - } - - private String getColumnName(Cell cell) { - return cell.column().name + ""; - } - - private Object getCellValue(Cell cell) { - return ((AbstractType) cell.column().cellValueType()).compose(cell.value()); - } - - private AbstractType getColumnType(Cell cell) { - return cell.column().type; - } -} diff --git a/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/common/audit/AuditUtil.java b/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/common/audit/AuditUtil.java deleted file mode 100644 index 0a4053807..000000000 --- a/sunbird-cassandra-migration/cassandra-trigger/src/main/java/org/sunbird/common/audit/AuditUtil.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.sunbird.common.audit; - -import java.time.Instant; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class AuditUtil { - - private static final Map> tablePrimaryKeyMap = new HashMap<>(); - - static { - tablePrimaryKeyMap.put("assessment_eval", Arrays.asList("id")); - tablePrimaryKeyMap.put("bulk_upload_process_task", Arrays.asList("processid,", "sequenceid")); - tablePrimaryKeyMap.put("course_management", Arrays.asList("id")); - tablePrimaryKeyMap.put("url_action", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_auth", Arrays.asList("id")); - tablePrimaryKeyMap.put("system_settings", Arrays.asList("id")); - tablePrimaryKeyMap.put("client_info", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_courses", Arrays.asList("id")); - tablePrimaryKeyMap.put("subject", Arrays.asList("id")); - tablePrimaryKeyMap.put("content_consumption", Arrays.asList("id")); - tablePrimaryKeyMap.put("role_group", Arrays.asList("id")); - tablePrimaryKeyMap.put("assessment_item", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_badge_assertion", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_skills", Arrays.asList("id")); - tablePrimaryKeyMap.put("geo_location", Arrays.asList("id")); - tablePrimaryKeyMap.put("location", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_org", Arrays.asList("id")); - tablePrimaryKeyMap.put("media_type", Arrays.asList("id")); - tablePrimaryKeyMap.put("badge", Arrays.asList("id")); - tablePrimaryKeyMap.put("master_action", Arrays.asList("id")); - tablePrimaryKeyMap.put("badge_class_extension", Arrays.asList("id")); - tablePrimaryKeyMap.put("cassandra_migration_version", Arrays.asList("version")); - tablePrimaryKeyMap.put("page_management", Arrays.asList("id")); - tablePrimaryKeyMap.put("course_enrollment", Arrays.asList("id")); - tablePrimaryKeyMap.put("org_external_identity", Arrays.asList("provider", "externalid")); - tablePrimaryKeyMap.put("email_template", Arrays.asList("name")); - tablePrimaryKeyMap.put( - "usr_external_identity", Arrays.asList("provider", "idtype", "externalid")); - tablePrimaryKeyMap.put("user_job_profile", Arrays.asList("id")); - tablePrimaryKeyMap.put("bulk_upload_process", Arrays.asList("id")); - tablePrimaryKeyMap.put("org_mapping", Arrays.asList("id")); - tablePrimaryKeyMap.put("address", Arrays.asList("id")); - tablePrimaryKeyMap.put("report_tracking", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_example", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_external_identity", Arrays.asList("id")); - tablePrimaryKeyMap.put("tenant_preference", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_action_role", Arrays.asList("id")); - tablePrimaryKeyMap.put("cassandra_migration_version_counts", Arrays.asList("name")); - tablePrimaryKeyMap.put("skills", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_notes", Arrays.asList("id")); - tablePrimaryKeyMap.put("rate_limit", Arrays.asList("key", "unit")); - tablePrimaryKeyMap.put("course_publish_status", Arrays.asList("id")); - tablePrimaryKeyMap.put("action_group", Arrays.asList("id")); - tablePrimaryKeyMap.put("org_type", Arrays.asList("id")); - tablePrimaryKeyMap.put("course_batch", Arrays.asList("id")); - tablePrimaryKeyMap.put("user", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_education", Arrays.asList("id")); - tablePrimaryKeyMap.put("content_badge_association", Arrays.asList("id")); - tablePrimaryKeyMap.put("user_badge", Arrays.asList("id")); - tablePrimaryKeyMap.put("organisation", Arrays.asList("id")); - tablePrimaryKeyMap.put("page_section", Arrays.asList("id")); - } - - public static Map getAuditEvent(Map triggerMap) { - Map resultMap = getIdentifier(triggerMap); - resultMap.put("ets", System.currentTimeMillis()); - String operationType = (String) triggerMap.remove("operationType"); - String objectType = (String) triggerMap.remove("objectType"); - getFormattedEvent(triggerMap, resultMap); - - resultMap.put("operationType", operationType); - resultMap.put("eventType", "transactional"); - resultMap.put("userId", "ANONYMOUS"); - resultMap.put("createdOn", Instant.now().toString()); - resultMap.put("objectType", objectType); - return resultMap; - } - - private static Map getIdentifier(Map triggerMap) { - Map resultMap = new HashMap<>(); - String tableName = (String) triggerMap.get("objectType"); - if (tablePrimaryKeyMap.get(tableName) != null) { - List primaryKeyList = tablePrimaryKeyMap.get(tableName); - if (primaryKeyList.size() == 1) { - resultMap.put("identifier", triggerMap.get(primaryKeyList.get(0))); - } else { - Map hashMap = new HashMap<>(); - for (int i = 0; i < primaryKeyList.size(); i++) { - String key = primaryKeyList.get(i); - if (triggerMap.get(key) != null) { - hashMap.put(key, triggerMap.get(key)); - } - } - resultMap.put("identifier", hashMap); - } - } - return resultMap; - } - - private static void getFormattedEvent( - Map triggerMap, Map resultMap) { - Map newMap = new HashMap<>(); - for (Map.Entry set : triggerMap.entrySet()) { - Map newValueMap = new HashMap<>(); - newValueMap.put("nv", set.getValue()); - newMap.put(set.getKey(), newValueMap); - } - Map eventMap = new HashMap<>(); - eventMap.put("properties", newMap); - resultMap.put("event", eventMap); - } -} diff --git a/sunbird-es-utils/.gitignore b/sunbird-es-utils/.gitignore deleted file mode 100644 index 55977f8f9..000000000 --- a/sunbird-es-utils/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/target/ -.classpath -.project -.settings -/bin/ - -*.iml diff --git a/sunbird-es-utils/pom.xml b/sunbird-es-utils/pom.xml deleted file mode 100644 index 6576405b3..000000000 --- a/sunbird-es-utils/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - 4.0.0 - org.sunbird - sunbird-es-utils - 1.0-SNAPSHOT - Sunbird ElasticSearch Utils - - - 2.3.1 - 1.8 - 1.8 - UTF-8 - UTF-8 - 1.1.1 - - - - - org.elasticsearch.client - elasticsearch-rest-high-level-client - 6.3.2 - - - - org.elasticsearch.client - transport - 6.3.0 - - - org.apache.logging.log4j - log4j-api - 2.8.2 - - - org.apache.logging.log4j - log4j-core - 2.8.2 - - - org.sunbird - common-util - 0.0.1-SNAPSHOT - - - junit - junit - 4.12 - test - - - - - ${basedir}/src/main/java - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - - **/*Spec.java - **/*Test.java - - - - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.4 - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - package - - report - - - - - - - \ No newline at end of file diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchHelper.java b/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchHelper.java deleted file mode 100644 index 422774425..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchHelper.java +++ /dev/null @@ -1,814 +0,0 @@ -package org.sunbird.common; - -import static org.sunbird.common.models.util.ProjectUtil.isNotNull; - -import akka.util.Timeout; -import com.typesafe.config.Config; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.lucene.search.join.ScoreMode; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.ExistsQueryBuilder; -import org.elasticsearch.index.query.MatchQueryBuilder; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.elasticsearch.index.query.TermQueryBuilder; -import org.elasticsearch.index.query.TermsQueryBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket; -import org.elasticsearch.search.sort.SortOrder; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.util.ConfigUtil; -import org.sunbird.dto.SearchDTO; -import scala.concurrent.Await; -import scala.concurrent.Future; - -/** - * This class will provide all required operation for elastic search. - * - * @author arvind - * @author Manzarul - * @author mayank:github.com/iostream04 - */ -public class ElasticSearchHelper { - - public static final String LTE = "<="; - public static final String LT = "<"; - public static final String GTE = ">="; - public static final String GT = ">"; - public static final String ASC_ORDER = "ASC"; - public static final String STARTS_WITH = "startsWith"; - public static final String ENDS_WITH = "endsWith"; - public static final String SOFT_MODE = "soft"; - public static final String RAW_APPEND = ".raw"; - protected static Map indexMap = new HashMap<>(); - protected static Map typeMap = new HashMap<>(); - protected static final String ES_CONFIG_FILE = "elasticsearch.conf"; - private static Config config = ConfigUtil.getConfig(ES_CONFIG_FILE); - public static final int WAIT_TIME = 5; - public static Timeout timeout = new Timeout(WAIT_TIME, TimeUnit.SECONDS); - public static final List upsertResults = - new ArrayList<>(Arrays.asList("CREATED", "UPDATED", "NOOP")); - private static final String _DOC = "_doc"; - - private ElasticSearchHelper() {} - - /** - * This method will return the object after getting complete future. - * - * @param future - * @return Object which future inherits - */ - @SuppressWarnings("unchecked") - public static Object getResponseFromFuture(Future future) { - try { - Object result = Await.result(future, timeout.duration()); - return result; - } catch (Exception e) { - ProjectLogger.log( - "ElasticSearchHelper:getResponseFromFuture: error occured " + e, LoggerEnum.INFO.name()); - } - return null; - } - - /** - * This method adds aggregations to the incoming SearchRequestBuilder object - * - * @param searchRequestBuilder which will be updated with facets if any present - * @param facets Facets provide aggregated data based on a search query - * @return SearchRequestBuilder - */ - public static SearchRequestBuilder addAggregations( - SearchRequestBuilder searchRequestBuilder, List> facets) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchHelper:addAggregations: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - if (facets != null && !facets.isEmpty()) { - Map map = facets.get(0); - if (!MapUtils.isEmpty(map)) { - for (Map.Entry entry : map.entrySet()) { - - String key = entry.getKey(); - String value = entry.getValue(); - if (JsonKey.DATE_HISTOGRAM.equalsIgnoreCase(value)) { - searchRequestBuilder.addAggregation( - AggregationBuilders.dateHistogram(key) - .field(key + RAW_APPEND) - .dateHistogramInterval(DateHistogramInterval.days(1))); - - } else if (null == value) { - searchRequestBuilder.addAggregation( - AggregationBuilders.terms(key).field(key + RAW_APPEND)); - } - } - } - long elapsedTime = calculateEndTime(startTime); - ProjectLogger.log( - "ElasticSearchHelper:addAggregations method end ==" - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG.name()); - } - - return searchRequestBuilder; - } - - /** - * This method returns any constraints defined in searchDto object - * - * @param searchDTO with constraints - * @return Map for constraints present in serachDTO - */ - public static Map getConstraints(SearchDTO searchDTO) { - if (null != searchDTO.getSoftConstraints() && !searchDTO.getSoftConstraints().isEmpty()) { - return searchDTO - .getSoftConstraints() - .entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().floatValue())); - } - return Collections.emptyMap(); - } - - /** - * This method return SearchRequestBuilder for transport client - * - * @param client transport client instance - * @param index to be checkout - * @return SearchRequestBuilder for a provided request - */ - public static SearchRequestBuilder getTransportSearchBuilder( - TransportClient client, String[] index) { - return client.prepareSearch().setIndices(index).setTypes(_DOC); - } - - /** - * Method to add the additional search query like range query , exists - not exist filter etc. - * - * @param query query which will be updated - * @param entry which will have key to be search and respective values - * @param constraintsMap constraints on key and values - */ - @SuppressWarnings("unchecked") - public static void addAdditionalProperties( - BoolQueryBuilder query, Entry entry, Map constraintsMap) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchHelper:addAdditionalProperties: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - String key = entry.getKey(); - if (JsonKey.FILTERS.equalsIgnoreCase(key)) { - - Map filters = (Map) entry.getValue(); - for (Map.Entry en : filters.entrySet()) { - query = createFilterESOpperation(en, query, constraintsMap); - } - } else if (JsonKey.EXISTS.equalsIgnoreCase(key) || JsonKey.NOT_EXISTS.equalsIgnoreCase(key)) { - query = createESOpperation(entry, query, constraintsMap); - } else if (JsonKey.NESTED_EXISTS.equalsIgnoreCase(key) - || JsonKey.NESTED_NOT_EXISTS.equalsIgnoreCase(key)) { - query = createNestedESOpperation(entry, query, constraintsMap); - } else if (JsonKey.NESTED_KEY_FILTER.equalsIgnoreCase(key)) { - Map nestedFilters = (Map) entry.getValue(); - for (Map.Entry en : nestedFilters.entrySet()) { - query = createNestedFilterESOpperation(en, query, constraintsMap); - } - } - long elapsedTime = calculateEndTime(startTime); - ProjectLogger.log( - "ElasticSearchHelper:addAdditionalProperties: method end ==" - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG.name()); - } - - /** - * Method to create CommonTermQuery , multimatch and Range Query. - * - * @param entry which contains key for search and respective values - * @param query Object which will be updated - * @param constraintsMap constraints for key and values - * @return BoolQueryBuilder - */ - @SuppressWarnings("unchecked") - private static BoolQueryBuilder createFilterESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - ProjectLogger.log( - "ElasticSearchHelper:createFilterESOpperation: method started ", LoggerEnum.INFO.name()); - String key = entry.getKey(); - Object val = entry.getValue(); - if (val instanceof List && val != null) { - query = getTermQueryFromList(val, key, query, constraintsMap); - } else if (val instanceof Map) { - if (key.equalsIgnoreCase(JsonKey.ES_OR_OPERATION)) { - query.must(createEsORFilterQuery((Map) val)); - } else { - query = getTermQueryFromMap(val, key, query, constraintsMap); - } - } else if (val instanceof String) { - query.must( - createTermQuery(key + RAW_APPEND, ((String) val).toLowerCase(), constraintsMap.get(key))); - } else { - query.must(createTermQuery(key + RAW_APPEND, val, constraintsMap.get(key))); - } - ProjectLogger.log( - "ElasticSearchHelper:createFilterESOpperation: method end ", LoggerEnum.INFO.name()); - return query; - } - - /** - * Method to create CommonTermQuery , multimatch and Range Query. - * - * @param entry which contains key for search and respective values - * @param query Object which will be updated - * @param constraintsMap constraints for key and values - * @return BoolQueryBuilder - */ - @SuppressWarnings("unchecked") - private static BoolQueryBuilder createNestedFilterESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - ProjectLogger.log( - "ElasticSearchHelper:createFilterESOpperation: method started ", LoggerEnum.INFO.name()); - String key = entry.getKey(); - Object val = entry.getValue(); - String path = key.split("\\.")[0]; - if (val instanceof List && CollectionUtils.isNotEmpty((List) val)) { - if (((List) val).get(0) instanceof String) { - ((List) val).replaceAll(String::toLowerCase); - query.must( - QueryBuilders.nestedQuery( - path, - createTermsQuery(key + RAW_APPEND, (List) val, constraintsMap.get(key)), - ScoreMode.None)); - } else { - query.must( - QueryBuilders.nestedQuery( - path, createTermsQuery(key, (List) val, constraintsMap.get(key)), ScoreMode.None)); - } - } else if (val instanceof Map) { - query = getNestedTermQueryFromMap(val, key, path, query, constraintsMap); - } else if (val instanceof String) { - query.must( - QueryBuilders.nestedQuery( - path, - createTermQuery( - key + RAW_APPEND, ((String) val).toLowerCase(), constraintsMap.get(key)), - ScoreMode.None)); - } else { - query.must( - QueryBuilders.nestedQuery( - path, - createTermQuery(key + RAW_APPEND, val, constraintsMap.get(key)), - ScoreMode.None)); - } - ProjectLogger.log( - "ElasticSearchHelper:createFilterESOpperation: method end ", LoggerEnum.INFO.name()); - return query; - } - - /** - * This method returns termQuery if any present in map provided - * - * @param key for search in termquery - * @param val value of the key to be searched - * @param query which will be updated according to key , value and constraints - * @param constraintsMap for setting any constraints on values for the specified key - * @return BoolQueryBuilder - */ - private static BoolQueryBuilder getTermQueryFromMap( - Object val, String key, BoolQueryBuilder query, Map constraintsMap) { - ProjectLogger.log( - "ElasticSearchHelper:getTermQueryFromMap: method started ", LoggerEnum.INFO.name()); - Map value = (Map) val; - Map rangeOperation = new HashMap<>(); - Map lexicalOperation = new HashMap<>(); - for (Map.Entry it : value.entrySet()) { - String operation = it.getKey(); - if (operation.startsWith(LT) || operation.startsWith(GT)) { - rangeOperation.put(operation, it.getValue()); - } else if (operation.startsWith(STARTS_WITH) || operation.startsWith(ENDS_WITH)) { - lexicalOperation.put(operation, it.getValue()); - } - } - if (!(rangeOperation.isEmpty())) { - query.must(createRangeQuery(key, rangeOperation, constraintsMap.get(key))); - } - if (!(lexicalOperation.isEmpty())) { - query.must(createLexicalQuery(key, lexicalOperation, constraintsMap.get(key))); - } - ProjectLogger.log( - "ElasticSearchHelper:getTermQueryFromMap: method end ", LoggerEnum.INFO.name()); - - return query; - } - - private static BoolQueryBuilder createEsORFilterQuery(Map orFilters) { - BoolQueryBuilder query = new BoolQueryBuilder(); - ProjectLogger.log( - "ElasticSearchHelper:createEsORFilterQuery:method started ", LoggerEnum.INFO.name()); - for (Map.Entry mp : orFilters.entrySet()) { - query.should( - QueryBuilders.termQuery( - mp.getKey() + RAW_APPEND, ((String) mp.getValue()).toLowerCase())); - } - ProjectLogger.log( - "ElasticSearchHelper:createEsORFilterQuery:method end ", LoggerEnum.INFO.name()); - return query; - } - - /** - * This method returns termQuery if any present in map provided - * - * @param key for search in termquery - * @param val value of the key to be searched - * @param query which will be updated according to key , value and constraints - * @param constraintsMap for setting any constraints on values for the specified key - * @return BoolQueryBuilder - */ - private static BoolQueryBuilder getNestedTermQueryFromMap( - Object val, - String key, - String path, - BoolQueryBuilder query, - Map constraintsMap) { - ProjectLogger.log( - "ElasticSearchHelper:getTermQueryFromMap: method started ", LoggerEnum.INFO.name()); - Map value = (Map) val; - Map rangeOperation = new HashMap<>(); - Map lexicalOperation = new HashMap<>(); - for (Map.Entry it : value.entrySet()) { - String operation = it.getKey(); - if (operation.startsWith(LT) || operation.startsWith(GT)) { - rangeOperation.put(operation, it.getValue()); - } else if (operation.startsWith(STARTS_WITH) || operation.startsWith(ENDS_WITH)) { - lexicalOperation.put(operation, it.getValue()); - } - } - if (!(rangeOperation.isEmpty())) { - query.must( - QueryBuilders.nestedQuery( - path, - createRangeQuery(key, rangeOperation, constraintsMap.get(key)), - ScoreMode.None)); - } - if (!(lexicalOperation.isEmpty())) { - query.must( - QueryBuilders.nestedQuery( - path, - createLexicalQuery(key, lexicalOperation, constraintsMap.get(key)), - ScoreMode.None)); - } - ProjectLogger.log( - "ElasticSearchHelper:getTermQueryFromMap: method end ", LoggerEnum.INFO.name()); - return query; - } - - /** - * This method returns termQuery if any present in List provided - * - * @param key for search in termquery - * @param val value of the key to be searched - * @param query which will be updated according to key , value and constraints - * @param constraintsMap for setting any constraints on values for the specified key - * @return BoolQueryBuilder - */ - private static BoolQueryBuilder getTermQueryFromList( - Object val, String key, BoolQueryBuilder query, Map constraintsMap) { - if (!((List) val).isEmpty()) { - if (((List) val).get(0) instanceof String) { - ((List) val).replaceAll(String::toLowerCase); - query.must(createTermsQuery(key + RAW_APPEND, (List) val, constraintsMap.get(key))); - } else { - query.must(createTermsQuery(key, (List) val, constraintsMap.get(key))); - } - } - return query; - } - - /** Method to create EXISTS and NOT EXIST FILTER QUERY . */ - /** - * @param entry contains operations and keys for filter - * @param query do get updated with provided operations - * @param constraintsMap to set ant constraints on keys for filter - * @return - */ - @SuppressWarnings("unchecked") - private static BoolQueryBuilder createESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - - String operation = entry.getKey(); - if (entry.getValue() != null && entry.getValue() instanceof List) { - List existsList = (List) entry.getValue(); - - if (JsonKey.EXISTS.equalsIgnoreCase(operation)) { - for (String name : existsList) { - query.must(createExistQuery(name, constraintsMap.get(name))); - } - } else if (JsonKey.NOT_EXISTS.equalsIgnoreCase(operation)) { - for (String name : existsList) { - query.mustNot(createExistQuery(name, constraintsMap.get(name))); - } - } - } - return query; - } - - /** Method to create EXISTS and NOT EXIST FILTER QUERY . */ - /** - * @param entry contains operations and keys for filter - * @param query do get updated with provided operations - * @param constraintsMap to set ant constraints on keys for filter - * @return - */ - @SuppressWarnings("unchecked") - private static BoolQueryBuilder createNestedESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - - String operation = entry.getKey(); - if (entry.getValue() != null && entry.getValue() instanceof Map) { - Map existsMap = (Map) entry.getValue(); - - if (JsonKey.NESTED_EXISTS.equalsIgnoreCase(operation)) { - for (Map.Entry nameByPath : existsMap.entrySet()) { - query.must( - QueryBuilders.nestedQuery( - nameByPath.getValue(), - createExistQuery(nameByPath.getKey(), constraintsMap.get(nameByPath.getKey())), - ScoreMode.None)); - } - } else if (JsonKey.NESTED_NOT_EXISTS.equalsIgnoreCase(operation)) { - for (Map.Entry nameByPath : existsMap.entrySet()) { - query.mustNot( - QueryBuilders.nestedQuery( - nameByPath.getValue(), - createExistQuery(nameByPath.getKey(), constraintsMap.get(nameByPath.getKey())), - ScoreMode.None)); - } - } - } - return query; - } - - /** Method to return the sorting order on basis of string param . */ - public static SortOrder getSortOrder(String value) { - return ASC_ORDER.equalsIgnoreCase(value) ? SortOrder.ASC : SortOrder.DESC; - } - - /** - * This method return MatchQueryBuilder Object with boosts if any provided - * - * @param name of the attribute - * @param value of the attribute - * @param boost for increasing the search parameters priority - * @return MatchQueryBuilder - */ - public static MatchQueryBuilder createMatchQuery(String name, Object value, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.matchQuery(name, value).boost(boost); - } else { - return QueryBuilders.matchQuery(name, value); - } - } - - /** - * This method returns TermsQueryBuilder with boosts if any provided - * - * @param key : field name - * @param values : values for the field value - * @param boost for increasing the search parameters priority - * @return TermsQueryBuilder - */ - private static TermsQueryBuilder createTermsQuery(String key, List values, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.termsQuery(key, (values).stream().toArray(Object[]::new)).boost(boost); - } else { - return QueryBuilders.termsQuery(key, (values).stream().toArray(Object[]::new)); - } - } - - /** - * This method returns RangeQueryBuilder with boosts if any provided - * - * @param name for the field - * @param rangeOperation: keys and value related to range - * @param boost for increasing the search parameters priority - * @return RangeQueryBuilder - */ - private static RangeQueryBuilder createRangeQuery( - String name, Map rangeOperation, Float boost) { - - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(name + RAW_APPEND); - for (Map.Entry it : rangeOperation.entrySet()) { - switch (it.getKey()) { - case LTE: - rangeQueryBuilder.lte(it.getValue()); - break; - case LT: - rangeQueryBuilder.lt(it.getValue()); - break; - case GTE: - rangeQueryBuilder.gte(it.getValue()); - break; - case GT: - rangeQueryBuilder.gt(it.getValue()); - break; - } - } - if (isNotNull(boost)) { - return rangeQueryBuilder.boost(boost); - } - return rangeQueryBuilder; - } - - /** - * This method returns TermQueryBuilder with boosts if any provided - * - * @param name of the field for termquery - * @param value of the field for termquery - * @param boost for increasing the search parameters priority - * @return TermQueryBuilder - */ - private static TermQueryBuilder createTermQuery(String name, Object value, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.termQuery(name, value).boost(boost); - } else { - return QueryBuilders.termQuery(name, value); - } - } - - /** - * this method return ExistsQueryBuilder with boosts if any provided - * - * @param name of the field which required for exists operation - * @param boost for increasing the search parameters priority - * @return ExistsQueryBuilder - */ - private static ExistsQueryBuilder createExistQuery(String name, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.existsQuery(name).boost(boost); - } else { - return QueryBuilders.existsQuery(name); - } - } - - /** - * This method create lexical query with boosts if any provided - * - * @param key for search - * @param rangeOperation to search or match in a particular way - * @param boost for increasing the search parameters priority - * @return QueryBuilder - */ - public static QueryBuilder createLexicalQuery( - String key, Map rangeOperation, Float boost) { - QueryBuilder queryBuilder = null; - for (Map.Entry it : rangeOperation.entrySet()) { - switch (it.getKey()) { - case STARTS_WITH: - { - String startsWithVal = (String) it.getValue(); - if (StringUtils.isNotBlank(startsWithVal)) { - startsWithVal = startsWithVal.toLowerCase(); - } - if (isNotNull(boost)) { - queryBuilder = - QueryBuilders.prefixQuery(key + RAW_APPEND, startsWithVal).boost(boost); - } - queryBuilder = QueryBuilders.prefixQuery(key + RAW_APPEND, startsWithVal); - break; - } - case ENDS_WITH: - { - String endsWithRegex = "~" + it.getValue(); - if (isNotNull(boost)) { - queryBuilder = - QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex).boost(boost); - } - queryBuilder = QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex); - break; - } - } - } - return queryBuilder; - } - - /** - * this method will take start time and subtract with current time to get the time spent in - * millis. - * - * @param startTime long - * @return long - */ - public static long calculateEndTime(long startTime) { - return System.currentTimeMillis() - startTime; - } - - /** - * This method will create searchdto on this of searchquery provided - * - * @param searchQueryMap Map contains query - * @return SearchDto for search data in elastic search - */ - public static SearchDTO createSearchDTO(Map searchQueryMap) { - SearchDTO search = new SearchDTO(); - search = getBasicBuiders(search, searchQueryMap); - search = setOffset(search, searchQueryMap); - search = getLimits(search, searchQueryMap); - if (searchQueryMap.containsKey(JsonKey.GROUP_QUERY)) { - search - .getGroupQuery() - .addAll( - (Collection>) searchQueryMap.get(JsonKey.GROUP_QUERY)); - } - search = getSoftConstraints(search, searchQueryMap); - return search; - } - - /** - * This method add any softconstraints present in seach query to search DTo - * - * @param SearchDTO search which contains the search parameters for elastic search. - * @param Map searchQueryMap which contains soft_constraints - * @return SearchDTO updated searchDTO which contains soft_constraits - */ - private static SearchDTO getSoftConstraints( - SearchDTO search, Map searchQueryMap) { - if (searchQueryMap.containsKey(JsonKey.SOFT_CONSTRAINTS)) { - search.setSoftConstraints( - (Map) searchQueryMap.get(JsonKey.SOFT_CONSTRAINTS)); - } - return search; - } - - /** - * This method adds any limits present in the search query - * - * @param SearchDTO search which contains the search parameters for elastic search. - * @param Map searchQueryMap which contain limit - * @return SearchDTO updated searchDTO which contains limit - */ - private static SearchDTO getLimits(SearchDTO search, Map searchQueryMap) { - if (searchQueryMap.containsKey(JsonKey.LIMIT)) { - if ((searchQueryMap.get(JsonKey.LIMIT)) instanceof Integer) { - search.setLimit((int) searchQueryMap.get(JsonKey.LIMIT)); - } else { - search.setLimit(((BigInteger) searchQueryMap.get(JsonKey.LIMIT)).intValue()); - } - } - return search; - } - - /** - * This method adds offset if any present in the searchQuery - * - * @param SearchDTO search which contains the search parameters for elastic search. - * @param map searchQueryMap which contains offset - * @return SearchDTO updated searchDTO which contain offset - */ - private static SearchDTO setOffset(SearchDTO search, Map searchQueryMap) { - if (searchQueryMap.containsKey(JsonKey.OFFSET)) { - if ((searchQueryMap.get(JsonKey.OFFSET)) instanceof Integer) { - search.setOffset((int) searchQueryMap.get(JsonKey.OFFSET)); - } else { - search.setOffset(((BigInteger) searchQueryMap.get(JsonKey.OFFSET)).intValue()); - } - } - return search; - } - - /** - * This method adds basic query parameter to SearchDTO if any provided - * - * @param SearchDTO search - * @param Map searchQueryMap - * @return SearchDTO - */ - private static SearchDTO getBasicBuiders(SearchDTO search, Map searchQueryMap) { - if (searchQueryMap.containsKey(JsonKey.QUERY)) { - search.setQuery((String) searchQueryMap.get(JsonKey.QUERY)); - } - if (searchQueryMap.containsKey(JsonKey.QUERY_FIELDS)) { - search.setQueryFields((List) searchQueryMap.get(JsonKey.QUERY_FIELDS)); - } - if (searchQueryMap.containsKey(JsonKey.FACETS)) { - search.setFacets((List>) searchQueryMap.get(JsonKey.FACETS)); - } - if (searchQueryMap.containsKey(JsonKey.FIELDS)) { - search.setFields((List) searchQueryMap.get(JsonKey.FIELDS)); - } - if (searchQueryMap.containsKey(JsonKey.FILTERS)) { - search.getAdditionalProperties().put(JsonKey.FILTERS, searchQueryMap.get(JsonKey.FILTERS)); - } - if (searchQueryMap.containsKey(JsonKey.EXISTS)) { - search.getAdditionalProperties().put(JsonKey.EXISTS, searchQueryMap.get(JsonKey.EXISTS)); - } - if (searchQueryMap.containsKey(JsonKey.NOT_EXISTS)) { - search - .getAdditionalProperties() - .put(JsonKey.NOT_EXISTS, searchQueryMap.get(JsonKey.NOT_EXISTS)); - } - if (searchQueryMap.containsKey(JsonKey.SORT_BY)) { - search - .getSortBy() - .putAll((Map) searchQueryMap.get(JsonKey.SORT_BY)); - } - return search; - } - - /** - * Method returns map which contains all the request data from elasticsearch - * - * @param SearchResponse response from elastic search - * @param searchDTO searchDTO which was used to search data - * @param finalFacetList Facets provide aggregated data based on a search query - * @return Map which will have all the requested data - */ - public static Map getSearchResponseMap( - SearchResponse response, SearchDTO searchDTO, List finalFacetList) { - Map responseMap = new HashMap<>(); - List> esSource = new ArrayList<>(); - long count = 0; - if (response != null) { - SearchHits hits = response.getHits(); - count = hits.getTotalHits(); - - for (SearchHit hit : hits) { - esSource.add(hit.getSourceAsMap()); - } - - // fetch aggregations aggregations - finalFacetList = getFinalFacetList(response, searchDTO, finalFacetList); - } - responseMap.put(JsonKey.CONTENT, esSource); - if (!(finalFacetList.isEmpty())) { - responseMap.put(JsonKey.FACETS, finalFacetList); - } - responseMap.put(JsonKey.COUNT, count); - return responseMap; - } - - private static List getFinalFacetList( - SearchResponse response, SearchDTO searchDTO, List finalFacetList) { - if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) { - ProjectLogger.log( - "ElasticSearchHelper:getFinalFacetList: " + "method start with facets not null", - LoggerEnum.INFO); - Map m1 = searchDTO.getFacets().get(0); - for (Map.Entry entry : m1.entrySet()) { - String field = entry.getKey(); - String aggsType = entry.getValue(); - List aggsList = new ArrayList<>(); - Map facetMap = new HashMap(); - if (JsonKey.DATE_HISTOGRAM.equalsIgnoreCase(aggsType)) { - Histogram agg = response.getAggregations().get(field); - for (Histogram.Bucket ent : agg.getBuckets()) { - // DateTime key = (DateTime) ent.getKey(); // Key - String keyAsString = ent.getKeyAsString(); // Key as String - long docCount = ent.getDocCount(); // Doc count - Map internalMap = new HashMap(); - internalMap.put(JsonKey.NAME, keyAsString); - internalMap.put(JsonKey.COUNT, docCount); - aggsList.add(internalMap); - } - } else { - Terms aggs = response.getAggregations().get(field); - for (Bucket bucket : aggs.getBuckets()) { - Map internalMap = new HashMap(); - internalMap.put(JsonKey.NAME, bucket.getKey()); - internalMap.put(JsonKey.COUNT, bucket.getDocCount()); - aggsList.add(internalMap); - } - } - facetMap.put("values", aggsList); - facetMap.put(JsonKey.NAME, field); - finalFacetList.add(facetMap); - } - ProjectLogger.log("ElasticSearchHelper:getFinalFacetList: " + "method end ", LoggerEnum.INFO); - } - return finalFacetList; - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchRestHighImpl.java b/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchRestHighImpl.java deleted file mode 100644 index 190246e68..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchRestHighImpl.java +++ /dev/null @@ -1,734 +0,0 @@ -package org.sunbird.common; - -import akka.dispatch.Futures; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.admin.indices.get.GetIndexRequest; -import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetRequest; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.action.update.UpdateResponse; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.SimpleQueryStringBuilder; -import org.elasticsearch.index.query.TermQueryBuilder; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.search.sort.FieldSortBuilder; -import org.elasticsearch.search.sort.SortMode; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import org.sunbird.helper.ConnectionManager; -import scala.concurrent.Future; -import scala.concurrent.Promise; - -/** - * This class will provide all required operation for elastic search. - * - * @author github.com/iostream04 - */ -public class ElasticSearchRestHighImpl implements ElasticSearchService { - private static final String ERROR = "ERROR"; - - /** - * This method will put a new data entry inside Elastic search. identifier value becomes _id - * inside ES, so every time provide a unique value while saving it. - * - * @param index String ES index name - * @param identifier ES column identifier as an String - * @param data Map - * @return Future which contains identifier for created data - */ - @Override - public Future save(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchUtilRest:save: method started at ==" + startTime + " for Index " + index, - LoggerEnum.PERF_LOG.name()); - if (StringUtils.isBlank(identifier) || StringUtils.isBlank(index)) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:save: " - + "Identifier or Index value is null or empty, identifier : " - + "" - + identifier - + ",index: " - + index - + ",not able to save data.", - LoggerEnum.INFO.name()); - promise.success(ERROR); - return promise.future(); - } - data.put("identifier", identifier); - - IndexRequest indexRequest = new IndexRequest(index, _DOC, identifier).source(data); - - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(IndexResponse indexResponse) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:save: Success for index : " - + index - + ", identifier :" - + identifier, - LoggerEnum.INFO.name()); - - promise.success(indexResponse.getId()); - ProjectLogger.log( - "ElasticSearchRestHighImpl:save: method end at ==" - + System.currentTimeMillis() - + " for Index " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - } - - @Override - public void onFailure(Exception e) { - promise.failure(e); - ProjectLogger.log( - "ElasticSearchRestHighImpl:save: " - + "Error while saving " - + index - + " id : " - + identifier - + " with error :" - + e, - LoggerEnum.ERROR.name()); - ProjectLogger.log( - "ElasticSearchRestHighImpl:save: method end at ==" - + System.currentTimeMillis() - + " for INdex " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - } - }; - - ConnectionManager.getRestClient().indexAsync(indexRequest, listener); - - return promise.future(); - } - - /** - * This method will update data entry inside Elastic search, using identifier and provided data . - * - * @param index String ES index name - * @param identifier ES column identifier as an String - * @param data Map - * @return true or false - */ - @Override - public Future update(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchRestHighImpl:update: method started at ==" - + startTime - + " for Index " - + index, - LoggerEnum.PERF_LOG.name()); - Promise promise = Futures.promise(); - ; - - if (!StringUtils.isBlank(index) && !StringUtils.isBlank(identifier) && data != null) { - UpdateRequest updateRequest = new UpdateRequest(index, _DOC, identifier).doc(data); - - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(UpdateResponse updateResponse) { - promise.success(true); - ProjectLogger.log( - "ElasticSearchRestHighImpl:update: Success with " - + updateResponse.getResult() - + " response from elastic search for index" - + index - + ",identifier : " - + identifier, - LoggerEnum.INFO.name()); - ProjectLogger.log( - "ElasticSearchRestHighImpl:update: method end ==" - + " for INdex " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - } - - @Override - public void onFailure(Exception e) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:update: exception occured:" + e.getMessage(), - LoggerEnum.ERROR.name()); - promise.failure(e); - } - }; - ConnectionManager.getRestClient().updateAsync(updateRequest, listener); - - } else { - ProjectLogger.log( - "ElasticSearchRestHighImpl:update: Requested data is invalid.", LoggerEnum.INFO.name()); - promise.failure(ProjectUtil.createClientException(ResponseCode.invalidData)); - } - return promise.future(); - } - - /** - * This method will provide data form ES based on incoming identifier. we can get data by passing - * index and identifier values , or all the three - * - * @param type String - * @param identifier String - * @return Map or empty map - */ - @Override - public Future> getDataByIdentifier(String index, String identifier) { - long startTime = System.currentTimeMillis(); - Promise> promise = Futures.promise(); - if (StringUtils.isNotEmpty(identifier) && StringUtils.isNotEmpty(index)) { - - ProjectLogger.log( - "ElasticSearchRestHighImpl:getDataByIdentifier: method started at ==" - + startTime - + " for Index " - + index, - LoggerEnum.PERF_LOG.name()); - - GetRequest getRequest = new GetRequest(index, _DOC, identifier); - - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(GetResponse getResponse) { - if (getResponse.isExists()) { - Map sourceAsMap = getResponse.getSourceAsMap(); - if (MapUtils.isNotEmpty(sourceAsMap)) { - promise.success(sourceAsMap); - ProjectLogger.log( - "ElasticSearchRestHighImpl:getDataByIdentifier: method end ==" - + " for Index " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - } else { - promise.success(new HashMap<>()); - } - } else { - promise.success(new HashMap<>()); - } - } - - @Override - public void onFailure(Exception e) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:getDataByIdentifier: method Failed with error == " + e, - LoggerEnum.INFO.name()); - promise.failure(e); - } - }; - - ConnectionManager.getRestClient().getAsync(getRequest, listener); - } else { - ProjectLogger.log( - "ElasticSearchRestHighImpl:getDataByIdentifier: " - + "provided index or identifier is null, index = " - + index - + "," - + " identifier = " - + identifier, - LoggerEnum.INFO.name()); - promise.failure(ProjectUtil.createClientException(ResponseCode.invalidData)); - } - - return promise.future(); - } - - /** - * This method will remove data from ES based on identifier. - * - * @param index String - * @param type String - * @param identifier String - */ - @Override - public Future delete(String index, String identifier) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchRestHighImpl:delete: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - Promise promise = Futures.promise(); - if (StringUtils.isNotEmpty(identifier) && StringUtils.isNotEmpty(index)) { - DeleteRequest delRequest = new DeleteRequest(index, _DOC, identifier); - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(DeleteResponse deleteResponse) { - if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:delete:OnResponse: Document not found for index : " - + index - + " , identifier : " - + identifier, - LoggerEnum.INFO.name()); - promise.success(false); - } else { - promise.success(true); - } - } - - @Override - public void onFailure(Exception e) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:delete: Async Failed due to error :" + e, - LoggerEnum.INFO.name()); - promise.failure(e); - } - }; - - ConnectionManager.getRestClient().deleteAsync(delRequest, listener); - } else { - ProjectLogger.log( - "ElasticSearchRestHighImpl:delete: " - + "provided index or identifier is null, index = " - + index - + "," - + " identifier = " - + identifier, - LoggerEnum.INFO.name()); - promise.failure(ProjectUtil.createClientException(ResponseCode.invalidData)); - } - - ProjectLogger.log( - "ElasticSearchRestHighImpl:delete: method end ==" - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - return promise.future(); - } - - /** - * Method to perform the elastic search on the basis of SearchDTO . SearchDTO contains the search - * criteria like fields, facets, sort by , filters etc. here user can pass single type to search - * or multiple type or null - * - * @param type var arg of String - * @return search result as Map. - */ - @Override - @SuppressWarnings({"unchecked", "rawtypes"}) - public Future> search(SearchDTO searchDTO, String index) { - long startTime = System.currentTimeMillis(); - - ProjectLogger.log( - "ElasticSearchRestHighImpl:search: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - SearchRequest searchRequest = new SearchRequest(index); - searchRequest.types(_DOC); - - // check mode and set constraints - Map constraintsMap = ElasticSearchHelper.getConstraints(searchDTO); - - BoolQueryBuilder query = new BoolQueryBuilder(); - - // add channel field as mandatory - String channel = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ES_CHANNEL); - if (!(StringUtils.isBlank(channel) || JsonKey.SUNBIRD_ES_CHANNEL.equals(channel))) { - query.must( - ElasticSearchHelper.createMatchQuery( - JsonKey.CHANNEL, channel, constraintsMap.get(JsonKey.CHANNEL))); - } - - // apply simple query string - if (!StringUtils.isBlank(searchDTO.getQuery())) { - SimpleQueryStringBuilder sqsb = QueryBuilders.simpleQueryStringQuery(searchDTO.getQuery()); - if (CollectionUtils.isEmpty(searchDTO.getQueryFields())) { - query.must(sqsb.field("all_fields")); - } else { - Map searchFields = - searchDTO - .getQueryFields() - .stream() - .collect(Collectors.toMap(s -> s, v -> 1.0f)); - query.must(sqsb.fields(searchFields)); - } - } - // apply the sorting - if (searchDTO.getSortBy() != null && searchDTO.getSortBy().size() > 0) { - for (Map.Entry entry : searchDTO.getSortBy().entrySet()) { - if (!entry.getKey().contains(".")) { - searchSourceBuilder.sort( - entry.getKey() + ElasticSearchHelper.RAW_APPEND, - ElasticSearchHelper.getSortOrder((String) entry.getValue())); - } else { - Map map = (Map) entry.getValue(); - Map dataMap = (Map) map.get(JsonKey.TERM); - for (Map.Entry dateMapEntry : dataMap.entrySet()) { - FieldSortBuilder mySort = - new FieldSortBuilder(entry.getKey() + ElasticSearchHelper.RAW_APPEND) - .setNestedFilter( - new TermQueryBuilder(dateMapEntry.getKey(), dateMapEntry.getValue())) - .sortMode(SortMode.MIN) - .order(ElasticSearchHelper.getSortOrder((String) map.get(JsonKey.ORDER))); - searchSourceBuilder.sort(mySort); - } - } - } - } - - // apply the fields filter - searchSourceBuilder.fetchSource( - searchDTO.getFields() != null - ? searchDTO.getFields().stream().toArray(String[]::new) - : null, - searchDTO.getExcludedFields() != null - ? searchDTO.getExcludedFields().stream().toArray(String[]::new) - : null); - - // setting the offset - if (searchDTO.getOffset() != null) { - searchSourceBuilder.from(searchDTO.getOffset()); - } - - // setting the limit - if (searchDTO.getLimit() != null) { - searchSourceBuilder.size(searchDTO.getLimit()); - } - // apply additional properties - if (searchDTO.getAdditionalProperties() != null - && searchDTO.getAdditionalProperties().size() > 0) { - for (Map.Entry entry : searchDTO.getAdditionalProperties().entrySet()) { - ElasticSearchHelper.addAdditionalProperties(query, entry, constraintsMap); - } - } - - // set final query to search request builder - searchSourceBuilder.query(query); - List finalFacetList = new ArrayList(); - - if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) { - searchSourceBuilder = addAggregations(searchSourceBuilder, searchDTO.getFacets()); - } - ProjectLogger.log( - "ElasticSearchRestHighImpl:search: calling search builder======" - + searchSourceBuilder.toString(), - LoggerEnum.INFO.name()); - - searchRequest.source(searchSourceBuilder); - Promise> promise = Futures.promise(); - - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(SearchResponse response) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:search:onResponse response1 = " + response, - LoggerEnum.DEBUG.name()); - if (response.getHits() == null || response.getHits().getTotalHits() == 0) { - - Map responseMap = new HashMap<>(); - List> esSource = new ArrayList<>(); - responseMap.put(JsonKey.CONTENT, esSource); - responseMap.put(JsonKey.COUNT, 0); - promise.success(responseMap); - } else { - Map responseMap = - ElasticSearchHelper.getSearchResponseMap(response, searchDTO, finalFacetList); - ProjectLogger.log( - "ElasticSearchRestHighImpl:search: method end " - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(responseMap); - } - } - - @Override - public void onFailure(Exception e) { - promise.failure(e); - - ProjectLogger.log( - "ElasticSearchRestHighImpl:search: method end for Index " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - ProjectLogger.log( - "ElasticSearchRestHighImpl:search: method Failed with error :" + e, - LoggerEnum.ERROR.name()); - } - }; - - ConnectionManager.getRestClient().searchAsync(searchRequest, listener); - return promise.future(); - } - - /** - * This method will do the health check of elastic search. - * - * @return boolean - */ - @Override - public Future healthCheck() { - - GetIndexRequest indexRequest = - new GetIndexRequest().indices(ProjectUtil.EsType.user.getTypeName()); - Promise promise = Futures.promise(); - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(Boolean getResponse) { - if (getResponse) { - promise.success(getResponse); - } else { - promise.success(false); - } - } - - @Override - public void onFailure(Exception e) { - promise.failure(e); - ProjectLogger.log( - "ElasticSearchRestHighImpl:healthCheck: error " + e.getMessage(), - LoggerEnum.INFO.name()); - } - }; - ConnectionManager.getRestClient().indices().existsAsync(indexRequest, listener); - - return promise.future(); - } - - /** - * This method will do the bulk data insertion. - * - * @param index String index name - * @param type String type name - * @param dataList List> - * @return boolean - */ - @Override - public Future bulkInsert(String index, List> dataList) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchRestHighImpl:bulkInsert: method started at ==" - + startTime - + " for Index " - + index, - LoggerEnum.PERF_LOG.name()); - BulkRequest request = new BulkRequest(); - Promise promise = Futures.promise(); - for (Map data : dataList) { - request.add(new IndexRequest(index, _DOC, (String) data.get(JsonKey.ID)).source(data)); - } - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(BulkResponse bulkResponse) { - Iterator responseItr = bulkResponse.iterator(); - if (responseItr != null) { - promise.success(true); - while (responseItr.hasNext()) { - - BulkItemResponse bResponse = responseItr.next(); - - if (bResponse.isFailed()) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:bulkinsert: api response===" - + bResponse.getId() - + " " - + bResponse.getFailureMessage(), - LoggerEnum.INFO.name()); - } - } - } - } - - @Override - public void onFailure(Exception e) { - ProjectLogger.log("ElasticSearchRestHighImpl:bulkinsert: Bulk upload error block", e); - promise.success(false); - } - }; - ConnectionManager.getRestClient().bulkAsync(request, listener); - - ProjectLogger.log( - "ElasticSearchRestHighImpl:bulkInsert: method end ==" - + " for Index " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - return promise.future(); - } - - private static long calculateEndTime(long startTime) { - return System.currentTimeMillis() - startTime; - } - - private static SearchSourceBuilder addAggregations( - SearchSourceBuilder searchSourceBuilder, List> facets) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtilRest:addAggregations: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - Map map = facets.get(0); - for (Map.Entry entry : map.entrySet()) { - - String key = entry.getKey(); - String value = entry.getValue(); - if (JsonKey.DATE_HISTOGRAM.equalsIgnoreCase(value)) { - searchSourceBuilder.aggregation( - AggregationBuilders.dateHistogram(key) - .field(key + ElasticSearchHelper.RAW_APPEND) - .dateHistogramInterval(DateHistogramInterval.days(1))); - - } else if (null == value) { - searchSourceBuilder.aggregation( - AggregationBuilders.terms(key).field(key + ElasticSearchHelper.RAW_APPEND)); - } - } - ProjectLogger.log( - "ElasticSearchUtilRest:addAggregations: method end ==" - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - return searchSourceBuilder; - } - - /** - * This method will update data based on identifier.take the data based on identifier and merge - * with incoming data then update it. - * - * @param index String - * @param type String - * @param identifier String - * @param data Map - * @return boolean - */ - @Override - public Future upsert(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchUtil:upsert: method started at ==" + startTime + " for INdex " + index, - LoggerEnum.PERF_LOG.name()); - if (!StringUtils.isBlank(index) - && !StringUtils.isBlank(identifier) - && data != null - && data.size() > 0) { - - IndexRequest indexRequest = new IndexRequest(index, _DOC, identifier).source(data); - - UpdateRequest updateRequest = new UpdateRequest(index, _DOC, identifier).upsert(indexRequest); - updateRequest.doc(indexRequest); - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(UpdateResponse updateResponse) { - promise.success(true); - ProjectLogger.log( - "ElasticSearchUtilRest:upsert: Response for index : " - + updateResponse.getResult() - + "," - + index - + ",identifier : " - + identifier, - LoggerEnum.INFO.name()); - ProjectLogger.log( - "ElasticSearchUtilRest:upsert: method end ==" - + " for Index " - + index - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - } - - @Override - public void onFailure(Exception e) { - ProjectLogger.log( - "ElasticSearchRestHighImpl:upsert: exception occured:" + e.getMessage(), - LoggerEnum.ERROR.name()); - promise.failure(e); - } - }; - ConnectionManager.getRestClient().updateAsync(updateRequest, listener); - return promise.future(); - } else { - ProjectLogger.log( - "ElasticSearchRestHighImpl:upsert: Requested data is invalid.", LoggerEnum.ERROR.name()); - promise.failure(ProjectUtil.createClientException(ResponseCode.invalidData)); - return promise.future(); - } - } - - /** - * This method will return map of objects on the basis of ids provided. - * - * @param ids List of String - * @param fields List of String - * @param index index of elasticserach for query - * @param data Map - * @return future of requested data in the form of map - */ - @Override - public Future>> getEsResultByListOfIds( - List ids, List fields, String index) { - long startTime = System.currentTimeMillis(); - - Map filters = new HashMap<>(); - filters.put(JsonKey.ID, ids); - - SearchDTO searchDTO = new SearchDTO(); - searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters); - searchDTO.setFields(fields); - - Future> resultF = search(searchDTO, index); - Map result = - (Map) ElasticSearchHelper.getResponseFromFuture(resultF); - List> esContent = (List>) result.get(JsonKey.CONTENT); - Promise>> promise = Futures.promise(); - promise.success( - esContent - .stream() - .collect( - Collectors.toMap( - obj -> { - return (String) obj.get("id"); - }, - val -> val))); - ProjectLogger.log( - "ElasticSearchUtil:getEsResultByListOfIds: method ended for index " + index, - LoggerEnum.INFO.name()); - - return promise.future(); - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchTcpImpl.java b/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchTcpImpl.java deleted file mode 100644 index bba17b1e5..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchTcpImpl.java +++ /dev/null @@ -1,605 +0,0 @@ -package org.sunbird.common; - -import akka.dispatch.Futures; -import akka.util.Timeout; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.bulk.BulkProcessor; -import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.search.SearchPhaseExecutionException; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.action.update.UpdateResponse; -import org.elasticsearch.client.Requests; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.SimpleQueryStringBuilder; -import org.elasticsearch.index.query.TermQueryBuilder; -import org.elasticsearch.search.sort.FieldSortBuilder; -import org.elasticsearch.search.sort.SortBuilders; -import org.elasticsearch.search.sort.SortMode; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import org.sunbird.helper.ConnectionManager; -import scala.concurrent.Future; -import scala.concurrent.Promise; - -/** - * This class will provide all required operation for elastic search. - * - * @author github.com/iostream04 - */ -public class ElasticSearchTcpImpl implements ElasticSearchService { - public static final int WAIT_TIME = 30; - public static Timeout timeout = new Timeout(WAIT_TIME, TimeUnit.SECONDS); - - /** - * This method will put a new data entry inside Elastic search. identifier value becomes _id - * inside ES, so every time provide a unique value while saving it. - * - * @param index String ES index name - * @param identifier ES column identifier as an String - * @param data Map - * @return identifier for created data - */ - @Override - public Future save(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchTcpImpl:save: method started at ==" + startTime + " for Index " + index, - LoggerEnum.PERF_LOG.name()); - if (StringUtils.isBlank(identifier) || StringUtils.isBlank(index)) { - ProjectLogger.log( - "ElasticSearchTcpImpl:save: Identifier value is null or empty ,not able to save data.", - LoggerEnum.ERROR.name()); - promise.success("ERROR"); - return promise.future(); - } - try { - data.put("identifier", identifier); - IndexResponse response = - ConnectionManager.getClient().prepareIndex(index, _DOC, identifier).setSource(data).get(); - ProjectLogger.log( - "ElasticSearchTcpImpl:save: " - + "Save value==" - + response.getId() - + " " - + response.status(), - LoggerEnum.INFO.name()); - ProjectLogger.log( - "ElasticSearchTcpImpl:save: method end at ==" - + System.currentTimeMillis() - + " for INdex " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(response.getId()); - return promise.future(); - } catch (Exception e) { - ProjectLogger.log( - "ElasticSearchTcpImpl:save: Error while saving index " - + index - + " id : " - + identifier - + " with error :" - + e, - LoggerEnum.INFO.name()); - ProjectLogger.log( - "ElasticSearchTcpImpl:save: method end at ==" - + System.currentTimeMillis() - + " for Index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(""); - } - return promise.future(); - } - - /** - * This method will provide data form ES based on incoming identifier. we can get data by passing - * index and identifier values , or all the three - * - * @param identifier String - * @return Map or empty map - */ - @Override - public Future> getDataByIdentifier(String index, String identifier) { - long startTime = System.currentTimeMillis(); - Promise> promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchTcpImpl:getDataByIdentifier: method started at ==" - + startTime - + " for index " - + index, - LoggerEnum.PERF_LOG.name()); - GetResponse response = null; - if (StringUtils.isBlank(index) || StringUtils.isBlank(identifier)) { - ProjectLogger.log( - "ElasticSearchTcpImpl:getDataByIdentifier: Invalid request is coming.", - LoggerEnum.INFO.name()); - promise.success(new HashMap<>()); - return promise.future(); - } else { - response = ConnectionManager.getClient().prepareGet(index, _DOC, identifier).get(); - } - if (response == null || null == response.getSource()) { - promise.success(new HashMap<>()); - return promise.future(); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:getDataByIdentifier: method " - + " for index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(response.getSource()); - return promise.future(); - } - - /** - * This method will update data based on identifier.take the data based on identifier and merge - * with incoming data then update it. - * - * @param index String - * @param identifier String - * @param data Map - * @return boolean - */ - @Override - public Future update(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchTcpImpl:update: method started at ==" + startTime + " for index " + index, - LoggerEnum.PERF_LOG.name()); - if (!StringUtils.isBlank(index) && !StringUtils.isBlank(identifier) && data != null) { - try { - UpdateResponse response = - ConnectionManager.getClient().prepareUpdate(index, _DOC, identifier).setDoc(data).get(); - ProjectLogger.log( - "ElasticSearchTcpImpl:update: " + "updated response==" + response.getResult().name(), - LoggerEnum.INFO.name()); - if (response.getResult().name().equals("UPDATED")) { - ProjectLogger.log( - "ElasticSearchTcpImpl:update: method end ==" - + " for index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(true); - return promise.future(); - } else { - ProjectLogger.log( - "ElasticSearchTcpImpl:update: update was not success:" + response.getResult(), - LoggerEnum.INFO.name()); - } - } catch (Exception e) { - ProjectLogger.log( - "ElasticSearchTcpImpl:update: exception occured:" + e.getMessage(), - LoggerEnum.ERROR.name()); - promise.failure(e); - } - } else { - ProjectLogger.log( - "ElasticSearchTcpImpl:update: Requested data is invalid.", LoggerEnum.INFO.name()); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:update: method end ==" - + " for Index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(false); - return promise.future(); - } - - /** - * This method will upsert data based on identifier.take the data based on identifier and merge - * with incoming data then update it and if identifier does not exist , it will insert data . - * - * @param index String - * @param identifier String - * @param data Map - * @return boolean - */ - @Override - public Future upsert(String index, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchTcpImpl:upsert: method started at ==" + startTime + " for INdex " + index, - LoggerEnum.PERF_LOG.name()); - if (!StringUtils.isBlank(index) - && !StringUtils.isBlank(identifier) - && data != null - && data.size() > 0) { - IndexRequest indexRequest = new IndexRequest(index, _DOC, identifier).source(data); - UpdateRequest updateRequest = - new UpdateRequest(index, _DOC, identifier).doc(data).upsert(indexRequest); - UpdateResponse response = null; - try { - response = ConnectionManager.getClient().update(updateRequest).get(); - } catch (InterruptedException | ExecutionException e) { - ProjectLogger.log("ElasticSearchTcpImpl:upsert: error occured == " + e.getMessage(), e); - promise.success(false); - return promise.future(); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:upsert: updated response==" + response.getResult().name(), - LoggerEnum.INFO.name()); - if (ElasticSearchHelper.upsertResults.contains(response.getResult().name())) { - ProjectLogger.log( - "ElasticSearchTcpImpl:upsert: method end ==" - + " for index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(true); - return promise.future(); - } - } else { - ProjectLogger.log( - "ElasticSearchTcpImpl:upsert: Requested data is invalid.", LoggerEnum.INFO.name()); - promise.success(false); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:upsert: method end ==" - + " for index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - return promise.future(); - } - - /** - * This method will remove data from ES based on identifier. - * - * @param index String - * @param identifier String - */ - @Override - public Future delete(String index, String identifier) { - long startTime = System.currentTimeMillis(); - Promise promise = Futures.promise(); - ProjectLogger.log( - "ElasticSearchTcpImpl:delete: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - DeleteResponse deleteResponse = null; - if (!StringUtils.isBlank(index) && !StringUtils.isBlank(identifier)) { - try { - deleteResponse = ConnectionManager.getClient().prepareDelete(index, _DOC, identifier).get(); - ProjectLogger.log( - "ElasticSearchTcpImpl:delete: info ==" - + deleteResponse.getResult().name() - + " " - + deleteResponse.getId(), - LoggerEnum.INFO.name()); - } catch (Exception e) { - promise.failure(e); - ProjectLogger.log( - "ElasticSearchTcpImpl:delete: error occured for index and identifier == " - + index - + " and " - + identifier - + " with error " - + e.getMessage(), - e); - } - } else { - ProjectLogger.log( - "ElasticSearchTcpImpl:delete: Data can not be deleted due to invalid input.", - LoggerEnum.INFO.name()); - promise.success(false); - return promise.future(); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:delete: method end ==" - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(deleteResponse.getResult().name().equalsIgnoreCase("DELETED")); - return promise.future(); - } - - /** - * Method to perform the elastic search on the basis of SearchDTO . SearchDTO contains the search - * criteria like fields, facets, sort by ,range, filters etc. - * - * @return search result as Map. - */ - @Override - public Future> search(SearchDTO searchDTO, String index) { - - long startTime = System.currentTimeMillis(); - Promise> promise = Futures.promise(); - String[] indices = {index}; - - ProjectLogger.log( - "ElasticSearchTcpImpl:search: method started at ==" + startTime, - LoggerEnum.PERF_LOG.name()); - SearchRequestBuilder searchRequestBuilder = - ElasticSearchHelper.getTransportSearchBuilder(ConnectionManager.getClient(), indices); - // check mode and set constraints - Map constraintsMap = ElasticSearchHelper.getConstraints(searchDTO); - - BoolQueryBuilder query = new BoolQueryBuilder(); - - // add channel field as mandatory - String channel = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ES_CHANNEL); - if (!(StringUtils.isBlank(channel) || JsonKey.SUNBIRD_ES_CHANNEL.equals(channel))) { - query.must( - ElasticSearchHelper.createMatchQuery( - JsonKey.CHANNEL, channel, constraintsMap.get(JsonKey.CHANNEL))); - } - - // apply simple query string - if (!StringUtils.isBlank(searchDTO.getQuery())) { - SimpleQueryStringBuilder sqsb = QueryBuilders.simpleQueryStringQuery(searchDTO.getQuery()); - if (CollectionUtils.isEmpty(searchDTO.getQueryFields())) { - query.must(sqsb.field("all_fields")); - } else { - Map searchFields = - searchDTO - .getQueryFields() - .stream() - .collect(Collectors.toMap(s -> s, v -> 1.0f)); - query.must(sqsb.fields(searchFields)); - } - } - // apply the sorting - if (searchDTO.getSortBy() != null && searchDTO.getSortBy().size() > 0) { - for (Map.Entry entry : searchDTO.getSortBy().entrySet()) { - if (!entry.getKey().contains(".")) { - searchRequestBuilder.addSort( - entry.getKey() + ElasticSearchHelper.RAW_APPEND, - ElasticSearchHelper.getSortOrder((String) entry.getValue())); - } else { - Map map = (Map) entry.getValue(); - Map dataMap = (Map) map.get(JsonKey.TERM); - for (Map.Entry dateMapEntry : dataMap.entrySet()) { - FieldSortBuilder mySort = - SortBuilders.fieldSort(entry.getKey() + ElasticSearchHelper.RAW_APPEND) - .setNestedFilter( - new TermQueryBuilder(dateMapEntry.getKey(), dateMapEntry.getValue())) - .sortMode(SortMode.MIN) - .order(ElasticSearchHelper.getSortOrder((String) map.get(JsonKey.ORDER))); - searchRequestBuilder.addSort(mySort); - } - } - } - } - - // apply the fields filter - searchRequestBuilder.setFetchSource( - searchDTO.getFields() != null - ? searchDTO.getFields().stream().toArray(String[]::new) - : null, - searchDTO.getExcludedFields() != null - ? searchDTO.getExcludedFields().stream().toArray(String[]::new) - : null); - - // setting the offset - if (searchDTO.getOffset() != null) { - searchRequestBuilder.setFrom(searchDTO.getOffset()); - } - - // setting the limit - if (searchDTO.getLimit() != null) { - searchRequestBuilder.setSize(searchDTO.getLimit()); - } - // apply additional properties - if (searchDTO.getAdditionalProperties() != null - && searchDTO.getAdditionalProperties().size() > 0) { - for (Map.Entry entry : searchDTO.getAdditionalProperties().entrySet()) { - ElasticSearchHelper.addAdditionalProperties(query, entry, constraintsMap); - } - } - - // set final query to search request builder - searchRequestBuilder.setQuery(query); - List finalFacetList = new ArrayList(); - - if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) { - searchRequestBuilder = - ElasticSearchHelper.addAggregations(searchRequestBuilder, searchDTO.getFacets()); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:search: calling search builder ==" + searchRequestBuilder.toString(), - LoggerEnum.INFO.name()); - SearchResponse response = null; - try { - response = searchRequestBuilder.execute().actionGet(); - } catch (SearchPhaseExecutionException e) { - promise.failure(e); - ProjectCommonException.throwClientErrorException( - ResponseCode.invalidValue, e.getRootCause().getMessage()); - } - - Map responseMap = - ElasticSearchHelper.getSearchResponseMap(response, searchDTO, finalFacetList); - ProjectLogger.log( - "ElasticSearchTcpImpl:search: method end" - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - promise.success(responseMap); - return promise.future(); - } - /** - * @param List of document's ids - * @param fields List of fields which needs to captured - * @param index of elastic search in which search need to be done - * @return Map> It will return a map with id as key and the data from ES - * as value - */ - @Override - public Future>> getEsResultByListOfIds( - List ids, List fields, String index) { - - Map filters = new HashMap<>(); - filters.put(JsonKey.ID, ids); - - SearchDTO searchDTO = new SearchDTO(); - searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters); - searchDTO.setFields(fields); - - Future> resultF = search(searchDTO, index); - Map result = - (Map) ElasticSearchHelper.getResponseFromFuture(resultF); - List> esContent = (List>) result.get(JsonKey.CONTENT); - Promise>> promise = Futures.promise(); - promise.success( - esContent - .stream() - .collect( - Collectors.toMap( - obj -> { - return (String) obj.get("id"); - }, - val -> val))); - ProjectLogger.log( - "ElasticSearchTcpImpl:getEsResultByListOfIds: method complete for for index " + index, - LoggerEnum.INFO.name()); - return promise.future(); - } - - /** - * This method will do the bulk data insertion. - * - * @param index String index name - * @param dataList List> - * @return boolean - */ - @Override - public Future bulkInsert(String index, List> dataList) { - Promise promise = Futures.promise(); - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchTcpImpl:bulkInsert: method started at ==" + startTime + " for index " + index, - LoggerEnum.PERF_LOG.name()); - promise.success(true); - try { - BulkProcessor bulkProcessor = - BulkProcessor.builder( - ConnectionManager.getClient(), - new BulkProcessor.Listener() { - @Override - public void beforeBulk(long executionId, BulkRequest request) {} - - @Override - public void afterBulk( - long executionId, BulkRequest request, BulkResponse response) { - Iterator bulkResponse = response.iterator(); - if (bulkResponse != null) { - while (bulkResponse.hasNext()) { - BulkItemResponse bResponse = bulkResponse.next(); - ProjectLogger.log( - "ElasticSearchTcpImpl:bulkInsert: " - + "Bulk insert api response===" - + bResponse.getId() - + " " - + bResponse.isFailed(), - LoggerEnum.INFO.name()); - } - } - } - - @Override - public void afterBulk( - long executionId, BulkRequest request, Throwable failure) { - ProjectLogger.log( - "ElasticSearchTcpImpl:bulkInsert: Bulk upload error block with error " - + failure, - LoggerEnum.INFO.name()); - } - }) - .setBulkActions(10000) - .setConcurrentRequests(0) - .build(); - - for (Map map : dataList) { - map.put(JsonKey.IDENTIFIER, map.get(JsonKey.ID)); - IndexRequest request = - new IndexRequest(index, _DOC, (String) map.get(JsonKey.IDENTIFIER)).source(map); - bulkProcessor.add(request); - } - // Flush any remaining requests - bulkProcessor.flush(); - - // Or close the bulkProcessor if you don't need it anymore - bulkProcessor.close(); - - // Refresh your indices - ConnectionManager.getClient().admin().indices().prepareRefresh().get(); - } catch (Exception e) { - promise.success(false); - ProjectLogger.log("ElasticSearchTcpImpl:bulkInsert: Bulk upload error " + e.getMessage(), e); - } - ProjectLogger.log( - "ElasticSearchTcpImpl:bulkInsert: method end at ==" - + System.currentTimeMillis() - + " for index " - + index - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG.name()); - return promise.future(); - } - - /** - * This method will do the health check of elastic search. - * - * @return boolean - */ - @Override - public Future healthCheck() { - Promise promise = Futures.promise(); - - boolean indexResponse = false; - try { - indexResponse = - ConnectionManager.getClient() - .admin() - .indices() - .exists(Requests.indicesExistsRequest(ProjectUtil.EsType.user.getTypeName())) - .get() - .isExists(); - } catch (Exception e) { - ProjectLogger.log("ElasticSearchTcpImpl:healthCheck: error " + e.getMessage(), e); - promise.failure(e); - } - promise.success(indexResponse); - return promise.future(); - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchUtil.java b/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchUtil.java deleted file mode 100644 index bd8ae9025..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/ElasticSearchUtil.java +++ /dev/null @@ -1,1219 +0,0 @@ -package org.sunbird.common; - -import static org.sunbird.common.models.util.ProjectUtil.isNotNull; - -import akka.dispatch.Futures; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.typesafe.config.Config; -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.bulk.BulkProcessor; -import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.search.SearchPhaseExecutionException; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.action.update.UpdateResponse; -import org.elasticsearch.client.Requests; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.ExistsQueryBuilder; -import org.elasticsearch.index.query.MatchQueryBuilder; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.elasticsearch.index.query.SimpleQueryStringBuilder; -import org.elasticsearch.index.query.TermQueryBuilder; -import org.elasticsearch.index.query.TermsQueryBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.search.sort.FieldSortBuilder; -import org.elasticsearch.search.sort.SortBuilders; -import org.elasticsearch.search.sort.SortMode; -import org.elasticsearch.search.sort.SortOrder; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.common.util.ConfigUtil; -import org.sunbird.dto.SearchDTO; -import org.sunbird.helper.ConnectionManager; -import scala.concurrent.Future; -import scala.concurrent.Promise; - -/** - * This class will provide all required operation for elastic search. - * - * @author arvind - * @author Manzarul - */ -public class ElasticSearchUtil { - - private static final String LTE = "<="; - private static final String LT = "<"; - private static final String GTE = ">="; - private static final String GT = ">"; - private static final String ASC_ORDER = "ASC"; - public static final String STARTS_WITH = "startsWith"; - private static final String ENDS_WITH = "endsWith"; - private static final List upsertResults = - new ArrayList<>(Arrays.asList("CREATED", "UPDATED", "NOOP")); - private static final String SOFT_MODE = "soft"; - private static final String RAW_APPEND = ".raw"; - protected static Map indexMap = new HashMap<>(); - protected static Map typeMap = new HashMap<>(); - protected static final String ES_CONFIG_FILE = "elasticsearch.conf"; - private static Config config = ConfigUtil.getConfig(ES_CONFIG_FILE); - - private ElasticSearchUtil() {} - - /** - * This method will put a new data entry inside Elastic search. identifier value becomes _id - * inside ES, so every time provide a unique value while saving it. - * - * @param index String ES index name - * @param type String ES type name - * @param identifier ES column identifier as an String - * @param data Map - * @return String identifier for created data - */ - public static String createData( - String index, String type, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil createData method started at ==" + startTime + " for Type " + type, - LoggerEnum.PERF_LOG); - if (StringUtils.isBlank(identifier) - || StringUtils.isBlank(type) - || StringUtils.isBlank(index)) { - ProjectLogger.log("Identifier value is null or empty ,not able to save data."); - return "ERROR"; - } - Map mappedIndexAndType = getMappedIndexAndType(index, type); - try { - data.put("identifier", identifier); - IndexResponse response = - ConnectionManager.getClient() - .prepareIndex( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .setSource(data) - .get(); - ProjectLogger.log( - "Save value==" + response.getId() + " " + response.status(), LoggerEnum.INFO.name()); - ProjectLogger.log( - "ElasticSearchUtil createData method end at ==" - + System.currentTimeMillis() - + " for Type " - + type - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG); - return response.getId(); - } catch (Exception e) { - ProjectLogger.log("Error while saving " + type + " id : " + identifier, e); - ProjectLogger.log( - "ElasticSearchUtil createData method end at ==" - + System.currentTimeMillis() - + " for Type " - + type - + " ,Total time elapsed = " - + calculateEndTime(startTime), - LoggerEnum.PERF_LOG); - return ""; - } - } - - /** - * This method will provide data form ES based on incoming identifier. we can get data by passing - * index and identifier values , or all the three - * - * @param type String - * @param identifier String - * @return Map or null - */ - public static Map getDataByIdentifier( - String index, String type, String identifier) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil getDataByIdentifier method started at ==" - + startTime - + " for Type " - + type, - LoggerEnum.PERF_LOG); - Map mappedIndexAndType = getMappedIndexAndType(index, type); - GetResponse response = null; - if (StringUtils.isBlank(index) || StringUtils.isBlank(identifier)) { - ProjectLogger.log("Invalid request is coming."); - return new HashMap<>(); - } else if (StringUtils.isBlank(type)) { - response = - ConnectionManager.getClient() - .prepareGet() - .setIndex(mappedIndexAndType.get(JsonKey.INDEX)) - .setId(identifier) - .get(); - } else { - response = - ConnectionManager.getClient() - .prepareGet( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .get(); - } - if (response == null || null == response.getSource()) { - return new HashMap<>(); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil getDataByIdentifier method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response.getSource(); - } - - /** - * This method will do the data search inside ES. based on incoming search data. - * - * @param index String - * @param type String - * @param searchData Map - * @return Map - */ - public static Map searchData( - String index, String type, Map searchData) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil searchData method started at ==" + startTime + " for Type " + type, - LoggerEnum.PERF_LOG); - SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); - Iterator> itr = searchData.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - sourceBuilder.query(QueryBuilders.commonTermsQuery(entry.getKey(), entry.getValue())); - } - Map mappedIndexAndType = getMappedIndexAndType(index, type); - SearchResponse sr = null; - try { - sr = - ConnectionManager.getClient() - .search( - new SearchRequest(mappedIndexAndType.get(JsonKey.INDEX)) - .types(mappedIndexAndType.get(JsonKey.TYPE)) - .source(sourceBuilder)) - .get(); - } catch (InterruptedException e) { - ProjectLogger.log("Error, interrupted while connecting to Elasticsearch", e); - Thread.currentThread().interrupt(); - } catch (ExecutionException e) { - ProjectLogger.log("Error while execution in Elasticsearch", e); - } - if (sr.getHits() == null || sr.getHits().getTotalHits() == 0) { - return new HashMap<>(); - } - sr.getHits().getAt(0); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil searchData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return sr.getAggregations().asList().get(0).getMetaData(); - } - - /** - * This method will update data based on identifier.take the data based on identifier and merge - * with incoming data then update it. - * - * @param index String - * @param type String - * @param identifier String - * @param data Map - * @return boolean - */ - public static boolean updateData( - String index, String type, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil updateData method started at ==" + startTime + " for Type " + type, - LoggerEnum.PERF_LOG); - if (!StringUtils.isBlank(index) - && !StringUtils.isBlank(type) - && !StringUtils.isBlank(identifier) - && data != null) { - Map mappedIndexAndType = getMappedIndexAndType(index, type); - try { - UpdateResponse response = - ConnectionManager.getClient() - .prepareUpdate( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .setDoc(data) - .get(); - ProjectLogger.log( - "updated response==" + response.getResult().name(), LoggerEnum.INFO.name()); - if (response.getResult().name().equals("UPDATED")) { - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil updateData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return true; - } else { - ProjectLogger.log( - "ElasticSearchUtil:updateData update was not success:" + response.getResult(), - LoggerEnum.INFO.name()); - } - } catch (Exception e) { - ProjectLogger.log( - "ElasticSearchUtil:updateData exception occured:" + e.getMessage(), - LoggerEnum.ERROR.name()); - } - } else { - ProjectLogger.log( - "ElasticSearchUtil:updateData Requested data is invalid.", LoggerEnum.INFO.name()); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil updateData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return false; - } - - /** - * This method will upser data based on identifier.take the data based on identifier and merge - * with incoming data then update it and if identifier does not exist , it will insert data . - * - * @param index String - * @param type String - * @param identifier String - * @param data Map - * @return boolean - */ - public static boolean upsertData( - String index, String type, String identifier, Map data) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil upsertData method started at ==" + startTime + " for Type " + type, - LoggerEnum.PERF_LOG); - if (!StringUtils.isBlank(index) - && !StringUtils.isBlank(type) - && !StringUtils.isBlank(identifier) - && data != null - && data.size() > 0) { - Map mappedIndexAndType = getMappedIndexAndType(index, type); - IndexRequest indexRequest = - new IndexRequest( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .source(data); - UpdateRequest updateRequest = - new UpdateRequest( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .doc(data) - .upsert(indexRequest); - UpdateResponse response = null; - try { - response = ConnectionManager.getClient().update(updateRequest).get(); - } catch (InterruptedException | ExecutionException e) { - ProjectLogger.log(e.getMessage(), e); - return false; - } - ProjectLogger.log("updated response==" + response.getResult().name()); - if (upsertResults.contains(response.getResult().name())) { - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil upsertData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return true; - } - } else { - ProjectLogger.log("Requested data is invalid."); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil upsertData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return false; - } - - /** - * This method will remove data from ES based on identifier. - * - * @param index String - * @param type String - * @param identifier String - */ - public static boolean removeData(String index, String type, String identifier) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil removeData method started at ==" + startTime, LoggerEnum.PERF_LOG); - DeleteResponse deleteResponse = null; - if (!StringUtils.isBlank(index) - && !StringUtils.isBlank(type) - && !StringUtils.isBlank(identifier)) { - Map mappedIndexAndType = getMappedIndexAndType(index, type); - try { - deleteResponse = - ConnectionManager.getClient() - .prepareDelete( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - identifier) - .get(); - ProjectLogger.log( - "delete info ==" + deleteResponse.getResult().name() + " " + deleteResponse.getId()); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - } else { - ProjectLogger.log("Data can not be deleted due to invalid input."); - return false; - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil removeData method end at ==" - + stopTime - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - - return (deleteResponse.getResult().name().equalsIgnoreCase("DELETED")); - } - - /** - * Method to perform the elastic search on the basis of SearchDTO . SearchDTO contains the search - * criteria like fields, facets, sort by , filters etc. here user can pass single type to search - * or multiple type or null - * - * @param type var arg of String - * @return search result as Map. - */ - public static Map complexSearch( - SearchDTO searchDTO, String index, String... type) { - long startTime = System.currentTimeMillis(); - List> indicesAndTypesMapping = getMappedIndexesAndTypes(index, type); - String[] indices = - indicesAndTypesMapping - .stream() - .map(indexMap -> indexMap.get(JsonKey.INDEX)) - .toArray(String[]::new); - String[] types = - indicesAndTypesMapping - .stream() - .map(indexMap -> indexMap.get(JsonKey.TYPE)) - .distinct() - .toArray(String[]::new); - ProjectLogger.log( - "ElasticSearchUtil complexSearch method started at ==" + startTime, LoggerEnum.PERF_LOG); - SearchRequestBuilder searchRequestBuilder = - getSearchBuilder(ConnectionManager.getClient(), indices, types); - // check mode and set constraints - Map constraintsMap = getConstraints(searchDTO); - - BoolQueryBuilder query = new BoolQueryBuilder(); - - // add channel field as mandatory - String channel = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ES_CHANNEL); - if (!(StringUtils.isBlank(channel) || JsonKey.SUNBIRD_ES_CHANNEL.equals(channel))) { - query.must(createMatchQuery(JsonKey.CHANNEL, channel, constraintsMap.get(JsonKey.CHANNEL))); - } - - // apply simple query string - if (!StringUtils.isBlank(searchDTO.getQuery())) { - SimpleQueryStringBuilder sqsb = QueryBuilders.simpleQueryStringQuery(searchDTO.getQuery()); - if (CollectionUtils.isEmpty(searchDTO.getQueryFields())) { - query.must(sqsb.field("all_fields")); - } else { - Map searchFields = - searchDTO - .getQueryFields() - .stream() - .collect(Collectors.toMap(s -> s, v -> 1.0f)); - query.must(sqsb.fields(searchFields)); - } - } - // apply the sorting - if (searchDTO.getSortBy() != null && searchDTO.getSortBy().size() > 0) { - for (Map.Entry entry : searchDTO.getSortBy().entrySet()) { - if (!entry.getKey().contains(".")) { - searchRequestBuilder.addSort( - entry.getKey() + RAW_APPEND, getSortOrder((String) entry.getValue())); - } else { - Map map = (Map) entry.getValue(); - Map dataMap = (Map) map.get(JsonKey.TERM); - for (Map.Entry dateMapEntry : dataMap.entrySet()) { - FieldSortBuilder mySort = - SortBuilders.fieldSort(entry.getKey() + RAW_APPEND) - .setNestedFilter( - new TermQueryBuilder(dateMapEntry.getKey(), dateMapEntry.getValue())) - .sortMode(SortMode.MIN) - .order(getSortOrder((String) map.get(JsonKey.ORDER))); - searchRequestBuilder.addSort(mySort); - } - } - } - } - - // apply the fields filter - searchRequestBuilder.setFetchSource( - searchDTO.getFields() != null - ? searchDTO.getFields().stream().toArray(String[]::new) - : null, - searchDTO.getExcludedFields() != null - ? searchDTO.getExcludedFields().stream().toArray(String[]::new) - : null); - - // setting the offset - if (searchDTO.getOffset() != null) { - searchRequestBuilder.setFrom(searchDTO.getOffset()); - } - - // setting the limit - if (searchDTO.getLimit() != null) { - searchRequestBuilder.setSize(searchDTO.getLimit()); - } - // apply additional properties - if (searchDTO.getAdditionalProperties() != null - && searchDTO.getAdditionalProperties().size() > 0) { - for (Map.Entry entry : searchDTO.getAdditionalProperties().entrySet()) { - addAdditionalProperties(query, entry, constraintsMap); - } - } - - // set final query to search request builder - searchRequestBuilder.setQuery(query); - List finalFacetList = new ArrayList(); - - if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) { - addAggregations(searchRequestBuilder, searchDTO.getFacets()); - } - ProjectLogger.log( - "calling search builder======" + searchRequestBuilder.toString(), LoggerEnum.INFO.name()); - SearchResponse response = null; - try { - response = searchRequestBuilder.execute().actionGet(); - } catch (SearchPhaseExecutionException e) { - ProjectCommonException.throwClientErrorException( - ResponseCode.invalidValue, e.getRootCause().getMessage()); - } - - List> esSource = new ArrayList<>(); - Map responsemap = new HashMap<>(); - long count = 0; - if (response != null) { - SearchHits hits = response.getHits(); - count = hits.getTotalHits(); - - for (SearchHit hit : hits) { - esSource.add(hit.getSourceAsMap()); - } - - // fetch aggregations aggregations - if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) { - Map m1 = searchDTO.getFacets().get(0); - for (Map.Entry entry : m1.entrySet()) { - String field = entry.getKey(); - String aggsType = entry.getValue(); - List aggsList = new ArrayList<>(); - Map facetMap = new HashMap(); - if (JsonKey.DATE_HISTOGRAM.equalsIgnoreCase(aggsType)) { - Histogram agg = response.getAggregations().get(field); - for (Histogram.Bucket ent : agg.getBuckets()) { - // DateTime key = (DateTime) ent.getKey(); // Key - String keyAsString = ent.getKeyAsString(); // Key as String - long docCount = ent.getDocCount(); // Doc count - Map internalMap = new HashMap(); - internalMap.put(JsonKey.NAME, keyAsString); - internalMap.put(JsonKey.COUNT, docCount); - aggsList.add(internalMap); - } - } else { - Terms aggs = response.getAggregations().get(field); - for (Bucket bucket : aggs.getBuckets()) { - Map internalMap = new HashMap(); - internalMap.put(JsonKey.NAME, bucket.getKey()); - internalMap.put(JsonKey.COUNT, bucket.getDocCount()); - aggsList.add(internalMap); - } - } - facetMap.put("values", aggsList); - facetMap.put(JsonKey.NAME, field); - finalFacetList.add(facetMap); - } - } - } - responsemap.put(JsonKey.CONTENT, esSource); - if (!(finalFacetList.isEmpty())) { - responsemap.put(JsonKey.FACETS, finalFacetList); - } - responsemap.put(JsonKey.COUNT, count); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil complexSearch method end at ==" - + stopTime - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return responsemap; - } - - private static void addAggregations( - SearchRequestBuilder searchRequestBuilder, List> facets) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil addAggregations method started at ==" + startTime, LoggerEnum.PERF_LOG); - Map map = facets.get(0); - for (Map.Entry entry : map.entrySet()) { - - String key = entry.getKey(); - String value = entry.getValue(); - if (JsonKey.DATE_HISTOGRAM.equalsIgnoreCase(value)) { - searchRequestBuilder.addAggregation( - AggregationBuilders.dateHistogram(key) - .field(key + RAW_APPEND) - .dateHistogramInterval(DateHistogramInterval.days(1))); - - } else if (null == value) { - searchRequestBuilder.addAggregation(AggregationBuilders.terms(key).field(key + RAW_APPEND)); - } - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil addAggregations method end at ==" - + stopTime - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - } - - private static Map getConstraints(SearchDTO searchDTO) { - if (null != searchDTO.getSoftConstraints() && !searchDTO.getSoftConstraints().isEmpty()) { - return searchDTO - .getSoftConstraints() - .entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().floatValue())); - } - return Collections.emptyMap(); - } - - private static SearchRequestBuilder getSearchBuilder( - TransportClient client, String[] index, String... type) { - - if (type == null || type.length == 0) { - return client.prepareSearch().setIndices(index); - } else { - return client.prepareSearch().setIndices(index).setTypes(type); - } - } - - /** Method to add the additional search query like range query , exists - not exist filter etc. */ - @SuppressWarnings("unchecked") - private static void addAdditionalProperties( - BoolQueryBuilder query, Entry entry, Map constraintsMap) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil addAdditionalProperties method started at ==" + startTime, - LoggerEnum.PERF_LOG); - String key = entry.getKey(); - - if (key.equalsIgnoreCase(JsonKey.FILTERS)) { - - Map filters = (Map) entry.getValue(); - for (Map.Entry en : filters.entrySet()) { - createFilterESOpperation(en, query, constraintsMap); - } - } else if (key.equalsIgnoreCase(JsonKey.EXISTS) || key.equalsIgnoreCase(JsonKey.NOT_EXISTS)) { - createESOpperation(entry, query, constraintsMap); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil addAdditionalProperties method end at ==" - + stopTime - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - } - - /** Method to create CommonTermQuery , multimatch and Range Query. */ - @SuppressWarnings("unchecked") - private static void createFilterESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - - String key = entry.getKey(); - Object val = entry.getValue(); - if (val instanceof List) { - if (!((List) val).isEmpty()) { - if (((List) val).get(0) instanceof String) { - ((List) val).replaceAll(String::toLowerCase); - query.must( - createTermsQuery(key + RAW_APPEND, (List) val, constraintsMap.get(key))); - } else { - query.must(createTermsQuery(key, (List) val, constraintsMap.get(key))); - } - } - } else if (val instanceof Map) { - Map value = (Map) val; - Map rangeOperation = new HashMap<>(); - Map lexicalOperation = new HashMap<>(); - for (Map.Entry it : value.entrySet()) { - String operation = it.getKey(); - if (operation.startsWith(LT) || operation.startsWith(GT)) { - rangeOperation.put(operation, it.getValue()); - } else if (operation.startsWith(STARTS_WITH) || operation.startsWith(ENDS_WITH)) { - lexicalOperation.put(operation, it.getValue()); - } - } - if (!(rangeOperation.isEmpty())) { - query.must(createRangeQuery(key, rangeOperation, constraintsMap.get(key))); - } - if (!(lexicalOperation.isEmpty())) { - query.must(createLexicalQuery(key, lexicalOperation, constraintsMap.get(key))); - } - - } else if (val instanceof String) { - query.must( - createTermQuery(key + RAW_APPEND, ((String) val).toLowerCase(), constraintsMap.get(key))); - } else { - query.must(createTermQuery(key + RAW_APPEND, val, constraintsMap.get(key))); - } - } - - /** Method to create EXISTS and NOT EXIST FILTER QUERY . */ - @SuppressWarnings("unchecked") - private static void createESOpperation( - Entry entry, BoolQueryBuilder query, Map constraintsMap) { - - String operation = entry.getKey(); - List existsList = (List) entry.getValue(); - - if (operation.equalsIgnoreCase(JsonKey.EXISTS)) { - for (String name : existsList) { - query.must(createExistQuery(name, constraintsMap.get(name))); - } - } else if (operation.equalsIgnoreCase(JsonKey.NOT_EXISTS)) { - for (String name : existsList) { - query.mustNot(createExistQuery(name, constraintsMap.get(name))); - } - } - } - - /** Method to return the sorting order on basis of string param . */ - private static SortOrder getSortOrder(String value) { - return value.equalsIgnoreCase(ASC_ORDER) ? SortOrder.ASC : SortOrder.DESC; - } - - private static MatchQueryBuilder createMatchQuery(String name, Object text, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.matchQuery(name, text).boost(boost); - } else { - return QueryBuilders.matchQuery(name, text); - } - } - - private static TermsQueryBuilder createTermsQuery(String key, List values, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.termsQuery(key, (values).stream().toArray(Object[]::new)).boost(boost); - } else { - return QueryBuilders.termsQuery(key, (values).stream().toArray(Object[]::new)); - } - } - - private static RangeQueryBuilder createRangeQuery( - String name, Map rangeOperation, Float boost) { - - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(name + RAW_APPEND); - for (Map.Entry it : rangeOperation.entrySet()) { - if (it.getKey().equalsIgnoreCase(LTE)) { - rangeQueryBuilder.lte(it.getValue()); - } else if (it.getKey().equalsIgnoreCase(LT)) { - rangeQueryBuilder.lt(it.getValue()); - } else if (it.getKey().equalsIgnoreCase(GTE)) { - rangeQueryBuilder.gte(it.getValue()); - } else if (it.getKey().equalsIgnoreCase(GT)) { - rangeQueryBuilder.gt(it.getValue()); - } - } - if (isNotNull(boost)) { - return rangeQueryBuilder.boost(boost); - } - return rangeQueryBuilder; - } - - private static TermQueryBuilder createTermQuery(String name, Object text, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.termQuery(name, text).boost(boost); - } else { - return QueryBuilders.termQuery(name, text); - } - } - - private static ExistsQueryBuilder createExistQuery(String name, Float boost) { - if (isNotNull(boost)) { - return QueryBuilders.existsQuery(name).boost(boost); - } else { - return QueryBuilders.existsQuery(name); - } - } - - private static QueryBuilder createLexicalQuery( - String key, Map rangeOperation, Float boost) { - QueryBuilder queryBuilder = null; - for (Map.Entry it : rangeOperation.entrySet()) { - if (it.getKey().equalsIgnoreCase(STARTS_WITH)) { - String startsWithVal = (String) it.getValue(); - if (StringUtils.isNotBlank(startsWithVal)) { - startsWithVal = startsWithVal.toLowerCase(); - } - if (isNotNull(boost)) { - queryBuilder = QueryBuilders.prefixQuery(key + RAW_APPEND, startsWithVal).boost(boost); - } - queryBuilder = QueryBuilders.prefixQuery(key + RAW_APPEND, startsWithVal); - } else if (it.getKey().equalsIgnoreCase(ENDS_WITH)) { - String endsWithRegex = "~" + it.getValue(); - if (isNotNull(boost)) { - queryBuilder = QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex).boost(boost); - } - queryBuilder = QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex); - } - } - return queryBuilder; - } - - /** - * This method will do the bulk data insertion. - * - * @param index String index name - * @param type String type name - * @param dataList List> - * @return boolean - */ - public static boolean bulkInsertData( - String index, String type, List> dataList) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchUtil bulkInsertData method started at ==" + startTime + " for Type " + type, - LoggerEnum.PERF_LOG); - boolean response = true; - Map mappedIndexAndType = getMappedIndexAndType(index, type); - try { - BulkProcessor bulkProcessor = - BulkProcessor.builder( - ConnectionManager.getClient(), - new BulkProcessor.Listener() { - @Override - public void beforeBulk(long executionId, BulkRequest request) {} - - @Override - public void afterBulk( - long executionId, BulkRequest request, BulkResponse response) { - Iterator bulkResponse = response.iterator(); - if (bulkResponse != null) { - while (bulkResponse.hasNext()) { - BulkItemResponse bResponse = bulkResponse.next(); - ProjectLogger.log( - "Bulk insert api response===" - + bResponse.getId() - + " " - + bResponse.isFailed()); - } - } - } - - @Override - public void afterBulk( - long executionId, BulkRequest request, Throwable failure) { - ProjectLogger.log("Bulk upload error block", failure); - } - }) - .setBulkActions(10000) - .setConcurrentRequests(0) - .build(); - - for (Map map : dataList) { - map.put(JsonKey.IDENTIFIER, map.get(JsonKey.ID)); - IndexRequest request = - new IndexRequest( - mappedIndexAndType.get(JsonKey.INDEX), - mappedIndexAndType.get(JsonKey.TYPE), - (String) map.get(JsonKey.IDENTIFIER)) - .source(map); - bulkProcessor.add(request); - } - // Flush any remaining requests - bulkProcessor.flush(); - - // Or close the bulkProcessor if you don't need it anymore - bulkProcessor.close(); - - // Refresh your indices - ConnectionManager.getClient().admin().indices().prepareRefresh().get(); - } catch (Exception e) { - response = false; - ProjectLogger.log(e.getMessage(), e); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil bulkInsertData method end at ==" - + stopTime - + " for Type " - + type - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response; - } - - /** - * This method will do the health check of elastic search. - * - * @return boolean - */ - public static boolean healthCheck() { - boolean indexResponse = false; - Map mappedIndexAndType = - getMappedIndexAndType( - ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.user.getTypeName()); - try { - indexResponse = - ConnectionManager.getClient() - .admin() - .indices() - .exists(Requests.indicesExistsRequest(mappedIndexAndType.get(JsonKey.INDEX))) - .get() - .isExists(); - } catch (Exception e) { - ProjectLogger.log("ElasticSearchUtil:healthCheck error " + e.getMessage(), e); - } - return indexResponse; - } - - /** - * Method to execute ES query with the limitation of size set to 0 Currently this is a rest call - * - * @param index ES indexName - * @param type ES type - * @param rawQuery actual query to be executed - * @return ES response for the query - */ - @SuppressWarnings("unchecked") - public static Response searchMetricsData(String index, String type, String rawQuery) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log("Metrics search method started at ==" + startTime, LoggerEnum.PERF_LOG); - String baseUrl = null; - if (!StringUtils.isBlank(System.getenv(JsonKey.SUNBIRD_ES_IP))) { - String envHost = System.getenv(JsonKey.SUNBIRD_ES_IP); - String[] host = envHost.split(","); - baseUrl = - "http://" - + host[0] - + ":" - + PropertiesCache.getInstance().getProperty(JsonKey.ES_METRICS_PORT); - } else { - ProjectLogger.log("ES URL from Properties file"); - baseUrl = PropertiesCache.getInstance().getProperty(JsonKey.ES_URL); - } - Map mappedIndexAndType = getMappedIndexAndType(index, type); - String requestURL = - baseUrl - + "/" - + mappedIndexAndType.get(JsonKey.INDEX) - + "/" - + mappedIndexAndType.get(JsonKey.TYPE) - + "/" - + "_search"; - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - Map responseData = new HashMap<>(); - try { - // TODO:Currently this is making a rest call but needs to be modified to make - // the call using - // ElasticSearch client - String responseStr = HttpUtil.sendPostRequest(requestURL, rawQuery, headers); - ObjectMapper mapper = new ObjectMapper(); - responseData = mapper.readValue(responseStr, Map.class); - } catch (IOException e) { - throw new ProjectCommonException( - ResponseCode.unableToConnectToES.getErrorCode(), - ResponseCode.unableToConnectToES.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.unableToParseData.getErrorCode(), - ResponseCode.unableToParseData.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - Response response = new Response(); - response.put(JsonKey.RESPONSE, responseData); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "ElasticSearchUtil metrics search method end at == " - + stopTime - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response; - } - - /** - * this method will take start time and subtract with current time to get the time spent in - * millis. - * - * @param startTime long - * @return long - */ - public static long calculateEndTime(long startTime) { - return System.currentTimeMillis() - startTime; - } - - public static SearchDTO createSearchDTO(Map searchQueryMap) { - SearchDTO search = new SearchDTO(); - if (searchQueryMap.containsKey(JsonKey.QUERY)) { - search.setQuery((String) searchQueryMap.get(JsonKey.QUERY)); - } - if (searchQueryMap.containsKey(JsonKey.QUERY_FIELDS)) { - search.setQueryFields((List) searchQueryMap.get(JsonKey.QUERY_FIELDS)); - } - if (searchQueryMap.containsKey(JsonKey.FACETS)) { - search.setFacets((List>) searchQueryMap.get(JsonKey.FACETS)); - } - if (searchQueryMap.containsKey(JsonKey.FIELDS)) { - search.setFields((List) searchQueryMap.get(JsonKey.FIELDS)); - } - if (searchQueryMap.containsKey(JsonKey.FILTERS)) { - search.getAdditionalProperties().put(JsonKey.FILTERS, searchQueryMap.get(JsonKey.FILTERS)); - } - if (searchQueryMap.containsKey(JsonKey.EXISTS)) { - search.getAdditionalProperties().put(JsonKey.EXISTS, searchQueryMap.get(JsonKey.EXISTS)); - } - if (searchQueryMap.containsKey(JsonKey.NOT_EXISTS)) { - search - .getAdditionalProperties() - .put(JsonKey.NOT_EXISTS, searchQueryMap.get(JsonKey.NOT_EXISTS)); - } - if (searchQueryMap.containsKey(JsonKey.SORT_BY)) { - search - .getSortBy() - .putAll((Map) searchQueryMap.get(JsonKey.SORT_BY)); - } - if (searchQueryMap.containsKey(JsonKey.OFFSET)) { - if ((searchQueryMap.get(JsonKey.OFFSET)) instanceof Integer) { - search.setOffset((int) searchQueryMap.get(JsonKey.OFFSET)); - } else { - search.setOffset(((BigInteger) searchQueryMap.get(JsonKey.OFFSET)).intValue()); - } - } - if (searchQueryMap.containsKey(JsonKey.LIMIT)) { - if ((searchQueryMap.get(JsonKey.LIMIT)) instanceof Integer) { - search.setLimit((int) searchQueryMap.get(JsonKey.LIMIT)); - } else { - search.setLimit(((BigInteger) searchQueryMap.get(JsonKey.LIMIT)).intValue()); - } - } - if (searchQueryMap.containsKey(JsonKey.GROUP_QUERY)) { - search - .getGroupQuery() - .addAll( - (Collection>) searchQueryMap.get(JsonKey.GROUP_QUERY)); - } - if (searchQueryMap.containsKey(JsonKey.SOFT_CONSTRAINTS)) { - search.setSoftConstraints((Map) searchQueryMap.get(JsonKey.SOFT_CONSTRAINTS)); - } - return search; - } - - /** - * @param ids List of ids of document - * @param fields List of fields which needs to captured - * @param typeToSearch type of ES - * @return Map> It will return a map with id as key and the data from ES - * as value - */ - public static Map> getEsResultByListOfIds( - List ids, List fields, ProjectUtil.EsType typeToSearch) { - - Map filters = new HashMap<>(); - filters.put(JsonKey.ID, ids); - - SearchDTO searchDTO = new SearchDTO(); - searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters); - searchDTO.setFields(fields); - - Map result = - complexSearch( - searchDTO, ProjectUtil.EsIndex.sunbird.getIndexName(), typeToSearch.getTypeName()); - List> esContent = (List>) result.get(JsonKey.CONTENT); - return esContent - .stream() - .collect( - Collectors.toMap( - obj -> { - return (String) obj.get("id"); - }, - val -> val)); - } - - private static Map getMappedIndexAndType( - String sunbirdIndex, String sunbirdType) { - String mappedIndexAndType = "mapping." + sunbirdIndex + "." + sunbirdType; - Map mappedIndexAndTypeResult = new HashMap<>(); - if (config.hasPath(mappedIndexAndType)) { - mappedIndexAndTypeResult = (Map) config.getAnyRef(mappedIndexAndType); - } else { - ProjectCommonException.throwServerErrorException(ResponseCode.SERVER_ERROR); - } - ProjectLogger.log( - "Elasticsearch input index " - + sunbirdIndex - + " types " - + sunbirdType - + " output " - + mappedIndexAndTypeResult, - LoggerEnum.DEBUG); - return mappedIndexAndTypeResult; - } - - private static List> getMappedIndexesAndTypes( - String sunbirdIndex, String... sunbirdTypes) { - List> mappedIndexesAndTypes = new ArrayList<>(); - for (String sunbirdType : sunbirdTypes) { - mappedIndexesAndTypes.add(getMappedIndexAndType(sunbirdIndex, sunbirdType)); - } - return mappedIndexesAndTypes; - } - - public static Future> doAsyncSearch( - String index, String type, SearchDTO searchDTO) { - Map indexTypeMap = getMappedIndexAndType(index, type); - Promise> promise = Futures.promise(); - SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - if (!StringUtils.isBlank(searchDTO.getQuery())) { - SimpleQueryStringBuilder sqsb = QueryBuilders.simpleQueryStringQuery(searchDTO.getQuery()); - if (CollectionUtils.isEmpty(searchDTO.getQueryFields())) { - boolQueryBuilder.must(sqsb.field("all_fields")); - } else { - Map searchFields = - searchDTO - .getQueryFields() - .stream() - .collect(Collectors.toMap(s -> s, v -> 1.0f)); - boolQueryBuilder.must(sqsb.fields(searchFields)); - } - } - sourceBuilder.from(searchDTO.getOffset() != null ? searchDTO.getOffset() : 0); - sourceBuilder.size(searchDTO.getLimit() != null ? searchDTO.getLimit() : 250); - // check mode and set constraints - Map constraintsMap = getConstraints(searchDTO); - // apply additional properties - if (searchDTO.getAdditionalProperties() != null - && searchDTO.getAdditionalProperties().size() > 0) { - for (Map.Entry entry : searchDTO.getAdditionalProperties().entrySet()) { - addAdditionalProperties(boolQueryBuilder, entry, constraintsMap); - } - } - sourceBuilder.query(boolQueryBuilder); - SearchRequest searchRequest = new SearchRequest(indexTypeMap.get(JsonKey.INDEX)); - searchRequest.source(sourceBuilder); - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(SearchResponse searchResponse) { - List> mapList = new ArrayList<>(); - Map responseMap = new HashMap<>(); - SearchHits hits = searchResponse.getHits(); - for (SearchHit hit : hits.getHits()) { - mapList.add(hit.getSourceAsMap()); - } - responseMap.put(JsonKey.CONTENT, mapList); - responseMap.put(JsonKey.COUNT, hits.getTotalHits()); - promise.success(responseMap); - } - - @Override - public void onFailure(Exception e) { - promise.failure(e); - } - }; - ConnectionManager.getRestClient().searchAsync(searchRequest, listener); - return promise.future(); - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/factory/EsClientFactory.java b/sunbird-es-utils/src/main/java/org/sunbird/common/factory/EsClientFactory.java deleted file mode 100644 index 364ef3b42..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/factory/EsClientFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.sunbird.common.factory; - -import org.sunbird.common.ElasticSearchRestHighImpl; -import org.sunbird.common.ElasticSearchTcpImpl; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; - -public class EsClientFactory { - - private static ElasticSearchService tcpClient = null; - private static ElasticSearchService restClient = null; - - /** - * This method return REST/TCP client for elastic search - * - * @param type can be "tcp" or "rest" - * @return ElasticSearchService with the respected type impl - */ - public static ElasticSearchService getInstance(String type) { - if (JsonKey.TCP.equals(type)) { - return getTcpClient(); - } else if (JsonKey.REST.equals(type)) { - return getRestClient(); - } else { - ProjectLogger.log( - "EsClientFactory:getInstance: value for client type provided null ", LoggerEnum.ERROR); - } - return null; - } - - private static ElasticSearchService getTcpClient() { - if (tcpClient == null) { - tcpClient = new ElasticSearchTcpImpl(); - } - return tcpClient; - } - - private static ElasticSearchService getRestClient() { - if (restClient == null) { - restClient = new ElasticSearchRestHighImpl(); - } - return restClient; - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/common/inf/ElasticSearchService.java b/sunbird-es-utils/src/main/java/org/sunbird/common/inf/ElasticSearchService.java deleted file mode 100644 index 4050d6fee..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/common/inf/ElasticSearchService.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.sunbird.common.inf; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.ElasticSearchHelper; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import scala.concurrent.Future; - -public interface ElasticSearchService { - public static final String _DOC = "_doc"; - - /** - * This method will put a new data entry inside Elastic search. identifier value becomes _id - * inside ES, so every time provide a unique value while saving it. - * - * @param index String ES index name - * @param identifier ES column identifier as an String - * @param data Map - * @return String identifier for created data - */ - public Future save(String index, String identifier, Map data); - - /** - * This method will update data based on identifier.take the data based on identifier and merge - * with incoming data then update it. - * - * @param index String - * @param identifier String - * @param data Map - * @return boolean - */ - public Future update(String index, String identifier, Map data); - - /** - * This method will provide data form ES based on incoming identifier. we can get data by passing - * index and identifier values , or all the three index, identifier and type - * - * @param index String - * @param identifier String - * @return Map or null - */ - public Future> getDataByIdentifier(String index, String identifier); - - /** - * This method will remove data from ES based on identifier. - * - * @param index String - * @param identifier String - */ - public Future delete(String index, String identifier); - - /** - * Method to perform the elastic search on the basis of SearchDTO . SearchDTO contains the search - * criteria like fields, facets, sort by , filters etc. here user can pass single type to search - * or multiple type or null - * - * @param type var arg of String - * @return search result as Map. - */ - public Future> search(SearchDTO searchDTO, String index); - - /** - * This method will do the health check of elastic search. - * - * @return boolean - */ - public Future healthCheck(); - - /** - * This method will do the bulk data insertion. - * - * @param index String index name - * @param dataList List> - * @return boolean - */ - public Future bulkInsert(String index, List> dataList); - - /** - * This method will upsert data based on identifier.take the data based on identifier and merge - * with incoming data then update it or if not present already will create it. - * - * @param index String - * @param identifier String - * @param data Map - * @return boolean - */ - public Future upsert(String index, String identifier, Map data); - - /** - * @param ids List of ids of document - * @param fields List of fields which needs to captured - * @param index elastic search index in which search should be done - * @return Map> It will return a map with id as key and the data from ES - * as value - */ - public Future>> getEsResultByListOfIds( - List organisationIds, List fields, String index); - - /** - * Method to execute ES raw query with the limitation of size set to 0 Currently, This is a not a - * tcp call. - * - * @param index ES indexName - * @param rawQuery actual query to be executed - * @return Response Object from elastic Search - */ - default Response searchMetricsData(String index, String rawQuery) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "ElasticSearchTcpImpl:searchMetricsData: " - + "Metrics search method started at ==" - + startTime, - LoggerEnum.PERF_LOG); - String baseUrl = null; - if (!StringUtils.isBlank(System.getenv(JsonKey.SUNBIRD_ES_IP))) { - String envHost = System.getenv(JsonKey.SUNBIRD_ES_IP); - String[] host = envHost.split(","); - baseUrl = - "http://" - + host[0] - + ":" - + PropertiesCache.getInstance().getProperty(JsonKey.ES_METRICS_PORT); - } else { - ProjectLogger.log("ElasticSearchTcpImpl:searchMetricsData:" + " ES URL from Properties file"); - baseUrl = PropertiesCache.getInstance().getProperty(JsonKey.ES_URL); - } - String requestURL = baseUrl + "/" + index + "/" + "_doc" + "/" + "_search"; - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - Map responseData = new HashMap<>(); - try { - // TODO:Currently this is making a rest call but needs to be modified to make - // the call using - // ElasticSearch client - String responseStr = HttpUtil.sendPostRequest(requestURL, rawQuery, headers); - ObjectMapper mapper = new ObjectMapper(); - responseData = mapper.readValue(responseStr, Map.class); - } catch (IOException e) { - throw new ProjectCommonException( - ResponseCode.unableToConnectToES.getErrorCode(), - ResponseCode.unableToConnectToES.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.unableToParseData.getErrorCode(), - ResponseCode.unableToParseData.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - Response response = new Response(); - response.put(JsonKey.RESPONSE, responseData); - ProjectLogger.log( - "ElasticSearchTcpImpl:searchMetricsData: " - + "ElasticSearchUtil metrics search method end at == " - + System.currentTimeMillis() - + " ,Total time elapsed = " - + ElasticSearchHelper.calculateEndTime(startTime), - LoggerEnum.PERF_LOG); - return response; - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/dto/SearchDTO.java b/sunbird-es-utils/src/main/java/org/sunbird/dto/SearchDTO.java deleted file mode 100644 index a442535a3..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/dto/SearchDTO.java +++ /dev/null @@ -1,177 +0,0 @@ -/** */ -package org.sunbird.dto; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * This class will take input for elastic search query - * - * @author Manzarul - */ -public class SearchDTO { - - @SuppressWarnings("rawtypes") - private List properties; - - private List> facets = new ArrayList<>(); - private List fields; - private List excludedFields; - private Map sortBy = new HashMap<>(); - private String operation; - private String query; - private List queryFields; - - private Integer limit = 250; - private Integer offset = 0; - private boolean fuzzySearch = false; - // additional properties will hold , filters, exist , not exist - private Map additionalProperties = new HashMap<>(); - private Map softConstraints = new HashMap<>(); - private List> groupQuery = new ArrayList<>(); - private List mode = new ArrayList<>(); - - public List> getGroupQuery() { - return groupQuery; - } - - public void setGroupQuery(List> groupQuery) { - this.groupQuery = groupQuery; - } - - public SearchDTO() { - super(); - } - - @SuppressWarnings("rawtypes") - public SearchDTO(List properties, String operation, int limit) { - super(); - this.properties = properties; - this.operation = operation; - this.limit = limit; - } - - @SuppressWarnings("rawtypes") - public List getProperties() { - return properties; - } - - @SuppressWarnings("rawtypes") - public void setProperties(List properties) { - this.properties = properties; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public Integer getLimit() { - return limit; - } - - public void setLimit(Integer limit) { - this.limit = limit; - } - - public List> getFacets() { - return facets; - } - - public void setFacets(List> facets) { - this.facets = facets; - } - - public Map getSortBy() { - return sortBy; - } - - public void setSortBy(Map sortBy) { - this.sortBy = sortBy; - } - - public boolean isFuzzySearch() { - return fuzzySearch; - } - - public void setFuzzySearch(boolean fuzzySearch) { - this.fuzzySearch = fuzzySearch; - } - - public Map getAdditionalProperties() { - return additionalProperties; - } - - public void setAdditionalProperties(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - public Object getAdditionalProperty(String key) { - return additionalProperties.get(key); - } - - public void addAdditionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public Integer getOffset() { - return offset; - } - - public void setOffset(Integer offset) { - this.offset = offset; - } - - public Map getSoftConstraints() { - return softConstraints; - } - - public void setSoftConstraints(Map softConstraints) { - this.softConstraints = softConstraints; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public List getMode() { - return mode; - } - - public void setMode(List mode) { - this.mode = mode; - } - - public List getExcludedFields() { - return excludedFields; - } - - public void setExcludedFields(List excludedFields) { - this.excludedFields = excludedFields; - } - - public List getQueryFields() { - return queryFields; - } - - public void setQueryFields(List queryFields) { - this.queryFields = queryFields; - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/helper/ConnectionManager.java b/sunbird-es-utils/src/main/java/org/sunbird/helper/ConnectionManager.java deleted file mode 100644 index 5c69812ab..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/helper/ConnectionManager.java +++ /dev/null @@ -1,294 +0,0 @@ -/** */ -package org.sunbird.helper; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpHost; -import org.elasticsearch.client.RestClient; -import org.elasticsearch.client.RestHighLevelClient; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.Settings.Builder; -import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.transport.client.PreBuiltTransportClient; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; - -/** - * This class will manage connection. - * - * @author Manzarul - */ -public class ConnectionManager { - - private static TransportClient client = null; - private static RestHighLevelClient restClient = null; - private static List host = new ArrayList<>(); - private static List ports = new ArrayList<>(); - private static PropertiesCache propertiesCache = PropertiesCache.getInstance(); - private static String cluster = propertiesCache.getProperty("es.cluster.name"); - private static String hostName = propertiesCache.getProperty("es.host.name"); - private static String port = propertiesCache.getProperty("es.host.port"); - - static { - System.setProperty("es.set.netty.runtime.available.processors", "false"); - initialiseConnection(); - registerShutDownHook(); - initialiseRestClientConnection(); - } - - private ConnectionManager() {} - - private static boolean initialiseRestClientConnection() { - boolean response = false; - try { - String cluster = System.getenv(JsonKey.SUNBIRD_ES_CLUSTER); - String hostName = System.getenv(JsonKey.SUNBIRD_ES_IP); - String port = System.getenv(JsonKey.SUNBIRD_ES_PORT); - if (StringUtils.isBlank(hostName) || StringUtils.isBlank(port)) { - return false; - } - String[] splitedHost = hostName.split(","); - for (String val : splitedHost) { - host.add(val); - } - String[] splitedPort = port.split(","); - for (String val : splitedPort) { - ports.add(Integer.parseInt(val)); - } - response = createRestClient(cluster, host); - ProjectLogger.log( - "ELASTIC SEARCH CONNECTION ESTABLISHED for restClient from EVN with Following Details cluster " - + cluster - + " hostName" - + hostName - + " port " - + port - + response, - LoggerEnum.INFO.name()); - } catch (Exception e) { - ProjectLogger.log("Error while initialising connection for restClient from the Env", e); - return false; - } - return response; - } - - /** - * This method will provide ES transport client. - * - * @return TransportClient - */ - public static TransportClient getClient() { - if (client == null) { - ProjectLogger.log("ELastic search clinet is null " + client, LoggerEnum.INFO.name()); - initialiseConnection(); - ProjectLogger.log( - "After calling initialiseConnection ES client value " + client, LoggerEnum.INFO.name()); - } - return client; - } - - /** - * This method will provide ES transport client. - * - * @return TransportClient - */ - public static RestHighLevelClient getRestClient() { - if (restClient == null) { - ProjectLogger.log( - "ConnectionManager:getRestClient eLastic search rest clinet is null " + client, - LoggerEnum.INFO.name()); - initialiseRestClientConnection(); - ProjectLogger.log( - "ConnectionManager:getRestClient after calling initialiseRestClientConnection ES client value " - + client, - LoggerEnum.INFO.name()); - } - return restClient; - } - - /** - * This method will create the client instance for elastic search. - * - * @param clusterName String - * @param host List - * @param port List - * @return boolean - * @throws UnknownHostException - */ - private static boolean createClient(String clusterName, List host) - throws UnknownHostException { - Builder builder = Settings.builder(); - if (clusterName != null && !"".equals(clusterName)) { - builder = builder.put("cluster.name", clusterName); - } - builder = builder.put("client.transport.sniff", false); - builder = builder.put("client.transport.ignore_cluster_name", true); - client = new PreBuiltTransportClient(builder.build()); - for (int i = 0; i < host.size(); i++) { - client.addTransportAddress( - new TransportAddress(InetAddress.getByName(host.get(i)), ports.get(i))); - ProjectLogger.log( - "ES Client is adding hsot and Port " + host.get(i) + " ," + ports.get(i), - LoggerEnum.INFO.name()); - } - return true; - } - - /** - * This method will create the client instance for elastic search. - * - * @param clusterName String - * @param host List - * @param port List - * @return boolean - * @throws UnknownHostException - */ - private static boolean createRestClient(String clusterName, List host) { - HttpHost[] httpHost = new HttpHost[host.size()]; - for (int i = 0; i < host.size(); i++) { - httpHost[i] = new HttpHost(host.get(i), 9200); - } - restClient = new RestHighLevelClient(RestClient.builder(httpHost)); - ProjectLogger.log( - "ConnectionManager:createRestClient client initialisation done. ", LoggerEnum.INFO.name()); - return true; - } - - /** - * This method will read configuration data form properties file and update the list. - * - * @return boolean - */ - private static boolean initialiseConnection() { - try { - if (initialiseConnectionFromEnv()) { - ProjectLogger.log("value found under system variable.", LoggerEnum.INFO.name()); - return true; - } - return initialiseConnectionFromPropertiesFile(cluster, hostName, port); - } catch (Exception e) { - ProjectLogger.log("Error while initialising elastic search connection", e); - return false; - } - } - - /** - * This method will initialize the connection from Resource properties file. - * - * @param cluster String cluster name - * @param hostName String host name - * @param port String port - * @return boolean - */ - public static boolean initialiseConnectionFromPropertiesFile( - String cluster, String hostName, String port) { - try { - String[] splitedHost = hostName.split(","); - for (String val : splitedHost) { - host.add(val); - } - String[] splitedPort = port.split(","); - for (String val : splitedPort) { - ports.add(Integer.parseInt(val)); - } - boolean response = createClient(cluster, host); - ProjectLogger.log( - "ES Connection Established from Properties file Cluster " - + cluster - + " host " - + hostName - + " port " - + port - + " Response " - + response, - LoggerEnum.INFO.name()); - } catch (Exception e) { - ProjectLogger.log("Error while initialising connection From Properties File", e); - return false; - } - return true; - } - - /** - * This method will read configuration data form System environment variable. - * - * @return boolean - */ - private static boolean initialiseConnectionFromEnv() { - boolean response = false; - try { - String cluster = System.getenv(JsonKey.SUNBIRD_ES_CLUSTER); - String hostName = System.getenv(JsonKey.SUNBIRD_ES_IP); - String port = System.getenv(JsonKey.SUNBIRD_ES_PORT); - ProjectLogger.log( - "Value set for es.set.netty.runtime.available.processors " - + System.getProperty("es.set.netty.runtime.available.processors"), - LoggerEnum.INFO.name()); - if (StringUtils.isBlank(hostName) || StringUtils.isBlank(port)) { - return false; - } - String[] splitedHost = hostName.split(","); - for (String val : splitedHost) { - host.add(val); - } - String[] splitedPort = port.split(","); - for (String val : splitedPort) { - ports.add(Integer.parseInt(val)); - } - response = createClient(cluster, host); - ProjectLogger.log( - "ELASTIC SEARCH CONNECTION ESTABLISHED from EVN with Following Details cluster " - + cluster - + " hostName" - + hostName - + " port " - + port - + response, - LoggerEnum.INFO.name()); - } catch (Exception e) { - ProjectLogger.log("Error while initialising connection from the Env", e); - return false; - } - return response; - } - - public static void closeClient() { - client.close(); - } - - /** - * This class will be called by registerShutDownHook to register the call inside jvm , when jvm - * terminate it will call the run method to clean up the resource. - * - * @author Manzarul - */ - public static class ResourceCleanUp extends Thread { - @Override - public void run() { - client.close(); - try { - restClient.close(); - } catch (IOException e) { - e.printStackTrace(); - ProjectLogger.log( - "ConnectionManager:ResourceCleanUp error occured during restclient resource cleanup " - + e, - LoggerEnum.ERROR.name()); - } - } - } - - /** Register the hook for resource clean up. this will be called when jvm shut down. */ - public static void registerShutDownHook() { - Runtime runtime = Runtime.getRuntime(); - runtime.addShutdownHook(new ResourceCleanUp()); - ProjectLogger.log("ShutDownHook registered."); - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchMapping.java b/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchMapping.java deleted file mode 100644 index c7c6c0d9a..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/** */ -package org.sunbird.helper; - -/** - * This class will define Elastic search mapping. - * - * @author Manzarul - */ -public class ElasticSearchMapping { - - /** - * This method will define ES default mapping. - * - * @return - */ - public static String createMapping() { - String mapping = - " { \"dynamic_templates\": [ {\"longs\": {\"match_mapping_type\": \"long\", \"mapping\": {\"type\": \"long\", \"fields\": { \"raw\": {\"type\": \"long\" } }}}},{\"booleans\": {\"match_mapping_type\": \"boolean\", \"mapping\": {\"type\": \"boolean\", \"fields\": { \"raw\": { \"type\": \"boolean\" }} }}},{\"doubles\": {\"match_mapping_type\": \"double\",\"mapping\": {\"type\": \"double\",\"fields\":{\"raw\": { \"type\": \"double\" } }}}},{ \"dates\": {\"match_mapping_type\": \"date\", \"mapping\": { \"type\": \"date\",\"fields\": {\"raw\": { \"type\": \"date\" } } }}},{\"strings\": {\"match_mapping_type\": \"string\",\"mapping\": {\"type\": \"text\",\"fielddata\": true,\"copy_to\": \"all_fields\",\"analyzer\": \"cs_index_analyzer\",\"search_analyzer\": \"cs_search_analyzer\",\"fields\": {\"raw\": {\"type\": \"text\",\"fielddata\": true,\"analyzer\": \"keylower\"}}}}}],\"properties\": {\"all_fields\": {\"type\": \"text\",\"analyzer\": \"cs_index_analyzer\",\"search_analyzer\": \"cs_search_analyzer\",\"fields\": { \"raw\": { \"type\": \"text\",\"analyzer\": \"keylower\" } }} }}"; - return mapping; - } -} diff --git a/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchSettings.java b/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchSettings.java deleted file mode 100644 index 41c9e17fc..000000000 --- a/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchSettings.java +++ /dev/null @@ -1,21 +0,0 @@ -/** */ -package org.sunbird.helper; - -/** - * This class will define Elastic search default settings. - * - * @author Manzarul - */ -public class ElasticSearchSettings { - - /** - * This method will do default settings for Elastic search index - * - * @return String - */ - public static String createSettingsForIndex() { - String settings = - "{\"analysis\": {\"analyzer\": {\"cs_index_analyzer\": {\"type\": \"custom\",\"tokenizer\": \"standard\",\"filter\": [\"lowercase\",\"mynGram\"]},\"cs_search_analyzer\": {\"type\": \"custom\",\"tokenizer\": \"standard\",\"filter\": [\"lowercase\",\"standard\"]},\"keylower\": {\"type\": \"custom\",\"tokenizer\": \"keyword\",\"filter\": \"lowercase\"}},\"filter\": {\"mynGram\": {\"type\": \"ngram\",\"min_gram\": 1,\"max_gram\": 20,\"token_chars\": [\"letter\", \"digit\",\"whitespace\",\"punctuation\",\"symbol\"]} }}}"; - return settings; - } -} diff --git a/sunbird-es-utils/src/main/resources/elasticsearch.conf b/sunbird-es-utils/src/main/resources/elasticsearch.conf deleted file mode 100644 index 9e18c715f..000000000 --- a/sunbird-es-utils/src/main/resources/elasticsearch.conf +++ /dev/null @@ -1,62 +0,0 @@ - { - mapping = { - searchindex = { - user = { - index = "user", - "type" = "_doc" - }, - org = { - index = "org", - "type" = "_doc" - }, - cbatch = { - index = "cbatch", - "type" = "_doc" - }, - badgeassociations = { - index = "badgeassociations", - "type" = "_doc" - }, - content = { - index = "content", - "type" = "_doc" - }, - usercourses = { - index = "usercourses", - "type" = "_doc" - }, - usernotes = { - index = "usernotes", - "type" = "_doc" - }, - userprofilevisibility = { - index = "userprofilevisibility", - "type" = "_doc" - }, - telemetry = { - index = "telemetry", - "type" = "_doc" - }, - location = { - index = "location", - "type" = "_doc" - }, - cbatchstats = { - index = "cbatchstats", - "type" = "_doc" - } - }, - sbtestindex = { - sbtesttype = { - index = "sbtestindex", - "type" = "sbtesttype" - } - }, - searchtest = { - usertest = { - index = "searchtest", - "type" = "usertest" - } - } - } - } diff --git a/sunbird-es-utils/src/main/resources/indices/announcement.json b/sunbird-es-utils/src/main/resources/indices/announcement.json deleted file mode 100644 index 8f091e230..000000000 --- a/sunbird-es-utils/src/main/resources/indices/announcement.json +++ /dev/null @@ -1,397 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "attachments": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "details": { - "properties": { - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "filename": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "from": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "title": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "links": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "sentcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "sourceId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "sourceid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "target": { - "properties": { - "geo": { - "properties": { - "ids": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - }, - "userid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/announcementtype.json b/sunbird-es-utils/src/main/resources/indices/announcementtype.json deleted file mode 100644 index 50ec50544..000000000 --- a/sunbird-es-utils/src/main/resources/indices/announcementtype.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootorgid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/badgeassociations.json b/sunbird-es-utils/src/main/resources/indices/badgeassociations.json deleted file mode 100644 index a2fe64596..000000000 --- a/sunbird-es-utils/src/main/resources/indices/badgeassociations.json +++ /dev/null @@ -1,249 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/cbatch.json b/sunbird-es-utils/src/main/resources/indices/cbatch.json deleted file mode 100644 index 55ff6e2a0..000000000 --- a/sunbird-es-utils/src/main/resources/indices/cbatch.json +++ /dev/null @@ -1,369 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countDecrementDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countDecrementStatus": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "countIncrementDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countIncrementStatus": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "courseCreator": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdFor": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "enrollmentType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "mentors": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "startDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "reportUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/cbatchstats.json b/sunbird-es-utils/src/main/resources/indices/cbatchstats.json deleted file mode 100644 index bbec75327..000000000 --- a/sunbird-es-utils/src/main/resources/indices/cbatchstats.json +++ /dev/null @@ -1,257 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completedPercent": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "districtName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "maskedEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/course-batch.json b/sunbird-es-utils/src/main/resources/indices/course-batch.json deleted file mode 100644 index adb3af368..000000000 --- a/sunbird-es-utils/src/main/resources/indices/course-batch.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/location.json b/sunbird-es-utils/src/main/resources/indices/location.json deleted file mode 100644 index 57d5e5262..000000000 --- a/sunbird-es-utils/src/main/resources/indices/location.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "code": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "parentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "value": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/metrics.json b/sunbird-es-utils/src/main/resources/indices/metrics.json deleted file mode 100644 index 1785559ca..000000000 --- a/sunbird-es-utils/src/main/resources/indices/metrics.json +++ /dev/null @@ -1,329 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "activity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "announcementId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "announcementid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootorgid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/org.json b/sunbird-es-utils/src/main/resources/indices/org.json deleted file mode 100644 index 61273d9dd..000000000 --- a/sunbird-es-utils/src/main/resources/indices/org.json +++ /dev/null @@ -1,876 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contactDetail": { - "properties": { - "Email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phone ": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phone Number": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phonenumber": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "age": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "fax": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "contactdetails": { - "type": "object" - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "externalId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "homeUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "imgUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDefault": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRootOrg": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "locationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "noOfMembers": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "orgCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgTypeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "preferredLanguage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "provider": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "slug": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "theme": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/user-courses.json b/sunbird-es-utils/src/main/resources/indices/user-courses.json deleted file mode 100644 index adb3af368..000000000 --- a/sunbird-es-utils/src/main/resources/indices/user-courses.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/user.json b/sunbird-es-utils/src/main/resources/indices/user.json deleted file mode 100644 index a08bef58f..000000000 --- a/sunbird-es-utils/src/main/resources/indices/user.json +++ /dev/null @@ -1,3605 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic":false, - "properties": { - "managedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "activeStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "appointmentType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "authenticationStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "avatar": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeAssertions": { - "properties": { - "assertionId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "assertionid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeclassimage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeclassname": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdTS": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdTs": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "createdts": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "badges": { - "properties": { - "badgeTypeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "receiverId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "batches": { - "properties": { - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastAccessedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "progress": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "classSubjectTaught": { - "properties": { - "classes": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "countryCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "disabilityType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "education": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "boardOrUniversity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "degree": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "percentage": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "yearOfPassing": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "emailVerified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "emailverified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "employmentState": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "framework": { - "properties": { - "board": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gradeLevel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "medium": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "fullName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestAcademicQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestEnglishQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestMathQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestSSTQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestScienceQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestTeacherQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestVernacularLanguageQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isMasterTrainer": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isCurrentJob": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "jobName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "joiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "orgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "role": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "masterTrainerSubjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisations": { - "properties": { - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addedByName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvalDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvaldate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isApproved": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRejected": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "orgJoinDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgLeftDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgjoindate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "position": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phoneVerified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "phoneverified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileVisibility": { - "properties": { - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "education": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grades": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "socialMedia": { - "properties": { - "in": { - "properties": { - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "twitter": { - "properties": { - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "test": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userSkills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "provider": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "regOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "registryId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "schoolCode": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "schoolJoiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "serviceJoiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skills": { - "properties": { - "addedAt": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsementcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsers": { - "properties": { - "0283452c-a607-4184-9806-1fac2f16d5b9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "39d460e8-80ef-4045-8fe0-de4a78e78bc4": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "3d45fbd8-b911-4cc5-b503-61215902d780": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "48a2fbc6-df85-4a41-8e68-7057986aee5a": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "62354c16-29c7-419c-8d30-a30491bef7c3": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "7526ab9d-e8a6-478b-83e2-6ff1296c302e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "9645e749-39f0-4b73-993d-09e633eeea1d": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a1355233-6b82-4660-86f5-73b95c03aec9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a3d4151b-4d3e-4068-8950-d5b27b10487e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "b2fff05d-dfc9-497c-840e-5675a2b78e57": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "be7efb23-6af9-4d92-82b3-a4d78fcfa2f6": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "c9f23b5f-cd4c-42db-9a24-1f3ebc60dc9a": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "d5efd1ab-3cad-4034-8143-32c480f5cc9e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherInBRC": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherInCRC": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherSchoolBoardAffiliation": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tncAcceptedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "tncAcceptedVersion": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "trainingsCompleted": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "vernacularLanguageStudied": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "properties": { - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/usercourses.json b/sunbird-es-utils/src/main/resources/indices/usercourses.json deleted file mode 100644 index 1038ff76b..000000000 --- a/sunbird-es-utils/src/main/resources/indices/usercourses.json +++ /dev/null @@ -1,1181 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "active": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseLogoUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dateTime": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "delta": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "framework": { - "properties": { - "board": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gradeLevel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "medium": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentStatus": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "leafNodesCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisations": { - "properties": { - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvaldate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isApproved": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRejected": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "organisationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgjoindate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "position": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileVisibility": { - "properties": { - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "education": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "progress": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "properties": { - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "tncAcceptedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "tncAcceptedVersion": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tocUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/userfeed.json b/sunbird-es-utils/src/main/resources/indices/userfeed.json deleted file mode 100644 index 1ba018b74..000000000 --- a/sunbird-es-utils/src/main/resources/indices/userfeed.json +++ /dev/null @@ -1,212 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic":false, - "properties": { - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "category": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "data": { - "type": "object" - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "priority": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "expireOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "updatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/usernotes.json b/sunbird-es-utils/src/main/resources/indices/usernotes.json deleted file mode 100644 index 8cf7ff145..000000000 --- a/sunbird-es-utils/src/main/resources/indices/usernotes.json +++ /dev/null @@ -1,289 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "note": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tags": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "title": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/indices/userprofilevisibility.json b/sunbird-es-utils/src/main/resources/indices/userprofilevisibility.json deleted file mode 100644 index c05c6579e..000000000 --- a/sunbird-es-utils/src/main/resources/indices/userprofilevisibility.json +++ /dev/null @@ -1,1641 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - }, - "mappings": { - "_doc": { - "dynamic": false, - "properties": { - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "avatar": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeAssertions": { - "properties": { - "assertionId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdts": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "countryCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "education": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "boardOrUniversity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "degree": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "percentage": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "yearOfPassing": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isCurrentJob": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "jobName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "joiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "orgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "role": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "properties": { - "addedAt": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsementcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsers": { - "properties": { - "39d460e8-80ef-4045-8fe0-de4a78e78bc4": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "7526ab9d-e8a6-478b-83e2-6ff1296c302e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a1355233-6b82-4660-86f5-73b95c03aec9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a3d4151b-4d3e-4068-8950-d5b27b10487e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "d5efd1ab-3cad-4034-8143-32c480f5cc9e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "properties": { - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/announcement-mapping.json b/sunbird-es-utils/src/main/resources/mappings/announcement-mapping.json deleted file mode 100644 index 08d45cadb..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/announcement-mapping.json +++ /dev/null @@ -1,348 +0,0 @@ -{ - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "attachments": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "details": { - "properties": { - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "filename": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "from": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "title": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "links": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "sentcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "sourceId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "sourceid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "target": { - "properties": { - "geo": { - "properties": { - "ids": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - }, - "userid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/announcementtype-mapping.json b/sunbird-es-utils/src/main/resources/mappings/announcementtype-mapping.json deleted file mode 100644 index bc518e631..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/announcementtype-mapping.json +++ /dev/null @@ -1,184 +0,0 @@ -{ - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootorgid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/badgeassociations-mapping.json b/sunbird-es-utils/src/main/resources/mappings/badgeassociations-mapping.json deleted file mode 100644 index dc2ada59d..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/badgeassociations-mapping.json +++ /dev/null @@ -1,200 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/cbatch-mapping.json b/sunbird-es-utils/src/main/resources/mappings/cbatch-mapping.json deleted file mode 100644 index 558dad77c..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/cbatch-mapping.json +++ /dev/null @@ -1,344 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countDecrementDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countDecrementStatus": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "countIncrementDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "countIncrementStatus": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "courseCreator": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdFor": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "enrollmentEndDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "enrollmentType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "mentors": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "startDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "participantCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "completedCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "reportUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/cbatchstats-mapping.json b/sunbird-es-utils/src/main/resources/mappings/cbatchstats-mapping.json deleted file mode 100644 index 082136d3b..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/cbatchstats-mapping.json +++ /dev/null @@ -1,208 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completedPercent": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "districtName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "maskedEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/course-batch-mapping.json b/sunbird-es-utils/src/main/resources/mappings/course-batch-mapping.json deleted file mode 100644 index 722516897..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/course-batch-mapping.json +++ /dev/null @@ -1,264 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdFor": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "enrollmentEndDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "enrollmentType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "mentors": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "startDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "participantCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "completedCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "reportUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/location-mapping.json b/sunbird-es-utils/src/main/resources/mappings/location-mapping.json deleted file mode 100644 index 39c416274..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/location-mapping.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "code": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "parentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "value": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/metrics-mapping.json b/sunbird-es-utils/src/main/resources/mappings/metrics-mapping.json deleted file mode 100644 index a68e93c22..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/metrics-mapping.json +++ /dev/null @@ -1,280 +0,0 @@ -{ - "dynamic_templates": [ - { - "longs": { - "match_mapping_type": "long", - "mapping": { - "fields": { - "raw": { - "type": "long" - } - }, - "type": "long" - } - } - }, - { - "booleans": { - "match_mapping_type": "boolean", - "mapping": { - "fields": { - "raw": { - "type": "boolean" - } - }, - "type": "boolean" - } - } - }, - { - "doubles": { - "match_mapping_type": "double", - "mapping": { - "fields": { - "raw": { - "type": "double" - } - }, - "type": "double" - } - } - }, - { - "dates": { - "match_mapping_type": "date", - "mapping": { - "fields": { - "raw": { - "type": "date" - } - }, - "type": "date" - } - } - }, - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "analyzer": "cs_index_analyzer", - "copy_to": "all_fields", - "fielddata": true, - "fields": { - "raw": { - "type": "text", - "fielddata": true, - "analyzer": "keylower" - } - }, - "search_analyzer": "cs_search_analyzer", - "type": "text" - } - } - } - ], - "properties": { - "activity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "announcementId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "announcementid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createddate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootorgid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/org-mapping.json b/sunbird-es-utils/src/main/resources/mappings/org-mapping.json deleted file mode 100644 index 94d8edacd..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/org-mapping.json +++ /dev/null @@ -1,827 +0,0 @@ -{ - "dynamic": false, - "properties": { - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contactDetail": { - "properties": { - "Email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phone ": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phone Number": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "Phonenumber": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "age": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "fax": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "contactdetails": { - "type": "object" - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "externalId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "homeUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "imgUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDefault": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRootOrg": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "locationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "noOfMembers": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "orgCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgTypeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "preferredLanguage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "provider": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "slug": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "theme": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/user-courses-mapping.json b/sunbird-es-utils/src/main/resources/mappings/user-courses-mapping.json deleted file mode 100644 index e67b5de92..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/user-courses-mapping.json +++ /dev/null @@ -1,397 +0,0 @@ -{ - "dynamic": false, - "properties": { - "active": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dateTime": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "delta": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentStatus": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "progress": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "contentStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completionPercentage": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "certificates": { - "type": "nested", - "properties": { - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "token": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastIssuedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReIssuedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/user-mapping.json b/sunbird-es-utils/src/main/resources/mappings/user-mapping.json deleted file mode 100644 index c60b64ea1..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/user-mapping.json +++ /dev/null @@ -1,3588 +0,0 @@ -{ - "dynamic": false, - "properties": { - "managedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "activeStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "appointmentType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "authenticationStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "avatar": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeAssertions": { - "properties": { - "assertionId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "assertionid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeclassimage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeclassname": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeid": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdTS": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdTs": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "createdts": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "badges": { - "properties": { - "badgeTypeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "receiverId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "batches": { - "properties": { - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastAccessedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "progress": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "channel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "classSubjectTaught": { - "properties": { - "classes": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "countryCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "disabilityType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "education": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "boardOrUniversity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "degree": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "percentage": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "yearOfPassing": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "prevUsedEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "emailVerified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "emailverified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "employmentState": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "framework": { - "properties": { - "board": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gradeLevel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "medium": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "fullName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestAcademicQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestEnglishQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestMathQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestSSTQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestScienceQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestTeacherQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "highestVernacularLanguageQualification": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isMasterTrainer": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isCurrentJob": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "jobName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "joiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "orgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "role": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "maskedPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "masterTrainerSubjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisations": { - "properties": { - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addedByName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvalDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvaldate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isApproved": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRejected": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "orgJoinDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgLeftDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgjoindate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "position": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "prevUsedPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phoneVerified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "phoneverified": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileVisibility": { - "properties": { - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "education": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grades": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "socialMedia": { - "properties": { - "in": { - "properties": { - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "twitter": { - "properties": { - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subjects": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "test": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userSkills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "provider": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "regOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "registryId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "schoolCode": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "schoolJoiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "serviceJoiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skills": { - "properties": { - "addedAt": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsementcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsers": { - "properties": { - "0283452c-a607-4184-9806-1fac2f16d5b9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "39d460e8-80ef-4045-8fe0-de4a78e78bc4": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "3d45fbd8-b911-4cc5-b503-61215902d780": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "48a2fbc6-df85-4a41-8e68-7057986aee5a": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "62354c16-29c7-419c-8d30-a30491bef7c3": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "7526ab9d-e8a6-478b-83e2-6ff1296c302e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "9645e749-39f0-4b73-993d-09e633eeea1d": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a1355233-6b82-4660-86f5-73b95c03aec9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a3d4151b-4d3e-4068-8950-d5b27b10487e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "b2fff05d-dfc9-497c-840e-5675a2b78e57": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "be7efb23-6af9-4d92-82b3-a4d78fcfa2f6": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "c9f23b5f-cd4c-42db-9a24-1f3ebc60dc9a": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "d5efd1ab-3cad-4034-8143-32c480f5cc9e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherInBRC": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherInCRC": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherSchoolBoardAffiliation": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherStatus": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "teacherType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tncAcceptedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "tncAcceptedVersion": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "trainingsCompleted": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "vernacularLanguageStudied": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "properties": { - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/usercourses-mapping.json b/sunbird-es-utils/src/main/resources/mappings/usercourses-mapping.json deleted file mode 100644 index df068fcd5..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/usercourses-mapping.json +++ /dev/null @@ -1,1132 +0,0 @@ -{ - "dynamic": false, - "properties": { - "active": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "batchId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completedOn": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseLogoUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dateTime": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "delta": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "description": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encEmail": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "encPhone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "enrolledDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "firstName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "framework": { - "properties": { - "board": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gradeLevel": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "medium": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastReadContentStatus": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "leafNodesCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "locationIds": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "organisations": { - "properties": { - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvaldate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "approvedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "hashTagId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isApproved": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "isRejected": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "organisationId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgjoindate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "position": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileVisibility": { - "properties": { - "address": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "education": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "progress": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "roles": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "rootOrgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "properties": { - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "status": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "tncAcceptedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "tncAcceptedVersion": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tocUrl": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/userfeed-mapping.json b/sunbird-es-utils/src/main/resources/mappings/userfeed-mapping.json deleted file mode 100644 index deba277e5..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/userfeed-mapping.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "dynamic":false, - "properties": { - "status": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "category": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "data": { - "type": "object" - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "priority": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "expireOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "updatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/usernotes-mapping.json b/sunbird-es-utils/src/main/resources/mappings/usernotes-mapping.json deleted file mode 100644 index c2aa64bfa..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/usernotes-mapping.json +++ /dev/null @@ -1,240 +0,0 @@ -{ - "dynamic": false, - "properties": { - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "completeness": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "contentId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "courseId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isDeleted": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "missingFields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "note": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "tags": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "title": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/mappings/userprofilevisibility-mapping.json b/sunbird-es-utils/src/main/resources/mappings/userprofilevisibility-mapping.json deleted file mode 100644 index 3a064c02b..000000000 --- a/sunbird-es-utils/src/main/resources/mappings/userprofilevisibility-mapping.json +++ /dev/null @@ -1,1592 +0,0 @@ -{ - "dynamic": false, - "properties": { - "address": { - "properties": { - "addType": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "country": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "all_fields": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower" - } - }, - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer" - }, - "avatar": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeAssertions": { - "properties": { - "assertionId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassImage": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeClassName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "badgeId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdts": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "issuerId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "countryCode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "dob": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "education": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "boardOrUniversity": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "degree": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "name": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "percentage": { - "type": "double", - "fields": { - "raw": { - "type": "double" - } - } - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "yearOfPassing": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - } - } - }, - "email": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "gender": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "grade": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "identifier": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "jobProfile": { - "properties": { - "address": { - "properties": { - "addressLine1": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "addressLine2": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "city": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "state": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "zipcode": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "addressId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "endDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "isCurrentJob": { - "type": "boolean", - "fields": { - "raw": { - "type": "boolean" - } - } - }, - "jobName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "joiningDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "orgId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "orgName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "role": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "updatedDate": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "language": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "location": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "loginId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "phone": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "profileSummary": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skills": { - "properties": { - "addedAt": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "addedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "createdOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "endorsementCount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsementcount": { - "type": "long", - "fields": { - "raw": { - "type": "long" - } - } - }, - "endorsers": { - "properties": { - "39d460e8-80ef-4045-8fe0-de4a78e78bc4": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "7526ab9d-e8a6-478b-83e2-6ff1296c302e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a1355233-6b82-4660-86f5-73b95c03aec9": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "a3d4151b-4d3e-4068-8950-d5b27b10487e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "d5efd1ab-3cad-4034-8143-32c480f5cc9e": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - } - } - }, - "endorsersList": { - "properties": { - "endorseDate": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "id": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedBy": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "lastUpdatedOn": { - "type": "date", - "fields": { - "raw": { - "type": "date" - } - } - }, - "skillName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "skillNameToLowercase": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - }, - "subject": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userId": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "userName": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "webPages": { - "properties": { - "type": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - }, - "url": { - "type": "text", - "fields": { - "raw": { - "type": "text", - "analyzer": "keylower", - "fielddata": true - } - }, - "copy_to": [ - "all_fields" - ], - "analyzer": "cs_index_analyzer", - "search_analyzer": "cs_search_analyzer", - "fielddata": true - } - } - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/reindexing/README.md b/sunbird-es-utils/src/main/resources/reindexing/README.md deleted file mode 100644 index d1b3d5260..000000000 --- a/sunbird-es-utils/src/main/resources/reindexing/README.md +++ /dev/null @@ -1,35 +0,0 @@ -This is the script which will perform reindexing on Elasticsearch Index... - -## How to run - - give permission to the script chmod +x reindex.sh - - bash reindex.sh {{es_ip}} {{old_index}} {{new_index}} {{alias_name}} {{index_req_filePath}} {{mappings_req_filePath}} - - - -## CLI ARGS DESCRIPTION - - es_ip: Ip of ElasticSearch and port is assumed to be 9200 - - old_index: Source Index from which reindexing to be done - - new_index: Destination Index, to which reindexing to be done - - alias_name: Name of Alias to which new_index to be mapped and old index need to be removed. - - index_req_filepath: .json file path which will have a request body for creating new_index. - - mapping_req_filepath: .json file path which will have a request body for creating mappings of new_index. - - - **NOTE**: old_index will be deleted by the script.
- - - ## Following Steps will be done by Script: - - 1: Validating Input params - a) File paths - b) ElasticSearch health
- 2: *Creating Backup file.
- 3: mapping alias_name with `old_index`.
- 4: creating indices and mapping of `new_index`.
- 5: Reindexing from `old_index` index to `new_index` index.
- 6: deleting alias with `old_index` and mapping alias with `new_index`.
- 7: deleting `old_index`.
- - -*BackUp file may not contain all the ES records(due to size limit in ES).
-SOURCE : https://engineering.carsguide.com.au/elasticsearch-zero-downtime-reindexing-e3a53000f0ac diff --git a/sunbird-es-utils/src/main/resources/reindexing/indices/certreg_indices.json b/sunbird-es-utils/src/main/resources/reindexing/indices/certreg_indices.json deleted file mode 100644 index 8dca30f04..000000000 --- a/sunbird-es-utils/src/main/resources/reindexing/indices/certreg_indices.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "settings": { - "index": { - "number_of_shards": "5", - "number_of_replicas": "1", - "analysis": { - "filter": { - "mynGram": { - "token_chars": [ - "letter", - "digit", - "whitespace", - "punctuation", - "symbol" - ], - "min_gram": "1", - "type": "ngram", - "max_gram": "20" - } - }, - "analyzer": { - "cs_index_analyzer": { - "filter": [ - "lowercase", - "mynGram" - ], - "type": "custom", - "tokenizer": "standard" - }, - "keylower": { - "filter": "lowercase", - "type": "custom", - "tokenizer": "keyword" - }, - "cs_search_analyzer": { - "filter": [ - "lowercase", - "standard" - ], - "type": "custom", - "tokenizer": "standard" - } - } - } - } - } -} diff --git a/sunbird-es-utils/src/main/resources/reindexing/mappings/certreg_mappings.json b/sunbird-es-utils/src/main/resources/reindexing/mappings/certreg_mappings.json deleted file mode 100644 index d1ec23ab4..000000000 --- a/sunbird-es-utils/src/main/resources/reindexing/mappings/certreg_mappings.json +++ /dev/null @@ -1,200 +0,0 @@ -{ - "dynamic":"false", - "properties":{ - "accessCode":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "createdAt":{ - "type":"date", - "fields":{ - "raw":{ - "type":"date" - } - } - }, - "createdBy":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "data":{ - "type":"object" - }, - "id":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "isRevoked":{ - "type":"boolean", - "fields":{ - "raw":{ - "type":"boolean" - } - } - }, - "jsonUrl":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "pdfUrl":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "reason":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "recipient":{ - "properties":{ - "id":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - }, - "type":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - } - } - }, - "related":{ - "properties":{ - "type":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - } - } - }, - "updatedAt":{ - "type":"date", - "fields":{ - "raw":{ - "type":"date" - } - } - }, - "updatedBy":{ - "type":"text", - "fields":{ - "raw":{ - "type":"text", - "analyzer":"keylower", - "fielddata":true - } - }, - "copy_to":[ - "all_fields" - ], - "analyzer":"cs_index_analyzer", - "search_analyzer":"cs_search_analyzer", - "fielddata":true - } - } -} \ No newline at end of file diff --git a/sunbird-es-utils/src/main/resources/reindexing/reindex.sh b/sunbird-es-utils/src/main/resources/reindexing/reindex.sh deleted file mode 100755 index 9fc38b77f..000000000 --- a/sunbird-es-utils/src/main/resources/reindexing/reindex.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/bash -set -eu -o pipefail - -perform_reindexing(){ - -echo ">>STEP1: mapping $alias_name with $old_index index" - - -alias_old_index_status=$( curl -s --write-out %{http_code} --silent --output --location --request POST 'http://'$es_ip':9200/_aliases?pretty' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "actions" : [ - { "add" : { "index" : "'$old_index'", "alias" : "'$alias_name'" } } - ] -}') - - -if [[ $alias_old_index_status == 200 ]] ; then - echo "'$old_index' index successfully map to alias $alias_name with status code 200" -else - echo "STEP1 FAILED:$old_index index is unable to map with alias $alias_name with status code $alias_old_index_status hence exiting program....." - exit 1 -fi - - -echo ">>STEP2: creating '$new_index' index" - -index_status_code=$( curl -s --write-out %{http_code} --silent --output --location --request PUT 'http://'$es_ip':9200/'$new_index'' \ ---header 'Content-Type: application/json' \ --d @$index_req_filepath) - -if [[ $index_status_code == 200 ]] ; then - echo "'$new_index' index successfully created with status code 200" -else - echo "STEP2 FAILED:'$new_index' index is unable to create with status code $index_status_code hence exiting program....." - exit 1 -fi - -echo ">>STEP3: creating mapping of '$new_index' index\n" - -mapping_status_code=$( curl -s --write-out %{http_code} --silent --output --location --request PUT 'http://'$es_ip':9200/'$new_index'/_doc/_mapping' \ ---header 'Content-Type: application/json' \ --d @$mapping_req_filepath) - -if [[ $mapping_status_code == 200 ]] ; then - echo "'$new_index' index mappings successfully created with status code 200" -else - echo "STEP3 FAILED:'$new_index' index is unable to create mappings with status code $mapping_status_code hence exiting program......" - exit 1 -fi - -echo ">>STEP4: copying $data_count certificates from '$old_index' index to '$new_index' index\n" - - -status_code=$( curl -s --write-out %{http_code} --silent --output --location --request POST 'http://'$es_ip':9200/_reindex' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "source": { - "index": "'$old_index'" - }, - "dest": { - "index": "'$new_index'" - } -}') - -if [[ $status_code == 200 ]] ; then - echo "$data_count certificates copied from '$old_index' to '$new_index' index with status code 200" -else - echo "STEP4 FAILED:to copy certificates with status code $status_code, please manually delete the temp index. exiting the program......" - exit 1 -fi - - -echo ">>STEP5: deleting $alias_name with $old_index index and mapping alias with $new_index" - -alias_new_index_status=$( curl -s --write-out %{http_code} --silent --output --location --request POST 'http://'$es_ip':9200/_aliases' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "actions" : [ - { "add" : { "index" : "'$new_index'", "alias" : "'$alias_name'" } }, - { "remove" : { "index" : "'$old_index'", "alias" : "'$alias_name'" }} - ] -}') - -if [[ $alias_new_index_status == 200 ]] ; then - echo "$alias_name successfully mapped to $new_index" -else - echo "$alias_name failed to map with $new_indexES with status code $alias_new_index_status, exiting....." - exit 1 -fi - -echo ">>STEP6: deleting previous $old_index index\n" - -index_delete_status_code=$( curl -s --write-out %{http_code} --silent --output --location --request DELETE 'http://'$es_ip':9200/'$old_index'' \ ---header 'Content-Type: application/json' ) - - -if [[ $index_delete_status_code == 200 ]] ; then - echo "$old_index index deleted with status code 200" -else - echo "STEP6 FAILED:to delete $old_index index with status code $index_delete_status_code exiting the program......" - exit 1 -fi - -} - - -echo "Starting REINDEXING PROGRAM IN ELASTICSEARCH......." - -es_ip=$1 -old_index=$2 -new_index=$3 -alias_name=$4 -index_req_filepath=$5 -mapping_req_filepath=$6 - -if [ "$#" -ne 6 ]; then - echo "PARAM INITIALIZATION FAILED, No command line arguments provided, Please provide esIp, old index, new index and alias name, index_req_filepath, mapping_req_filepath" - exit 1 -fi - - - -echo "checking provide file existence" - -[ -f "$index_req_filepath" ] || { echo "$index_req_filepath NOT FOUND" ; exit 1 ;} -[ -f "$mapping_req_filepath" ] || { echo "$mapping_req_filepath NOT FOUND" ; exit 1 ;} - - - - - -echo "ES_IP GOT: $es_ip\n" -echo "OLD INDEX(NEED TO BE DELETED) GOT: $old_index\n" -echo "NEW INDEX GOT: $new_index\n" -echo "Alias GOT: $alias_name\n" -echo "index json request path got $index_req_filepath" -echo "mapping request json path $mapping_req_filepath" -echo "=======Params Initialized==========\n" -echo "NOTE: IF ANY STEP FAILED PLEASE MANUALLY DELETE THE NEW INDEX from ElasticSearch i.e $new_index." - - - -eshealth_status_code=$( curl -s --write-out %{http_code} --silent --output --location --request GET 'http://'$es_ip':9200' \ ---header 'Content-Type: application/json' ) - -if [[ $eshealth_status_code == 200 ]] ; then - echo "ELASTICSEARCH IS ALIVE" -else - echo "ES is not alive please make sure es is up and running, exiting....." - exit 1 -fi - -DATE=`date "+%Y%m%d-%H%M%S"` -backup_file_name=certregBackup$DATE.txt -echo "PERFORMING '$old_index' BACKUP, can be found in file $backup_file_name" - -curl -s --location --request GET 'http://'$es_ip':9200/'$old_index'/_search?size=10000' --header 'Content-Type: application/json' --data-raw '{ - "query":{ - - "match_all":{} - - } -} - -' | jq '.' > $backup_file_name - - -data_count=$( curl -s --location --request GET 'http://'$es_ip':9200/'$old_index'/_count' --header 'Content-Type: application/json' --header 'Accept: text' | jq ."count" ) -echo "continue reindexing of $data_count records" -perform_reindexing - - - - diff --git a/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchRestHighImplTest.java b/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchRestHighImplTest.java deleted file mode 100644 index de1e7ef4c..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchRestHighImplTest.java +++ /dev/null @@ -1,466 +0,0 @@ -package org.sunbird.common; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; -import static org.powermock.api.mockito.PowerMockito.doNothing; -import static org.powermock.api.mockito.PowerMockito.mock; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.bulk.BulkProcessor; -import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetRequestBuilder; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.update.UpdateResponse; -import org.elasticsearch.client.RestHighLevelClient; -import org.elasticsearch.common.util.concurrent.FutureUtils; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.Aggregations; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.factory.EsClientFactory; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.helper.ConnectionManager; -import scala.concurrent.Future; -@Ignore -/** - * Test class for Elastic search Rest High level client Impl - * - * @author github.com/iostream04 - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -@PrepareForTest({ - ConnectionManager.class, - RestHighLevelClient.class, - AcknowledgedResponse.class, - GetRequestBuilder.class, - HttpUtil.class, - BulkProcessor.class, - FutureUtils.class, - SearchHit.class, - SearchHits.class, - Aggregations.class, - ElasticSearchHelper.class -}) -public class ElasticSearchRestHighImplTest { - - private ElasticSearchService esService = EsClientFactory.getInstance(JsonKey.REST); - private static RestHighLevelClient client = null; - - @Before - public void initBeforeTest() { - mockBaseRules(); - mockRulesForSave(false); - } - - @Test - public void testSaveSuccess() { - mockRulesForSave(false); - Future result = esService.save("test", "001", new HashMap<>()); - String res = (String) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals("001", res); - } - - @Test - public void testSaveFailureWithEmptyIndex() { - - Future result = esService.save("", "001", new HashMap<>()); - String res = (String) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals("ERROR", res); - } - - @Test - public void testSaveFailureWithEmptyIdentifier() { - Future result = esService.save("test", "", new HashMap<>()); - String res = (String) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals("ERROR", res); - } - - @Test - public void testSaveFailure() { - mockRulesForSave(true); - Future result = esService.save("test", "001", new HashMap<>()); - String res = (String) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(null, res); - } - - @Test - public void testUpdateSuccess() { - mockRulesForUpdate(false); - Future result = esService.update("test", "001", new HashMap<>()); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(true, res); - } - - @Test - public void testUpdateFailure() { - mockRulesForUpdate(true); - Future result = esService.update("test", "001", new HashMap<>()); - Object res = ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(null, res); - } - - @Test - public void testUpdateFailureWithEmptyIndex() { - try { - esService.update("", "001", new HashMap<>()); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testUpdateFailureWithEmptyIdentifier() { - try { - esService.update("test", "", new HashMap<>()); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testGetDataByIdentifierFailureWithEmptyIndex() { - try { - esService.getDataByIdentifier("", "001"); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testGetDataByIdentifierFailureWithEmptyIdentifier() { - try { - esService.getDataByIdentifier("test", ""); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testGetDataByIdentifierFailure() { - mockRulesForGet(true); - Future> result = esService.getDataByIdentifier("test", "001"); - Object res = ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(null, res); - } - - @Test - public void testDeleteSuccess() { - mockRulesForDelete(false, false); - Future result = esService.delete("test", "001"); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(true, res); - } - - @Test - public void testDeleteSuccessWithoutDelete() { - mockRulesForDelete(false, true); - Future result = esService.delete("test", "001"); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(false, res); - } - - @Test - public void testDeleteFailure() { - mockRulesForDelete(true, false); - Future result = esService.delete("test", "001"); - Object res = ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(null, res); - } - - @Test - public void testDeleteFailureWithEmptyIdentifier() { - try { - esService.delete("test", ""); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testDeleteFailureWithEmptyIndex() { - try { - esService.delete("", "001"); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testUpsertSuccess() { - mockRulesForUpdate(false); - Future result = esService.update("test", "001", new HashMap<>()); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(true, res); - } - - @Test - public void testUpsertFailure() { - mockRulesForUpdate(true); - Future result = esService.update("test", "001", new HashMap<>()); - Object res = ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(null, res); - } - - @Test - public void testUpsertFailureWithEmptyIndex() { - try { - esService.update("", "001", new HashMap<>()); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testUpsertFailureWithEmptyIdentifier() { - try { - esService.update("test", "", new HashMap<>()); - } catch (ProjectCommonException e) { - assertEquals(e.getResponseCode(), ResponseCode.invalidData.getResponseCode()); - } - } - - @Test - public void testBuilInsertSuccess() { - mockRulesForBulk(false); - List> list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.IDENTIFIER, "0001"); - list.add(map); - Future result = esService.bulkInsert("test", list); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(true, res); - } - - @Test - public void testBuilInsertFailure() { - mockRulesForBulk(true); - List> list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.IDENTIFIER, "0001"); - list.add(map); - Future result = esService.bulkInsert("test", list); - boolean res = (boolean) ElasticSearchHelper.getResponseFromFuture(result); - assertEquals(false, res); - } - - private void mockBaseRules() { - client = mock(RestHighLevelClient.class); - PowerMockito.mockStatic(ConnectionManager.class); - try { - doNothing().when(ConnectionManager.class, "registerShutDownHook"); - } catch (Exception e) { - Assert.fail("Initialization of test case failed due to " + e.getLocalizedMessage()); - } - when(ConnectionManager.getRestClient()).thenReturn(client); - } - - private static void mockRulesForBulk(boolean fail) { - Iterator itr = mock(Iterator.class); - - BulkResponse response = mock(BulkResponse.class); - when(response.iterator()).thenReturn(itr); - when(itr.hasNext()).thenReturn(false); - - if (!fail) { - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((ActionListener) invocation.getArguments()[1]) - .onResponse(response); - return null; - } - }) - .when(client) - .bulkAsync(Mockito.any(), Mockito.any()); - } else { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - - ((ActionListener) invocation.getArguments()[1]) - .onFailure(new NullPointerException()); - return null; - } - }) - .when(client) - .bulkAsync(Mockito.any(), Mockito.any()); - } - } - - private static void mockRulesForSave(boolean fail) { - IndexResponse ir = mock(IndexResponse.class); - when(ir.getId()).thenReturn("001"); - - if (!fail) { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((ActionListener) invocation.getArguments()[1]).onResponse(ir); - return null; - } - }) - .when(client) - .indexAsync(Mockito.any(), Mockito.any()); - } else { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - - ((ActionListener) invocation.getArguments()[1]) - .onFailure(new NullPointerException()); - return null; - } - }) - .when(client) - .indexAsync(Mockito.any(), Mockito.any()); - } - } - - @SuppressWarnings("rawtypes") - private static void mockRulesForUpdate(boolean fail) { - UpdateResponse updateRes = mock(UpdateResponse.class); - when(updateRes.getResult()).thenReturn(null); - - if (!fail) { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((ActionListener) invocation.getArguments()[1]) - .onResponse(updateRes); - return null; - } - }) - .when(client) - .updateAsync(Mockito.any(), Mockito.any()); - } else { - - doAnswer( - new Answer() { - @SuppressWarnings("unchecked") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - - ((ActionListener) invocation.getArguments()[1]) - .onFailure(new NullPointerException()); - return null; - } - }) - .when(client) - .updateAsync(Mockito.any(), Mockito.any()); - } - } - - @SuppressWarnings("rawtypes") - private static void mockRulesForGet(boolean fail) { - GetResponse getResponse = mock(GetResponse.class); - Map map = new HashMap<>(); - map.put("test", "any"); - when(getResponse.getSourceAsMap()).thenReturn(map); - when(getResponse.isExists()).thenReturn(true); - - if (!fail) { - - doAnswer( - new Answer() { - @SuppressWarnings("unchecked") - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((ActionListener) invocation.getArguments()[1]) - .onResponse(getResponse); - return null; - } - }) - .when(client) - .getAsync(Mockito.any(), Mockito.any()); - } else { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - - ((ActionListener) invocation.getArguments()[1]) - .onFailure(new NullPointerException()); - return null; - } - }) - .when(client) - .getAsync(Mockito.any(), Mockito.any()); - } - } - - private static void mockRulesForDelete(boolean fail, boolean notFound) { - DeleteResponse delResponse = mock(DeleteResponse.class); - - if (!fail) { - if (notFound) { - when(delResponse.getResult()).thenReturn(DocWriteResponse.Result.NOT_FOUND); - } - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((ActionListener) invocation.getArguments()[1]) - .onResponse(delResponse); - return null; - } - }) - .when(client) - .deleteAsync(Mockito.any(), Mockito.any()); - } else { - - doAnswer( - new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - - ((ActionListener) invocation.getArguments()[1]) - .onFailure(new NullPointerException()); - return null; - } - }) - .when(client) - .deleteAsync(Mockito.any(), Mockito.any()); - } - } -} diff --git a/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchTcpImplTest.java b/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchTcpImplTest.java deleted file mode 100644 index c98d35388..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/common/ElasticSearchTcpImplTest.java +++ /dev/null @@ -1,806 +0,0 @@ -package org.sunbird.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.doNothing; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import org.elasticsearch.action.ActionFuture; -import org.elasticsearch.action.DocWriteResponse.Result; -import org.elasticsearch.action.ListenableActionFuture; -import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; -import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; -import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; -import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; -import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; -import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder; -import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; -import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder; -import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; -import org.elasticsearch.action.bulk.BulkProcessor; -import org.elasticsearch.action.bulk.BulkProcessor.Listener; -import org.elasticsearch.action.delete.DeleteRequestBuilder; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetRequestBuilder; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.action.update.UpdateResponse; -import org.elasticsearch.client.AdminClient; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.IndicesAdminClient; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.FutureUtils; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.Aggregations; -import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.sort.SortOrder; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Ignore; -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; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.factory.EsClientFactory; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import org.sunbird.helper.ConnectionManager; -import scala.concurrent.Future; - -/** - * Test class for Elastic search TCP client Impl - * - * @author github.com/iostream04 - */ -@Ignore -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -@PrepareForTest({ - ConnectionManager.class, - TransportClient.class, - AcknowledgedResponse.class, - GetRequestBuilder.class, - HttpUtil.class, - BulkProcessor.class, - FutureUtils.class, - SearchHit.class, - SearchHits.class, - Aggregations.class -}) -@SuppressStaticInitializationFor({"org.sunbird.common.ConnectionManager"}) -public class ElasticSearchTcpImplTest { - private static Map chemistryMap = null; - private static Map physicsMap = null; - private static TransportClient client = null; - private static final String INDEX_NAME = "sbtestindex"; - private static final String STARTS_WITH = "startsWith"; - private static final String ENDS_WITH = "endsWith"; - private ElasticSearchService esService = EsClientFactory.getInstance(JsonKey.TCP); - - @BeforeClass - public static void initClass() throws Exception { - chemistryMap = initializeChemistryCourse(5); - physicsMap = intitializePhysicsCourse(60); - } - - @Before - public void initBeforeTest() { - mockBaseRules(); - mockRulesForGet(); - mockRulesForInsert(); - mockRulesForUpdate(); - mockRulesForDelete(); - - mockRulesForIndexes(); - mockRulesHttpRequest(); - mockRulesBulkInsert(); - } - - @Test - public void testCreateDataSuccess() { - mockRulesForInsert(); - - esService.save(INDEX_NAME, (String) chemistryMap.get("courseId"), chemistryMap); - assertNotNull(chemistryMap.get("courseId")); - - esService.save(INDEX_NAME, (String) physicsMap.get("courseId"), physicsMap); - assertNotNull(physicsMap.get("courseId")); - } - - @Test - public void testGetByIdentifierSuccess() { - Future> responseMapF = - esService.getDataByIdentifier(INDEX_NAME, (String) chemistryMap.get("courseId")); - - Map responseMap = - (Map) ElasticSearchHelper.getResponseFromFuture(responseMapF); - - assertEquals(responseMap.get("courseId"), chemistryMap.get("courseId")); - } - - @Test - public void testUpdateDataSuccess() { - Map innermap = new HashMap<>(); - innermap.put("courseName", "Updated course name"); - innermap.put("organisationId", "updatedOrgId"); - - GetRequestBuilder grb = mock(GetRequestBuilder.class); - GetResponse getResponse = mock(GetResponse.class); - when(client.prepareGet( - Mockito.anyString(), - Mockito.anyString(), - Mockito.eq((String) chemistryMap.get("courseId")))) - .thenReturn(grb); - when(grb.get()).thenReturn(getResponse); - when(getResponse.getSource()).thenReturn(innermap); - - Future responseF = - esService.update(INDEX_NAME, (String) chemistryMap.get("courseId"), innermap); - boolean response = (boolean) ElasticSearchHelper.getResponseFromFuture(responseF); - assertTrue(response); - } - - @Test - @Ignore - public void testComplexSearchSuccess() throws Exception { - SearchDTO searchDTO = new SearchDTO(); - - List fields = new ArrayList(); - fields.add("courseId"); - fields.add("courseType"); - fields.add("createdOn"); - fields.add("description"); - - Map sortMap = new HashMap<>(); - sortMap.put("courseType", "ASC"); - searchDTO.setSortBy(sortMap); - - List excludedFields = new ArrayList(); - excludedFields.add("createdOn"); - searchDTO.setExcludedFields(excludedFields); - - searchDTO.setLimit(20); - searchDTO.setOffset(0); - - Map additionalPro = new HashMap(); - searchDTO.addAdditionalProperty("test", additionalPro); - - List existsList = new ArrayList(); - existsList.add("pkgVersion"); - existsList.add("size"); - - Map additionalProperties = new HashMap(); - additionalProperties.put(JsonKey.EXISTS, existsList); - - List description = new ArrayList(); - description.add("This is for chemistry"); - description.add("Hindi Jii"); - - List sizes = new ArrayList(); - sizes.add(10); - sizes.add(20); - - Map filterMap = new HashMap(); - filterMap.put("description", description); - filterMap.put("size", sizes); - additionalProperties.put(JsonKey.FILTERS, filterMap); - - Map rangeMap = new HashMap(); - rangeMap.put(">", 0); - filterMap.put("pkgVersion", rangeMap); - - Map lexicalMap = new HashMap<>(); - lexicalMap.put(STARTS_WITH, "type"); - filterMap.put("courseType", lexicalMap); - Map lexicalMap1 = new HashMap<>(); - lexicalMap1.put(ENDS_WITH, "sunbird"); - filterMap.put("courseAddedByName", lexicalMap1); - filterMap.put("orgName", "Name of the organisation"); - - searchDTO.setAdditionalProperties(additionalProperties); - searchDTO.setFields(fields); - searchDTO.setQuery("organisation"); - - List mode = Arrays.asList("soft"); - searchDTO.setMode(mode); - Map constraintMap = new HashMap(); - constraintMap.put("grades", 10); - constraintMap.put("pkgVersion", 5); - searchDTO.setSoftConstraints(constraintMap); - searchDTO.setQuery("organisation Name published"); - mockRulesForSearch(3); - Future> map = esService.search(searchDTO, INDEX_NAME); - Map response = - (Map) ElasticSearchHelper.getResponseFromFuture(map); - - assertEquals(2, response.size()); - } - - @Test - @Ignore - public void testComplexSearchSuccessWithRangeGreaterThan() { - SearchDTO searchDTO = new SearchDTO(); - Map additionalProperties = new HashMap(); - List sizes = new ArrayList(); - sizes.add(10); - sizes.add(20); - Map filterMap = new HashMap(); - filterMap.put("size", sizes); - Map innerMap = new HashMap<>(); - innerMap.put("createdOn", "2017-11-06"); - filterMap.put(">=", innerMap); - additionalProperties.put(JsonKey.FILTERS, filterMap); - Map rangeMap = new HashMap(); - rangeMap.put(">", 0); - filterMap.put("pkgVersion", rangeMap); - Map lexicalMap = new HashMap<>(); - lexicalMap.put(STARTS_WITH, "type"); - filterMap.put("courseType", lexicalMap); - Map lexicalMap1 = new HashMap<>(); - lexicalMap1.put(ENDS_WITH, "sunbird"); - filterMap.put("courseAddedByName", lexicalMap1); - filterMap.put("orgName", "Name of the organisation"); - - searchDTO.setAdditionalProperties(additionalProperties); - searchDTO.setQuery("organisation"); - mockRulesForSearch(3); - - Future> map = esService.search(searchDTO, INDEX_NAME); - Map response = - (Map) ElasticSearchHelper.getResponseFromFuture(map); - assertEquals(2, response.size()); - } - - @Test - @Ignore - public void testComplexSearchSuccessWithRangeLessThan() { - SearchDTO searchDTO = new SearchDTO(); - Map additionalProperties = new HashMap(); - List sizes = new ArrayList(); - sizes.add(10); - sizes.add(20); - Map filterMap = new HashMap(); - filterMap.put("size", sizes); - Map innerMap = new HashMap<>(); - innerMap.put("createdOn", "2017-11-06"); - filterMap.put("<=", innerMap); - additionalProperties.put(JsonKey.FILTERS, filterMap); - Map rangeMap = new HashMap(); - rangeMap.put(">", 0); - filterMap.put("pkgVersion", rangeMap); - Map lexicalMap = new HashMap<>(); - lexicalMap.put(STARTS_WITH, "type"); - filterMap.put("courseType", lexicalMap); - Map lexicalMap1 = new HashMap<>(); - lexicalMap1.put(ENDS_WITH, "sunbird"); - filterMap.put("courseAddedByName", lexicalMap1); - filterMap.put("orgName", "Name of the organisation"); - - searchDTO.setAdditionalProperties(additionalProperties); - searchDTO.setQuery("organisation"); - mockRulesForSearch(3); - Future> map = esService.search(searchDTO, INDEX_NAME); - Map response = - (Map) ElasticSearchHelper.getResponseFromFuture(map); - assertEquals(2, response.size()); - } - - @Test - public void testGetByIdentifierFailureWithoutIndex() { - try { - esService.getDataByIdentifier(null, (String) chemistryMap.get("courseId")); - } catch (ProjectCommonException ex) { - assertEquals(ResponseCode.SERVER_ERROR.getResponseCode(), ex.getResponseCode()); - } - } - - @Test - public void testGetByIdentifierFailureWithoutTypeAndIndexIdentifier() { - try { - esService.getDataByIdentifier(null, ""); - } catch (ProjectCommonException ex) { - assertEquals(ResponseCode.SERVER_ERROR.getResponseCode(), ex.getResponseCode()); - } - } - - @Test - public void testGetDataByIdentifierFailureWithoutIdentifier() { - Future> responseMap = esService.getDataByIdentifier(INDEX_NAME, ""); - Map map = - (Map) ElasticSearchHelper.getResponseFromFuture(responseMap); - assertEquals(0, map.size()); - } - - @Test - public void testUpdateDataFailureWithoutIdentifier() { - Map innermap = new HashMap<>(); - innermap.put("courseName", "Updated Course Name"); - innermap.put("organisationId", "updatedOrgId"); - Future response = esService.update(INDEX_NAME, null, innermap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testUpdateDataFailureWithEmptyMap() { - Map innermap = new HashMap<>(); - Future response = - esService.update(INDEX_NAME, (String) chemistryMap.get("courseId"), innermap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testUpdateDataFailureWithNullMap() { - Future response = - esService.update(INDEX_NAME, (String) chemistryMap.get("courseId"), null); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testUpsertDataFailureWithoutIdentifier() { - Map innermap = new HashMap<>(); - innermap.put("courseName", "Updated Course Name"); - innermap.put("organisationId", "updatedOrgId"); - Future response = esService.upsert(INDEX_NAME, null, innermap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testUpsertDataFailureWithoutIndex() { - Map innermap = new HashMap<>(); - innermap.put("courseName", "Updated Course Name"); - innermap.put("organisationId", "updatedOrgId"); - Future response = - esService.upsert(null, (String) chemistryMap.get("courseId"), innermap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testUpsertDataFailureWithEmptyMap() { - Map innermap = new HashMap<>(); - Future response = - esService.upsert(INDEX_NAME, (String) chemistryMap.get("courseId"), innermap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertFalse(result); - } - - @Test - public void testSaveDataFailureWithoutIndexName() { - Future response = - esService.save("", (String) chemistryMap.get("courseId"), chemistryMap); - String result = (String) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals("ERROR", result); - } - - @Test - public void testGetDataByIdentifierFailureByEmptyIdentifier() { - Future> responseMap = esService.getDataByIdentifier(INDEX_NAME, ""); - Map response = - (Map) ElasticSearchHelper.getResponseFromFuture(responseMap); - assertEquals(0, response.size()); - } - - @Test - public void testRemoveDataSuccessByIdentifier() { - Future response = esService.delete(INDEX_NAME, (String) chemistryMap.get("courseId")); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals(true, result); - } - - @Test - public void testRemoveDataFailureByIdentifierEmpty() { - Future response = esService.delete(INDEX_NAME, ""); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals(false, result); - } - - @Test - public void testInitialiseConnectionFailureFromProperties() { - boolean response = - ConnectionManager.initialiseConnectionFromPropertiesFile( - "Test", "localhost1,128.0.0.1", "9200,9300"); - assertFalse(response); - } - - @Test - public void testHealthCheckSuccess() { - Future response = esService.healthCheck(); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals(true, result); - } - - @Test - public void testUpsertDataSuccess() { - Map data = new HashMap(); - data.put("test", "test"); - Future response = esService.upsert(INDEX_NAME, "test-12349", data); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals(true, result); - } - - @Test - public void testBulkInsertDataSuccess() { - Map data = new HashMap(); - data.put("test1", "test"); - data.put("test2", "manzarul"); - List> listOfMap = new ArrayList>(); - listOfMap.add(data); - Future response = esService.bulkInsert(INDEX_NAME, listOfMap); - boolean result = (boolean) ElasticSearchHelper.getResponseFromFuture(response); - assertEquals(true, result); - } - - @Test - public void testSearchMetricsDataSuccess() { - String index = "searchindex"; - String rawQuery = "{\"query\":{\"match_none\":{}}}"; - Response response = esService.searchMetricsData(index, rawQuery); - assertEquals(ResponseCode.OK, response.getResponseCode()); - } - - @Test - public void testSearchMetricsDataFailure() { - String index = "searchtest"; - String rawQuery = "{\"query\":{\"match_none\":{}}}"; - try { - esService.searchMetricsData(index, rawQuery); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.unableToConnectToES.getErrorCode(), e.getCode()); - } - } - - private static Map initializeChemistryCourse(int appendVal) { - Map chemistryMap = new HashMap<>(); - chemistryMap.put("courseType", "type of the course. all , private"); - chemistryMap.put("description", "This is for chemistry"); - chemistryMap.put("size", 10); - chemistryMap.put("objectType", "course"); - chemistryMap.put("courseId", "course id_" + appendVal); - chemistryMap.put("courseName", "NTP course_" + appendVal); - chemistryMap.put("courseDuration", appendVal); - chemistryMap.put("noOfLecture", 30 + appendVal); - chemistryMap.put("organisationId", "org id"); - chemistryMap.put("orgName", "Name of the organisation"); - chemistryMap.put("courseAddedById", "who added the course in NTP"); - chemistryMap.put("courseAddedByName", "Name of the person who added the course under sunbird"); - chemistryMap.put("coursePublishedById", "who published the course"); - chemistryMap.put("coursePublishedByName", "who published the course"); - chemistryMap.put("enrollementStartDate", new Date()); - chemistryMap.put("publishedDate", new Date()); - chemistryMap.put("updatedDate", new Date()); - chemistryMap.put("updatedById", "last updated by id"); - chemistryMap.put("updatedByName", "last updated person name"); - - chemistryMap.put("facultyId", "faculty for this course"); - chemistryMap.put("facultyName", "name of the faculty"); - chemistryMap.put( - "CoursecontentType", - "list of course content type as comma separated , pdf, video, wordDoc"); - chemistryMap.put("availableFor", "[\"C.B.S.C\",\"I.C.S.C\",\"all\"]"); - chemistryMap.put("tutor", "[{\"id\":\"name\"},{\"id\":\"name\"}]"); - chemistryMap.put("operationType", "add/updated/delete"); - chemistryMap.put("owner", "EkStep"); - - chemistryMap.put("visibility", "Default"); - chemistryMap.put( - "downloadUrl", - "https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/ecar_files/do_112228048362078208130/test-content-1_1493905653021_do_112228048362078208130_5.0.ecar"); - - chemistryMap.put("language", "[\"Hindi\"]"); - chemistryMap.put("mediaType", "content"); - chemistryMap.put( - "variants", - "{\"spine\": {\"ecarUrl\": \"https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/ecar_files/do_112228048362078208130/test-content-1_1493905655272_do_112228048362078208130_5.0_spine.ecar\",\"size\": 863}}"); - chemistryMap.put("mimeType", "application/vnd.ekstep.html-archive"); - chemistryMap.put("osId", "org.ekstep.quiz.app"); - chemistryMap.put("languageCode", "hi"); - chemistryMap.put("createdOn", "2017-05-04T13:47:32.676+0000"); - chemistryMap.put("pkgVersion", appendVal); - chemistryMap.put("versionKey", "1495646809112"); - - chemistryMap.put("lastPublishedOn", "2017-05-04T13:47:33.000+0000"); - chemistryMap.put( - "collections", - "[{\"identifier\": \"do_1121912573615472641169\",\"name\": \"A\",\"objectType\": \"Content\",\"relation\": \"hasSequenceMember\",\"description\": \"A.\",\"index\": null}]"); - chemistryMap.put("name", "Test Content 1"); - chemistryMap.put( - "artifactUrl", - "https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/content/do_112228048362078208130/artifact/advancedenglishassessment1_1533_1489654074_1489653812104_1492681721669.zip"); - chemistryMap.put("lastUpdatedOn", "2017-05-24T17:26:49.112+0000"); - chemistryMap.put("contentType", "Story"); - chemistryMap.put("status", "Live"); - chemistryMap.put("channel", "NTP"); - return chemistryMap; - } - - private static Map intitializePhysicsCourse(int appendVal) { - Map physicsCourseMap = new HashMap<>(); - physicsCourseMap.put("courseType", "type of the course. all , private"); - physicsCourseMap.put("description", "This is for physics"); - physicsCourseMap.put("size", 20); - physicsCourseMap.put("objectType", "course"); - physicsCourseMap.put("courseId", "course id_" + appendVal); - physicsCourseMap.put("courseName", "NTP course_" + appendVal); - physicsCourseMap.put("courseDuration", appendVal); - physicsCourseMap.put("noOfLecture", 30 + appendVal); - physicsCourseMap.put("organisationId", "org id"); - physicsCourseMap.put("orgName", "Name of the organisation"); - physicsCourseMap.put("courseAddedById", "who added the course in NTP"); - physicsCourseMap.put( - "courseAddedByName", "Name of the person who added the course under sunbird"); - physicsCourseMap.put("coursePublishedById", "who published the course"); - physicsCourseMap.put("coursePublishedByName", "who published the course"); - physicsCourseMap.put("enrollementStartDate", new Date()); - physicsCourseMap.put("publishedDate", new Date()); - physicsCourseMap.put("updatedDate", new Date()); - physicsCourseMap.put("updatedById", "last updated by id"); - physicsCourseMap.put("updatedByName", "last updated person name"); - - physicsCourseMap.put("facultyId", "faculty for this course"); - physicsCourseMap.put("facultyName", "name of the faculty"); - physicsCourseMap.put( - "CoursecontentType", - "list of course content type as comma separated , pdf, video, wordDoc"); - physicsCourseMap.put("availableFor", "[\"C.B.S.C\",\"I.C.S.C\",\"all\"]"); - physicsCourseMap.put("tutor", "[{\"id\":\"name\"},{\"id\":\"name\"}]"); - physicsCourseMap.put("operationType", "add/updated/delete"); - physicsCourseMap.put("owner", "EkStep"); - - physicsCourseMap.put("visibility", "Default"); - physicsCourseMap.put( - "downloadUrl", - "https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/ecar_files/do_112228048362078208130/test-content-1_1493905653021_do_112228048362078208130_5.0.ecar"); - - physicsCourseMap.put("language", "[\"Hindi\"]"); - physicsCourseMap.put("mediaType", "content"); - physicsCourseMap.put( - "variants", - "{\"spine\": {\"ecarUrl\": \"https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/ecar_files/do_112228048362078208130/test-content-1_1493905655272_do_112228048362078208130_5.0_spine.ecar\",\"size\": 863}}"); - physicsCourseMap.put("mimeType", "application/vnd.ekstep.html-archive"); - physicsCourseMap.put("osId", "org.ekstep.quiz.app"); - physicsCourseMap.put("languageCode", "hi"); - physicsCourseMap.put("createdOn", "2017-06-04T13:47:32.676+0000"); - physicsCourseMap.put("pkgVersion", appendVal); - physicsCourseMap.put("versionKey", "1495646809112"); - - physicsCourseMap.put("lastPublishedOn", "2017-05-04T13:47:33.000+0000"); - physicsCourseMap.put( - "collections", - "[{\"identifier\": \"do_1121912573615472641169\",\"name\": \"A\",\"objectType\": \"Content\",\"relation\": \"hasSequenceMember\",\"description\": \"A.\",\"index\": null}]"); - physicsCourseMap.put("name", "Test Content 1"); - physicsCourseMap.put( - "artifactUrl", - "https://ekstep-public-dev.s3-ap-south-1.amazonaws.com/content/do_112228048362078208130/artifact/advancedenglishassessment1_1533_1489654074_1489653812104_1492681721669.zip"); - physicsCourseMap.put("lastUpdatedOn", "2017-05-24T17:26:49.112+0000"); - physicsCourseMap.put("contentType", "Story"); - physicsCourseMap.put("status", "Live"); - physicsCourseMap.put("channel", "NTP"); - return physicsCourseMap; - } - - private void mockBaseRules() { - client = mock(TransportClient.class); - PowerMockito.mockStatic(ConnectionManager.class); - try { - doNothing().when(ConnectionManager.class, "registerShutDownHook"); - } catch (Exception e) { - Assert.fail("Initialization of test case failed due to " + e.getLocalizedMessage()); - } - when(ConnectionManager.getClient()).thenReturn(client); - } - - private static void mockRulesForGet() { - mockRulesForGet(false); - } - - private static void mockRulesForGet(boolean expectedEmptyMap) { - GetRequestBuilder grb = mock(GetRequestBuilder.class); - GetResponse gResp = mock(GetResponse.class); - when(client.prepareGet(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) - .thenReturn(grb); - - when(client.prepareGet()).thenReturn(grb); - when(grb.setIndex(Mockito.anyString())).thenReturn(grb); - when(grb.setId(Mockito.anyString())).thenReturn(grb); - when(grb.get()).thenReturn(gResp); - Map expMap = expectedEmptyMap ? Collections.emptyMap() : chemistryMap; - when(gResp.getSource()).thenReturn(expMap); - } - - private void mockRulesForSearch(long expectedValue) { - SearchRequestBuilder srb = mock(SearchRequestBuilder.class); - ListenableActionFuture lstActFtr = mock(ListenableActionFuture.class); - List lst = new ArrayList<>(); - SearchHit hit1 = mock(SearchHit.class); - lst.add(hit1); - - SearchResponse searchResponse = mock(SearchResponse.class); - Aggregations aggregations = mock(Aggregations.class); - Terms terms = mock(Terms.class); - Histogram histogram = mock(Histogram.class); - SearchHits searchHits = mock(SearchHits.class); - - when(client.prepareSearch(Mockito.anyVararg())).thenReturn(srb); - when(srb.setIndices(Mockito.anyVararg())).thenReturn(srb); - when(srb.setTypes(Mockito.anyVararg())).thenReturn(srb); - when(srb.addSort(Mockito.anyString(), Mockito.any(SortOrder.class))).thenReturn(srb); - when(srb.execute()).thenReturn(lstActFtr); - when(lstActFtr.actionGet()).thenReturn(searchResponse); - when(searchResponse.getHits()).thenReturn(searchHits); - when(searchResponse.getAggregations()).thenReturn(aggregations); - when(aggregations.get(Mockito.eq("description"))).thenReturn(terms); - // when(aggregations.get(Mockito.eq("createdOn"))).thenReturn(histogram); - when(terms.getBuckets()).thenReturn(new ArrayList<>()); - when(histogram.getBuckets()).thenReturn(new ArrayList<>()); - - when(searchHits.getTotalHits()).thenReturn(expectedValue); - - when(searchHits.iterator()).thenReturn(lst.iterator()); - when(hit1.getSourceAsMap()).thenReturn(new HashMap()); - } - - private static void mockRulesForInsert() { - IndexRequestBuilder irb = mock(IndexRequestBuilder.class); - IndexResponse ir = mock(IndexResponse.class); - - when(client.prepareIndex(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) - .thenReturn(irb); - when(irb.setSource(Mockito.anyMap())).thenReturn(irb); - when(irb.get()).thenReturn(ir); - when(ir.getId()).thenReturn((String) chemistryMap.get("courseId")); - } - - private static void mockRulesForUpdate() { - UpdateRequestBuilder urbForUpdate = mock(UpdateRequestBuilder.class); - UpdateRequestBuilder urbForEmptyUpdate = mock(UpdateRequestBuilder.class); - ActionFuture actFtr = mock(ActionFuture.class); - UpdateResponse updateResponse = mock(UpdateResponse.class); - UpdateResponse updateForEmptyRespose = mock(UpdateResponse.class); - - when(client.prepareUpdate(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) - .thenReturn(urbForUpdate); - when(urbForUpdate.setDoc(Mockito.anyMap())).thenReturn(urbForUpdate); - when(urbForUpdate.get()).thenReturn(updateResponse); - when(updateResponse.getResult()).thenReturn(Result.UPDATED); - - // Making sure update returns empty for empty response. - when(urbForUpdate.setDoc(Mockito.eq(new HashMap()))) - .thenReturn(urbForEmptyUpdate); - when(urbForEmptyUpdate.get()).thenReturn(updateForEmptyRespose); - when(updateForEmptyRespose.getResult()).thenReturn(Result.NOOP); - - when(client.update(Mockito.any(UpdateRequest.class))).thenReturn(actFtr); - try { - when(actFtr.get()).thenReturn(updateResponse); - } catch (InterruptedException | ExecutionException e) { - Assert.fail("Initialization of test case failed due to " + e.getLocalizedMessage()); - } - } - - private static void mockRulesForDelete() { - DeleteRequestBuilder drb = mock(DeleteRequestBuilder.class); - DeleteResponse delResponse = mock(DeleteResponse.class); - when(client.prepareDelete(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) - .thenReturn(drb); - when(drb.get()).thenReturn(delResponse); - when(delResponse.getResult()).thenReturn(Result.DELETED); - } - - public static void mockRulesForIndexes() { - mockRulesForIndexes(true); - } - - public static void mockRulesForIndexes(boolean mappingsDone) { - - IndicesAdminClient indicesAdminMock = mock(IndicesAdminClient.class); - AdminClient adminMock = mock(AdminClient.class); - RefreshRequestBuilder refReqBldr = mock(RefreshRequestBuilder.class); - RefreshResponse refResponse = mock(RefreshResponse.class); - ActionFuture actFtrType = mock(ActionFuture.class); - ActionFuture actFtrIndex = mock(ActionFuture.class); - IndicesExistsResponse indExistResponse = mock(IndicesExistsResponse.class); - TypesExistsResponse typeExistsResponse = mock(TypesExistsResponse.class); - - CreateIndexRequestBuilder mockCreateIndexReqBldr = mock(CreateIndexRequestBuilder.class); - PutMappingRequestBuilder mockPutMappingReqBldr = mock(PutMappingRequestBuilder.class); - PutMappingResponse mockPutMappingResponse = mock(PutMappingResponse.class); - CreateIndexResponse mockCreateIndResp = mock(CreateIndexResponse.class); - - doReturn(adminMock).when(client).admin(); - doReturn(indicesAdminMock).when(adminMock).indices(); - doReturn(actFtrType).when(indicesAdminMock).typesExists(Mockito.any(TypesExistsRequest.class)); - doReturn(actFtrIndex).when(indicesAdminMock).exists(Mockito.any(IndicesExistsRequest.class)); - doReturn(refReqBldr).when(indicesAdminMock).prepareRefresh(Mockito.anyVararg()); - - doReturn(refResponse).when(refReqBldr).get(); - try { - doReturn(indExistResponse).when(actFtrIndex).get(); - doReturn(true).when(indExistResponse).isExists(); - } catch (InterruptedException | ExecutionException e) { - Assert.fail("Exception occurred " + e.getLocalizedMessage()); - } - - try { - doReturn(typeExistsResponse).when(actFtrType).get(); - doReturn(true).when(typeExistsResponse).isExists(); - } catch (InterruptedException | ExecutionException e) { - Assert.fail("Exception occurred " + e.getLocalizedMessage()); - } - doReturn(mockCreateIndexReqBldr).when(indicesAdminMock).prepareCreate(Mockito.anyString()); - - doReturn(mockCreateIndexReqBldr) - .when(mockCreateIndexReqBldr) - .setSettings(Mockito.any(Settings.class)); - - doReturn(mockCreateIndResp).when(mockCreateIndexReqBldr).get(); - doReturn(true).when(mockCreateIndResp).isAcknowledged(); - doReturn(mockPutMappingReqBldr).when(indicesAdminMock).preparePutMapping(Mockito.anyString()); - doReturn(mockPutMappingReqBldr).when(indicesAdminMock).preparePutMapping(Mockito.anyString()); - doReturn(mockPutMappingReqBldr).when(mockPutMappingReqBldr).setSource(Mockito.anyString()); - doReturn(mockPutMappingReqBldr).when(mockPutMappingReqBldr).setType(Mockito.anyString()); - doReturn(mockPutMappingResponse).when(mockPutMappingReqBldr).get(); - doReturn(mappingsDone).when(mockPutMappingResponse).isAcknowledged(); - } - - private static void mockRulesHttpRequest() { - PowerMockito.mockStatic(HttpUtil.class); - try { - when(HttpUtil.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.anyMap())) - .thenReturn("{}"); - } catch (Exception e) { - Assert.fail("Exception occurred " + e.getLocalizedMessage()); - } - } - - private static void mockRulesBulkInsert() { - PowerMockito.mockStatic(BulkProcessor.class); - BulkProcessor.Builder bldr = mock(BulkProcessor.Builder.class); - BulkProcessor bProcessor = mock(BulkProcessor.class); - when(BulkProcessor.builder(Mockito.any(Client.class), Mockito.any(Listener.class))) - .thenReturn(bldr); - when(bldr.setBulkActions(Mockito.anyInt())).thenReturn(bldr); - when(bldr.setConcurrentRequests(Mockito.anyInt())).thenReturn(bldr); - when(bldr.build()).thenReturn(bProcessor); - when(bProcessor.add(Mockito.any(IndexRequest.class))).thenReturn(bProcessor); - } -} diff --git a/sunbird-es-utils/src/test/java/org/sunbird/common/factory/EsClientFactoryTest.java b/sunbird-es-utils/src/test/java/org/sunbird/common/factory/EsClientFactoryTest.java deleted file mode 100644 index e20e53911..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/common/factory/EsClientFactoryTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sunbird.common.factory; - -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.ElasticSearchRestHighImpl; -import org.sunbird.common.ElasticSearchTcpImpl; -import org.sunbird.common.inf.ElasticSearchService; - -public class EsClientFactoryTest { - - @Test - public void testGetTcpClient() { - ElasticSearchService service = EsClientFactory.getInstance("tcp"); - Assert.assertTrue(service instanceof ElasticSearchTcpImpl); - } - @Test - public void testGetRestClient() { - ElasticSearchService service = EsClientFactory.getInstance("rest"); - Assert.assertTrue(service instanceof ElasticSearchRestHighImpl); - } - @Test - public void testInstanceNull() { - ElasticSearchService service = EsClientFactory.getInstance("test"); - Assert.assertNull(service); - } -} diff --git a/sunbird-es-utils/src/test/java/org/sunbird/helper/ConnectionManagerTest.java b/sunbird-es-utils/src/test/java/org/sunbird/helper/ConnectionManagerTest.java deleted file mode 100644 index 94cfc1aff..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/helper/ConnectionManagerTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.sunbird.helper; - -import org.elasticsearch.action.bulk.BulkProcessor; -import org.elasticsearch.action.get.GetRequestBuilder; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.RestHighLevelClient; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.util.concurrent.FutureUtils; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.Aggregations; -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.models.util.HttpUtil; - -/** - * - * @author manzarul - * - */ -@Ignore -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -@PrepareForTest({ - ConnectionManager.class, - TransportClient.class, - AcknowledgedResponse.class, - GetRequestBuilder.class, - HttpUtil.class, - BulkProcessor.class, - FutureUtils.class, - SearchHit.class, - SearchHits.class, - Aggregations.class -}) -public class ConnectionManagerTest { - - @Test - public void testInitialiseConnection() { - TransportClient client = ConnectionManager.getClient(); - Assert.assertNotNull(client); - } - - @Test - public void testGetRestClientNull() { - RestHighLevelClient client = ConnectionManager.getRestClient(); - Assert.assertNull(client); - } - - @Test - @Ignore - public void testInitialiseConnectionFromPropertiesFile() { - boolean response = ConnectionManager.initialiseConnectionFromPropertiesFile("test", "localhost", "9200"); - Assert.assertTrue(response); - } - - @Test - public void testInitialiseConnectionFromPropertiesFileFailWithEmpty() { - boolean response = ConnectionManager.initialiseConnectionFromPropertiesFile("test", "localhost", ""); - Assert.assertFalse(response); - } - - @Test - public void testInitialiseConnectionFromPropertiesFileFailWithNull() { - boolean response = ConnectionManager.initialiseConnectionFromPropertiesFile("test", "localhost", null); - Assert.assertFalse(response); - } - - @Test - public void testCloseConnection () { - ConnectionManager.closeClient(); - Assert.assertTrue(true); - } - - -} diff --git a/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchMappingTest.java b/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchMappingTest.java deleted file mode 100644 index 6dc64a80c..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchMappingTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sunbird.helper; - -import org.junit.Assert; -import org.junit.Test; - -public class ElasticSearchMappingTest { - - @Test - public void testcreateMapping() { - String mapping = ElasticSearchMapping.createMapping(); - Assert.assertNotNull(mapping); - } - -} diff --git a/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchSettingsTest.java b/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchSettingsTest.java deleted file mode 100644 index f9d9fe886..000000000 --- a/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchSettingsTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sunbird.helper; - -import org.junit.Assert; -import org.junit.Test; - -public class ElasticSearchSettingsTest { - - @Test - public void testcreateSettingsForIndex() { - - String settings = ElasticSearchSettings.createSettingsForIndex(); - Assert.assertNotNull(settings); - } - -} diff --git a/sunbird-es-utils/src/test/resources/elasticsearch.config.properties b/sunbird-es-utils/src/test/resources/elasticsearch.config.properties deleted file mode 100644 index 84aafa4dd..000000000 --- a/sunbird-es-utils/src/test/resources/elasticsearch.config.properties +++ /dev/null @@ -1,3 +0,0 @@ -es.cluster.name=test -es.host.name=localhost -es.host.port=9300 \ No newline at end of file diff --git a/sunbird-platform-core/actor-core/.gitignore b/sunbird-platform-core/actor-core/.gitignore deleted file mode 100644 index 918338544..000000000 --- a/sunbird-platform-core/actor-core/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/target/ -/.classpath -/.project -/.settings -/logs -/bin/ diff --git a/sunbird-platform-core/actor-core/pom.xml b/sunbird-platform-core/actor-core/pom.xml deleted file mode 100644 index ee63ae488..000000000 --- a/sunbird-platform-core/actor-core/pom.xml +++ /dev/null @@ -1,139 +0,0 @@ - - 4.0.0 - - org.sunbird - actor-core - 1.0-SNAPSHOT - actor-core - - 2.3.1 - 1.8 - 1.8 - UTF-8 - UTF-8 - 1.1.1 - 1.6.1 - 1.0.7 - 2.5.19 - - - - org.sunbird - common-util - 0.0.1-SNAPSHOT - - - com.typesafe.akka - akka-actor_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-slf4j_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-remote_2.11 - ${learner.akka.version} - - - org.reflections - reflections - 0.9.10 - - - log4j - log4j - 1.2.17 - - - com.fasterxml.jackson.core - jackson-core - 2.10.1 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.1 - - - - - com.google.guava - guava - 18.0 - - - io.netty - netty-codec - 4.1.11.Final - - - - io.netty - netty-transport - 4.1.11.Final - - - - io.netty - netty-buffer - 4.1.11.Final - - - - - ${basedir}/src/main/java - ${basedir}/src/test/java - - - org.jacoco - jacoco-maven-plugin - 0.8.4 - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - package - - report - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - - - **/*Spec.java - **/*Test.java - - - - - - diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseActor.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseActor.java deleted file mode 100644 index f6001fcd3..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseActor.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.sunbird.actor.core; - -import akka.actor.ActorRef; -import akka.actor.ActorSelection; -import akka.actor.UntypedAbstractActor; -import akka.util.Timeout; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; -import com.typesafe.config.ConfigValue; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.TimeUnit; -import org.sunbird.actor.router.BackgroundRequestRouter; -import org.sunbird.actor.router.RequestRouter; -import org.sunbird.actor.service.BaseMWService; -import org.sunbird.actor.service.SunbirdMWService; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.response.ResponseParams; -import org.sunbird.common.models.response.ResponseParams.StatusType; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.StringFormatter; -import org.sunbird.common.request.ExecutionContext; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import scala.concurrent.duration.Duration; - -public abstract class BaseActor extends UntypedAbstractActor { - - public abstract void onReceive(Request request) throws Throwable; - - private static final String eventSyncConfFile = "eventSync.conf"; - private static final String EVENT_SYNC = "eventSync"; - private static final String DEFAULT = "default"; - public static final int AKKA_WAIT_TIME = 30; - public static Timeout timeout = new Timeout(AKKA_WAIT_TIME, TimeUnit.SECONDS); - private static Config config = ConfigFactory.parseResources(eventSyncConfFile); - private static Map eventSyncProperties = new HashMap<>(); - - @Override - public void onReceive(Object message) throws Throwable { - if (message instanceof Request) { - Request request = (Request) message; - String operation = request.getOperation(); - ProjectLogger.log("BaseActor: onReceive called for operation: " + operation, LoggerEnum.INFO); - try { - onReceive(request); - } catch (Exception e) { - ProjectLogger.log("BaseActor: FAILED onReceive called for operation: " + operation, LoggerEnum.INFO); - onReceiveException(operation, e); - } - } else { - // Do nothing ! - } - } - - public void tellToAnother(Request request) { - request - .getContext() - .put(JsonKey.TELEMETRY_CONTEXT, ExecutionContext.getCurrent().getRequestContext()); - SunbirdMWService.tellToBGRouter(request, self()); - } - - public void unSupportedMessage() throws Exception { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - sender().tell(exception, self()); - } - - public void onReceiveUnsupportedOperation(String callerName) throws Exception { - ProjectLogger.log(callerName + ": unsupported message"); - unSupportedMessage(); - } - - public void onReceiveUnsupportedMessage(String callerName) { - ProjectLogger.log(callerName + ": unsupported operation"); - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.invalidOperationName.getErrorCode(), - ResponseCode.invalidOperationName.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - sender().tell(exception, self()); - } - - protected void onReceiveException(String callerName, Exception exception) throws Exception { - ProjectLogger.log( - "Exception in message processing for: " - + callerName - + " :: message: " - + exception.getMessage(), - exception); - sender().tell(exception, self()); - } - - protected Response getErrorResponse(Exception e) { - Response response = new Response(); - ResponseParams resStatus = new ResponseParams(); - String message = e.getMessage(); - resStatus.setErrmsg(message); - resStatus.setStatus(StatusType.FAILED.name()); - if (e instanceof ProjectCommonException) { - ProjectCommonException me = (ProjectCommonException) e; - resStatus.setErr(me.getCode()); - response.setResponseCode(ResponseCode.SERVER_ERROR); - } else { - resStatus.setErr(e.getMessage()); - response.setResponseCode(ResponseCode.SERVER_ERROR); - } - response.setParams(resStatus); - return response; - } - - protected ActorRef getActorRef(String operation) { - int waitTime = 10; - ActorSelection select = null; - ActorRef actor = RequestRouter.getActor(operation); - if (null != actor) { - return actor; - } else { - select = - (BaseMWService.getRemoteRouter(RequestRouter.class.getSimpleName()) == null - ? (BaseMWService.getRemoteRouter(BackgroundRequestRouter.class.getSimpleName())) - : BaseMWService.getRemoteRouter(RequestRouter.class.getSimpleName())); - CompletionStage futureActor = - select.resolveOneCS(Duration.create(waitTime, "seconds")); - try { - actor = futureActor.toCompletableFuture().get(); - } catch (Exception e) { - ProjectLogger.log( - "InterServiceCommunicationImpl : getResponse - unable to get actorref from actorselection " - + e.getMessage(), - e); - } - return actor; - } - } - - protected String getEventSyncSetting(String actor) { - if (eventSyncProperties.isEmpty()) { - initEventSyncProperties(); - } - - String key = StringFormatter.joinByDot(EVENT_SYNC, actor); - if (eventSyncProperties.containsKey(key)) { - return eventSyncProperties.get(key); - } - - key = StringFormatter.joinByDot(EVENT_SYNC, DEFAULT); - return eventSyncProperties.get(key); - } - - private void initEventSyncProperties() { - Set> confs = config.entrySet(); - for (Entry conf : confs) { - eventSyncProperties.put(conf.getKey(), conf.getValue().unwrapped().toString()); - } - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseRouter.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseRouter.java deleted file mode 100644 index 85b4ada43..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/BaseRouter.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.sunbird.actor.core; - -import akka.actor.ActorRef; -import akka.actor.Props; -import akka.routing.FromConfig; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.reflections.Reflections; -import org.sunbird.actor.router.ActorConfig; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Mahesh Kumar Gangula */ -public abstract class BaseRouter extends BaseActor { - - public abstract String getRouterMode(); - - public abstract void route(Request request) throws Throwable; - - protected abstract void cacheActor(String key, ActorRef actor); - - @Override - public void onReceive(Request request) throws Throwable { - String senderPath = sender().path().toString(); - if (RouterMode.LOCAL.name().equalsIgnoreCase(getRouterMode()) - && !StringUtils.startsWith(senderPath, "akka://")) { - throw new RouterException( - "Invalid invocation of the router. Processing not possible from: " + senderPath); - } - route(request); - } - - private Set> getActors() { - synchronized (BaseRouter.class) { - Reflections reflections = new Reflections("org.sunbird"); - Set> actors = reflections.getSubTypesOf(BaseActor.class); - return actors; - } - } - - protected void initActors(ActorContext context, String name) { - Set> actors = getActors(); - for (Class actor : actors) { - ActorConfig routerDetails = actor.getAnnotation(ActorConfig.class); - if (null != routerDetails) { - String dispatcher = routerDetails.dispatcher(); - switch (name) { - case "BackgroundRequestRouter": - String[] bgOperations = routerDetails.asyncTasks(); - dispatcher = (StringUtils.isNotBlank(dispatcher)) ? dispatcher : "brr-usr-dispatcher"; - createActor(context, actor, bgOperations, dispatcher); - break; - case "RequestRouter": - String[] operations = routerDetails.tasks(); - dispatcher = (StringUtils.isNotBlank(dispatcher)) ? dispatcher : "rr-usr-dispatcher"; - createActor(context, actor, operations, dispatcher); - break; - default: - System.out.println("Router with name '" + name + "' not supported."); - break; - } - } else { - // System.out.println(actor.getSimpleName() + " don't have config."); - } - } - } - - private void createActor( - ActorContext context, - Class actor, - String[] operations, - String dispatcher) { - if (null != operations && operations.length > 0) { - Props props = null; - if (StringUtils.isNotBlank(dispatcher)) { - props = Props.create(actor).withDispatcher(dispatcher); - } else { - props = Props.create(actor); - } - ActorRef actorRef = - context.actorOf(FromConfig.getInstance().props(props), actor.getSimpleName()); - for (String operation : operations) { - String parentName = self().path().name(); - cacheActor(getKey(parentName, operation), actorRef); - } - } - } - - protected static String getKey(String name, String operation) { - return name + ":" + operation; - } - - protected static String getPropertyValue(String key) { - String mode = System.getenv(key); - if (StringUtils.isBlank(mode)) { - mode = PropertiesCache.getInstance().getProperty(key); - } - return mode; - } - - @Override - public void unSupportedMessage() { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - sender().tell(exception, ActorRef.noSender()); - } - - @Override - public void onReceiveException(String callerName, Exception e) { - ProjectLogger.log(callerName + ": exception in message processing = " + e.getMessage(), e); - sender().tell(e, ActorRef.noSender()); - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterException.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterException.java deleted file mode 100644 index 8faa212ea..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.sunbird.actor.core; - -/** @author Mahesh Kumar Gangula */ -public class RouterException extends RuntimeException { - - /** */ - private static final long serialVersionUID = 7669891026222754334L; - - public RouterException(String message) { - super(message); - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterMode.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterMode.java deleted file mode 100644 index a4e56629c..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterMode.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.sunbird.actor.core; - -/** @author Mahesh Kumar Gangula */ -public enum RouterMode { - OFF, - LOCAL, - REMOTE; -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/ActorConfig.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/ActorConfig.java deleted file mode 100644 index b28de705f..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/ActorConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sunbird.actor.router; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** @author Mahesh Kumar Gangula */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -public @interface ActorConfig { - String[] tasks(); - - String[] asyncTasks(); - - String dispatcher() default ""; -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/BackgroundRequestRouter.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/BackgroundRequestRouter.java deleted file mode 100644 index 7d9a4b755..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/BackgroundRequestRouter.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.sunbird.actor.router; - -import akka.actor.ActorRef; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.actor.core.BaseRouter; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.Request; - -/** @author Mahesh Kumar Gangula */ -public class BackgroundRequestRouter extends BaseRouter { - - private static String mode; - private static String name; - private static Map routingMap = new HashMap<>(); - - public BackgroundRequestRouter() { - getMode(); - } - - @Override - public void preStart() throws Exception { - super.preStart(); - name = self().path().name(); - initActors(getContext(), BackgroundRequestRouter.class.getSimpleName()); - } - - @Override - protected void cacheActor(String key, ActorRef actor) { - routingMap.put(key, actor); - } - - @Override - public void route(Request request) throws Throwable { - org.sunbird.common.request.ExecutionContext.setRequestId(request.getRequestId()); - String operation = request.getOperation(); - ActorRef ref = routingMap.get(getKey(self().path().name(), operation)); - if (null != ref) { - ref.tell(request, self()); - } else { - onReceiveUnsupportedOperation(request.getOperation()); - } - } - - public String getRouterMode() { - return getMode(); - } - - public static String getMode() { - if (StringUtils.isBlank(mode)) { - mode = getPropertyValue(JsonKey.BACKGROUND_ACTOR_PROVIDER); - } - return mode; - } - - public static ActorRef getActor(String operation) { - return routingMap.get(getKey(name, operation)); - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/RequestRouter.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/RequestRouter.java deleted file mode 100644 index 8c1e084e8..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/RequestRouter.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.sunbird.actor.router; - -import akka.actor.ActorRef; -import akka.dispatch.OnComplete; -import akka.pattern.Patterns; -import akka.util.Timeout; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.actor.core.BaseRouter; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import scala.concurrent.ExecutionContext; -import scala.concurrent.Future; -import scala.concurrent.duration.Duration; - -/** @author Mahesh Kumar Gangula */ -public class RequestRouter extends BaseRouter { - - private static String mode; - private static String name; - public static Map routingMap = new HashMap<>(); - - public RequestRouter() { - getMode(); - } - - @Override - public void preStart() throws Exception { - super.preStart(); - name = self().path().name(); - initActors(getContext(), RequestRouter.class.getSimpleName()); - } - - @Override - protected void cacheActor(String key, ActorRef actor) { - routingMap.put(key, actor); - } - - @Override - public void route(Request request) throws Throwable { - org.sunbird.common.request.ExecutionContext.setRequestId(request.getRequestId()); - String operation = request.getOperation(); - ActorRef ref = routingMap.get(getKey(self().path().name(), operation)); - if (null != ref) { - route(ref, request, getContext().dispatcher()); - } else { - onReceiveUnsupportedOperation(request.getOperation()); - } - } - - public static ActorRef getActor(String operation) { - return routingMap.get(getKey(name, operation)); - } - - public String getRouterMode() { - return getMode(); - } - - public static String getMode() { - if (StringUtils.isBlank(mode)) { - mode = getPropertyValue(JsonKey.API_ACTOR_PROVIDER); - } - return mode; - } - - /** - * method will route the message to corresponding router pass into the argument . - * - * @param router - * @param message - * @return boolean - */ - private boolean route(ActorRef router, Request message, ExecutionContext ec) { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "Actor Service Call start for api ==" - + message.getOperation() - + " start time " - + startTime, - LoggerEnum.PERF_LOG); - Timeout timeout = new Timeout(Duration.create(message.getTimeout(), TimeUnit.SECONDS)); - Future future = Patterns.ask(router, message, timeout); - ActorRef parent = sender(); - future.onComplete( - new OnComplete() { - @Override - public void onComplete(Throwable failure, Object result) { - if (failure != null) { - // We got a failure, handle it here - ProjectLogger.log(failure.getMessage(), failure); - if (failure instanceof ProjectCommonException) { - parent.tell(failure, self()); - } else if (failure instanceof akka.pattern.AskTimeoutException) { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.operationTimeout.getErrorCode(), - ResponseCode.operationTimeout.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - parent.tell(exception, self()); - - } else { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.internalError.getErrorCode(), - ResponseCode.internalError.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - parent.tell(exception, self()); - } - } else { - parent.tell(result, self()); - } - } - }, - ec); - return true; - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/BaseMWService.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/BaseMWService.java deleted file mode 100644 index 3763c922d..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/BaseMWService.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.sunbird.actor.service; - -import akka.actor.ActorRef; -import akka.actor.ActorSelection; -import akka.actor.ActorSystem; -import akka.actor.Props; -import akka.routing.FromConfig; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.actor.core.RouterMode; -import org.sunbird.actor.router.BackgroundRequestRouter; -import org.sunbird.actor.router.RequestRouter; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; - -/** @author Mahesh Kumar Gangula */ -public class BaseMWService { - - public static Config config = - ConfigFactory.systemEnvironment().withFallback(ConfigFactory.load()); - private static String actorMode; - protected static ActorSystem system; - protected static String name = "SunbirdMWSystem"; - protected static ActorRef requestRouter; - protected static ActorRef bgRequestRouter; - - protected static String getMode() { - if (StringUtils.isBlank(actorMode)) { - List routers = - Arrays.asList(RequestRouter.getMode(), BackgroundRequestRouter.getMode()); - long localCount = - routers.stream().filter(mode -> StringUtils.equalsIgnoreCase(mode, "local")).count(); - actorMode = (routers.size() == localCount) ? "local" : "remote"; - } - return actorMode; - } - - public static Object getRequestRouter() { - if (null != requestRouter) return requestRouter; - else { - return getRemoteRouter(RequestRouter.class.getSimpleName()); - } - } - - public static Object getBackgroundRequestRouter() { - if (null != bgRequestRouter) return bgRequestRouter; - else { - return getRemoteRouter(BackgroundRequestRouter.class.getSimpleName()); - } - } - - public static ActorSelection getRemoteRouter(String router) { - String path = null; - if (BackgroundRequestRouter.class.getSimpleName().equals(router)) { - path = config.getString("sunbird_remote_bg_req_router_path"); - return system.actorSelection(path); - } else if (RequestRouter.class.getSimpleName().equals(router)) { - path = config.getString("sunbird_remote_req_router_path"); - return system.actorSelection(path); - } else { - return null; - } - } - - protected static ActorSystem getActorSystem(String host, String port) { - if (null == system) { - Config conf; - if ("remote".equals(getMode())) { - Config remote = getRemoteConfig(host, port); - conf = remote.withFallback(config.getConfig(name)); - } else { - conf = config.getConfig(name); - } - ProjectLogger.log("ActorSystem starting with mode: " + getMode(), LoggerEnum.INFO.name()); - system = ActorSystem.create(name, conf); - } - return system; - } - - protected static Config getRemoteConfig(String host, String port) { - List details = new ArrayList(); - details.add("akka.actor.provider=akka.remote.RemoteActorRefProvider"); - details.add("akka.remote.enabled-transports = [\"akka.remote.netty.tcp\"]"); - if (StringUtils.isNotBlank(host)) details.add("akka.remote.netty.tcp.hostname=" + host); - if (StringUtils.isNotBlank(port)) details.add("akka.remote.netty.tcp.port=" + port); - - return ConfigFactory.parseString(StringUtils.join(details, ",")); - } - - protected static void initRouters() { - ProjectLogger.log("RequestRouter mode: " + RequestRouter.getMode(), LoggerEnum.INFO.name()); - if (!RouterMode.OFF.name().equalsIgnoreCase(RequestRouter.getMode())) { - requestRouter = - system.actorOf( - FromConfig.getInstance() - .props(Props.create(RequestRouter.class).withDispatcher("rr-dispatcher")), - RequestRouter.class.getSimpleName()); - } - ProjectLogger.log( - "BackgroundRequestRouter mode: " + BackgroundRequestRouter.getMode(), - LoggerEnum.INFO.name()); - if (!RouterMode.OFF.name().equalsIgnoreCase(BackgroundRequestRouter.getMode())) { - bgRequestRouter = - system.actorOf( - FromConfig.getInstance() - .props( - Props.create(BackgroundRequestRouter.class).withDispatcher("brr-dispatcher")), - BackgroundRequestRouter.class.getSimpleName()); - } - } -} diff --git a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/SunbirdMWService.java b/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/SunbirdMWService.java deleted file mode 100644 index 04af0b6b1..000000000 --- a/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/SunbirdMWService.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.sunbird.actor.service; - -import akka.actor.ActorRef; -import akka.actor.ActorSelection; -import org.sunbird.actor.router.BackgroundRequestRouter; -import org.sunbird.actor.router.RequestRouter; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.Request; - -/** @author Mahesh Kumar Gangula */ -public class SunbirdMWService extends BaseMWService { - - public static void init() { - String host = System.getenv(JsonKey.MW_SYSTEM_HOST); - String port = System.getenv(JsonKey.MW_SYSTEM_PORT); - getActorSystem(host, port); - initRouters(); - } - - public static void tellToRequestRouter(Request request, ActorRef sender) { - String operation = request.getOperation(); - ActorRef actor = RequestRouter.getActor(operation); - if (null == actor) { - ActorSelection select = getRemoteRouter(RequestRouter.class.getSimpleName()); - select.tell(request, sender); - } else { - actor.tell(request, sender); - } - } - - public static void tellToBGRouter(Request request, ActorRef sender) { - String operation = request.getOperation(); - ActorRef actor = BackgroundRequestRouter.getActor(operation); - if (null == actor) { - ActorSelection select = getRemoteRouter(BackgroundRequestRouter.class.getSimpleName()); - select.tell(request, sender); - } else { - actor.tell(request, sender); - } - } -} diff --git a/sunbird-platform-core/actor-util/.gitignore b/sunbird-platform-core/actor-util/.gitignore deleted file mode 100644 index 55977f8f9..000000000 --- a/sunbird-platform-core/actor-util/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/target/ -.classpath -.project -.settings -/bin/ - -*.iml diff --git a/sunbird-platform-core/actor-util/pom.xml b/sunbird-platform-core/actor-util/pom.xml deleted file mode 100644 index a5be7a916..000000000 --- a/sunbird-platform-core/actor-util/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - 4.0.0 - - org.sunbird - actor-util - 0.0.1-SNAPSHOT - jar - - actor-util - http://maven.apache.org - - - UTF-8 - 2.5.19 - - - - - com.typesafe.akka - akka-actor_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-slf4j_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-remote_2.11 - ${learner.akka.version} - - - - org.scala-lang - scala-library - 2.11.11 - - - - com.fasterxml.jackson.core - jackson-core - 2.10.1 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.1 - - - org.apache.commons - commons-lang3 - 3.0 - - - org.sunbird - common-util - 0.0.1-SNAPSHOT - - - junit - junit - 3.8.1 - test - - - org.sunbird - sunbird-es-utils - 1.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - - diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunication.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunication.java deleted file mode 100644 index d62c171c9..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunication.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.sunbird.actorutil; - -import akka.actor.ActorRef; -import org.sunbird.common.request.Request; -import scala.concurrent.Future; - -/** Interface for actor to actor communication. */ -public interface InterServiceCommunication { - - /** - * @param actorRef Actor reference - * @param request Request object - * @return Response object - */ - public Object getResponse(ActorRef actorRef, Request request); - - /* - * @param actorRef Actor reference - * @param request Request object - * @return Future for given actor and request operation - */ - public Future getFuture(ActorRef actorRef, Request request); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunicationFactory.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunicationFactory.java deleted file mode 100644 index 88c4a9ae6..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/InterServiceCommunicationFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sunbird.actorutil; - -import org.sunbird.actorutil.impl.InterServiceCommunicationImpl; - -/** - * @Desc Factory class for InterServiceCommunication. - * - * @author Arvind - */ -public class InterServiceCommunicationFactory { - - private static InterServiceCommunication instance; - - private InterServiceCommunicationFactory() {} - - static { - instance = new InterServiceCommunicationImpl(); - } - - public static InterServiceCommunication getInstance() { - if (null == instance) { - instance = new InterServiceCommunicationImpl(); - } - return instance; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/CourseEnrollmentClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/CourseEnrollmentClient.java deleted file mode 100644 index 999418579..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/CourseEnrollmentClient.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sunbird.actorutil.courseenrollment; - -import akka.actor.ActorRef; -import java.util.Map; -import org.sunbird.common.models.response.Response; - -public interface CourseEnrollmentClient { - /** - * Unenroll user from course. - * - * @param actorRef Actor reference - * @param request Request containing unenroll information - * @return Response containing unenroll request status - */ - Response unenroll(ActorRef actorRef, Map request); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/impl/CourseEnrollmentClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/impl/CourseEnrollmentClientImpl.java deleted file mode 100644 index 237c0bf3d..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/courseenrollment/impl/CourseEnrollmentClientImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.sunbird.actorutil.courseenrollment.impl; - -import akka.actor.ActorRef; -import java.util.Map; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.courseenrollment.CourseEnrollmentClient; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.ActorOperations; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class CourseEnrollmentClientImpl implements CourseEnrollmentClient { - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - private static CourseEnrollmentClientImpl courseEnrollmentClient = null; - - public static CourseEnrollmentClientImpl getInstance() { - if (null == courseEnrollmentClient) { - courseEnrollmentClient = new CourseEnrollmentClientImpl(); - } - return courseEnrollmentClient; - } - - @Override - public Response unenroll(ActorRef actorRef, Map map) { - Request request = new Request(); - request.setOperation(ActorOperations.UNENROLL_COURSE.getValue()); - request.setRequest(map); - Object obj = interServiceCommunication.getResponse(actorRef, request); - if (obj instanceof Response) { - Response response = (Response) obj; - return response; - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceClient.java deleted file mode 100644 index 463f2abc4..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceClient.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sunbird.actorutil.email; - -import akka.actor.ActorRef; -import java.util.Map; -import org.sunbird.common.models.response.Response; - -public interface EmailServiceClient { - /** - * Send mail user from course. - * - * @param actorRef Actor reference - * @param request Request containing email realted information - * @return Response containing email send status - */ - Response sendMail(ActorRef actorRef, Map request); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceFactory.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceFactory.java deleted file mode 100644 index 5891f4b2d..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.sunbird.actorutil.email; - -import org.sunbird.actorutil.email.impl.EmailServiceClientImpl; - -public class EmailServiceFactory { - - private static EmailServiceClient instance; - - private EmailServiceFactory() {} - - static { - instance = new EmailServiceClientImpl(); - } - - public static EmailServiceClient getInstance() { - if (null == instance) { - instance = new EmailServiceClientImpl(); - } - return instance; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/impl/EmailServiceClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/impl/EmailServiceClientImpl.java deleted file mode 100644 index ea880fcca..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/impl/EmailServiceClientImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.sunbird.actorutil.email.impl; - -import akka.actor.ActorRef; -import java.util.HashMap; -import java.util.Map; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.email.EmailServiceClient; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class EmailServiceClientImpl implements EmailServiceClient { - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - - @Override - public Response sendMail(ActorRef actorRef, Map requestMap) { - Request actorRequest = new Request(); - Map request = new HashMap(); - request.put(JsonKey.EMAIL_REQUEST, requestMap); - actorRequest.setOperation((String) requestMap.get(JsonKey.REQUEST)); - actorRequest.setRequest(request); - - Object obj = interServiceCommunication.getResponse(actorRef, actorRequest); - if (obj instanceof Response) { - Response response = (Response) obj; - return response; - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/impl/InterServiceCommunicationImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/impl/InterServiceCommunicationImpl.java deleted file mode 100644 index 7cee8c132..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/impl/InterServiceCommunicationImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.sunbird.actorutil.impl; - -import akka.actor.ActorRef; -import akka.pattern.Patterns; -import akka.util.Timeout; -import java.util.concurrent.TimeUnit; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import scala.concurrent.Await; -import scala.concurrent.Future; -import scala.concurrent.duration.Duration; - -public class InterServiceCommunicationImpl implements InterServiceCommunication { - - private Timeout t = new Timeout(Duration.create(10, TimeUnit.SECONDS)); - - @Override - public Object getResponse(ActorRef actorRef, Request request) { - try { - return Await.result(getFuture(actorRef, request), t.duration()); - } catch (Exception e) { - ProjectLogger.log( - "InterServiceCommunicationImpl:getResponse: Exception occurred with error message = " - + e.getMessage(), - e); - ProjectCommonException.throwServerErrorException( - ResponseCode.unableToCommunicateWithActor, - ResponseCode.unableToCommunicateWithActor.getErrorMessage()); - } - return null; - } - - @Override - public Future getFuture(ActorRef actorRef, Request request) { - if (null == actorRef) { - ProjectLogger.log( - "InterServiceCommunicationImpl:getFuture: actorRef is null", LoggerEnum.INFO); - ProjectCommonException.throwServerErrorException( - ResponseCode.unableToCommunicateWithActor, - ResponseCode.unableToCommunicateWithActor.getErrorMessage()); - } - try { - return Patterns.ask(actorRef, request, t); - } catch (Exception e) { - ProjectLogger.log( - "InterServiceCommunicationImpl:getFuture: Exception occured with error message = " - + e.getMessage(), - e); - ProjectCommonException.throwServerErrorException( - ResponseCode.unableToCommunicateWithActor, - ResponseCode.unableToCommunicateWithActor.getErrorMessage()); - } - return null; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/LocationClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/LocationClient.java deleted file mode 100644 index 4eb3189b7..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/LocationClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.sunbird.actorutil.location; - -import akka.actor.ActorRef; -import java.util.List; -import org.sunbird.models.location.Location; -import org.sunbird.models.location.apirequest.UpsertLocationRequest; - -/** - * This interface defines methods supported by Location service. - * - * @author Amit Kumar - */ -public interface LocationClient { - - /** - * @desc This method will fetch location details by list of code. - * @param actorRef Actor reference. - * @param codeList List of location code. - * @return List of location. - */ - List getLocationsByCodes(ActorRef actorRef, List codeList); - - public List getLocationByIds(ActorRef actorRef, List idsList); - /** - * @desc This method will fetch location details by id. - * @param actorRef Actor reference. - * @param id Location id. - * @return Location details. - */ - Location getLocationById(ActorRef actorRef, String id); - - /** - * @desc This method will fetch location details by code. - * @param actorRef Actor reference. - * @param locationCode location code. - * @return Location details. - */ - Location getLocationByCode(ActorRef actorRef, String locationCode); - - /** - * @desc This method will create Location and returns the response. - * @param actorRef Actor reference. - * @param location Location details. - * @return Location id. - */ - String createLocation(ActorRef actorRef, UpsertLocationRequest location); - - /** - * @desc This method will update location details. - * @param actorRef Actor reference. - * @param location Location details. - */ - void updateLocation(ActorRef actorRef, UpsertLocationRequest location); - - /** - * @desc For given location codes, fetch location IDs (including, if any, those of its parent or - * ancestor(s) locations). - * @param actorRef Actor reference. - * @param codes List of location codes. - * @return List of related location IDs - */ - List getRelatedLocationIds(ActorRef actorRef, List codes); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/impl/LocationClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/impl/LocationClientImpl.java deleted file mode 100644 index d0653101f..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/location/impl/LocationClientImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.sunbird.actorutil.location.impl; - -import akka.actor.ActorRef; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.location.LocationClient; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.GeoLocationJsonKey; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LocationActorOperation; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.models.location.Location; -import org.sunbird.models.location.apirequest.UpsertLocationRequest; - -public class LocationClientImpl implements LocationClient { - - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - private ObjectMapper mapper = new ObjectMapper(); - - @Override - public List getLocationsByCodes(ActorRef actorRef, List codeList) { - return getSearchResponse(actorRef, GeoLocationJsonKey.CODE, codeList); - } - - @Override - public List getLocationByIds(ActorRef actorRef, List idsList) { - return getSearchResponse(actorRef, GeoLocationJsonKey.ID, idsList); - } - - @Override - public Location getLocationById(ActorRef actorRef, String id) { - List locationList = getSearchResponse(actorRef, JsonKey.ID, id); - if (CollectionUtils.isNotEmpty(locationList)) { - return locationList.get(0); - } else { - return null; - } - } - - private List getSearchResponse(ActorRef actorRef, String param, Object value) { - List response = null; - Map filters = new HashMap<>(); - Map searchRequestMap = new HashMap<>(); - filters.put(param, value); - searchRequestMap.put(JsonKey.FILTERS, filters); - Request request = new Request(); - request.setOperation(LocationActorOperation.SEARCH_LOCATION.getValue()); - request.getRequest().putAll(searchRequestMap); - ProjectLogger.log("LocationClientImpl : callSearchLocation ", LoggerEnum.INFO); - Object obj = interServiceCommunication.getResponse(actorRef, request); - if (obj instanceof Response) { - Response responseObj = (Response) obj; - List> responseList = - (List>) responseObj.getResult().get(JsonKey.RESPONSE); - return responseList - .stream() - .map(s -> mapper.convertValue(s, Location.class)) - .collect(Collectors.toList()); - } else { - response = new ArrayList<>(); - } - return response; - } - - @Override - public Location getLocationByCode(ActorRef actorRef, String locationCode) { - String param = GeoLocationJsonKey.CODE; - Object value = locationCode; - List locationList = getSearchResponse(actorRef, param, value); - if (CollectionUtils.isNotEmpty(locationList)) { - return locationList.get(0); - } else { - return null; - } - } - - @Override - public String createLocation(ActorRef actorRef, UpsertLocationRequest location) { - Request request = new Request(); - String locationId = null; - request.getRequest().putAll(mapper.convertValue(location, Map.class)); - Map resLocation = new HashMap<>(); - request.setOperation(LocationActorOperation.CREATE_LOCATION.getValue()); - ProjectLogger.log("LocationClientImpl : callCreateLocation ", LoggerEnum.INFO); - Object obj = interServiceCommunication.getResponse(actorRef, request); - checkLocationResponseForException(obj); - if (obj instanceof Response) { - Response response = (Response) obj; - locationId = (String) response.get(JsonKey.ID); - } - return locationId; - } - - @Override - public void updateLocation(ActorRef actorRef, UpsertLocationRequest location) { - Request request = new Request(); - request.getRequest().putAll(mapper.convertValue(location, Map.class)); - request.setOperation(LocationActorOperation.UPDATE_LOCATION.getValue()); - ProjectLogger.log("LocationClientImpl : callUpdateLocation ", LoggerEnum.INFO); - Object obj = interServiceCommunication.getResponse(actorRef, request); - checkLocationResponseForException(obj); - } - - @Override - public List getRelatedLocationIds(ActorRef actorRef, List codes) { - Map requestMap = new HashMap<>(); - requestMap.put(JsonKey.LOCATION_CODES, codes); - - Request request = new Request(); - request.setOperation(LocationActorOperation.GET_RELATED_LOCATION_IDS.getValue()); - request.getRequest().putAll(requestMap); - - ProjectLogger.log("LocationClientImpl: getRelatedLocationIds called", LoggerEnum.INFO); - Object obj = interServiceCommunication.getResponse(actorRef, request); - checkLocationResponseForException(obj); - - if (obj instanceof Response) { - Response responseObj = (Response) obj; - List responseList = (List) responseObj.getResult().get(JsonKey.RESPONSE); - return responseList; - } - - return new ArrayList<>(); - } - - private void checkLocationResponseForException(Object obj) { - if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else if (obj instanceof Exception) { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/OrganisationClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/OrganisationClient.java deleted file mode 100644 index bbc9cdd0f..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/OrganisationClient.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.sunbird.actorutil.org; - -import akka.actor.ActorRef; -import java.util.List; -import java.util.Map; -import org.sunbird.models.organisation.Organisation; - -public interface OrganisationClient { - - /** - * Create organisation. - * - * @param actorRef Actor reference - * @param orgMap Organisation details - * @return Organisation ID - */ - String createOrg(ActorRef actorRef, Map orgMap); - - /** - * Update organisation details. - * - * @param actorRef Actor reference - * @param orgMap Organisation details - */ - void updateOrg(ActorRef actorRef, Map orgMap); - - /** - * Get details of organisation for given ID. - * - * @param actorRef Actor reference - * @param orgId Organisation ID - * @return Organisation details - */ - Organisation getOrgById(ActorRef actorRef, String orgId); - - /** - * Get details of organisation for given external ID and provider. - * - * @param externalId External ID - * @param provider provider - * @return Organisation details - */ - Organisation esGetOrgByExternalId(String externalId, String provider); - - /** - * Get details of organisation for given ID. - * - * @param orgId Organisation ID - * @return Organisation details - */ - Organisation esGetOrgById(String orgId); - - /** - * Search organisations using specified filter. - * - * @param filter Filter criteria for organisation search - * @return List of organisations - */ - List esSearchOrgByFilter(Map filter); - - /** - * Search organisations by IDs. - * - * @param orgIds List of org IDs - * @param outputColumns List of attributes required in each organisation search result - * @return List of organisations found - */ - List esSearchOrgByIds(List orgIds, List outputColumns); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/impl/OrganisationClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/impl/OrganisationClientImpl.java deleted file mode 100644 index 3ce76f451..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/org/impl/OrganisationClientImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.sunbird.actorutil.org.impl; - -import akka.actor.ActorRef; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.org.OrganisationClient; -import org.sunbird.common.ElasticSearchHelper; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.factory.EsClientFactory; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.ActorOperations; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import org.sunbird.models.organisation.Organisation; -import scala.concurrent.Future; - -public class OrganisationClientImpl implements OrganisationClient { - - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - ObjectMapper objectMapper = new ObjectMapper(); - private ElasticSearchService esUtil = EsClientFactory.getInstance(JsonKey.REST); - - @Override - public String createOrg(ActorRef actorRef, Map orgMap) { - ProjectLogger.log("OrganisationClientImpl: createOrg called", LoggerEnum.INFO); - return upsertOrg(actorRef, orgMap, ActorOperations.CREATE_ORG.getValue()); - } - - @Override - public void updateOrg(ActorRef actorRef, Map orgMap) { - ProjectLogger.log("OrganisationClientImpl: updateOrg called", LoggerEnum.INFO); - upsertOrg(actorRef, orgMap, ActorOperations.UPDATE_ORG.getValue()); - } - - private String upsertOrg(ActorRef actorRef, Map orgMap, String operation) { - String orgId = null; - - Request request = new Request(); - request.setRequest(orgMap); - request.setOperation(operation); - request.getContext().put(JsonKey.CALLER_ID, JsonKey.BULK_ORG_UPLOAD); - Object obj = interServiceCommunication.getResponse(actorRef, request); - - if (obj instanceof Response) { - Response response = (Response) obj; - orgId = (String) response.get(JsonKey.ORGANISATION_ID); - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else if (obj instanceof Exception) { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - return orgId; - } - - @Override - public Organisation getOrgById(ActorRef actorRef, String orgId) { - ProjectLogger.log("OrganisationClientImpl: getOrgById called", LoggerEnum.INFO); - Organisation organisation = null; - - Request request = new Request(); - Map requestMap = new HashMap<>(); - requestMap.put(JsonKey.ORGANISATION_ID, orgId); - request.setRequest(requestMap); - request.setOperation(ActorOperations.GET_ORG_DETAILS.getValue()); - - Object obj = interServiceCommunication.getResponse(actorRef, request); - - if (obj instanceof Response) { - ObjectMapper objectMapper = new ObjectMapper(); - Response response = (Response) obj; - - // Convert contact details (received from ES) format from map to - // JSON string (as in Cassandra contact details are stored as text) - Map map = (Map) response.get(JsonKey.RESPONSE); - map.put(JsonKey.CONTACT_DETAILS, String.valueOf(map.get(JsonKey.CONTACT_DETAILS))); - organisation = objectMapper.convertValue(map, Organisation.class); - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else if (obj instanceof Exception) { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - return organisation; - } - - @Override - public Organisation esGetOrgByExternalId(String externalId, String provider) { - Organisation organisation = null; - Map map = null; - SearchDTO searchDto = new SearchDTO(); - Map filter = new HashMap<>(); - filter.put(JsonKey.EXTERNAL_ID, externalId); - filter.put(JsonKey.PROVIDER, provider); - searchDto.getAdditionalProperties().put(JsonKey.FILTERS, filter); - Future> esResponseF = - esUtil.search(searchDto, ProjectUtil.EsType.organisation.getTypeName()); - Map esResponse = - (Map) ElasticSearchHelper.getResponseFromFuture(esResponseF); - List> list = (List>) esResponse.get(JsonKey.CONTENT); - if (!list.isEmpty()) { - map = list.get(0); - map.put(JsonKey.CONTACT_DETAILS, String.valueOf(map.get(JsonKey.CONTACT_DETAILS))); - organisation = objectMapper.convertValue(map, Organisation.class); - } - return organisation; - } - - @Override - public Organisation esGetOrgById(String id) { - Map map = null; - Future> mapF = - esUtil.getDataByIdentifier(ProjectUtil.EsType.organisation.getTypeName(), id); - - map = (Map) ElasticSearchHelper.getResponseFromFuture(mapF); - if (MapUtils.isEmpty(map)) { - return null; - } else { - map.put(JsonKey.CONTACT_DETAILS, String.valueOf(map.get(JsonKey.CONTACT_DETAILS))); - return objectMapper.convertValue(map, Organisation.class); - } - } - - @Override - public List esSearchOrgByFilter(Map filter) { - SearchDTO searchDto = new SearchDTO(); - searchDto.getAdditionalProperties().put(JsonKey.FILTERS, filter); - return searchOrganisation(searchDto); - } - - @SuppressWarnings("unchecked") - private List searchOrganisation(SearchDTO searchDto) { - List orgList = new ArrayList<>(); - Future> resultF = - esUtil.search(searchDto, ProjectUtil.EsType.organisation.getTypeName()); - Map result = - (Map) ElasticSearchHelper.getResponseFromFuture(resultF); - - List> orgMapList = (List>) result.get(JsonKey.CONTENT); - if (CollectionUtils.isNotEmpty(orgMapList)) { - for (Map orgMap : orgMapList) { - orgMap.put(JsonKey.CONTACT_DETAILS, String.valueOf(orgMap.get(JsonKey.CONTACT_DETAILS))); - orgList.add(objectMapper.convertValue(orgMap, Organisation.class)); - } - return orgList; - } else { - return Collections.emptyList(); - } - } - - @Override - public List esSearchOrgByIds(List orgIds, List outputColumns) { - SearchDTO searchDTO = new SearchDTO(); - - searchDTO.setFields(outputColumns); - - Map filters = new HashMap<>(); - filters.put(JsonKey.ID, orgIds); - - searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters); - - return searchOrganisation(searchDTO); - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/SystemSettingClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/SystemSettingClient.java deleted file mode 100644 index 7e8f220f8..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/SystemSettingClient.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.sunbird.actorutil.systemsettings; - -import akka.actor.ActorRef; -import com.fasterxml.jackson.core.type.TypeReference; -import org.sunbird.models.systemsetting.SystemSetting; - -/** - * This interface defines methods supported by System Setting service. - * - * @author Amit Kumar - */ -public interface SystemSettingClient { - - /** - * Get system setting information for given field (setting) name. - * - * @param actorRef Actor reference - * @param field System setting field name - * @return System setting details - */ - SystemSetting getSystemSettingByField(ActorRef actorRef, String field); - - /** - * Get system setting information for given field (setting) and key name. - * - * @param actorRef Actor reference - * @param field System setting field name - * @param key Key (e.g. csv.mandatoryColumns) within system setting information - * @param typeReference Type reference for value corresponding to specified key - * @return System setting value corresponding to given field and key name - */ - T getSystemSettingByFieldAndKey( - ActorRef actorRef, String field, String key, TypeReference typeReference); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/impl/SystemSettingClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/impl/SystemSettingClientImpl.java deleted file mode 100644 index f29202d06..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/impl/SystemSettingClientImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.sunbird.actorutil.systemsettings.impl; - -import akka.actor.ActorRef; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.systemsettings.SystemSettingClient; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.ActorOperations; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.models.systemsetting.SystemSetting; - -public class SystemSettingClientImpl implements SystemSettingClient { - - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - private static SystemSettingClient systemSettingClient = null; - public static SystemSettingClient getInstance() { - if (null == systemSettingClient) { - systemSettingClient = new SystemSettingClientImpl(); - } - return systemSettingClient; - } - - @Override - public SystemSetting getSystemSettingByField(ActorRef actorRef, String field) { - ProjectLogger.log("SystemSettingClientImpl:getSystemSettingByField: field is " + field, LoggerEnum.INFO.name()); - SystemSetting systemSetting = getSystemSetting(actorRef, JsonKey.FIELD, field); - return systemSetting; - } - - @Override - public T getSystemSettingByFieldAndKey( - ActorRef actorRef, String field, String key, TypeReference typeReference) { - SystemSetting systemSetting = getSystemSettingByField(actorRef, field); - ObjectMapper objectMapper = new ObjectMapper(); - if (systemSetting != null) { - try { - Map valueMap = objectMapper.readValue(systemSetting.getValue(), Map.class); - String[] keys = key.split("\\."); - int numKeys = keys.length; - for (int i = 0; i < numKeys - 1; i++) { - valueMap = objectMapper.convertValue(valueMap.get(keys[i]), Map.class); - } - return (T)objectMapper.convertValue(valueMap.get(keys[numKeys - 1]), typeReference); - } catch (Exception e) { - ProjectLogger.log( - "SystemSettingClientImpl:getSystemSettingByFieldAndKey: Exception occurred with error message = " - + e.getMessage(), - LoggerEnum.ERROR.name()); - } - } - return null; - } - - private SystemSetting getSystemSetting(ActorRef actorRef, String param, Object value) { - ProjectLogger.log("SystemSettingClientImpl: getSystemSetting called", LoggerEnum.DEBUG); - Request request = new Request(); - Map map = new HashMap<>(); - map.put(param, value); - request.setContext(map); - request.setOperation(ActorOperations.GET_SYSTEM_SETTING.getValue()); - Object obj = interServiceCommunication.getResponse(actorRef, request); - - if (obj instanceof Response) { - Response responseObj = (Response) obj; - return (SystemSetting) responseObj.getResult().get(JsonKey.RESPONSE); - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/UserClient.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/UserClient.java deleted file mode 100644 index e842a3b67..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/UserClient.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.sunbird.actorutil.user; - -import akka.actor.ActorRef; -import java.util.Map; - -public interface UserClient { - - /** - * Create user. - * - * @param actorRef Actor reference - * @param userMap User details - * @return User ID - */ - String createUser(ActorRef actorRef, Map userMap); - - /** - * Update user details. - * - * @param actorRef Actor reference - * @param userMap User details - */ - void updateUser(ActorRef actorRef, Map userMap); - - /** Verify phone uniqueness across all users in the system. */ - void esVerifyPhoneUniqueness(); - - /** Verify email uniqueness across all users in the system. */ - void esVerifyEmailUniqueness(); -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/impl/UserClientImpl.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/impl/UserClientImpl.java deleted file mode 100644 index 726a91612..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/user/impl/UserClientImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.sunbird.actorutil.user.impl; - -import akka.actor.ActorRef; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.sunbird.actorutil.InterServiceCommunication; -import org.sunbird.actorutil.InterServiceCommunicationFactory; -import org.sunbird.actorutil.user.UserClient; -import org.sunbird.common.ElasticSearchHelper; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.factory.EsClientFactory; -import org.sunbird.common.inf.ElasticSearchService; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.ActorOperations; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.dto.SearchDTO; -import scala.concurrent.Future; - -public class UserClientImpl implements UserClient { - - private static InterServiceCommunication interServiceCommunication = - InterServiceCommunicationFactory.getInstance(); - private ElasticSearchService esUtil = EsClientFactory.getInstance(JsonKey.REST); - - @Override - public String createUser(ActorRef actorRef, Map userMap) { - ProjectLogger.log("UserClientImpl: createUser called", LoggerEnum.INFO); - return upsertUser(actorRef, userMap, ActorOperations.CREATE_USER.getValue()); - } - - @Override - public void updateUser(ActorRef actorRef, Map userMap) { - ProjectLogger.log("UserClientImpl: updateUser called", LoggerEnum.INFO); - upsertUser(actorRef, userMap, ActorOperations.UPDATE_USER.getValue()); - } - - @Override - public void esVerifyPhoneUniqueness() { - esVerifyFieldUniqueness(JsonKey.ENC_PHONE, JsonKey.PHONE); - } - - @Override - public void esVerifyEmailUniqueness() { - esVerifyFieldUniqueness(JsonKey.ENC_EMAIL, JsonKey.EMAIL); - } - - private void esVerifyFieldUniqueness(String facetsKey, String objectType) { - SearchDTO searchDto = null; - searchDto = new SearchDTO(); - searchDto.setLimit(0); - - Map facets = new HashMap<>(); - facets.put(facetsKey, null); - List> list = new ArrayList<>(); - list.add(facets); - searchDto.setFacets(list); - - Future> esResponseF = - esUtil.search(searchDto, ProjectUtil.EsType.user.getTypeName()); - Map esResponse = - (Map) ElasticSearchHelper.getResponseFromFuture(esResponseF); - - if (null != esResponse) { - List> facetsResponse = - (List>) esResponse.get(JsonKey.FACETS); - - if (CollectionUtils.isNotEmpty(facetsResponse)) { - Map map = facetsResponse.get(0); - List> valueList = (List>) map.get("values"); - - for (Map value : valueList) { - long count = (long) value.get(JsonKey.COUNT); - if (count > 1) { - throw new ProjectCommonException( - ResponseCode.errorDuplicateEntries.getErrorCode(), - MessageFormat.format( - ResponseCode.errorDuplicateEntries.getErrorMessage(), objectType), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - } - } - } - - private String upsertUser(ActorRef actorRef, Map userMap, String operation) { - String userId = null; - - Request request = new Request(); - request.setRequest(userMap); - request.setOperation(operation); - request.getContext().put(JsonKey.VERSION, JsonKey.VERSION_2); - request.getContext().put(JsonKey.CALLER_ID, JsonKey.BULK_USER_UPLOAD); - request.getContext().put(JsonKey.ROOT_ORG_ID, userMap.get(JsonKey.ROOT_ORG_ID)); - userMap.remove(JsonKey.ROOT_ORG_ID); - Object obj = interServiceCommunication.getResponse(actorRef, request); - if (obj instanceof Response) { - Response response = (Response) obj; - userId = (String) response.get(JsonKey.USER_ID); - } else if (obj instanceof ProjectCommonException) { - throw (ProjectCommonException) obj; - } else if (obj instanceof Exception) { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - return userId; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/Location.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/Location.java deleted file mode 100644 index 898d7de4b..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/Location.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.sunbird.models.location; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.io.Serializable; - -/** - * @desc POJO class for Location - * @author Amit Kumar - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Location implements Serializable { - - private static final long serialVersionUID = -7967252522327069670L; - - private String id; - private String code; - private String name; - private String type; - private String parentId; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/apirequest/UpsertLocationRequest.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/apirequest/UpsertLocationRequest.java deleted file mode 100644 index 0214f94f8..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/apirequest/UpsertLocationRequest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.sunbird.models.location.apirequest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -/** - * Class to represent the location api request object. - * - * @author arvind. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class UpsertLocationRequest { - - private String id; - private String code; - private String name; - private String type; - private String parentId; - private String parentCode; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public String getParentCode() { - return parentCode; - } - - public void setParentCode(String parentCode) { - this.parentCode = parentCode; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/organisation/Organisation.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/organisation/Organisation.java deleted file mode 100644 index 1af6ca420..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/organisation/Organisation.java +++ /dev/null @@ -1,357 +0,0 @@ -package org.sunbird.models.organisation; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.List; - -/** - * @desc POJO class for Organisation - * @author Amit Kumar - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class Organisation implements Serializable { - - private static final long serialVersionUID = 3617862727235741692L; - private String id; - private String addressId; - private String approvedBy; - private String approvedDate; - private String channel; - private String communityId; - private String contactDetail; - private String createdBy; - private String createdDate; - private Timestamp dateTime; - private String description; - private String email; - private String externalId; - private String hashTagId; - private String homeUrl; - private String imgUrl; - private Boolean isApproved; - private Boolean isDefault; - private Boolean isRootOrg; - private String locationId; - private Integer noOfMembers; - private String orgCode; - private String orgName; - private String orgType; - private String orgTypeId; - private String parentOrgId; - private String preferredLanguage; - private String provider; - private String rootOrgId; - private String slug; - private Integer status; - private String theme; - private String thumbnail; - private String updatedBy; - private String updatedDate; - private List locationIds; - private Boolean isSSOEnabled; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getAddressId() { - return addressId; - } - - public void setAddressId(String addressId) { - this.addressId = addressId; - } - - public String getApprovedBy() { - return approvedBy; - } - - public void setApprovedBy(String approvedBy) { - this.approvedBy = approvedBy; - } - - public String getApprovedDate() { - return approvedDate; - } - - public void setApprovedDate(String approvedDate) { - this.approvedDate = approvedDate; - } - - public String getChannel() { - return channel; - } - - public void setChannel(String channel) { - this.channel = channel; - } - - public String getCommunityId() { - return communityId; - } - - public void setCommunityId(String communityId) { - this.communityId = communityId; - } - - public String getContactDetail() { - return contactDetail; - } - - public void setContactDetail(String contactDetail) { - this.contactDetail = contactDetail; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(String createdDate) { - this.createdDate = createdDate; - } - - public Timestamp getDateTime() { - return dateTime; - } - - public void setDateTime(Timestamp dateTime) { - this.dateTime = dateTime; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getExternalId() { - return externalId; - } - - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public String getHashTagId() { - return hashTagId; - } - - public void setHashTagId(String hashTagId) { - this.hashTagId = hashTagId; - } - - public String getHomeUrl() { - return homeUrl; - } - - public void setHomeUrl(String homeUrl) { - this.homeUrl = homeUrl; - } - - public String getImgUrl() { - return imgUrl; - } - - public void setImgUrl(String imgUrl) { - this.imgUrl = imgUrl; - } - - public String getLocationId() { - return locationId; - } - - public void setLocationId(String locationId) { - this.locationId = locationId; - } - - public Integer getNoOfMembers() { - return noOfMembers; - } - - public void setNoOfMembers(Integer noOfMembers) { - this.noOfMembers = noOfMembers; - } - - public String getOrgCode() { - return orgCode; - } - - public void setOrgCode(String orgCode) { - this.orgCode = orgCode; - } - - public String getOrgName() { - return orgName; - } - - public void setOrgName(String orgName) { - this.orgName = orgName; - } - - public String getOrgType() { - return orgType; - } - - public void setOrgType(String orgType) { - this.orgType = orgType; - } - - public String getOrgTypeId() { - return orgTypeId; - } - - public void setOrgTypeId(String orgTypeId) { - this.orgTypeId = orgTypeId; - } - - public String getParentOrgId() { - return parentOrgId; - } - - public void setParentOrgId(String parentOrgId) { - this.parentOrgId = parentOrgId; - } - - public String getPreferredLanguage() { - return preferredLanguage; - } - - public void setPreferredLanguage(String preferredLanguage) { - this.preferredLanguage = preferredLanguage; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - public String getRootOrgId() { - return rootOrgId; - } - - public void setRootOrgId(String rootOrgId) { - this.rootOrgId = rootOrgId; - } - - public String getSlug() { - return slug; - } - - public void setSlug(String slug) { - this.slug = slug; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getTheme() { - return theme; - } - - public void setTheme(String theme) { - this.theme = theme; - } - - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - public String getUpdatedDate() { - return updatedDate; - } - - public void setUpdatedDate(String updatedDate) { - this.updatedDate = updatedDate; - } - - public List getLocationIds() { - return locationIds; - } - - public void setLocationIds(List locationIds) { - this.locationIds = locationIds; - } - - @JsonProperty(value = "isApproved") - public Boolean isApproved() { - return isApproved; - } - - public void setApproved(Boolean isApproved) { - this.isApproved = isApproved; - } - - @JsonProperty(value = "isDefault") - public Boolean isDefault() { - return isDefault; - } - - public void setDefault(Boolean isDefault) { - this.isDefault = isDefault; - } - - @JsonProperty(value = "isRootOrg") - public Boolean isRootOrg() { - return isRootOrg; - } - - public void setRootOrg(Boolean isRootOrg) { - this.isRootOrg = isRootOrg; - } - - @JsonProperty(value = "isSSOEnabled") - public Boolean isSSOEnabled() { - return isSSOEnabled; - } - - public void setSSOEnabled(Boolean isSsoEnabled) { - this.isSSOEnabled = isSsoEnabled; - } -} diff --git a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java b/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java deleted file mode 100644 index 0e5813fd7..000000000 --- a/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.sunbird.models.systemsetting; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.io.Serializable; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(Include.NON_NULL) -public class SystemSetting implements Serializable { - private static final long serialVersionUID = 1L; - private String id; - private String field; - private String value; - - public SystemSetting() {} - - public SystemSetting(String id, String field, String value) { - this.id = id; - this.field = field; - this.value = value; - } - - public String getId() { - return this.id; - } - - public String getField() { - return this.field; - } - - public String getValue() { - return this.value; - } - - public void setId(String id) { - this.id = id; - } - - public void setField(String field) { - this.field = field; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/sunbird-platform-core/common-util/.gitignore b/sunbird-platform-core/common-util/.gitignore deleted file mode 100644 index 55977f8f9..000000000 --- a/sunbird-platform-core/common-util/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/target/ -.classpath -.project -.settings -/bin/ - -*.iml diff --git a/sunbird-platform-core/common-util/pom.xml b/sunbird-platform-core/common-util/pom.xml deleted file mode 100644 index 7f44f5e6a..000000000 --- a/sunbird-platform-core/common-util/pom.xml +++ /dev/null @@ -1,327 +0,0 @@ - - 4.0.0 - - org.sunbird - common-util - 0.0.1-SNAPSHOT - common-util - http://maven.apache.org - - - UTF-8 - - 2.5.19 - - - - - junit - junit - 4.12 - test - - - com.typesafe.akka - akka-actor_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-slf4j_2.11 - ${learner.akka.version} - - - com.typesafe.akka - akka-remote_2.11 - ${learner.akka.version} - - - org.apache.logging.log4j - log4j-api - 2.8.2 - - - org.apache.logging.log4j - log4j-core - 2.8.2 - - - - org.apache.commons - commons-lang3 - 3.0 - - - - org.keycloak - keycloak-admin-client - 6.0.1 - - - org.jboss.resteasy - jaxrs-api - 3.0.11.Final - - - org.jboss.resteasy - resteasy-client - 3.1.0.Final - - - - com.microsoft.azure - azure-storage - 5.4.0 - - - - org.apache.velocity - velocity-tools - 2.0 - - - - javax.mail - javax.mail-api - 1.5.1 - - - - com.sun.mail - javax.mail - 1.6.0 - - - - org.jboss.resteasy - resteasy-jackson2-provider - 3.1.3.Final - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-databind - - - - - - - com.moparisthebest - junidecode - 0.1.1 - - - - org.apache.poi - poi-ooxml - 3.15 - - - com.fasterxml.jackson.core - jackson-core - 2.10.1 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.1 - - - com.fasterxml.jackson.core - jackson-annotations - 2.10.1 - - - - org.apache.commons - commons-csv - 1.4 - - - - org.jvnet.mock-javamail - mock-javamail - 1.9 - test - - - - com.googlecode.libphonenumber - libphonenumber - 8.10.2 - - - - org.apache.tika - tika-core - 1.16 - - - - com.lmax - disruptor - 3.2.0 - - - - org.apache.httpcomponents - httpclient - 4.5 - - - - - org.apache.httpcomponents - httpmime - 4.5.2 - - - - org.powermock - powermock-module-junit4 - 1.6.5 - - - - - org.powermock - powermock-api-mockito - 1.6.5 - - - - - - org.apache.httpcomponents - httpcore - 4.4.4 - - - com.mashape.unirest - unirest-java - 1.4.9 - - - - com.google.guava - guava - 18.0 - - - org.sunbird - cloud-store-sdk - 1.2.6 - - - com.sun.jersey - jersey-core - - - com.sun.jersey - jersey-server - - - com.fasterxml.jackson.module - jackson-module-scala_2.11 - - - - - com.fasterxml.jackson.module - jackson-module-scala_2.11 - 2.10.1 - - - org.glassfish.jersey.core - jersey-common - 2.27 - - - org.glassfish.jersey.core - jersey-client - 2.27 - - - org.glassfish.jersey.core - jersey-server - 2.27 - - - org.apache.kafka - kafka-clients - 0.10.0.1 - - - - - - cloud-store - https://oss.sonatype.org/content/repositories/orgsunbird-1021 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - - **/*Spec.java - **/*Test.java - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.17 - - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.4 - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - package - - report - - - - - - - diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/ProjectCommonException.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/ProjectCommonException.java deleted file mode 100644 index 4fddff180..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/ProjectCommonException.java +++ /dev/null @@ -1,128 +0,0 @@ -/** */ -package org.sunbird.common.exception; - -import java.text.MessageFormat; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * This exception will be used across all backend code. This will send status code and error message - * - * @author Manzarul.Haque - */ -public class ProjectCommonException extends RuntimeException { - - /** serialVersionUID. */ - private static final long serialVersionUID = 1L; - /** code String code ResponseCode. */ - private String code; - /** message String ResponseCode. */ - private String message; - /** responseCode int ResponseCode. */ - private int responseCode; - - /** - * This code is for client to identify the error and based on that do the message localization. - * - * @return String - */ - public String getCode() { - return code; - } - - /** - * To set the client code. - * - * @param code String - */ - public void setCode(String code) { - this.code = code; - } - - /** - * message for client in english. - * - * @return String - */ - @Override - public String getMessage() { - return message; - } - - /** @param message String */ - public void setMessage(String message) { - this.message = message; - } - - /** - * This method will provide response code, this code will be used in response header. - * - * @return int - */ - public int getResponseCode() { - return responseCode; - } - - /** @param responseCode int */ - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - /** - * three argument constructor. - * - * @param code String - * @param message String - * @param responseCode int - */ - public ProjectCommonException(String code, String message, int responseCode) { - super(); - this.code = code; - this.message = message; - this.responseCode = responseCode; - } - - public ProjectCommonException( - String code, String messageWithPlaceholder, int responseCode, String... placeholderValue) { - super(); - this.code = code; - this.message = MessageFormat.format(messageWithPlaceholder, placeholderValue); - this.responseCode = responseCode; - } - - public static void throwClientErrorException(ResponseCode responseCode, String exceptionMessage) { - throw new ProjectCommonException( - responseCode.getErrorCode(), - StringUtils.isBlank(exceptionMessage) ? responseCode.getErrorMessage() : exceptionMessage, - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - public static void throwResourceNotFoundException() { - throw new ProjectCommonException( - ResponseCode.resourceNotFound.getErrorCode(), - ResponseCode.resourceNotFound.getErrorMessage(), - ResponseCode.RESOURCE_NOT_FOUND.getResponseCode()); - } - - public static void throwServerErrorException(ResponseCode responseCode, String exceptionMessage) { - throw new ProjectCommonException( - responseCode.getErrorCode(), - StringUtils.isBlank(exceptionMessage) ? responseCode.getErrorMessage() : exceptionMessage, - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - public static void throwServerErrorException(ResponseCode responseCode) { - throwServerErrorException(responseCode, responseCode.getErrorMessage()); - } - - public static void throwClientErrorException(ResponseCode responseCode) { - throwClientErrorException(responseCode, responseCode.getErrorMessage()); - } - - public static void throwUnauthorizedErrorException() { - throw new ProjectCommonException( - ResponseCode.unAuthorized.getErrorCode(), - ResponseCode.unAuthorized.getErrorMessage(), - ResponseCode.UNAUTHORIZED.getResponseCode()); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/package-info.java deleted file mode 100644 index 18e910d04..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.exception; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/hash/HashGeneratorUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/hash/HashGeneratorUtil.java deleted file mode 100644 index 0f28662df..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/hash/HashGeneratorUtil.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.sunbird.common.hash; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.sunbird.common.models.util.datasecurity.OneWayHashing; - -public class HashGeneratorUtil { - private static List primes = null; - private static int MAX_NUMBER = 300; - private static int numPrimes = 7; - - private static List getPrimes() { - List list = new ArrayList<>(); - boolean prime[] = new boolean[MAX_NUMBER + 1]; - Arrays.fill(prime, true); - for (int p = 2; p * p <= MAX_NUMBER; p++) { - if (prime[p] == true) { - for (int i = p * p; i <= MAX_NUMBER; i += p) prime[i] = false; - } - } - for (int i = numPrimes; i <= MAX_NUMBER; i++) { - if (prime[i] == true) { - list.add(i); - } - } - return list; - } - - public static String getHashCode(String jsonString) { - return OneWayHashing.encryptVal(jsonString); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ClientErrorResponse.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ClientErrorResponse.java deleted file mode 100644 index d1f8c7fd5..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ClientErrorResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.sunbird.common.models.response; - -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.responsecode.ResponseCode; - -public class ClientErrorResponse extends Response { - - private ProjectCommonException exception = null; - - public ClientErrorResponse() { - responseCode = ResponseCode.CLIENT_ERROR; - } - - public ProjectCommonException getException() { - return exception; - } - - public void setException(ProjectCommonException exception) { - this.exception = exception; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/HttpUtilResponse.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/HttpUtilResponse.java deleted file mode 100644 index 501b957f2..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/HttpUtilResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.sunbird.common.models.response; - -public class HttpUtilResponse { - private String body; - private int statusCode; - - public HttpUtilResponse() {} - - public HttpUtilResponse(String body, int statusCode) { - this.body = body; - this.statusCode = statusCode; - } - - /** @return the body */ - public String getBody() { - return body; - } - - /** @param body the body to set */ - public void setBody(String body) { - this.body = body; - } - - /** @return the statusCode */ - public int getStatusCode() { - return statusCode; - } - - /** @param statusCode the statusCode to set */ - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Params.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Params.java deleted file mode 100644 index 9d740f5c6..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Params.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.sunbird.common.models.response; - -import java.io.Serializable; - -/** - * Common response parameter bean - * - * @author Manzarul - */ -public class Params implements Serializable { - - private static final long serialVersionUID = -8786004970726124473L; - private String resmsgid; - private String msgid; - private String err; - private String status; - private String errmsg; - - /** @return String */ - public String getResmsgid() { - return resmsgid; - } - - /** @param resmsgid Stirng */ - public void setResmsgid(String resmsgid) { - this.resmsgid = resmsgid; - } - - /** @return Stirng */ - public String getMsgid() { - return msgid; - } - - /** @param msgid String */ - public void setMsgid(String msgid) { - this.msgid = msgid; - } - - /** @return String */ - public String getErr() { - return err; - } - - /** @param err String */ - public void setErr(String err) { - this.err = err; - } - - /** @return String */ - public String getStatus() { - return status; - } - - /** @param status Stirng */ - public void setStatus(String status) { - this.status = status; - } - - /** @return Stirng */ - public String getErrmsg() { - return errmsg; - } - - /** @param errmsg Stirng */ - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Response.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Response.java deleted file mode 100644 index adbaed174..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Response.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.sunbird.common.models.response; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * This is a common response class for all the layer. All layer will send same response object. - * - * @author Manzarul - */ -public class Response implements Serializable, Cloneable { - - private static final long serialVersionUID = -3773253896160786443L; - protected String id; - protected String ver; - protected String ts; - protected ResponseParams params; - protected ResponseCode responseCode = ResponseCode.OK; - protected Map result = new HashMap<>(); - - /** - * This will provide request unique id. - * - * @return String - */ - public String getId() { - return id; - } - - /** - * set the unique id - * - * @param id String - */ - public void setId(String id) { - this.id = id; - } - - /** - * this will provide api version - * - * @return String - */ - public String getVer() { - return ver; - } - - /** - * set the api version - * - * @param ver String - */ - public void setVer(String ver) { - this.ver = ver; - } - - /** - * this will provide complete time value - * - * @return String - */ - public String getTs() { - return ts; - } - - /** - * set the time value - * - * @param ts String - */ - public void setTs(String ts) { - this.ts = ts; - } - - /** @return Map */ - public Map getResult() { - return result; - } - - /** - * @param key String - * @return Object - */ - public Object get(String key) { - return result.get(key); - } - - /** - * @param key String - * @param vo Object - */ - public void put(String key, Object vo) { - result.put(key, vo); - } - - /** @param map Map */ - public void putAll(Map map) { - result.putAll(map); - } - - public boolean containsKey(String key) { - return result.containsKey(key); - } - - /** - * This will provide response parameter object. - * - * @return ResponseParams - */ - public ResponseParams getParams() { - return params; - } - - /** - * set the response parameter object. - * - * @param params ResponseParams - */ - public void setParams(ResponseParams params) { - this.params = params; - } - - /** - * Set the response code for header. - * - * @param code ResponseCode - */ - public void setResponseCode(ResponseCode code) { - this.responseCode = code; - } - - /** - * get the response code - * - * @return ResponseCode - */ - public ResponseCode getResponseCode() { - return this.responseCode; - } - - public Response clone(Response response) { - try { - return (Response) response.clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ResponseParams.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ResponseParams.java deleted file mode 100644 index e46355168..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ResponseParams.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.sunbird.common.models.response; - -import java.io.Serializable; - -/** - * This class will contains response envelop. - * - * @author Manzarul - */ -public class ResponseParams implements Serializable { - - private static final long serialVersionUID = 6772142067149203497L; - private String resmsgid; - private String msgid; - private String err; - private String status; - private String errmsg; - - public enum StatusType { - SUCCESSFUL, - WARNING, - FAILED; - } - - /** - * This will contains response message id. - * - * @return String - */ - public String getResmsgid() { - return resmsgid; - } - - /** - * set the response message id. - * - * @param resmsgid String - */ - public void setResmsgid(String resmsgid) { - this.resmsgid = resmsgid; - } - - /** - * This will provide request specific message id. - * - * @return String - */ - public String getMsgid() { - return msgid; - } - - /** - * Set the request specific message id. - * - * @param msgid - */ - public void setMsgid(String msgid) { - this.msgid = msgid; - } - - /** - * This will provide error message - * - * @return String - */ - public String getErr() { - return err; - } - - /** - * Set the error message - * - * @param err String - */ - public void setErr(String err) { - this.err = err; - } - - /** - * This will return api call status - * - * @return String - */ - public String getStatus() { - return status; - } - - /** - * Set the api call status - * - * @param status - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * This will provide Error message in english - * - * @return String - */ - public String getErrmsg() { - return errmsg; - } - - /** - * Set the error message in English. - * - * @param message String - */ - public void setErrmsg(String message) { - this.errmsg = message; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/package-info.java deleted file mode 100644 index db2569117..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.response; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ActorOperations.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ActorOperations.java deleted file mode 100644 index c01d98719..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ActorOperations.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.sunbird.common.models.util; - -/** - * This enum will contains different operation for a learner {addCourse, getCourse, update , - * getContent} - * - * @author Manzarul - */ -public enum ActorOperations { - ENROLL_COURSE("enrollCourse"), - UNENROLL_COURSE("unenrollCourse"), - GET_COURSE("getCourse"), - ADD_CONTENT("addContent"), - GET_CONTENT("getContent"), - CREATE_COURSE("createCourse"), - UPDATE_COURSE("updateCourse"), - PUBLISH_COURSE("publishCourse"), - SEARCH_COURSE("searchCourse"), - DELETE_COURSE("deleteCourse"), - CREATE_USER("createUser"), - UPDATE_USER("updateUser"), - USER_AUTH("userAuth"), - GET_USER_PROFILE("getUserProfile"), - GET_USER_PROFILE_V2("getUserProfileV2"), - CREATE_ORG("createOrg"), - UPDATE_ORG("updateOrg"), - UPDATE_ORG_STATUS("updateOrgStatus"), - GET_ORG_DETAILS("getOrgDetails"), - CREATE_PAGE("createPage"), - UPDATE_PAGE("updatePage"), - DELETE_PAGE("deletePage"), - GET_PAGE_SETTINGS("getPageSettings"), - GET_PAGE_SETTING("getPageSetting"), - GET_PAGE_DATA("getPageData"), - GET_DIAL_PAGE_DATA("getDialPageData"), - CREATE_SECTION("createSection"), - UPDATE_SECTION("updateSection"), - GET_ALL_SECTION("getAllSection"), - GET_SECTION("getSection"), - GET_COURSE_BY_ID("getCourseById"), - UPDATE_USER_COUNT("updateUserCount"), - GET_RECOMMENDED_COURSES("getRecommendedCourses"), - UPDATE_USER_INFO_ELASTIC("updateUserInfoToElastic"), - GET_ROLES("getRoles"), - APPROVE_ORGANISATION("approveOrganisation"), - ADD_MEMBER_ORGANISATION("addMemberOrganisation"), - REMOVE_MEMBER_ORGANISATION("removeMemberOrganisation"), - COMPOSITE_SEARCH("compositeSearch"), - GET_USER_DETAILS_BY_LOGINID("getUserDetailsByLoginId"), - GET_USER_BY_KEY("getUserByKey"), - UPDATE_ORG_INFO_ELASTIC("updateOrgInfoToElastic"), - INSERT_ORG_INFO_ELASTIC("insertOrgInfoToElastic"), - DOWNLOAD_ORGS("downlaodOrg"), - BLOCK_USER("blockUser"), - DELETE_BY_IDENTIFIER("deleteByIdentifier"), - BULK_UPLOAD("bulkUpload"), - PROCESS_BULK_UPLOAD("processBulkUpload"), - ASSIGN_ROLES("assignRoles"), - UNBLOCK_USER("unblockUser"), - CREATE_BATCH("createBatch"), - UPDATE_BATCH("updateBatch"), - REMOVE_BATCH("removeBatch"), - ADD_USER_TO_BATCH("addUserBatch"), - REMOVE_USER_FROM_BATCH("removeUserFromBatch"), - GET_BATCH("getBatch"), - INSERT_COURSE_BATCH_ES("insertCourseBatchToEs"), - UPDATE_COURSE_BATCH_ES("updateCourseBatchToEs"), - GET_BULK_OP_STATUS("getBulkOpStatus"), - GET_BULK_UPLOAD_STATUS_DOWNLOAD_LINK("getBulkUploadStatusDownloadLink"), - ORG_CREATION_METRICS("orgCreationMetrics"), - ORG_CONSUMPTION_METRICS("orgConsumptionMetrics"), - ORG_CREATION_METRICS_DATA("orgCreationMetricsData"), - ORG_CONSUMPTION_METRICS_DATA("orgConsumptionMetricsData"), - COURSE_PROGRESS_METRICS("courseProgressMetrics"), - COURSE_PROGRESS_METRICS_V2("courseProgressMetricsV2"), - COURSE_CREATION_METRICS("courseConsumptionMetrics"), - USER_CREATION_METRICS("userCreationMetrics"), - USER_CONSUMPTION_METRICS("userConsumptionMetrics"), - GET_COURSE_BATCH_DETAIL("getCourseBatchDetail"), - UPDATE_USER_ORG_ES("updateUserOrgES"), - REMOVE_USER_ORG_ES("removeUserOrgES"), - UPDATE_USER_ROLES_ES("updateUserRoles"), - SYNC("sync"), - BACKGROUND_SYNC("backgroundSync"), - INSERT_USR_COURSES_INFO_ELASTIC("insertUserCoursesInfoToElastic"), - UPDATE_USR_COURSES_INFO_ELASTIC("updateUserCoursesInfoToElastic"), - SCHEDULE_BULK_UPLOAD("scheduleBulkUpload"), - COURSE_PROGRESS_METRICS_REPORT("courseProgressMetricsReport"), - COURSE_CREATION_METRICS_REPORT("courseConsumptionMetricsReport"), - ORG_CREATION_METRICS_REPORT("orgCreationMetricsReport"), - ORG_CONSUMPTION_METRICS_REPORT("orgConsumptionMetricsReport"), - EMAIL_SERVICE("emailService"), - FILE_STORAGE_SERVICE("fileStorageService"), - ADD_USER_BADGE_BKG("addUserBadgebackground"), - FILE_GENERATION_AND_UPLOAD("fileGenerationAndUpload"), - HEALTH_CHECK("healthCheck"), - SEND_MAIL("sendMail"), - PROCESS_DATA("processData"), - ACTOR("actor"), - CASSANDRA("cassandra"), - ES("es"), - EKSTEP("ekstep"), - GET_ORG_TYPE_LIST("getOrgTypeList"), - CREATE_ORG_TYPE("createOrgType"), - UPDATE_ORG_TYPE("updateOrgType"), - CREATE_NOTE("createNote"), - UPDATE_NOTE("updateNote"), - SEARCH_NOTE("searchNote"), - GET_NOTE("getNote"), - DELETE_NOTE("deleteNote"), - INSERT_USER_NOTES_ES("insertUserNotesToElastic"), - ENCRYPT_USER_DATA("encryptUserData"), - DECRYPT_USER_DATA("decryptUserData"), - UPDATE_USER_NOTES_ES("updateUserNotesToElastic"), - USER_CURRENT_LOGIN("userCurrentLogin"), - GET_MEDIA_TYPES("getMediaTypes"), - ADD_SKILL("addSkill"), - GET_SKILL("getSkill"), - UPDATE_SKILL("updateSkill"), - GET_SKILLS_LIST("getSkillsList"), - ADD_USER_SKILL_ENDORSEMENT("addUserSkillEndorsement"), - PROFILE_VISIBILITY("profileVisibility"), - CREATE_TENANT_PREFERENCE("createTanentPreference"), - UPDATE_TENANT_PREFERENCE("updateTenantPreference"), - GET_TENANT_PREFERENCE("getTenantPreference"), - REGISTER_CLIENT("registerClient"), - UPDATE_CLIENT_KEY("updateClientKey"), - GET_CLIENT_KEY("getClientKey"), - CREATE_GEO_LOCATION("createGeoLocation"), - GET_GEO_LOCATION("getGeoLocation"), - UPDATE_GEO_LOCATION("updateGeoLocation"), - DELETE_GEO_LOCATION("deleteGeoLocation"), - GET_USER_COUNT("getUserCount"), - UPDATE_USER_COUNT_TO_LOCATIONID("updateUserCountToLocationID"), - SEND_NOTIFICATION("sendNotification"), - SYNC_KEYCLOAK("syncKeycloak"), - UPDATE_SYSTEM_SETTINGS("updateSystemSettings"), - CREATE_DATA("createData"), - UPDATE_DATA("updateData"), - DELETE_DATA("deleteData"), - READ_DATA("readData"), - READ_ALL_DATA("readAllData"), - SEARCH_DATA("searchData"), - GET_METRICS("getMetrics"), - REG_CHANNEL("channelReg"), - UPDATE_LEARNER_STATE("updateLearnerState"), - GET_SYSTEM_SETTING("getSystemSetting"), - GET_ALL_SYSTEM_SETTINGS("getAllSystemSettings"), - SET_SYSTEM_SETTING("setSystemSetting"), - COURSE_BATCH_NOTIFICATION("courseBatchNotification"), - USER_TNC_ACCEPT("userTnCAccept"), - GENERATE_OTP("generateOTP"), - BACKGROUND_ENCRYPTION("backgroundEncryption"), - BACKGROUND_DECRYPTION("backgroundDecryption"), - VERIFY_OTP("verifyOTP"), - SEND_OTP("sendOTP"), - GET_USER_TYPES("getUserTypes"), - CLEAR_CACHE("clearCache"), - USER_TENANT_MIGRATE("userTenantMigrate"), - GET_PARTICIPANTS("getParticipants"), - GET_USER_COURSE("getUserCourse"), - FREEUP_USER_IDENTITY("freeUpUserIdentity"), - RESET_PASSWORD("resetPassword"), - MERGE_USER("mergeUser"), - MERGE_USER_TO_ELASTIC("mergeUserToElastic"), - VALIDATE_CERTIFICATE("validateCertificate"), - ADD_CERTIFICATE("addCertificate"), - ASSIGN_KEYS("assignKeys"), - DOWNLOAD_QR_CODES("downloadQRCodes"), - GET_SIGN_URL("getSignUrl"), - MERGE_USER_CERTIFICATE("mergeUserCertificate"), - MIGRATE_USER("migrateUser"), - REJECT_MIGRATION("rejectMigration"), - GET_USER_FEED_BY_ID("getUserFeedById"), - CREATE_USER_V3("createUserV3"), - ONDEMAND_START_SCHEDULER("onDemandStartScheduler"); - private String value; - - /** - * constructor - * - * @param value String - */ - ActorOperations(String value) { - this.value = value; - } - - /** - * returns the enum value - * - * @return String - */ - public String getValue() { - return this.value; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/AuditLog.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/AuditLog.java deleted file mode 100644 index 9c5d6d721..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/AuditLog.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.sunbird.common.models.util; - -import java.util.Map; - -public class AuditLog { - - private String requestId; - private String objectId; - private String objectType; - private String operationType; - private String date; - private String userId; - private Map logRecord; - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getObjectId() { - return objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public String getObjectType() { - return objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getOperationType() { - return operationType; - } - - public void setOperationType(String operationType) { - this.operationType = operationType; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public Map getLogRecord() { - return logRecord; - } - - public void setLogRecord(Map logRecord) { - this.logRecord = logRecord; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingActorOperations.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingActorOperations.java deleted file mode 100644 index 48df17022..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingActorOperations.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.sunbird.common.models.util; - -/** Created by arvind on 7/3/18. */ -public enum BadgingActorOperations { - CREATE_BADGE_CLASS("createBadgeClass"), - GET_BADGE_CLASS("getBadgeClass"), - SEARCH_BADGE_CLASS("searchBadgeClass"), - DELETE_BADGE_CLASS("deleteBadgeClass"), - CREATE_BADGE_ISSUER("createBadgeIssuer"), - ASSIGN_BADGE_MESSAGE("assignBadgeMessage"), - REVOKE_BADGE_MESSAGE("revokeBadgeMessage"), - CREATE_BADGE_ASSERTION("createBadgeAssertion"), - GET_BADGE_ASSERTION("getBadgeAssertion"), - GET_BADGE_ASSERTION_LIST("getBadgeAssertionList"), - REVOKE_BADGE("revokeBadge"), - GET_BADGE_ISSUER("getBadgeIssuer"), - GET_ALL_ISSUER("getAllIssuer"), - CREATE_BADGE_ASSOCIATION("createBadgeAssociation"), - REMOVE_BADGE_ASSOCIATION("removeBadgeAssociation"); - - private String value; - - /** - * constructor - * - * @param value String - */ - BadgingActorOperations(String value) { - this.value = value; - } - - /** - * returns the enum value - * - * @return String - */ - public String getValue() { - return this.value; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingJsonKey.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingJsonKey.java deleted file mode 100644 index 025431a8b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BadgingJsonKey.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.sunbird.common.models.util; - -/** Created by arvind on 7/3/18. */ -public class BadgingJsonKey { - public static final String ASSERTIONS = "assertions"; - public static final String ASSERTION_SLUG = "assertionSlug"; - public static final String BADGE_CRITERIA = "criteria"; - public static final String BADGE_ID = "badgeId"; - public static final String BADGE_IDs = "badgeIds"; - public static final String BADGE_ID_URL = "badgeIdUrl"; - public static final String BADGE_LIST = "badgeList"; - public static final String BADGE_SLUG = "badgeSlug"; - public static final String BADGE_TYPE_USER = "user"; - public static final String BADGE_TYPE_CONTENT = "content"; - public static final String BADGER_BASE_URL = "sunbird_badger_baseurl"; - public static final String BADGES = "badges"; - public static final String BADGING_ASSERTION_LIST_SIZE = "badging_assertion_list_size"; - public static final String BADGING_AUTHORIZATION_KEY = "badging_authorization_key"; - public static final String CONTEXT = "context"; - public static final String CREATE_NOTIFICATION = "create_notification"; - public static final String CREATED_AT = "created_at"; - public static final String EVIDENCE = "evidence"; - public static final String ISSUER_ID = "issuerId"; - public static final String ISSUER_ID_URL = "issuerIdUrl"; - public static final String ISSUER_LIST = "issuerList"; - public static final String ISSUER_SLUG = "issuerSlug"; - public static final String ISSUER_URL = "issuerUrl"; - public static final String ISSUERS = "issuers"; - public static final String ASSERTION_ID = "assertionId"; - public static final String ASSOCIATION_ID = "associationId"; - public static final String JSON_CRITERIA = "json.criteria"; - public static final String JSON_DESCRIPTION = "json.description"; - public static final String JSON_EMAIL = "json.email"; - public static final String JSON_ID = "json.id"; - public static final String JSON_ISSUER = "json.issuer"; - public static final String JSON_URL = "json.url"; - public static final String NOTIFY = "notify"; - public static final String RECIPIENT_COUNT = "recipient_count"; - public static final String RECIPIENT_EMAIL = "recipientEmail"; - public static final String RECIPIENT_ID = "recipientId"; - public static final String RECIPIENT_IDENTIFIER = "recipient_identifier"; - public static final String RECIPIENT_TYPE = "recipientType"; - public static final String REVOCATION_REASON = "revocationReason"; - public static final String JSON_ISSUED_ON = "json.issuedOn"; - public static final String JSON_IMAGE = "json.image"; - public static final String JSON_BADGE = "json.badge"; - public static final String BADGE_CLASS = "badge_class"; - public static final String ISSUER = "issuer"; - public static final String JSON_RECIPIENT = "json.recipient"; - public static final String JSON_VERIFY = "json.verify"; - public static final String REVOCATION_REASON_BADGE = "revocation_reason"; - public static final String ASSERTION_DATE = "assertionDate"; - public static final String ASSERTION_ID_URL = "assertionIdUrl"; - public static final String ASSERTION_IMAGE_URL = "assertionImageUrl"; - public static final String RECIPIENT = "recipient"; - public static final String VERIFY = "verify"; - public static final String REVOKED = "revoked"; - public static final String CREATED_TS = "createdTS"; - public static final String BADGE_CLASS_NANE = "badgeClassName"; - public static final String NAME = "name"; - public static final String IMAGE = "image"; - public static final String BADGE_CLASS_IMAGE = "badgeClassImage"; - public static final String BADGE_ASSERTION = "badgeAssertion"; - public static final String SLUG = "slug"; - public static final String VALID_BADGE_SUBTYPES = "sunbird_valid_badge_subtypes"; - public static final String VALID_BADGE_ROLES = "sunbird_valid_badge_roles"; - public static final String BADGE_CLASS_ID = "badgeId"; - public static final String USER_BADGE_ASSERTION_DB = "user_badge_assertion"; - public static final String CONTENT_BADGE_ASSOCIATION_DB = "content_badge_association"; - public static final String BADGE_ASSERTIONS = "badgeAssertions"; - public static final String BADGE_ASSOCIATIONS = "badgeAssociations"; - public static final String BADGE = "badge"; - // this email will be set while sunbird installation and used to send the email - // in case of assertion , if user email is absent. - public static final String SUNBIRD_INSTALLATION_EMAIL = "sunbird_installation_email"; - public static final String BADGE_ISSUER = "BadgeIssuer"; - public static final String TELEMETRY_DB = "telemetry_raw_data"; - - public static final String TELE_MID = "mid"; - public static final String TELE_TS = "ts"; - public static final String TELE_EVENT_DATA = "eventData"; - public static final String TELE_PDATA_ID = "pdataId"; - public static final String TELE_EID = "eid"; - public static final String TELE_ETS = "ets"; - public static final String TELE_PDATA = "pdata"; - public static final String TELE_VERSION = "ver"; - public static final String TELE_CONTEXT = "context"; - public static final String USER = "user"; - public static final String CONTENT = "content"; - - private BadgingJsonKey() {} -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadActorOperation.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadActorOperation.java deleted file mode 100644 index 66cc045da..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadActorOperation.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.sunbird.common.models.util; - -/** Enum to represent bulk upload operations */ -public enum BulkUploadActorOperation { - LOCATION_BULK_UPLOAD("locationBulkUpload"), - LOCATION_BULK_UPLOAD_BACKGROUND_JOB("locationBulkUploadBackground"), - - ORG_BULK_UPLOAD("orgBulkUpload"), - ORG_BULK_UPLOAD_BACKGROUND_JOB("orgBulkUploadBackground"), - - USER_BULK_UPLOAD("userBulkUpload"), - USER_BULK_UPLOAD_BACKGROUND_JOB("userBulkUploadBackground"), - USER_BULK_MIGRATION("userBulkMigration"); - - private String value; - - BulkUploadActorOperation(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadJsonKey.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadJsonKey.java deleted file mode 100644 index 4cc2757c9..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadJsonKey.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sunbird.common.models.util; - -/** - * Constants for Bulk Upload service. - * - * @author Arvind - */ -public class BulkUploadJsonKey { - - private BulkUploadJsonKey() {} - - public static final String TASK_COUNT = "taskCount"; - public static final String SEQUENCE_ID = "sequenceId"; - public static final String OPERATION_STATUS_MSG = "Operation is {0}."; - public static final String NOT_STARTED = "NOT STARTED"; - public static final String IN_PROGRESS = "IN PROGRESS"; - public static final String COMPLETED = "COMPLETED"; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/CassandraPropertyReader.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/CassandraPropertyReader.java deleted file mode 100644 index 9d3c62806..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/CassandraPropertyReader.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.sunbird.common.models.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * This class will be used to read cassandratablecolumn properties file. - * - * @author Amit Kumar - */ -public class CassandraPropertyReader { - - private final Properties properties = new Properties(); - private static final String file = "cassandratablecolumn.properties"; - private static CassandraPropertyReader cassandraPropertyReader = null; - - /** private default constructor */ - private CassandraPropertyReader() { - InputStream in = this.getClass().getClassLoader().getResourceAsStream(file); - try { - properties.load(in); - } catch (IOException e) { - ProjectLogger.log("Error in properties cache", e); - } - } - - public static CassandraPropertyReader getInstance() { - if (null == cassandraPropertyReader) { - synchronized (CassandraPropertyReader.class) { - if (null == cassandraPropertyReader) { - cassandraPropertyReader = new CassandraPropertyReader(); - } - } - } - return cassandraPropertyReader; - } - - /** - * Method to read value from resource file . - * - * @param key property value to read - * @return value corresponding to given key if found else will return key itself. - */ - public String readProperty(String key) { - return properties.getProperty(key) != null ? properties.getProperty(key) : key; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/DbConstant.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/DbConstant.java deleted file mode 100644 index 7ea3d27f9..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/DbConstant.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.sunbird.common.models.util; - -/** - * Enum contains the database related constants - * - * @author arvind - */ -public enum DbConstant { - sunbirdKeyspaceName("sunbird"), - userTableName("user"); - - DbConstant(String value) { - this.value = value; - } - - String value; - - public String getValue() { - return this.value; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/EmailValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/EmailValidator.java deleted file mode 100644 index 821c73d55..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/EmailValidator.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.sunbird.common.models.util; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.lang.StringUtils; - -/** - * Helper class for validating email. - * - * @author Amit Kumar - */ -public class EmailValidator { - - private static Pattern pattern; - private static final String EMAIL_PATTERN = - "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" - + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; - - private EmailValidator() {} - - static { - pattern = Pattern.compile(EMAIL_PATTERN); - } - - /** - * Validates format of email. - * - * @param email Email value. - * @return True, if email format is valid. Otherwise, return false. - */ - public static boolean isEmailValid(String email) { - if (StringUtils.isBlank(email)) { - return false; - } - Matcher matcher = pattern.matcher(email); - return matcher.matches(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ExcelFileUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ExcelFileUtil.java deleted file mode 100644 index bc1503be6..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ExcelFileUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.sunbird.common.models.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.List; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -public class ExcelFileUtil extends FileUtil { - - @SuppressWarnings({"resource", "unused"}) - public File writeToFile(String fileName, List> dataValues) { - // Blank workbook - XSSFWorkbook workbook = new XSSFWorkbook(); - // Create a blank sheet - XSSFSheet sheet = workbook.createSheet("Data"); - FileOutputStream out = null; - File file = null; - int rownum = 0; - for (Object key : dataValues) { - Row row = sheet.createRow(rownum); - List objArr = dataValues.get(rownum); - int cellnum = 0; - for (Object obj : objArr) { - Cell cell = row.createCell(cellnum++); - if (obj instanceof String) { - cell.setCellValue((String) obj); - } else if (obj instanceof Integer) { - cell.setCellValue((Integer) obj); - } else if (obj instanceof List) { - cell.setCellValue(getListValue(obj)); - } else if (obj instanceof Double) { - cell.setCellValue((Double) obj); - } else { - if (ProjectUtil.isNotNull(obj)) { - cell.setCellValue(obj.toString()); - } - } - } - rownum++; - } - - try { - // Write the workbook in file system - file = new File(fileName + ".xlsx"); - out = new FileOutputStream(file); - workbook.write(out); - // out.close(); - ProjectLogger.log("File " + fileName + " created successfully"); - - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } finally { - if (null != out) { - try { - out.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return file; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/FileUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/FileUtil.java deleted file mode 100644 index cda6931f6..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/FileUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.sunbird.common.models.util; - -import java.io.File; -import java.util.List; -import org.apache.commons.lang3.StringUtils; - -public abstract class FileUtil { - - public abstract File writeToFile(String fileName, List> dataValues); - - @SuppressWarnings("unchecked") - protected static String getListValue(Object obj) { - List data = (List) obj; - if (!(data.isEmpty())) { - StringBuilder sb = new StringBuilder(); - for (Object value : data) { - sb.append((String) value).append(","); - } - sb.deleteCharAt(sb.length() - 1); - return sb.toString(); - } - return ""; - } - - public static FileUtil getFileUtil(String format) { - String tempformat = ""; - if (!StringUtils.isBlank(format)) { - tempformat = format.toLowerCase(); - } - switch (tempformat) { - case "excel": - return (new ExcelFileUtil()); - default: - return (new ExcelFileUtil()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/GeoLocationJsonKey.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/GeoLocationJsonKey.java deleted file mode 100644 index 8c3b8c4ad..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/GeoLocationJsonKey.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sunbird.common.models.util; - -/** Created by arvind on 19/4/18. */ -public class GeoLocationJsonKey { - - private GeoLocationJsonKey() {} - - public static final String PARENT_CODE = "parentCode"; - public static final String CODE = "code"; - public static final String LOCATION_TYPE = "type"; - public static final String PARENT_ID = "parentId"; - public static final String SUNBIRD_VALID_LOCATION_TYPES = "sunbird_valid_location_types"; - public static final String PROPERTY_NAME = "name"; - public static final String PROPERTY_VALUE = "value"; - public static final String ID = "id"; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/HttpUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/HttpUtil.java deleted file mode 100644 index 915de52ed..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/HttpUtil.java +++ /dev/null @@ -1,902 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.net.URI; -import java.net.URL; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MIME; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.sunbird.common.models.response.HttpUtilResponse; -import org.sunbird.common.request.ExecutionContext; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.common.util.KeycloakRequiredActionLinkUtil; -import org.sunbird.telemetry.util.TelemetryEvents; - -/** - * This utility method will handle external http call - * - * @author Manzarul - */ -public class HttpUtil { - - // private static TelemetryLmaxWriter lmaxWriter = TelemetryLmaxWriter.getInstance(); - - private HttpUtil() {} - - /** - * Makes an HTTP request using GET method to the specified URL. - * - * @param requestURL the URL of the remote server - * @param headers the Map - * @return An String object - * @throws IOException thrown if any I/O error occurred - */ - public static String sendGetRequest(String requestURL, Map headers) - throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = getRequest(requestURL, headers, startTime); - String str = getResponse(httpURLConnection); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil sendGetRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return str; - } - - /** - * Makes an HTTP request using GET method to the specified URLand in response it will return Map - * of status code with get response in String format. - * - * @param requestURL the URL of the remote server - * @param headers the Map - * @return HttpUtilResponse - * @throws IOException thrown if any I/O error occurred - */ - public static HttpUtilResponse doGetRequest(String requestURL, Map headers) - throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = getRequest(requestURL, headers, startTime); - HttpUtilResponse response = null; - String body = ""; - try { - body = getResponse(httpURLConnection); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpURLConnection.getResponseCode()); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil doGetRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response; - } - - /** - * @param requestURL - * @param headers - * @param startTime - * @return - * @throws MalformedURLException - * @throws IOException - * @throws ProtocolException - */ - private static HttpURLConnection getRequest( - String requestURL, Map headers, long startTime) throws IOException { - ProjectLogger.log( - "HttpUtil sendGetRequest method started at ==" - + startTime - + " for requestURL " - + requestURL, - LoggerEnum.PERF_LOG); - URL url = new URL(requestURL); - HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setUseCaches(false); - httpURLConnection.setDoInput(true); - httpURLConnection.setDoOutput(false); - httpURLConnection.setRequestMethod(ProjectUtil.Method.GET.name()); - if (headers != null && headers.size() > 0) { - setHeaders(httpURLConnection, headers); - } - return httpURLConnection; - } - - /** - * Makes an HTTP request using POST method to the specified URL. - * - * @param requestURL the URL of the remote server - * @param params A map containing POST data in form of key-value pairs - * @return String - * @throws IOException thrown if any I/O error occurred - */ - public static String sendPostRequest( - String requestURL, Map params, Map headers) - throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = postRequest(requestURL, params, headers, startTime); - String str = getResponse(httpURLConnection); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil sendPostRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return str; - } - - /** - * Makes an HTTP request using POST method to the specified URL and in response it will return Map - * of status code with post response in String format. - * - * @param requestURL the URL of the remote server - * @param params A map containing POST data in form of key-value pairs - * @return HttpUtilResponse - * @throws IOException thrown if any I/O error occurred - */ - public static HttpUtilResponse doPostRequest( - String requestURL, Map params, Map headers) - throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = postRequest(requestURL, params, headers, startTime); - HttpUtilResponse response = null; - String body = ""; - try { - body = getResponse(httpURLConnection); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpURLConnection.getResponseCode()); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil doPostRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response; - } - - private static HttpURLConnection postRequest( - String requestURL, Map params, Map headers, long startTime) - throws IOException { - HttpURLConnection httpURLConnection = null; - OutputStreamWriter writer = null; - ProjectLogger.log( - "HttpUtil sendPostRequest method started at ==" - + startTime - + " for requestURL " - + requestURL, - LoggerEnum.PERF_LOG); - try { - URL url = new URL(requestURL); - httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setUseCaches(false); - httpURLConnection.setDoInput(true); - httpURLConnection.setRequestMethod(ProjectUtil.Method.POST.name()); - StringBuilder requestParams = new StringBuilder(); - if (params != null && params.size() > 0) { - httpURLConnection.setDoOutput(true); - // creates the params string, encode them using URLEncoder - for (Map.Entry entry : params.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - requestParams.append(URLEncoder.encode(key, "UTF-8")); - requestParams.append("=").append(URLEncoder.encode(value, "UTF-8")); - requestParams.append("&"); - } - } - if (headers != null && headers.size() > 0) { - setHeaders(httpURLConnection, headers); - } - if (requestParams.length() > 0) { - writer = - new OutputStreamWriter(httpURLConnection.getOutputStream(), StandardCharsets.UTF_8); - writer.write(requestParams.toString()); - writer.flush(); - } - } catch (IOException ex) { - ProjectLogger.log(ex.getMessage(), ex); - throw ex; - } finally { - if (null != writer) { - try { - writer.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return httpURLConnection; - } - - /** - * Makes an HTTP request using POST method to the specified URL. - * - * @param requestURL the URL of the remote server - * @param params A map containing POST data in form of key-value pairs - * @return An HttpURLConnection object - * @throws IOException thrown if any I/O error occurred - */ - public static String sendPostRequest( - String requestURL, String params, Map headers) throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = postRequest(requestURL, params, headers, startTime); - String str = getResponse(httpURLConnection); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil sendPostRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return str; - } - - private static HttpURLConnection postRequest( - String requestURL, String params, Map headers, long startTime) - throws IOException { - ProjectLogger.log( - "HttpUtil sendPostRequest method started at ==" - + startTime - + " for requestURL " - + requestURL, - LoggerEnum.PERF_LOG); - HttpURLConnection httpURLConnection = null; - OutputStreamWriter writer = null; - try { - URL url = new URL(requestURL); - httpURLConnection = (HttpURLConnection) url.openConnection(); - httpURLConnection.setUseCaches(false); - httpURLConnection.setDoInput(true); - httpURLConnection.setRequestMethod(ProjectUtil.Method.POST.name()); - httpURLConnection.setDoOutput(true); - if (headers != null && headers.size() > 0) { - setHeaders(httpURLConnection, headers); - } - writer = new OutputStreamWriter(httpURLConnection.getOutputStream(), StandardCharsets.UTF_8); - writer.write(params); - writer.flush(); - } catch (IOException e) { - ProjectLogger.log("HttpUtil:postRequest call failure with error = " + e.getMessage(), e); - throw e; - } finally { - if (null != writer) { - try { - writer.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return httpURLConnection; - } - - /** - * Makes an HTTP request using POST method to the specified URL and in response it will return Map - * of status code with post response in String format. - * - * @param requestURL the URL of the remote server - * @param params A map containing POST data in form of key-value pairs - * @return HttpUtilResponse - * @throws IOException thrown if any I/O error occurred - */ - public static HttpUtilResponse doPostRequest( - String requestURL, String params, Map headers) throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - HttpURLConnection httpURLConnection = postRequest(requestURL, params, headers, startTime); - HttpUtilResponse response = null; - String body = ""; - try { - body = getResponse(httpURLConnection); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpURLConnection.getResponseCode()); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil doPostRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return response; - } - - private static String getResponse(HttpURLConnection httpURLConnection) throws IOException { - InputStream inStream = null; - BufferedReader reader = null; - StringBuilder builder = new StringBuilder(); - try { - inStream = httpURLConnection.getInputStream(); - reader = new BufferedReader(new InputStreamReader(inStream, StandardCharsets.UTF_8)); - String line = null; - while ((line = reader.readLine()) != null) { - builder.append(line); - } - } catch (IOException e) { - ProjectLogger.log("Error in getResponse HttpUtil:", e); - throw e; - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - ProjectLogger.log("Error while closing the reader:", e); - } - } - if (inStream != null) { - try { - inStream.close(); - } catch (IOException e) { - ProjectLogger.log("Error while closing the stream:", e); - } - } - if (httpURLConnection != null) { - httpURLConnection.disconnect(); - } - } - return builder.toString(); - } - - /** - * Makes an HTTP request using PATCH method to the specified URL. - * - * @param requestURL the URL of the remote server - * @param params A map containing POST data in form of key-value pairs - * @return An HttpURLConnection object - * @throws IOException thrown if any I/O error occurred - */ - public static String sendPatchRequest( - String requestURL, String params, Map headers) throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - ProjectLogger.log( - "HttpUtil sendPatchRequest method started at ==" - + startTime - + " for requestURL and params " - + requestURL - + " param==" - + params, - LoggerEnum.PERF_LOG); - - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpPatch patch = new HttpPatch(requestURL); - setHeaders(patch, headers); - StringEntity entity = new StringEntity(params); - patch.setEntity(entity); - CloseableHttpResponse response = httpClient.execute(patch); - if (response.getStatusLine().getStatusCode() == ResponseCode.OK.getResponseCode()) { - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil sendPatchRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return ResponseCode.success.getErrorCode(); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "Patch request failure status code ==" - + response.getStatusLine().getStatusCode() - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return "Failure"; - } catch (Exception e) { - ProjectLogger.log("HttpUtil call fails == " + e.getMessage(), e); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - telemetryProcessingCall(logInfo); - ProjectLogger.log( - "HttpUtil sendPatchRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - return "Failure"; - } - - /** - * Set the header for request. - * - * @param httpPatch HttpURLConnection - * @param headers Map - */ - private static void setHeaders(HttpPatch httpPatch, Map headers) { - Iterator> itr = headers.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - httpPatch.setHeader(entry.getKey(), entry.getValue()); - } - } - - /** - * Set the header for request. - * - * @param httpURLConnection HttpURLConnection - * @param headers Map - */ - private static void setHeaders(HttpURLConnection httpURLConnection, Map headers) { - Iterator> itr = headers.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue()); - } - } - - private static Map genarateLogInfo(String logType, String message) { - - Map info = new HashMap<>(); - info.put(JsonKey.LOG_TYPE, logType); - long startTime = System.currentTimeMillis(); - info.put(JsonKey.START_TIME, startTime); - info.put(JsonKey.MESSAGE, message); - info.put(JsonKey.LOG_LEVEL, JsonKey.INFO); - return info; - } - - public static void telemetryProcessingCall(Map request) { - - Map logInfo = request; - long endTime = System.currentTimeMillis(); - logInfo.put(JsonKey.END_TIME, endTime); - Request req = new Request(); - req.setRequest(generateTelemetryRequest(TelemetryEvents.LOG.getName(), logInfo)); - // lmaxWriter.submitMessage(req); - - } - - private static Map generateTelemetryRequest( - String eventType, Map params) { - - Map context = new HashMap<>(); - context.putAll(ExecutionContext.getCurrent().getRequestContext()); - context.putAll(ExecutionContext.getCurrent().getGlobalContext()); - Map map = new HashMap<>(); - map.put(JsonKey.TELEMETRY_EVENT_TYPE, eventType); - map.put(JsonKey.CONTEXT, context); - map.put(JsonKey.PARAMS, params); - return map; - } - - /** - * @description this method will send the patch request and in response it will return Map of - * status code with patch method response in String format - * @param requestURL - * @param params - * @param headers (Map) - * @return HttpUtilResponse - * @throws IOException - */ - public static HttpUtilResponse doPatchRequest( - String requestURL, String params, Map headers) throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + requestURL); - ProjectLogger.log( - "HttpUtil sendPatchRequest method started at ==" - + startTime - + " for requestURL " - + requestURL, - LoggerEnum.PERF_LOG); - - HttpPatch patch = new HttpPatch(requestURL); - setHeaders(patch, headers); - StringEntity entity = new StringEntity(params); - patch.setEntity(entity); - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - ProjectLogger.log("response code for Patch Resques"); - HttpResponse httpResponse = httpClient.execute(patch); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil doPatchRequest method end at ==" - + stopTime - + " for requestURL " - + requestURL - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - // telemetryProcessingCall(logInfo); - return response; - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - throw e; - } - } - - /** - * @description this method will post the form data and in response it will return Map of status - * code with post response in String format - * @param reqData (Map) - * @param fileData (Map) - * @param headers (Map) - * @param url - * @return HttpUtilResponse - * @throws IOException - */ - public static HttpUtilResponse postFormData( - Map reqData, - Map fileData, - Map headers, - String url) - throws IOException { - long startTime = System.currentTimeMillis(); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + url); - ProjectLogger.log( - "HttpUtil postFormData method started at ==" + startTime + " for requestURL " + url, - LoggerEnum.PERF_LOG); - try (CloseableHttpClient client = HttpClients.createDefault()) { - HttpPost httpPost = new HttpPost(url); - Set> headerEntry = headers.entrySet(); - for (Entry headerObj : headerEntry) { - httpPost.addHeader(headerObj.getKey(), headerObj.getValue()); - } - - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - Set> entry = reqData.entrySet(); - for (Entry entryObj : entry) { - builder.addTextBody( - entryObj.getKey(), - entryObj.getValue(), - ContentType.create("text/plain", MIME.UTF8_CHARSET)); - } - Set> fileEntry = fileData.entrySet(); - for (Entry entryObj : fileEntry) { - if (!StringUtils.isBlank(entryObj.getKey()) && null != entryObj.getValue()) { - builder.addBinaryBody( - entryObj.getKey(), - entryObj.getValue(), - ContentType.APPLICATION_OCTET_STREAM, - entryObj.getKey()); - } - } - HttpEntity multipart = builder.build(); - httpPost.setEntity(multipart); - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil postFormData method end at ==" - + stopTime - + " for requestURL " - + url - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - HttpResponse httpResponse = client.execute(httpPost); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - telemetryProcessingCall(logInfo); - return response; - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while calling postFormData method.", ex); - throw ex; - } - } - - private static String generateResponse(HttpResponse httpResponse) throws IOException { - StringBuilder builder1 = new StringBuilder(); - BufferedReader br = - new BufferedReader(new InputStreamReader((httpResponse.getEntity().getContent()))); - String output; - while ((output = br.readLine()) != null) { - builder1.append(output); - } - return builder1.toString(); - } - - /** - * @description this method will process send delete request and in response it will return Map of - * status code with post response in String format - * @param headers - * @param url - * @return HttpUtilResponse - * @throws IOException - */ - public static HttpUtilResponse sendDeleteRequest(Map headers, String url) - throws IOException { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "HttpUtil sendDeleteRequest method started at ==" + startTime + " for requestURL " + url, - LoggerEnum.PERF_LOG); - try (CloseableHttpClient httpclient = HttpClients.createDefault()) { - HttpDelete httpDelete = new HttpDelete(url); - ProjectLogger.log("Executing sendDeleteRequest " + httpDelete.getRequestLine()); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + url); - Set> headerEntry = headers.entrySet(); - for (Entry headerObj : headerEntry) { - httpDelete.addHeader(headerObj.getKey(), headerObj.getValue()); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil sendDeleteRequest method end at ==" - + stopTime - + " for requestURL " - + url - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - HttpResponse httpResponse = httpclient.execute(httpDelete); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - telemetryProcessingCall(logInfo); - return response; - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while calling sendDeleteRequest method.", ex); - throw ex; - } - } - - /** - * @description this method will process send delete request and in response it will return Map of - * status code with post response in String format - * @param headers - * @param url - * @param reqBody Map - * @return HttpUtilResponse - * @throws IOException - */ - public static HttpUtilResponse sendDeleteRequest( - Map reqBody, Map headers, String url) throws IOException { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "HttpUtil sendDeleteRequest method started at ==" + startTime + " for requestURL " + url, - LoggerEnum.PERF_LOG); - try (CloseableHttpClient httpclient = HttpClients.createDefault()) { - ObjectMapper mapper = new ObjectMapper(); - String reqString = mapper.writeValueAsString(reqBody); - HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url); - StringEntity input = new StringEntity(reqString, ContentType.APPLICATION_JSON); - httpDelete.setEntity(input); - ProjectLogger.log("Executing sendDeleteRequest " + httpDelete.getRequestLine()); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + url); - Set> headerEntry = headers.entrySet(); - for (Entry headerObj : headerEntry) { - httpDelete.addHeader(headerObj.getKey(), headerObj.getValue()); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil sendDeleteRequest method end at ==" - + stopTime - + " for requestURL " - + url - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - HttpResponse httpResponse = httpclient.execute(httpDelete); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - telemetryProcessingCall(logInfo); - return response; - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while calling sendDeleteRequest method.", ex); - throw ex; - } - } - - /** - * this method call the http post method which accept post body as byte[] - * - * @param byteArr - * @param headers - * @param url - * @return - * @throws IOException - */ - public static HttpUtilResponse postInputStream( - byte[] byteArr, Map headers, String url) throws IOException { - try (CloseableHttpClient client = HttpClients.createDefault()) { - HttpPost httpPost = new HttpPost(url); - HttpEntity entity = new ByteArrayEntity(byteArr); - httpPost.setEntity(entity); - Set> headerEntry = headers.entrySet(); - for (Entry headerObj : headerEntry) { - httpPost.addHeader(headerObj.getKey(), headerObj.getValue()); - } - HttpResponse httpResponse = client.execute(httpPost); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - return response; - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while calling posting inputStream data method.", ex); - throw ex; - } - } - - /** - * @description this method will process send delete request and in response it will return Map of - * status code with post response in String format - * @param headers - * @param url - * @param reqBody as JSON String - * @return HttpUtilResponse - * @throws IOException - */ - public static HttpUtilResponse sendDeleteRequest( - String reqBody, Map headers, String url) throws IOException { - long startTime = System.currentTimeMillis(); - ProjectLogger.log( - "HttpUtil sendDeleteRequest method started at ==" + startTime + " for requestURL " + url, - LoggerEnum.PERF_LOG); - try (CloseableHttpClient httpclient = HttpClients.createDefault()) { - HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url); - StringEntity input = new StringEntity(reqBody, ContentType.APPLICATION_JSON); - httpDelete.setEntity(input); - ProjectLogger.log("Executing sendDeleteRequest " + httpDelete.getRequestLine()); - Map logInfo = genarateLogInfo(JsonKey.API_CALL, "API CALL : " + url); - Set> headerEntry = headers.entrySet(); - for (Entry headerObj : headerEntry) { - httpDelete.addHeader(headerObj.getKey(), headerObj.getValue()); - } - long stopTime = System.currentTimeMillis(); - long elapsedTime = stopTime - startTime; - ProjectLogger.log( - "HttpUtil sendDeleteRequest method end at ==" - + stopTime - + " for requestURL " - + url - + " ,Total time elapsed = " - + elapsedTime, - LoggerEnum.PERF_LOG); - HttpResponse httpResponse = httpclient.execute(httpDelete); - HttpUtilResponse response = null; - String body = ""; - try { - body = generateResponse(httpResponse); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while reading body" + ex); - } - response = new HttpUtilResponse(body, httpResponse.getStatusLine().getStatusCode()); - telemetryProcessingCall(logInfo); - return response; - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while calling sendDeleteRequest method.", ex); - throw ex; - } - } - - public static Map getHeader(Map input) throws Exception { - return new HashMap() {{ - put("Content-Type", "application/json"); - put(JsonKey.X_AUTHENTICATED_USER_TOKEN, KeycloakRequiredActionLinkUtil.getAdminAccessToken()); - if(MapUtils.isNotEmpty(input)) - putAll(input); - }}; - } -} - -@NotThreadSafe -class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { - public static final String METHOD_NAME = "DELETE"; - - @Override - public String getMethod() { - return METHOD_NAME; - } - - public HttpDeleteWithBody(final String uri) { - super(); - setURI(URI.create(uri)); - } - - public HttpDeleteWithBody(final URI uri) { - super(); - setURI(uri); - } - - public HttpDeleteWithBody() { - super(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java deleted file mode 100644 index d2c5b0abd..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java +++ /dev/null @@ -1,1027 +0,0 @@ -package org.sunbird.common.models.util; - -/** - * This class will contains all the key related to request and response. - * - * @author Manzarul - */ -public final class JsonKey { - public static final String ANONYMOUS = "Anonymous"; - public static final String UNAUTHORIZED = "Unauthorized"; - public static final String MW_SYSTEM_HOST = "sunbird_mw_system_host"; - public static final String MW_SYSTEM_PORT = "sunbird_mw_system_port"; - public static final String MW_SYSTEM_CLIENT_PORT = "sunbird_mw_system_client_port"; - public static final String ACCESS_TOKEN = "access_token"; - public static final String ACCESSTOKEN = "accessToken"; - public static final String ACCOUNT_KEY = "sunbird_account_key"; - public static final String ACCOUNT_NAME = "sunbird_account_name"; - public static final String DOWNLOAD_LINK_EXPIRY_TIMEOUT = "download_link_expiry_timeout"; - public static final String SIGNED_URL = "signedUrl"; - public static final String REPORTS = "reports"; - public static final String PROGRESS_REPORT_SIGNED_URL = "courseProgressReportUrl"; - public static final String ASSESSMENT_REPORT_BLOB_URL = "reportUrl"; - public static final String ASSESSMENT_REPORT_SIGNED_URL = "assessmentReportUrl"; - public static final String BULK_UPLOAD_STATUS = "Status"; - public static final String BULK_UPLOAD_ERROR = "Remarks"; - public static final String ACTION_GROUP = "action_group"; - public static final String ACTION_GROUPS = "actionGroups"; - public static final String ACTION_NAME = "actionName"; - public static final String ACTION_URL = "actionUrl"; - public static final String ACTIONS = "actions"; - public static final String ACTIVE = "active"; - public static final String ACTOR_ID = "actorId"; - public static final String ACTOR_SERVICE = "Actor service"; - public static final String ACTOR_TYPE = "actorType"; - public static final String ADD_TYPE = "addType"; - public static final String ADDED_AT = "addedAt"; - public static final String ADDED_BY = "addedBy"; - public static final String ADDED_BY_NAME = "addedByName"; - public static final String ADDITIONAL_INFO = "ADDITIONAL_INFO"; - public static final String ADDRESS = "address"; - public static final String ADDRESS_DB = "address"; - public static final String ADDRESS_ID = "addressId"; - public static final String ADDRESS_LINE1 = "addressLine1"; - public static final String ADDRESS_LINE2 = "addressLine2"; - public static final String ADDRESS_TYPE = "address type"; - public static final String AGGREGATIONS = "aggregations"; - public static final String ALL = "all"; - public static final String ALLOWED_LOGIN = "allowedLogin"; - public static final String ANNOUNCEMENT = "announcement"; - public static final String API_ACCESS = "api_access"; - public static final String API_ACTOR_PROVIDER = "api_actor_provider"; - public static final String API_CALL = "API_CALL"; - public static final String API_ID = "apiId"; - public static final String APP_ICON = "appIcon"; - public static final String APP_MAP = "appMap"; - public static final String APP_SECTIONS = "appSections"; - public static final String APP_URL = "appUrl"; - public static final String APPICON = "appIcon"; - public static final String APPLICABLE_FOR = "applicableFor"; - public static final String APPROOVE_DATE = "approvalDate"; - public static final String APPROVED_BY = "approvedBy"; - public static final String APPROVED_BY_NAME = "approvedByName"; - public static final String APPROVED_DATE = "approvedDate"; - public static final String ASSESSMENT = "assessment"; - public static final String ASSESSMENT_EVENTS = "assessments"; - public static final String ASSESSMENT_TS = "assessmentTs"; - public static final String ASSESSMENT_ANSWERS = "answers"; - public static final String ASSESSMENT_ATTEMPT_DATE = "attemptedDate"; - public static final String ASSESSMENT_EVAL_DB = "assessment_eval_db"; - public static final String ASSESSMENT_GRADE = "grade"; - public static final String ASSESSMENT_ITEM_DB = "assessment_item_db"; - public static final String ASSESSMENT_ITEM_ID = "assessmentItemId"; - public static final String ASSESSMENT_MAX_SCORE = "maxScore"; - public static final String ASSESSMENT_SCORE = "score"; - public static final String ASSESSMENT_STATUS = "assessmentStatus"; - public static final String ASSESSMENT_TYPE = "assessmentType"; - public static final String ATTEMPT_ID = "attemptId"; - public static final String ATTEMPTED_COUNT = "attemptedCount"; - public static final String AUTH_TOKEN = "authToken"; - public static final String AUTH_USER_HEADER = "X-Authenticated-Userid"; - public static final String AUTH_WITH_MASTER_KEY = "authWithMasterKey"; - public static final String AUTHORIZATION = "Authorization"; - public static final String BACKGROUND_ACTOR_PROVIDER = "background_actor_provider"; - public static final String BAD_REQUEST = "badRequest"; - public static final String BADGE_TYPE_ID = "badgeTypeId"; - public static final String BADGES = "badges"; - public static final String BADGES_DB = "badge"; - public static final String BATCH = "batch"; - public static final String BATCH_ID = "batchId"; - public static final String BATCH_RELATIONS = "batch_relations"; - public static final String BEARER = "Bearer "; - public static final String BLOCKED = "blocked"; - public static final String BODY = "body"; - public static final String BULK_OP_DB = "BulkOpDb"; - public static final String BULK_UPLOAD_BATCH_DATA_SIZE = "bulk_upload_batch_data_size"; - public static final String BULK_UPLOAD_ORG_DATA_SIZE = "bulk_upload_org_data_size"; - public static final String BULK_UPLOAD_USER_DATA_SIZE = "sunbird_user_bulk_upload_size"; - public static final String BULK_USER_UPLOAD = "bulkUserUpload"; - public static final String CASSANDRA_IN_EMBEDDED_MODE = "cassandraInEmbeddedMode"; - public static final String CASSANDRA_SERVICE = "Cassandra service"; - public static final String CATEGORIES = "categories"; - public static final String CHANNEL = "channel"; - public static final String CHANNEL_REG_STATUS = "channelRegStatus"; - public static final String CHANNEL_REG_STATUS_ID = "003"; - public static final String CHANNELS = "channels"; - public static final String CHECKS = "checks"; - public static final String CHILD_OF = "childOf"; - public static final String CHILDREN = "children"; - public static final String CITY = "city"; - public static final String CLASS = "class"; - public static final String CLIENT_ID = "clientId"; - public static final String CLIENT_INFO_DB = "clientInfo_db"; - public static final String CLIENT_NAME = "clientName"; - public static final String CLIENT_NAMES = "client.names"; - public static final String CODE = "code"; - public static final String COMPLETED_COUNT = "completedCount"; - public static final String COMPLETENESS = "completeness"; - public static final String CONSUMER = "consumer"; - public static final String CONTACT_DETAILS = "contactDetail"; - public static final String CONTAINER = "container"; - public static final String CONTENT = "content"; - public static final String CONTENT_CREATOR = "CONTENT_CREATOR"; - public static final String CONTENT_ID = "contentId"; - public static final String CONTENT_IDS = "contentIds"; - public static final String CONTENT_LIST = "contentList"; - public static final String CONTENT_NAME = "contentName"; - public static final String CONTENT_PROGRESS = "progress"; - public static final String CONTENT_TYPE = "contentType"; - public static final String CONTENT_VERSION = "contentVersion"; - public static final String CONTENTS = "contents"; - public static final String CONTEXT = "context"; - public static final String CORRELATED_OBJECTS = "correlatedObjects"; - public static final String COUNT = "count"; - public static final String COUNT_DECREMENT_DATE = "countDecrementDate"; - public static final String COUNT_INCREMENT_DATE = "countIncrementDate"; - public static final String COUNTER_DECREMENT_STATUS = "countDecrementStatus"; - public static final String COUNTER_INCREMENT_STATUS = "countIncrementStatus"; - public static final String COUNTRY = "country"; - public static final String COUNTRY_CODE = "countryCode"; - public static final String COURSE = "course"; - public static final String COURSE_ADDITIONAL_INFO = "courseAdditionalInfo"; - public static final String COURSE_BATCH_DB = "courseBatchDB"; - public static final String COURSE_CREATED_FOR = "createdFor"; - public static final String COURSE_CREATOR = "courseCreator"; - public static final String COURSE_DURATION = "courseDuration"; - public static final String COURSE_ENROLL_DATE = "enrolledDate"; - public static final String COURSE_ID = "courseId"; - public static final String COURSE_IDS = "courseIds"; - public static final String COURSE_LIST = "courseList"; - public static final String COURSE_LOGO_URL = "courseLogoUrl"; - public static final String COURSE_MANAGEMENT_DB = "courseManagement_db"; - public static final String COURSE_NAME = "courseName"; - public static final String COURSE_PROGRESS = "progress"; - public static final String COURSE_PUBLISHED_STATUS = "course_publish_status"; - public static final String COURSE_VERSION = "courseVersion"; - public static final String CourseConsumption = "courseConsumption"; - public static final String CourseProgress = "courseProgress"; - public static final String COURSES = "courses"; - public static final String CREATE = "create"; - public static final String CREATED_BY = "createdBy"; - public static final String CREATED_DATE = "createdDate"; - public static final String CRITERIA = "criteria"; - public static final String CURRENT_LOGIN_TIME = "currentLoginTime"; - public static final String CURRENT_STATE = "CURRENT_STATE"; - public static final String DASHBOARD = "dashboard"; - public static final String DATA = "data"; - public static final String KEY = "key"; - public static final String KEYS = "keys"; - public static final String DATE = "date"; - public static final String DATE_HISTOGRAM = "DATE_HISTOGRAM"; - public static final String DATE_TIME = "dateTime"; - public static final String DB_IP = "db.ip"; - public static final String DB_KEYSPACE = "db.keyspace"; - public static final String DB_PASSWORD = "db.password"; - public static final String DB_PORT = "db.port"; - public static final String DB_USERNAME = "db.username"; - public static final String DEFAULT_ACTION_NAME = "Download Reports"; - public static final String DEFAULT_CONSUMER_ID = "internal"; - public static final String DEFAULT_ROOT_ORG_ID = "ORG_001"; - public static final String DEGREE = "degree"; - public static final String DELETE = "delete"; - public static final String DELTA = "delta"; - public static final String DESCRIPTION = "description"; - public static final String DOB = "dob"; - public static final String DOWNLOAD_URL = "downloadUrl"; - public static final String DUPLICATE = "duplicate"; - public static final String EDUCATION = "education"; - public static final String EDUCATION_DB = "user_education"; - public static final String EKS = "eks"; - public static final String SEARCH_SERVICE_API_BASE_URL = "sunbird_search_service_api_base_url"; - public static final String ANALYTICS_API_BASE_URL = "sunbird_analytics_api_base_url"; - public static final String EKSTEP_AUTHORIZATION = "ekstep_authorization"; - public static final String EKSTEP_BASE_URL = "ekstep_api_base_url"; - public static final String EKSTEP_CHANNEL_REG_API_URL = "ekstep.channel.reg.api.url"; - public static final String EKSTEP_CHANNEL_UPDATE_API_URL = "ekstep.channel.update.api.url"; - public static final String EKSTEP_CONCEPT_URL = "ekstep_concept_base_url"; - public static final String EKSTEP_CONTENT_SEARCH_BASE_URL = "ekstep_content_search_base_url"; - public static final String EKSTEP_CONTENT_SEARCH_URL = "ekstep_content_search_url"; - public static final String EKSTEP_CONTENT_UPDATE_URL = "ekstep.content.update.url"; - public static final String EKSTEP_CONTENT_URL = "content_url"; - public static final String EKSTEP_COURSE_PUBLISH_URL = "ekstep_course_publish_url"; - public static final String EKSTEP_DOMAIN_URL = "ekstep_domain_url"; - public static final String EKSTEP_ES_METRICS_API_URL = "ekstep_es_metrics_api_url"; - public static final String EKSTEP_GET_CHANNEL_LIST = "ekstep.channel.list.api.url"; - public static final String EKSTEP_METRICS_API_URL = "ekstep_metrics_api_url"; - public static final String EKSTEP_METRICS_AUTHORIZATION = "ekstep_metrics_authorization"; - public static final String EKSTEP_METRICS_URL = "ekstep_metrics_base_url"; - public static final String EKSTEP_SERVICE = "EkStep service"; - public static final String EKSTEP_TAG_API_URL = "ekstep.tag.api.url"; - public static final String EKSTEP_TELEMETRY_API_URL = "ekstep_telemetry_api_url"; - public static final String EKSTEP_TELEMETRY_BASE_URL = "ekstep_telemetry_api_base_url"; - public static final String EKSTEP_TELEMETRY_V3_URL = "eksetp_telemetry_V3_url"; - public static final String EMAIL = "email"; - public static final String EMAIL_REQUEST = "emailReq"; - public static final String EMAIL_SERVER_FROM = "sunbird_mail_server_from_email"; - public static final String EMAIL_SERVER_HOST = "sunbird_mail_server_host"; - public static final String EMAIL_SERVER_PASSWORD = "sunbird_mail_server_password"; - public static final String EMAIL_SERVER_PORT = "sunbird_mail_server_port"; - public static final String EMAIL_SERVER_USERNAME = "sunbird_mail_server_username"; - public static final String EMAIL_TEMPLATE_TYPE = "emailTemplateType"; - public static final String EMAIL_UNIQUE = "emailUnique"; - public static final String EMAIL_VERIFIED = "emailVerified"; - public static final String EMAIL_VERIFIED_UPDATED = "emailVerifiedUpdated"; - public static final String EMBEDDED = "embedded"; - public static final String EMBEDDED_CASSANDRA_HOST = "embedded_cassandra_host"; - public static final String EMBEDDED_CASSANDRA_PORT = "embedded_cassandra_port"; - public static final String EMBEDDED_CQL_FILE_NAME = "embedded_cql_file_name"; - public static final String EMBEDDED_MODE = "embedded"; - public static final String ENC_EMAIL = "encEmail"; - public static final String ENC_PHONE = "encPhone"; - public static final String ENCRYPTION_KEY = "sunbird_encryption_key"; - public static final String END_DATE = "endDate"; - public static final String END_TIME = "endTime"; - public static final String ENDORSE_DATE = "endorseDate"; - public static final String ENDORSED_USER_ID = "endorsedUserId"; - public static final String ENDORSEMENT_COUNT = "endorsementCount"; - public static final String ENDORSERS = "endorsers"; - public static final String ENDORSERS_LIST = "endorsersList"; - public static final String ENROLLMENT_END_DATE = "enrollmentEndDate"; - public static final String ENROLLMENT_START_DATE = "enrollementStartDate"; - public static final String ENROLLMENT_TYPE = "enrollmentType"; - public static final String ENROLMENTTYPE = "enrolmentType"; - public static final String ENV = "env"; - public static final String ERR_TYPE = "errtype"; - public static final String ERROR = "err"; - public static final String ERROR_MSG = "err_msg"; - public static final String ERRORMSG = "errmsg"; - public static final String ES_METRICS_PORT = "es_metrics_port"; - public static final String ES_SERVICE = "Elastic search service"; - public static final String ES_URL = "es_search_url"; - public static final String ESTIMATED_COUNT_REQ = "estimatedCountReq"; - public static final String EVENTS = "events"; - public static final String EXISTS = "exists"; - public static final String EXTERNAL_ID = "externalId"; - public static final String EXTERNAL_ID_VALUE = "externalIdValue"; - public static final String FACETS = "facets"; - public static final String FAILED = "FAILED"; - public static final String FAILURE = "failure"; - public static final String FAILURE_RESULT = "failureResult"; - public static final String FCM = "fcm"; - public static final String FCM_URL = "fcm.url"; - public static final String FIELD = "field"; - public static final String FIELDS = "fields"; - public static final String FILE = "file"; - public static final String FILE_NAME = "fileName"; - public static final String FILE_PARAMS = "fileParams"; - public static final String FILE_URL = "fileUrl"; - public static final String FILTER = "filter"; - public static final String FILTERS = "filters"; - public static final String FIRST_NAME = "firstName"; - public static final String FORM_PARAMS = "formParams"; - public static final String FORMAT = "format"; - public static final String FRAMEWORK = "framework"; - public static final String FROM_EMAIL = "fromEmail"; - public static final String GENDER = "gender"; - public static final String GEO_LOCATION_DB = "geoLocationDb"; - public static final String GRADE = "grade"; - public static final String GRADE_LEVEL = "gradeLevel"; - public static final String GROUP = "group"; - public static final String GROUP_QUERY = "groupQuery"; - public static final String HASH_TAG_ID = "hashtagid"; - public static final String HASHTAGID = "hashTagId"; - public static final String HEADER = "header"; - public static final String Healthy = "healthy"; - public static final String HOME_URL = "homeUrl"; - public static final String ID = "id"; - public static final String IDENTIFIER = "identifier"; - public static final String IMAGE = "image"; - public static final String INACTIVE = "inactive"; - public static final String INDEX = "index"; - public static final String INFO = "info"; - public static final String INSERT = "insert"; - public static final String INVITE_ONLY = "invite-only"; - public static final String IS_APPROVED = "isApproved"; - public static final String IS_AUTH_REQ = "isAuthReq"; - public static final String IS_DEFAULT = "isDefault"; - public static final String IS_DELETED = "isDeleted"; - public static final String IS_REJECTED = "isRejected"; - public static final String IS_ROOT_ORG = "isRootOrg"; - public static final String IS_SSO_ENABLED = "sso.enabled"; - public static final String IS_VERIFIED = "isVerified"; - public static final String JOB_NAME = "jobName"; - public static final String JOB_PROFILE = "jobProfile"; - public static final String JOB_PROFILE_DB = "user_job_profile"; - public static final String JOINING_DATE = "joiningDate"; - public static final String LANGUAGE = "language"; - public static final String LAST_ACCESS_TIME = "lastAccessTime"; - public static final String LAST_COMPLETED_TIME = "lastCompletedTime"; - public static final String LAST_LOGIN_TIME = "lastLoginTime"; - public static final String LAST_LOGOUT_TIME = "lastLogoutTime"; - public static final String LAST_NAME = "lastName"; - public static final String LAST_READ_CONTENT_STATUS = "lastReadContentStatus"; - public static final String LAST_READ_CONTENT_VERSION = "lastReadContentVersion"; - public static final String LAST_READ_CONTENTID = "lastReadContentId"; - public static final String LAST_UPDATED_TIME = "lastUpdatedTime"; - public static final String LEAF_NODE_COUNT = "leafNodesCount"; - public static final String LEARNER_CONTENT_DB = "learnerContent_db"; - public static final String LEARNER_COURSE_DB = "learnerCourse_db"; - public static final String LEARNER_SERVICE = "Learner service"; - public static final String LEVEL = "level"; - public static final String LIMIT = "limit"; - public static final String LIST = "List"; - public static final String LOC_ID = "locationId"; - public static final String LOCATION = "location"; - public static final String LOCATION_NAME = "locationName"; - public static final String LOCATION_ID = "locationId"; - public static final String LOCATION_IDS = "locationIds"; - public static final String LOCATIONS = "locations"; - public static final String LOG_LEVEL = "logLevel"; - public static final String LOG_RECORD = "logRecord"; - public static final String LOG_TYPE = "logType"; - public static final String LOGIN_GENERAL = "general"; - public static final String LOGIN_ID = "loginId"; - public static final String LOGIN_ID_DELIMETER = "@"; - public static final String LOGIN_TYPE = "type"; - public static final String MAIL_NOTE = "mail_note"; - public static final String MANDATORY_FIELDS = "mandatoryFields"; - public static final String MAP = "map"; - public static final String MAPPED_FORM_PARAMS = "mappedFormParams"; - public static final String MASKED_EMAIL = "maskedEmail"; - public static final String MASKED_PHONE = "maskedPhone"; - public static final String MASTER_ACTION = "master_action"; - public static final String MASTER_KEY = "masterKey"; - public static final String MEDIA_TYPE_DB = "mediaTypeDB"; - public static final String MENTORS = "mentors"; - public static final String MESSAGE = "message"; - public static final String MESSAGE_Id = "message_id"; - public static final String MESSAGE_ID = "X-msgId"; - public static final String METHOD = "method"; - public static final String METHOD_NAME = "methodName"; - public static final String METRICS = "metrics"; - public static final String MISSING_FIELDS = "missingFields"; - public static final String MOBILE = "mobile"; - public static final String NAME = "name"; - public static final String NEW_PASSWORD = "newPassword"; - public static final String NO_OF_LECTURES = "noOfLectures"; - public static final String NO_OF_MEMBERS = "noOfMembers"; - public static final String NOT_AVAILABLE = "NA"; - public static final String NOT_EXISTS = "not_exists"; - public static final String NOTE = "note"; - public static final String NOTE_ID = "noteId"; - public static final String NOTIFICATION = "notification"; - public static final String NULL = "null"; - public static final String OBJECT_ID = "objectId"; - public static final String OBJECT_IDS = "objectIds"; - public static final String OBJECT_TYPE = "objectType"; - public static final String OFFSET = "offset"; - public static final String ON = "ON"; - public static final String ONBOARDING_WELCOME_MAIL_BODY = "onboarding_welcome_mail_body"; - public static final String OPEN = "open"; - public static final String OPERATION = "operation"; - public static final String OPERATION_FOR = "operationFor"; - public static final String OPERATION_TYPE = "operationType"; - public static final String ORDER = "order"; - public static final String ORG_CODE = "orgCode"; - public static final String ORG_CODE_HEADER = "X-Org-code"; - public static final String ORG_EXT_ID_DB = "org_external_identity"; - public static final String ORG_DB = "org_db"; - public static final String ORG_ID = "orgId"; - public static final String ORG_ID_ONE = "orgIdOne"; - public static final String ORG_ID_TWO = "orgIdTwo"; - public static final String ORG_IMAGE_URL = "orgImageUrl"; - public static final String ORG_JOIN_DATE = "orgJoinDate"; - public static final String ORG_LEFT_DATE = "orgLeftDate"; - public static final String ORG_MAP_DB = "org_mapping"; - public static final String ORG_NAME = "orgName"; - public static final String ORG_RELATIONS = "org_relations"; - public static final String ORG_SERVER_FROM_NAME = "orgServerFromName"; - public static final String ORG_TYPE = "orgType"; - public static final String ORG_TYPE_DB = "org_type"; - public static final String ORG_TYPE_ID = "orgTypeId"; - public static final String ORGANISATION = "organisation"; - public static final String ORGANISATION_ID = "organisationId"; - public static final String ORGANISATION_NAME = "orgName"; - public static final String ORGANISATIONS = "organisations"; - public static final String OrgConsumption = "orgConsumption"; - public static final String OrgCreation = "orgCreation"; - public static final String OTP = "otp"; - public static final String OTP_EMAIL_RESET_PASSWORD_TEMPLATE = "otpEmailResetPasswordTemplate"; - public static final String OTP_PHONE_RESET_PASSWORD_TEMPLATE = "otpPhoneResetPasswordTemplate"; - public static final String VERIFY_PHONE_OTP_TEMPLATE = "verifyPhoneOtpTemplate"; - public static final String PAGE = "page"; - public static final String PAGE_ID = "pageId"; - public static final String PAGE_MGMT_DB = "page_mgmt_db"; - public static final String PAGE_NAME = "name"; - public static final String PAGE_SECTION = "page_section"; - public static final String PAGE_SECTION_DB = "page_section_db"; - public static final String PARAMS = "params"; - public static final String PARENT_OF = "parentOf"; - public static final String PARENT_ORG_ID = "parentOrgId"; - public static final String PARTICIPANT = "participant"; - public static final String PARTICIPANTS = "participants"; - public static final String PASSWORD = "password"; - public static final String PDATA = "pdata"; - - public static final String PERCENTAGE = "percentage"; - public static final String PERIOD = "period"; - public static final String PHONE = "phone"; - public static final String PHONE_NUMBER_VERIFIED = "phoneNumberVerified"; - public static final String PHONE_UNIQUE = "phoneUnique"; - public static final String PHONE_VERIFIED = "phoneVerified"; - public static final String PID = "pid"; - public static final String PORTAL_MAP = "portalMap"; - public static final String PORTAL_SECTIONS = "portalSections"; - public static final String POSITION = "position"; - public static final String PREFERRED_LANGUAGE = "preferredLanguage"; - public static final String PREV_STATE = "PREV_STATE"; - public static final String PRIMARY_KEY_DELIMETER = "##"; - public static final String PRIVATE = "private"; - public static final String PROCESS_END_TIME = "processEndTime"; - public static final String PROCESS_ID = "processId"; - public static final String PROCESS_START_TIME = "processStartTime"; - public static final String PROCESSING_STATUS = "processingStatus"; - public static final String PDATA_ID = "telemetry_pdata_id"; - public static final String PDATA_PID = "telemetry_pdata_pid"; - public static final String PDATA_VERSION = "telemetry_pdata_ver"; - public static final String PROFILE_SUMMARY = "profileSummary"; - public static final String PROFILE_VISIBILITY = "profileVisibility"; - public static final String PROGRESS = "progress"; - public static final String PROPERTIES = "properties"; - public static final String PROPS = "props"; - public static final String PROVIDER = "provider"; - public static final String PUBLIC = "public"; - public static final String PUBLISH_COURSE = "publishCourse"; - public static final String QUERY = "query"; - public static final String QUERY_FIELDS = "queryFields"; - public static final String RECEIVER_ID = "receiverId"; - public static final String RECIPIENT_COUNT = "recipientCount"; - public static final String RECIPIENT_EMAILS = "recipientEmails"; - public static final String RECIPIENT_USERIDS = "recipientUserIds"; - public static final String RECOMMEND_TYPE = "recommendType"; - public static final String REGISTERED_ORG = "registeredOrg"; - public static final String REGISTERED_ORG_ID = "regOrgId"; - public static final String RELATION = "relation"; - public static final String RELATIONS = "relations"; - public static final String REMOTE = "remote"; - public static final String REPLACE_WITH_ASTERISK = "*"; - public static final String REPLACE_WITH_X = "X"; - public static final String REPORT_TRACKING_DB = "reportTrackingDb"; - public static final String REQ_ID = "reqId"; - public static final String REQUEST = "request"; - public static final String REQUEST_ID = "requestId"; - public static final String REQUEST_MESSAGE_ID = "msgId"; - public static final String REQUEST_TYPE = "requestType"; - public static final String REQUESTED_BY = "requestedBy"; - public static final String RES_MSG_ID = "resmsgId"; - public static final String RESOURCE_ID = "resourceId"; - public static final String RESPONSE = "response"; - public static final String RESULT = "result"; - public static final String RETIRED = "retired"; - public static final String RETRY_COUNT = "retryCount"; - public static final String ROLE = "role"; - public static final String ROLE_GROUP = "role_group"; - public static final String ROLE_GROUP_ID = "rolegroupid"; - public static final String ROLES = "roles"; - public static final String ROLLUP = "rollup"; - public static final String ROOT_ORG = "rootOrg"; - public static final String ROOT_ORG_ID = "rootOrgId"; - public static final String SCHEDULER_JOB = "scheduler"; - public static final String SEARCH = "search"; - public static final String SEARCH_QUERY = "searchQuery"; - public static final String SEARCH_TOP_N = "searchTopN"; - public static final String SECTION = "section"; - public static final String SECTION_DATA_TYPE = "sectionDataType"; - public static final String SECTION_DISPLAY = "display"; - public static final String SECTION_ID = "sectionId"; - public static final String SECTION_MGMT_DB = "section_mgmt_db"; - public static final String SECTION_NAME = "name"; - public static final String SECTIONS = "sections"; - public static final String SERIES = "series"; - public static final String SIZE = "size"; - public static final String SKILL_ENDORSEMENT_DB = "skillEndorsementDb"; - public static final String SKILL_NAME = "skillName"; - public static final String SKILL_NAME_TO_LOWERCASE = "skillnametolowercase"; - public static final String SKILLS = "skills"; - public static final String SKILLS_LIST_DB = "skillsListDb"; - public static final String SLUG = "slug"; - public static final String SNAPSHOT = "snapshot"; - public static final String SORT = "sort"; - public static final String SORT_BY = "sort_by"; - public static final String SOURCE = "source"; - public static final String SOURCE_HEADER = "X-Source"; - public static final String SPLIT = "split"; - public static final String SSO_CLIENT_ID = "sso.client.id"; - public static final String SSO_CLIENT_SECRET = "sso.client.secret"; - public static final String SSO_PASSWORD = "sso.password"; - public static final String SSO_POOL_SIZE = "sso.connection.pool.size"; - public static final String SSO_PUBLIC_KEY = "sunbird_sso_publickey"; - public static final String SSO_REALM = "sso.realm"; - public static final String SSO_URL = "sso.url"; - public static final String SSO_USERNAME = "sso.username"; - public static final String STACKTRACE = "stacktrace"; - public static final String STANDALONE_MODE = "standalone"; - public static final String START_DATE = "startDate"; - public static final String START_TIME = "startTime"; - public static final String STATE = "state"; - public static final String STATUS = "status"; - public static final String STATUS_CODE = "statusCode"; - public static final String SUB_SECTIONS = "subSections"; - public static final String SUBJECT = "subject"; - public static final String SUBMIT_DATE = "submitDate"; - public static final String SUBTYPE = "subtype"; - public static final String SUCCESS = "SUCCESS"; - public static final String SUCCESS_RESULT = "successResult"; - public static final String SUMMARY = "summary"; - public static final String SUNBIRD = "sunbird"; - public static final String SUNBIRD_ALLOWED_LOGIN = "sunbird_allowed_login"; - public static final String SUNBIRD_APP_URL = "sunbird_app_url"; - public static final String SUNBIRD_API_BASE_URL = "sunbird_api_base_url"; - public static final String SUNBIRD_CASSANDRA_IP = "sunbird_cassandra_host"; - public static final String SUNBIRD_CASSANDRA_KEYSPACE = "sunbird_cassandra_keyspace"; - public static final String SUNBIRD_CASSANDRA_MODE = "sunbird_cassandra_mode"; - public static final String SUNBIRD_CASSANDRA_PASSWORD = "sunbird_cassandra_password"; - public static final String SUNBIRD_CASSANDRA_PORT = "sunbird_cassandra_port"; - public static final String SUNBIRD_CASSANDRA_USER_NAME = "sunbird_cassandra_username"; - public static final String SUNBIRD_ENCRYPTION = "sunbird_encryption"; - public static final String SUNBIRD_ENV_LOGO_URL = "sunbird_env_logo_url"; - public static final String SUNBIRD_ES_CHANNEL = "es.channel.name"; - public static final String SUNBIRD_ES_CLUSTER = "sunbird_es_cluster"; - public static final String SUNBIRD_ES_IP = "sunbird_es_host"; - public static final String SUNBIRD_ES_PORT = "sunbird_es_port"; - public static final String SUNBIRD_FCM_ACCOUNT_KEY = "sunbird_fcm_account_key"; - public static final String SUNBIRD_INSTALLATION = "sunbird_installation"; - public static final String SUNBIRD_NETTY_HOST = "sunbird_netty_host"; - public static final String SUNBIRD_NETTY_PORT = "sunbird_netty_port"; - public static final String SUNBIRD_PG_DB = "sunbird_pg_db"; - public static final String SUNBIRD_PG_HOST = "sunbird_pg_host"; - public static final String SUNBIRD_PG_PASSWORD = "sunbird_pg_password"; - public static final String SUNBIRD_PG_PORT = "sunbird_pg_port"; - public static final String SUNBIRD_PG_USER = "sunbird_pg_user"; - public static final String SUNBIRD_QUARTZ_MODE = "sunbird_quartz_mode"; - public static final String SUNBIRD_SSO_CLIENT_ID = "sunbird_sso_client_id"; - public static final String SUNBIRD_SSO_CLIENT_SECRET = "sunbird_sso_client_secret"; - public static final String SUNBIRD_SSO_PASSWORD = "sunbird_sso_password"; - public static final String SUNBIRD_SSO_RELAM = "sunbird_sso_realm"; - public static final String SUNBIRD_SSO_URL = "sunbird_sso_url"; - public static final String SUNBIRD_SSO_USERNAME = "sunbird_sso_username"; - public static final String SUNBIRD_WEB_URL = "sunbird_web_url"; - public static final String SUNBIRD_GET_ORGANISATION_API = "sunbird_search_organisation_api"; - public static final String SUNBIRD_GET_SINGLE_USER_API = "sunbird_read_user_api"; - public static final String SUNBIRD_GET_MULTIPLE_USER_API = "sunbird_search_user_api"; - public static final String SUNBIRD_CHANNEL_READ_API = "sunbird_channel_read_api"; - public static final String SUNBIRD_FRAMEWORK_READ_API = "sunbird_framework_read_api"; - public static final String SUNBIRD_CONTENT_GET_HIERARCHY_API = "sunbird_get_hierarchy_api"; - public static final String SUNBIRD_CONTENT_READ_API = "sunbird_content_read_api"; - public static final String SUNBIRD_USERNAME_NUM_DIGITS = "sunbird_username_num_digits"; - public static final String SYSTEM = "system"; - public static final String SYSTEM_SETTINGS_DB = "system_settings"; - public static final String TAG = "tag"; - public static final String TAGS = "tags"; - public static final String TARGET_OBJECT = "targetObject"; - public static final String TC_UPDATED_DATE = "tcUpdatedAt"; - public static final String TELEMETRY_CONTEXT = "TELEMETRY_CONTEXT"; - public static final String TELEMETRY_EVENT_TYPE = "telemetryEventType"; - public static final String TELEMETRY_QUEUE_THRESHOLD_VALUE = "telemetry_queue_threshold_value"; - public static final String TEMPORARY_PASSWORD = "tempPassword"; - public static final String TENANT_PREFERENCE = "tenantPreference"; - public static final String TENANT_PREFERENCE_DB = "tenantPreferenceDb"; - public static final String TERM_AND_CONDITION_STATUS = "tcStatus"; - public static final String TERMS = "terms"; - public static final String THEME = "theme"; - public static final String THUMBNAIL = "thumbnail"; - public static final String TIME_TAKEN = "timeTaken"; - public static final String TIME_UNIT = "time_unit"; - public static final String TITLE = "title"; - public static final String TO = "to"; - public static final String TOC_URL = "tocUrl"; - public static final String TOKEN = "token"; - public static final String TOPIC = "topic"; - public static final String TOPIC_NAME = "topicName"; - public static final String TOPICS = "topics"; - public static final String TOPN = "topn"; - public static final String TRY_COUNT = "tryCount"; - public static final String TYPE = "type"; - public static final String UNDEFINED_IDENTIFIER = "Undefined column name "; - public static final String UNIQUE = "unique"; - public static final String UNKNOWN_IDENTIFIER = "Unknown identifier "; - public static final String UPDATE = "update"; - public static final String UPDATED_BY = "updatedBy"; - public static final String UPDATED_BY_NAME = "updatedByName"; - public static final String UPDATED_DATE = "updatedDate"; - public static final String UPLOADED_BY = "uploadedBy"; - public static final String UPLOADED_DATE = "uploadedDate"; - public static final String URL = "url"; - public static final String URL_ACTION = "url_action"; - public static final String URL_ACTION_ID = "url_action_ids"; - public static final String URLS = "urls"; - public static final String USER = "user"; - public static final String USER_ACTION_ROLE = "user_action_role"; - public static final String USER_AUTH_DB = "userAuth_db"; - public static final String USER_BADGES_DB = "user_badge"; - public static final String USER_COUNT = "userCount"; - public static final String USER_COUNT_TTL = "userCountTTL"; - public static final String USER_COURSE = "user_course"; - public static final String USER_COURSES = "userCourses"; - public static final String USER_DB = "user_db"; - public static final String USER_FOUND = "user exist with this login Id."; - public static final String USER_ID = "userId"; - public static final String USER_IDs = "userIds"; - public static final String USER_LIST = "userList"; - public static final String USER_LIST_REQ = "userListReq"; - public static final String USER_NAME = "username"; - public static final String USER_NOT_FOUND = "user does not exist with this login Id."; - public static final String USER_NOTES_DB = "userNotes_db"; - public static final String USER_ORG = "user_org"; - public static final String USER_ORG_DB = "user_org_db"; - public static final String USER_RELATIONS = "user_relations"; - public static final String USER_SKILL_DB = "userSkillDb"; - public static final String USERIDS = "userIds"; - public static final String USERNAME = "userName"; - public static final String USR_EXT_ID_DB = "user_external_identity"; - public static final String USR_ORG_DB = "user_org"; - public static final String VALUE = "value"; - public static final String VER = "ver"; - public static final String VERSION = "version"; - public static final String VIEW_COUNT = "viewCount"; - public static final String VIEW_POSITION = "viewPosition"; - public static final String WEB_PAGES = "webPages"; - public static final String WEB_URL = "webUrl"; - public static final String WELCOME_MESSAGE = "welcomeMessage"; - public static final String YEAR_OF_PASSING = "yearOfPassing"; - public static final String ZIPCODE = "zipcode"; - public static final String SUNBIRD_CONTENT_SERVICE_BASE_URL = "sunbird_content_service_base_url"; - public static final String SUNBIRD_CONTENT_SERVICE_AUTHORIZATION = - "sunbird_content_service_authorization"; - public static final String SUNBIRD_HEALTH_CHECK_ENABLE = "sunbird_health_check_enable"; - public static final String HEALTH = "health"; - public static final String SERVICE = "service"; - public static final String SOFT_CONSTRAINTS = "softConstraints"; - public static final String SUNBIRD_USER_ORG_API_BASE_URL = "sunbird_user_org_api_base_url"; - public static final String SUNBIRD_API_MGR_BASE_URL = "sunbird_api_mgr_base_url"; - public static final String SUNBIRD_AUTHORIZATION = "sunbird_authorization"; - public static final String SUNBIRD_CS_BASE_URL = "sunbird_cs_base_url"; - public static final String SUNBIRD_CS_SEARCH_PATH = "sunbird_cs_search_path"; - public static final String SUNBIRD_CONTENT_BADGE_ASSIGN_URL = "sunbird.content.badge.assign.url"; - public static final String SUNBIRD_CONTENT_BADGE_REVOKE_URL = "sunbird.content.badge.revoke.url"; - public static final String SUNBIRD_LMS_BASE_URL = "sunbird_lms_base_url"; - public static final String SUNBIRD_TELEMETRY_API_PATH = "sunbird_telemetry_api_path"; - public static final String SUNBIRD_LMS_TELEMETRY = "Sunbird_LMS_Telemetry"; - public static final String SUNBIRD_LMS_AUTHORIZATION = "sunbird_authorization"; - public static final String ETS = "ets"; - public static final String CONTENT_ENCODING = "Content-Encoding"; - public static final String EK_STEP = "EK-STEP"; - public static final String RESOURCE_NAME = "resourceName"; - public static final String BADGE_ASSERTIONS = "badgeAssertions"; - public static final String USER_BADGE_ASSERTION_DB = "user_badge_assertion"; - public static final String DURATION = "duration"; - public static final String OBJECT_STORE = "object-store"; - public static final String IMAGE_URL = "imgUrl"; - public static final String COMMUNITY_ID = "communityId"; - public static final String LOCATION_CODE = "locationCode"; - public static final String LATITUDE = "latitude"; - public static final String LONGITUDE = "longitude"; - public static final String UPLOAD_FILE_MAX_SIZE = "file_upload_max_size"; - public static final String PRIMARY_KEY = "PK"; - public static final String NON_PRIMARY_KEY = "NonPK"; - public static final String PARENT_ID = "parentId"; - public static final String CREATED_ON = "createdOn"; - public static final String UPDATED_ON = "updatedOn"; - public static final String LAST_UPDATED_ON = "lastUpdatedOn"; - public static final String LAST_UPDATED_BY = "lastUpdatedBy"; - public static final String SUNBIRD_DEFAULT_CHANNEL = "sunbird_default_channel"; - public static final String CASSANDRA_WRITE_BATCH_SIZE = "cassandra_write_batch_size"; - public static final String CASSANDRA_UPDATE_BATCH_SIZE = "cassandra_update_batch_size"; - public static final String ORG_EXTERNAL_ID = "orgExternalId"; - public static final String ORG_PROVIDER = "orgProvider"; - public static final String EXTERNAL_IDS = "externalIds"; - public static final String SUNBIRD_TELEMETRY_BASE_URL = "sunbird_telemetry_base_url"; - public static final String EXTERNAL_ID_TYPE = "externalIdType"; - public static final String ID_TYPE = "idType"; - public static final String ADD = "add"; - public static final String REMOVE = "remove"; - public static final String EDIT = "edit"; - public static final String DEFAULT_FRAMEWORK = "defaultFramework"; - public static final String SUNBIRD_OPENSABER_BRIDGE_ENABLE = "sunbird_open_saber_bridge_enable"; - public static final String EXTERNAL_ID_PROVIDER = "externalIdProvider"; - public static final String SUNBIRD_INSTALLATION_DISPLAY_NAME = - "sunbird_installation_display_name"; - public static final String USR_EXT_IDNT_TABLE = "usr_external_identity"; - public static final String END_TIME_IN_HOUR_MINUTE_SECOND = " 23:59:59"; - public static final String REGISTRY_ID = "registryId"; - public static final String RESPONSE_CODE = "responseCode"; - public static final String OK = "ok"; - public static final String SUNBIRD_APP_NAME = "sunbird_app_name"; - public static final String SUNBIRD_DEFAULT_COUNTRY_CODE = "sunbird_default_country_code"; - public static final String ONBOARDING_MAIL_SUBJECT = "onboarding_mail_subject"; - public static final String ONBOARDING_MAIL_MESSAGE = "onboarding_welcome_message"; - public static final String SUNBIRD_DEFAULT_WELCOME_MSG = "sunbird_default_welcome_sms"; - public static final String SUNBIRD_DEFAULT_USER_TYPE = "sunbird_default_user_type"; - public static final String ES_TYPES = "types"; - public static final String RECIPIENT_SEARCH_QUERY = "recipientSearchQuery"; - public static final String SUNBIRD_EMAIL_MAX_RECEPIENT_LIMIT = - "sunbird_email_max_recipients_limit"; - public static final String ORIGINAL_EXTERNAL_ID = "originalExternalId"; - public static final String ORIGINAL_ID_TYPE = "originalIdType"; - public static final String ORIGINAL_PROVIDER = "originalProvider"; - public static final String SUNBIRD_CASSANDRA_CONSISTENCY_LEVEL = - "sunbird_cassandra_consistency_level"; - public static final String VERSION_2 = "v2"; - public static final String CUSTODIAN_ORG_CHANNEL = "custodianOrgChannel"; - public static final String CUSTODIAN_ORG_ID = "custodianOrgId"; - public static final String APP_ID = "appId"; - public static final String REDIRECT_URI = "redirectUri"; - public static final String SET_PASSWORD_LINK = "set_password_link"; - public static final String VERIFY_EMAIL_LINK = "verify_email_link"; - public static final String LINK = "link"; - public static final String SET_PW_LINK = "setPasswordLink"; - public static final String SUNBIRD_URL_SHORTNER_ENABLE = "sunbird_url_shortner_enable"; - public static final String USER_PROFILE_CONFIG = "userProfileConfig"; - public static final String PUBLIC_FIELDS = "publicFields"; - public static final String PRIVATE_FIELDS = "privateFields"; - public static final String SUNBIRD_USER_PROFILE_FIELD_DEFAULT_VISIBILITY = - "sunbird_user_profile_field_default_visibility"; - public static final String DEFAULT_PROFILE_FIELD_VISIBILITY = "defaultProfileFieldVisibility"; - - public static final String SUNBIRD_COURSE_BATCH_NOTIFICATIONS_ENABLED = - "sunbird_course_batch_notification_enabled"; - - public static final String BATCH_START_DATE = "batchStartDate"; - public static final String BATCH_END_DATE = "batchEndDate"; - public static final String BATCH_NAME = "batchName"; - public static final String BATCH_MENTOR_ENROL = "batchMentorEnrol"; - public static final String BATCH_LEARNER_ENROL = "batchLearnerEnrol"; - public static final String COURSE_INVITATION = "Course Invitation"; - public static final String BATCH_LEARNER_UNENROL = "batchLearnerUnenrol"; - public static final String BATCH_MENTOR_UNENROL = "batchMentorUnenrol"; - public static final String UNENROLL_FROM_COURSE_BATCH = "Unenrolled from Training"; - public static final String OPEN_BATCH_LEARNER_UNENROL = "openBatchLearnerUnenrol"; - - public static final String MENTOR = "mentor"; - public static final String OLD = "old"; - public static final String NEW = "new"; - public static final String COURSE_BATCH = "courseBatch"; - public static final String ADDED_MENTORS = "addedMentors"; - public static final String REMOVED_MENTORS = "removedMentors"; - public static final String ADDED_PARTICIPANTS = "addedParticipants"; - public static final String REMOVED_PARTICIPANTS = "removedParticipants"; - public static final String URL_QUERY_STRING = "urlQueryString"; - public static final String SUNBIRD_API_REQUEST_LOWER_CASE_FIELDS = - "sunbird_api_request_lower_case_fields"; - public static final String ATTRIBUTE = "attribute"; - public static final String ERRORS = "errors"; - public static final String ROLE_LIST = "roleList"; - public static final String SUNBIRD_USER_PROFILE_READ_EXCLUDED_FIELDS = "read.excludedFields"; - public static final String COMPLETED_ON = "completedOn"; - public static final String CALLER_ID = "callerId"; - public static final String USER_TYPE = "userType"; - public static final String MANAGED_BY = "managedBy"; - - public static final String COURSE_BATCH_URL = "courseBatchUrl"; - public static final String SUNBIRD_COURSE_BATCH_NOTIFICATION_SIGNATURE = - "sunbird_course_batch_notification_signature"; - public static final String SIGNATURE = "signature"; - public static final String OPEN_BATCH_LEARNER_ENROL = "openBatchLearnerEnrol"; - public static final String CONTENT_PROPERTY_MEDIUM = "medium"; - public static final String CONTENT_PROPERTY_GRADE_LEVEL = "gradeLevel"; - public static final String CONTENT_PROPERTY_SUBJECT = "subject"; - public static final String CONTENT_PROPERTY_NAME = "name"; - public static final String CONTENT_PROPERTY_VISIBILITY = "visibility"; - public static final String CONTENT_PROPERTY_VISIBILITY_PARENT = "Parent"; - public static final String CONTENT_PROPERTY_MIME_TYPE = "mimeType"; - public static final String CONTENT_MIME_TYPE_COLLECTION = - "application/vnd.ekstep.content-collection"; - public static final String VERSION_KEY = "versionKey"; - public static final String CSV_SEPERATOR = ","; - public static final String CONTENT_CLOUD_STORAGE_TYPE = "sunbird_content_cloud_storage_type"; - public static final String CONTENT_AZURE_STORAGE_CONTAINER = - "sunbird_content_azure_storage_container"; - public static final String CLOUD_FOLDER_CONTENT = "sunbird_cloud_content_folder"; - public static final String TO_URL = "toUrl"; - public static final String TTL = "ttl"; - public static final String TEXTBOOK_TOC_CSV_TTL = "sunbird_texbook_toc_csv_ttl"; - public static final String FILE_TYPE_CSV = "csv"; - - // Texbook TOC - public static final String TEXTBOOK = "textbook"; - public static final String TEXTBOOK_ID = "textbookId"; - public static final String MODE = "mode"; - public static final String MIME_TYPE = "mimeType"; - public static final String METADATA = "metadata"; - public static final String HIERARCHY = "hierarchy"; - public static final String FILE_DATA = "fileData"; - public static final String FRAMEWORK_METADATA = "frameworkCategories"; - public static final String TEXTBOOK_TOC_ALLOWED_MIMETYPE = - "application/vnd.ekstep.content-collection"; - public static final String TEXTBOOK_TOC_ALLOWED_CONTNET_TYPES = - "textbook_toc_allowed_content_types"; - public static final String TEXTBOOK_TOC_MAX_CSV_ROWS = "textbook_toc_max_csv_rows"; - public static final String TEXTBOOK_TOC_INPUT_MAPPING = "textbook_toc_input_mapping"; - public static final String NODES_MODIFIED = "nodesModified"; - public static final String TEXT_TOC_FILE_SUPPRESS_COLUMN_NAMES = - "textbook_toc_file_suppress_column_names"; - public static final String TEXTBOOK_TOC_MANDATORY_FIELDS = "textbook_toc_mandatory_fields"; - public static final String DOWNLOAD = "download"; - public static final String COLLECTION_MIME_TYPE = "application/vnd.ekstep.content-collection"; - public static final String TB_ROOT = "root"; - public static final String TB_IS_NEW = "isNew"; - public static final String KEYWORDS = "keywords"; - public static final String UNIT = "Unit"; - public static final String UPDATE_HIERARCHY_API = "sunbird_update_hierarchy_api"; - public static final String TB_MESSAGES = "messages"; - public static final String TNC_ACCEPTED_ON = "tncAcceptedOn"; - public static final String TNC_ACCEPTED_VERSION = "tncAcceptedVersion"; - public static final String TNC_LATEST_VERSION_URL = "tncLatestVersionUrl"; - public static final String PROMPT_TNC = "promptTnC"; - public static final String TNC_LATEST_VERSION = "tncLatestVersion"; - public static final String BULK_ORG_UPLOAD = "bulkOrgUpload"; - public static final String FRAMEWORKS = "frameworks"; - public static final String LATEST_VERSION = "latestVersion"; - public static final String TNC_CONFIG = "tncConfig"; - public static final String TNC = "tnc"; - public static final String ACCEPT = "accept"; - public static final String ROOT_ORG_NAME = "rootOrgName"; - public static final String SUNBIRD_OTP_EXPIRATION = "sunbird_otp_expiration"; - public static final String SUNBIRD_OTP_LENGTH = "sunbird_otp_length"; - public static final String OTP_EXPIRATION_IN_MINUTES = "otpExpiryInMinutes"; - public static final String SUNBIRD_RATE_LIMIT_ENABLED = "sunbird_rate_limit_enabled"; - public static final String SUNBIRD_USER_MAX_ENCRYPTION_LIMIT = - "sunbird_user_max_encryption_limit"; - public static final String SUNBIRD_USER_MAX_PHONE_LENGTH = "sunbird_user_max_phone_length"; - public static final String RATE_LIMIT = "rate_limit"; - public static final String RATE_LIMIT_UNIT = "unit"; - public static final String RATE = "rate"; - public static final String INSTALLATION_NAME = "installationName"; - public static final String LOCATION_CODES = "locationCodes"; - public static final String BATCH_DETAILS = "batchDetails"; - public static final String USER_LOCATIONS = "userLocations"; - public static final String DIAL_CODES = "dialcodes"; - public static final String DIAL_CODE_REQUIRED = "dialcodeRequired"; - public static final String NO = "No"; - public static final String YES = "Yes"; - public static final String QR_CODE_REQUIRED = "QR Code Required?"; - public static final String QR_CODE = "QR Code"; - public static final String RESERVED_DIAL_CODES = "reservedDialcodes"; - public static final String FRAMEWORK_READ_API_URL = "framework_read_api_url"; - public static final String DIAL_CODE_IDENTIFIER_MAP = "dialCodeIdentifierMap"; - public static final String LINK_DIAL_CODE_API = "sunbird_link_dial_code_api"; - public static final String LINKED_CONTENT = "linkedContent"; - public static final String MAX_ALLOWED_CONTENT_SIZE = "max_allowed_content_size"; - public static final String SUNBIRD_LINKED_CONTENT_BASE_URL = "sunbird_linked_content_base_url"; - public static final String LINKED_CONTENT_COLUMN_KEY = "Linked Content"; - - public static final String BATCHES = "batches"; - public static final String ENROLLED_ON = "enrolledOn"; - public static final String LAST_ACCESSED_ON = "lastAccessedOn"; - public static final String OTHER = "OTHER"; - public static final String TEACHER = "TEACHER"; - public static final String USER_EXTERNAL_ID = "userExternalId"; - public static final String USER_ID_TYPE = "userIdType"; - public static final String USER_PROVIDER = "userProvider"; - public static final String SORTBY = "sortBy"; - public static final String SORT_ORDER = "sortOrder"; - public static final String NUMERIC = "NUMERIC"; - public static final String ASC = "asc"; - public static final String TERM = "term"; - public static final String DESC = "desc"; - public static final String SUNBIRD_TOC_LINKED_CONTENT_COLUMN_NAME = - "sunbird_toc_linked_content_column_name"; - public static final String SUNBIRD_TOC_MAX_FIRST_LEVEL_UNITS = - "sunbird_toc_max_first_level_units"; - public static final String TEXTBOOK_TOC_OUTPUT_MAPPING = "textbook_toc_output_mapping"; - public static final String TEXTBOOK_UNIT = "TextBookUnit"; - public static final String USER_NAME_HEADER = "User Name"; - public static final String ORG_NAME_HEADER = "Org Name"; - public static final String SCHOOL_NAME_HEADER = "School Name"; - public static final String COURSE_ENROLL_DATE_HEADER = "Enrollment Date"; - public static final String PROGRESS_HEADER = "Progress"; - public static final String SUNBIRD_CONTENT_SEARCH_URL = "sunbird_content_search_url"; - public static final String DATE_TIME_HEADER = "Date time stamp"; - public static final String PHONE_HEADER = "Mobile Number"; - public static final String EMAIL_HEADER = "Email Id"; - public static final String COURSE_PROGRESS_MAIL_TEMPLATE = "courseProgressMailTemplate"; - public static final String SUNBIRD_TIMEZONE = "sunbird_time_zone"; - public static final String COURSE_STAT_MAIL_DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; - public static final String DATA_SOURCE = "dataSource"; - public static final String SUNBIRD_DIALCODE_SEARCH_API = "sunbird_dialcode_search_api"; - public static final String FROM_BEGINING = "fromBegining"; - public static final String SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID = - "sunbird_keycloak_user_federation_provider_id"; - public static final String DEVICE_ID = "did"; - public static final String SUNBIRD_GZIP_FILTER_ENABLED = "sunbird_gzip_filter_enabled"; - public static final String COMPLETED_PERCENT = "completedPercent"; - public static final String PARTICIPANT_COUNT = "participantCount"; - public static final String BOARD = "board"; - public static final String MEDIUM = "medium"; - public static final String SUNBIRD_GZIP_ENABLE = "sunbird_gzip_enable"; - public static final String SHOW_DOWNLOAD_LINK = "showDownloadLink"; - public static final String SUNBIRD_SYNC_READ_WAIT_TIME = "sunbird_sync_read_wait_time"; - public static final String SUNBIRD_COURSE_METRICS_CONTANER = "sunbird_course_metrics_container"; - public static final String SUNBIRD_COURSE_METRICS_REPORT_FOLDER = - "sunbird_course_metrics_report_folder"; - public static final String SUNBIRD_ASSESSMENT_REPORT_FOLDER = "sunbird_assessment_report_folder"; - public static final String REPORT_UPDATED_ON = "reportUpdatedOn"; - 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 PAGE_MANAGEMENT = "page_management"; - public static final String SUNBIRD_CACHE_ENABLE = "sunbird_cache_enable"; - public static final String MAP_NAME = "mapName"; - public static final String PAGE_ASSEMBLE = "pageAssemble"; - public static final String SIGNUP_TYPE = "signupType"; - public static final String REQUEST_SOURCE = "source"; - - public static final String SUNBIRD_REDIS_CONN_POOL_SIZE = "sunbird_redis_connection_pool_size"; - public static final String RECIPIENT_PHONES = "recipientPhones"; - public static final String TCP = "tcp"; - public static final String REST = "rest"; - public static final String SUNBIRD_AUDIT_EVENT_BATCH_ALLOWED = - "sunbird_audit_event_batch_allowed"; - public static final String ES_OR_OPERATION = "$or"; - public static final String PREV_USED_EMAIL = "prevUsedEmail"; - public static final String PREV_USED_PHONE = "prevUsedPhone"; - public static final String MERGE_USER = "Mergeuser"; - public static final String FROM_ACCOUNT_ID = "fromAccountId"; - public static final String TO_ACCOUNT_ID = "toAccountId"; - public static final String MERGEE_ID = "mergeeId"; - public static final String USER_MERGEE_ACCOUNT = "userMergeeAccount"; - public static final String SEARCH_FUZZY = "fuzzy"; - public static final String SUNBIRD_FUZZY_SEARCH_THRESHOLD = "sunbird_fuzzy_search_threshold"; - public static final String CERT_ID = "certId"; - public static final String ACCESS_CODE = "accessCode"; - public static final String USER_CERT = "user_cert"; - public static final String STORE = "store"; - public static final String JSON = "json"; - public static final String PDF = "pdf"; - public static final String JSON_DATA = "jsonData"; - public static final String PDF_URL = "pdfURL"; - public static final String CREATED_AT = "createdAt"; - public static final String UPDATED_AT = "updatedAt"; - public static final String SIGN_KEYS = "signKeys"; - public static final String ENC_KEYS = "encKeys"; - public static final String SUNBIRD_STATE_IMG_URL = "sunbird_state_img_url"; - public static final String SUNBIRD_DIKSHA_IMG_URL = "sunbird_diksha_img_url"; - public static final String SUNBIRD_CERT_COMPLETION_IMG_URL = "sunbird_cert_completion_img_url"; - public static final String stateImgUrl = "stateImgUrl"; - public static final String dikshaImgUrl = "dikshaImgUrl"; - public static final String certificateImgUrl = "certificateImgUrl"; - public static final String SUNBIRD_RESET_PASS_MAIL_SUBJECT = "sunbird_reset_pass_mail_subject"; - public static final String X_AUTHENTICATED_USER_TOKEN = "x-authenticated-user-token"; - public static final String X_SOURCE_USER_TOKEN = "x-source-user-token"; - public static final String SUNBIRD_SUBDOMAIN_KEYCLOAK_BASE_URL = - "sunbird_subdomain_keycloak_base_url"; - public static final String SUNBIRD_CERT_SERVICE_BASE_URL = "sunbird_cert_service_base_url"; - public static final String SUNBIRD_CERT_DOWNLOAD_URI = "sunbird_cert_download_uri"; - public static final String ACTION = "action"; - public static final String ITERATION = "iteration"; - public static final String TELEMETRY_TARGET_USER_MERGE_TYPE = "MergeUserCoursesAndCert"; - public static final String TELEMETRY_PRODUCER_USER_MERGE_ID = "org.sunbird.platform"; - public static final String TELEMETRY_EDATA_USER_MERGE_ACTION = "merge-user-courses-and-cert"; - public static final String BE_JOB_REQUEST = "BE_JOB_REQUEST"; - public static final String TELEMETRY_ACTOR_USER_MERGE_ID = "Merge User Courses and Cert"; - public static final String SUNBIRD_COURSE_DIALCODES_DB = "sunbird_course_dialcodes_db"; - public static final String SUNBIRD_ACCOUNT_MERGE_BODY = "sunbird_account_merge_body"; - public static final String CERTIFICATE = "Certificate"; - public static final String OLD_CERTIFICATE = "oldCertificate"; - public static final String MERGE_CERT = "Mergecert"; - public static final String RECOVERY_EMAIL = "recoveryEmail"; - public static final String RECOVERY_PHONE = "recoveryPhone"; - public static final String SUPPORTED_COlUMNS = "supportedColumns"; - public static final String INPUT_STATUS = "input status"; - public static final String EXTERNAL_USER_ID = "ext user id"; - public static final String EXTERNAL_ORG_ID = "ext org id"; - public static final String MIGRATION_USER_OBJECT = "MigrationUser"; - public static final String TASK_COUNT = "taskCount"; - public static final String ERROR_VISUALIZATION_THRESHOLD = - "sunbird_user_upload_error_visualization_threshold"; - public static final String NESTED_KEY_FILTER = "nestedFilters"; - public static final String SHADOW_USER = "shadow_user"; - public static final String USER_EXT_ID = "userExtId"; - public static final String ORG_EXT_ID = "orgExtId"; - public static final String STATE_VALIDATED = "stateValidated"; - public static final String FLAGS_VALUE = "flagsValue"; - public static final String USER_STATUS = "userStatus"; - public static final String CLAIM_STATUS = "claimStatus"; - public static final String CLAIMED_ON = "claimedOn"; - public static final String SUNBIRD_MIGRATE_USER_BODY = "sunbird_migrate_user_body"; - public static final String SMS = "sms"; - public static final String SUNBIRD_ACCOUNT_MERGE_SUBJECT = "sunbird_account_merge_subject"; - public static final String CONTEXT_TELEMETRY = "telemetryContext"; - public static final String OLD_ID = "oldId"; - public static final String MAX_ATTEMPT = "maxAttempt"; - public static final String REMAINING_ATTEMPT = "remainingAttempt"; - public static final String IS_SSO_ROOTORG_ENABLED = "isSSOEnabled"; - public static final String USER_FEED_DB = "user_feed"; - public static final String USER_FEED = "userFeed"; - public static final String FEED_DATA = "data"; - public static final String REJECT = "reject"; - public static final String FEED_ID = "feedId"; - public static final String LICENSE = "license"; - public static final String DEFAULT_LICENSE = "defaultLicense"; - public static final String SUNBIRD_PASS_REGEX = "sunbird_pass_regex"; - public static final String NESTED_EXISTS = "nested_exists"; - public static final String NESTED_NOT_EXISTS = "nested_not_exists"; - public static final String PROSPECT_CHANNELS = "prospectChannels"; - public static final String CATEGORY = "category"; - public static final String TEMPLATE_ID = "templateId"; - public static final String TEMPLATE_ID_VALUE = "resetPasswordWithOtp"; - public static final String VERSION_3 = "v3"; - public static final String LEARNING_SERVICE_BASE_URL = "learning_service_base_url"; - public static final String CREATOR_DETAILS_FIELDS = "sunbird_user_search_cretordetails_fields"; - public static final String USER_SEARCH_BASE_URL = "sunbird_user_service_api_base_url"; - public static final String WARD_LOGIN_OTP_TEMPLATE_ID = "wardLoginOTP"; - public static final String OTP_PHONE_WARD_LOGIN_TEMPLATE = "verifyPhoneOtpTemplateWard"; - public static final String OTP_EMAIL_WARD_LOGIN_TEMPLATE = "verifyEmailOtpTemplateWard"; - public static final String SUNBIRD_QRCODE_COURSES_LIMIT ="sunbird_user_qrcode_courses_limit"; - private JsonKey() {} -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/KeyCloakConnectionProvider.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/KeyCloakConnectionProvider.java deleted file mode 100644 index d88daae12..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/KeyCloakConnectionProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import org.apache.commons.lang3.StringUtils; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.KeycloakBuilder; - -/** - * @author Manzarul This class will connect to key cloak server and provide the connection to do - * other operations. - */ -public class KeyCloakConnectionProvider { - - private static Keycloak keycloak; - private static PropertiesCache cache = PropertiesCache.getInstance(); - public static String SSO_URL = null; - public static String SSO_REALM = null; - public static String CLIENT_ID = null; - - static { - try { - initialiseConnection(); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - registerShutDownHook(); - } - - /** - * Method to initializate the Keycloak connection - * - * @return Keycloak connection - */ - public static Keycloak initialiseConnection() throws Exception { - ProjectLogger.log("key cloak instance is creation started."); - keycloak = initialiseEnvConnection(); - if (keycloak != null) { - return keycloak; - } - KeycloakBuilder keycloakBuilder = - KeycloakBuilder.builder() - .serverUrl(cache.getProperty(JsonKey.SSO_URL)) - .realm(cache.getProperty(JsonKey.SSO_REALM)) - .username(cache.getProperty(JsonKey.SSO_USERNAME)) - .password(cache.getProperty(JsonKey.SSO_PASSWORD)) - .clientId(cache.getProperty(JsonKey.SSO_CLIENT_ID)) - .resteasyClient( - new ResteasyClientBuilder() - .connectionPoolSize(Integer.parseInt(cache.getProperty(JsonKey.SSO_POOL_SIZE))) - .build()); - if (cache.getProperty(JsonKey.SSO_CLIENT_SECRET) != null - && !(cache.getProperty(JsonKey.SSO_CLIENT_SECRET).equals(JsonKey.SSO_CLIENT_SECRET))) { - keycloakBuilder.clientSecret(cache.getProperty(JsonKey.SSO_CLIENT_SECRET)); - } - SSO_URL = cache.getProperty(JsonKey.SSO_URL); - SSO_REALM = cache.getProperty(JsonKey.SSO_REALM); - CLIENT_ID = cache.getProperty(JsonKey.SSO_CLIENT_ID); - keycloak = keycloakBuilder.build(); - - ProjectLogger.log("key cloak instance is created successfully."); - return keycloak; - } - - /** - * This method will provide the keycloak connection from environment variable. if environment - * variable is not set then it will return null. - * - * @return Keycloak - */ - private static Keycloak initialiseEnvConnection() throws Exception { - String url = System.getenv(JsonKey.SUNBIRD_SSO_URL); - String username = System.getenv(JsonKey.SUNBIRD_SSO_USERNAME); - String password = System.getenv(JsonKey.SUNBIRD_SSO_PASSWORD); - String cleintId = System.getenv(JsonKey.SUNBIRD_SSO_CLIENT_ID); - String clientSecret = System.getenv(JsonKey.SUNBIRD_SSO_CLIENT_SECRET); - String relam = System.getenv(JsonKey.SUNBIRD_SSO_RELAM); - if (StringUtils.isBlank(url) - || StringUtils.isBlank(username) - || StringUtils.isBlank(password) - || StringUtils.isBlank(cleintId) - || StringUtils.isBlank(relam)) { - ProjectLogger.log( - "key cloak connection is not provided by Environment variable.", LoggerEnum.INFO.name()); - return null; - } - SSO_URL = url; - ProjectLogger.log("SSO url is==" + SSO_URL, LoggerEnum.INFO.name()); - SSO_REALM = relam; - CLIENT_ID = cleintId; - KeycloakBuilder keycloakBuilder = - KeycloakBuilder.builder() - .serverUrl(url) - .realm(relam) - .username(username) - .password(password) - .clientId(cleintId) - .resteasyClient( - new ResteasyClientBuilder() - .connectionPoolSize(Integer.parseInt(cache.getProperty(JsonKey.SSO_POOL_SIZE))) - .build()); - - if (StringUtils.isNotBlank(clientSecret)) { - keycloakBuilder.clientSecret(clientSecret); - ProjectLogger.log( - "KeyCloakConnectionProvider:initialiseEnvConnection client sceret is provided.", - LoggerEnum.INFO.name()); - } - keycloakBuilder.grantType("client_credentials"); - keycloak = keycloakBuilder.build(); - ProjectLogger.log( - "key cloak instance is created from Environment variable settings .", - LoggerEnum.INFO.name()); - return keycloak; - } - - /** - * This method will provide key cloak connection instance. - * - * @return Keycloak - */ - public static Keycloak getConnection() { - if (keycloak != null) { - return keycloak; - } else { - try { - return initialiseConnection(); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - } - return null; - } - - /** - * This class will be called by registerShutDownHook to register the call inside jvm , when jvm - * terminate it will call the run method to clean up the resource. - * - * @author Manzarul - */ - static class ResourceCleanUp extends Thread { - public void run() { - ProjectLogger.log("started resource cleanup."); - keycloak.close(); - ProjectLogger.log("completed resource cleanup."); - } - } - - /** Register the hook for resource clean up. this will be called when jvm shut down. */ - public static void registerShutDownHook() { - Runtime runtime = Runtime.getRuntime(); - runtime.addShutdownHook(new ResourceCleanUp()); - ProjectLogger.log("ShutDownHook registered."); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LearnerServiceUrls.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LearnerServiceUrls.java deleted file mode 100644 index 09d5720be..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LearnerServiceUrls.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.sunbird.common.models.util; - -import java.util.HashMap; -import java.util.Map; - -public class LearnerServiceUrls { - public static final String BASE_URL = "sunbird_learner_service_url"; - - public static final String PREFIX_ORG_SERVICE = "/api/org"; - - public enum Path { - API_GW_PATH_READ_ORG("/v1/read"), - LOCAL_PATH_READ_ORG("/v1/org/read"); - - private final String text; - - Path(final String text) { - this.text = text; - } - - @Override - public String toString() { - return text; - } - } - - public static String getRequestUrl(String baseUrl, String prefix, Path path) { - String pathEnumName = path.name(); - - if (baseUrl.contains("localhost") || baseUrl.contains("127.0.0.1")) { - prefix = ""; - pathEnumName = pathEnumName.replace("API_GW", "LOCAL"); - } - return String.format("%s%s%s", baseUrl, prefix, Path.valueOf(pathEnumName)); - } - - public static Map getRequestHeaders(Map inputMap) { - Map outputMap = new HashMap<>(); - - for (Map.Entry entry : inputMap.entrySet()) { - if (entry.getKey().toLowerCase().startsWith("x-") - || entry.getKey().equalsIgnoreCase("Authorization")) { - if (entry.getValue() != null) { - outputMap.put(entry.getKey(), entry.getValue()[0]); - } - } - } - - outputMap.put("Content-Type", "application/json"); - return outputMap; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LocationActorOperation.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LocationActorOperation.java deleted file mode 100644 index 224c89482..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LocationActorOperation.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sunbird.common.models.util; - -public enum LocationActorOperation { - CREATE_LOCATION("createLocation"), - UPDATE_LOCATION("updateLocation"), - SEARCH_LOCATION("searchLocation"), - DELETE_LOCATION("deleteLocation"), - GET_RELATED_LOCATION_IDS("getRelatedLocationIds"), - READ_LOCATION_TYPE("readLocationType"), - UPSERT_LOCATION_TO_ES("upsertLocationDataToES"), - DELETE_LOCATION_FROM_ES("deleteLocationDataFromES"); - - private String value; - - LocationActorOperation(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LogEvent.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LogEvent.java deleted file mode 100644 index 9c509ee3f..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LogEvent.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.sunbird.common.models.util; - -import java.util.HashMap; -import java.util.Map; - -/** - * This class will log the api request , response , and error message insdie log file .in predefine - * structure. - * - * @author Manzarul - */ -public class LogEvent { - - private String eid; - private long ets; - private String mid; - private String ver; - private Map context; - private Map edata; - - public String getEid() { - return eid; - } - - public void setEid(String eid) { - this.eid = eid; - } - - public long getEts() { - return ets; - } - - public void setEts(long ets) { - this.ets = ets; - } - - public String getMid() { - return mid; - } - - public void setMid(String mid) { - this.mid = mid; - } - - public String getVer() { - return ver; - } - - public void setVer(String ver) { - this.ver = ver; - } - - public Map getContext() { - return context; - } - - public void setContext(Map context) { - this.context = context; - } - - public Map getEdata() { - return edata; - } - - public void setEdata(Map eks) { - this.edata = new HashMap(); - edata.put(JsonKey.EKS, eks); - } - - public void setContext(String id, String ver) { - this.context = new HashMap(); - Map pdata = new HashMap(); - pdata.put(JsonKey.ID, id); - pdata.put(JsonKey.VER, ver); - this.context.put(JsonKey.PDATA, pdata); - } - - /** - * Set the error data with this method - * - * @param level String - * @param className String - * @param method String - * @param data Object - * @param stackTrace Object - * @param exception Object - */ - public void setEdata( - String level, - String className, - String method, - Object data, - Object stackTrace, - Object exception) { - this.edata = new HashMap(); - Map eks = new HashMap(); - eks.put(JsonKey.LEVEL, level); - eks.put(JsonKey.CLASS, className); - eks.put(JsonKey.METHOD, method); - eks.put(JsonKey.DATA, data); - eks.put(JsonKey.STACKTRACE, stackTrace); - edata.put(JsonKey.EKS, eks); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LoggerEnum.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LoggerEnum.java deleted file mode 100644 index fc78efae5..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LoggerEnum.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.sunbird.common.models.util; - -/** @author Manzarul */ -public enum LoggerEnum { - INFO, - WARN, - DEBUG, - ERROR, - BE_LOG, - PERF_LOG; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/MapperUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/MapperUtil.java deleted file mode 100644 index 20797eb7b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/MapperUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.sunbird.common.models.util; - -import java.util.Map; - -public class MapperUtil { - public static void put( - Map inMap, String inKey, Map outMap, String outKey) { - String[] inputKeys = inKey.split("\\."); - String lastKey = inputKeys[inputKeys.length - 1]; - - Map map = inMap; - - for (int i = 0; i < (inputKeys.length - 1); i++) { - if (map.containsKey(inputKeys[i])) { - map = (Map) inMap.get(inputKeys[i]); - } - } - - if (map.containsKey(lastKey)) { - outMap.put(outKey, map.get(lastKey)); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PhoneValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PhoneValidator.java deleted file mode 100644 index bfc87a107..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PhoneValidator.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.sunbird.common.models.util; - -import com.google.i18n.phonenumbers.NumberParseException; -import com.google.i18n.phonenumbers.PhoneNumberUtil; -import com.google.i18n.phonenumbers.Phonenumber; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * This class will provide helper method to validate phone number and its country code. - * - * @author Amit Kumar - */ -public class PhoneValidator { - - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - private PhoneValidator() {} - - public static boolean validatePhoneNumber(String phone, String countryCode) { - if (phone.contains("+")) { - throw new ProjectCommonException( - ResponseCode.invalidPhoneNumber.getErrorCode(), - ResponseCode.invalidPhoneNumber.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isNotBlank(countryCode)) { - boolean isCountryCodeValid = validateCountryCode(countryCode); - if (!isCountryCodeValid) { - throw new ProjectCommonException( - ResponseCode.invalidCountryCode.getErrorCode(), - ResponseCode.invalidCountryCode.getErrorMessage(), - ERROR_CODE); - } - } - if (validatePhone(phone, countryCode)) { - return true; - } else { - throw new ProjectCommonException( - ResponseCode.phoneNoFormatError.getErrorCode(), - ResponseCode.phoneNoFormatError.getErrorMessage(), - ERROR_CODE); - } - } - - public static boolean validateCountryCode(String countryCode) { - String countryCodePattern = "^(?:[+] ?){0,1}(?:[0-9] ?){1,3}"; - try { - Pattern pattern = Pattern.compile(countryCodePattern); - Matcher matcher = pattern.matcher(countryCode); - return matcher.matches(); - } catch (Exception e) { - return false; - } - } - - public static boolean validatePhone(String phone, String countryCode) { - PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); - String code = countryCode; - if (StringUtils.isNotBlank(countryCode) && (countryCode.charAt(0) != '+')) { - code = "+" + countryCode; - } - Phonenumber.PhoneNumber phoneNumber = null; - try { - if (StringUtils.isBlank(countryCode)) { - code = PropertiesCache.getInstance().getProperty("sunbird_default_country_code"); - } - String isoCode = phoneNumberUtil.getRegionCodeForCountryCode(Integer.parseInt(code)); - phoneNumber = phoneNumberUtil.parse(phone, isoCode); - return phoneNumberUtil.isValidNumber(phoneNumber); - } catch (NumberParseException e) { - ProjectLogger.log( - "PhoneValidator:validatePhone: Exception occurred while validating phone number = ", e); - } - return false; - } - - public static boolean validatePhoneNumber(String phoneNumber) { - if (StringUtils.isBlank(phoneNumber)) { - return false; - } - String phonePattern = "([+]?(91)?[-]?[0-9]{10}$)"; - Pattern pattern = Pattern.compile(phonePattern); - Matcher matcher = pattern.matcher(phoneNumber); - return matcher.matches(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectLogger.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectLogger.java deleted file mode 100644 index e54f41a40..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectLogger.java +++ /dev/null @@ -1,196 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.request.ExecutionContext; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.telemetry.util.TelemetryEvents; - -/** - * This class will used to log the project message in any level. - * - * @author Manzarul - */ -public class ProjectLogger { - - private static String eVersion = "1.0"; - private static String pVersion = "1.0"; - private static String dataId = "Sunbird"; - private static ObjectMapper mapper = new ObjectMapper(); - private static Logger rootLogger = (Logger) LogManager.getLogger("defaultLogger"); - // private static TelemetryLmaxWriter lmaxWriter = TelemetryLmaxWriter.getInstance(); - - /** To log only message. */ - public static void log(String message) { - log(message, null, LoggerEnum.DEBUG.name()); - } - - public static void log(String message, Throwable e) { - log(message, null, e); - } - - public static void log(String message, Throwable e, Map telemetryInfo) { - log(message, null, e); - telemetryProcess(telemetryInfo, e); - } - - private static void telemetryProcess(Map telemetryInfo, Throwable e) { - - ProjectCommonException projectCommonException = null; - if (e instanceof ProjectCommonException) { - projectCommonException = (ProjectCommonException) e; - } else { - projectCommonException = - new ProjectCommonException( - ResponseCode.internalError.getErrorCode(), - ResponseCode.internalError.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - Request request = new Request(); - telemetryInfo.put(JsonKey.TELEMETRY_EVENT_TYPE, TelemetryEvents.ERROR.getName()); - - Map params = (Map) telemetryInfo.get(JsonKey.PARAMS); - params.put(JsonKey.ERROR, projectCommonException.getCode()); - params.put(JsonKey.STACKTRACE, generateStackTrace(e.getStackTrace())); - request.setRequest(telemetryInfo); - // lmaxWriter.submitMessage(request); - - } - - private static String generateStackTrace(StackTraceElement[] elements) { - StringBuilder builder = new StringBuilder(""); - for (StackTraceElement element : elements) { - builder.append(element.toString()); - } - return builder.toString(); - } - - public static void log(String message, String logLevel) { - log(message, null, logLevel); - } - - /** To log message, data in used defined log level. */ - public static void log(String message, LoggerEnum logEnum) { - info(message, null, logEnum); - } - - /** To log message, data in used defined log level. */ - public static void log(String message, Object data, String logLevel) { - backendLog(message, data, null, logLevel); - } - - /** To log exception with message and data. */ - public static void log(String message, Object data, Throwable e) { - backendLog(message, data, e, LoggerEnum.ERROR.name()); - } - - /** To log exception with message and data for user specific log level. */ - public static void log(String message, Object data, Throwable e, String logLevel) { - backendLog(message, data, e, logLevel); - } - - private static void info(String message, Object data) { - rootLogger.info(getBELogEvent(LoggerEnum.INFO.name(), message, data)); - } - - private static void info(String message, Object data, LoggerEnum loggerEnum) { - rootLogger.info(getBELogEvent(LoggerEnum.INFO.name(), message, data, loggerEnum)); - } - - private static void debug(String message, Object data) { - rootLogger.debug(getBELogEvent(LoggerEnum.DEBUG.name(), message, data)); - } - - private static void error(String message, Object data, Throwable exception) { - rootLogger.error(getBELogEvent(LoggerEnum.ERROR.name(), message, data, exception)); - } - - private static void warn(String message, Object data, Throwable exception) { - rootLogger.warn(getBELogEvent(LoggerEnum.WARN.name(), message, data, exception)); - } - - private static void backendLog(String message, Object data, Throwable e, String logLevel) { - if (!StringUtils.isBlank(logLevel)) { - - switch (logLevel) { - case "INFO": - info(message, data); - break; - case "DEBUG": - debug(message, data); - break; - case "WARN": - warn(message, data, e); - break; - case "ERROR": - error(message, data, e); - break; - default: - debug(message, data); - break; - } - } - } - - private static String getBELogEvent( - String logLevel, String message, Object data, LoggerEnum logEnum) { - String logData = getBELog(logLevel, message, data, null, logEnum); - return logData; - } - - private static String getBELogEvent(String logLevel, String message, Object data) { - String logData = getBELog(logLevel, message, data, null, null); - return logData; - } - - private static String getBELogEvent(String logLevel, String message, Object data, Throwable e) { - String logData = getBELog(logLevel, message, data, e, null); - return logData; - } - - private static String getBELog( - String logLevel, String message, Object data, Throwable exception, LoggerEnum logEnum) { - String mid = dataId + "." + System.currentTimeMillis() + "." + UUID.randomUUID(); - long unixTime = System.currentTimeMillis(); - LogEvent te = new LogEvent(); - Map eks = new HashMap(); - eks.put(JsonKey.LEVEL, logLevel); - eks.put(JsonKey.MESSAGE, message); - String msgId = ExecutionContext.getRequestId(); - if (null != msgId) { - eks.put(JsonKey.REQUEST_MESSAGE_ID, msgId); - } - if (null != data) { - eks.put(JsonKey.DATA, data); - } - if (null != exception) { - eks.put(JsonKey.STACKTRACE, ExceptionUtils.getStackTrace(exception)); - } - if (logEnum != null) { - te.setEid(logEnum.name()); - } else { - te.setEid(LoggerEnum.BE_LOG.name()); - } - te.setEts(unixTime); - te.setMid(mid); - te.setVer(eVersion); - te.setContext(dataId, pVersion); - String jsonMessage = null; - try { - te.setEdata(eks); - jsonMessage = mapper.writeValueAsString(te); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return jsonMessage; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectUtil.java deleted file mode 100644 index 42534ba21..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/ProjectUtil.java +++ /dev/null @@ -1,1073 +0,0 @@ -package org.sunbird.common.models.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.i18n.phonenumbers.NumberParseException; -import com.google.i18n.phonenumbers.PhoneNumberUtil; -import com.google.i18n.phonenumbers.Phonenumber; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.validator.UrlValidator; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -import java.io.IOException; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; -import java.text.MessageFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Random; -import java.util.TimeZone; -import java.util.UUID; -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. - * - * @author Manzarul - */ -public class ProjectUtil { - - /** - * format the date in YYYY-MM-DD hh:mm:ss:SSZ - */ - private static AtomicInteger atomicInteger = new AtomicInteger(); - - public static Integer DEFAULT_BATCH_SIZE = 10; - public static final long BACKGROUND_ACTOR_WAIT_TIME = 30; - public static final String ELASTIC_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; - public static final String YEAR_MONTH_DATE_FORMAT = "yyyy-MM-dd"; - private static final int randomPasswordLength = 9; - - protected static final String FILE_NAME[] = { - "cassandratablecolumn.properties", - "elasticsearch.config.properties", - "cassandra.config.properties", - "dbconfig.properties", - "externalresource.properties", - "sso.properties", - "userencryption.properties", - "profilecompleteness.properties", - "mailTemplates.properties" - }; - public static PropertiesCache propertiesCache; - private static Pattern pattern; - private static final String EMAIL_PATTERN = - "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" - + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; - public static final String[] excludes = - new String[]{ - JsonKey.COMPLETENESS, - JsonKey.MISSING_FIELDS, - JsonKey.PROFILE_VISIBILITY, - JsonKey.LOGIN_ID, - JsonKey.USER_ID - }; - - public static final String[] defaultPrivateFields = new String[]{JsonKey.EMAIL, JsonKey.PHONE}; - private static final String INDEX_NAME = "telemetry.raw"; - private static String YYYY_MM_DD_FORMATTER = "yyyy-MM-dd"; - private static final String STARTDATE = "startDate"; - private static final String ENDDATE = "endDate"; - private static ObjectMapper mapper = new ObjectMapper(); - - static { - pattern = Pattern.compile(EMAIL_PATTERN); - propertiesCache = PropertiesCache.getInstance(); - } - - /** - * @author Manzarul - */ - public enum Environment { - dev(1), - qa(2), - prod(3); - int value; - - private Environment(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } - - /** - * @author Amit Kumar - */ - public enum Status { - ACTIVE(1), - INACTIVE(0); - - private int value; - - Status(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } - } - - public enum BulkProcessStatus { - NEW(0), - IN_PROGRESS(1), - INTERRUPT(2), - COMPLETED(3), - FAILED(9); - - private int value; - - BulkProcessStatus(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } - } - - public enum OrgStatus { - INACTIVE(0), - ACTIVE(1), - BLOCKED(2), - RETIRED(3); - - private Integer value; - - OrgStatus(Integer value) { - this.value = value; - } - - public Integer getValue() { - return this.value; - } - } - - /** - * @author Amit Kumar - */ - public enum ProgressStatus { - NOT_STARTED(0), - STARTED(1), - COMPLETED(2); - - private int value; - - ProgressStatus(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } - } - - /** - * @author Amit Kumar - */ - public enum ActiveStatus { - ACTIVE(true), - INACTIVE(false); - - private boolean value; - - ActiveStatus(boolean value) { - this.value = value; - } - - public boolean getValue() { - return this.value; - } - } - - public enum Action { - YES(1), - NO(0); - - private int value; - - Action(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } - - /** - * @author Amit Kumar - */ - public enum CourseMgmtStatus { - DRAFT("draft"), - LIVE("live"), - RETIRED("retired"); - - private String value; - - CourseMgmtStatus(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } - } - - /** - * @author Amit Kumar - */ - public enum Source { - WEB("web"), - ANDROID("android"), - IOS("ios"), - APP("app"); - - private String value; - - Source(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } - } - - /** - * @author Amit Kumar - */ - public enum UserRole { - PUBLIC("PUBLIC"), - CONTENT_CREATOR("CONTENT_CREATOR"), - CONTENT_REVIEWER("CONTENT_REVIEWER"), - ORG_ADMIN("ORG_ADMIN"), - ORG_MEMBER("ORG_MEMBER"); - - private String value; - - UserRole(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } - } - - /** - * This method will check incoming value is null or empty it will do empty check by doing trim - * method. in case of null or empty it will return true else false. - * - * @param value - * @return - */ - public static boolean isStringNullOREmpty(String value) { - return (value == null || "".equals(value.trim())); - } - - /** - * This method will provide formatted date - * - * @return - */ - public static String getFormattedDate() { - return getDateFormatter().format(new Date()); - } - - /** - * This method will provide formatted date - * - * @return - */ - public static String formatDate(Date date) { - if (null != date) return getDateFormatter().format(date); - else return null; - } - - /** - * Validate email with regular expression - * - * @param email - * @return true valid email, false invalid email - */ - public static boolean isEmailvalid(final String email) { - if (StringUtils.isBlank(email)) { - return false; - } - Matcher matcher = pattern.matcher(email); - return matcher.matches(); - } - - /** - * This method will generate auth token based on name , source and timestamp - * - * @param name String - * @param source String - * @return String - */ - public static String createAuthToken(String name, String source) { - String data = name + source + System.currentTimeMillis(); - UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); - return authId.toString(); - } - - /** - * This method will generate unique id based on current time stamp and some random value mixed up. - * - * @param environmentId int - * @return String - */ - public static String getUniqueIdFromTimestamp(int environmentId) { - Random random = new Random(); - long env = (environmentId + random.nextInt(99999)) / 10000000; - long uid = System.currentTimeMillis() + random.nextInt(999999); - uid = uid << 13; - return env + "" + uid + "" + atomicInteger.getAndIncrement(); - } - - /** - * This method will generate the unique id . - * - * @return - */ - public static synchronized String generateUniqueId() { - return UUID.randomUUID().toString(); - } - - public enum Method { - GET, - POST, - PUT, - DELETE, - PATCH - } - - /** - * Enum to hold the index name for Elastic search. - * - * @author Manzarul - */ - public enum EsIndex { - sunbird("searchindex"), - courseBatchStats("cbatchstats"); - private String indexName; - - private EsIndex(String name) { - this.indexName = name; - } - - public String getIndexName() { - return indexName; - } - } - - /** - * This enum will hold all the ES type name. - * - * @author Manzarul - */ - public enum EsType { - course("cbatch"), - courseBatch("course-batch"), - content("content"), - badgeassociations("badgeassociations"), - user("user"), - organisation("org"), - usercourses("user-courses"), - usernotes("usernotes"), - userprofilevisibility("userprofilevisibility"), - telemetry("telemetry"), - location("location"), - announcementType("announcementtype"), - announcement("announcement"), - metrics("metrics"), - cbatchstats("cbatchstats"), - cbatchassessment("cbatch-assessment"), - userfeed("userfeed"); - - private String typeName; - - private EsType(String name) { - this.typeName = name; - } - - public String getTypeName() { - return typeName; - } - } - - public enum SectionDataType { - course("course"), - content("content"); - private String typeName; - - private SectionDataType(String name) { - this.typeName = name; - } - - public String getTypeName() { - return typeName; - } - } - - public enum AddressType { - permanent("permanent"), - current("current"), - office("office"), - home("home"); - private String typeName; - - private AddressType(String name) { - this.typeName = name; - } - - public String getTypeName() { - return typeName; - } - } - - public enum AssessmentResult { - gradeA("A", "Pass"), - gradeB("B", "Pass"), - gradeC("C", "Pass"), - gradeD("D", "Pass"), - gradeE("E", "Pass"), - gradeF("F", "Fail"); - private String grade; - private String result; - - private AssessmentResult(String grade, String result) { - this.grade = grade; - this.result = result; - } - - public String getGrade() { - return grade; - } - - public String getResult() { - return result; - } - } - - /** - * This method will calculate the percentage - * - * @param score double - * @param maxScore double - * @return double - */ - public static double calculatePercentage(double score, double maxScore) { - double percentage = (score * 100) / (maxScore * 1.0); - return Math.round(percentage); - } - - /** - * This method will calculate grade based on percentage marks. - * - * @param percentage double - * @return AssessmentResult - */ - public static AssessmentResult calcualteAssessmentResult(double percentage) { - switch (Math.round(Float.valueOf(String.valueOf(percentage))) / 10) { - case 10: - return AssessmentResult.gradeA; - case 9: - return AssessmentResult.gradeA; - case 8: - return AssessmentResult.gradeB; - case 7: - return AssessmentResult.gradeC; - case 6: - return AssessmentResult.gradeD; - case 5: - return AssessmentResult.gradeE; - default: - return AssessmentResult.gradeF; - } - } - - public static boolean isNull(Object obj) { - return null == obj ? true : false; - } - - public static boolean isNotNull(Object obj) { - return null != obj ? true : false; - } - - public static String formatMessage(String exceptionMsg, Object... fieldValue) { - return MessageFormat.format(exceptionMsg, fieldValue); - } - - public static SimpleDateFormat getDateFormatter() { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSSZ"); - simpleDateFormat.setLenient(false); - return simpleDateFormat; - } - - /** - * @author Manzarul - */ - public enum EnrolmentType { - open("open"), - inviteOnly("invite-only"); - private String val; - - EnrolmentType(String val) { - this.val = val; - } - - public String getVal() { - return val; - } - } - - /** - * @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(); - if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { - context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { - context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); - } - context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); - String fromEmail = getFromEmail(map); - if (StringUtils.isNotBlank(fromEmail)) { - context.put(JsonKey.FROM_EMAIL, fromEmail); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { - context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); - } - String logoUrl = getSunbirdLogoUrl(map); - if (StringUtils.isNotBlank(logoUrl)) { - context.put(JsonKey.ORG_IMAGE_URL, logoUrl); - } - context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); - context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); - context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); - - if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { - context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { - context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { - context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { - context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { - context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); - } else { - context.put(JsonKey.NAME, ""); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { - context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); - } - if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { - context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); - } - context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); - map = addCertStaticResource(map); - for (Map.Entry entry : map.entrySet()) { - context.put(entry.getKey(), entry.getValue()); - } - return context; - } - - private static String getSunbirdLogoUrl(Map map) { - String logoUrl = (String) getValue(map, JsonKey.ORG_IMAGE_URL); - if (StringUtils.isBlank(logoUrl)) { - logoUrl = getConfigValue(JsonKey.SUNBIRD_ENV_LOGO_URL); - } - ProjectLogger.log("ProjectUtil:getSunbirdLogoUrl: url = " + logoUrl, LoggerEnum.INFO.name()); - return logoUrl; - } - - private static Map addCertStaticResource(Map map) { - map.putIfAbsent( - JsonKey.certificateImgUrl, - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_CERT_COMPLETION_IMG_URL)); - map.putIfAbsent( - JsonKey.dikshaImgUrl, ProjectUtil.getConfigValue(JsonKey.SUNBIRD_DIKSHA_IMG_URL)); - map.putIfAbsent(JsonKey.stateImgUrl, ProjectUtil.getConfigValue(JsonKey.SUNBIRD_STATE_IMG_URL)); - return map; - } - - private static String getFromEmail(Map map) { - String fromEmail = (String) getValue(map, JsonKey.EMAIL_SERVER_FROM); - if (StringUtils.isBlank(fromEmail)) { - fromEmail = getConfigValue(JsonKey.EMAIL_SERVER_FROM); - } - ProjectLogger.log("ProjectUtil:getFromEmail: fromEmail = " + fromEmail, LoggerEnum.INFO.name()); - return fromEmail; - } - - private static Object getValue(Map map, String key) { - Object value = map.get(key); - map.remove(key); - return value; - } - - /** - * @author Arvind - */ - public enum ReportTrackingStatus { - NEW(0), - GENERATING_DATA(1), - UPLOADING_FILE(2), - UPLOADING_FILE_SUCCESS(3), - SENDING_MAIL(4), - SENDING_MAIL_SUCCESS(5), - FAILED(9); - - private int value; - - ReportTrackingStatus(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } - } - - public static Map createCheckResponse( - String serviceName, boolean isError, Exception e) { - Map responseMap = new HashMap<>(); - responseMap.put(JsonKey.NAME, serviceName); - if (!isError) { - responseMap.put(JsonKey.Healthy, true); - responseMap.put(JsonKey.ERROR, ""); - responseMap.put(JsonKey.ERRORMSG, ""); - } else { - responseMap.put(JsonKey.Healthy, false); - if (e != null && e instanceof ProjectCommonException) { - ProjectCommonException commonException = (ProjectCommonException) e; - responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); - responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); - } else { - responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); - responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); - } - } - return responseMap; - } - - /** - * This method will make EkStep api call register the tag. - * - * @param tagId String unique tag id. - * @param body String requested body - * @param header Map - * @return String - * @throws IOException - */ - public static String registertag(String tagId, String body, Map header) - throws IOException { - String tagStatus = ""; - try { - ProjectLogger.log("start call for registering the tag ==" + tagId); - String analyticsBaseUrl = getConfigValue(JsonKey.ANALYTICS_API_BASE_URL); - tagStatus = - HttpUtil.sendPostRequest( - analyticsBaseUrl - + PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_TAG_API_URL) - + "/" - + tagId, - body, - header); - ProjectLogger.log( - "end call for tag registration id and status ==" + tagId + " " + tagStatus); - } catch (Exception e) { - throw e; - } - return tagStatus; - } - - public enum ObjectTypes { - user("user"), - organisation("organisation"), - batch("batch"); - - private String value; - - private ObjectTypes(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - public static String generateRandomPassword() { - String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; - StringBuilder salt = new StringBuilder(); - Random rnd = new Random(); - while (salt.length() < randomPasswordLength) { // length of the random string. - int index = (int) (rnd.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.charAt(index)); - } - String saltStr = salt.toString(); - return saltStr; - } - - /** - * This method will do the phone number validation check - * - * @param phone String - * @return boolean - */ - public static boolean validatePhoneNumber(String phone) { - String phoneNo = ""; - phoneNo = phone.replace("+", ""); - if (phoneNo.matches("\\d{10}")) return true; - else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; - else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; - else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); - } - - public static Map getEkstepHeader() { - Map headerMap = new HashMap<>(); - String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); - if (StringUtils.isBlank(header)) { - header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); - } else { - header = JsonKey.BEARER + header; - } - headerMap.put(JsonKey.AUTHORIZATION, header); - headerMap.put("Content-Type", "application/json"); - return headerMap; - } - - public static boolean validatePhone(String phNumber, String countryCode) { - PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); - String contryCode = countryCode; - if (!StringUtils.isBlank(countryCode) && (countryCode.charAt(0) != '+')) { - contryCode = "+" + countryCode; - } - Phonenumber.PhoneNumber phoneNumber = null; - try { - if (StringUtils.isBlank(countryCode)) { - contryCode = PropertiesCache.getInstance().getProperty("sunbird_default_country_code"); - } - String isoCode = phoneNumberUtil.getRegionCodeForCountryCode(Integer.parseInt(contryCode)); - phoneNumber = phoneNumberUtil.parse(phNumber, isoCode); - return phoneNumberUtil.isValidNumber(phoneNumber); - } catch (NumberParseException e) { - ProjectLogger.log("Exception occurred while validating phone number : ", e); - ProjectLogger.log(phNumber + "this phone no. is not a valid one."); - } - return false; - } - - public static boolean validateCountryCode(String countryCode) { - String pattern = "^(?:[+] ?){0,1}(?:[0-9] ?){1,3}"; - try { - Pattern patt = Pattern.compile(pattern); - Matcher matcher = patt.matcher(countryCode); - return matcher.matches(); - } catch (RuntimeException e) { - return false; - } - } - - public static boolean validateUUID(String uuidStr) { - try { - UUID.fromString(uuidStr); - return true; - } catch (Exception ex) { - return false; - } - } - - public static String getSMSBody(Map smsTemplate) { - try { - Properties props = new Properties(); - props.put("resource.loader", "class"); - props.put( - "class.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - - VelocityEngine ve = new VelocityEngine(); - ve.init(props); - smsTemplate.put("newline", "\n"); - smsTemplate.put( - "instanceName", - StringUtils.isBlank(smsTemplate.get("instanceName")) - ? "" - : smsTemplate.get("instanceName")); - Template t = ve.getTemplate("/welcomeSmsTemplate.vm"); - VelocityContext context = new VelocityContext(smsTemplate); - StringWriter writer = new StringWriter(); - t.merge(context, writer); - return writer.toString(); - } catch (Exception ex) { - ProjectLogger.log("Exception occurred while formating and sending SMS " + ex); - } - return ""; - } - - public static boolean isDateValidFormat(String format, String value) { - Date date = null; - try { - SimpleDateFormat sdf = new SimpleDateFormat(format); - date = sdf.parse(value); - if (!value.equals(sdf.format(date))) { - date = null; - } - } catch (ParseException ex) { - ProjectLogger.log(ex.getMessage(), ex); - } - return date != null; - } - - /** - * This method will create a new ProjectCommonException of type server Error and throws it. - */ - public static void createAndThrowServerError() { - throw new ProjectCommonException( - ResponseCode.SERVER_ERROR.getErrorCode(), - ResponseCode.SERVER_ERROR.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - /** - * This method will create and return server exception to caller. - * - * @param responseCode ResponseCode - * @return ProjectCommonException - */ - public static ProjectCommonException createServerError(ResponseCode responseCode) { - return new ProjectCommonException( - responseCode.getErrorCode(), - responseCode.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - - /** - * This method will create ProjectCommonException of type invalidUserDate exception and throws it. - */ - public static void createAndThrowInvalidUserDataException() { - throw new ProjectCommonException( - ResponseCode.invalidUsrData.getErrorCode(), - ResponseCode.invalidUsrData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - /** - * Method to verify url is valid or not. - * - * @param url String - * @return boolean - */ - public static boolean isUrlvalid(String url) { - String[] schemes = {"http", "https"}; - UrlValidator urlValidator = new UrlValidator(schemes); - return urlValidator.isValid(url); - } - - public static String getConfigValue(String key) { - if (StringUtils.isNotBlank(System.getenv(key))) { - return System.getenv(key); - } - return propertiesCache.readProperty(key); - } - - /** - * This method will create index for Elastic search as follow "telemetry.raw.yyyy.mm" - * - * @return - */ - public static String createIndex() { - Calendar cal = Calendar.getInstance(); - return new StringBuffer() - .append(INDEX_NAME) - .append("." + cal.get(Calendar.YEAR)) - .append( - "." - + ((cal.get(Calendar.MONTH) + 1) > 9 - ? (cal.get(Calendar.MONTH) + 1) - : "0" + (cal.get(Calendar.MONTH) + 1))) - .toString(); - } - - /** - * This method will check whether Array contains only empty string or not - * - * @param strArray String[] - * @return boolean - */ - public static boolean isNotEmptyStringArray(String[] strArray) { - for (String str : strArray) { - if (StringUtils.isNotEmpty(str)) { - return false; - } - } - return true; - } - - /** - * Method to convert List of map to Json String. - * - * @param mapList List of map. - * @return String List of map converted as Json string. - */ - public static String convertMapToJsonString(List> mapList) { - try { - return mapper.writeValueAsString(mapList); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - return null; - } - - /** - * Method to remove attributes from map. - * - * @param map contains data as key value. - * @param keys list of string that has to be remove from map if presents. - */ - public static void removeUnwantedFields(Map map, String... keys) { - Arrays.stream(keys) - .forEach( - x -> { - map.remove(x); - }); - } - - /** - * Method to convert Json string to Map. - * - * @param jsonString represents json string. - * @return map corresponding to json string. - * @throws IOException - */ - public static Map convertJsonStringToMap(String jsonString) throws IOException { - return mapper.readValue(jsonString, Map.class); - } - - /** - * Method to convert Request object to module specific POJO request. - * - * @param request Represents the incoming request object. - * @param clazz Target POJO class. - * @param Target request object type. - * @return request object of target type. - */ - public static T convertToRequestPojo(Request request, Class clazz) { - return mapper.convertValue(request.getRequest(), clazz); - } - - /** - * This method will take number of days in request and provide date range. Date range is - * calculated as STARTDATE and ENDDATE, start date will be current date minus provided number of - * days and ENDDATE will be current date minus one day. If date is less than equal to zero then it - * will return empty map. - * - * @param numDays Number of days. - * @return Map with STARTDATE and ENDDATE key in YYYY_MM_DD_FORMATTER format. - */ - public static Map getDateRange(int numDays) { - Map map = new HashMap<>(); - if (numDays <= 0) { - return map; - } - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, -numDays); - map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); - cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, -1); - map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); - return map; - } - - /** - * This method will be used to create ProjectCommonException for all kind of client error for the - * given response code(enum). - * - * @param : An enum of all the api responses. - * @return ProjectCommonException - */ - public static ProjectCommonException createClientException(ResponseCode responseCode) { - return new ProjectCommonException( - responseCode.getErrorCode(), - responseCode.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - public static String getLmsUserId(String fedUserId) { - String userId = fedUserId; - String prefix = - "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; - if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { - userId = fedUserId.replace(prefix, ""); - } - return userId; - } - - public static String getFirstNCharacterString(String originalText, int noOfChar) { - if (StringUtils.isBlank(originalText)) { - return ""; - } - String firstNChars = ""; - if (originalText.length() > noOfChar) { - firstNChars = originalText.substring(0, noOfChar); - } else { - firstNChars = originalText; - } - return firstNChars; - } - - public enum MigrateAction { - ACCEPT("accept"), - REJECT("reject"); - private String value; - - MigrateAction(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PropertiesCache.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PropertiesCache.java deleted file mode 100644 index 4ab67c6fd..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PropertiesCache.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.sunbird.common.models.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.StringUtils; - -/* - * @author Amit Kumar - * - * this class is used for reading properties file - */ -public class PropertiesCache { - - private final String[] fileName = { - "elasticsearch.config.properties", - "cassandra.config.properties", - "dbconfig.properties", - "externalresource.properties", - "sso.properties", - "userencryption.properties", - "profilecompleteness.properties", - "mailTemplates.properties" - }; - private final Properties configProp = new Properties(); - public final Map attributePercentageMap = new ConcurrentHashMap<>(); - private static PropertiesCache propertiesCache = null; - - /** private default constructor */ - private PropertiesCache() { - for (String file : fileName) { - InputStream in = this.getClass().getClassLoader().getResourceAsStream(file); - try { - configProp.load(in); - } catch (IOException e) { - ProjectLogger.log("Error in properties cache", e); - } - } - loadWeighted(); - } - - public static PropertiesCache getInstance() { - - // change the lazy holder implementation to simple singleton implementation ... - if (null == propertiesCache) { - synchronized (PropertiesCache.class) { - if (null == propertiesCache) { - propertiesCache = new PropertiesCache(); - } - } - } - - return propertiesCache; - } - - public void saveConfigProperty(String key, String value) { - configProp.setProperty(key, value); - } - - public String getProperty(String key) { - String value = System.getenv(key); - if (StringUtils.isNotBlank(value)) return value; - return configProp.getProperty(key) != null ? configProp.getProperty(key) : key; - } - - private void loadWeighted() { - String key = configProp.getProperty("user.profile.attribute"); - String value = configProp.getProperty("user.profile.weighted"); - if (StringUtils.isBlank(key)) { - ProjectLogger.log("Profile completeness value is not set==", LoggerEnum.INFO.name()); - } else { - String keys[] = key.split(","); - String values[] = value.split(","); - if (keys.length == value.length()) { - // then take the value from user - ProjectLogger.log("weighted value is provided by user."); - for (int i = 0; i < keys.length; i++) - attributePercentageMap.put(keys[i], new Float(values[i])); - } else { - // equally divide all the provided field. - ProjectLogger.log("weighted value is not provided by user."); - float perc = (float) 100.0 / keys.length; - for (int i = 0; i < keys.length; i++) attributePercentageMap.put(keys[i], perc); - } - } - } - - /** - * Method to read value from resource file . - * - * @param key - * @return - */ - public String readProperty(String key) { - String value = System.getenv(key); - if (StringUtils.isNotBlank(value)) return value; - return configProp.getProperty(key); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/RestUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/RestUtil.java deleted file mode 100644 index d2086e9e1..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/RestUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.sunbird.common.models.util; - -import akka.dispatch.Futures; -import com.mashape.unirest.http.HttpResponse; -import com.mashape.unirest.http.JsonNode; -import com.mashape.unirest.http.Unirest; -import com.mashape.unirest.http.async.Callback; -import com.mashape.unirest.http.exceptions.UnirestException; -import com.mashape.unirest.request.BaseRequest; -import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; -import scala.concurrent.Future; -import scala.concurrent.Promise; - -/** @author Mahesh Kumar Gangula */ -public class RestUtil { - - static { - String apiKey = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); - if (StringUtils.isBlank(apiKey)) { - apiKey = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); - } - Unirest.setDefaultHeader("Content-Type", "application/json"); - Unirest.setDefaultHeader("Authorization", "Bearer " + apiKey); - Unirest.setDefaultHeader("Connection", "Keep-Alive"); - } - - public static Future> executeAsync(BaseRequest request) { - ProjectLogger.log("RestUtil:execute: request url = " + request.getHttpRequest().getUrl()); - Promise> promise = Futures.promise(); - - request.asJsonAsync( - new Callback() { - - @Override - public void failed(UnirestException e) { - promise.failure(e); - } - - @Override - public void completed(HttpResponse response) { - promise.success(response); - } - - @Override - public void cancelled() { - promise.failure(new Exception("cancelled")); - } - }); - - return promise.future(); - } - - public static HttpResponse execute(BaseRequest request) throws Exception { - return request.asJson(); - } - - public static String getFromResponse(HttpResponse resp, String key) throws Exception { - String[] nestedKeys = key.split("\\."); - JSONObject obj = resp.getBody().getObject(); - - for (int i = 0; i < nestedKeys.length - 1; i++) { - String nestedKey = nestedKeys[i]; - if (obj.has(nestedKey)) obj = obj.getJSONObject(nestedKey); - } - - String val = obj.getString(nestedKeys[nestedKeys.length - 1]); - return val; - } - - public static boolean isSuccessful(HttpResponse resp) { - int status = resp.getStatus(); - return (status == 200); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/Slug.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/Slug.java deleted file mode 100644 index da58937d2..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/Slug.java +++ /dev/null @@ -1,103 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import java.net.URLDecoder; -import java.text.Normalizer; -import java.text.Normalizer.Form; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Locale; -import java.util.Set; -import java.util.regex.Pattern; -import net.sf.junidecode.Junidecode; - -/** - * This class will remove the special character,space from the provided String. - * - * @author Manzarul - */ -public class Slug { - - private static final Pattern NONLATIN = Pattern.compile("[^\\w-\\.]"); - private static final Pattern WHITESPACE = Pattern.compile("[\\s]"); - private static final Pattern DUPDASH = Pattern.compile("-+"); - - public static String makeSlug(String input, boolean transliterate) { - String origInput = input; - String tempInputValue = ""; - // Validate the input - if (input == null) { - ProjectLogger.log("Provided input value is null"); - return input; - } - // Remove extra spaces - tempInputValue = input.trim(); - // Remove URL encoding - tempInputValue = urlDecode(tempInputValue); - // If transliterate is required - if (transliterate) { - // Tranlisterate & cleanup - String transliterated = transliterate(tempInputValue); - tempInputValue = transliterated; - } - // Replace all whitespace with dashes - tempInputValue = WHITESPACE.matcher(tempInputValue).replaceAll("-"); - // Remove all accent chars - tempInputValue = Normalizer.normalize(tempInputValue, Form.NFD); - // Remove all non-latin special characters - tempInputValue = NONLATIN.matcher(tempInputValue).replaceAll(""); - // Remove any consecutive dashes - tempInputValue = normalizeDashes(tempInputValue); - // Validate before returning - validateResult(tempInputValue, origInput); - // Slug is always lowercase - return tempInputValue.toLowerCase(Locale.ENGLISH); - } - - private static void validateResult(String input, String origInput) { - // Check if we are not left with a blank - if (input.length() == 0) { - ProjectLogger.log("Failed to cleanup the input " + origInput); - } - } - - public static String transliterate(String input) { - return Junidecode.unidecode(input); - } - - public static String urlDecode(String input) { - String value = ""; - try { - value = URLDecoder.decode(input, "UTF-8"); - } catch (Exception ex) { - ProjectLogger.log(ex.getMessage(), ex); - } - return value; - } - - public static String removeDuplicateChars(String text) { - Set set = new LinkedHashSet<>(); - StringBuilder ret = new StringBuilder(text.length()); - if (text.length() == 0) { - return ""; - } - for (int i = 0; i < text.length(); i++) { - set.add(text.charAt(i)); - } - Iterator itr = set.iterator(); - while (itr.hasNext()) { - ret.append(itr.next()); - } - return ret.toString(); - } - - public static String normalizeDashes(String text) { - String clean = DUPDASH.matcher(text).replaceAll("-"); - // Special case that only dashes remain - if ("-".equals(clean) || "--".equals(clean)) return ""; - int startIdx = (clean.startsWith("-") ? 1 : 0); - int endIdx = (clean.endsWith("-") ? 1 : 0); - clean = clean.substring(startIdx, (clean.length() - endIdx)); - return clean; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/StringFormatter.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/StringFormatter.java deleted file mode 100644 index 61d8e1851..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/StringFormatter.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.sunbird.common.models.util; - -/** - * Helper class for String formatting operations. - * - * @author Amit Kumar - */ -public class StringFormatter { - - public static final String DOT = "."; - public static final String AND = " and "; - public static final String OR = " or "; - public static final String COMMA = ", "; - - private StringFormatter() {} - - /** - * Helper method to construct dot formatted string. - * - * @param params One or more strings to be joined by dot - * @return Dot formatted string - */ - public static String joinByDot(String... params) { - return String.join(DOT, params); - } - - /** - * Helper method to construct or formatted string. - * - * @param params One or more strings to be joined by or - * @return Or formatted string - */ - public static String joinByOr(String... params) { - return String.join(OR, params); - } - - /** - * Helper method to construct and formatted string. - * - * @param params One or more strings to be joined by and - * @return and formatted string - */ - public static String joinByAnd(String... params) { - return String.join(AND, params); - } - - /** - * Helper method to construct and formatted string. - * - * @param params One or more strings to be joined by comma - * @return and formatted string - */ - public static String joinByComma(String... params) { - return String.join(COMMA, params); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/TelemetryEnvKey.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/TelemetryEnvKey.java deleted file mode 100644 index 3f0a3c3be..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/TelemetryEnvKey.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.sunbird.common.models.util; - -/** Created by arvind on 9/4/18. */ -public class TelemetryEnvKey { - - public static final String USER = "User"; - public static final String ORGANISATION = "Organisation"; - public static final String BADGE = "Badge"; - public static final String BATCH = "CourseBatch"; - public static final String SKILL = "Skill"; - public static final String GEO_LOCATION = "GeoLocation"; - public static final String BADGE_ISSUER = "BadgeIssuer"; - public static final String BADGE_CLASS = "BadgeClass"; - public static final String BADGE_ASSERTION = "BadgeAssertion"; - public static final String PAGE = "Page"; - public static final String SYSTEM_SETTINGS = "SystemSetting"; - public static final String MASTER_KEY = "MasterKey"; - public static final String OBJECT_STORE = "ObjectStore"; - public static final String LOCATION = "Location"; - public static final String PAGE_SECTION = "PageSection"; - public static final String REQUEST_UPPER_CAMEL = "Request"; - public static final String QR_CODE_DOWNLOAD = "QRCodeDownload"; - public static final String COURSE_CREATE = "COURSE_CREATE"; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureCloudService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureCloudService.java deleted file mode 100644 index 6c9e6d283..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureCloudService.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.sunbird.common.models.util.azure; - -import java.io.File; -import java.util.List; - -/** Created by arvind on 24/8/17. */ -public class AzureCloudService implements CloudService { - - @Override - public String uploadFile(String containerName, String fileName, String fileLocation) { - return AzureFileUtility.uploadFile(containerName, fileName, fileLocation); - } - - @Override - public boolean downLoadFile(String containerName, String fileName, String downloadFolder) { - return AzureFileUtility.downloadFile(containerName, fileName, downloadFolder); - } - - @Override - public String uploadFile(String containerName, File file) { - return AzureFileUtility.uploadFile(containerName, file); - } - - @Override - public boolean deleteFile(String containerName, String fileName) { - return AzureFileUtility.deleteFile(containerName, fileName); - } - - @Override - public List listAllFiles(String containerName) { - return AzureFileUtility.listAllBlobbs(containerName); - } - - @Override - public boolean deleteContainer(String containerName) { - return AzureFileUtility.deleteContainer(containerName); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureConnectionManager.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureConnectionManager.java deleted file mode 100644 index f7ba726ba..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureConnectionManager.java +++ /dev/null @@ -1,130 +0,0 @@ -/** */ -package org.sunbird.common.models.util.azure; - -import com.microsoft.azure.storage.CloudStorageAccount; -import com.microsoft.azure.storage.StorageException; -import com.microsoft.azure.storage.blob.BlobContainerPermissions; -import com.microsoft.azure.storage.blob.BlobContainerPublicAccessType; -import com.microsoft.azure.storage.blob.CloudBlobClient; -import com.microsoft.azure.storage.blob.CloudBlobContainer; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.Locale; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; - -/** - * This class will manage azure connection. - * - * @author Manzarul - */ -public class AzureConnectionManager { - - private static String accountName = ""; - private static String accountKey = ""; - private static String storageAccountString; - private static AzureConnectionManager connectionManager; - - static { - String name = System.getenv(JsonKey.ACCOUNT_NAME); - String key = System.getenv(JsonKey.ACCOUNT_KEY); - if (StringUtils.isBlank(name) || StringUtils.isBlank(key)) { - ProjectLogger.log( - "Azure account name and key is not provided by environment variable." + name + " " + key); - accountName = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_NAME); - accountKey = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_KEY); - storageAccountString = - "DefaultEndpointsProtocol=https;AccountName=" - + accountName - + ";AccountKey=" - + accountKey - + ";EndpointSuffix=core.windows.net"; - } else { - accountName = name; - accountKey = key; - ProjectLogger.log( - "Azure account name and key is provided by environment variable." + name + " " + key); - storageAccountString = - "DefaultEndpointsProtocol=https;AccountName=" - + accountName - + ";AccountKey=" - + accountKey - + ";EndpointSuffix=core.windows.net"; - } - } - - private AzureConnectionManager() throws CloneNotSupportedException { - if (connectionManager != null) throw new CloneNotSupportedException(); - } - - /** - * This method will provide Azure CloudBlobContainer object or in case of error it will provide - * null; - * - * @param containerName String - * @return CloudBlobContainer or null - */ - public static CloudBlobContainer getContainer(String containerName, boolean isPublicAccess) { - - try { - CloudBlobClient cloudBlobClient = getBlobClient(); - // Get a reference to a container , The container name must be lower case - CloudBlobContainer container = - cloudBlobClient.getContainerReference(containerName.toLowerCase(Locale.ENGLISH)); - // Create the container if it does not exist. - boolean response = container.createIfNotExists(); - ProjectLogger.log("container creation done if not exist==" + response); - // Create a permissions object. - if (isPublicAccess) { - BlobContainerPermissions containerPermissions = new BlobContainerPermissions(); - // Include public access in the permissions object. - containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER); - // Set the permissions on the container. - container.uploadPermissions(containerPermissions); - } - return container; - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return null; - } - - public static CloudBlobContainer getContainerReference(String containerName) { - - CloudBlobContainer container = null; - try { - // Create the blob client. - CloudBlobClient blobClient = getBlobClient(); - // Retrieve reference to a previously created container. - container = blobClient.getContainerReference(containerName.toLowerCase(Locale.ENGLISH)); - if (container.exists()) { - return container; - } - } catch (URISyntaxException e) { - ProjectLogger.log(e.getMessage(), e); - } catch (StorageException e) { - ProjectLogger.log(e.getMessage(), e); - } - ProjectLogger.log("Container does not exist ==" + containerName); - return null; - } - - private static CloudBlobClient getBlobClient() { - - // Retrieve storage account from connection-string. - CloudStorageAccount storageAccount = null; - CloudBlobClient blobClient = null; - try { - storageAccount = CloudStorageAccount.parse(storageAccountString); - // Create the blob client. - blobClient = storageAccount.createCloudBlobClient(); - } catch (URISyntaxException e) { - ProjectLogger.log(e.getMessage(), e); - } catch (InvalidKeyException e) { - ProjectLogger.log(e.getMessage(), e); - } - return blobClient; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureFileUtility.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureFileUtility.java deleted file mode 100644 index 0d5e1c14e..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureFileUtility.java +++ /dev/null @@ -1,231 +0,0 @@ -/** */ -package org.sunbird.common.models.util.azure; - -import com.microsoft.azure.storage.StorageException; -import com.microsoft.azure.storage.blob.CloudBlobContainer; -import com.microsoft.azure.storage.blob.CloudBlockBlob; -import com.microsoft.azure.storage.blob.ListBlobItem; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.apache.tika.Tika; -import org.sunbird.common.models.util.ProjectLogger; - -/** @author Manzarul */ -public class AzureFileUtility { - - private static final String DEFAULT_CONTAINER = "default"; - - /** - * This method will remove the file from Azure Storage. - * - * @param fileName - * @param containerName - * @return boolean - */ - public static boolean deleteFile(String containerName, String fileName) { - if (fileName == null) { - ProjectLogger.log("File name can not be null"); - return false; - } - if (StringUtils.isBlank(containerName)) { - ProjectLogger.log("Container name can't be null or empty"); - return false; - } - CloudBlobContainer container = AzureConnectionManager.getContainer(containerName, true); - if (container == null) { - ProjectLogger.log("Unable to get Azure contains object"); - return false; - } - try { - // Retrieve reference to a blob named "myimage.jpg". - CloudBlockBlob blob = container.getBlockBlobReference(fileName); - // Delete the blob. - boolean response = blob.deleteIfExists(); - if (!response) { - ProjectLogger.log("Provided file not found to delete."); - } - return true; - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return false; - } - - /** - * This method will remove the container from Azure Storage. - * - * @param containerName - * @return boolean - */ - public static boolean deleteContainer(String containerName) { - if (StringUtils.isBlank(containerName)) { - ProjectLogger.log("Container name can't be null or empty"); - return false; - } - CloudBlobContainer container = AzureConnectionManager.getContainer(containerName, true); - if (container == null) { - ProjectLogger.log("Unable to get Azure contains object"); - return false; - } - try { - boolean response = container.deleteIfExists(); - if (!response) { - ProjectLogger.log("Container not found.."); - } else { - ProjectLogger.log("Container is deleted==="); - } - return true; - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return false; - } - - public static String uploadFile(String containerName, String blobName, String fileName) { - - CloudBlobContainer container = AzureConnectionManager.getContainer(containerName, true); - // Create or overwrite the "myimage.jpg" blob with contents from a local file. - CloudBlockBlob blob = null; - String fileUrl = null; - FileInputStream fis = null; - Tika tika = new Tika(); - try { - blob = container.getBlockBlobReference(blobName); - File source = new File(fileName); - fis = new FileInputStream(source); - String mimeType = tika.detect(source); - ProjectLogger.log("File - " + source.getName() + " mimeType " + mimeType); - blob.getProperties().setContentType(mimeType); - blob.upload(fis, source.length()); - // fileUrl = blob.getStorageUri().getPrimaryUri().getPath(); - fileUrl = blob.getUri().toString(); - } catch (URISyntaxException | IOException e) { - ProjectLogger.log("Unable to upload file :" + fileName, e); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } finally { - if (null != fis) { - try { - fis.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - - return fileUrl; - } - - public static String uploadFile(String containerName, File source) { - - String containerPath = ""; - String filePath = ""; - Tika tika = new Tika(); - String contrName = containerName; - - if (StringUtils.isBlank(containerName)) { - contrName = DEFAULT_CONTAINER; - } else { - contrName = containerName.toLowerCase(); - } - if (containerName.startsWith("/")) { - contrName = containerName.substring(1); - } - if (contrName.contains("/")) { - String[] arr = contrName.split("/", 2); - containerPath = arr[0]; - if (arr[1].length() > 0 && arr[1].endsWith("/")) { - filePath = arr[1]; - } else if (arr[1].length() > 0) { - filePath = arr[1] + "/"; - } - } else { - containerPath = contrName; - } - - CloudBlobContainer container = AzureConnectionManager.getContainer(containerPath, true); - // Create or overwrite the "myimage.jpg" blob with contents from a local file. - CloudBlockBlob blob = null; - String fileUrl = null; - FileInputStream fis = null; - try { - blob = container.getBlockBlobReference(filePath + source.getName()); - // File source = new File(fileName); - fis = new FileInputStream(source); - String mimeType = tika.detect(source); - ProjectLogger.log("File - " + source.getName() + " mimeType " + mimeType); - blob.getProperties().setContentType(mimeType); - blob.upload(fis, source.length()); - // fileUrl = blob.getStorageUri().getPrimaryUri().getPath(); - fileUrl = blob.getUri().toString(); - } catch (URISyntaxException | IOException e) { - ProjectLogger.log("Unable to upload file :" + source.getName(), e); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } finally { - if (null != fis) { - try { - fis.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return fileUrl; - } - - public static boolean downloadFile(String containerName, String blobName, String downloadFolder) { - - String dwnldFolder = ""; - boolean flag = false; - CloudBlobContainer container = AzureConnectionManager.getContainer(containerName, true); - // Create or overwrite blob with contents . - CloudBlockBlob blob = null; - FileOutputStream fos = null; - - try { - blob = container.getBlockBlobReference(blobName); - if (blob.exists()) { - if (!(downloadFolder.endsWith(("/")))) { - dwnldFolder = downloadFolder + "/"; - } - File file = new File(dwnldFolder + blobName); - fos = new FileOutputStream(file); - blob.download(fos); - } - } catch (URISyntaxException | StorageException | FileNotFoundException e) { - ProjectLogger.log("Unable to upload blobfile :" + blobName, e); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } finally { - if (null != fos) { - try { - fos.close(); - } catch (IOException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return flag; - } - - public static List listAllBlobbs(String containerName) { - - List blobsList = new ArrayList<>(); - CloudBlobContainer container = AzureConnectionManager.getContainer(containerName, true); - // Loop over blobs within the container and output the URI to each of them. - if (container != null) { - for (ListBlobItem blobItem : container.listBlobs()) { - blobsList.add(blobItem.getUri().toString()); - } - } - return blobsList; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudService.java deleted file mode 100644 index a36183057..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudService.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.sunbird.common.models.util.azure; - -import java.io.File; -import java.util.List; - -/** Created by arvind on 24/8/17. */ -public interface CloudService { - - String uploadFile(String containerName, String filName, String fileLocation); - - boolean downLoadFile(String containerName, String fileName, String downloadFolder); - - String uploadFile(String containerName, File file); - - boolean deleteFile(String containerName, String fileName); - - List listAllFiles(String containerName); - - boolean deleteContainer(String containerName); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudServiceFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudServiceFactory.java deleted file mode 100644 index 936f2a1fd..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudServiceFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.sunbird.common.models.util.azure; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.sunbird.common.models.util.ProjectUtil; - -/** - * Factory class to store the various upload download services like Azure , Amazon S3 etc... Created - * by arvind on 24/8/17. - */ -public class CloudServiceFactory { - - private static Map factory = new HashMap<>(); - private static List allowedServiceNames = Arrays.asList("Azure", "Amazon S3"); - - private CloudServiceFactory() {} - - /** - * @param serviceName - * @return - */ - public static Object get(String serviceName) { - - if (ProjectUtil.isNotNull(factory.get(serviceName))) { - return factory.get(serviceName); - } else { - // create the service with the given name - return createService(serviceName); - } - } - - /** - * @param serviceName - * @return - */ - private static CloudService createService(String serviceName) { - - if (!(allowedServiceNames.contains(serviceName))) { - return null; - } - - synchronized (CloudServiceFactory.class) { - if (ProjectUtil.isNull(factory.get(serviceName)) && "Azure".equalsIgnoreCase(serviceName)) { - CloudService service = new AzureCloudService(); - factory.put("Azure", service); - } - } - return factory.get(serviceName); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/package-info.java deleted file mode 100644 index 37f0b9c05..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util.azure; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DataMaskingService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DataMaskingService.java deleted file mode 100644 index ffe7d91f4..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DataMaskingService.java +++ /dev/null @@ -1,58 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity; - -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; - -/** @author Manzarul */ -public interface DataMaskingService { - - /** - * This method will allow to mask user phone number. - * - * @param phone String - * @return String - */ - String maskPhone(String phone); - - /** - * This method will allow user to mask email. - * - * @param email String - * @return String - */ - String maskEmail(String email); - - /** - * @param data - * @return - */ - default String maskData(String data) { - if (StringUtils.isBlank(data) || data.length() <= 3) { - return data; - } - int lenght = data.length() - 4; - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < data.length(); i++) { - if (i < lenght) { - builder.append(JsonKey.REPLACE_WITH_ASTERISK); - } else { - builder.append(data.charAt(i)); - } - } - return builder.toString(); - } - - /** - * Mask an OTP - * @param otp - * @return Depending on the length - 6, 4, masks 1 character - */ - default String maskOTP(String otp) { - if (otp.length() >= 6) { - return otp.replaceAll("(^[^*]{5}|(?!^)\\G)[^*]", "$1*"); - } else { - return otp.replaceAll("(^[^*]{3}|(?!^)\\G)[^*]", "$1*"); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DecryptionService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DecryptionService.java deleted file mode 100644 index 0d32b2c13..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/DecryptionService.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.sunbird.common.models.util.datasecurity; - -import java.util.List; -import java.util.Map; - -/** - * This service will have data decryption methods. decryption logic will differ based on imp - * classes. - * - * @author Manzarul - */ -public interface DecryptionService { - - String ALGORITHM = "AES"; - int ITERATIONS = 3; - byte[] keyValue = - new byte[] {'T', 'h', 'i', 's', 'A', 's', 'I', 'S', 'e', 'r', 'c', 'e', 'K', 't', 'e', 'y'}; - - /** - * This method will take input as key value pair , value can be any primitive or String or both or - * can have another map as values. inner map will also have values as primitive or String or both - * - * @param data Map - * @return Map - * @throws Exception - */ - Map decryptData(Map data); - - /** - * This method will take list of map as an input to decrypt the data, after decryption it will - * return same map with decrypted values. values in side map can have primitive , String or - * another map have primitive , String values. - * - * @param data List> - * @return List> - * @throws Exception - */ - List> decryptData(List> data); - - /** - * Decrypt given data. - * - * @param data Input data - * @return Decrypted data - */ - String decryptData(String data); - - /** - * Decrypt given data. - * - * @param data Input data - * @return Decrypted data - * @throws ProjectCommonException in case of an error during decryption. - */ - String decryptData(String data, boolean throwExceptionOnFailure); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/EncryptionService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/EncryptionService.java deleted file mode 100644 index 33db2d2b6..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/EncryptionService.java +++ /dev/null @@ -1,49 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity; - -import java.util.List; -import java.util.Map; - -/** - * This service will have the data encryption logic. these logic will differ based on implementation - * class. - * - * @author Manzarul - */ -public interface EncryptionService { - - String ALGORITHM = "AES"; - int ITERATIONS = 3; - byte[] keyValue = - new byte[] {'T', 'h', 'i', 's', 'A', 's', 'I', 'S', 'e', 'r', 'c', 'e', 'K', 't', 'e', 'y'}; - - /** - * This method will take input as key value pair , value can be any primitive or String or both or - * can have another map as values. inner map will also have values as primitive or String or both - * - * @param data Map - * @return Map - * @throws Exception - */ - Map encryptData(Map data) throws Exception; - - /** - * This method will take list of map as an input to encrypt the data, after encryption it will - * return same map with encrypted values. values in side map can have primitive , String or - * another map have primitive , String values. - * - * @param data List> - * @return List> - * @throws Exception - */ - List> encryptData(List> data) throws Exception; - - /** - * This method will take String as an input and encrypt the String and return back. - * - * @param data String - * @return String - * @throws Exception - */ - String encryptData(String data) throws Exception; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/OneWayHashing.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/OneWayHashing.java deleted file mode 100644 index 6065bbe22..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/OneWayHashing.java +++ /dev/null @@ -1,40 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity; - -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import org.sunbird.common.models.util.ProjectLogger; - -/** - * This class will do one way data hashing. - * - * @author Manzarul - */ -public class OneWayHashing { - - private OneWayHashing() {} - - /** - * This method will encrypt value using SHA-256 . it is one way encryption. - * - * @param val String - * @return String encrypted value or empty in case of exception - */ - public static String encryptVal(String val) { - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(val.getBytes(StandardCharsets.UTF_8)); - byte byteData[] = md.digest(); - // convert the byte to hex format method 1 - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < byteData.length; i++) { - sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1)); - } - ProjectLogger.log("encrypted value is==: " + sb.toString()); - return sb.toString(); - } catch (Exception e) { - ProjectLogger.log("Error while encrypting", e); - } - return ""; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Decoder.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Decoder.java deleted file mode 100644 index 1aa96257b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Decoder.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.sunbird.common.models.util.datasecurity.impl; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PushbackInputStream; - -/** - * This class implements a BASE64 Character decoder as specified in RFC1521. - * - *

This RFC is part of the MIME specification which is published by the Internet Engineering Task - * Force (IETF). Unlike some other encoding schemes there is nothing in this encoding that tells the - * decoder where a buffer starts or stops, so to use it you will need to isolate your encoded data - * into a single chunk and then feed them this decoder. The simplest way to do that is to read all - * of the encoded data into a string and then use: - * - *

- *      byte    mydata[];
- *      BASE64Decoder base64 = new BASE64Decoder();
- *
- *      mydata = base64.decodeBuffer(bufferString);
- * 
- * - * This will decode the String in bufferString and give you an array of bytes in the array - * myData. - * - *

On errors, this class throws a CEFormatException with the following detail strings: - * - *

- *    "BASE64Decoder: Not enough bytes for an atom."
- * 
- * - * @author Chuck McManis - * @see CharacterEncoder - * @see BASE64Decoder - */ -public class BASE64Decoder extends CharacterDecoder { - /** This class has 4 bytes per atom */ - protected int bytesPerAtom() { - return (4); - } - - /** Any multiple of 4 will do, 72 might be common */ - protected int bytesPerLine() { - return (72); - } - - /** This character array provides the character to value map based on RFC1521. */ - private static final char pem_array[] = { - // 0 1 2 3 4 5 6 7 - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 1 - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 2 - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 3 - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 4 - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 5 - 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 6 - '4', '5', '6', '7', '8', '9', '+', '/' // 7 - }; - - private static final byte pem_convert_array[] = new byte[256]; - - static { - for (int i = 0; i < 255; i++) { - pem_convert_array[i] = -1; - } - for (int i = 0; i < pem_array.length; i++) { - pem_convert_array[pem_array[i]] = (byte) i; - } - } - - byte decode_buffer[] = new byte[4]; - - /** Decode one BASE64 atom into 1, 2, or 3 bytes of data. */ - @SuppressWarnings("fallthrough") - protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem) - throws IOException { - int i; - byte a = -1, b = -1, c = -1, d = -1; - - if (rem < 2) { - throw new IOException("BASE64Decoder: Not enough bytes for an atom."); - } - do { - i = inStream.read(); - if (i == -1) { - throw new IOException(); - } - } while (i == '\n' || i == '\r'); - decode_buffer[0] = (byte) i; - - i = readFully(inStream, decode_buffer, 1, rem - 1); - if (i == -1) { - throw new IOException(); - } - - if (rem > 3 && decode_buffer[3] == '=') { - rem = 3; - } - if (rem > 2 && decode_buffer[2] == '=') { - rem = 2; - } - switch (rem) { - case 4: - d = pem_convert_array[decode_buffer[3] & 0xff]; - // NOBREAK - case 3: - c = pem_convert_array[decode_buffer[2] & 0xff]; - // NOBREAK - case 2: - b = pem_convert_array[decode_buffer[1] & 0xff]; - a = pem_convert_array[decode_buffer[0] & 0xff]; - break; - } - - switch (rem) { - case 2: - outStream.write((byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3))); - break; - case 3: - outStream.write((byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3))); - outStream.write((byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf))); - break; - case 4: - outStream.write((byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3))); - outStream.write((byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf))); - outStream.write((byte) (((c << 6) & 0xc0) | (d & 0x3f))); - break; - } - return; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Encoder.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Encoder.java deleted file mode 100644 index 7a1ea376b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/BASE64Encoder.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.sunbird.common.models.util.datasecurity.impl; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * This class implements a BASE64 Character encoder as specified in RFC1521. This RFC is part of the - * MIME specification as published by the Internet Engineering Task Force (IETF). Unlike some other - * encoding schemes there is nothing in this encoding that indicates where a buffer starts or ends. - * - *

This means that the encoded text will simply start with the first line of encoded text and end - * with the last line of encoded text. - * - * @author Chuck McManis - * @see CharacterEncoder - * @see BASE64Decoder - */ -public class BASE64Encoder extends CharacterEncoder { - /** this class encodes three bytes per atom. */ - protected int bytesPerAtom() { - return (3); - } - - /** - * this class encodes 57 bytes per line. This results in a maximum of 57/3 * 4 or 76 characters - * per output line. Not counting the line termination. - */ - protected int bytesPerLine() { - return (57); - } - - /** This array maps the characters to their 6 bit values */ - private static final char pem_array[] = { - // 0 1 2 3 4 5 6 7 - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 1 - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 2 - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 3 - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 4 - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 5 - 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 6 - '4', '5', '6', '7', '8', '9', '+', '/' // 7 - }; - - /** - * encodeAtom - Take three bytes of input and encode it as 4 printable characters. Note that if - * the length in len is less than three is encodes either one or two '=' signs to indicate padding - * characters. - */ - protected void encodeAtom(OutputStream outStream, byte data[], int offset, int len) - throws IOException { - byte a, b, c; - - if (len == 1) { - a = data[offset]; - b = 0; - c = 0; - outStream.write(pem_array[(a >>> 2) & 0x3F]); - outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); - outStream.write('='); - outStream.write('='); - } else if (len == 2) { - a = data[offset]; - b = data[offset + 1]; - c = 0; - outStream.write(pem_array[(a >>> 2) & 0x3F]); - outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); - outStream.write(pem_array[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); - outStream.write('='); - } else { - a = data[offset]; - b = data[offset + 1]; - c = data[offset + 2]; - outStream.write(pem_array[(a >>> 2) & 0x3F]); - outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); - outStream.write(pem_array[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); - outStream.write(pem_array[c & 0x3F]); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterDecoder.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterDecoder.java deleted file mode 100644 index 3a52e5fca..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterDecoder.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.sunbird.common.models.util.datasecurity.impl; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PushbackInputStream; -import java.nio.ByteBuffer; - -/** - * This class defines the decoding half of character encoders. A character decoder is an algorithim - * for transforming 8 bit binary data that has been encoded into text by a character encoder, back - * into original binary form. - * - *

The character encoders, in general, have been structured around a central theme that binary - * data can be encoded into text that has the form: - * - *

- *      [Buffer Prefix]
- *      [Line Prefix][encoded data atoms][Line Suffix]
- *      [Buffer Suffix]
- * 
- * - * Of course in the simplest encoding schemes, the buffer has no distinct prefix of suffix, however - * all have some fixed relationship between the text in an 'atom' and the binary data itself. - * - *

In the CharacterEncoder and CharacterDecoder classes, one complete chunk of data is referred - * to as a buffer. Encoded buffers are all text, and decoded buffers (sometimes just referred - * to as buffers) are binary octets. - * - *

To create a custom decoder, you must, at a minimum, overide three abstract methods in this - * class. - * - *

- *
bytesPerAtom which tells the decoder how many bytes to expect from decodeAtom - *
decodeAtom which decodes the bytes sent to it as text. - *
bytesPerLine which tells the encoder the maximum number of bytes per line. - *
- * - * In general, the character decoders return error in the form of a CEFormatException. The syntax of - * the detail string is - * - *
- *      DecoderClassName: Error message.
- * 
- * - * Several useful decoders have already been written and are referenced in the See Also list below. - * - * @author Chuck McManis - * @see CharacterEncoder - * @see BASE64Decoder - */ -public abstract class CharacterDecoder { - public CharacterDecoder() {} - /** Return the number of bytes per atom of decoding */ - protected abstract int bytesPerAtom(); - - /** Return the maximum number of bytes that can be encoded per line */ - protected abstract int bytesPerLine(); - - /** decode the beginning of the buffer, by default this is a NOP. */ - protected void decodeBufferPrefix(PushbackInputStream aStream, OutputStream bStream) - throws IOException {} - - /** decode the buffer suffix, again by default it is a NOP. */ - protected void decodeBufferSuffix(PushbackInputStream aStream, OutputStream bStream) - throws IOException {} - - /** - * This method should return, if it knows, the number of bytes that will be decoded. Many formats - * such as uuencoding provide this information. By default we return the maximum bytes that could - * have been encoded on the line. - */ - protected int decodeLinePrefix(PushbackInputStream aStream, OutputStream bStream) - throws IOException { - return (bytesPerLine()); - } - - /** - * This method post processes the line, if there are error detection or correction codes in a - * line, they are generally processed by this method. The simplest version of this method looks - * for the (newline) character. - */ - protected void decodeLineSuffix(PushbackInputStream aStream, OutputStream bStream) - throws IOException {} - - /** - * This method does an actual decode. It takes the decoded bytes and writes them to the - * OutputStream. The integer l tells the method how many bytes are required. This is always - * <= bytesPerAtom(). - */ - protected void decodeAtom(PushbackInputStream aStream, OutputStream bStream, int l) - throws IOException { - throw new IOException(); - } - - /** This method works around the bizarre semantics of BufferedInputStream's read method. */ - protected int readFully(InputStream in, byte buffer[], int offset, int len) - throws IOException { - for (int i = 0; i < len; i++) { - int q = in.read(); - if (q == -1) return ((i == 0) ? -1 : i); - buffer[i + offset] = (byte) q; - } - return len; - } - - /** - * Decode the text from the InputStream and write the decoded octets to the OutputStream. This - * method runs until the stream is exhausted. - * - * @exception IOException An error has occurred while decoding - * @exception IOException The input stream is unexpectedly out of data - */ - public void decodeBuffer(InputStream aStream, OutputStream bStream) throws IOException { - int i; - int totalBytes = 0; - - PushbackInputStream ps = new PushbackInputStream(aStream); - decodeBufferPrefix(ps, bStream); - while (true) { - int length; - - try { - length = decodeLinePrefix(ps, bStream); - for (i = 0; (i + bytesPerAtom()) < length; i += bytesPerAtom()) { - decodeAtom(ps, bStream, bytesPerAtom()); - totalBytes += bytesPerAtom(); - } - if ((i + bytesPerAtom()) == length) { - decodeAtom(ps, bStream, bytesPerAtom()); - totalBytes += bytesPerAtom(); - } else { - decodeAtom(ps, bStream, length - i); - totalBytes += (length - i); - } - decodeLineSuffix(ps, bStream); - } catch (IOException e) { - break; - } - } - decodeBufferSuffix(ps, bStream); - } - - /** - * Alternate decode interface that takes a String containing the encoded buffer and returns a byte - * array containing the data. - * - * @exception IOException An error has occurred while decoding - */ - public byte decodeBuffer(String inputString)[] throws IOException { - byte inputBuffer[] = new byte[inputString.length()]; - ByteArrayInputStream inStream; - ByteArrayOutputStream outStream; - - inputString.getBytes(0, inputString.length(), inputBuffer, 0); - inStream = new ByteArrayInputStream(inputBuffer); - outStream = new ByteArrayOutputStream(); - decodeBuffer(inStream, outStream); - return (outStream.toByteArray()); - } - - /** Decode the contents of the inputstream into a buffer. */ - public byte decodeBuffer(InputStream in)[] throws IOException { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - decodeBuffer(in, outStream); - return (outStream.toByteArray()); - } - - /** Decode the contents of the String into a ByteBuffer. */ - public ByteBuffer decodeBufferToByteBuffer(String inputString) throws IOException { - return ByteBuffer.wrap(decodeBuffer(inputString)); - } - - /** Decode the contents of the inputStream into a ByteBuffer. */ - public ByteBuffer decodeBufferToByteBuffer(InputStream in) throws IOException { - return ByteBuffer.wrap(decodeBuffer(in)); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterEncoder.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterEncoder.java deleted file mode 100644 index e1bc3df17..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/CharacterEncoder.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright (c) 1995, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.sunbird.common.models.util.datasecurity.impl; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.nio.ByteBuffer; -/** - * This class defines the encoding half of character encoders. A character encoder is an algorithim - * for transforming 8 bit binary data into text (generally 7 bit ASCII or 8 bit ISO-Latin-1 text) - * for transmition over text channels such as e-mail and network news. - * - *

The character encoders have been structured around a central theme that, in general, the - * encoded text has the form: - * - *

- *      [Buffer Prefix]
- *      [Line Prefix][encoded data atoms][Line Suffix]
- *      [Buffer Suffix]
- * 
- * - * In the CharacterEncoder and CharacterDecoder classes, one complete chunk of data is referred to - * as a buffer. Encoded buffers are all text, and decoded buffers (sometimes just referred to - * as buffers) are binary octets. - * - *

To create a custom encoder, you must, at a minimum, overide three abstract methods in this - * class. - * - *

- *
bytesPerAtom which tells the encoder how many bytes to send to encodeAtom - *
encodeAtom which encodes the bytes sent to it as text. - *
bytesPerLine which tells the encoder the maximum number of bytes per line. - *
- * - * Several useful encoders have already been written and are referenced in the See Also list below. - * - * @author Chuck McManis - * @see CharacterDecoder; - * @see BASE64Encoder - */ -public abstract class CharacterEncoder { - /** Stream that understands "printing" */ - protected PrintStream pStream; - - /** Return the number of bytes per atom of encoding */ - protected abstract int bytesPerAtom(); - - /** Return the number of bytes that can be encoded per line */ - protected abstract int bytesPerLine(); - - /** - * Encode the prefix for the entire buffer. By default is simply opens the PrintStream for use by - * the other functions. - */ - protected void encodeBufferPrefix(OutputStream aStream) throws IOException { - pStream = new PrintStream(aStream); - } - - /** Encode the suffix for the entire buffer. */ - protected void encodeBufferSuffix(OutputStream aStream) throws IOException {} - - /** Encode the prefix that starts every output line. */ - protected void encodeLinePrefix(OutputStream aStream, int aLength) throws IOException {} - - /** - * Encode the suffix that ends every output line. By default this method just prints a - * into the output stream. - */ - protected void encodeLineSuffix(OutputStream aStream) throws IOException { - pStream.println(); - } - - /** Encode one "atom" of information into characters. */ - protected abstract void encodeAtom( - OutputStream aStream, byte someBytes[], int anOffset, int aLength) throws IOException; - - /** This method works around the bizarre semantics of BufferedInputStream's read method. */ - protected int readFully(InputStream in, byte buffer[]) throws IOException { - for (int i = 0; i < buffer.length; i++) { - int q = in.read(); - if (q == -1) return i; - buffer[i] = (byte) q; - } - return buffer.length; - } - - /** - * Encode bytes from the input stream, and write them as text characters to the output stream. - * This method will run until it exhausts the input stream, but does not print the line suffix for - * a final line that is shorter than bytesPerLine(). - */ - public void encode(InputStream inStream, OutputStream outStream) throws IOException { - int j; - int numBytes; - byte tmpbuffer[] = new byte[bytesPerLine()]; - - encodeBufferPrefix(outStream); - - while (true) { - numBytes = readFully(inStream, tmpbuffer); - if (numBytes == 0) { - break; - } - encodeLinePrefix(outStream, numBytes); - for (j = 0; j < numBytes; j += bytesPerAtom()) { - - if ((j + bytesPerAtom()) <= numBytes) { - encodeAtom(outStream, tmpbuffer, j, bytesPerAtom()); - } else { - encodeAtom(outStream, tmpbuffer, j, (numBytes) - j); - } - } - if (numBytes < bytesPerLine()) { - break; - } else { - encodeLineSuffix(outStream); - } - } - encodeBufferSuffix(outStream); - } - - /** - * Encode the buffer in aBuffer and write the encoded result to the OutputStream - * aStream. - */ - public void encode(byte aBuffer[], OutputStream aStream) throws IOException { - ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); - encode(inStream, aStream); - } - - /** - * A 'streamless' version of encode that simply takes a buffer of bytes and returns a string - * containing the encoded buffer. - */ - public String encode(byte aBuffer[]) { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); - String retVal = null; - try { - encode(inStream, outStream); - // explicit ascii->unicode conversion - retVal = outStream.toString("8859_1"); - } catch (Exception IOException) { - // This should never happen. - throw new Error("CharacterEncoder.encode internal error"); - } - return (retVal); - } - - /** - * Return a byte array from the remaining bytes in this ByteBuffer. - * - *

The ByteBuffer's position will be advanced to ByteBuffer's limit. - * - *

To avoid an extra copy, the implementation will attempt to return the byte array backing the - * ByteBuffer. If this is not possible, a new byte array will be created. - */ - private byte[] getBytes(ByteBuffer bb) { - /* - * This should never return a BufferOverflowException, as we're - * careful to allocate just the right amount. - */ - byte[] buf = null; - - /* - * If it has a usable backing byte buffer, use it. Use only - * if the array exactly represents the current ByteBuffer. - */ - if (bb.hasArray()) { - byte[] tmp = bb.array(); - if ((tmp.length == bb.capacity()) && (tmp.length == bb.remaining())) { - buf = tmp; - bb.position(bb.limit()); - } - } - - if (buf == null) { - /* - * This class doesn't have a concept of encode(buf, len, off), - * so if we have a partial buffer, we must reallocate - * space. - */ - buf = new byte[bb.remaining()]; - - /* - * position() automatically updated - */ - bb.get(buf); - } - - return buf; - } - - /** - * Encode the aBuffer ByteBuffer and write the encoded result to the OutputStream - * aStream. - * - *

The ByteBuffer's position will be advanced to ByteBuffer's limit. - */ - public void encode(ByteBuffer aBuffer, OutputStream aStream) throws IOException { - byte[] buf = getBytes(aBuffer); - encode(buf, aStream); - } - - /** - * A 'streamless' version of encode that simply takes a ByteBuffer and returns a string containing - * the encoded buffer. - * - *

The ByteBuffer's position will be advanced to ByteBuffer's limit. - */ - public String encode(ByteBuffer aBuffer) { - byte[] buf = getBytes(aBuffer); - return encode(buf); - } - - /** - * Encode bytes from the input stream, and write them as text characters to the output stream. - * This method will run until it exhausts the input stream. It differs from encode in that it will - * add the line at the end of a final line that is shorter than bytesPerLine(). - */ - public void encodeBuffer(InputStream inStream, OutputStream outStream) throws IOException { - int j; - int numBytes; - byte tmpbuffer[] = new byte[bytesPerLine()]; - - encodeBufferPrefix(outStream); - - while (true) { - numBytes = readFully(inStream, tmpbuffer); - if (numBytes == 0) { - break; - } - encodeLinePrefix(outStream, numBytes); - for (j = 0; j < numBytes; j += bytesPerAtom()) { - if ((j + bytesPerAtom()) <= numBytes) { - encodeAtom(outStream, tmpbuffer, j, bytesPerAtom()); - } else { - encodeAtom(outStream, tmpbuffer, j, (numBytes) - j); - } - } - encodeLineSuffix(outStream); - if (numBytes < bytesPerLine()) { - break; - } - } - encodeBufferSuffix(outStream); - } - - /** - * Encode the buffer in aBuffer and write the encoded result to the OutputStream - * aStream. - */ - public void encodeBuffer(byte aBuffer[], OutputStream aStream) throws IOException { - ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); - encodeBuffer(inStream, aStream); - } - - /** - * A 'streamless' version of encode that simply takes a buffer of bytes and returns a string - * containing the encoded buffer. - */ - public String encodeBuffer(byte aBuffer[]) { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); - try { - encodeBuffer(inStream, outStream); - } catch (Exception IOException) { - // This should never happen. - throw new Error("CharacterEncoder.encodeBuffer internal error"); - } - return (outStream.toString()); - } - - /** - * Encode the aBuffer ByteBuffer and write the encoded result to the OutputStream - * aStream. - * - *

The ByteBuffer's position will be advanced to ByteBuffer's limit. - */ - public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream) throws IOException { - byte[] buf = getBytes(aBuffer); - encodeBuffer(buf, aStream); - } - - /** - * A 'streamless' version of encode that simply takes a ByteBuffer and returns a string containing - * the encoded buffer. - * - *

The ByteBuffer's position will be advanced to ByteBuffer's limit. - */ - public String encodeBuffer(ByteBuffer aBuffer) { - byte[] buf = getBytes(aBuffer); - return encodeBuffer(buf); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDataMaskServiceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDataMaskServiceImpl.java deleted file mode 100644 index 03782cb97..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDataMaskServiceImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity.impl; - -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.datasecurity.DataMaskingService; - -/** @author Manzarul */ -public class DefaultDataMaskServiceImpl implements DataMaskingService { - - @Override - public String maskPhone(String phone) { - if (StringUtils.isBlank(phone) || phone.length() < 10) { - return phone; - } - String tempPhone = ""; - StringBuilder builder = new StringBuilder(); - tempPhone = phone.trim().replace("-", ""); - int length = tempPhone.length(); - for (int i = 0; i < length; i++) { - if (i < length - 4) { - builder.append(JsonKey.REPLACE_WITH_ASTERISK); - } else { - builder.append(tempPhone.charAt(i)); - } - } - return builder.toString(); - } - - @Override - public String maskEmail(String email) { - if ((StringUtils.isBlank(email)) || (!ProjectUtil.isEmailvalid(email))) { - return email; - } - StringBuilder builder = new StringBuilder(); - String[] emails = email.split("@"); - int length = emails[0].length(); - for (int i = 0; i < email.length(); i++) { - if (i < 2 || i >= length) { - builder.append(email.charAt(i)); - } else { - builder.append(JsonKey.REPLACE_WITH_ASTERISK); - } - } - return builder.toString(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDecryptionServiceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDecryptionServiceImpl.java deleted file mode 100644 index 715016b80..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultDecryptionServiceImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.sunbird.common.models.util.datasecurity.impl; - -import java.nio.charset.StandardCharsets; -import java.security.Key; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.models.util.datasecurity.DecryptionService; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.common.models.util.datasecurity.impl.BASE64Decoder; - -public class DefaultDecryptionServiceImpl implements DecryptionService { - private static String sunbird_encryption = ""; - - private String sunbirdEncryption = ""; - - private static Cipher c; - - static { - try { - sunbird_encryption = DefaultEncryptionServivceImpl.getSalt(); - Key key = generateKey(); - c = Cipher.getInstance(ALGORITHM); - c.init(Cipher.DECRYPT_MODE, key); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - } - - public DefaultDecryptionServiceImpl() { - sunbirdEncryption = System.getenv(JsonKey.SUNBIRD_ENCRYPTION); - if (StringUtils.isBlank(sunbirdEncryption)) { - sunbirdEncryption = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ENCRYPTION); - } - } - - @Override - public Map decryptData(Map data) { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (data == null) { - return data; - } - Iterator> itr = data.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - if (!(entry.getValue() instanceof Map || entry.getValue() instanceof List) - && null != entry.getValue()) { - data.put(entry.getKey(), decrypt(entry.getValue() + "", false)); - } - } - } - return data; - } - - @Override - public List> decryptData(List> data) { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (data == null || data.isEmpty()) { - return data; - } - - for (Map map : data) { - decryptData(map); - } - } - return data; - } - - @Override - public String decryptData(String data) { - return decryptData(data, false); - } - - @Override - public String decryptData(String data, boolean throwExceptionOnFailure) { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (StringUtils.isBlank(data)) { - return data; - } else { - return decrypt(data, throwExceptionOnFailure); - } - } else { - return data; - } - } - - public static String decrypt(String value, boolean throwExceptionOnFailure) { - try { - String dValue = null; - String valueToDecrypt = value.trim(); - for (int i = 0; i < ITERATIONS; i++) { - byte[] decordedValue = new BASE64Decoder().decodeBuffer(valueToDecrypt); - byte[] decValue = c.doFinal(decordedValue); - dValue = - new String(decValue, StandardCharsets.UTF_8).substring(sunbird_encryption.length()); - valueToDecrypt = dValue; - } - return dValue; - } catch (Exception ex) { - ProjectLogger.log( - "DefaultDecryptionServiceImpl:decrypt: Exception occurred with error message = " - + ex.getMessage(), - LoggerEnum.ERROR.name()); - if (throwExceptionOnFailure) { - ProjectCommonException.throwClientErrorException(ResponseCode.userDataEncryptionError); - } - } - return value; - } - - private static Key generateKey() { - return new SecretKeySpec(keyValue, ALGORITHM); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultEncryptionServivceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultEncryptionServivceImpl.java deleted file mode 100644 index bfdf9b236..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/DefaultEncryptionServivceImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity.impl; - -import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.SecretKeySpec; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.models.util.datasecurity.EncryptionService; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * Default data encryption service - * - * @author Manzarul - */ -public class DefaultEncryptionServivceImpl implements EncryptionService { - - private static String encryption_key = ""; - - private String sunbirdEncryption = ""; - - private static Cipher c; - - static { - try { - encryption_key = getSalt(); - Key key = generateKey(); - c = Cipher.getInstance(ALGORITHM); - c.init(Cipher.ENCRYPT_MODE, key); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - } - - public DefaultEncryptionServivceImpl() { - sunbirdEncryption = System.getenv(JsonKey.SUNBIRD_ENCRYPTION); - if (StringUtils.isBlank(sunbirdEncryption)) { - sunbirdEncryption = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ENCRYPTION); - } - } - - @Override - public Map encryptData(Map data) throws Exception { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (data == null) { - return data; - } - Iterator> itr = data.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - if (!(entry.getValue() instanceof Map || entry.getValue() instanceof List) - && null != entry.getValue()) { - data.put(entry.getKey(), encrypt(entry.getValue() + "")); - } - } - } - return data; - } - - @Override - public List> encryptData(List> data) throws Exception { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (data == null || data.isEmpty()) { - return data; - } - for (Map map : data) { - encryptData(map); - } - } - return data; - } - - @Override - public String encryptData(String data) throws Exception { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - if (StringUtils.isBlank(data)) { - return data; - } - if (null != data) { - return encrypt(data); - } else { - return data; - } - } else { - return data; - } - } - - /** - * this method is used to encrypt the password. - * - * @param value String password - * @param encryption_key - * @return encrypted password. - * @throws NoSuchPaddingException - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws BadPaddingException - * @throws IllegalBlockSizeException - * @throws UnsupportedEncodingException - */ - @SuppressWarnings("restriction") - public static String encrypt(String value) - throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, - IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { - String valueToEnc = null; - String eValue = value; - for (int i = 0; i < ITERATIONS; i++) { - valueToEnc = encryption_key + eValue; - byte[] encValue = c.doFinal(valueToEnc.getBytes(StandardCharsets.UTF_8)); - eValue = new BASE64Encoder().encode(encValue); - } - return eValue; - } - - private static Key generateKey() { - return new SecretKeySpec(keyValue, ALGORITHM); - } - - /** @return */ - public static String getSalt() { - if (!StringUtils.isBlank(encryption_key)) { - return encryption_key; - } else { - encryption_key = System.getenv(JsonKey.ENCRYPTION_KEY); - if (StringUtils.isBlank(encryption_key)) { - ProjectLogger.log("Salt value is not provided by Env"); - encryption_key = PropertiesCache.getInstance().getProperty(JsonKey.ENCRYPTION_KEY); - } - } - if (StringUtils.isBlank(encryption_key)) { - ProjectLogger.log("throwing exception for invalid salt==", LoggerEnum.INFO.name()); - throw new ProjectCommonException( - ResponseCode.saltValue.getErrorCode(), - ResponseCode.saltValue.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode()); - } - return encryption_key; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImpl.java deleted file mode 100644 index 90399b977..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.sunbird.common.models.util.datasecurity.impl; - -import org.sunbird.common.models.util.datasecurity.DataMaskingService; - -public class LogMaskServiceImpl implements DataMaskingService { - /** - * Mask an email - * @param email - * @return the first 4 or 2 characters in plain and masks the rest. The domain is - * still in plain - */ - public String maskEmail(String email) { - if (email.indexOf("@") > 4) { - return email.replaceAll("(^[^@]{4}|(?!^)\\G)[^@]", "$1*"); - } else { - return email.replaceAll("(^[^@]{2}|(?!^)\\G)[^@]", "$1*"); - } - } - - /** - * Mask a phone number - * @param phone - * @return a string with the last digit masked - */ - public String maskPhone(String phone) { - return phone.replaceAll("(^[^*]{9}|(?!^)\\G)[^*]", "$1*"); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/ServiceFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/ServiceFactory.java deleted file mode 100644 index 91a783c85..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/ServiceFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity.impl; - -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.datasecurity.DataMaskingService; -import org.sunbird.common.models.util.datasecurity.DecryptionService; -import org.sunbird.common.models.util.datasecurity.EncryptionService; - -/** - * This factory will provide encryption service instance and decryption service instance with - * default implementation. - * - * @author Manzarul - */ -public class ServiceFactory { - - private static EncryptionService encryptionService; - private static DecryptionService decryptionService; - private static DataMaskingService maskingService; - - static { - encryptionService = new DefaultEncryptionServivceImpl(); - decryptionService = new DefaultDecryptionServiceImpl(); - maskingService = new DefaultDataMaskServiceImpl(); - } - - /** - * this method will provide encryptionServiceImple instance. by default it will provide - * DefaultEncryptionServiceImpl instance to get a particular service impl instance , need to - * change the object creation and provided logic. - * - * @param val String ( pass null or empty in case of defaultImple object.) - * @return EncryptionService - */ - public static EncryptionService getEncryptionServiceInstance(String val) { - if (StringUtils.isBlank(val)) { - return encryptionService; - } - switch (val) { - case "defaultEncryption": - return encryptionService; - default: - return encryptionService; - } - } - - /** - * this method will provide decryptionServiceImple instance. by default it will provide - * DefaultDecryptionServiceImpl instance to get a particular service impl instance , need to - * change the object creation and provided logic. - * - * @param val String ( pass null or empty in case of defaultImple object.) - * @return DecryptionService - */ - public static DecryptionService getDecryptionServiceInstance(String val) { - if (StringUtils.isBlank(val)) { - return decryptionService; - } - switch (val) { - case "defaultDecryption": - return decryptionService; - default: - return decryptionService; - } - } - - public static DataMaskingService getMaskingServiceInstance(String val) { - if (StringUtils.isBlank(val)) { - return maskingService; - } - switch (val) { - case "defaultMasking": - return maskingService; - default: - return maskingService; - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/package-info.java deleted file mode 100644 index c601093b4..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util.datasecurity.impl; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/package-info.java deleted file mode 100644 index 09c3c5704..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util.datasecurity; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/Notification.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/Notification.java deleted file mode 100644 index 8daea20ae..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/Notification.java +++ /dev/null @@ -1,61 +0,0 @@ -/** */ -package org.sunbird.common.models.util.fcm; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; - -/** @author Manzarul */ -public class Notification { - /** FCM_URL URL of FCM server */ - public static final String FCM_URL = PropertiesCache.getInstance().getProperty(JsonKey.FCM_URL); - /** FCM_ACCOUNT_KEY FCM server key. */ - private static final String FCM_ACCOUNT_KEY = System.getenv(JsonKey.SUNBIRD_FCM_ACCOUNT_KEY); - - private static Map headerMap = new HashMap<>(); - private static final String TOPIC_SUFFIX = "/topics/"; - - static { - headerMap.put(JsonKey.AUTHORIZATION, FCM_ACCOUNT_KEY); - headerMap.put("Content-Type", "application/json"); - } - - /** - * This method will send notification to FCM. - * - * @param topic String - * @param data Map - * @param url String - * @return String as Json.{"message_id": 7253391319867149192} - */ - public static String sendNotification(String topic, Map data, String url) { - if (StringUtils.isBlank(FCM_ACCOUNT_KEY) || StringUtils.isBlank(url)) { - ProjectLogger.log( - "FCM account key or URL is not provided===" + FCM_URL, LoggerEnum.INFO.name()); - return JsonKey.FAILURE; - } - String response = null; - try { - JSONObject object1 = new JSONObject(data); - JSONObject object = new JSONObject(); - object.put(JsonKey.DATA, object1); - object.put(JsonKey.TO, TOPIC_SUFFIX + topic); - response = HttpUtil.sendPostRequest(FCM_URL, object.toString(), headerMap); - ProjectLogger.log("FCM Notification response== for topic " + topic + response); - object1 = null; - object1 = new JSONObject(response); - long val = object1.getLong(JsonKey.MESSAGE_Id); - response = val + ""; - } catch (Exception e) { - response = JsonKey.FAILURE; - ProjectLogger.log(e.getMessage(), e); - } - return response; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/package-info.java deleted file mode 100644 index 676f493d8..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/fcm/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util.fcm; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/GMailAuthenticator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/GMailAuthenticator.java deleted file mode 100644 index cb65dbb88..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/GMailAuthenticator.java +++ /dev/null @@ -1,29 +0,0 @@ -/** */ -package org.sunbird.common.models.util.mail; - -import javax.mail.Authenticator; -import javax.mail.PasswordAuthentication; - -/** @author Manzarul.Haque */ -public class GMailAuthenticator extends Authenticator { - private String user; - private String pw; - - /** - * this method is used to authenticate gmail user name and password. - * - * @param username - * @param password - */ - public GMailAuthenticator(String username, String password) { - super(); - this.user = username; - this.pw = password; - } - - /** */ - @Override - public PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(this.user, this.pw); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/SendMail.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/SendMail.java deleted file mode 100644 index 70eb39ffd..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/SendMail.java +++ /dev/null @@ -1,298 +0,0 @@ -package org.sunbird.common.models.util.mail; - -import java.io.StringWriter; -import java.util.Properties; -import javax.activation.DataHandler; -import javax.activation.DataSource; -import javax.activation.FileDataSource; -import javax.mail.BodyPart; -import javax.mail.Message; -import javax.mail.Message.RecipientType; -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; -import org.apache.commons.lang3.StringUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.app.VelocityEngine; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; - -/** - * this api is used to sending mail. - * - * @author Manzarul.Haque - */ -public class SendMail { - - private static Properties props = null; - private static String host; - private static String port; - private static String userName; - private static String password; - private static String fromEmail; - - static { - // collecting setup value from ENV - host = System.getenv(JsonKey.EMAIL_SERVER_HOST); - port = System.getenv(JsonKey.EMAIL_SERVER_PORT); - userName = System.getenv(JsonKey.EMAIL_SERVER_USERNAME); - password = System.getenv(JsonKey.EMAIL_SERVER_PASSWORD); - fromEmail = System.getenv(JsonKey.EMAIL_SERVER_FROM); - if (StringUtils.isBlank(host) - || StringUtils.isBlank(port) - || StringUtils.isBlank(userName) - || StringUtils.isBlank(password) - || StringUtils.isBlank(fromEmail)) { - ProjectLogger.log( - "Email setting value is not provided by Env variable==" - + host - + " " - + port - + " " - + fromEmail, - LoggerEnum.INFO.name()); - initialiseFromProperty(); - } - props = System.getProperties(); - props.put("mail.smtp.host", host); - props.put("mail.smtp.socketFactory.port", port); - /* - * props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); - */ - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.port", port); - } - - /** This method will initialize values from property files. */ - public static void initialiseFromProperty() { - host = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_HOST); - port = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_PORT); - userName = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_USERNAME); - password = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_PASSWORD); - fromEmail = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_FROM); - } - - /** - * Send email using given template name. - * - * @param emailList List of recipient emails - * @param context Context for Velocity template - * @param templateName Name of email template - * @param subject Subject of email - */ - public static boolean sendMail( - String[] emailList, String subject, VelocityContext context, String templateName) { - VelocityEngine engine = new VelocityEngine(); - Properties p = new Properties(); - p.setProperty("resource.loader", "class"); - p.setProperty( - "class.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - StringWriter writer = null; - try { - engine.init(p); - Template template = engine.getTemplate(templateName); - writer = new StringWriter(); - template.merge(context, writer); - } catch (Exception e) { - ProjectLogger.log( - "SendMail:sendMail : Exception occurred with message = " + e.getMessage(), e); - } - - return sendEmail(emailList, subject, context, writer); - } - - /** - * Send email using given template body. - * - * @param emailList List of recipient emails - * @param context Context for Velocity template - * @param templateBody Email template body - * @param subject Subject of email - */ - public static boolean sendMailWithBody( - String[] emailList, String subject, VelocityContext context, String templateBody) { - StringWriter writer = null; - try { - Velocity.init(); - writer = new StringWriter(); - Velocity.evaluate(context, writer, "SimpleVelocity", templateBody); - } catch (Exception e) { - ProjectLogger.log( - "SendMail:sendMailWithBody : Exception occurred with message =" + e.getMessage(), e); - } - return sendEmail(emailList, subject, context, writer); - } - - /** - * Send email (with Cc) using given template name. - * - * @param emailList List of recipient emails - * @param context Context for Velocity template - * @param templateName Name of email template - * @param subject Subject of email - * @param ccEmailList List of Cc emails - */ - public static void sendMail( - String[] emailList, - String subject, - VelocityContext context, - String templateName, - String[] ccEmailList) { - ProjectLogger.log("Mail Template name - " + templateName, LoggerEnum.INFO.name()); - Transport transport = null; - try { - Session session = Session.getInstance(props, new GMailAuthenticator(userName, password)); - MimeMessage message = new MimeMessage(session); - message.setFrom(new InternetAddress(fromEmail)); - int size = emailList.length; - int i = 0; - while (size > 0) { - message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailList[i])); - i++; - size--; - } - size = ccEmailList.length; - i = 0; - while (size > 0) { - message.addRecipient(Message.RecipientType.CC, new InternetAddress(ccEmailList[i])); - i++; - size--; - } - message.setSubject(subject); - VelocityEngine engine = new VelocityEngine(); - Properties p = new Properties(); - p.setProperty("resource.loader", "class"); - p.setProperty( - "class.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - engine.init(p); - Template template = engine.getTemplate(templateName); - StringWriter writer = new StringWriter(); - template.merge(context, writer); - message.setContent(writer.toString(), "text/html; charset=utf-8"); - transport = session.getTransport("smtp"); - transport.connect(host, userName, password); - transport.sendMessage(message, message.getAllRecipients()); - transport.close(); - } catch (Exception e) { - ProjectLogger.log(e.toString(), e); - } finally { - if (transport != null) { - try { - transport.close(); - } catch (MessagingException e) { - ProjectLogger.log(e.toString(), e); - } - } - } - } - - /** - * Send email (with attachment) and given body. - * - * @param emailList List of recipient emails - * @param emailBody Text of email body - * @param subject Subject of email - * @param filePath Path of attachment file - */ - public static void sendAttachment( - String[] emailList, String emailBody, String subject, String filePath) { - Transport transport = null; - try { - Session session = Session.getInstance(props, new GMailAuthenticator(userName, password)); - MimeMessage message = new MimeMessage(session); - message.setFrom(new InternetAddress(fromEmail)); - int size = emailList.length; - int i = 0; - while (size > 0) { - message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailList[i])); - i++; - size--; - } - message.setSubject(subject); - BodyPart messageBodyPart = new MimeBodyPart(); - messageBodyPart.setContent(emailBody, "text/html; charset=utf-8"); - // messageBodyPart.setText(mail); - // Create a multipar message - Multipart multipart = new MimeMultipart(); - multipart.addBodyPart(messageBodyPart); - DataSource source = new FileDataSource(filePath); - messageBodyPart = null; - messageBodyPart = new MimeBodyPart(); - messageBodyPart.setDataHandler(new DataHandler(source)); - messageBodyPart.setFileName(filePath); - multipart.addBodyPart(messageBodyPart); - message.setSubject(subject); - message.setContent(multipart); - transport = session.getTransport("smtp"); - transport.connect(host, userName, password); - transport.sendMessage(message, message.getAllRecipients()); - transport.close(); - } catch (Exception e) { - ProjectLogger.log(e.toString(), e); - } finally { - if (transport != null) { - try { - transport.close(); - } catch (MessagingException e) { - ProjectLogger.log(e.toString(), e); - } - } - } - } - - private static boolean sendEmail( - String[] emailList, String subject, VelocityContext context, StringWriter writer) { - Transport transport = null; - boolean sentStatus = true; - try { - if (context != null) { - context.put(JsonKey.FROM_EMAIL, fromEmail); - } - Session session = Session.getInstance(props, new GMailAuthenticator(userName, password)); - MimeMessage message = new MimeMessage(session); - message.setFrom(new InternetAddress(fromEmail)); - RecipientType recipientType = null; - if (emailList.length > 1) { - recipientType = Message.RecipientType.BCC; - } else { - recipientType = Message.RecipientType.TO; - } - for (String email : emailList) { - message.addRecipient(recipientType, new InternetAddress(email)); - } - if (recipientType == Message.RecipientType.BCC) - message.addRecipient(Message.RecipientType.TO, new InternetAddress(fromEmail)); - message.setSubject(subject); - message.setContent(writer.toString(), "text/html; charset=utf-8"); - transport = session.getTransport("smtp"); - transport.connect(host, userName, password); - transport.sendMessage(message, message.getAllRecipients()); - transport.close(); - } catch (Exception e) { - - sentStatus = false; - ProjectLogger.log( - "SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); - } finally { - if (transport != null) { - try { - transport.close(); - } catch (MessagingException e) { - ProjectLogger.log(e.toString(), e); - } - } - } - return sentStatus; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/package-info.java deleted file mode 100644 index 812922d93..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util.mail; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/package-info.java deleted file mode 100644 index be4d48c50..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.models.util; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortner.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortner.java deleted file mode 100644 index 823d7e51d..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortner.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.sunbird.common.models.util.url; - -public interface URLShortner { - - public String shortUrl(String url); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortnerImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortnerImpl.java deleted file mode 100644 index a7d74903d..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortnerImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.sunbird.common.models.util.url; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; - -/** @author Amit Kumar */ -public class URLShortnerImpl implements URLShortner { - - private static String resUrl = null; - private static final String SUNBIRD_WEB_URL = "sunbird_web_url"; - - @Override - public String shortUrl(String url) { - boolean flag = false; - try { - flag = Boolean.parseBoolean(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_URL_SHORTNER_ENABLE)); - } catch (Exception ex) { - ProjectLogger.log( - "URLShortnerImpl:shortUrl : Exception occurred while parsing sunbird_url_shortner_enable key"); - } - if (flag) { - String baseUrl = PropertiesCache.getInstance().getProperty("sunbird_url_shortner_base_url"); - String accessToken = System.getenv("url_shortner_access_token"); - if (StringUtils.isBlank(accessToken)) { - accessToken = - PropertiesCache.getInstance().getProperty("sunbird_url_shortner_access_token"); - } - String requestURL = baseUrl + accessToken + "&longUrl=" + url; - String response = ""; - try { - response = HttpUtil.sendGetRequest(requestURL, null); - } catch (IOException e) { - ProjectLogger.log("Exception occurred while sending request for URL shortening", e); - } - ObjectMapper mapper = new ObjectMapper(); - Map map = null; - if (!StringUtils.isBlank(response)) { - try { - map = mapper.readValue(response, HashMap.class); - Map dataMap = (Map) map.get("data"); - return dataMap.get("url"); - } catch (IOException | ClassCastException e) { - ProjectLogger.log(e.getMessage(), e); - } - } - } - return url; - } - - /** @return the url */ - public String getUrl() { - if (StringUtils.isBlank(resUrl)) { - String webUrl = System.getenv(SUNBIRD_WEB_URL); - if (StringUtils.isBlank(webUrl)) { - webUrl = PropertiesCache.getInstance().getProperty(SUNBIRD_WEB_URL); - } - return shortUrl(webUrl); - } else { - return resUrl; - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/AddressRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/AddressRequestValidator.java deleted file mode 100644 index 615bf6e6d..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/AddressRequestValidator.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.sunbird.common.request; - -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.ProjectUtil.AddressType; -import org.sunbird.common.responsecode.ResponseCode; - -public class AddressRequestValidator extends BaseRequestValidator { - - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - public void validateAddress(Map address, String type) { - if (StringUtils.isBlank((String) address.get(JsonKey.ADDRESS_LINE1))) { - throw new ProjectCommonException( - ResponseCode.addressError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.addressError.getErrorMessage(), type, JsonKey.ADDRESS_LINE1), - ERROR_CODE); - } - if (StringUtils.isBlank((String) address.get(JsonKey.CITY))) { - throw new ProjectCommonException( - ResponseCode.addressError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.addressError.getErrorMessage(), type, JsonKey.CITY), - ERROR_CODE); - } - if (address.containsKey(JsonKey.ADD_TYPE)) { - - if (StringUtils.isBlank((String) address.get(JsonKey.ADD_TYPE))) { - throw new ProjectCommonException( - ResponseCode.addressError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.addressError.getErrorMessage(), JsonKey.ADDRESS, JsonKey.TYPE), - ERROR_CODE); - } - - if (!StringUtils.isBlank((String) address.get(JsonKey.ADD_TYPE)) - && !checkAddressType((String) address.get(JsonKey.ADD_TYPE))) { - throw new ProjectCommonException( - ResponseCode.addressTypeError.getErrorCode(), - ResponseCode.addressTypeError.getErrorMessage(), - ERROR_CODE); - } - } - } - - private static boolean checkAddressType(String addrType) { - for (AddressType type : AddressType.values()) { - if (type.getTypeName().equals(addrType)) { - return true; - } - } - return false; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java deleted file mode 100644 index 2dd730e69..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/BaseRequestValidator.java +++ /dev/null @@ -1,498 +0,0 @@ -package org.sunbird.common.request; - -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.EmailValidator; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.StringFormatter; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * Base request validator class to house common validation methods. - * - * @author B Vinaya Kumar - */ -public class BaseRequestValidator { - - /** - * Helper method which throws an exception if given parameter value is blank (null or empty). - * - * @param value Request parameter value. - * @param error Error to be thrown in case of validation error. - */ - public void validateParam(String value, ResponseCode error) { - if (StringUtils.isBlank(value)) { - throw new ProjectCommonException( - error.getErrorCode(), - error.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - /** - * Helper method which throws an exception if given parameter value is blank (null or empty). - * - * @param value Request parameter value. - * @param error Error to be thrown in case of validation error. - * @param errorMsgArgument Argument for error message. - */ - public void validateParam(String value, ResponseCode error, String errorMsgArgument) { - if (StringUtils.isBlank(value)) { - throw new ProjectCommonException( - error.getErrorCode(), - MessageFormat.format(error.getErrorMessage(), errorMsgArgument), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - /** - * Helper method which throws an exception if the given parameter list size exceeds the expected - * size - * - * @param paramName Configuration parameter name - * @param key Request parameter name - * @param listValue Request parameter value - */ - public void validateListParamSize(String paramName, String key, List listValue) { - int maximumSizeAllowed = 0; - try { - maximumSizeAllowed = Integer.valueOf(ProjectUtil.getConfigValue(paramName).trim()); - } catch (NumberFormatException e) { - ProjectCommonException.throwServerErrorException( - ResponseCode.errorInvalidConfigParamValue, - MessageFormat.format( - ResponseCode.errorInvalidConfigParamValue.getErrorMessage(), - ProjectUtil.getConfigValue(key).trim(), - key)); - } - if (listValue.size() > maximumSizeAllowed) { - ProjectCommonException.throwClientErrorException( - ResponseCode.errorMaxSizeExceeded, - MessageFormat.format( - ResponseCode.errorMaxSizeExceeded.getErrorMessage(), - key, - String.valueOf(maximumSizeAllowed))); - } - } - - /** - * This method will create the ProjectCommonException by reading ResponseCode and errorCode. - * incase ResponseCode is null then it will throw invalidData error. - * - * @param code Error response code - * @param errorCode (Http error code) - * @return custom project exception - */ - public ProjectCommonException createExceptionByResponseCode(ResponseCode code, int errorCode) { - if (code == null) { - ProjectLogger.log("ResponseCode object is coming as null", LoggerEnum.INFO.name()); - return new ProjectCommonException( - ResponseCode.invalidData.getErrorCode(), - ResponseCode.invalidData.getErrorMessage(), - errorCode); - } - return new ProjectCommonException(code.getErrorCode(), code.getErrorMessage(), errorCode); - } - - /** - * This method will create the ProjectCommonException by reading ResponseCode and errorCode. - * incase ResponseCode is null then it will throw invalidData error. - * - * @param code Error response code - * @param errorCode (Http error code) - * @return custom project exception - */ - public ProjectCommonException createExceptionByResponseCode( - ResponseCode code, int errorCode, String errorMsgArgument) { - if (code == null) { - ProjectLogger.log("ResponseCode object is coming as null", LoggerEnum.INFO.name()); - return new ProjectCommonException( - ResponseCode.invalidData.getErrorCode(), - ResponseCode.invalidData.getErrorMessage(), - errorCode); - } - return new ProjectCommonException( - code.getErrorCode(), - MessageFormat.format(code.getErrorMessage(), errorMsgArgument), - errorCode); - } - - /** - * Method to check whether given mandatory fields is in given map or not. - * - * @param data Map contains the key value, - * @param keys List of string represents the mandatory fields. - */ - public void checkMandatoryFieldsPresent(Map data, String... keys) { - if (MapUtils.isEmpty(data)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - Arrays.stream(keys) - .forEach( - key -> { - if (StringUtils.isEmpty((String) data.get(key))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - key); - } - }); - } - /** - * Method to check whether given mandatory fields is in given map or not. also check the instance - * of request attributes - * - * @param data Map contains the key value, - * @param mandatoryParamsList List of string represents the mandatory fields. - */ - public void checkMandatoryFieldsPresent( - Map data, List mandatoryParamsList) { - if (MapUtils.isEmpty(data)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - mandatoryParamsList.forEach( - key -> { - if (StringUtils.isEmpty((String) data.get(key))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - key); - } - if (!(data.get(key) instanceof String)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format(ResponseCode.dataTypeError.getErrorMessage(), key, "String"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - - /** - * Method to check whether given mandatory fields is in given map or not . - * - * @param data Map contains the key value - * @param keys List of string represents the mandatory fields - * @param exceptionMsg Exception message - */ - public void checkMandatoryParamsPresent( - Map data, String exceptionMsg, String... keys) { - if (MapUtils.isEmpty(data)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - Arrays.stream(keys) - .forEach( - key -> { - if (StringUtils.isEmpty((String) data.get(key))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), exceptionMsg), - ResponseCode.CLIENT_ERROR.getResponseCode(), - key); - } - }); - } - - /** - * Method to check whether given fields is in given map or not .If it is there throw exception. - * because in some update request cases we don't want to update some props to , if it is there in - * request , throw exception. - * - * @param data Map contains the key value - * @param keys List of string represents the must not present fields. - */ - public void checkReadOnlyAttributesAbsent(Map data, String... keys) { - - if (MapUtils.isEmpty(data)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - Arrays.stream(keys) - .forEach( - key -> { - if (data.containsKey(key)) { - throw new ProjectCommonException( - ResponseCode.unupdatableField.getErrorCode(), - ResponseCode.unupdatableField.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - key); - } - }); - } - - /** - * Method to check whether given header fields present or not. - * - * @param data List of strings representing the header names in received request. - * @param keys List of string represents the headers fields. - */ - public void checkMandatoryHeadersPresent(Map data, String... keys) { - if (MapUtils.isEmpty(data)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - Arrays.stream(keys) - .forEach( - key -> { - if (ArrayUtils.isEmpty(data.get(key))) { - throw new ProjectCommonException( - ResponseCode.mandatoryHeadersMissing.getErrorCode(), - ResponseCode.mandatoryHeadersMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - key); - } - }); - } - - /** - * Ensures not allowed fields are absent in given request. - * - * @param requestMap Request information - * @param fields List of not allowed fields - */ - public void checkForFieldsNotAllowed(Map requestMap, List fields) { - fields - .stream() - .forEach( - field -> { - if (requestMap.containsKey(field)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestParameter.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.invalidRequestParameter.getErrorMessage(), field), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - - /** - * Helper method which throws an exception if each field is not of type List. - * - * @param requestMap Request information - * @param fieldPrefix Field prefix - * @param fields List of fields - */ - public void validateListParamWithPrefix( - Map requestMap, String fieldPrefix, String... fields) { - Arrays.stream(fields) - .forEach( - field -> { - if (requestMap.containsKey(field) - && null != requestMap.get(field) - && !(requestMap.get(field) instanceof List)) { - - String fieldWithPrefix = - fieldPrefix != null ? StringFormatter.joinByDot(fieldPrefix, field) : field; - - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), - fieldWithPrefix, - JsonKey.LIST), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - - /** - * Helper method which throws an exception if each field is not of type List. - * - * @param requestMap Request information - * @param fields List of fields - */ - public void validateListParam(Map requestMap, String... fields) { - validateListParamWithPrefix(requestMap, null, fields); - } - - /** - * Helper method which throws an exception if given date is not in YYYY-MM-DD format. - * - * @param dob Date of birth. - */ - public void validateDateParam(String dob) { - if (StringUtils.isNotBlank(dob)) { - boolean isValidDate = ProjectUtil.isDateValidFormat(ProjectUtil.YEAR_MONTH_DATE_FORMAT, dob); - if (!isValidDate) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - } - - /** - * Helper method which throws an exception if given parameter value is blank (null or empty). - * - * @param error Error to be thrown in case of validation error. - * @param errorMsg Error message. - */ - public void validateParamValue(String value, ResponseCode error, String errorMsg) { - if (StringUtils.isBlank(value)) { - throw new ProjectCommonException( - error.getErrorCode(), - MessageFormat.format(error.getErrorMessage(), errorMsg), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - /** - * Helper method which throws an exception if user ID in request is not same as that in user - * token. - * - * @param request API request - * @param userIdKey Attribute name for user ID in API request - */ - public static void validateUserId(Request request, String userIdKey) { - if (!(request - .getRequest() - .get(userIdKey) - .equals(request.getContext().get(JsonKey.REQUESTED_BY)))) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - ResponseCode.invalidParameterValue.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - (String) request.getRequest().get(JsonKey.USER_ID), - JsonKey.USER_ID); - } - } - - public void validateSearchRequest(Request request) { - if (null == request.getRequest().get(JsonKey.FILTERS)) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - MessageFormat.format( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), JsonKey.FILTERS), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - if (request.getRequest().containsKey(JsonKey.FILTERS) - && (!(request.getRequest().get(JsonKey.FILTERS) instanceof Map))) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.FILTERS, "Map"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - validateSearchRequestFiltersValues(request); - validateSearchRequestFieldsValues(request); - } - - private void validateSearchRequestFieldsValues(Request request) { - if (request.getRequest().containsKey(JsonKey.FIELDS) - && (!(request.getRequest().get(JsonKey.FIELDS) instanceof List))) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.FIELDS, "List"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - if (request.getRequest().containsKey(JsonKey.FIELDS) - && (request.getRequest().get(JsonKey.FIELDS) instanceof List)) { - for (Object obj : (List) request.getRequest().get(JsonKey.FIELDS)) { - if (!(obj instanceof String)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.FIELDS, "List of String"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - } - } - - private void validateSearchRequestFiltersValues(Request request) { - if (request.getRequest().containsKey(JsonKey.FILTERS) - && ((request.getRequest().get(JsonKey.FILTERS) instanceof Map))) { - Map map = (Map) request.getRequest().get(JsonKey.FILTERS); - - map.forEach( - (key, val) -> { - if (key == null) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), key, JsonKey.FILTERS), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - if (val instanceof List) { - validateListValues((List) val, key); - } else if (val instanceof Map) { - validateMapValues((Map) val); - } else if (val == null) - if (StringUtils.isEmpty((String) val)) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), val, key), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - } - - private void validateMapValues(Map val) { - val.forEach( - (k, v) -> { - if (k == null || v == null) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - MessageFormat.format(ResponseCode.invalidParameterValue.getErrorMessage(), v, k), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - - private void validateListValues(List val, String key) { - val.forEach( - v -> { - if (v == null) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - MessageFormat.format(ResponseCode.invalidParameterValue.getErrorMessage(), v, key), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - }); - } - - public void validateEmail(String email) { - if (!EmailValidator.isEmailValid(email)) { - throw new ProjectCommonException( - ResponseCode.emailFormatError.getErrorCode(), - ResponseCode.emailFormatError.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - public void validatePhone(String phone) { - if (!ProjectUtil.validatePhone(phone, null)) { - throw new ProjectCommonException( - ResponseCode.phoneNoFormatError.getErrorCode(), - ResponseCode.phoneNoFormatError.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/ExecutionContext.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/ExecutionContext.java deleted file mode 100644 index c85050b02..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/ExecutionContext.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.sunbird.common.request; - -import java.util.HashMap; -import java.util.Map; -import java.util.Stack; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.response.Response; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.PropertiesCache; - -/** @author Manzarul */ -public class ExecutionContext { - - public static final String USER_ID = "userId"; - public static final String USER_ROLE = "userRole"; - private Stack serviceCallStack = new Stack<>(); - - private Map> contextStackValues = new HashMap<>(); - private Map globalContext = new HashMap<>(); - private Map requestContext = new HashMap<>(); - - public Map getRequestContext() { - return requestContext; - } - - public void setRequestContext(Map requestContext) { - this.requestContext = requestContext; - initializeGlobalContext(ExecutionContext.getCurrent()); - } - - private static ThreadLocal context = - new ThreadLocal() { - - @Override - protected ExecutionContext initialValue() { - ExecutionContext context = new ExecutionContext(); - return context; - } - }; - - private static void initializeGlobalContext(ExecutionContext context) { - context.getGlobalContext().put(JsonKey.PDATA_ID, getContextValue(JsonKey.PDATA_ID)); - context.getGlobalContext().put(JsonKey.PDATA_PID, getContextValue(JsonKey.PDATA_PID)); - context.getGlobalContext().put(JsonKey.PDATA_VERSION, getContextValue(JsonKey.PDATA_VERSION)); - } - - private static String getContextValue(String key) { - String value = System.getenv(key); - if (StringUtils.isBlank(value)) { - value = PropertiesCache.getInstance().getProperty(key); - } - return value; - } - - public static ExecutionContext getCurrent() { - return context.get(); - } - - public static void setRequestId(String requestId) { - ExecutionContext.getCurrent() - .getGlobalContext() - .put(HeaderParam.REQUEST_ID.getParamName(), requestId); - } - - public static String getRequestId() { - return (String) - ExecutionContext.getCurrent().getGlobalContext().get(HeaderParam.REQUEST_ID.getParamName()); - } - - public Map getContextValues() { - String serviceCallStack = getServiceCallStack(); - Map contextValues = contextStackValues.get(serviceCallStack); - if (contextValues == null) { - contextValues = new HashMap<>(); - setContextValues(contextValues, serviceCallStack); - } - - return contextStackValues.get(serviceCallStack); - } - - public void setContextValues(Map currentContextValues) { - this.contextStackValues.put( - getServiceCallStack(), new HashMap(currentContextValues)); - } - - public void setContextValues(Map currentContextValues, String serviceCallStack) { - this.contextStackValues.put( - serviceCallStack, new HashMap(currentContextValues)); - } - - public void removeContext() { - this.contextStackValues.remove(getServiceCallStack()); - } - - public void cleanup() { - removeContext(); - pop(); - if (serviceCallStack.size() == 0) { - this.globalContext.remove(HeaderParam.REQUEST_ST_ED_PATH.getParamName()); - } - } - - // TODO move Response out of context - public Response getResponse() { - Response contextResponse = - (Response) ExecutionContext.getCurrent().getContextValues().get("RESPONSE"); - if (contextResponse == null) { - contextResponse = new Response(); - ExecutionContext.getCurrent().getContextValues().put("RESPONSE", contextResponse); - } - return contextResponse; - } - - public void push(String methodName) { - serviceCallStack.push(methodName); - } - - public String pop() { - return serviceCallStack.pop(); - } - - public String peek() { - return serviceCallStack.peek(); - } - - public String getServiceCallStack() { - String serviceCallPath = ""; - for (String value : serviceCallStack) { - if ("".equals(serviceCallPath)) serviceCallPath = value; - else serviceCallPath = serviceCallPath + "/" + value; - } - - if ("".equals(serviceCallPath)) { - serviceCallStack.push("default"); - return "default"; - } - return serviceCallPath; - } - - public Map getGlobalContext() { - return globalContext; - } - - public void setGlobalContext(Map globalContext) { - this.globalContext = globalContext; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/HeaderParam.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/HeaderParam.java deleted file mode 100644 index 116c0a64b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/HeaderParam.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.sunbird.common.request; - -/** - * The keys of the Execution Context Values. - * - * @author Manzarul - */ -public enum HeaderParam { - REQUEST_ID, - REQUEST_PATH, - REQUEST_ST_ED_PATH, - CURRENT_INVOCATION_PATH, - USER_DATA, - USER_LOCALE, - SYSTEM_LOCALE, - USER_ID, - PROXY_USER_ID, - USER_NAME, - PROXY_USER_NAME, - SCOPE_ID, - X_Consumer_ID("x-consumer-id"), - X_Session_ID("x-session-id"), - X_Device_ID("x-device-id"), - X_Authenticated_Userid("x-authenticated-userid"), - ts("ts"), - Content_Type("content-type"), - X_Authenticated_User_Token("x-authenticated-user-token"), - X_Authenticated_Client_Token("x-authenticated-client-token"), - X_Authenticated_Client_Id("x-authenticated-client-id"), - X_APP_ID("x-app-id"), - CHANNEL_ID("x-channel-id"), - X_Response_Length("x-response-length"); - /** name of the parameter */ - private String name; - - /** - * 1-arg constructor - * - * @param name String - */ - private HeaderParam(String name) { - this.name = name; - } - - /** - * this will return parameter default name - * - * @return - */ - public String getParamName() { - return this.name(); - } - - private HeaderParam() {} - - /** - * This will provide name of one argument enum - * - * @return String - */ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/LearnerStateRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/LearnerStateRequestValidator.java deleted file mode 100644 index 91d5a4bc5..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/LearnerStateRequestValidator.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.sunbird.common.request; - -import org.apache.commons.collections.CollectionUtils; -import org.sunbird.common.models.util.JsonKey; - -import java.util.List; - -/** @author arvind */ -public class LearnerStateRequestValidator extends BaseRequestValidator { - - /** - * Method to validate the get content state request. - * - * @param request Representing the request object. - */ - public void validateGetContentState(Request request) { - validateListParam(request.getRequest(), JsonKey.COURSE_IDS, JsonKey.CONTENT_IDS); - if (request.getRequest().containsKey(JsonKey.COURSE_IDS)) { - List courseIds = (List) request.getRequest().get(JsonKey.COURSE_IDS); - request.getRequest().remove(JsonKey.COURSE_IDS); - if (!request.getRequest().containsKey(JsonKey.COURSE_ID) && CollectionUtils.isNotEmpty(courseIds)) { - request.getRequest().put(JsonKey.COURSE_ID, courseIds.get(0)); - } - } - checkMandatoryFieldsPresent(request.getRequest(), JsonKey.USER_ID, JsonKey.COURSE_ID, JsonKey.BATCH_ID); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/Request.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/Request.java deleted file mode 100644 index 665da4590..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/Request.java +++ /dev/null @@ -1,210 +0,0 @@ -package org.sunbird.common.request; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Request implements Serializable { - - private static final long serialVersionUID = -2362783406031347676L; - private static final Integer MIN_TIMEOUT = 0; - private static final Integer MAX_TIMEOUT = 30; - private static final int WAIT_TIME_VALUE = 30; - - protected Map context; - private String id; - private String ver; - private String ts; - private RequestParams params; - - private Map request = new HashMap<>(); - - private String managerName; - private String operation; - private String requestId; - private int env; - - private Integer timeout; // in seconds - - public Request() { - this.params = new RequestParams(); - this.params.setMsgid(requestId); - init(); - } - - private void init() { - // Set the context here. - Map currContext = ExecutionContext.getCurrent().getContextValues(); - context = currContext == null ? new HashMap<>() : new HashMap<>(currContext); - if (ExecutionContext.getCurrent() - .getGlobalContext() - .containsKey(HeaderParam.CURRENT_INVOCATION_PATH.getParamName())) { - context.put( - HeaderParam.REQUEST_PATH.getParamName(), - ExecutionContext.getCurrent() - .getGlobalContext() - .get(HeaderParam.CURRENT_INVOCATION_PATH.getParamName())); - } - - // set request_id - requestId = - (String) - ExecutionContext.getCurrent() - .getGlobalContext() - .get(HeaderParam.REQUEST_ID.getParamName()); - } - - public void toLower() { - Arrays.asList( - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_API_REQUEST_LOWER_CASE_FIELDS).split(",")) - .stream() - .forEach( - field -> { - if (StringUtils.isNotBlank((String) this.getRequest().get(field))) { - this.getRequest().put(field, ((String) this.getRequest().get(field)).toLowerCase()); - } - }); - } - - public Request(Request request) { - this.params = request.getParams(); - if (null == this.params) this.params = new RequestParams(); - else if (!StringUtils.isBlank(this.params.getMsgid())) { - ExecutionContext.setRequestId(this.params.getMsgid()); - this.requestId = this.params.getMsgid(); - } - if (StringUtils.isBlank(this.params.getMsgid()) && !StringUtils.isBlank(requestId)) - this.params.setMsgid(requestId); - this.context.putAll(request.getContext()); - } - - public String getRequestId() { - if (null != this.params) return this.params.getMsgid(); - return requestId; - } - - public Map getContext() { - return context; - } - - public void setContext(Map context) { - this.context = context; - } - - /** @return the requestValueObjects */ - public Map getRequest() { - return request; - } - - public void setRequest(Map request) { - this.request = request; - } - - public Object get(String key) { - return request.get(key); - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public void put(String key, Object vo) { - request.put(key, vo); - } - - public String getManagerName() { - return managerName; - } - - public void setManagerName(String managerName) { - this.managerName = managerName; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public void copyRequestValueObjects(Map map) { - if (null != map && map.size() > 0) { - this.request.putAll(map); - } - } - - @Override - public String toString() { - return "Request [" - + (context != null ? "context=" + context + ", " : "") - + (request != null ? "requestValueObjects=" + request : "") - + "]"; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVer() { - return ver; - } - - public void setVer(String ver) { - this.ver = ver; - } - - public String getTs() { - return ts; - } - - public void setTs(String ts) { - this.ts = ts; - } - - public RequestParams getParams() { - return params; - } - - public void setParams(RequestParams params) { - this.params = params; - if (this.params.getMsgid() == null && requestId != null) this.params.setMsgid(requestId); - } - - /** @return the env */ - public int getEnv() { - return env; - } - - /** @param env the env to set */ - public void setEnv(int env) { - this.env = env; - } - - public Integer getTimeout() { - return timeout == null ? WAIT_TIME_VALUE : timeout; - } - - public void setTimeout(Integer timeout) { - if (timeout < MIN_TIMEOUT && timeout > MAX_TIMEOUT) { - ProjectCommonException.throwServerErrorException( - ResponseCode.invalidRequestTimeout, - MessageFormat.format(ResponseCode.invalidRequestTimeout.getErrorMessage(), timeout)); - } - this.timeout = timeout; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestParams.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestParams.java deleted file mode 100644 index 92ff599a8..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestParams.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.sunbird.common.request; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import java.io.Serializable; - -/** @author rayulu */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class RequestParams implements Serializable { - - private static final long serialVersionUID = -759588115950763188L; - - private String did; - private String key; - private String msgid; - private String uid; - private String cid; - private String sid; - private String authToken; - - /** @return the authToken */ - public String getAuthToken() { - return authToken; - } - - /** @param authToken the authToken to set */ - public void setAuthToken(String authToken) { - this.authToken = authToken; - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public String getDid() { - return did; - } - - public void setDid(String did) { - this.did = did; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getMsgid() { - return msgid; - } - - public void setMsgid(String msgid) { - this.msgid = msgid; - } - - public String getCid() { - return cid; - } - - public void setCid(String cid) { - this.cid = cid; - } - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestValidator.java deleted file mode 100644 index de447776f..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/RequestValidator.java +++ /dev/null @@ -1,1038 +0,0 @@ -package org.sunbird.common.request; - -import java.text.MessageFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.ProjectUtil.ProgressStatus; -import org.sunbird.common.models.util.ProjectUtil.Source; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.models.util.StringFormatter; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.common.responsecode.ResponseMessage; - -/** - * This call will do validation for all incoming request data. - * - * @author Manzarul - */ -public final class RequestValidator { - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - private RequestValidator() {} - - /** - * This method will do content state request data validation. if all mandatory data is coming then - * it won't do any thing if any mandatory data is missing then it will throw exception. - * - * @param contentRequestDto Request - */ - @SuppressWarnings("unchecked") - public static void validateUpdateContent(Request contentRequestDto) { - List> list = - (List>) (contentRequestDto.getRequest().get(JsonKey.CONTENTS)); - if(CollectionUtils.isNotEmpty(list)) { - for (Map map : list) { - if (null != map.get(JsonKey.LAST_UPDATED_TIME)) { - boolean bool = - ProjectUtil.isDateValidFormat( - "yyyy-MM-dd HH:mm:ss:SSSZ", (String) map.get(JsonKey.LAST_UPDATED_TIME)); - if (!bool) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - } - if (null != map.get(JsonKey.LAST_COMPLETED_TIME)) { - boolean bool = - ProjectUtil.isDateValidFormat( - "yyyy-MM-dd HH:mm:ss:SSSZ", (String) map.get(JsonKey.LAST_COMPLETED_TIME)); - if (!bool) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - } - if (map.containsKey(JsonKey.CONTENT_ID)) { - - if (null == map.get(JsonKey.CONTENT_ID)) { - throw new ProjectCommonException( - ResponseCode.contentIdRequired.getErrorCode(), - ResponseCode.contentIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - if (ProjectUtil.isNull(map.get(JsonKey.STATUS))) { - throw new ProjectCommonException( - ResponseCode.contentStatusRequired.getErrorCode(), - ResponseCode.contentStatusRequired.getErrorMessage(), - ERROR_CODE); - } - - } else { - throw new ProjectCommonException( - ResponseCode.contentIdRequired.getErrorCode(), - ResponseCode.contentIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - } - List> assessmentData = (List>) contentRequestDto.getRequest().get(JsonKey.ASSESSMENT_EVENTS); - if (!CollectionUtils.isEmpty(assessmentData)) { - for (Map map : assessmentData) { - if (!map.containsKey(JsonKey.ASSESSMENT_TS)){ - throw new ProjectCommonException( - ResponseCode.assessmentAttemptDateRequired.getErrorCode(), - ResponseCode.assessmentAttemptDateRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.COURSE_ID) || StringUtils.isBlank((String) map.get(JsonKey.COURSE_ID))){ - throw new ProjectCommonException( - ResponseCode.courseIdRequired.getErrorCode(), - ResponseCode.courseIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.CONTENT_ID) || StringUtils.isBlank((String) map.get(JsonKey.CONTENT_ID))) { - throw new ProjectCommonException( - ResponseCode.contentIdRequired.getErrorCode(), - ResponseCode.contentIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.BATCH_ID) || StringUtils.isBlank((String) map.get(JsonKey.BATCH_ID))) { - throw new ProjectCommonException( - ResponseCode.courseBatchIdRequired.getErrorCode(), - ResponseCode.courseBatchIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.USER_ID) || StringUtils.isBlank((String) map.get(JsonKey.USER_ID))) { - throw new ProjectCommonException( - ResponseCode.userIdRequired.getErrorCode(), - ResponseCode.userIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.ATTEMPT_ID) || StringUtils.isBlank((String) map.get(JsonKey.ATTEMPT_ID))) { - throw new ProjectCommonException( - ResponseCode.attemptIdRequired.getErrorCode(), - ResponseCode.attemptIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.EVENTS)) { - throw new ProjectCommonException( - ResponseCode.eventsRequired.getErrorCode(), - ResponseCode.eventsRequired.getErrorMessage(), - ERROR_CODE); - } - } - } - } - List> assessmentData = - (List>) contentRequestDto.getRequest().get(JsonKey.ASSESSMENT_EVENTS); - if (!CollectionUtils.isEmpty(assessmentData)) { - for (Map map : assessmentData) { - if (!map.containsKey(JsonKey.ASSESSMENT_TS)) { - throw new ProjectCommonException( - ResponseCode.assessmentAttemptDateRequired.getErrorCode(), - ResponseCode.assessmentAttemptDateRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.COURSE_ID) - || StringUtils.isBlank((String) map.get(JsonKey.COURSE_ID))) { - throw new ProjectCommonException( - ResponseCode.courseIdRequired.getErrorCode(), - ResponseCode.courseIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.CONTENT_ID) - || StringUtils.isBlank((String) map.get(JsonKey.CONTENT_ID))) { - throw new ProjectCommonException( - ResponseCode.contentIdRequired.getErrorCode(), - ResponseCode.contentIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.BATCH_ID) - || StringUtils.isBlank((String) map.get(JsonKey.BATCH_ID))) { - throw new ProjectCommonException( - ResponseCode.courseBatchIdRequired.getErrorCode(), - ResponseCode.courseBatchIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.USER_ID) - || StringUtils.isBlank((String) map.get(JsonKey.USER_ID))) { - throw new ProjectCommonException( - ResponseCode.userIdRequired.getErrorCode(), - ResponseCode.userIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.ATTEMPT_ID) - || StringUtils.isBlank((String) map.get(JsonKey.ATTEMPT_ID))) { - throw new ProjectCommonException( - ResponseCode.attemptIdRequired.getErrorCode(), - ResponseCode.attemptIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (!map.containsKey(JsonKey.EVENTS)) { - throw new ProjectCommonException( - ResponseCode.eventsRequired.getErrorCode(), - ResponseCode.eventsRequired.getErrorMessage(), - ERROR_CODE); - } - } - } - } - - /** - * This method will validate get page data api. - * - * @param request Request - */ - public static void validateGetPageData(Request request) { - if (request == null || (StringUtils.isBlank((String) request.get(JsonKey.SOURCE)))) { - throw new ProjectCommonException( - ResponseCode.sourceRequired.getErrorCode(), - ResponseCode.sourceRequired.getErrorMessage(), - ERROR_CODE); - } - if (!validPageSourceType((String) request.get(JsonKey.SOURCE))) { - throw new ProjectCommonException( - ResponseCode.invalidPageSource.getErrorCode(), - ResponseCode.invalidPageSource.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.get(JsonKey.PAGE_NAME))) { - throw new ProjectCommonException( - ResponseCode.pageNameRequired.getErrorCode(), - ResponseCode.pageNameRequired.getErrorMessage(), - ERROR_CODE); - } - } - - private static boolean validPageSourceType(String source) { - - Boolean isValidSource = false; - for (Source src : ProjectUtil.Source.values()) { - if (src.getValue().equalsIgnoreCase(source)) { - isValidSource = true; - break; - } - } - return isValidSource; - } - - /** - * This method will validate add course request data. - * - * @param courseRequest Request - */ - public static void validateAddBatchCourse(Request courseRequest) { - - if (courseRequest.getRequest().get(JsonKey.BATCH_ID) == null) { - throw new ProjectCommonException( - ResponseCode.courseBatchIdRequired.getErrorCode(), - ResponseCode.courseBatchIdRequired.getErrorMessage(), - ERROR_CODE); - } - if (courseRequest.getRequest().get(JsonKey.USER_IDs) == null) { - throw new ProjectCommonException( - ResponseCode.userIdRequired.getErrorCode(), - ResponseCode.userIdRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate add course request data. - * - * @param courseRequest Request - */ - public static void validateGetBatchCourse(Request courseRequest) { - - if (courseRequest.getRequest().get(JsonKey.BATCH_ID) == null) { - throw new ProjectCommonException( - ResponseCode.courseBatchIdRequired.getErrorCode(), - ResponseCode.courseBatchIdRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate update course request data. - * - * @param request Request - */ - public static void validateUpdateCourse(Request request) { - - if (request.getRequest().get(JsonKey.COURSE_ID) == null) { - throw new ProjectCommonException( - ResponseCode.courseIdRequired.getErrorCode(), - ResponseCode.courseIdRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate published course request data. - * - * @param request Request - */ - public static void validatePublishCourse(Request request) { - if (request.getRequest().get(JsonKey.COURSE_ID) == null) { - throw new ProjectCommonException( - ResponseCode.courseIdRequiredError.getErrorCode(), - ResponseCode.courseIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate Delete course request data. - * - * @param request Request - */ - public static void validateDeleteCourse(Request request) { - if (request.getRequest().get(JsonKey.COURSE_ID) == null) { - throw new ProjectCommonException( - ResponseCode.courseIdRequiredError.getErrorCode(), - ResponseCode.courseIdRequiredError.getErrorMessage(), - ERROR_CODE); - } - } - - /* - * This method will validate create section data - * - * @param userRequest Request - */ - public static void validateCreateSection(Request request) { - if (StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.SECTION_NAME) != null - ? request.getRequest().get(JsonKey.SECTION_NAME) - : ""))) { - throw new ProjectCommonException( - ResponseCode.sectionNameRequired.getErrorCode(), - ResponseCode.sectionNameRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.SECTION_DATA_TYPE) != null - ? request.getRequest().get(JsonKey.SECTION_DATA_TYPE) - : ""))) { - throw new ProjectCommonException( - ResponseCode.sectionDataTypeRequired.getErrorCode(), - ResponseCode.sectionDataTypeRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate update section request data - * - * @param request Request - */ - public static void validateUpdateSection(Request request) { - if (request.getRequest().containsKey(JsonKey.SECTION_NAME) - && StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.SECTION_NAME) != null - ? request.getRequest().get(JsonKey.SECTION_NAME) - : ""))) { - throw new ProjectCommonException( - ResponseCode.sectionNameRequired.getErrorCode(), - ResponseCode.sectionNameRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.ID) != null - ? request.getRequest().get(JsonKey.ID) - : ""))) { - throw new ProjectCommonException( - ResponseCode.sectionIdRequired.getErrorCode(), - ResponseCode.sectionIdRequired.getErrorMessage(), - ERROR_CODE); - } - if (request.getRequest().containsKey(JsonKey.SECTION_DATA_TYPE) - && StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.SECTION_DATA_TYPE) != null - ? request.getRequest().get(JsonKey.SECTION_DATA_TYPE) - : ""))) { - throw new ProjectCommonException( - ResponseCode.sectionDataTypeRequired.getErrorCode(), - ResponseCode.sectionDataTypeRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate create page data - * - * @param request Request - */ - public static void validateCreatePage(Request request) { - if (StringUtils.isEmpty( - (String) - (request.getRequest().get(JsonKey.PAGE_NAME) != null - ? request.getRequest().get(JsonKey.PAGE_NAME) - : ""))) { - throw new ProjectCommonException( - ResponseCode.pageNameRequired.getErrorCode(), - ResponseCode.pageNameRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate update page request data - * - * @param request Request - */ - public static void validateUpdatepage(Request request) { - if (request.getRequest().containsKey(JsonKey.PAGE_NAME) - && StringUtils.isEmpty( - (String) - (request.getRequest().get(JsonKey.PAGE_NAME) != null - ? request.getRequest().get(JsonKey.PAGE_NAME) - : ""))) { - throw new ProjectCommonException( - ResponseCode.pageNameRequired.getErrorCode(), - ResponseCode.pageNameRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank( - (String) - (request.getRequest().get(JsonKey.ID) != null - ? request.getRequest().get(JsonKey.ID) - : ""))) { - throw new ProjectCommonException( - ResponseCode.pageIdRequired.getErrorCode(), - ResponseCode.pageIdRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate bulk user upload requested data. - * - * @param reqObj Request - */ - public static void validateUploadUser(Map reqObj) { - if (StringUtils.isBlank((String) reqObj.get(JsonKey.ORGANISATION_ID)) - && (StringUtils.isBlank((String) reqObj.get(JsonKey.ORG_EXTERNAL_ID)) - || StringUtils.isBlank((String) reqObj.get(JsonKey.ORG_PROVIDER)))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - (ProjectUtil.formatMessage( - ResponseMessage.Message.OR_FORMAT, - JsonKey.ORGANISATION_ID, - ProjectUtil.formatMessage( - ResponseMessage.Message.AND_FORMAT, - JsonKey.ORG_EXTERNAL_ID, - JsonKey.ORG_PROVIDER)))), - ERROR_CODE); - } - if (null == reqObj.get(JsonKey.FILE)) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), JsonKey.FILE), - ERROR_CODE); - } - } - - /** - * courseId : Should be a valid courseId under EKStep. name : should not be null or empty - * enrolmentType: can have only following two values {"open","invite-only"} startDate : In - * yyyy-MM-DD format , and must be >= today date. endDate : In yyyy-MM-DD format and must be > - * startDate createdFor : List of valid organisation ids. this filed will be used in case of - * "invite-only" enrolmentType. for open type if createdFor values is coming then system will just - * save that value. mentors : List of user ids , who will work as a mentor. - * - * @param request - */ - public static void validateCreateBatchReq(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.COURSE_ID))) { - throw new ProjectCommonException( - ResponseCode.invalidCourseId.getErrorCode(), - ResponseCode.invalidCourseId.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.NAME))) { - throw new ProjectCommonException( - ResponseCode.courseNameRequired.getErrorCode(), - ResponseCode.courseNameRequired.getErrorMessage(), - ERROR_CODE); - } - String enrolmentType = (String) request.getRequest().get(JsonKey.ENROLLMENT_TYPE); - validateEnrolmentType(enrolmentType); - String startDate = (String) request.getRequest().get(JsonKey.START_DATE); - String endDate = (String) request.getRequest().get(JsonKey.END_DATE); - validateStartDate(startDate); - validateEndDate(startDate, endDate); - - if (request.getRequest().containsKey(JsonKey.COURSE_CREATED_FOR) - && !(request.getRequest().get(JsonKey.COURSE_CREATED_FOR) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE); - } - } - - private static boolean checkProgressStatus(int status) { - for (ProgressStatus pstatus : ProgressStatus.values()) { - if (pstatus.getValue() == status) { - return true; - } - } - return false; - } - - public static void validateUpdateCourseBatchReq(Request request) { - - if (null != request.getRequest().get(JsonKey.STATUS)) { - boolean status = validateBatchStatus(request); - if (!status) { - throw new ProjectCommonException( - ResponseCode.progressStatusError.getErrorCode(), - ResponseCode.progressStatusError.getErrorMessage(), - ERROR_CODE); - } - } - if (request.getRequest().containsKey(JsonKey.NAME) - && StringUtils.isEmpty((String) request.getRequest().get(JsonKey.NAME))) { - throw new ProjectCommonException( - ResponseCode.courseNameRequired.getErrorCode(), - ResponseCode.courseNameRequired.getErrorMessage(), - ERROR_CODE); - } - if (request.getRequest().containsKey(JsonKey.ENROLLMENT_TYPE)) { - String enrolmentType = (String) request.getRequest().get(JsonKey.ENROLLMENT_TYPE); - validateEnrolmentType(enrolmentType); - } - String startDate = (String) request.getRequest().get(JsonKey.START_DATE); - String endDate = (String) request.getRequest().get(JsonKey.END_DATE); - - validateUpdateBatchStartDate(startDate); - validateEndDate(startDate, endDate); - - boolean bool = validateDateWithTodayDate(endDate); - if (!bool) { - throw new ProjectCommonException( - ResponseCode.invalidBatchEndDateError.getErrorCode(), - ResponseCode.invalidBatchEndDateError.getErrorMessage(), - ERROR_CODE); - } - - validateUpdateBatchEndDate(request); - if (request.getRequest().containsKey(JsonKey.COURSE_CREATED_FOR) - && !(request.getRequest().get(JsonKey.COURSE_CREATED_FOR) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE); - } - - if (request.getRequest().containsKey(JsonKey.MENTORS) - && !(request.getRequest().get(JsonKey.MENTORS) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE); - } - } - - private static void validateUpdateBatchStartDate(String startDate) { - if (StringUtils.isNotBlank(startDate)) { - try { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.parse(startDate); - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - } else { - throw new ProjectCommonException( - ResponseCode.courseBatchStartDateRequired.getErrorCode(), - ResponseCode.courseBatchStartDateRequired.getErrorMessage(), - ERROR_CODE); - } - } - - private static boolean validateBatchStatus(Request request) { - boolean status = false; - try { - status = checkProgressStatus(Integer.parseInt("" + request.getRequest().get(JsonKey.STATUS))); - - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return status; - } - - private static void validateUpdateBatchEndDate(Request request) { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - String startDate = (String) request.getRequest().get(JsonKey.START_DATE); - String endDate = (String) request.getRequest().get(JsonKey.END_DATE); - format.setLenient(false); - if (StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(startDate)) { - Date batchStartDate = null; - Date batchEndDate = null; - try { - batchStartDate = format.parse(startDate); - batchEndDate = format.parse(endDate); - Calendar cal1 = Calendar.getInstance(); - Calendar cal2 = Calendar.getInstance(); - cal1.setTime(batchStartDate); - cal2.setTime(batchEndDate); - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - if (batchEndDate.before(batchStartDate)) { - throw new ProjectCommonException( - ResponseCode.invalidBatchEndDateError.getErrorCode(), - ResponseCode.invalidBatchEndDateError.getErrorMessage(), - ERROR_CODE); - } - } - } - - private static boolean validateDateWithTodayDate(String date) { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setLenient(false); - try { - if (StringUtils.isNotEmpty(date)) { - Date reqDate = format.parse(date); - Date todayDate = format.parse(format.format(new Date())); - Calendar cal1 = Calendar.getInstance(); - Calendar cal2 = Calendar.getInstance(); - cal1.setTime(reqDate); - cal2.setTime(todayDate); - if (reqDate.before(todayDate)) { - return false; - } - } - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - return true; - } - - /** @param enrolmentType */ - public static void validateEnrolmentType(String enrolmentType) { - if (StringUtils.isBlank(enrolmentType)) { - throw new ProjectCommonException( - ResponseCode.enrolmentTypeRequired.getErrorCode(), - ResponseCode.enrolmentTypeRequired.getErrorMessage(), - ERROR_CODE); - } - if (!(ProjectUtil.EnrolmentType.open.getVal().equalsIgnoreCase(enrolmentType) - || ProjectUtil.EnrolmentType.inviteOnly.getVal().equalsIgnoreCase(enrolmentType))) { - throw new ProjectCommonException( - ResponseCode.enrolmentIncorrectValue.getErrorCode(), - ResponseCode.enrolmentIncorrectValue.getErrorMessage(), - ERROR_CODE); - } - } - - /** @param startDate */ - private static void validateStartDate(String startDate) { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setLenient(false); - if (StringUtils.isBlank(startDate)) { - throw new ProjectCommonException( - ResponseCode.courseBatchStartDateRequired.getErrorCode(), - ResponseCode.courseBatchStartDateRequired.getErrorMessage(), - ERROR_CODE); - } - try { - Date batchStartDate = format.parse(startDate); - Date todayDate = format.parse(format.format(new Date())); - Calendar cal1 = Calendar.getInstance(); - Calendar cal2 = Calendar.getInstance(); - cal1.setTime(batchStartDate); - cal2.setTime(todayDate); - if (batchStartDate.before(todayDate)) { - throw new ProjectCommonException( - ResponseCode.courseBatchStartDateError.getErrorCode(), - ResponseCode.courseBatchStartDateError.getErrorMessage(), - ERROR_CODE); - } - } catch (ProjectCommonException e) { - throw e; - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - } - - private static void validateEndDate(String startDate, String endDate) { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setLenient(false); - Date batchEndDate = null; - Date batchStartDate = null; - try { - if (StringUtils.isNotEmpty(endDate)) { - batchEndDate = format.parse(endDate); - batchStartDate = format.parse(startDate); - } - } catch (Exception e) { - throw new ProjectCommonException( - ResponseCode.dateFormatError.getErrorCode(), - ResponseCode.dateFormatError.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isNotEmpty(endDate) && batchStartDate.getTime() >= batchEndDate.getTime()) { - throw new ProjectCommonException( - ResponseCode.endDateError.getErrorCode(), - ResponseCode.endDateError.getErrorMessage(), - ERROR_CODE); - } - } - - public static void validateSyncRequest(Request request) { - String operation = (String) request.getRequest().get(JsonKey.OPERATION_FOR); - if ((null != operation) && (!operation.equalsIgnoreCase("keycloak"))) { - if (request.getRequest().get(JsonKey.OBJECT_TYPE) == null) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE); - } - List list = - new ArrayList<>( - Arrays.asList( - new String[] { - JsonKey.USER, JsonKey.ORGANISATION, JsonKey.BATCH, JsonKey.USER_COURSE - })); - if (!list.contains(request.getRequest().get(JsonKey.OBJECT_TYPE))) { - throw new ProjectCommonException( - ResponseCode.invalidObjectType.getErrorCode(), - ResponseCode.invalidObjectType.getErrorMessage(), - ERROR_CODE); - } - } - } - - public static void validateUpdateSystemSettingsRequest(Request request) { - List list = - new ArrayList<>( - Arrays.asList( - PropertiesCache.getInstance() - .getProperty("system_settings_properties") - .split(","))); - for (String str : request.getRequest().keySet()) { - if (!list.contains(str)) { - throw new ProjectCommonException( - ResponseCode.invalidPropertyError.getErrorCode(), - MessageFormat.format(ResponseCode.invalidPropertyError.getErrorMessage(), str), - ERROR_CODE); - } - } - } - - public static void validateSendMail(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.SUBJECT))) { - throw new ProjectCommonException( - ResponseCode.emailSubjectError.getErrorCode(), - ResponseCode.emailSubjectError.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.BODY))) { - throw new ProjectCommonException( - ResponseCode.emailBodyError.getErrorCode(), - ResponseCode.emailBodyError.getErrorMessage(), - ERROR_CODE); - } - if (CollectionUtils.isEmpty((List) (request.getRequest().get(JsonKey.RECIPIENT_EMAILS))) - && CollectionUtils.isEmpty( - (List) (request.getRequest().get(JsonKey.RECIPIENT_USERIDS))) - && MapUtils.isEmpty( - (Map) (request.getRequest().get(JsonKey.RECIPIENT_SEARCH_QUERY))) - && CollectionUtils.isEmpty( - (List) (request.getRequest().get(JsonKey.RECIPIENT_PHONES)))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - MessageFormat.format( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - StringFormatter.joinByOr( - StringFormatter.joinByComma( - JsonKey.RECIPIENT_EMAILS, - JsonKey.RECIPIENT_USERIDS, - JsonKey.RECIPIENT_PHONES), - JsonKey.RECIPIENT_SEARCH_QUERY)), - ERROR_CODE); - } - } - - public static void validateFileUpload(Request reqObj) { - - if (StringUtils.isBlank((String) reqObj.get(JsonKey.CONTAINER))) { - throw new ProjectCommonException( - ResponseCode.storageContainerNameMandatory.getErrorCode(), - ResponseCode.storageContainerNameMandatory.getErrorMessage(), - ERROR_CODE); - } - } - - /** @param reqObj */ - public static void validateCreateOrgType(Request reqObj) { - if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.NAME))) { - throw createExceptionInstance(ResponseCode.orgTypeMandatory.getErrorCode()); - } - } - - /** @param reqObj */ - public static void validateUpdateOrgType(Request reqObj) { - if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.NAME))) { - throw createExceptionInstance(ResponseCode.orgTypeMandatory.getErrorCode()); - } - if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.ID))) { - throw createExceptionInstance(ResponseCode.orgTypeIdRequired.getErrorCode()); - } - } - - /** - * Method to validate not for userId, title, note, courseId, contentId and tags - * - * @param request - */ - @SuppressWarnings("rawtypes") - public static void validateNote(Request request) { - if (StringUtils.isBlank((String) request.get(JsonKey.USER_ID))) { - throw new ProjectCommonException( - ResponseCode.userIdRequired.getErrorCode(), - ResponseCode.userIdRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.get(JsonKey.TITLE))) { - throw new ProjectCommonException( - ResponseCode.titleRequired.getErrorCode(), - ResponseCode.titleRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.get(JsonKey.NOTE))) { - throw new ProjectCommonException( - ResponseCode.noteRequired.getErrorCode(), - ResponseCode.noteRequired.getErrorMessage(), - ERROR_CODE); - } - if (StringUtils.isBlank((String) request.get(JsonKey.CONTENT_ID)) - && StringUtils.isBlank((String) request.get(JsonKey.COURSE_ID))) { - throw new ProjectCommonException( - ResponseCode.contentIdError.getErrorCode(), - ResponseCode.contentIdError.getErrorMessage(), - ERROR_CODE); - } - if (request.getRequest().containsKey(JsonKey.TAGS) - && ((request.getRequest().get(JsonKey.TAGS) instanceof List) - && ((List) request.getRequest().get(JsonKey.TAGS)).isEmpty())) { - throw new ProjectCommonException( - ResponseCode.invalidTags.getErrorCode(), - ResponseCode.invalidTags.getErrorMessage(), - ERROR_CODE); - } else if (request.getRequest().get(JsonKey.TAGS) instanceof String) { - throw new ProjectCommonException( - ResponseCode.invalidTags.getErrorCode(), - ResponseCode.invalidTags.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * Method to validate noteId - * - * @param noteId - */ - public static void validateNoteId(String noteId) { - if (StringUtils.isBlank(noteId)) { - throw createExceptionInstance(ResponseCode.invalidNoteId.getErrorCode()); - } - } - - /** - * Method to validate - * - * @param request - */ - public static void validateRegisterClient(Request request) { - - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.CLIENT_NAME))) { - throw createExceptionInstance(ResponseCode.invalidClientName.getErrorCode()); - } - } - - /** - * Method to validate the request for updating the client key - * - * @param clientId - * @param masterAccessToken - */ - public static void validateUpdateClientKey(String clientId, String masterAccessToken) { - validateClientId(clientId); - if (StringUtils.isBlank(masterAccessToken)) { - throw createExceptionInstance(ResponseCode.invalidRequestData.getErrorCode()); - } - } - - /** - * Method to validate the request for updating the client key - * - * @param id - * @param type - */ - public static void validateGetClientKey(String id, String type) { - validateClientId(id); - if (StringUtils.isBlank(type)) { - throw createExceptionInstance(ResponseCode.invalidRequestData.getErrorCode()); - } - } - - /** - * Method to validate clientId. - * - * @param clientId - */ - public static void validateClientId(String clientId) { - if (StringUtils.isBlank(clientId)) { - throw createExceptionInstance(ResponseCode.invalidClientId.getErrorCode()); - } - } - - /** - * Method to validate notification request data. - * - * @param request Request - */ - @SuppressWarnings("unchecked") - public static void validateSendNotification(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.TO))) { - throw createExceptionInstance(ResponseCode.invalidTopic.getErrorCode()); - } - if (request.getRequest().get(JsonKey.DATA) == null - || !(request.getRequest().get(JsonKey.DATA) instanceof Map) - || ((Map) request.getRequest().get(JsonKey.DATA)).size() == 0) { - throw createExceptionInstance(ResponseCode.invalidTopicData.getErrorCode()); - } - - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.TYPE))) { - throw createExceptionInstance(ResponseCode.invalidNotificationType.getErrorCode()); - } - if (!(JsonKey.FCM.equalsIgnoreCase((String) request.getRequest().get(JsonKey.TYPE)))) { - throw createExceptionInstance(ResponseCode.notificationTypeSupport.getErrorCode()); - } - } - - @SuppressWarnings("rawtypes") - public static void validateGetUserCount(Request request) { - if (!validateListType(request, JsonKey.LOCATION_IDS)) { - throw createDataTypeException( - ResponseCode.dataTypeError.getErrorCode(), JsonKey.LOCATION_IDS, JsonKey.LIST); - } - if (null == request.getRequest().get(JsonKey.LOCATION_IDS) - && ((List) request.getRequest().get(JsonKey.LOCATION_IDS)).isEmpty()) { - throw createExceptionInstance(ResponseCode.locationIdRequired.getErrorCode()); - } - - if (!validateBooleanType(request, JsonKey.USER_LIST_REQ)) { - throw createDataTypeException( - ResponseCode.dataTypeError.getErrorCode(), JsonKey.USER_LIST_REQ, "Boolean"); - } - - if (null != request.getRequest().get(JsonKey.USER_LIST_REQ) - && (Boolean) request.getRequest().get(JsonKey.USER_LIST_REQ)) { - throw createExceptionInstance(ResponseCode.functionalityMissing.getErrorCode()); - } - - if (!validateBooleanType(request, JsonKey.ESTIMATED_COUNT_REQ)) { - throw createDataTypeException( - ResponseCode.dataTypeError.getErrorCode(), JsonKey.ESTIMATED_COUNT_REQ, "Boolean"); - } - - if (null != request.getRequest().get(JsonKey.ESTIMATED_COUNT_REQ) - && (Boolean) request.getRequest().get(JsonKey.ESTIMATED_COUNT_REQ)) { - throw createExceptionInstance(ResponseCode.functionalityMissing.getErrorCode()); - } - } - - /** - * if the request contains that key and key is not instance of List then it will return false. - * other cases it will return true. - * - * @param request Request - * @param key String - * @return boolean - */ - private static boolean validateListType(Request request, String key) { - return !(request.getRequest().containsKey(key) - && null != request.getRequest().get(key) - && !(request.getRequest().get(key) instanceof List)); - } - - /** - * If the request contains the key and key value is not Boolean type then it will return false , - * for any other case it will return true. - * - * @param request Request - * @param key String - * @return boolean - */ - private static boolean validateBooleanType(Request request, String key) { - return !(request.getRequest().containsKey(key) - && null != request.getRequest().get(key) - && !(request.getRequest().get(key) instanceof Boolean)); - } - - private static ProjectCommonException createDataTypeException( - String errorCode, String key1, String key2) { - return new ProjectCommonException( - ResponseCode.getResponse(errorCode).getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.getResponse(errorCode).getErrorMessage(), key1, key2), - ERROR_CODE); - } - - private static ProjectCommonException createExceptionInstance(String errorCode) { - return new ProjectCommonException( - ResponseCode.getResponse(errorCode).getErrorCode(), - ResponseCode.getResponse(errorCode).getErrorMessage(), - ERROR_CODE); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/TelemetryV3Request.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/TelemetryV3Request.java deleted file mode 100644 index 5360274a3..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/TelemetryV3Request.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.sunbird.common.request; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** Created by arvind on 23/3/18. */ -public class TelemetryV3Request implements Serializable { - - private String id; - private String ver; - private Long ets; - private Params params; - - private List> events = new ArrayList<>(); - - public TelemetryV3Request() { - params = new Params(); - } - - class Params implements Serializable { - - private String did; - private String key; - private String msgid; - - public String getDid() { - return did; - } - - public void setDid(String did) { - this.did = did; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getMsgid() { - return msgid; - } - - public void setMsgid(String msgid) { - this.msgid = msgid; - } - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVer() { - return ver; - } - - public void setVer(String ver) { - this.ver = ver; - } - - public Long getEts() { - return ets; - } - - public void setEts(Long ets) { - this.ets = ets; - } - - public Params getParams() { - return params; - } - - public void setParams(Params params) { - this.params = params; - } - - public List> getEvents() { - return events; - } - - public void setEvents(List> events) { - this.events = events; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserFreeUpRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserFreeUpRequestValidator.java deleted file mode 100644 index abd93780c..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserFreeUpRequestValidator.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.sunbird.common.request; - -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class UserFreeUpRequestValidator extends BaseRequestValidator { - - private Request request; - private static List identifiers = new ArrayList<>(); - static { - identifiers.add(JsonKey.EMAIL); - identifiers.add(JsonKey.PHONE); - } - - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - - /** - * this method is used to get the instance to UserFreeUpRequestValidator class - * @param request - * @return - */ - public static UserFreeUpRequestValidator getInstance(Request request) { - return new UserFreeUpRequestValidator(request); - } - - private UserFreeUpRequestValidator(Request request) { - this.request = request; - } - - /** - * this is the method we need to call to validate the IdentifierFreeUpUser request. - */ - public void validate() { - validateIdPresence(); - validateIdentifier(); - } - - - private void validateIdPresence() { - validateParam( - (String) request.getRequest().get(JsonKey.ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.ID); - } - - private void validateIdentifier() { - validatePresence(); - validateObject(); - validateSubset(); - } - - - private void validatePresence() { - if (!request.getRequest().containsKey(JsonKey.IDENTIFIER)) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - MessageFormat.format(ResponseCode.mandatoryParamsMissing.getErrorMessage(), JsonKey.IDENTIFIER), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - } - - private void validateObject() { - Object identifierType = request.getRequest().get(JsonKey.IDENTIFIER); - if (!(identifierType instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.IDENTIFIER, JsonKey.LIST), - ERROR_CODE); - } - } - - private void validateSubset() { - List identifierVal = (List) request.getRequest().get(JsonKey.IDENTIFIER); - if (!identifiers.containsAll(identifierVal)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - String.format("%s %s",ResponseCode.invalidIdentifier.getErrorMessage(),Arrays.toString(identifiers.toArray())), JsonKey.IDENTIFIER, JsonKey.DATA), - ERROR_CODE); - } - } - -} - - diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserProfileRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserProfileRequestValidator.java deleted file mode 100644 index 3ae7f5241..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserProfileRequestValidator.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.sunbird.common.request; - -import java.util.List; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -public class UserProfileRequestValidator extends BaseRequestValidator { - - @SuppressWarnings("unchecked") - public void validateProfileVisibility(Request request) { - validateParam( - (String) request.getRequest().get(JsonKey.USER_ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.USER_ID); - validateUserId(request, JsonKey.USER_ID); - validatePublicAndPrivateFields(request); - } - - private void validatePublicAndPrivateFields(Request request) { - List publicList = (List) request.getRequest().get(JsonKey.PUBLIC); - List privateList = (List) request.getRequest().get(JsonKey.PRIVATE); - - if (publicList == null && privateList == null) { - throw new ProjectCommonException( - ResponseCode.invalidData.getErrorCode(), - ResponseCode.invalidData.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - validateListElementsAreDisjoint(publicList, privateList); - } - - private void validateListElementsAreDisjoint(List list1, List list2) { - if (list1 == null || list2 == null) { - return; - } - for (String field : list2) { - if (list1.contains(field)) { - throw new ProjectCommonException( - ResponseCode.visibilityInvalid.getErrorCode(), - ResponseCode.visibilityInvalid.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserRequestValidator.java deleted file mode 100644 index 8f2e74eb3..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserRequestValidator.java +++ /dev/null @@ -1,1099 +0,0 @@ -package org.sunbird.common.request; - -import java.text.MessageFormat; -import java.util.*; -import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.StringFormatter; -import org.sunbird.common.responsecode.ResponseCode; - -public class UserRequestValidator extends BaseRequestValidator { - - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - public void validateCreateUserRequest(Request userRequest) { - externalIdsValidation(userRequest, JsonKey.CREATE); - fieldsNotAllowed( - Arrays.asList( - JsonKey.REGISTERED_ORG_ID, - JsonKey.ROOT_ORG_ID, - JsonKey.PROVIDER, - JsonKey.EXTERNAL_ID, - JsonKey.EXTERNAL_ID_PROVIDER, - JsonKey.EXTERNAL_ID_TYPE, - JsonKey.ID_TYPE), - userRequest); - createUserBasicValidation(userRequest); - validateUserType(userRequest); - phoneValidation(userRequest); - addressValidation(userRequest); - educationValidation(userRequest); - jobProfileValidation(userRequest); - validateWebPages(userRequest); - validateLocationCodes(userRequest); - validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); - } - - public static boolean isGoodPassword(String password) { - return password.matches(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_PASS_REGEX)); - } - - private static void validatePassword(String password) { - if (StringUtils.isNotBlank(password)) { - boolean response = isGoodPassword(password); - if (!response) { - throw new ProjectCommonException( - ResponseCode.passwordValidation.getErrorCode(), - ResponseCode.passwordValidation.getErrorMessage(), - ERROR_CODE); - } - } - } - - private void validateLocationCodes(Request userRequest) { - Object locationCodes = userRequest.getRequest().get(JsonKey.LOCATION_CODES); - if ((locationCodes != null) && !(locationCodes instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LOCATION_CODES, JsonKey.LIST), - ERROR_CODE); - } - if (locationCodes != null) { - List set = new ArrayList(new HashSet<>((List) locationCodes)); - userRequest.getRequest().put(JsonKey.LOCATION_CODES, set); - } - } - - private void validateUserName(Request userRequest) { - validateParam( - (String) userRequest.getRequest().get(JsonKey.USERNAME), - ResponseCode.mandatoryParamsMissing, - JsonKey.USERNAME); - } - - public void validateUserCreateV3(Request userRequest) { - validateParam( - (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), - ResponseCode.mandatoryParamsMissing, - JsonKey.FIRST_NAME); - if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { - ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); - } - - if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) - || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) - && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { - ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); - } - - if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ - userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); - userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); - } - phoneVerifiedValidation(userRequest); - emailVerifiedValidation(userRequest); - validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); - if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { - validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); - } - if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { - validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); - } - } - - public void validateCreateUserV3Request(Request userRequest) { - validateCreateUserRequest(userRequest); - } - - public void validateCreateUserV1Request(Request userRequest) { - validateUserName(userRequest); - validateCreateUserV3Request(userRequest); - } - - public void validateCreateUserV2Request(Request userRequest) { - validateCreateUserRequest(userRequest); - } - - public void fieldsNotAllowed(List fields, Request userRequest) { - for (String field : fields) { - if (((userRequest.getRequest().get(field) instanceof String) - && StringUtils.isNotBlank((String) userRequest.getRequest().get(field))) - || (null != userRequest.getRequest().get(field))) { - throw new ProjectCommonException( - ResponseCode.invalidRequestParameter.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.invalidRequestParameter.getErrorMessage(), field), - ERROR_CODE); - } - } - } - - public void phoneValidation(Request userRequest) { - if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { - boolean bool = - ProjectUtil.validateCountryCode( - (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); - if (!bool) { - ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); - } - } - if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { - validatePhoneNo( - (String) userRequest.getRequest().get(JsonKey.PHONE), - (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); - } - phoneVerifiedValidation(userRequest); - } - - private void phoneVerifiedValidation(Request userRequest) { - if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { - if (null != userRequest.getRequest().get(JsonKey.PHONE_VERIFIED)) { - if (userRequest.getRequest().get(JsonKey.PHONE_VERIFIED) instanceof Boolean) { - if (!((boolean) userRequest.getRequest().get(JsonKey.PHONE_VERIFIED))) { - ProjectCommonException.throwClientErrorException(ResponseCode.phoneVerifiedError); - } - } else { - ProjectCommonException.throwClientErrorException(ResponseCode.phoneVerifiedError); - } - } else { - ProjectCommonException.throwClientErrorException(ResponseCode.phoneVerifiedError); - } - } - } - - /** - * This method will do basic validation for user request object. - * - * @param userRequest - */ - public void createUserBasicValidation(Request userRequest) { - - createUserBasicProfileFieldsValidation(userRequest); - if (userRequest.getRequest().containsKey(JsonKey.ROLES) - && null != userRequest.getRequest().get(JsonKey.ROLES) - && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), - ERROR_CODE); - } - if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) - && null != userRequest.getRequest().get(JsonKey.LANGUAGE) - && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), - ERROR_CODE); - } - } - - private void createUserBasicProfileFieldsValidation(Request userRequest) { - validateParam( - (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), - ResponseCode.mandatoryParamsMissing, - JsonKey.FIRST_NAME); - if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { - ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); - } - - if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) - || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) - && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { - ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); - } - - if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ - userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); - userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); - } - - if (null != userRequest.getRequest().get(JsonKey.DOB)) { - boolean bool = - ProjectUtil.isDateValidFormat( - ProjectUtil.YEAR_MONTH_DATE_FORMAT, - (String) userRequest.getRequest().get(JsonKey.DOB)); - if (!bool) { - ProjectCommonException.throwClientErrorException(ResponseCode.dateFormatError); - } - } - - if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) - && !ProjectUtil.isEmailvalid((String) userRequest.getRequest().get(JsonKey.EMAIL))) { - ProjectCommonException.throwClientErrorException(ResponseCode.emailFormatError); - } else { - emailVerifiedValidation(userRequest); - } - } - - private void emailVerifiedValidation(Request userRequest) { - if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { - if (null != userRequest.getRequest().get(JsonKey.EMAIL_VERIFIED)) { - if (userRequest.getRequest().get(JsonKey.EMAIL_VERIFIED) instanceof Boolean) { - if (!((boolean) userRequest.getRequest().get(JsonKey.EMAIL_VERIFIED))) { - ProjectCommonException.throwClientErrorException(ResponseCode.emailVerifiedError); - } - } else { - ProjectCommonException.throwClientErrorException(ResponseCode.emailVerifiedError); - } - } else { - ProjectCommonException.throwClientErrorException(ResponseCode.emailVerifiedError); - } - } - } - - /** - * Method to validate Address - * - * @param userRequest - */ - @SuppressWarnings("unchecked") - private void addressValidation(Request userRequest) { - Map addrReqMap; - if (userRequest.getRequest().containsKey(JsonKey.ADDRESS) - && null != userRequest.getRequest().get(JsonKey.ADDRESS)) { - if (!(userRequest.getRequest().get(JsonKey.ADDRESS) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ADDRESS, JsonKey.LIST), - ERROR_CODE); - } else if (userRequest.getRequest().get(JsonKey.ADDRESS) instanceof List) { - List> reqList = - (List>) userRequest.get(JsonKey.ADDRESS); - for (int i = 0; i < reqList.size(); i++) { - addrReqMap = reqList.get(i); - new AddressRequestValidator().validateAddress(addrReqMap, JsonKey.ADDRESS); - } - } - } - } - - /** - * Method to validate educational details of the user - * - * @param userRequest - */ - @SuppressWarnings("unchecked") - private void educationValidation(Request userRequest) { - Map addrReqMap; - Map reqMap; - if (userRequest.getRequest().containsKey(JsonKey.EDUCATION) - && null != userRequest.getRequest().get(JsonKey.EDUCATION)) { - if (!(userRequest.getRequest().get(JsonKey.EDUCATION) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.EDUCATION, JsonKey.LIST), - ERROR_CODE); - } else if (userRequest.getRequest().get(JsonKey.EDUCATION) instanceof List) { - List> reqList = - (List>) userRequest.get(JsonKey.EDUCATION); - for (int i = 0; i < reqList.size(); i++) { - reqMap = reqList.get(i); - if (StringUtils.isBlank((String) reqMap.get(JsonKey.NAME))) { - ProjectCommonException.throwClientErrorException(ResponseCode.educationNameError); - } - if (StringUtils.isBlank((String) reqMap.get(JsonKey.DEGREE))) { - ProjectCommonException.throwClientErrorException(ResponseCode.educationDegreeError); - } - if (reqMap.containsKey(JsonKey.ADDRESS) && null != reqMap.get(JsonKey.ADDRESS)) { - addrReqMap = (Map) reqMap.get(JsonKey.ADDRESS); - new AddressRequestValidator().validateAddress(addrReqMap, JsonKey.EDUCATION); - } - } - } - } - } - - /** - * Method to validate jobProfile of a user - * - * @param userRequest - */ - private void jobProfileValidation(Request userRequest) { - if (userRequest.getRequest().containsKey(JsonKey.JOB_PROFILE) - && null != userRequest.getRequest().get(JsonKey.JOB_PROFILE)) { - if (!(userRequest.getRequest().get(JsonKey.JOB_PROFILE) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.JOB_PROFILE, JsonKey.LIST), - ERROR_CODE); - } else if (userRequest.getRequest().get(JsonKey.JOB_PROFILE) instanceof List) { - validateJob(userRequest); - } - } - } - - private void validateJob(Request userRequest) { - - Map reqMap = null; - List> reqList = - (List>) userRequest.get(JsonKey.JOB_PROFILE); - for (int i = 0; i < reqList.size(); i++) { - reqMap = reqList.get(i); - validateJoinEndDate(reqMap); - validateJobOrgNameAndAddress(reqMap); - } - } - - private void validateJoinEndDate(Map reqMap) { - if (null != reqMap.get(JsonKey.JOINING_DATE)) { - boolean bool = - ProjectUtil.isDateValidFormat( - ProjectUtil.YEAR_MONTH_DATE_FORMAT, (String) reqMap.get(JsonKey.JOINING_DATE)); - if (!bool) { - ProjectCommonException.throwClientErrorException(ResponseCode.dateFormatError); - } - } - if (null != reqMap.get(JsonKey.END_DATE)) { - boolean bool = - ProjectUtil.isDateValidFormat( - ProjectUtil.YEAR_MONTH_DATE_FORMAT, (String) reqMap.get(JsonKey.END_DATE)); - if (!bool) { - ProjectCommonException.throwClientErrorException(ResponseCode.dateFormatError); - } - } - } - - private void validateJobOrgNameAndAddress(Map reqMap) { - Map addrReqMap = null; - if (StringUtils.isBlank((String) reqMap.get(JsonKey.JOB_NAME))) { - ProjectCommonException.throwClientErrorException(ResponseCode.jobNameError); - } - if (StringUtils.isBlank((String) reqMap.get(JsonKey.ORG_NAME))) { - ProjectCommonException.throwClientErrorException(ResponseCode.organisationNameError); - } - if (reqMap.containsKey(JsonKey.ADDRESS) && null != reqMap.get(JsonKey.ADDRESS)) { - addrReqMap = (Map) reqMap.get(JsonKey.ADDRESS); - new AddressRequestValidator().validateAddress(addrReqMap, JsonKey.JOB_PROFILE); - } - } - - @SuppressWarnings("unchecked") - public void validateWebPages(Request request) { - if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { - List> data = - (List>) request.getRequest().get(JsonKey.WEB_PAGES); - if (null == data || data.isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); - } - } - } - - private boolean validatePhoneNo(String phone, String countryCode) { - if (phone.contains("+")) { - ProjectCommonException.throwClientErrorException(ResponseCode.invalidPhoneNumber); - } - if (ProjectUtil.validatePhone(phone, countryCode)) { - return true; - } else { - ProjectCommonException.throwClientErrorException(ResponseCode.phoneNoFormatError); - } - return false; - } - - /** - * This method will validate update user data. - * - * @param userRequest Request - */ - public void validateUpdateUserRequest(Request userRequest) { - if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { - ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); - } - externalIdsValidation(userRequest, JsonKey.UPDATE); - phoneValidation(userRequest); - updateUserBasicValidation(userRequest); - validateAddressField(userRequest); - validateJobProfileField(userRequest); - validateEducationField(userRequest); - validateUserType(userRequest); - validateUserOrgField(userRequest); - - if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); - } - validateLocationCodes(userRequest); - validateExtIdTypeAndProvider(userRequest); - validateFrameworkDetails(userRequest); - validateRecoveryEmailOrPhone(userRequest); - } - - private void validateUserOrgField(Request userRequest) { - Map request = userRequest.getRequest(); - boolean isPrivate = - BooleanUtils.isTrue((Boolean) userRequest.getContext().get(JsonKey.PRIVATE)); - if (isPrivate - && StringUtils.isBlank((String) request.get(JsonKey.USER_ID)) - && request.containsKey(JsonKey.ORGANISATIONS)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), JsonKey.USER_ID)); - } - - if (!isPrivate && request.containsKey(JsonKey.ORGANISATIONS)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.errorUnsupportedField, - ProjectUtil.formatMessage( - ResponseCode.errorUnsupportedField.getErrorMessage(), JsonKey.ORGANISATIONS)); - } - - if (isPrivate - && request.containsKey(JsonKey.ORGANISATIONS) - && !(request.get(JsonKey.ORGANISATIONS) instanceof List)) { - throwInvalidUserOrgData(); - } - - if (isPrivate && request.containsKey(JsonKey.ORGANISATIONS)) { - List list = (List) request.get(JsonKey.ORGANISATIONS); - for (Object map : list) { - if (!(map instanceof Map)) { - throwInvalidUserOrgData(); - } else { - validRolesDataType((Map) map); - } - } - } - } - - private void validRolesDataType(Map map) { - String organisationId = (String) map.get(JsonKey.ORGANISATION_ID); - if (StringUtils.isBlank(organisationId)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), JsonKey.ORGANISATION_ID)); - } - if (map.containsKey(JsonKey.ROLES)) { - if (!(map.get(JsonKey.ROLES) instanceof List)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.dataTypeError, - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST)); - } else if (CollectionUtils.isEmpty((List) map.get(JsonKey.ROLES))) { - ProjectCommonException.throwClientErrorException( - ResponseCode.emptyRolesProvided, ResponseCode.emptyRolesProvided.getErrorMessage()); - } - } - } - - private void throwInvalidUserOrgData() { - ProjectCommonException.throwClientErrorException( - ResponseCode.dataTypeError, - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), - JsonKey.ORGANISATIONS, - String.join(" ", JsonKey.LIST, " of ", JsonKey.MAP))); - } - - private void validateAddressField(Request userRequest) { - if (userRequest.getRequest().get(JsonKey.ADDRESS) != null - && ((List) userRequest.getRequest().get(JsonKey.ADDRESS)).isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.addressRequired); - } - - if (userRequest.getRequest().get(JsonKey.ADDRESS) != null - && (!((List) userRequest.getRequest().get(JsonKey.ADDRESS)).isEmpty())) { - validateUpdateUserAddress(userRequest); - } - } - - private void validateJobProfileField(Request userRequest) { - if (userRequest.getRequest().get(JsonKey.JOB_PROFILE) != null - && ((List) userRequest.getRequest().get(JsonKey.JOB_PROFILE)).isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.jobDetailsRequired); - } - - if (userRequest.getRequest().get(JsonKey.JOB_PROFILE) != null - && (!((List) userRequest.getRequest().get(JsonKey.JOB_PROFILE)).isEmpty())) { - validateUpdateUserJobProfile(userRequest); - } - } - - private void validateEducationField(Request userRequest) { - if (userRequest.getRequest().get(JsonKey.EDUCATION) != null - && ((List) userRequest.getRequest().get(JsonKey.EDUCATION)).isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.educationRequired); - } - - if (userRequest.getRequest().get(JsonKey.EDUCATION) != null - && (!((List) userRequest.getRequest().get(JsonKey.EDUCATION)).isEmpty())) { - validateUpdateUserEducation(userRequest); - } - } - - public void externalIdsValidation(Request userRequest, String operation) { - if (userRequest.getRequest().containsKey(JsonKey.EXTERNAL_IDS) - && (null != userRequest.getRequest().get(JsonKey.EXTERNAL_IDS))) { - if (!(userRequest.getRequest().get(JsonKey.EXTERNAL_IDS) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.EXTERNAL_IDS, JsonKey.LIST), - ERROR_CODE); - } - List> externalIds = - (List>) userRequest.getRequest().get(JsonKey.EXTERNAL_IDS); - validateIndividualExternalId(operation, externalIds); - if (operation.equalsIgnoreCase(JsonKey.CREATE)) { - checkForDuplicateExternalId(externalIds); - } - } - } - - private void validateIndividualExternalId( - String operation, List> externalIds) { - // valid operation type for externalIds in user api. - List operationTypeList = Arrays.asList(JsonKey.ADD, JsonKey.REMOVE, JsonKey.EDIT); - externalIds - .stream() - .forEach( - identity -> { - // check for invalid operation type - if (StringUtils.isNotBlank(identity.get(JsonKey.OPERATION)) - && (!operationTypeList.contains( - (identity.get(JsonKey.OPERATION)).toLowerCase()))) { - throw new ProjectCommonException( - ResponseCode.invalidValue.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.invalidValue.getErrorMessage(), - StringFormatter.joinByDot(JsonKey.EXTERNAL_IDS, JsonKey.OPERATION), - identity.get(JsonKey.OPERATION), - String.join(StringFormatter.COMMA, operationTypeList)), - ERROR_CODE); - } - // throw exception for invalid operation if other operation type is coming in - // request - // other than add or null for create user api - if (JsonKey.CREATE.equalsIgnoreCase(operation) - && StringUtils.isNotBlank(identity.get(JsonKey.OPERATION)) - && (!JsonKey.ADD.equalsIgnoreCase(((identity.get(JsonKey.OPERATION)))))) { - throw new ProjectCommonException( - ResponseCode.invalidValue.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.invalidValue.getErrorMessage(), - StringFormatter.joinByDot(JsonKey.EXTERNAL_IDS, JsonKey.OPERATION), - identity.get(JsonKey.OPERATION), - JsonKey.ADD), - ERROR_CODE); - } - validateExternalIdMandatoryParam(JsonKey.ID, identity.get(JsonKey.ID)); - validateExternalIdMandatoryParam(JsonKey.PROVIDER, identity.get(JsonKey.PROVIDER)); - validateExternalIdMandatoryParam(JsonKey.ID_TYPE, identity.get(JsonKey.ID_TYPE)); - }); - } - - private void validateExternalIdMandatoryParam(String param, String paramValue) { - if (StringUtils.isBlank(paramValue)) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - StringFormatter.joinByDot(JsonKey.EXTERNAL_IDS, param)), - ERROR_CODE); - } - } - - private void validateUpdateUserEducation(Request userRequest) { - List> reqList = - (List>) userRequest.get(JsonKey.EDUCATION); - for (int i = 0; i < reqList.size(); i++) { - Map reqMap = reqList.get(i); - if (reqMap.containsKey(JsonKey.IS_DELETED) - && null != reqMap.get(JsonKey.IS_DELETED) - && ((boolean) reqMap.get(JsonKey.IS_DELETED)) - && StringUtils.isBlank((String) reqMap.get(JsonKey.ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.idRequired); - } - if (!reqMap.containsKey(JsonKey.IS_DELETED) - || (reqMap.containsKey(JsonKey.IS_DELETED) - && (null == reqMap.get(JsonKey.IS_DELETED) - || !(boolean) reqMap.get(JsonKey.IS_DELETED)))) { - educationValidation(userRequest); - } - } - } - - private void validateUpdateUserJobProfile(Request userRequest) { - List> reqList = - (List>) userRequest.get(JsonKey.JOB_PROFILE); - for (int i = 0; i < reqList.size(); i++) { - Map reqMap = reqList.get(i); - if (reqMap.containsKey(JsonKey.IS_DELETED) - && null != reqMap.get(JsonKey.IS_DELETED) - && ((boolean) reqMap.get(JsonKey.IS_DELETED)) - && StringUtils.isBlank((String) reqMap.get(JsonKey.ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.idRequired); - } - if (!reqMap.containsKey(JsonKey.IS_DELETED) - || (reqMap.containsKey(JsonKey.IS_DELETED) - && (null == reqMap.get(JsonKey.IS_DELETED) - || !(boolean) reqMap.get(JsonKey.IS_DELETED)))) { - jobProfileValidation(userRequest); - } - } - } - - private void validateUpdateUserAddress(Request userRequest) { - List> reqList = - (List>) userRequest.get(JsonKey.ADDRESS); - for (int i = 0; i < reqList.size(); i++) { - Map reqMap = reqList.get(i); - - if (reqMap.containsKey(JsonKey.IS_DELETED) - && null != reqMap.get(JsonKey.IS_DELETED) - && ((boolean) reqMap.get(JsonKey.IS_DELETED)) - && StringUtils.isBlank((String) reqMap.get(JsonKey.ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.idRequired); - } - if (!reqMap.containsKey(JsonKey.IS_DELETED) - || (reqMap.containsKey(JsonKey.IS_DELETED) - && (null == reqMap.get(JsonKey.IS_DELETED) - || !(boolean) reqMap.get(JsonKey.IS_DELETED)))) { - new AddressRequestValidator().validateAddress(reqMap, JsonKey.ADDRESS); - } - } - } - - @SuppressWarnings("rawtypes") - private void updateUserBasicValidation(Request userRequest) { - fieldsNotAllowed( - Arrays.asList( - JsonKey.REGISTERED_ORG_ID, - JsonKey.ROOT_ORG_ID, - JsonKey.CHANNEL, - JsonKey.USERNAME, - JsonKey.PROVIDER, - JsonKey.ID_TYPE), - userRequest); - validateUserIdOrExternalId(userRequest); - if (userRequest.getRequest().containsKey(JsonKey.FIRST_NAME) - && (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.FIRST_NAME)))) { - ProjectCommonException.throwClientErrorException(ResponseCode.firstNameRequired); - } - - if ((userRequest.getRequest().containsKey(JsonKey.EMAIL) - && userRequest.getRequest().get(JsonKey.EMAIL) != null) - && !ProjectUtil.isEmailvalid((String) userRequest.getRequest().get(JsonKey.EMAIL))) { - ProjectCommonException.throwClientErrorException(ResponseCode.emailFormatError); - } - - if (userRequest.getRequest().containsKey(JsonKey.ROLES) - && null != userRequest.getRequest().get(JsonKey.ROLES)) { - if (userRequest.getRequest().get(JsonKey.ROLES) instanceof List - && ((List) userRequest.getRequest().get(JsonKey.ROLES)).isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.rolesRequired); - } else if (!(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), - ERROR_CODE); - } - } - validateLangaugeFields(userRequest); - } - - private void validateUserIdOrExternalId(Request userRequest) { - if ((StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.USER_ID)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ID))) - && (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID)) - || StringUtils.isBlank( - (String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_PROVIDER)) - || StringUtils.isBlank( - (String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_TYPE)))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - (StringFormatter.joinByOr( - JsonKey.USER_ID, - StringFormatter.joinByAnd( - StringFormatter.joinByComma(JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_TYPE), - JsonKey.EXTERNAL_ID_PROVIDER)))), - ERROR_CODE); - } - } - - private void validateLangaugeFields(Request userRequest) { - if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) - && null != userRequest.getRequest().get(JsonKey.LANGUAGE)) { - if (userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List - && ((List) userRequest.getRequest().get(JsonKey.LANGUAGE)).isEmpty()) { - ProjectCommonException.throwClientErrorException(ResponseCode.languageRequired); - } else if (!(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), - ERROR_CODE); - } - } - } - - /** - * This method will validate change password requested data. - * - * @param userRequest Request - */ - public void validateChangePassword(Request userRequest) { - if (userRequest.getRequest().get(JsonKey.PASSWORD) == null - || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { - ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); - } - if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { - ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); - } - if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { - ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); - } - } - - /** - * This method will validate verifyUser requested data. - * - * @param userRequest Request - */ - public void validateVerifyUser(Request userRequest) { - if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); - } - } - - /** - * Either user will send UserId or (provider and externalId). - * - * @param request - */ - public void validateAssignRole(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { - ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); - } - - if (request.getRequest().get(JsonKey.ROLES) == null - || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), - ERROR_CODE); - } - - String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); - String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); - String provider = (String) request.getRequest().get(JsonKey.PROVIDER); - if (StringUtils.isBlank(organisationId) - && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - (StringFormatter.joinByOr( - JsonKey.ORGANISATION_ID, - StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), - ERROR_CODE); - } - } - - /** @param request */ - public void validateForgotPassword(Request request) { - if (request.getRequest().get(JsonKey.USERNAME) == null - || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { - throw new ProjectCommonException( - ResponseCode.userNameRequired.getErrorCode(), - ResponseCode.userNameRequired.getErrorMessage(), - ERROR_CODE); - } - } - - /** - * This method will validate bulk api user data. - * - * @param userRequest Request - */ - public void validateBulkUserData(Request userRequest) { - externalIdsValidation(userRequest, JsonKey.BULK_USER_UPLOAD); - createUserBasicValidation(userRequest); - phoneValidation(userRequest); - validateWebPages(userRequest); - validateExtIdTypeAndProvider(userRequest); - if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.USERNAME)) - && (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_PROVIDER)) - || StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID)) - || StringUtils.isBlank( - (String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_TYPE)))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - (StringFormatter.joinByOr( - JsonKey.USERNAME, - StringFormatter.joinByAnd( - StringFormatter.joinByComma(JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_TYPE), - JsonKey.EXTERNAL_ID_PROVIDER)))), - ERROR_CODE); - } - } - - private void validateExtIdTypeAndProvider(Request userRequest) { - if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_PROVIDER)) - && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID)) - && StringUtils.isNotBlank( - (String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_TYPE)))) { - return; - } else if (StringUtils.isBlank( - (String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_PROVIDER)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID)) - && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EXTERNAL_ID_TYPE))) { - return; - } else { - throw new ProjectCommonException( - ResponseCode.dependentParamsMissing.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.dependentParamsMissing.getErrorMessage(), - StringFormatter.joinByComma( - JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_TYPE, JsonKey.EXTERNAL_ID_PROVIDER)), - ERROR_CODE); - } - } - - private void checkForDuplicateExternalId(List> list) { - List> checkedList = new ArrayList<>(); - for (Map externalId : list) { - for (Map checkedExternalId : checkedList) { - String provider = checkedExternalId.get(JsonKey.PROVIDER); - String idType = checkedExternalId.get(JsonKey.ID_TYPE); - if (provider.equalsIgnoreCase(externalId.get(JsonKey.PROVIDER)) - && idType.equalsIgnoreCase(externalId.get(JsonKey.ID_TYPE))) { - String exceptionMsg = - MessageFormat.format( - ResponseCode.duplicateExternalIds.getErrorMessage(), idType, provider); - ProjectCommonException.throwClientErrorException( - ResponseCode.duplicateExternalIds, exceptionMsg); - } - } - checkedList.add(externalId); - } - } - - @SuppressWarnings("unchecked") - private void validateFrameworkDetails(Request request) { - if (request.getRequest().containsKey(JsonKey.FRAMEWORK) - && (!(request.getRequest().get(JsonKey.FRAMEWORK) instanceof Map))) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE, - JsonKey.FRAMEWORK, - JsonKey.MAP); - } else { - Map framework = - (Map) request.getRequest().get(JsonKey.FRAMEWORK); - if (!MapUtils.isEmpty(framework)) { - if (framework.get(JsonKey.ID) instanceof List) { - List frameworkId = (List) framework.get(JsonKey.ID); - if (CollectionUtils.isEmpty(frameworkId)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - MessageFormat.format( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - StringFormatter.joinByDot(JsonKey.FRAMEWORK, JsonKey.ID))); - } else if (frameworkId.size() > 1) { - throw new ProjectCommonException( - ResponseCode.errorInvalidParameterSize.getErrorCode(), - ResponseCode.errorInvalidParameterSize.getErrorMessage(), - ERROR_CODE, - StringFormatter.joinByDot(JsonKey.FRAMEWORK, JsonKey.ID), - "1", - String.valueOf(frameworkId.size())); - } - } else if (framework.get(JsonKey.ID) instanceof String) { - String frameworkId = (String) framework.get(JsonKey.ID); - if (StringUtils.isBlank(frameworkId)) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - MessageFormat.format( - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - StringFormatter.joinByDot(JsonKey.FRAMEWORK, JsonKey.ID))); - } - } - } - } - } - - @SuppressWarnings("unchecked") - public void validateMandatoryFrameworkFields( - Map userMap, - List frameworkFields, - List frameworkMandatoryFields) { - if (userMap.containsKey(JsonKey.FRAMEWORK)) { - Map frameworkRequest = (Map) userMap.get(JsonKey.FRAMEWORK); - for (String field : frameworkFields) { - if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) - && frameworkMandatoryFields.contains(field)) { - if (!frameworkRequest.containsKey(field)) { - validateParam(null, ResponseCode.mandatoryParamsMissing, field); - } - validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); - List fieldValue = (List) frameworkRequest.get(field); - if (fieldValue.isEmpty()) { - throw new ProjectCommonException( - ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), - ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), - ERROR_CODE, - StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); - } - } else { - if (frameworkRequest.containsKey(field) - && frameworkRequest.get(field) != null - && !(frameworkRequest.get(field) instanceof List)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - ResponseCode.dataTypeError.getErrorMessage(), - ERROR_CODE, - field, - JsonKey.LIST); - } - } - } - List frameworkRequestFieldList = - frameworkRequest.keySet().stream().collect(Collectors.toList()); - for (String frameworkRequestField : frameworkRequestFieldList) { - if (!frameworkFields.contains(frameworkRequestField)) { - throw new ProjectCommonException( - ResponseCode.errorUnsupportedField.getErrorCode(), - ResponseCode.errorUnsupportedField.getErrorMessage(), - ERROR_CODE, - StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); - } - } - } - } - - @SuppressWarnings("unchecked") - public void validateFrameworkCategoryValues( - Map userMap, Map>> frameworkMap) { - Map> fwRequest = - (Map>) userMap.get(JsonKey.FRAMEWORK); - for (Map.Entry> fwRequestFieldEntry : fwRequest.entrySet()) { - if (!fwRequestFieldEntry.getValue().isEmpty()) { - List allowedFieldValues = - getKeyValueFromFrameWork(fwRequestFieldEntry.getKey(), frameworkMap) - .stream() - .map(fieldMap -> fieldMap.get(JsonKey.NAME)) - .collect(Collectors.toList()); - - List fwRequestFieldList = fwRequestFieldEntry.getValue(); - - for (String fwRequestField : fwRequestFieldList) { - if (!allowedFieldValues.contains(fwRequestField)) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - ResponseCode.invalidParameterValue.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - fwRequestField, - StringFormatter.joinByDot(JsonKey.FRAMEWORK, fwRequestFieldEntry.getKey())); - } - } - } - } - } - - private List> getKeyValueFromFrameWork( - String key, Map>> frameworkMap) { - if (frameworkMap.get(key) == null) { - throw new ProjectCommonException( - ResponseCode.errorUnsupportedField.getErrorCode(), - MessageFormat.format( - ResponseCode.errorUnsupportedField.getErrorMessage(), - key + " in " + JsonKey.FRAMEWORK), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - return frameworkMap.get(key); - } - - private void validateUserType(Request userRequest) { - String userType = (String) userRequest.getRequest().get(JsonKey.USER_TYPE); - - if (userType != null - && (!JsonKey.OTHER.equalsIgnoreCase(userType)) - && (!JsonKey.TEACHER.equalsIgnoreCase(userType))) { - ProjectCommonException.throwClientErrorException( - ResponseCode.invalidParameterValue, - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), - new String[] {userType, JsonKey.USER_TYPE})); - } - } - - public void validateUserMergeRequest( - Request request, String authUserToken, String sourceUserToken) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.FROM_ACCOUNT_ID))) { - throw new ProjectCommonException( - ResponseCode.fromAccountIdRequired.getErrorCode(), - ResponseCode.fromAccountIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.TO_ACCOUNT_ID))) { - throw new ProjectCommonException( - ResponseCode.toAccountIdRequired.getErrorCode(), - ResponseCode.toAccountIdRequired.getErrorMessage(), - ERROR_CODE); - } - - if (StringUtils.isBlank(authUserToken)) { - createClientError( - ResponseCode.mandatoryHeaderParamsMissing, JsonKey.X_AUTHENTICATED_USER_TOKEN); - } - - if (StringUtils.isBlank(authUserToken)) { - createClientError( - ResponseCode.mandatoryHeaderParamsMissing, JsonKey.X_AUTHENTICATED_USER_TOKEN); - } - if (StringUtils.isBlank(sourceUserToken)) { - createClientError(ResponseCode.mandatoryHeaderParamsMissing, JsonKey.X_SOURCE_USER_TOKEN); - } - } - - public void validateCertValidationRequest(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.CERT_ID))) { - createClientError(ResponseCode.mandatoryParamsMissing, JsonKey.CERT_ID); - } - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.ACCESS_CODE))) { - createClientError(ResponseCode.mandatoryParamsMissing, JsonKey.ACCESS_CODE); - } - } - - private void createClientError(ResponseCode responseCode, String field) { - throw new ProjectCommonException( - responseCode.getErrorCode(), - ProjectUtil.formatMessage(responseCode.getErrorMessage(), field), - ERROR_CODE); - } - - private void validateRecoveryEmailOrPhone(Request userRequest) { - if (StringUtils.isNotBlank((String) userRequest.get(JsonKey.RECOVERY_EMAIL))) { - validateEmail((String) userRequest.get(JsonKey.RECOVERY_EMAIL)); - } - if (StringUtils.isNotBlank((String) userRequest.get(JsonKey.RECOVERY_PHONE))) { - validatePhone((String) userRequest.get(JsonKey.RECOVERY_PHONE)); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserTenantMigrationRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserTenantMigrationRequestValidator.java deleted file mode 100644 index cc1539747..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/UserTenantMigrationRequestValidator.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sunbird.common.request; - -import java.util.Map; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * Request validator class for user tenant migration request. - * @author Amit Kumar - * - */ -public class UserTenantMigrationRequestValidator extends UserRequestValidator { - - /** - * This method will validate the user migration request. - * @param request user migration request body - */ - public void validateUserTenantMigrateRequest(Request request) { - Map req = request.getRequest(); - validateParam( - (String) req.get(JsonKey.CHANNEL), ResponseCode.mandatoryParamsMissing, JsonKey.CHANNEL); - validateParam( - (String) req.get(JsonKey.USER_ID), ResponseCode.mandatoryParamsMissing, JsonKey.USER_ID); - externalIdsValidation(request, JsonKey.CREATE); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/certificatevalidator/CertAddRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/certificatevalidator/CertAddRequestValidator.java deleted file mode 100644 index 7fccb6cb0..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/certificatevalidator/CertAddRequestValidator.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.sunbird.common.request.certificatevalidator; - -import com.google.common.collect.Lists; -import java.text.MessageFormat; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.BaseRequestValidator; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - - -/** - * this class is responsible to validate the certificate add request - * - * @author anmolgupta - */ -public class CertAddRequestValidator extends BaseRequestValidator { - public static final String PDF_URL = "pdfUrl"; - - private Request request; - static List mandatoryParamsList = - Lists.newArrayList(JsonKey.ID, JsonKey.ACCESS_CODE, JsonKey.PDF_URL, JsonKey.USER_ID); - - private CertAddRequestValidator(Request request) { - this.request = request; - } - - /** - * this method we should use to get the instance of the validator class - * - * @param request - * @return - */ - public static CertAddRequestValidator getInstance(Request request) { - return new CertAddRequestValidator(request); - } - - /** this method should be call to validate the request */ - public void validate() { - checkMandatoryFieldsPresent(request.getRequest(), mandatoryParamsList); - validateMandatoryJsonData(); - } - - private void validateMandatoryJsonData() { - validatePresence(); - validateDataType(); - } - - private void validateDataType() { - if (!(request.get(JsonKey.JSON_DATA) instanceof Map)) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.JSON_DATA, "MAP"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - private void validatePresence() { - if (null == request.get(JsonKey.JSON_DATA)) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - JsonKey.JSON_DATA); - } - } - - public void validateDownlaodFileData() { - if (StringUtils.isBlank((String) request.getRequest().get(PDF_URL))) { - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(), - PDF_URL); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/BaseOrgRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/BaseOrgRequestValidator.java deleted file mode 100644 index 376622fb8..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/BaseOrgRequestValidator.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.sunbird.common.request.orgvalidator; - -import java.text.MessageFormat; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.BaseRequestValidator; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class BaseOrgRequestValidator extends BaseRequestValidator { - - public static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - public void validateOrgReference(Request request) { - validateParam( - (String) request.getRequest().get(JsonKey.ORGANISATION_ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.ORGANISATION_ID); - } - - public void validateRootOrgChannel(Request request) { - if ((null != request.getRequest().get(JsonKey.IS_ROOT_ORG) - && (Boolean) request.getRequest().get(JsonKey.IS_ROOT_ORG)) - && StringUtils.isEmpty((String) request.getRequest().get(JsonKey.CHANNEL))) { - throw new ProjectCommonException( - ResponseCode.dependentParameterMissing.getErrorCode(), - MessageFormat.format( - ResponseCode.dependentParameterMissing.getErrorMessage(), - JsonKey.CHANNEL, - JsonKey.IS_ROOT_ORG), - ERROR_CODE); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/KeyManagementValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/KeyManagementValidator.java deleted file mode 100644 index 3d2ff61fc..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/KeyManagementValidator.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.sunbird.common.request.orgvalidator; - -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.BaseRequestValidator; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -import java.text.MessageFormat; -import java.util.List; - -/** - * this class is used to validate the request of the OrgAssignKeys Controller - * @author anmolgupta - */ -public class KeyManagementValidator extends BaseRequestValidator { - - - private Request request; - - private KeyManagementValidator(Request request) { - this.request = request; - } - - - /** - * this method should be used to get the instance of the class - * @param request - * @return - */ - public static KeyManagementValidator getInstance(Request request){ - return new KeyManagementValidator(request); - } - - - /** - * this method should be used to validate the OrgAssignKeysController request. - */ - public void validate(){ - id(); - signKeys(); - encKeys(); - - } - - private void id(){ - validateParam( - (String) request.getRequest().get(JsonKey.ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.ID); - } - - private void signKeys(){ - validateKeyPresence(JsonKey.SIGN_KEYS); - validateListTypeObject(JsonKey.SIGN_KEYS); - validateSize(JsonKey.SIGN_KEYS); - } - - private void encKeys(){ - validateKeyPresence(JsonKey.ENC_KEYS); - validateListTypeObject(JsonKey.ENC_KEYS); - validateSize(JsonKey.ENC_KEYS); - } - - private void validateListTypeObject(String key){ - if(!(request.get(key) instanceof List)){ - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), key, "List"), - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - private void validateKeyPresence(String key){ - if(!request.getRequest().containsKey(key)){ - throw new ProjectCommonException( - ResponseCode.mandatoryParamsMissing.getErrorCode(), - ResponseCode.mandatoryParamsMissing.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(),key); - } - } - - private void validateSize(String key){ - if(((List)request.get(key)).size()==0){ - throw new ProjectCommonException( - ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), - ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode(),key); - } - - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgMemberRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgMemberRequestValidator.java deleted file mode 100644 index 21e9b9356..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgMemberRequestValidator.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.sunbird.common.request.orgvalidator; - -import java.text.MessageFormat; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class OrgMemberRequestValidator extends BaseOrgRequestValidator { - - public void validateAddMemberRequest(Request request) { - validateCommonParams(request); - if (request.getRequest().containsKey(JsonKey.ROLES) - && (!(request.getRequest().get(JsonKey.ROLES) instanceof List))) { - throw new ProjectCommonException( - ResponseCode.dataTypeError.getErrorCode(), - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), - ERROR_CODE); - } - } - - private void validateCommonParams(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { - ProjectLogger.log( - "OrgMemberRequestValidator : validateCommonParams : UserId is missing. Validating userExternalId"); - validateCommonUserParams(request); - } - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.ORGANISATION_ID))) { - ProjectLogger.log( - "OrgMemberRequestValidator : validateCommonParams : OrganizationId is missing. Validating ExternalId"); - validateCommonOrgParams(request); - } - } - - private void validateCommonOrgParams(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.EXTERNAL_ID))) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - " Please provide organizationId or ExternalId,Provider "); - } - validateParam( - (String) request.getRequest().get(JsonKey.PROVIDER), - ResponseCode.mandatoryParamsMissing, - JsonKey.PROVIDER); - } - - private void validateCommonUserParams(Request request) { - if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_EXTERNAL_ID))) { - ProjectCommonException.throwClientErrorException( - ResponseCode.mandatoryParamsMissing, - " Please provide userId or userExternalId,userProvider,userIdType "); - } - validateParam( - (String) request.getRequest().get(JsonKey.USER_PROVIDER), - ResponseCode.mandatoryParamsMissing, - JsonKey.USER_PROVIDER); - validateParam( - (String) request.getRequest().get(JsonKey.USER_ID_TYPE), - ResponseCode.mandatoryParamsMissing, - JsonKey.USER_ID_TYPE); - } - - public void validateCommon(Request request) { - validateOrgReference(request); - validateParam( - (String) request.getRequest().get(JsonKey.USER_ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.USER_ID); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgRequestValidator.java deleted file mode 100644 index 06456dd02..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgRequestValidator.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.sunbird.common.request.orgvalidator; - -import java.text.MessageFormat; -import java.util.Map; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.request.AddressRequestValidator; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class OrgRequestValidator extends BaseOrgRequestValidator { - - private static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); - - public void validateCreateOrgRequest(Request orgRequest) { - - validateParam( - (String) orgRequest.getRequest().get(JsonKey.ORG_NAME), - ResponseCode.mandatoryParamsMissing, - JsonKey.ORG_NAME); - validateRootOrgChannel(orgRequest); - validateLicense(orgRequest); - - Map address = - (Map) orgRequest.getRequest().get(JsonKey.ADDRESS); - if (MapUtils.isNotEmpty(address)) { - new AddressRequestValidator().validateAddress(address, JsonKey.ORGANISATION); - } - validateLocationIdOrCode(orgRequest); - } - - private void validateLicense(Request orgRequest) { - if (orgRequest.getRequest().containsKey(JsonKey.IS_ROOT_ORG) - && (boolean) orgRequest.getRequest().get(JsonKey.IS_ROOT_ORG) - && orgRequest.getRequest().containsKey(JsonKey.LICENSE) - && StringUtils.isBlank((String) orgRequest.getRequest().get(JsonKey.LICENSE))) { - throw new ProjectCommonException( - ResponseCode.invalidParameterValue.getErrorCode(), - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), - (String) orgRequest.getRequest().get(JsonKey.LICENSE), - JsonKey.LICENSE), - ERROR_CODE); - } - } - - public void validateUpdateOrgRequest(Request request) { - validateOrgReference(request); - if (request.getRequest().containsKey(JsonKey.ROOT_ORG_ID) - && StringUtils.isEmpty((String) request.getRequest().get(JsonKey.ROOT_ORG_ID))) { - throw new ProjectCommonException( - ResponseCode.invalidRootOrganisationId.getErrorCode(), - ResponseCode.invalidRootOrganisationId.getErrorMessage(), - ERROR_CODE); - } - if (request.getRequest().get(JsonKey.STATUS) != null) { - throw new ProjectCommonException( - ResponseCode.invalidRequestParameter.getErrorCode(), - ProjectUtil.formatMessage( - ResponseCode.invalidRequestParameter.getErrorMessage(), JsonKey.STATUS), - ERROR_CODE); - } - - validateRootOrgChannel(request); - validateLocationIdOrCode(request); - Map address = (Map) request.getRequest().get(JsonKey.ADDRESS); - if (MapUtils.isNotEmpty(address)) { - new AddressRequestValidator().validateAddress(address, JsonKey.ORGANISATION); - } - } - - public void validateUpdateOrgStatusRequest(Request request) { - validateOrgReference(request); - - if (!request.getRequest().containsKey(JsonKey.STATUS)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ERROR_CODE); - } - - if (!(request.getRequest().get(JsonKey.STATUS) instanceof Integer)) { - throw new ProjectCommonException( - ResponseCode.invalidRequestData.getErrorCode(), - ResponseCode.invalidRequestData.getErrorMessage(), - ERROR_CODE); - } - } - - private void validateLocationIdOrCode(Request orgRequest) { - validateListParam(orgRequest.getRequest(), JsonKey.LOCATION_IDS, JsonKey.LOCATION_CODE); - if (orgRequest.getRequest().get(JsonKey.LOCATION_IDS) != null - && orgRequest.getRequest().get(JsonKey.LOCATION_CODE) != null) { - ProjectCommonException.throwClientErrorException( - ResponseCode.errorAttributeConflict, - MessageFormat.format( - ResponseCode.errorAttributeConflict.getErrorMessage(), - JsonKey.LOCATION_CODE, - JsonKey.LOCATION_IDS)); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgTypeRequestValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgTypeRequestValidator.java deleted file mode 100644 index ad16b3884..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/OrgTypeRequestValidator.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.sunbird.common.request.orgvalidator; - -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; - -public class OrgTypeRequestValidator extends BaseOrgRequestValidator { - - public void validateUpdateOrgTypeRequest(Request request) { - validateCreateOrgTypeRequest(request); - validateParam( - (String) request.getRequest().get(JsonKey.ID), - ResponseCode.mandatoryParamsMissing, - JsonKey.ID); - } - - public void validateCreateOrgTypeRequest(Request request) { - validateParam( - (String) request.getRequest().get(JsonKey.NAME), - ResponseCode.mandatoryParamsMissing, - JsonKey.NAME); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/package-info.java deleted file mode 100644 index af17271ba..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.request; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseCode.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseCode.java deleted file mode 100644 index 640840efc..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseCode.java +++ /dev/null @@ -1,995 +0,0 @@ -package org.sunbird.common.responsecode; - -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; - -/** @author Manzarul */ -public enum ResponseCode { - unAuthorized(ResponseMessage.Key.UNAUTHORIZED_USER, ResponseMessage.Message.UNAUTHORIZED_USER), - invalidUserCredentials( - ResponseMessage.Key.INVALID_USER_CREDENTIALS, - ResponseMessage.Message.INVALID_USER_CREDENTIALS), - operationTimeout( - ResponseMessage.Key.OPERATION_TIMEOUT, ResponseMessage.Message.OPERATION_TIMEOUT), - invalidOperationName( - ResponseMessage.Key.INVALID_OPERATION_NAME, ResponseMessage.Message.INVALID_OPERATION_NAME), - invalidRequestData( - ResponseMessage.Key.INVALID_REQUESTED_DATA, ResponseMessage.Message.INVALID_REQUESTED_DATA), - invalidCustomerId( - ResponseMessage.Key.CONSUMER_ID_MISSING_ERROR, - ResponseMessage.Message.CONSUMER_ID_MISSING_ERROR), - customerIdRequired( - ResponseMessage.Key.CONSUMER_ID_INVALID_ERROR, - ResponseMessage.Message.CONSUMER_ID_INVALID_ERROR), - deviceIdRequired( - ResponseMessage.Key.DEVICE_ID_MISSING_ERROR, ResponseMessage.Message.DEVICE_ID_MISSING_ERROR), - invalidContentId( - ResponseMessage.Key.CONTENT_ID_INVALID_ERROR, - ResponseMessage.Message.CONTENT_ID_INVALID_ERROR), - courseIdRequired( - ResponseMessage.Key.COURSE_ID_MISSING_ERROR, ResponseMessage.Message.COURSE_ID_MISSING_ERROR), - contentIdRequired( - ResponseMessage.Key.CONTENT_ID_MISSING_ERROR, - ResponseMessage.Message.CONTENT_ID_MISSING_ERROR), - errorInvalidConfigParamValue( - ResponseMessage.Key.ERROR_INVALID_CONFIG_PARAM_VALUE, - ResponseMessage.Message.ERROR_INVALID_CONFIG_PARAM_VALUE), - errorMaxSizeExceeded( - ResponseMessage.Key.ERROR_MAX_SIZE_EXCEEDED, ResponseMessage.Message.ERROR_MAX_SIZE_EXCEEDED), - apiKeyRequired( - ResponseMessage.Key.API_KEY_MISSING_ERROR, ResponseMessage.Message.API_KEY_MISSING_ERROR), - invalidApiKey( - ResponseMessage.Key.API_KEY_INVALID_ERROR, ResponseMessage.Message.API_KEY_INVALID_ERROR), - internalError(ResponseMessage.Key.INTERNAL_ERROR, ResponseMessage.Message.INTERNAL_ERROR), - dbInsertionError( - ResponseMessage.Key.DB_INSERTION_FAIL, ResponseMessage.Message.DB_INSERTION_FAIL), - dbUpdateError(ResponseMessage.Key.DB_UPDATE_FAIL, ResponseMessage.Message.DB_UPDATE_FAIL), - courseNameRequired( - ResponseMessage.Key.COURSE_NAME_MISSING, ResponseMessage.Message.COURSE_NAME_MISSING), - success(ResponseMessage.Key.SUCCESS_MESSAGE, ResponseMessage.Message.SUCCESS_MESSAGE), - sessionIdRequiredError( - ResponseMessage.Key.SESSION_ID_MISSING, ResponseMessage.Message.SESSION_ID_MISSING), - courseIdRequiredError( - ResponseMessage.Key.COURSE_ID_MISSING, ResponseMessage.Message.COURSE_ID_MISSING), - contentIdRequiredError( - ResponseMessage.Key.CONTENT_ID_MISSING, ResponseMessage.Message.CONTENT_ID_MISSING), - versionRequiredError( - ResponseMessage.Key.VERSION_MISSING, ResponseMessage.Message.VERSION_MISSING), - courseVersionRequiredError( - ResponseMessage.Key.COURSE_VERSION_MISSING, ResponseMessage.Message.COURSE_VERSION_MISSING), - contentVersionRequiredError( - ResponseMessage.Key.CONTENT_VERSION_MISSING, ResponseMessage.Message.CONTENT_VERSION_MISSING), - courseDescriptionError( - ResponseMessage.Key.COURSE_DESCRIPTION_MISSING, - ResponseMessage.Message.COURSE_DESCRIPTION_MISSING), - courseTocUrlError( - ResponseMessage.Key.COURSE_TOCURL_MISSING, ResponseMessage.Message.COURSE_TOCURL_MISSING), - emailRequired(ResponseMessage.Key.EMAIL_MISSING, ResponseMessage.Message.EMAIL_MISSING), - emailFormatError(ResponseMessage.Key.EMAIL_FORMAT, ResponseMessage.Message.EMAIL_FORMAT), - urlFormatError(ResponseMessage.Key.URL_FORMAT_ERROR, ResponseMessage.Message.URL_FORMAT_ERROR), - firstNameRequired( - ResponseMessage.Key.FIRST_NAME_MISSING, ResponseMessage.Message.FIRST_NAME_MISSING), - languageRequired(ResponseMessage.Key.LANGUAGE_MISSING, ResponseMessage.Message.LANGUAGE_MISSING), - passwordRequired(ResponseMessage.Key.PASSWORD_MISSING, ResponseMessage.Message.PASSWORD_MISSING), - passwordMinLengthError( - ResponseMessage.Key.PASSWORD_MIN_LENGHT, ResponseMessage.Message.PASSWORD_MIN_LENGHT), - passwordMaxLengthError( - ResponseMessage.Key.PASSWORD_MAX_LENGHT, ResponseMessage.Message.PASSWORD_MAX_LENGHT), - organisationIdRequiredError( - ResponseMessage.Key.ORGANISATION_ID_MISSING, ResponseMessage.Message.ORGANISATION_ID_MISSING), - sourceAndExternalIdValidationError( - ResponseMessage.Key.REQUIRED_DATA_ORG_MISSING, - ResponseMessage.Message.REQUIRED_DATA_ORG_MISSING), - organisationNameRequired( - ResponseMessage.Key.ORGANISATION_NAME_MISSING, - ResponseMessage.Message.ORGANISATION_NAME_MISSING), - channelUniquenessInvalid( - ResponseMessage.Key.CHANNEL_SHOULD_BE_UNIQUE, - ResponseMessage.Message.CHANNEL_SHOULD_BE_UNIQUE), - errorDuplicateEntry( - ResponseMessage.Key.ERROR_DUPLICATE_ENTRY, ResponseMessage.Message.ERROR_DUPLICATE_ENTRY), - unableToConnect( - ResponseMessage.Key.UNABLE_TO_CONNECT_TO_EKSTEP, - ResponseMessage.Message.UNABLE_TO_CONNECT_TO_EKSTEP), - unableToConnectToES( - ResponseMessage.Key.UNABLE_TO_CONNECT_TO_ES, ResponseMessage.Message.UNABLE_TO_CONNECT_TO_ES), - unableToParseData( - ResponseMessage.Key.UNABLE_TO_PARSE_DATA, ResponseMessage.Message.UNABLE_TO_PARSE_DATA), - invalidJsonData(ResponseMessage.Key.INVALID_JSON, ResponseMessage.Message.INVALID_JSON), - invalidOrgData(ResponseMessage.Key.INVALID_ORG_DATA, ResponseMessage.Message.INVALID_ORG_DATA), - invalidRootOrganisationId( - ResponseMessage.Key.INVALID_ROOT_ORGANIZATION, - ResponseMessage.Message.INVALID_ROOT_ORGANIZATION), - invalidParentId( - ResponseMessage.Key.INVALID_PARENT_ORGANIZATION_ID, - ResponseMessage.Message.INVALID_PARENT_ORGANIZATION_ID), - cyclicValidationError( - ResponseMessage.Key.CYCLIC_VALIDATION_FAILURE, - ResponseMessage.Message.CYCLIC_VALIDATION_FAILURE), - invalidUsrData(ResponseMessage.Key.INVALID_USR_DATA, ResponseMessage.Message.INVALID_USR_DATA), - usrValidationError( - ResponseMessage.Key.USR_DATA_VALIDATION_ERROR, - ResponseMessage.Message.USR_DATA_VALIDATION_ERROR), - errorInvalidOTP(ResponseMessage.Key.ERROR_INVALID_OTP, ResponseMessage.Message.ERROR_INVALID_OTP), - enrollmentStartDateRequiredError( - ResponseMessage.Key.ENROLLMENT_START_DATE_MISSING, - ResponseMessage.Message.ENROLLMENT_START_DATE_MISSING), - courseDurationRequiredError( - ResponseMessage.Key.COURSE_DURATION_MISSING, ResponseMessage.Message.COURSE_DURATION_MISSING), - loginTypeRequired( - ResponseMessage.Key.LOGIN_TYPE_MISSING, ResponseMessage.Message.LOGIN_TYPE_MISSING), - emailAlreadyExistError(ResponseMessage.Key.EMAIL_IN_USE, ResponseMessage.Message.EMAIL_IN_USE), - invalidCredentials( - ResponseMessage.Key.INVALID_CREDENTIAL, ResponseMessage.Message.INVALID_CREDENTIAL), - userNameRequired(ResponseMessage.Key.USERNAME_MISSING, ResponseMessage.Message.USERNAME_MISSING), - userNameAlreadyExistError( - ResponseMessage.Key.USERNAME_IN_USE, ResponseMessage.Message.USERNAME_IN_USE), - userIdRequired(ResponseMessage.Key.USERID_MISSING, ResponseMessage.Message.USERID_MISSING), - roleRequired(ResponseMessage.Key.ROLE_MISSING, ResponseMessage.Message.ROLE_MISSING), - msgIdRequiredError( - ResponseMessage.Key.MESSAGE_ID_MISSING, ResponseMessage.Message.MESSAGE_ID_MISSING), - userNameCanntBeUpdated( - ResponseMessage.Key.USERNAME_CANNOT_BE_UPDATED, - ResponseMessage.Message.USERNAME_CANNOT_BE_UPDATED), - authTokenRequired( - ResponseMessage.Key.AUTH_TOKEN_MISSING, ResponseMessage.Message.AUTH_TOKEN_MISSING), - invalidAuthToken( - ResponseMessage.Key.INVALID_AUTH_TOKEN, ResponseMessage.Message.INVALID_AUTH_TOKEN), - timeStampRequired( - ResponseMessage.Key.TIMESTAMP_REQUIRED, ResponseMessage.Message.TIMESTAMP_REQUIRED), - publishedCourseCanNotBeUpdated( - ResponseMessage.Key.PUBLISHED_COURSE_CAN_NOT_UPDATED, - ResponseMessage.Message.PUBLISHED_COURSE_CAN_NOT_UPDATED), - sourceRequired(ResponseMessage.Key.SOURCE_MISSING, ResponseMessage.Message.SOURCE_MISSING), - sectionNameRequired( - ResponseMessage.Key.SECTION_NAME_MISSING, ResponseMessage.Message.SECTION_NAME_MISSING), - sectionDataTypeRequired( - ResponseMessage.Key.SECTION_DATA_TYPE_MISSING, - ResponseMessage.Message.SECTION_DATA_TYPE_MISSING), - sectionIdRequired( - ResponseMessage.Key.SECTION_ID_REQUIRED, ResponseMessage.Message.SECTION_ID_REQUIRED), - pageNameRequired( - ResponseMessage.Key.PAGE_NAME_REQUIRED, ResponseMessage.Message.PAGE_NAME_REQUIRED), - pageIdRequired(ResponseMessage.Key.PAGE_ID_REQUIRED, ResponseMessage.Message.PAGE_ID_REQUIRED), - invaidConfiguration( - ResponseMessage.Key.INVALID_CONFIGURATION, ResponseMessage.Message.INVALID_CONFIGURATION), - assessmentItemIdRequired( - ResponseMessage.Key.ASSESSMENT_ITEM_ID_REQUIRED, - ResponseMessage.Message.ASSESSMENT_ITEM_ID_REQUIRED), - assessmentTypeRequired( - ResponseMessage.Key.ASSESSMENT_TYPE_REQUIRED, - ResponseMessage.Message.ASSESSMENT_TYPE_REQUIRED), - assessmentAttemptDateRequired( - ResponseMessage.Key.ATTEMPTED_DATE_REQUIRED, ResponseMessage.Message.ATTEMPTED_DATE_REQUIRED), - assessmentAnswersRequired( - ResponseMessage.Key.ATTEMPTED_ANSWERS_REQUIRED, - ResponseMessage.Message.ATTEMPTED_ANSWERS_REQUIRED), - assessmentmaxScoreRequired( - ResponseMessage.Key.MAX_SCORE_REQUIRED, ResponseMessage.Message.MAX_SCORE_REQUIRED), - statusCanntBeUpdated( - ResponseMessage.Key.STATUS_CANNOT_BE_UPDATED, - ResponseMessage.Message.STATUS_CANNOT_BE_UPDATED), - attemptIdRequired( - ResponseMessage.Key.ATTEMPT_ID_MISSING_ERROR, - ResponseMessage.Message.ATTEMPT_ID_MISSING_ERROR), - emailANDUserNameAlreadyExistError( - ResponseMessage.Key.USERNAME_EMAIL_IN_USE, ResponseMessage.Message.USERNAME_EMAIL_IN_USE), - keyCloakDefaultError( - ResponseMessage.Key.KEY_CLOAK_DEFAULT_ERROR, ResponseMessage.Message.KEY_CLOAK_DEFAULT_ERROR), - userRegUnSuccessfull( - ResponseMessage.Key.USER_REG_UNSUCCESSFUL, ResponseMessage.Message.USER_REG_UNSUCCESSFUL), - userUpdationUnSuccessfull( - ResponseMessage.Key.USER_UPDATE_UNSUCCESSFUL, - ResponseMessage.Message.USER_UPDATE_UNSUCCESSFUL), - loginTypeError(ResponseMessage.Key.LOGIN_TYPE_ERROR, ResponseMessage.Message.LOGIN_TYPE_ERROR), - invalidOrgId(ResponseMessage.Key.INVALID_ORG_ID, ResponseMessage.Key.INVALID_ORG_ID), - invalidOrgStatus(ResponseMessage.Key.INVALID_ORG_STATUS, ResponseMessage.Key.INVALID_ORG_STATUS), - invalidOrgStatusTransition( - ResponseMessage.Key.INVALID_ORG_STATUS_TRANSITION, - ResponseMessage.Key.INVALID_ORG_STATUS_TRANSITION), - addressRequired( - ResponseMessage.Key.ADDRESS_REQUIRED_ERROR, ResponseMessage.Message.ADDRESS_REQUIRED_ERROR), - educationRequired( - ResponseMessage.Key.EDUCATION_REQUIRED_ERROR, - ResponseMessage.Message.EDUCATION_REQUIRED_ERROR), - phoneNoRequired( - ResponseMessage.Key.PHONE_NO_REQUIRED_ERROR, ResponseMessage.Message.PHONE_NO_REQUIRED_ERROR), - jobDetailsRequired( - ResponseMessage.Key.JOBDETAILS_REQUIRED_ERROR, - ResponseMessage.Message.JOBDETAILS_REQUIRED_ERROR), - dataAlreadyExist( - ResponseMessage.Key.DATA_ALREADY_EXIST, ResponseMessage.Message.DATA_ALREADY_EXIST), - invalidData(ResponseMessage.Key.INVALID_DATA, ResponseMessage.Message.INVALID_DATA), - invalidCourseId(ResponseMessage.Key.INVALID_COURSE_ID, ResponseMessage.Message.INVALID_COURSE_ID), - orgIdRequired(ResponseMessage.Key.ORG_ID_MISSING, ResponseMessage.Message.ORG_ID_MISSING), - actorConnectionError( - ResponseMessage.Key.ACTOR_CONNECTION_ERROR, ResponseMessage.Message.ACTOR_CONNECTION_ERROR), - userAlreadyExists( - ResponseMessage.Key.USER_ALREADY_EXISTS, ResponseMessage.Message.USER_ALREADY_EXISTS), - invalidUserId(ResponseMessage.Key.INVALID_USER_ID, ResponseMessage.Message.INVALID_USER_ID), - loginIdRequired(ResponseMessage.Key.LOGIN_ID_MISSING, ResponseMessage.Message.LOGIN_ID_MISSING), - contentStatusRequired( - ResponseMessage.Key.CONTENT_STATUS_MISSING_ERROR, - ResponseMessage.Message.CONTENT_STATUS_MISSING_ERROR), - esError(ResponseMessage.Key.ES_ERROR, ResponseMessage.Message.ES_ERROR), - invalidPeriod(ResponseMessage.Key.INVALID_PERIOD, ResponseMessage.Message.INVALID_PERIOD), - userNotFound(ResponseMessage.Key.USER_NOT_FOUND, ResponseMessage.Message.USER_NOT_FOUND), - idRequired(ResponseMessage.Key.ID_REQUIRED_ERROR, ResponseMessage.Message.ID_REQUIRED_ERROR), - dataTypeError(ResponseMessage.Key.DATA_TYPE_ERROR, ResponseMessage.Message.DATA_TYPE_ERROR), - errorAttributeConflict( - ResponseMessage.Key.ERROR_ATTRIBUTE_CONFLICT, - ResponseMessage.Message.ERROR_ATTRIBUTE_CONFLICT), - addressError(ResponseMessage.Key.ADDRESS_ERROR, ResponseMessage.Message.ADDRESS_ERROR), - addressTypeError( - ResponseMessage.Key.ADDRESS_TYPE_ERROR, ResponseMessage.Message.ADDRESS_TYPE_ERROR), - educationNameError( - ResponseMessage.Key.NAME_OF_INSTITUTION_ERROR, - ResponseMessage.Message.NAME_OF_INSTITUTION_ERROR), - jobNameError(ResponseMessage.Key.JOB_NAME_ERROR, ResponseMessage.Message.JOB_NAME_ERROR), - educationDegreeError( - ResponseMessage.Key.EDUCATION_DEGREE_ERROR, ResponseMessage.Message.EDUCATION_DEGREE_ERROR), - organisationNameError( - ResponseMessage.Key.NAME_OF_ORGANISATION_ERROR, - ResponseMessage.Message.NAME_OF_ORGANISATION_ERROR), - rolesRequired(ResponseMessage.Key.ROLES_MISSING, ResponseMessage.Message.ROLES_MISSING), - emptyRolesProvided( - ResponseMessage.Key.EMPTY_ROLES_PROVIDED, ResponseMessage.Message.EMPTY_ROLES_PROVIDED), - invalidDateFormat( - ResponseMessage.Key.INVALID_DATE_FORMAT, ResponseMessage.Message.INVALID_DATE_FORMAT), - sourceAndExternalIdAlreadyExist( - ResponseMessage.Key.SRC_EXTERNAL_ID_ALREADY_EXIST, - ResponseMessage.Message.SRC_EXTERNAL_ID_ALREADY_EXIST), - userAlreadyEnrolledCourse( - ResponseMessage.Key.USER_ALREADY_ENROLLED_COURSE, - ResponseMessage.Message.USER_ALREADY_ENROLLED_COURSE), - userNotEnrolledCourse( - ResponseMessage.Key.USER_NOT_ENROLLED_COURSE, - ResponseMessage.Message.USER_NOT_ENROLLED_COURSE), - courseBatchAlreadyCompleted( - ResponseMessage.Key.COURSE_BATCH_ALREADY_COMPLETED, - ResponseMessage.Message.COURSE_BATCH_ALREADY_COMPLETED), - courseBatchEnrollmentDateEnded( - ResponseMessage.Key.COURSE_BATCH_ENROLLMENT_DATE_ENDED, - ResponseMessage.Message.COURSE_BATCH_ENROLLMENT_DATE_ENDED), - userAlreadyCompletedCourse( - ResponseMessage.Key.USER_ALREADY_COMPLETED_COURSE, - ResponseMessage.Message.USER_ALREADY_COMPLETED_COURSE), - pageAlreadyExist( - ResponseMessage.Key.PAGE_ALREADY_EXIST, ResponseMessage.Message.PAGE_ALREADY_EXIST), - contentTypeRequiredError( - ResponseMessage.Key.CONTENT_TYPE_ERROR, ResponseMessage.Message.CONTENT_TYPE_ERROR), - invalidPropertyError( - ResponseMessage.Key.INVALID_PROPERTY_ERROR, ResponseMessage.Message.INVALID_PROPERTY_ERROR), - usernameOrUserIdError( - ResponseMessage.Key.USER_NAME_OR_ID_ERROR, ResponseMessage.Message.USER_NAME_OR_ID_ERROR), - emailVerifiedError( - ResponseMessage.Key.EMAIL_VERIFY_ERROR, ResponseMessage.Message.EMAIL_VERIFY_ERROR), - phoneVerifiedError( - ResponseMessage.Key.PHONE_VERIFY_ERROR, ResponseMessage.Message.PHONE_VERIFY_ERROR), - bulkUserUploadError( - ResponseMessage.Key.BULK_USER_UPLOAD_ERROR, ResponseMessage.Message.BULK_USER_UPLOAD_ERROR), - dataSizeError(ResponseMessage.Key.DATA_SIZE_EXCEEDED, ResponseMessage.Message.DATA_SIZE_EXCEEDED), - InvalidColumnError( - ResponseMessage.Key.INVALID_COLUMN_NAME, ResponseMessage.Message.INVALID_COLUMN_NAME), - userAccountlocked( - ResponseMessage.Key.USER_ACCOUNT_BLOCKED, ResponseMessage.Message.USER_ACCOUNT_BLOCKED), - userAlreadyActive( - ResponseMessage.Key.USER_ALREADY_ACTIVE, ResponseMessage.Message.USER_ALREADY_ACTIVE), - userAlreadyInactive( - ResponseMessage.Key.USER_ALREADY_INACTIVE, ResponseMessage.Message.USER_ALREADY_INACTIVE), - enrolmentTypeRequired( - ResponseMessage.Key.ENROLMENT_TYPE_REQUIRED, ResponseMessage.Message.ENROLMENT_TYPE_REQUIRED), - enrolmentIncorrectValue( - ResponseMessage.Key.ENROLMENT_TYPE_VALUE_ERROR, - ResponseMessage.Message.ENROLMENT_TYPE_VALUE_ERROR), - courseBatchStartDateRequired( - ResponseMessage.Key.COURSE_BATCH_START_DATE_REQUIRED, - ResponseMessage.Message.COURSE_BATCH_START_DATE_REQUIRED), - courseBatchStartDateError( - ResponseMessage.Key.COURSE_BATCH_START_DATE_INVALID, - ResponseMessage.Message.COURSE_BATCH_START_DATE_INVALID), - dateFormatError( - ResponseMessage.Key.DATE_FORMAT_ERRROR, ResponseMessage.Message.DATE_FORMAT_ERRROR), - endDateError(ResponseMessage.Key.END_DATE_ERROR, ResponseMessage.Message.END_DATE_ERROR), - enrollmentEndDateStartError( - ResponseMessage.Key.ENROLLMENT_END_DATE_START_ERROR, - ResponseMessage.Message.ENROLLMENT_END_DATE_START_ERROR), - enrollmentEndDateEndError( - ResponseMessage.Key.ENROLLMENT_END_DATE_END_ERROR, - ResponseMessage.Message.ENROLLMENT_END_DATE_END_ERROR), - enrollmentEndDateUpdateError( - ResponseMessage.Key.ENROLLMENT_END_DATE_UPDATE_ERROR, - ResponseMessage.Message.ENROLLMENT_END_DATE_UPDATE_ERROR), - csvError(ResponseMessage.Key.INVALID_CSV_FILE, ResponseMessage.Message.INVALID_CSV_FILE), - invalidCourseBatchId( - ResponseMessage.Key.INVALID_COURSE_BATCH_ID, ResponseMessage.Message.INVALID_COURSE_BATCH_ID), - courseBatchIdRequired( - ResponseMessage.Key.COURSE_BATCH_ID_MISSING, ResponseMessage.Message.COURSE_BATCH_ID_MISSING), - enrollmentTypeValidation( - ResponseMessage.Key.ENROLLMENT_TYPE_VALIDATION, - ResponseMessage.Message.ENROLLMENT_TYPE_VALIDATION), - courseCreatedForIsNull( - ResponseMessage.Key.COURSE_CREATED_FOR_NULL, ResponseMessage.Message.COURSE_CREATED_FOR_NULL), - userNotAssociatedToOrg( - ResponseMessage.Key.USER_NOT_BELONGS_TO_ANY_ORG, - ResponseMessage.Message.USER_NOT_BELONGS_TO_ANY_ORG), - invalidObjectType( - ResponseMessage.Key.INVALID_OBJECT_TYPE, ResponseMessage.Message.INVALID_OBJECT_TYPE), - progressStatusError( - ResponseMessage.Key.INVALID_PROGRESS_STATUS, ResponseMessage.Message.INVALID_PROGRESS_STATUS), - courseBatchStartPassedDateError( - ResponseMessage.Key.COURSE_BATCH_START_PASSED_DATE_INVALID, - ResponseMessage.Message.COURSE_BATCH_START_PASSED_DATE_INVALID), - csvFileEmpty(ResponseMessage.Key.EMPTY_CSV_FILE, ResponseMessage.Message.EMPTY_CSV_FILE), - invalidRootOrgData( - ResponseMessage.Key.INVALID_ROOT_ORG_DATA, ResponseMessage.Message.INVALID_ROOT_ORG_DATA), - noDataForConsumption(ResponseMessage.Key.NO_DATA, ResponseMessage.Message.NO_DATA), - invalidChannel(ResponseMessage.Key.INVALID_CHANNEL, ResponseMessage.Message.INVALID_CHANNEL), - invalidProcessId( - ResponseMessage.Key.INVALID_PROCESS_ID, ResponseMessage.Message.INVALID_PROCESS_ID), - emailSubjectError( - ResponseMessage.Key.EMAIL_SUBJECT_ERROR, ResponseMessage.Message.EMAIL_SUBJECT_ERROR), - emailBodyError(ResponseMessage.Key.EMAIL_BODY_ERROR, ResponseMessage.Message.EMAIL_BODY_ERROR), - recipientAddressError( - ResponseMessage.Key.RECIPIENT_ADDRESS_ERROR, ResponseMessage.Message.RECIPIENT_ADDRESS_ERROR), - storageContainerNameMandatory( - ResponseMessage.Key.STORAGE_CONTAINER_NAME_MANDATORY, - ResponseMessage.Message.STORAGE_CONTAINER_NAME_MANDATORY), - userOrgAssociationError( - ResponseMessage.Key.USER_ORG_ASSOCIATION_ERROR, - ResponseMessage.Message.USER_ORG_ASSOCIATION_ERROR), - cloudServiceError( - ResponseMessage.Key.CLOUD_SERVICE_ERROR, ResponseMessage.Message.CLOUD_SERVICE_ERROR), - badgeTypeIdMandatory( - ResponseMessage.Key.BADGE_TYPE_ID_ERROR, ResponseMessage.Message.BADGE_TYPE_ID_ERROR), - receiverIdMandatory( - ResponseMessage.Key.RECEIVER_ID_ERROR, ResponseMessage.Message.RECEIVER_ID_ERROR), - invalidReceiverId( - ResponseMessage.Key.INVALID_RECEIVER_ID, ResponseMessage.Message.INVALID_RECEIVER_ID), - invalidBadgeTypeId( - ResponseMessage.Key.INVALID_BADGE_ID, ResponseMessage.Message.INVALID_BADGE_ID), - invalidRole(ResponseMessage.Key.INVALID_ROLE, ResponseMessage.Message.INVALID_ROLE), - saltValue(ResponseMessage.Key.INVALID_SALT, ResponseMessage.Message.INVALID_SALT), - orgTypeMandatory( - ResponseMessage.Key.ORG_TYPE_MANDATORY, ResponseMessage.Message.ORG_TYPE_MANDATORY), - orgTypeAlreadyExist( - ResponseMessage.Key.ORG_TYPE_ALREADY_EXIST, ResponseMessage.Message.ORG_TYPE_ALREADY_EXIST), - orgTypeIdRequired( - ResponseMessage.Key.ORG_TYPE_ID_REQUIRED_ERROR, - ResponseMessage.Message.ORG_TYPE_ID_REQUIRED_ERROR), - titleRequired(ResponseMessage.Key.TITLE_REQUIRED, ResponseMessage.Message.TITLE_REQUIRED), - noteRequired(ResponseMessage.Key.NOTE_REQUIRED, ResponseMessage.Message.NOTE_REQUIRED), - contentIdError(ResponseMessage.Key.CONTENT_ID_ERROR, ResponseMessage.Message.CONTENT_ID_ERROR), - invalidTags(ResponseMessage.Key.INVALID_TAGS, ResponseMessage.Message.INVALID_TAGS), - invalidNoteId(ResponseMessage.Key.NOTE_ID_INVALID, ResponseMessage.Message.NOTE_ID_INVALID), - userDataEncryptionError( - ResponseMessage.Key.USER_DATA_ENCRYPTION_ERROR, - ResponseMessage.Message.USER_DATA_ENCRYPTION_ERROR), - phoneNoFormatError( - ResponseMessage.Key.INVALID_PHONE_NO_FORMAT, ResponseMessage.Message.INVALID_PHONE_NO_FORMAT), - invalidWebPageData( - ResponseMessage.Key.INVALID_WEBPAGE_DATA, ResponseMessage.Message.INVALID_WEBPAGE_DATA), - invalidMediaType( - ResponseMessage.Key.INVALID_MEDIA_TYPE, ResponseMessage.Message.INVALID_MEDIA_TYPE), - invalidWebPageUrl( - ResponseMessage.Key.INVALID_WEBPAGE_URL, ResponseMessage.Message.INVALID_WEBPAGE_URL), - invalidDateRange( - ResponseMessage.Key.INVALID_DATE_RANGE, ResponseMessage.Message.INVALID_DATE_RANGE), - invalidBatchEndDateError( - ResponseMessage.Key.INVALID_BATCH_END_DATE_ERROR, - ResponseMessage.Message.INVALID_BATCH_END_DATE_ERROR), - invalidBatchStartDateError( - ResponseMessage.Key.INVALID_BATCH_START_DATE_ERROR, - ResponseMessage.Message.INVALID_BATCH_START_DATE_ERROR), - courseBatchEndDateError( - ResponseMessage.Key.COURSE_BATCH_END_DATE_ERROR, - ResponseMessage.Message.COURSE_BATCH_END_DATE_ERROR), - BatchCloseError( - ResponseMessage.Key.COURSE_BATCH_IS_CLOSED_ERROR, - ResponseMessage.Message.COURSE_BATCH_IS_CLOSED_ERROR), - newPasswordRequired( - ResponseMessage.Key.CONFIIRM_PASSWORD_MISSING, - ResponseMessage.Message.CONFIIRM_PASSWORD_MISSING), - newPasswordEmpty( - ResponseMessage.Key.CONFIIRM_PASSWORD_EMPTY, ResponseMessage.Message.CONFIIRM_PASSWORD_EMPTY), - samePasswordError( - ResponseMessage.Key.SAME_PASSWORD_ERROR, ResponseMessage.Message.SAME_PASSWORD_ERROR), - endorsedUserIdRequired( - ResponseMessage.Key.ENDORSED_USER_ID_REQUIRED, - ResponseMessage.Message.ENDORSED_USER_ID_REQUIRED), - canNotEndorse(ResponseMessage.Key.CAN_NOT_ENDORSE, ResponseMessage.Message.CAN_NOT_ENDORSE), - invalidOrgTypeId( - ResponseMessage.Key.INVALID_ORG_TYPE_ID_ERROR, - ResponseMessage.Message.INVALID_ORG_TYPE_ID_ERROR), - invalidOrgType( - ResponseMessage.Key.INVALID_ORG_TYPE_ERROR, ResponseMessage.Message.INVALID_ORG_TYPE_ERROR), - tableOrDocNameError( - ResponseMessage.Key.TABLE_OR_DOC_NAME_ERROR, ResponseMessage.Message.TABLE_OR_DOC_NAME_ERROR), - emailorPhoneRequired( - ResponseMessage.Key.EMAIL_OR_PHONE_MISSING, ResponseMessage.Message.EMAIL_OR_PHONE_MISSING), - emailorPhoneorManagedByRequired( - ResponseMessage.Key.EMAIL_OR_PHONE_OR_MANAGEDBY_MISSING, ResponseMessage.Message.EMAIL_OR_PHONE_OR_MANAGEDBY_MISSING), - OnlyEmailorPhoneorManagedByRequired( - ResponseMessage.Key.ONLY_EMAIL_OR_PHONE_OR_MANAGEDBY_REQUIRED, ResponseMessage.Message.ONLY_EMAIL_OR_PHONE_OR_MANAGEDBY_REQUIRED), - PhoneNumberInUse( - ResponseMessage.Key.PHONE_ALREADY_IN_USE, ResponseMessage.Message.PHONE_ALREADY_IN_USE), - invalidClientName( - ResponseMessage.Key.INVALID_CLIENT_NAME, ResponseMessage.Message.INVALID_CLIENT_NAME), - invalidClientId(ResponseMessage.Key.INVALID_CLIENT_ID, ResponseMessage.Message.INVALID_CLIENT_ID), - userPhoneUpdateFailed( - ResponseMessage.Key.USER_PHONE_UPDATE_FAILED, - ResponseMessage.Message.USER_PHONE_UPDATE_FAILED), - esUpdateFailed(ResponseMessage.Key.ES_UPDATE_FAILED, ResponseMessage.Message.ES_UPDATE_FAILED), - updateFailed(ResponseMessage.Key.UPDATE_FAILED, ResponseMessage.Message.UPDATE_FAILED), - invalidTypeValue(ResponseMessage.Key.INVALID_TYPE_VALUE, ResponseMessage.Key.INVALID_TYPE_VALUE), - invalidLocationId( - ResponseMessage.Key.INVALID_LOCATION_ID, ResponseMessage.Message.INVALID_LOCATION_ID), - invalidHashTagId( - ResponseMessage.Key.INVALID_HASHTAG_ID, ResponseMessage.Message.INVALID_HASHTAG_ID), - invalidUsrOrgData( - ResponseMessage.Key.INVALID_USR_ORG_DATA, ResponseMessage.Message.INVALID_USR_ORG_DATA), - visibilityInvalid( - ResponseMessage.Key.INVALID_VISIBILITY_REQUEST, - ResponseMessage.Message.INVALID_VISIBILITY_REQUEST), - invalidTopic(ResponseMessage.Key.INVALID_TOPIC_NAME, ResponseMessage.Message.INVALID_TOPIC_NAME), - invalidTopicData( - ResponseMessage.Key.INVALID_TOPIC_DATA, ResponseMessage.Message.INVALID_TOPIC_DATA), - invalidNotificationType( - ResponseMessage.Key.INVALID_NOTIFICATION_TYPE, - ResponseMessage.Message.INVALID_NOTIFICATION_TYPE), - notificationTypeSupport( - ResponseMessage.Key.INVALID_NOTIFICATION_TYPE_SUPPORT, - ResponseMessage.Message.INVALID_NOTIFICATION_TYPE_SUPPORT), - emailInUse(ResponseMessage.Key.EMAIL_IN_USE, ResponseMessage.Message.EMAIL_IN_USE), - invalidPhoneNumber( - ResponseMessage.Key.INVALID_PHONE_NUMBER, ResponseMessage.Message.INVALID_PHONE_NUMBER), - invalidCountryCode( - ResponseMessage.Key.INVALID_COUNTRY_CODE, ResponseMessage.Message.INVALID_COUNTRY_CODE), - locationIdRequired( - ResponseMessage.Key.LOCATION_ID_REQUIRED, ResponseMessage.Message.LOCATION_ID_REQUIRED), - functionalityMissing(ResponseMessage.Key.NOT_SUPPORTED, ResponseMessage.Message.NOT_SUPPORTED), - userNameOrUserIdRequired( - ResponseMessage.Key.USERNAME_USERID_MISSING, ResponseMessage.Message.USERNAME_USERID_MISSING), - channelRegFailed( - ResponseMessage.Key.CHANNEL_REG_FAILED, ResponseMessage.Message.CHANNEL_REG_FAILED), - invalidCourseCreatorId( - ResponseMessage.Key.INVALID_COURSE_CREATOR_ID, - ResponseMessage.Message.INVALID_COURSE_CREATOR_ID), - userNotAssociatedToRootOrg( - ResponseMessage.Key.USER_NOT_ASSOCIATED_TO_ROOT_ORG, - ResponseMessage.Message.USER_NOT_ASSOCIATED_TO_ROOT_ORG), - slugIsNotUnique( - ResponseMessage.Key.SLUG_IS_NOT_UNIQUE, ResponseMessage.Message.SLUG_IS_NOT_UNIQUE), - invalidDataForCreateBadgeIssuer( - ResponseMessage.Key.INVALID_CREATE_BADGE_ISSUER_DATA, - ResponseMessage.Message.INVALID_CREATE_BADGE_ISSUER_DATA), - issuerIdRequired( - ResponseMessage.Key.ISSUER_ID_REQUIRED, ResponseMessage.Message.ISSUER_ID_REQUIRED), - badgeIdRequired(ResponseMessage.Key.BADGE_ID_REQUIRED, ResponseMessage.Message.BADGE_ID_REQUIRED), - badgeNameRequired( - ResponseMessage.Key.BADGE_NAME_REQUIRED, ResponseMessage.Message.BADGE_NAME_REQUIRED), - badgeDescriptionRequired( - ResponseMessage.Key.BADGE_DESCRIPTION_REQUIRED, - ResponseMessage.Message.BADGE_DESCRIPTION_REQUIRED), - badgeCriteriaRequired( - ResponseMessage.Key.BADGE_CRITERIA_REQUIRED, ResponseMessage.Message.BADGE_CRITERIA_REQUIRED), - rootOrgIdRequired( - ResponseMessage.Key.ROOT_ORG_ID_REQUIRED, ResponseMessage.Message.ROOT_ORG_ID_REQUIRED), - badgeTypeRequired( - ResponseMessage.Key.BADGE_TYPE_REQUIRED, ResponseMessage.Message.BADGE_TYPE_REQUIRED), - invalidBadgeType( - ResponseMessage.Key.INVALID_BADGE_TYPE, ResponseMessage.Message.INVALID_BADGE_TYPE), - invalidBadgeSubtype( - ResponseMessage.Key.INVALID_BADGE_SUBTYPE, ResponseMessage.Message.INVALID_BADGE_SUBTYPE), - invalidBadgeRole( - ResponseMessage.Key.INVALID_BADGE_ROLE, ResponseMessage.Message.INVALID_BADGE_ROLE), - badgeRolesRequired( - ResponseMessage.Key.BADGE_ROLES_REQUIRED, ResponseMessage.Message.BADGE_ROLES_REQUIRED), - badgeImageRequired( - ResponseMessage.Key.BADGE_IMAGE_REQUIRED, ResponseMessage.Message.BADGE_IMAGE_REQUIRED), - recipientEmailRequired( - ResponseMessage.Key.RECIPIENT_EMAIL_REQUIRED, - ResponseMessage.Message.RECIPIENT_EMAIL_REQUIRED), - evidenceRequired( - ResponseMessage.Key.ASSERTION_EVIDENCE_REQUIRED, - ResponseMessage.Message.ASSERTION_EVIDENCE_REQUIRED), - assertionIdRequired( - ResponseMessage.Key.ASSERTION_ID_REQUIRED, ResponseMessage.Message.ASSERTION_ID_REQUIRED), - recipientIdRequired( - ResponseMessage.Key.RECIPIENT_ID_REQUIRED, ResponseMessage.Message.RECIPIENT_ID_REQUIRED), - recipientTypeRequired( - ResponseMessage.Key.RECIPIENT_TYPE_REQUIRED, ResponseMessage.Message.RECIPIENT_TYPE_REQUIRED), - badgingserverError( - ResponseMessage.Key.BADGING_SERVER_ERROR, ResponseMessage.Message.BADGING_SERVER_ERROR), - resourceNotFound( - ResponseMessage.Key.RESOURCE_NOT_FOUND, ResponseMessage.Message.RESOURCE_NOT_FOUND), - sizeLimitExceed( - ResponseMessage.Key.MAX_ALLOWED_SIZE_LIMIT_EXCEED, - ResponseMessage.Message.MAX_ALLOWED_SIZE_LIMIT_EXCEED), - slugRequired(ResponseMessage.Key.SLUG_REQUIRED, ResponseMessage.Message.SLUG_REQUIRED), - invalidIssuerId(ResponseMessage.Key.INVALID_ISSUER_ID, ResponseMessage.Message.INVALID_ISSUER_ID), - revocationReasonRequired( - ResponseMessage.Key.REVOCATION_REASON_REQUIRED, - ResponseMessage.Message.REVOCATION_REASON_REQUIRED), - badgeAssertionAlreadyRevoked( - ResponseMessage.Key.ALREADY_REVOKED, ResponseMessage.Message.ALREADY_REVOKED), - invalidRecipientType( - ResponseMessage.Key.INVALID_RECIPIENT_TYPE, ResponseMessage.Message.INVALID_RECIPIENT_TYPE), - customClientError( - ResponseMessage.Key.CUSTOM_CLIENT_ERROR, ResponseMessage.Message.CUSTOM_CLIENT_ERROR), - customResourceNotFound( - ResponseMessage.Key.CUSTOM_RESOURCE_NOT_FOUND_ERROR, - ResponseMessage.Message.CUSTOM_RESOURCE_NOT_FOUND_ERROR), - customServerError( - ResponseMessage.Key.CUSTOM_SERVER_ERROR, ResponseMessage.Message.CUSTOM_SERVER_ERROR), - inactiveUser(ResponseMessage.Key.INACTIVE_USER, ResponseMessage.Message.INACTIVE_USER), - userInactiveForThisOrg( - ResponseMessage.Key.USER_INACTIVE_FOR_THIS_ORG, - ResponseMessage.Message.USER_INACTIVE_FOR_THIS_ORG), - userUpdateToOrgFailed( - ResponseMessage.Key.USER_UPDATE_FAILED_FOR_THIS_ORG, - ResponseMessage.Message.USER_UPDATE_FAILED_FOR_THIS_ORG), - preferenceKeyMissing( - ResponseMessage.Key.USER_UPDATE_FAILED_FOR_THIS_ORG, - ResponseMessage.Message.USER_UPDATE_FAILED_FOR_THIS_ORG), - pageDoesNotExist(ResponseMessage.Key.PAGE_NOT_EXIST, ResponseMessage.Message.PAGE_NOT_EXIST), - sectionDoesNotExist( - ResponseMessage.Key.SECTION_NOT_EXIST, ResponseMessage.Message.SECTION_NOT_EXIST), - orgDoesNotExist(ResponseMessage.Key.ORG_NOT_EXIST, ResponseMessage.Message.ORG_NOT_EXIST), - invalidPageSource( - ResponseMessage.Key.INVALID_PAGE_SOURCE, ResponseMessage.Message.INVALID_PAGE_SOURCE), - badgeSubTypeRequired( - ResponseMessage.Key.BADGE_SUBTYPE_REQUIRED, ResponseMessage.Message.BADGE_SUBTYPE_REQUIRED), - locationTypeRequired( - ResponseMessage.Key.LOCATION_TYPE_REQUIRED, ResponseMessage.Message.LOCATION_TYPE_REQUIRED), - invalidRequestDataForLocation( - ResponseMessage.Key.INVALID_REQUEST_DATA_FOR_LOCATION, - ResponseMessage.Message.INVALID_REQUEST_DATA_FOR_LOCATION), - alreadyExists(ResponseMessage.Key.ALREADY_EXISTS, ResponseMessage.Message.ALREADY_EXISTS), - invalidValue(ResponseMessage.Key.INVALID_VALUE, ResponseMessage.Message.INVALID_VALUE), - parentCodeAndIdValidationError( - ResponseMessage.Key.PARENT_CODE_AND_PARENT_ID_MISSING, - ResponseMessage.Message.PARENT_CODE_AND_PARENT_ID_MISSING), - invalidParameter( - ResponseMessage.Key.INVALID_PARAMETER, ResponseMessage.Message.INVALID_PARAMETER), - invalidLocationDeleteRequest( - ResponseMessage.Key.INVALID_LOCATION_DELETE_REQUEST, - ResponseMessage.Message.INVALID_LOCATION_DELETE_REQUEST), - locationTypeConflicts( - ResponseMessage.Key.LOCATION_TYPE_CONFLICTS, ResponseMessage.Message.LOCATION_TYPE_CONFLICTS), - mandatoryParamsMissing( - ResponseMessage.Key.MANDATORY_PARAMETER_MISSING, - ResponseMessage.Message.MANDATORY_PARAMETER_MISSING), - errorMandatoryParamsEmpty( - ResponseMessage.Key.ERROR_MANDATORY_PARAMETER_EMPTY, - ResponseMessage.Message.ERROR_MANDATORY_PARAMETER_EMPTY), - errorNoFrameworkFound( - ResponseMessage.Key.ERROR_NO_FRAMEWORK_FOUND, - ResponseMessage.Message.ERROR_NO_FRAMEWORK_FOUND), - unupdatableField( - ResponseMessage.Key.UPDATE_NOT_ALLOWED, ResponseMessage.Message.UPDATE_NOT_ALLOWED), - mandatoryHeadersMissing( - ResponseMessage.Key.MANDATORY_HEADER_MISSING, - ResponseMessage.Message.MANDATORY_HEADER_MISSING), - invalidParameterValue( - ResponseMessage.Key.INVALID_PARAMETER_VALUE, ResponseMessage.Message.INVALID_PARAMETER_VALUE), - parentNotAllowed( - ResponseMessage.Key.PARENT_NOT_ALLOWED, ResponseMessage.Message.PARENT_NOT_ALLOWED), - missingFileAttachment( - ResponseMessage.Key.MISSING_FILE_ATTACHMENT, ResponseMessage.Message.MISSING_FILE_ATTACHMENT), - fileAttachmentSizeNotConfigured( - ResponseMessage.Key.FILE_ATTACHMENT_SIZE_NOT_CONFIGURED, - ResponseMessage.Message.FILE_ATTACHMENT_SIZE_NOT_CONFIGURED), - emptyFile(ResponseMessage.Key.EMPTY_FILE, ResponseMessage.Message.EMPTY_FILE), - invalidColumns(ResponseMessage.Key.INVALID_COLUMNS, ResponseMessage.Message.INVALID_COLUMNS), - conflictingOrgLocations( - ResponseMessage.Key.CONFLICTING_ORG_LOCATIONS, - ResponseMessage.Message.CONFLICTING_ORG_LOCATIONS), - unableToCommunicateWithActor( - ResponseMessage.Key.UNABLE_TO_COMMUNICATE_WITH_ACTOR, - ResponseMessage.Message.UNABLE_TO_COMMUNICATE_WITH_ACTOR), - emptyHeaderLine(ResponseMessage.Key.EMPTY_HEADER_LINE, ResponseMessage.Message.EMPTY_HEADER_LINE), - invalidRequestParameter( - ResponseMessage.Key.INVALID_REQUEST_PARAMETER, - ResponseMessage.Message.INVALID_REQUEST_PARAMETER), - rootOrgAssociationError( - ResponseMessage.Key.ROOT_ORG_ASSOCIATION_ERROR, - ResponseMessage.Message.ROOT_ORG_ASSOCIATION_ERROR), - dependentParameterMissing( - ResponseMessage.Key.DEPENDENT_PARAMETER_MISSING, - ResponseMessage.Message.DEPENDENT_PARAMETER_MISSING), - externalIdNotFound( - ResponseMessage.Key.EXTERNALID_NOT_FOUND, ResponseMessage.Message.EXTERNALID_NOT_FOUND), - externalIdAssignedToOtherUser( - ResponseMessage.Key.EXTERNALID_ASSIGNED_TO_OTHER_USER, - ResponseMessage.Message.EXTERNALID_ASSIGNED_TO_OTHER_USER), - dependentParamsMissing( - ResponseMessage.Key.DEPENDENT_PARAMETER_MISSING, - ResponseMessage.Message.DEPENDENT_PARAMS_MISSING), - mandatoryConfigParamMissing( - ResponseMessage.Key.MANDATORY_CONFIG_PARAMETER_MISSING, - ResponseMessage.Message.MANDATORY_CONFIG_PARAMETER_MISSING), - cassandraConnectionEstablishmentFailed( - ResponseMessage.Key.CASSANDRA_CONNECTION_ESTABLISHMENT_FAILED, - ResponseMessage.Message.CASSANDRA_CONNECTION_ESTABLISHMENT_FAILED), - commonAttributeMismatch( - ResponseMessage.Key.COMMON_ATTRIBUTE_MISMATCH, - ResponseMessage.Message.COMMON_ATTRIBUTE_MISMATCH), - multipleCoursesNotAllowedForBatch( - ResponseMessage.Key.MULTIPLE_COURSES_FOR_BATCH, - ResponseMessage.Message.MULTIPLE_COURSES_FOR_BATCH), - errorJsonTransformInvalidTypeConfig( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_INVALID_TYPE_CONFIG, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_INVALID_TYPE_CONFIG), - errorJsonTransformInvalidDateFormat( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_INVALID_DATE_FORMAT, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_INVALID_DATE_FORMAT), - errorJsonTransformInvalidInput( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_INVALID_INPUT, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_INVALID_INPUT), - errorJsonTransformInvalidEnumInput( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_INVALID_ENUM_INPUT, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_INVALID_ENUM_INPUT), - errorJsonTransformEnumValuesEmpty( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_ENUM_VALUES_EMPTY, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_ENUM_VALUES_EMPTY), - errorJsonTransformBasicConfigMissing( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_BASIC_CONFIG_MISSING, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_BASIC_CONFIG_MISSING), - errorJsonTransformInvalidFilterConfig( - ResponseMessage.Key.ERROR_JSON_TRANSFORM_INVALID_FILTER_CONFIG, - ResponseMessage.Message.ERROR_JSON_TRANSFORM_INVALID_FILTER_CONFIG), - errorLoadConfig(ResponseMessage.Key.ERROR_LOAD_CONFIG, ResponseMessage.Message.ERROR_LOAD_CONFIG), - errorRegistryClientCreation( - ResponseMessage.Key.ERROR_REGISTRY_CLIENT_CREATION, - ResponseMessage.Message.ERROR_REGISTRY_CLIENT_CREATION), - errorRegistryAddEntity( - ResponseMessage.Key.ERROR_REGISTRY_ADD_ENTITY, - ResponseMessage.Message.ERROR_REGISTRY_ADD_ENTITY), - errorRegistryReadEntity( - ResponseMessage.Key.ERROR_REGISTRY_READ_ENTITY, - ResponseMessage.Message.ERROR_REGISTRY_READ_ENTITY), - errorRegistryUpdateEntity( - ResponseMessage.Key.ERROR_REGISTRY_UPDATE_ENTITY, - ResponseMessage.Message.ERROR_REGISTRY_UPDATE_ENTITY), - errorRegistryDeleteEntity( - ResponseMessage.Key.ERROR_REGISTRY_DELETE_ENTITY, - ResponseMessage.Message.ERROR_REGISTRY_DELETE_ENTITY), - errorRegistryParseResponse( - ResponseMessage.Key.ERROR_REGISTRY_PARSE_RESPONSE, - ResponseMessage.Message.ERROR_REGISTRY_PARSE_RESPONSE), - errorRegistryEntityTypeBlank( - ResponseMessage.Key.ERROR_REGISTRY_ENTITY_TYPE_BLANK, - ResponseMessage.Message.ERROR_REGISTRY_ENTITY_TYPE_BLANK), - errorRegistryEntityIdBlank( - ResponseMessage.Key.ERROR_REGISTRY_ENTITY_ID_BLANK, - ResponseMessage.Message.ERROR_REGISTRY_ENTITY_ID_BLANK), - errorRegistryAccessTokenBlank( - ResponseMessage.Key.ERROR_REGISTRY_ACCESS_TOKEN_BLANK, - ResponseMessage.Message.ERROR_REGISTRY_ACCESS_TOKEN_BLANK), - duplicateExternalIds( - ResponseMessage.Key.DUPLICATE_EXTERNAL_IDS, ResponseMessage.Message.DUPLICATE_EXTERNAL_IDS), - invalidDuplicateValue( - ResponseMessage.Key.INVALID_DUPLICATE_VALUE, ResponseMessage.Message.INVALID_DUPLICATE_VALUE), - emailNotSentRecipientsExceededMaxLimit( - ResponseMessage.Key.EMAIL_RECIPIENTS_EXCEEDS_MAX_LIMIT, - ResponseMessage.Message.EMAIL_RECIPIENTS_EXCEEDS_MAX_LIMIT), - emailNotSentRecipientsZero( - ResponseMessage.Key.NO_EMAIL_RECIPIENTS, ResponseMessage.Message.NO_EMAIL_RECIPIENTS), - parameterMismatch( - ResponseMessage.Key.PARAMETER_MISMATCH, ResponseMessage.Message.PARAMETER_MISMATCH), - errorForbidden(ResponseMessage.Key.FORBIDDEN, ResponseMessage.Message.FORBIDDEN), - errorConfigLoadEmptyString( - ResponseMessage.Key.ERROR_CONFIG_LOAD_EMPTY_STRING, - ResponseMessage.Message.ERROR_CONFIG_LOAD_EMPTY_STRING), - errorConfigLoadParseString( - ResponseMessage.Key.ERROR_CONFIG_LOAD_PARSE_STRING, - ResponseMessage.Message.ERROR_CONFIG_LOAD_PARSE_STRING), - errorConfigLoadEmptyConfig( - ResponseMessage.Key.ERROR_CONFIG_LOAD_EMPTY_CONFIG, - ResponseMessage.Message.ERROR_CONFIG_LOAD_EMPTY_CONFIG), - errorConflictingFieldConfiguration( - ResponseMessage.Key.ERROR_CONFLICTING_FIELD_CONFIGURATION, - ResponseMessage.Message.ERROR_CONFLICTING_FIELD_CONFIGURATION), - errorSystemSettingNotFound( - ResponseMessage.Key.ERROR_SYSTEM_SETTING_NOT_FOUND, - ResponseMessage.Message.ERROR_SYSTEM_SETTING_NOT_FOUND), - errorNoRootOrgAssociated( - ResponseMessage.Key.ERROR_NO_ROOT_ORG_ASSOCIATED, - ResponseMessage.Message.ERROR_NO_ROOT_ORG_ASSOCIATED), - errorInactiveCustodianOrg( - ResponseMessage.Key.ERROR_INACTIVE_CUSTODIAN_ORG, - ResponseMessage.Message.ERROR_INACTIVE_CUSTODIAN_ORG), - errorUnsupportedCloudStorage( - ResponseMessage.Key.ERROR_UNSUPPORTED_CLOUD_STORAGE, - ResponseMessage.Message.ERROR_UNSUPPORTED_CLOUD_STORAGE), - errorUnsupportedField( - ResponseMessage.Key.ERROR_UNSUPPORTED_FIELD, ResponseMessage.Message.ERROR_UNSUPPORTED_FIELD), - errorGenerateDownloadLink( - ResponseMessage.Key.ERROR_GENERATE_DOWNLOAD_LINK, - ResponseMessage.Message.ERROR_GENERATE_DOWNLOAD_LINK), - errorUnavailableDownloadLink( - ResponseMessage.Key.ERROR_DOWNLOAD_LINK_UNAVAILABLE, - ResponseMessage.Message.ERROR_DOWNLOAD_LINK_UNAVAILABLE), - errorSavingStorageDetails( - ResponseMessage.Key.ERROR_SAVING_STORAGE_DETAILS, - ResponseMessage.Message.ERROR_SAVING_STORAGE_DETAILS), - errorCsvNoDataRows( - ResponseMessage.Key.ERROR_CSV_NO_DATA_ROWS, ResponseMessage.Message.ERROR_CSV_NO_DATA_ROWS), - errorInactiveOrg( - ResponseMessage.Key.ERROR_INACTIVE_ORG, ResponseMessage.Message.ERROR_INACTIVE_ORG), - errorDuplicateEntries( - ResponseMessage.Key.ERROR_DUPLICATE_ENTRIES, ResponseMessage.Message.ERROR_DUPLICATE_ENTRIES), - errorConflictingValues( - ResponseMessage.Key.ERROR_CONFLICTING_VALUES, - ResponseMessage.Message.ERROR_CONFLICTING_VALUES), - errorConflictingRootOrgId( - ResponseMessage.Key.ERROR_CONFLICTING_ROOT_ORG_ID, - ResponseMessage.Message.ERROR_CONFLICTING_ROOT_ORG_ID), - errorUpdateSettingNotAllowed( - ResponseMessage.Key.ERROR_UPDATE_SETTING_NOT_ALLOWED, - ResponseMessage.Message.ERROR_UPDATE_SETTING_NOT_ALLOWED), - errorCreatingFile( - ResponseMessage.Key.ERROR_CREATING_FILE, ResponseMessage.Message.ERROR_CREATING_FILE), - errorProcessingRequest( - ResponseMessage.Key.ERROR_PROCESSING_REQUEST, - ResponseMessage.Message.ERROR_PROCESSING_REQUEST), - errorUnavailableCertificate( - ResponseMessage.Key.ERROR_UNAVAILABLE_CERTIFICATE, - ResponseMessage.Message.ERROR_UNAVAILABLE_CERTIFICATE), - invalidTextbook(ResponseMessage.Key.INVALID_TEXTBOOK, ResponseMessage.Message.INVALID_TEXTBOOK), - csvRowsExceeds(ResponseMessage.Key.CSV_ROWS_EXCEEDS, ResponseMessage.Message.CSV_ROWS_EXCEEDS), - invalidTextbookName( - ResponseMessage.Key.INVALID_TEXTBOOK_NAME, ResponseMessage.Message.INVALID_TEXTBOOK_NAME), - duplicateRows(ResponseMessage.Key.DUPLICATE_ROWS, ResponseMessage.Message.DUPLICATE_ROWS), - requiredHeaderMissing( - ResponseMessage.Key.REQUIRED_HEADER_MISSING, ResponseMessage.Message.REQUIRED_HEADER_MISSING), - requiredFieldMissing( - ResponseMessage.Key.REQUIRED_FIELD_MISSING, ResponseMessage.Message.REQUIRED_FIELD_MISSING), - blankCsvData(ResponseMessage.Key.BLANK_CSV_DATA, ResponseMessage.Message.BLANK_CSV_DATA), - exceedMaxChildren( - ResponseMessage.Key.EXCEEDS_MAX_CHILDREN, ResponseMessage.Message.EXCEEDS_MAX_CHILDREN), - textbookChildrenExist( - ResponseMessage.Key.TEXTBOOK_CHILDREN_EXISTS, - ResponseMessage.Message.TEXTBOOK_CHILDREN_EXISTS), - textbookUpdateFailure( - ResponseMessage.Key.TEXTBOOK_UPDATE_FAILURE, ResponseMessage.Message.TEXTBOOK_UPDATE_FAILURE), - noChildrenExists( - ResponseMessage.Key.TEXTBOOK_CHILDREN_NOT_EXISTS, - ResponseMessage.Message.TEXTBOOK_CHILDREN_NOT_EXISTS), - textBookNotFound( - ResponseMessage.Key.TEXTBOOK_NOT_FOUND, ResponseMessage.Message.TEXTBOOK_NOT_FOUND), - errorProcessingFile( - ResponseMessage.Key.ERROR_PROCESSING_FILE, ResponseMessage.Message.ERROR_PROCESSING_FILE), - fileNotFound(ResponseMessage.Key.ERR_FILE_NOT_FOUND, ResponseMessage.Message.ERR_FILE_NOT_FOUND), - errorTbUpdate(ResponseMessage.Key.ERROR_TB_UPDATE, ResponseMessage.Message.ERROR_TB_UPDATE), - errorInvalidParameterSize( - ResponseMessage.Key.ERROR_INVALID_PARAMETER_SIZE, - ResponseMessage.Message.ERROR_INVALID_PARAMETER_SIZE), - errorInvalidPageSection( - ResponseMessage.Key.INVALID_PAGE_SECTION, ResponseMessage.Message.INVALID_PAGE_SECTION), - errorRateLimitExceeded( - ResponseMessage.Key.ERROR_RATE_LIMIT_EXCEEDED, - ResponseMessage.Message.ERROR_RATE_LIMIT_EXCEEDED), - errorInvalidDialCode( - ResponseMessage.Key.ERROR_INVALID_DIAL_CODE, ResponseMessage.Message.ERROR_INVALID_DIAL_CODE), - errorInvalidTopic( - ResponseMessage.Key.ERROR_INVALID_TOPIC, ResponseMessage.Message.ERROR_INVALID_TOPIC), - errorDialCodeDuplicateEntry( - ResponseMessage.Key.ERROR_DIAL_CODE_DUPLICATE_ENTRY, - ResponseMessage.Message.ERROR_DIAL_CODE_DUPLICATE_ENTRY), - errorDialCodeAlreadyAssociated( - ResponseMessage.Key.ERROR_DIAL_CODE_ALREADY_ASSOCIATED, - ResponseMessage.Message.ERROR_DIAL_CODE_ALREADY_ASSOCIATED), - errorDialCodeLinkingFail( - ResponseMessage.Key.DIAL_CODE_LINKING_FAILED, - ResponseMessage.Message.DIAL_CODE_LINKING_FAILED), - errorDialCodeLinkingClientError( - ResponseMessage.Key.ERROR_TEXTBOOK_UPDATE, ResponseMessage.Message.ERROR_TEXTBOOK_UPDATE), - errorInvalidLinkedContentId( - ResponseMessage.Key.ERROR_INVALID_LINKED_CONTENT_ID, - ResponseMessage.Message.ERROR_INVALID_LINKED_CONTENT_ID), - errorDuplicateLinkedContentId( - ResponseMessage.Key.ERROR_DUPLICATE_LINKED_CONTENT, - ResponseMessage.Message.ERROR_DUPLICATE_LINKED_CONTENT), - - errorTeacherCannotBelongToCustodianOrg( - ResponseMessage.Key.TEACHER_CANNOT_BELONG_TO_CUSTODIAN_ORG, - ResponseMessage.Message.TEACHER_CANNOT_BELONG_TO_CUSTODIAN_ORG), - errorDduplicateDialCodeEntry( - ResponseMessage.Key.ERROR_DUPLICATE_QR_CODE_ENTRY, - ResponseMessage.Message.ERROR_DUPLICATE_QR_CODE_ENTRY), - errorInvalidTextbookUnitId( - ResponseMessage.Key.ERROR_INVALID_TEXTBOOK_UNIT_ID, - ResponseMessage.Message.ERROR_INVALID_TEXTBOOK_UNIT_ID), - invalidRequestTimeout( - ResponseMessage.Key.INVALID_REQUEST_TIMEOUT, ResponseMessage.Message.INVALID_REQUEST_TIMEOUT), - errorBGMSMismatch( - ResponseMessage.Key.ERROR_BGMS_MISMATCH, ResponseMessage.Message.ERROR_BGMS_MISMATCH), - errorUserMigrationFailed( - ResponseMessage.Key.ERROR_USER_MIGRATION_FAILED, - ResponseMessage.Message.ERROR_USER_MIGRATION_FAILED), - invalidIdentifier( - ResponseMessage.Key.VALID_IDENTIFIER_ABSENSE, - ResponseMessage.Message.IDENTIFIER_VALIDATION_FAILED), - fromAccountIdRequired( - ResponseMessage.Key.FROM_ACCOUNT_ID_MISSING, ResponseMessage.Message.FROM_ACCOUNT_ID_MISSING), - toAccountIdRequired( - ResponseMessage.Key.TO_ACCOUNT_ID_MISSING, ResponseMessage.Message.TO_ACCOUNT_ID_MISSING), - fromAccountIdNotExists( - ResponseMessage.Key.FROM_ACCOUNT_ID_NOT_EXISTS, - ResponseMessage.Message.FROM_ACCOUNT_ID_NOT_EXISTS), - mandatoryHeaderParamsMissing( - ResponseMessage.Key.MANDATORY_HEADER_PARAMETER_MISSING, - ResponseMessage.Message.MANDATORY_HEADER_PARAMETER_MISSING), - recoveryParamsMatchException( - ResponseMessage.Key.RECOVERY_PARAM_MATCH_EXCEPTION, - ResponseMessage.Message.RECOVERY_PARAM_MATCH_EXCEPTION), - PARAM_NOT_MATCH(ResponseMessage.Key.PARAM_NOT_MATCH, ResponseMessage.Message.PARAM_NOT_MATCH), - emptyContentsForUpdateBatchStatus( - ResponseMessage.Key.EMPTY_CONTENTS_FOR_UPDATE_BATCH_STATUS, - ResponseMessage.Message.EMPTY_CONTENTS_FOR_UPDATE_BATCH_STATUS), - errorUserHasNotCreatedAnyCourse( - ResponseMessage.Key.ERROR_USER_HAS_NOT_CREATED_ANY_COURSE, - ResponseMessage.Message.ERROR_USER_HAS_NOT_CREATED_ANY_COURSE), - errorUploadQRCodeCSVfailed( - ResponseMessage.Key.ERROR_UPLOAD_QRCODE_CSV_FAILED, - ResponseMessage.Message.ERROR_UPLOAD_QRCODE_CSV_FAILED), - errorNoDialcodesLinked( - ResponseMessage.Key.ERROR_NO_DIALCODES_LINKED, - ResponseMessage.Message.ERROR_NO_DIALCODES_LINKED), - eventsRequired( - ResponseMessage.Key.EVENTS_DATA_MISSING, ResponseMessage.Message.EVENTS_DATA_MISSING), - accountNotFound(ResponseMessage.Key.ACCOUNT_NOT_FOUND, ResponseMessage.Message.ACCOUNT_NOT_FOUND), - userMigrationFiled( - ResponseMessage.Key.USER_MIGRATION_FAILED, ResponseMessage.Message.USER_MIGRATION_FAILED), - invalidUserExternalId( - ResponseMessage.Key.INVALID_EXT_USER_ID, ResponseMessage.Message.INVALID_EXT_USER_ID), - invalidElementInList( - ResponseMessage.Key.INVALID_ELEMENT_IN_LIST, ResponseMessage.Message.INVALID_ELEMENT_IN_LIST), - passwordValidation( - ResponseMessage.Key.INVALID_PASSWORD, ResponseMessage.Message.INVALID_PASSWORD), - otpVerificationFailed( - ResponseMessage.Key.OTP_VERIFICATION_FAILED, ResponseMessage.Message.OTP_VERIFICATION_FAILED), - serviceUnAvailable( - ResponseMessage.Key.SERVICE_UNAVAILABLE, ResponseMessage.Message.SERVICE_UNAVAILABLE), - missingData( - ResponseMessage.Key.MISSING_CODE, ResponseMessage.Message.MISSING_MESSAGE), - managedByNotAllowed( - ResponseMessage.Key.MANAGED_BY_NOT_ALLOWED, ResponseMessage.Message.MANAGED_BY_NOT_ALLOWED), - OK(200), - CLIENT_ERROR(400), - SERVER_ERROR(500), - RESOURCE_NOT_FOUND(404), - UNAUTHORIZED(401), - FORBIDDEN(403), - REDIRECTION_REQUIRED(302), - TOO_MANY_REQUESTS(429), - SERVICE_UNAVAILABLE(503), - PARTIAL_SUCCESS_RESPONSE(206); - private int responseCode; - /** error code contains String value */ - private String errorCode; - /** errorMessage contains proper error message. */ - private String errorMessage; - - /** - * @param errorCode String - * @param errorMessage String - */ - private ResponseCode(String errorCode, String errorMessage) { - this.errorCode = errorCode; - this.errorMessage = errorMessage; - } - - private ResponseCode(String errorCode, String errorMessage, int responseCode) { - this.errorCode = errorCode; - this.errorMessage = errorMessage; - this.responseCode = responseCode; - } - - /** - * @param errorCode - * @return - */ - public String getMessage(int errorCode) { - return ""; - } - - /** @return */ - public String getErrorCode() { - return errorCode; - } - - /** @param errorCode */ - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - /** @return */ - public String getErrorMessage() { - return errorMessage; - } - - /** @param errorMessage */ - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * This method will provide status message based on code - * - * @param code - * @return String - */ - public static String getResponseMessage(String code) { - if (StringUtils.isBlank(code)) { - return ""; - } - ResponseCode responseCodes[] = ResponseCode.values(); - for (ResponseCode actionState : responseCodes) { - if (actionState.getErrorCode().equals(code)) { - return actionState.getErrorMessage(); - } - } - return ""; - } - - private ResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - public int getResponseCode() { - return responseCode; - } - - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - /** - * This method will take header response code as int value and it provide matched enum value, if - * code is not matched or exception occurs then it will provide SERVER_ERROR - * - * @param code int - * @return HeaderResponseCode - */ - public static ResponseCode getHeaderResponseCode(int code) { - if (code > 0) { - try { - ResponseCode[] arr = ResponseCode.values(); - if (null != arr) { - for (ResponseCode rc : arr) { - if (rc.getResponseCode() == code) return rc; - } - } - } catch (Exception e) { - return ResponseCode.SERVER_ERROR; - } - } - return ResponseCode.SERVER_ERROR; - } - - /** - * This method will provide ResponseCode enum based on error code - * - * @param errorCode - * @return String - */ - public static ResponseCode getResponse(String errorCode) { - if (StringUtils.isBlank(errorCode)) { - return null; - } else if (JsonKey.UNAUTHORIZED.equals(errorCode)) { - return ResponseCode.unAuthorized; - } else { - ResponseCode value = null; - ResponseCode responseCodes[] = ResponseCode.values(); - for (ResponseCode response : responseCodes) { - if (response.getErrorCode().equals(errorCode)) { - return response; - } - } - return value; - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseMessage.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseMessage.java deleted file mode 100644 index a9d3ac2d0..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/ResponseMessage.java +++ /dev/null @@ -1,871 +0,0 @@ -package org.sunbird.common.responsecode; - -/** - * This interface will hold all the response key and message - * - * @author Manzarul - */ -public interface ResponseMessage { - - interface Message { - - String UNAUTHORIZED_USER = "You are not authorized."; - String INVALID_USER_CREDENTIALS = "Please check your credentials"; - String OPERATION_TIMEOUT = "Request processing taking too long time. Please try again later."; - String INVALID_OPERATION_NAME = - "Operation name is invalid. Please provide a valid operation name"; - String INVALID_REQUESTED_DATA = "Requested data for this operation is not valid."; - String CONSUMER_ID_MISSING_ERROR = "Consumer id is mandatory."; - String CONSUMER_ID_INVALID_ERROR = "Consumer id is invalid."; - String DEVICE_ID_MISSING_ERROR = "Device id is mandatory."; - String CONTENT_ID_INVALID_ERROR = "Please provide a valid content id."; - String CONTENT_ID_MISSING_ERROR = "Please provide content id."; - String COURSE_ID_MISSING_ERROR = "Please provide course id."; - String API_KEY_MISSING_ERROR = "APi key is mandatory."; - String API_KEY_INVALID_ERROR = "APi key is invalid."; - String INTERNAL_ERROR = "Process failed,please try again later."; - String COURSE_NAME_MISSING = "Please provide the course name."; - String SUCCESS_MESSAGE = "Success"; - String SESSION_ID_MISSING = "Session id is mandatory."; - String COURSE_ID_MISSING = "Course id is mandatory."; - String CONTENT_ID_MISSING = "Content id is mandatory."; - String VERSION_MISSING = "Version is mandatory."; - String COURSE_VERSION_MISSING = "Course version is mandatory."; - String CONTENT_VERSION_MISSING = "Content version is mandatory."; - String COURSE_DESCRIPTION_MISSING = "Description is mandatory."; - String COURSE_TOCURL_MISSING = "Course tocurl is mandatory."; - String EMAIL_MISSING = "Email is mandatory."; - String EMAIL_FORMAT = "Email is invalid."; - String URL_FORMAT_ERROR = "URL is invalid."; - String FIRST_NAME_MISSING = "First name is mandatory."; - String LANGUAGE_MISSING = "Language is mandatory."; - String PASSWORD_MISSING = "Password is mandatory."; - String ERROR_INVALID_CONFIG_PARAM_VALUE = "Invalid value {0} for config parameter {1}."; - String ERROR_MAX_SIZE_EXCEEDED = "Size of {0} exceeds max limit {1}"; - String PASSWORD_MIN_LENGHT = "Password should have at least 8 character."; - String PASSWORD_MAX_LENGHT = "Password should not be more than 12 character."; - String ORGANISATION_ID_MISSING = "Organization id is mandatory."; - String REQUIRED_DATA_ORG_MISSING = - "Organization Id or Provider with External Id values are required for the operation"; - String ORGANISATION_NAME_MISSING = "organization name is mandatory."; - String CHANNEL_SHOULD_BE_UNIQUE = - "Channel value already used by another organization. Provide different value for channel"; - String ERROR_DUPLICATE_ENTRY = "Value {0} for {1} is already in use."; - String INVALID_ORG_DATA = - "Given Organization Data doesn't exist in our records. Please provide a valid one"; - String INVALID_USR_DATA = - "Given User Data doesn't exist in our records. Please provide a valid one"; - String USR_DATA_VALIDATION_ERROR = "Please provide valid userId or userName and provider"; - String INVALID_ROOT_ORGANIZATION = "Root organization id is invalid"; - String INVALID_PARENT_ORGANIZATION_ID = "Parent organization id is invalid"; - String CYCLIC_VALIDATION_FAILURE = "The relation cannot be created as it is cyclic"; - String ENROLLMENT_START_DATE_MISSING = "Enrollment start date is mandatory."; - String COURSE_DURATION_MISSING = "Course duration is mandatory."; - String LOGIN_TYPE_MISSING = "Login type is required."; - String ERROR_INVALID_OTP = "Invalid OTP."; - String EMAIL_IN_USE = "Email already exists."; - String USERNAME_EMAIL_IN_USE = - "Username or Email is already in use. Please try with a different Username or Email."; - String KEY_CLOAK_DEFAULT_ERROR = "server error at sso."; - String USER_REG_UNSUCCESSFUL = "User Registration unsuccessful."; - String USER_UPDATE_UNSUCCESSFUL = "User update operation is unsuccessful."; - String INVALID_CREDENTIAL = "Invalid credential."; - String USERNAME_MISSING = "Username is mandatory."; - String USERNAME_IN_USE = "Username already exists."; - String USERID_MISSING = "UserId is mandatory."; - String ROLE_MISSING = "Role of the user is required"; - String MESSAGE_ID_MISSING = "Message id is mandatory."; - String USERNAME_CANNOT_BE_UPDATED = "UserName cann't be updated."; - String AUTH_TOKEN_MISSING = "Auth token is mandatory."; - String INVALID_AUTH_TOKEN = "Auth token is invalid.Please login again."; - String TIMESTAMP_REQUIRED = "TimeStamp is required."; - String PUBLISHED_COURSE_CAN_NOT_UPDATED = "Published course can't be updated."; - String SOURCE_MISSING = "Source is required."; - String SECTION_NAME_MISSING = "Section name is required."; - String SECTION_DATA_TYPE_MISSING = "Section data type missing."; - String SECTION_ID_REQUIRED = "Section id is required."; - String PAGE_NAME_REQUIRED = "Page name is required."; - String PAGE_ID_REQUIRED = "Page id is required."; - String INVALID_CONFIGURATION = "Invalid configuration data."; - String ASSESSMENT_ITEM_ID_REQUIRED = "Assessment item id is required."; - String ASSESSMENT_TYPE_REQUIRED = "Assessment type is required."; - String ATTEMPTED_DATE_REQUIRED = "Attempted data is required."; - String ATTEMPTED_ANSWERS_REQUIRED = "Attempted answers is required."; - String MAX_SCORE_REQUIRED = "Max score is required."; - String STATUS_CANNOT_BE_UPDATED = "status cann't be updated."; - String ATTEMPT_ID_MISSING_ERROR = "Please provide attempt id."; - String LOGIN_TYPE_ERROR = "provide login type as null."; - String INVALID_ORG_ID = "Org id does not exist ."; - String INVALID_ORG_STATUS = "Invalid org status for approve ."; - String INVALID_ORG_STATUS_TRANSITION = "Can not change state of Org to requeted state ."; - String ADDRESS_REQUIRED_ERROR = "Please provide address."; - String EDUCATION_REQUIRED_ERROR = "Please provide education details."; - String JOBDETAILS_REQUIRED_ERROR = "Please provide job details."; - String DB_INSERTION_FAIL = "DB insert operation failed."; - String DB_UPDATE_FAIL = "Db update operation failed."; - String DATA_ALREADY_EXIST = "data already exist."; - String INVALID_DATA = "Incorrect data."; - String INVALID_COURSE_ID = "Course doesnot exist. Please provide a valid course identifier"; - String PHONE_NO_REQUIRED_ERROR = "Phone number is required."; - String ORG_ID_MISSING = "Organization Id required."; - String ACTOR_CONNECTION_ERROR = "Service is not able to connect with actor."; - String USER_ALREADY_EXISTS = "User already exists for given {0}."; - String PAGE_ALREADY_EXIST = "page already exist with this Page Name and Org Code."; - String INVALID_USER_ID = "User Id does not exists in our records"; - String LOGIN_ID_MISSING = "loginId is required."; - String CONTENT_STATUS_MISSING_ERROR = "content status is required ."; - String ES_ERROR = "Something went wrong when processing data for search"; - String INVALID_PERIOD = "Time Period is invalid"; - String USER_NOT_FOUND = "user not found."; - String ID_REQUIRED_ERROR = "For deleting a record, Id is required."; - String DATA_TYPE_ERROR = "Data type of {0} should be {1}."; - String ERROR_ATTRIBUTE_CONFLICT = "Either pass attribute {0} or {1} but not both."; - String ADDRESS_ERROR = "In {0}, {1} is mandatory."; - String ADDRESS_TYPE_ERROR = "Please provide correct address Type."; - String NAME_OF_INSTITUTION_ERROR = "Please provide name of Institution."; - String EDUCATION_DEGREE_ERROR = "Education degree is required."; - String JOB_NAME_ERROR = "Job Name is required."; - String NAME_OF_ORGANISATION_ERROR = "Organization Name is required."; - String ROLES_MISSING = "user role is required."; - String EMPTY_ROLES_PROVIDED = "Roles cannot be empty."; - String CHANNEL_REG_FAILED = "Channel Registration failed."; - String INVALID_COURSE_CREATOR_ID = "Course creator id does not exist ."; - String USER_NOT_ASSOCIATED_TO_ROOT_ORG = - "User (ID = {0}) not associated to course batch creator root org."; - String SLUG_IS_NOT_UNIQUE = - "Please provide different channel value. This channel value already exist."; - String INVALID_CREATE_BADGE_ISSUER_DATA = "{0}"; - String INVALID_DATE_FORMAT = - "Invalid Date format . Date format should be : yyyy-MM-dd hh:mm:ss:SSSZ"; - String SRC_EXTERNAL_ID_ALREADY_EXIST = "PROVIDER WITH EXTERNAL ID ALREADY EXIST ."; - String USER_ALREADY_ENROLLED_COURSE = "User has already Enrolled this course ."; - String USER_NOT_ENROLLED_COURSE = "User is not enrolled to given course batch."; - String USER_ALREADY_COMPLETED_COURSE = "User already completed given course batch."; - String COURSE_BATCH_ALREADY_COMPLETED = "Course batch is already completed."; - String COURSE_BATCH_ENROLLMENT_DATE_ENDED = "Course batch enrollment date has ended."; - String EXISTING_ORG_MEMBER = "You already have a membership of this organization."; - String CONTENT_TYPE_ERROR = "Please add Content-Type header with value application/json"; - String INVALID_PROPERTY_ERROR = "Invalid property {0}."; - String USER_NAME_OR_ID_ERROR = "Please provide either username or userId."; - String USER_ACCOUNT_BLOCKED = "User account has been blocked ."; - String EMAIL_VERIFY_ERROR = "Please provide a verified email in order to create user."; - String PHONE_VERIFY_ERROR = - "Please provide a verified phone number in order to create/update user."; - String BULK_USER_UPLOAD_ERROR = - "Please provide either organization Id or external Id & provider value."; - String DATA_SIZE_EXCEEDED = "Maximum upload data size should be {0}"; - String INVALID_COLUMN_NAME = "Invalid column name."; - String USER_ALREADY_ACTIVE = "User is already active."; - String USER_ALREADY_INACTIVE = "User is already inactive."; - String ENROLMENT_TYPE_REQUIRED = "Enrolment type is mandatory."; - String ENROLMENT_TYPE_VALUE_ERROR = "EnrolmentType value must be either open or invite-only."; - String COURSE_BATCH_START_DATE_REQUIRED = "Batch start date is mandatory."; - String COURSE_BATCH_START_DATE_INVALID = - "Batch start date should be either today or future date."; - String DATE_FORMAT_ERRROR = "Date format error."; - String END_DATE_ERROR = "End date should be greater than start date."; - String ENROLLMENT_END_DATE_START_ERROR = - "Enrollment End date should be greater than course batch start date."; - String ENROLLMENT_END_DATE_END_ERROR = - "Enrollment End date should be lesser than course batch end date."; - String ENROLLMENT_END_DATE_UPDATE_ERROR = - "Invalid Enrollment End date. Please provide future date."; - String INVALID_CSV_FILE = "Please provide valid csv file."; - String INVALID_COURSE_BATCH_ID = "Invalid course batch id "; - String COURSE_BATCH_ID_MISSING = "Course batch Id required"; - String ENROLLMENT_TYPE_VALIDATION = "Enrollment type should be invite-only."; - String USER_NOT_BELONGS_TO_ANY_ORG = "User does not belongs to any org ."; - String INVALID_OBJECT_TYPE = "Invalid Object Type."; - String INVALID_PROGRESS_STATUS = - "Progress status value should be NOT_STARTED(0), STARTED(1), COMPLETED(2)."; - String COURSE_CREATED_FOR_NULL = "Batch does not belong to any organization ."; - String COURSE_BATCH_START_PASSED_DATE_INVALID = "This Batch already started."; - String UNABLE_TO_CONNECT_TO_EKSTEP = "Unable to connect to Ekstep Server"; - String UNABLE_TO_CONNECT_TO_ES = "Unable to connect to Elastic Search"; - String UNABLE_TO_PARSE_DATA = "Unable to parse the data"; - String INVALID_JSON = "Unable to process object to JSON/ JSON to Object"; - String EMPTY_CSV_FILE = "CSV file is Empty."; - String INVALID_ROOT_ORG_DATA = - "Root org doesn't exist for this Organization Id and channel {0}"; - String NO_DATA = "You have uploaded an empty file. Fill mandatory details and upload the file."; - String INVALID_CHANNEL = "Channel value is invalid."; - String INVALID_PROCESS_ID = "Invalid Process Id."; - String EMAIL_SUBJECT_ERROR = "Email Subject is mandatory."; - String EMAIL_BODY_ERROR = "Email Body is mandatory."; - String RECIPIENT_ADDRESS_ERROR = "Please send recipientEmails or recipientUserIds."; - String STORAGE_CONTAINER_NAME_MANDATORY = " Container name can not be null or empty."; - String CLOUD_SERVICE_ERROR = "Cloud storage service error."; - String BADGE_TYPE_ID_ERROR = "Badge type id is mandatory."; - String RECEIVER_ID_ERROR = "Receiver id is mandatory."; - String INVALID_RECEIVER_ID = "Receiver id is invalid."; - String INVALID_BADGE_ID = "Invalid badge type id."; - String USER_ORG_ASSOCIATION_ERROR = "User is already associated with another organization."; - String INVALID_ROLE = "Invalid role value provided in request."; - String INVALID_SALT = "Please provide salt value."; - String ORG_TYPE_MANDATORY = "Org Type name is mandatory."; - String ORG_TYPE_ALREADY_EXIST = - "Org type with this name already exist.Please provide some other name."; - String ORG_TYPE_ID_REQUIRED_ERROR = "Org Type Id is required."; - String TITLE_REQUIRED = "Title is required"; - String NOTE_REQUIRED = "No data to store for notes"; - String CONTENT_ID_ERROR = "Please provide content id or course id"; - String INVALID_TAGS = "Invalid data for tags"; - String NOTE_ID_INVALID = "Invalid note id"; - String USER_DATA_ENCRYPTION_ERROR = "Exception Occurred while encrypting user data."; - String INVALID_PHONE_NO_FORMAT = "Please provide a valid phone number."; - String INVALID_WEBPAGE_DATA = "Invalid webPage data"; - String INVALID_MEDIA_TYPE = "Invalid media type for webPage"; - String INVALID_WEBPAGE_URL = "Invalid URL for {0}."; - String INVALID_DATE_RANGE = "Date range should be between 3 Month."; - String INVALID_BATCH_END_DATE_ERROR = "Please provide valid End Date."; - String INVALID_BATCH_START_DATE_ERROR = "Please provide valid Start Date."; - String COURSE_BATCH_END_DATE_ERROR = "Batch has been closed."; - String COURSE_BATCH_IS_CLOSED_ERROR = "Batch has been closed."; - String CONFIIRM_PASSWORD_MISSING = "Confirm password is mandatory."; - String CONFIIRM_PASSWORD_EMPTY = "Confirm password can not be empty."; - String SAME_PASSWORD_ERROR = "New password can't be same as old password."; - String ENDORSED_USER_ID_REQUIRED = " Endorsed user id required ."; - String CAN_NOT_ENDORSE = "Can not endorse since both belong to different orgs ."; - String INVALID_ORG_TYPE_ID_ERROR = "Please provide valid orgTypeId."; - String INVALID_ORG_TYPE_ERROR = "Please provide valid orgType."; - String TABLE_OR_DOC_NAME_ERROR = "Please provide valid table or documentName."; - String EMAIL_OR_PHONE_MISSING = "Please provide either email or phone."; - //No need to indicate managedby is missing to user. - String EMAIL_OR_PHONE_OR_MANAGEDBY_MISSING = "Please provide either email or phone."; - String ONLY_EMAIL_OR_PHONE_OR_MANAGEDBY_REQUIRED = "Please provide only email or phone or managed by"; - String PHONE_ALREADY_IN_USE = "Phone already in use. Please provide different phone number."; - String INVALID_CLIENT_NAME = "Please provide unique valid client name"; - String INVALID_CLIENT_ID = "Please provide valid client id"; - String USER_PHONE_UPDATE_FAILED = "user phone update is failed."; - String ES_UPDATE_FAILED = "Data insertion to ES failed."; - String UPDATE_FAILED = "Data updation failed due to invalid Request"; - String INVALID_TYPE_VALUE = "Type value should be organisation OR location ."; - String INVALID_LOCATION_ID = "Please provide valid location id."; - String INVALID_HASHTAG_ID = - "Please provide different hashTagId.This HashTagId is associated with some other organization."; - String INVALID_USR_ORG_DATA = - "Given User Data doesn't belongs to this organization. Please provide a valid one."; - String INVALID_VISIBILITY_REQUEST = "Private and Public fields cannot be same."; - String INVALID_TOPIC_NAME = "Please provide a valid toipc."; - String INVALID_TOPIC_DATA = "Please provide valid notification data."; - String INVALID_NOTIFICATION_TYPE = "Please provide a valid notification type."; - String INVALID_NOTIFICATION_TYPE_SUPPORT = "Only notification type FCM is supported."; - String INVALID_PHONE_NUMBER = "Please send Phone and country code seprately."; - String INVALID_COUNTRY_CODE = "Please provide a valid country code."; - String ERROR_DUPLICATE_ENTRIES = "System contains duplicate entry for {0}."; - String LOCATION_ID_REQUIRED = "Please provide Location Id."; - String NOT_SUPPORTED = "Not Supported."; - String USERNAME_USERID_MISSING = "Please provide either userName or userId."; - String ISSUER_ID_REQUIRED = "Please provide issuer ID."; - String ISSUER_LIST_REQUIRED = "Please provide issuer list."; - String BADGE_ID_REQUIRED = "Please provide badge class ID."; - String BADGE_TYPE_REQUIRED = "Please provide badge class type."; - String INVALID_BADGE_TYPE = "Please provide valid badge class type."; - String INVALID_BADGE_SUBTYPE = "Please provide valid badge class subtype."; - String INVALID_BADGE_ROLE = "Please provide valid badge class role(s)."; - String BADGE_ROLES_REQUIRED = "Please provide authorised roles for badge class."; - String ROOT_ORG_ID_REQUIRED = "Please provide root organisation ID."; - String BADGE_NAME_REQUIRED = "Please provide badge class name."; - String BADGE_DESCRIPTION_REQUIRED = "Please provide badge class description."; - String BADGE_CRITERIA_REQUIRED = "Please provide badge class criteria."; - String BADGE_IMAGE_REQUIRED = "Please provide badge class image."; - String RECIPIENT_EMAIL_REQUIRED = "Please provide recipient email."; - String ASSERTION_EVIDENCE_REQUIRED = "Please provide valid assertion url as an evidence."; - String ASSERTION_ID_REQUIRED = "Please provide assertion ID."; - String RECIPIENT_ID_REQUIRED = "Please provide a recipient id."; - String RECIPIENT_TYPE_REQUIRED = "Please provide recipient type."; - String BADGING_SERVER_ERROR = "Badging server is down or on high load"; - String RESOURCE_NOT_FOUND = "Requested resource not found"; - String MAX_ALLOWED_SIZE_LIMIT_EXCEED = "Max allowed size is {0}"; - String SLUG_REQUIRED = "Slug is required ."; - String INVALID_ISSUER_ID = "Invalid issuer ID."; - String REVOCATION_REASON_REQUIRED = "Please provide revocation reason."; - String ALREADY_REVOKED = "Assertion is already revoked."; - String INVALID_RECIPIENT_TYPE = "Please provide a valid recipient type."; - String CUSTOM_CLIENT_ERROR = "Request failed. {0}"; - String CUSTOM_RESOURCE_NOT_FOUND_ERROR = "{0}"; - String CUSTOM_SERVER_ERROR = "{0}"; - String INACTIVE_USER = "User is Inactive. Please make it active to proceed."; - String USER_INACTIVE_FOR_THIS_ORG = - "User is Inactive for this org. Please make it active to proceed."; - String USER_UPDATE_FAILED_FOR_THIS_ORG = "user updation failed for this org."; - String PAGE_NOT_EXIST = "Requested page does not exist."; - String SECTION_NOT_EXIST = "Requested section does not exist."; - String ORG_NOT_EXIST = "Requested organisation does not exist."; - String INVALID_PAGE_SOURCE = "Invalid page source."; - String BADGE_SUBTYPE_REQUIRED = "Please provide badge class subtype."; - String LOCATION_TYPE_REQUIRED = "Location type required."; - String INVALID_REQUEST_DATA_FOR_LOCATION = "{0} field required."; - String ALREADY_EXISTS = "A {0} with {1} already exists. Please retry with a unique value."; - String INVALID_VALUE = "Invalid {0}: {1}. Valid values are: {2}."; - String PARENT_CODE_AND_PARENT_ID_MISSING = "Please provide either parentCode or parentId."; - String INVALID_PARAMETER = "Please provide valid {0}."; - String INVALID_PARENT_ID = "Please provide valid parentId."; - String INVALID_LOCATION_DELETE_REQUEST = - "One or more locations have a parent reference to given location and hence cannot be deleted."; - String LOCATION_TYPE_CONFLICTS = "Location type conflicts with its parent location type."; - String MANDATORY_PARAMETER_MISSING = "Mandatory parameter {0} is missing."; - String ERROR_MANDATORY_PARAMETER_EMPTY = "Mandatory parameter {0} is empty."; - String ERROR_NO_FRAMEWORK_FOUND = "No framework found."; - String INVALID_LOCN_ID = "Please provide valid locationId."; - String UPDATE_NOT_ALLOWED = "Update of {0} is not allowed."; - String MANDATORY_HEADER_MISSING = "Mandatory header {0} is missing."; - String INVALID_PARAMETER_VALUE = - "Invalid value {0} for parameter {1}. Please provide a valid value."; - String PARENT_NOT_ALLOWED = "For top level location, {0} is not allowed."; - String MISSING_FILE_ATTACHMENT = "Missing file attachment."; - String FILE_ATTACHMENT_SIZE_NOT_CONFIGURED = "File attachment max size is not configured."; - String EMPTY_FILE = "Attached file is empty."; - String INVALID_COLUMNS = "Invalid column: {0}. Valid columns are: {1}."; - String CONFLICTING_ORG_LOCATIONS = - "An organisation cannot be associated to two conflicting locations ({0}, {1}) at {2} level. "; - String UNABLE_TO_COMMUNICATE_WITH_ACTOR = "Unable to communicate with actor."; - String EMPTY_HEADER_LINE = "Missing header line in CSV file."; - String INVALID_REQUEST_PARAMETER = "Invalid parameter {0} in request."; - String ROOT_ORG_ASSOCIATION_ERROR = - "No root organisation found which is associated with given {0}."; - String OR_FORMAT = "{0} or {1}"; - String AND_FORMAT = "{0} and {1}"; - String DOT_FORMAT = "{0}.{1}"; - String DEPENDENT_PARAMETER_MISSING = "Missing parameter {0} which is dependent on {1}."; - String DEPENDENT_PARAMS_MISSING = "Missing parameter value in {0}."; - String EXTERNALID_NOT_FOUND = - "External ID (id: {0}, idType: {1}, provider: {2}) not found for given user."; - String PARSING_FAILED = "Failed to parse {0}."; - String EXTERNAL_ID_FORMAT = "externalId (id: {0}, idType: {1}, provider: {2})"; - String EXTERNALID_ASSIGNED_TO_OTHER_USER = - "External ID (id: {0}, idType: {1}, provider: {2}) already assigned to another user."; - String MANDATORY_CONFIG_PARAMETER_MISSING = - "Mandatory configuration parameter {0} missing which is required for service startup."; - String CASSANDRA_CONNECTION_ESTABLISHMENT_FAILED = - "Cassandra connection establishment failed in {0} mode."; - String COMMON_ATTRIBUTE_MISMATCH = "{0} mismatch of {1} and {2}"; - String MULTIPLE_COURSES_FOR_BATCH = "A batch cannot belong to multiple courses."; - String ERROR_JSON_TRANSFORM_INVALID_TYPE_CONFIG = - "JSON transformation failed as invalid type configuration found for field {0}."; - String ERROR_JSON_TRANSFORM_INVALID_DATE_FORMAT = - "JSON transformation failed as invalid date format configuration found for field {0}."; - String ERROR_JSON_TRANSFORM_INVALID_INPUT = - "JSON transformation failed as invalid input provided for field {0}."; - String ERROR_JSON_TRANSFORM_INVALID_ENUM_INPUT = - "JSON transformation failed as invalid enum input provided for field {0}."; - String ERROR_JSON_TRANSFORM_ENUM_VALUES_EMPTY = - "JSON transformation failed as enum values is empty in configuration for field {0}."; - String ERROR_JSON_TRANSFORM_BASIC_CONFIG_MISSING = - "JSON transformation failed as mandatory configuration (toFieldName, fromType or toType) is missing for field {0}."; - String ERROR_JSON_TRANSFORM_INVALID_FILTER_CONFIG = - "JSON transformation failed as invalid filter configuration found for field {0}."; - String ERROR_LOAD_CONFIG = "Loading failed for configuration file {0}."; - String ERROR_REGISTRY_CLIENT_CREATION = "Registry client creation failed."; - String ERROR_REGISTRY_ADD_ENTITY = "Registry add entity API failed."; - String ERROR_REGISTRY_READ_ENTITY = "Registry read entity API failed."; - String ERROR_REGISTRY_UPDATE_ENTITY = "Registry update entity API failed."; - String ERROR_REGISTRY_DELETE_ENTITY = "Registry delete entity API failed."; - String ERROR_REGISTRY_PARSE_RESPONSE = "Error while parsing response from registry."; - String ERROR_REGISTRY_ENTITY_TYPE_BLANK = "Request failed as entity type is blank."; - String ERROR_REGISTRY_ENTITY_ID_BLANK = "Request failed as entity id is not provided."; - String ERROR_REGISTRY_ACCESS_TOKEN_BLANK = - "Request failed as user access token is not provided."; - String DUPLICATE_EXTERNAL_IDS = - "Duplicate external IDs for given idType ({0}) and provider ({1})."; - String INVALID_DUPLICATE_VALUE = "Values for {0} and {1} cannot be same."; - String EMAIL_RECIPIENTS_EXCEEDS_MAX_LIMIT = - "Email notification is not sent as the number of recipients exceeded configured limit ({0})."; - String NO_EMAIL_RECIPIENTS = - "Email notification is not sent as the number of recipients is zero."; - String PARAMETER_MISMATCH = "Mismatch of given parameters: {0}."; - String FORBIDDEN = "You are forbidden from accessing specified resource."; - String ERROR_CONFIG_LOAD_EMPTY_STRING = - "Loading {0} configuration failed as empty string is passed as parameter."; - String ERROR_CONFIG_LOAD_PARSE_STRING = - "Loading {0} configuration failed due to parsing error."; - String ERROR_CONFIG_LOAD_EMPTY_CONFIG = "Loading {0} configuration failed."; - String ERROR_CONFLICTING_FIELD_CONFIGURATION = - "Field {0} in {1} configuration is conflicting in {2} and {3}."; - String ERROR_SYSTEM_SETTING_NOT_FOUND = "System Setting not found for id: {0}"; - String ERROR_NO_ROOT_ORG_ASSOCIATED = "Not able to associate with root org"; - String ERROR_INACTIVE_CUSTODIAN_ORG = "Custodian organisation is inactive."; - String ERROR_UNSUPPORTED_CLOUD_STORAGE = "Unsupported cloud storage type {0}."; - String ERROR_UNSUPPORTED_FIELD = "Unsupported field {0}."; - String ERROR_GENERATE_DOWNLOAD_LINK = "Error in generating download link."; - String ERROR_DOWNLOAD_LINK_UNAVAILABLE = "Download link is unavailable."; - String ERROR_SAVING_STORAGE_DETAILS = "Error saving storage details for download link."; - String ERROR_CSV_NO_DATA_ROWS = "No data rows in CSV."; - String ERROR_INACTIVE_ORG = "Organisation corresponding to given {0} ({1}) is inactive."; - String ERROR_CONFLICTING_VALUES = "Conflicting values for {0} ({1}) and {2} ({3})."; - String ERROR_CONFLICTING_ROOT_ORG_ID = - "Root organisation ID of API user is conflicting with that of specified organisation ID."; - String ERROR_UPDATE_SETTING_NOT_ALLOWED = "Update of system setting {0} is not allowed."; - String ERROR_CREATING_FILE = "Error Reading File"; - String ERROR_PROCESSING_REQUEST = "Something went wrong while Processing Request"; - String ERROR_UNAVAILABLE_CERTIFICATE = "Certificate is unavailable"; - String INVALID_TEXTBOOK = "Invalid Textbook. Please Provide Valid Textbook Identifier."; - String CSV_ROWS_EXCEEDS = "Number of rows in csv file is more than "; - String INVALID_TEXTBOOK_NAME = - "Textbook Name given in the file doesn’t match current Textbook name. Please check and upload again."; - String DUPLICATE_ROWS = - "Duplicate Textbook node found. Please check and upload again. Row number "; - String REQUIRED_HEADER_MISSING = "Required set of header missing: "; - String REQUIRED_FIELD_MISSING = - "Required columns missing. Please check and upload again. Mandatory fields are: "; - String BLANK_CSV_DATA = - "Did not find any Table of Contents data. Please check and upload again."; - String EXCEEDS_MAX_CHILDREN = "Number of first level units is more than allowed."; - String TEXTBOOK_CHILDREN_EXISTS = "Textbook is already having children."; - String TEXTBOOK_UPDATE_FAILURE = "Textbook could not be updated."; - String TEXTBOOK_CHILDREN_NOT_EXISTS = "No Children Exists for given TextBook."; - String TEXTBOOK_NOT_FOUND = "Textbook not found."; - String ERROR_PROCESSING_FILE = - "Something Went Wrong While Reading File. Please Check The File."; - String ERR_FILE_NOT_FOUND = "File not found. Please select valid file and upload."; - String ERROR_TB_UPDATE = "Error while updating the textbook"; - String ERROR_INVALID_PARAMETER_SIZE = - "Parameter {0} is of invalid size (expected: {1}, actual: {2})."; - String INVALID_PAGE_SECTION = "Page section associated with the page is invalid."; - String ERROR_RATE_LIMIT_EXCEEDED = - "Your per {0} rate limit has exceeded. You can retry after some time."; - String ERROR_INVALID_DIAL_CODE = "The given QR code {0} is not valid."; - String ERROR_INVALID_TOPIC = "Topic {0} not found in the framework. Please check and correct."; - String ERROR_DIAL_CODE_DUPLICATE_ENTRY = - "QR code {0} is associated with more than one section {1}."; - String ERROR_DIAL_CODE_ALREADY_ASSOCIATED = - "QR code {0} is already associated with a section {1} in the textbook"; - String DIAL_CODE_LINKING_FAILED = "QR code linking failed."; - String ERROR_TEXTBOOK_UPDATE = "{0}"; - - String ERROR_INVALID_LINKED_CONTENT_ID = "Linked Content {0} is not valid at row {1}."; - String ERROR_DUPLICATE_LINKED_CONTENT = "Duplicate content {0} at row {1}."; - String TEACHER_CANNOT_BELONG_TO_CUSTODIAN_ORG = - "User type teacher is not supported for custodian organisation users"; - String ERROR_DUPLICATE_QR_CODE_ENTRY = - "CSV file contains more than one entry for {0}. Correct the duplicate entry and try again."; - String ERROR_INVALID_TEXTBOOK_UNIT_ID = "Invalid textbook unit id {0} for texbook."; - String INVALID_REQUEST_TIMEOUT = "Invalid request timeout value {0}."; - String ERROR_USER_UPDATE_PASSWORD = "User is created but password couldn't be updated."; - String ERROR_BGMS_MISMATCH = "Mismatch in {0} at row - {1}"; - String ERROR_USER_MIGRATION_FAILED = "User migration failed."; - String EMPTY_CONTENTS_FOR_UPDATE_BATCH_STATUS = - "Contents should not be empty for batch status update."; - String IDENTIFIER_VALIDATION_FAILED = - "Valid identifier is not present in List, Valid supported identifiers are "; - String FROM_ACCOUNT_ID_MISSING = "From Account id is mandatory."; - String TO_ACCOUNT_ID_MISSING = "To Account id is mandatory."; - String FROM_ACCOUNT_ID_NOT_EXISTS = "From Account id not exists"; - String PARAM_NOT_MATCH = "%s-NOT-MATCH"; - String MANDATORY_HEADER_PARAMETER_MISSING = "Mandatory header parameter {0} is missing."; - String RECOVERY_PARAM_MATCH_EXCEPTION = "{0} could not be same as {1}"; - String ERROR_USER_HAS_NOT_CREATED_ANY_COURSE = - "User hasn't created any course, or may not have a creator role"; - String ERROR_UPLOAD_QRCODE_CSV_FAILED = "Uploading the html file to cloud storage has failed."; - String ERROR_NO_DIALCODES_LINKED = "No dialcodes are linked to any courses created by user(s)"; - String EVENTS_DATA_MISSING = "Events array is mandatory"; - String ACCOUNT_NOT_FOUND = "Account not found."; - String INVALID_EXT_USER_ID = "provided ext user id {0} is incorrect"; - String USER_MIGRATION_FAILED = "user is failed to migrate"; - String INVALID_ELEMENT_IN_LIST = - "Invalid value supplied for parameter {0}.Supported values are {1}"; - String INVALID_PASSWORD = - "Password must contain a minimum of 8 characters including numerals, lower and upper case alphabets and special characters"; - String OTP_VERIFICATION_FAILED = "OTP verification failed. Remaining attempt count is {0}."; - String SERVICE_UNAVAILABLE = "SERVICE UNAVAILABLE"; - String MISSING_MESSAGE = "Required fields for create course are missing. {0}"; - String MANAGED_BY_NOT_ALLOWED = "managedBy cannot be updated."; - } - - interface Key { - String UNAUTHORIZED_USER = "UNAUTHORIZED_USER"; - String INVALID_USER_CREDENTIALS = "INVALID_USER_CREDENTIALS"; - String OPERATION_TIMEOUT = "PROCESS_EXE_TIMEOUT"; - String INVALID_OPERATION_NAME = "INVALID_OPERATION_NAME"; - String INVALID_REQUESTED_DATA = "INVALID_REQUESTED_DATA"; - String CONSUMER_ID_MISSING_ERROR = "CONSUMER_ID_REQUIRED_ERROR"; - String CONSUMER_ID_INVALID_ERROR = "CONSUMER_ID_INVALID_ERROR"; - String DEVICE_ID_MISSING_ERROR = "DEVICE_ID_REQUIRED_ERROR"; - String CONTENT_ID_INVALID_ERROR = "CONTENT_ID_INVALID_ERROR"; - String CONTENT_ID_MISSING_ERROR = "CONTENT_ID_REQUIRED_ERROR"; - String COURSE_ID_MISSING_ERROR = "COURSE_ID_REQUIRED_ERROR"; - String API_KEY_MISSING_ERROR = "API_KEY_REQUIRED_ERROR"; - String API_KEY_INVALID_ERROR = "API_KEY_INVALID_ERROR"; - String INTERNAL_ERROR = "INTERNAL_ERROR"; - String COURSE_NAME_MISSING = "COURSE_NAME_REQUIRED_ERROR"; - String SUCCESS_MESSAGE = "SUCCESS"; - String SESSION_ID_MISSING = "SESSION_ID_REQUIRED_ERROR"; - String COURSE_ID_MISSING = "COURSE_ID_REQUIRED_ERROR"; - String CONTENT_ID_MISSING = "CONTENT_ID_REQUIRED_ERROR"; - String VERSION_MISSING = "VERSION_REQUIRED_ERROR"; - String COURSE_VERSION_MISSING = "COURSE_VERSION_REQUIRED_ERROR"; - String CONTENT_VERSION_MISSING = "CONTENT_VERSION_REQUIRED_ERROR"; - String COURSE_DESCRIPTION_MISSING = "COURSE_DESCRIPTION_REQUIRED_ERROR"; - String COURSE_TOCURL_MISSING = "COURSE_TOCURL_REQUIRED_ERROR"; - String EMAIL_MISSING = "EMAIL_ID_REQUIRED_ERROR"; - String EMAIL_FORMAT = "EMAIL_FORMAT_ERROR"; - String URL_FORMAT_ERROR = "URL_FORMAT_ERROR"; - String FIRST_NAME_MISSING = "FIRST_NAME_REQUIRED_ERROR"; - String LANGUAGE_MISSING = "LANGUAGE_REQUIRED_ERROR"; - String PASSWORD_MISSING = "PASSWORD_REQUIRED_ERROR"; - String PASSWORD_MIN_LENGHT = "PASSWORD_MIN_LENGHT_ERROR"; - String PASSWORD_MAX_LENGHT = "PASSWORD_MAX_LENGHT_ERROR"; - String ORGANISATION_ID_MISSING = "ORGANIZATION_ID_MISSING"; - String REQUIRED_DATA_ORG_MISSING = "REQUIRED_DATA_MISSING"; - String ORGANISATION_NAME_MISSING = "ORGANIZATION_NAME_MISSING"; - String CHANNEL_SHOULD_BE_UNIQUE = "CHANNEL_SHOULD_BE_UNIQUE"; - String ERROR_DUPLICATE_ENTRY = "ERROR_DUPLICATE_ENTRY"; - String INVALID_ORG_DATA = "INVALID_ORGANIZATION_DATA"; - String INVALID_USR_DATA = "INVALID_USER_DATA"; - String USR_DATA_VALIDATION_ERROR = "USER_DATA_VALIDATION_ERROR"; - String INVALID_ROOT_ORGANIZATION = "INVALID ROOT ORGANIZATION"; - String INVALID_PARENT_ORGANIZATION_ID = "INVALID_PARENT_ORGANIZATION_ID"; - String CYCLIC_VALIDATION_FAILURE = "CYCLIC_VALIDATION_FAILURE"; - String ENROLLMENT_START_DATE_MISSING = "ENROLLMENT_START_DATE_MISSING"; - String COURSE_DURATION_MISSING = "COURSE_DURATION_MISSING"; - String LOGIN_TYPE_MISSING = "LOGIN_TYPE_MISSING"; - String EMAIL_IN_USE = "EMAIL_IN_USE"; - String USERNAME_EMAIL_IN_USE = "USERNAME_EMAIL_IN_USE"; - String KEY_CLOAK_DEFAULT_ERROR = "KEY_CLOAK_DEFAULT_ERROR"; - String USER_REG_UNSUCCESSFUL = "USER_REG_UNSUCCESSFUL"; - String USER_UPDATE_UNSUCCESSFUL = "USER_UPDATE_UNSUCCESSFUL"; - String INVALID_CREDENTIAL = "INVALID_CREDENTIAL"; - String USERNAME_MISSING = "USERNAME_MISSING"; - String USERNAME_IN_USE = "USERNAME_IN_USE"; - String USERID_MISSING = "USERID_MISSING"; - String ROLE_MISSING = "ROLE_MISSING"; - String MESSAGE_ID_MISSING = "MESSAGE_ID_MISSING"; - String USERNAME_CANNOT_BE_UPDATED = "USERNAME_CANNOT_BE_UPDATED"; - String AUTH_TOKEN_MISSING = "X_Authenticated_Userid_MISSING"; - String INVALID_AUTH_TOKEN = "INVALID_AUTH_TOKEN"; - String TIMESTAMP_REQUIRED = "TIMESTAMP_REQUIRED"; - String PUBLISHED_COURSE_CAN_NOT_UPDATED = "PUBLISHED_COURSE_CAN_NOT_UPDATED"; - String SOURCE_MISSING = "SOURCE_MISSING"; - String SECTION_NAME_MISSING = "SECTION_NAME_MISSING"; - String SECTION_DATA_TYPE_MISSING = "SECTION_DATA_TYPE_MISSING"; - String SECTION_ID_REQUIRED = "SECTION_ID_REQUIRED"; - String PAGE_NAME_REQUIRED = "PAGE_NAME_REQUIRED"; - String PAGE_ID_REQUIRED = "PAGE_ID_REQUIRED"; - String INVALID_CONFIGURATION = "INVALID_CONFIGURATION"; - String ASSESSMENT_ITEM_ID_REQUIRED = "ASSESSMENT_ITEM_ID_REQUIRED"; - String ASSESSMENT_TYPE_REQUIRED = "ASSESSMENT_TYPE_REQUIRED"; - String ATTEMPTED_DATE_REQUIRED = "ATTEMPTED_DATE_REQUIRED"; - String ATTEMPTED_ANSWERS_REQUIRED = "ATTEMPTED_ANSWERS_REQUIRED"; - String MAX_SCORE_REQUIRED = "MAX_SCORE_REQUIRED"; - String STATUS_CANNOT_BE_UPDATED = "STATUS_CANNOT_BE_UPDATED"; - String ATTEMPT_ID_MISSING_ERROR = "ATTEMPT_ID_REQUIRED_ERROR"; - String LOGIN_TYPE_ERROR = "LOGIN_TYPE_ERROR"; - String INVALID_ORG_ID = "INVALID_ORG_ID"; - String INVALID_ORG_STATUS = "INVALID_ORG_STATUS"; - String INVALID_ORG_STATUS_TRANSITION = "INVALID_ORG_STATUS_TRANSITION"; - String ADDRESS_REQUIRED_ERROR = "ADDRESS_REQUIRED_ERROR"; - String EDUCATION_REQUIRED_ERROR = "EDUCATION_REQUIRED_ERROR"; - String JOBDETAILS_REQUIRED_ERROR = "JOBDETAILS_REQUIRED_ERROR"; - String DB_INSERTION_FAIL = "DB_INSERTION_FAIL"; - String DB_UPDATE_FAIL = "DB_UPDATE_FAIL"; - String DATA_ALREADY_EXIST = "DATA_ALREADY_EXIST"; - String INVALID_DATA = "INVALID_DATA"; - String INVALID_COURSE_ID = "INVALID_COURSE_ID"; - String PHONE_NO_REQUIRED_ERROR = "PHONE_NO_REQUIRED_ERROR"; - String ORG_ID_MISSING = "ORG_ID_MISSING"; - String ACTOR_CONNECTION_ERROR = "ACTOR_CONNECTION_ERROR"; - String USER_ALREADY_EXISTS = "USER_ALREADY_EXISTS"; - String PAGE_ALREADY_EXIST = "PAGE_ALREADY_EXIST"; - String INVALID_USER_ID = "INVALID_USER_ID"; - String LOGIN_ID_MISSING = "LOGIN_ID_MISSING"; - String CONTENT_STATUS_MISSING_ERROR = "CONTENT_STATUS_MISSING_ERROR"; - String ES_ERROR = "ELASTICSEARCH_ERROR"; - String INVALID_PERIOD = "INVALID_PERIOD"; - String USER_NOT_FOUND = "USER_NOT_FOUND"; - String ID_REQUIRED_ERROR = "ID_REQUIRED_ERROR"; - String DATA_TYPE_ERROR = "DATA_TYPE_ERROR"; - String ERROR_ATTRIBUTE_CONFLICT = "ERROR_ATTRIBUTE_CONFLICT"; - String ADDRESS_ERROR = "ADDRESS_ERROR"; - String ADDRESS_TYPE_ERROR = "ADDRESS_TYPE_ERROR"; - String NAME_OF_INSTITUTION_ERROR = "NAME_OF_INSTITUTION_ERROR"; - String EDUCATION_DEGREE_ERROR = "EDUCATION_DEGREE_ERROR"; - String JOB_NAME_ERROR = "JOB_NAME_ERROR"; - String NAME_OF_ORGANISATION_ERROR = "NAME_OF_ORGANIZATION_ERROR"; - String ROLES_MISSING = "ROLES_REQUIRED_ERROR"; - String EMPTY_ROLES_PROVIDED = "EMPTY_ROLES_PROVIDED"; - String INVALID_DATE_FORMAT = "INVALID_DATE_FORMAT"; - String SRC_EXTERNAL_ID_ALREADY_EXIST = "SRC_EXTERNAL_ID_ALREADY_EXIST"; - String USER_ALREADY_ENROLLED_COURSE = "USER_ALREADY_ENROLLED_COURSE"; - String USER_NOT_ENROLLED_COURSE = "USER_NOT_ENROLLED_COURSE"; - String USER_ALREADY_COMPLETED_COURSE = "USER_ALREADY_COMPLETED_COURSE"; - String COURSE_BATCH_ALREADY_COMPLETED = "COURSE_BATCH_ALREADY_COMPLETED"; - String COURSE_BATCH_ENROLLMENT_DATE_ENDED = "COURSE_BATCH_ENROLLMENT_DATE_ENDED"; - String CONTENT_TYPE_ERROR = "CONTENT_TYPE_ERROR"; - String INVALID_PROPERTY_ERROR = "INVALID_PROPERTY_ERROR"; - String USER_NAME_OR_ID_ERROR = "USER_NAME_OR_ID_ERROR"; - String USER_ACCOUNT_BLOCKED = "USER_ACCOUNT_BLOCKED"; - String EMAIL_VERIFY_ERROR = "EMAIL_VERIFY_ERROR"; - String PHONE_VERIFY_ERROR = "PHONE_VERIFY_ERROR"; - String BULK_USER_UPLOAD_ERROR = "BULK_USER_UPLOAD_ERROR"; - String DATA_SIZE_EXCEEDED = "DATA_SIZE_EXCEEDED"; - String INVALID_COLUMN_NAME = "INVALID_COLUMN_NAME"; - String USER_ALREADY_ACTIVE = "USER_ALREADY_ACTIVE"; - String USER_ALREADY_INACTIVE = "USER_ALREADY_INACTIVE"; - String ENROLMENT_TYPE_REQUIRED = "ENROLMENT_TYPE_REQUIRED"; - String ENROLMENT_TYPE_VALUE_ERROR = "ENROLMENT_TYPE_VALUE_ERROR"; - String COURSE_BATCH_START_DATE_REQUIRED = "COURSE_BATCH_START_DATE_REQUIRED"; - String COURSE_BATCH_START_DATE_INVALID = "COURSE_BATCH_START_DATE_INVALID"; - String DATE_FORMAT_ERRROR = "DATE_FORMAT_ERRROR"; - String END_DATE_ERROR = "END_DATE_ERROR"; - String ENROLLMENT_END_DATE_START_ERROR = "ENROLLMENT_END_DATE_START_ERROR"; - String ENROLLMENT_END_DATE_END_ERROR = "ENROLLMENT_END_DATE_END_ERROR"; - String ENROLLMENT_END_DATE_UPDATE_ERROR = "ENROLLMENT_END_DATE_UPDATE_ERROR"; - String INVALID_CSV_FILE = "INVALID_CSV_FILE"; - String INVALID_COURSE_BATCH_ID = "INVALID_COURSE_BATCH_ID"; - String COURSE_BATCH_ID_MISSING = "COURSE_BATCH_ID_MISSING"; - String ENROLLMENT_TYPE_VALIDATION = "ENROLLMENT_TYPE_VALIDATION"; - String COURSE_CREATED_FOR_NULL = "COURSE_CREATED_FOR_NULL"; - String USER_NOT_BELONGS_TO_ANY_ORG = "USER_NOT_BELONGS_TO_ANY_ORG"; - String INVALID_OBJECT_TYPE = "INVALID_OBJECT_TYPE"; - String INVALID_PROGRESS_STATUS = "INVALID_PROGRESS_STATUS"; - String COURSE_BATCH_START_PASSED_DATE_INVALID = "COURSE_BATCH_START_PASSED_DATE_INVALID"; - String UNABLE_TO_CONNECT_TO_EKSTEP = "UNABLE_TO_CONNECT_TO_EKSTEP"; - String UNABLE_TO_CONNECT_TO_ES = "UNABLE_TO_CONNECT_TO_ES"; - String UNABLE_TO_PARSE_DATA = "UNABLE_TO_PARSE_DATA"; - String INVALID_JSON = "INVALID_JSON"; - String EMPTY_CSV_FILE = "EMPTY_CSV_FILE"; - String INVALID_ROOT_ORG_DATA = "INVALID_ROOT_ORG_DATA"; - String NO_DATA = "NO_DATA"; - String INVALID_CHANNEL = "INVALID_CHANNEL"; - String INVALID_PROCESS_ID = "INVALID_PROCESS_ID"; - String EMAIL_SUBJECT_ERROR = "EMAIL_SUBJECT_ERROR"; - String EMAIL_BODY_ERROR = "EMAIL_BODY_ERROR"; - String RECIPIENT_ADDRESS_ERROR = "RECIPIENT_ADDRESS_ERROR"; - String ISSUER_ID_REQUIRED = "ISSUER_ID_REQUIRED"; - String ISSUER_LIST_REQUIRED = "ISSUER_LIST_REQUIRED"; - String BADGE_ID_REQUIRED = "BADGE_ID_REQUIRED"; - String ROOT_ORG_ID_REQUIRED = "BADGE_ROOT_ORG_ID_REQUIRED"; - String BADGE_TYPE_REQUIRED = "BADGE_TYPE_REQUIRED"; - String INVALID_BADGE_TYPE = "INVALID_BADGE_TYPE"; - String INVALID_BADGE_SUBTYPE = "INVALID_BADGE_SUBTYPE"; - String INVALID_BADGE_ROLE = "INVALID_BADGE_ROLE"; - String BADGE_ROLES_REQUIRED = "BADGE_ROLES_REQUIRED"; - String BADGE_NAME_REQUIRED = "BADGE_NAME_REQUIRED"; - String BADGE_DESCRIPTION_REQUIRED = "BADGE_DESCRIPTION_REQUIRED"; - String BADGE_CRITERIA_REQUIRED = "BADGE_CRITERIA_REQUIRED"; - String BADGE_IMAGE_REQUIRED = "BADGE_IMAGE_REQUIRED"; - String RECIPIENT_EMAIL_REQUIRED = "RECIPIENT_EMAIL_REQUIRED"; - String ASSERTION_EVIDENCE_REQUIRED = "ASSERTION_EVIDENCE_REQUIRED"; - String ASSERTION_ID_REQUIRED = "ASSERTION_ID_REQUIRED"; - String STORAGE_CONTAINER_NAME_MANDATORY = "STORAGE_CONTAINER_NAME_MANDATORY"; - String USER_ORG_ASSOCIATION_ERROR = "USER_ORG_ASSOCIATION_ERROR"; - String CLOUD_SERVICE_ERROR = "CLOUD_SERVICE_ERROR"; - String BADGE_TYPE_ID_ERROR = "BADGE_TYPE_ID_ERROR"; - String RECEIVER_ID_ERROR = "RECEIVER_ID_ERROR"; - String INVALID_RECEIVER_ID = "INVALID_RECEIVER_ID"; - String INVALID_BADGE_ID = "INVALID_BADGE_ID"; - String INVALID_ROLE = "INVALID_ROLE"; - String INVALID_SALT = "INVALID_SALT"; - String ORG_TYPE_MANDATORY = "ORG_TYPE_MANDATORY"; - String ORG_TYPE_ALREADY_EXIST = "ORG_TYPE_ALREADY_EXIST"; - String ORG_TYPE_ID_REQUIRED_ERROR = "ORG_TYPE_ID_REQUIRED_ERROR"; - String TITLE_REQUIRED = "TITLE_REQUIRED"; - String NOTE_REQUIRED = "NOTE_REQUIRED"; - String CONTENT_ID_ERROR = "CONTENT_ID_OR_COURSE_ID_REQUIRED"; - String INVALID_TAGS = "INVALID_TAGS"; - String NOTE_ID_INVALID = "NOTE_ID_INVALID"; - String USER_DATA_ENCRYPTION_ERROR = "USER_DATA_ENCRYPTION_ERROR"; - String INVALID_PHONE_NO_FORMAT = "INVALID_PHONE_NO_FORMAT"; - String INVALID_WEBPAGE_DATA = "INVALID_WEBPAGE_DATA"; - String INVALID_MEDIA_TYPE = "INVALID_MEDIA_TYPE"; - String INVALID_WEBPAGE_URL = "INVALID_WEBPAGE_URL"; - String INVALID_DATE_RANGE = "INVALID_DATE_RANGE"; - String INVALID_BATCH_END_DATE_ERROR = "INVALID_BATCH_END_DATE_ERROR"; - String INVALID_BATCH_START_DATE_ERROR = "INVALID_BATCH_START_DATE_ERROR"; - String COURSE_BATCH_END_DATE_ERROR = "COURSE_BATCH_END_DATE_ERROR"; - String COURSE_BATCH_IS_CLOSED_ERROR = "COURSE_BATCH_IS_CLOSED_ERROR"; - String CONFIIRM_PASSWORD_MISSING = "CONFIIRM_PASSWORD_MISSING"; - String CONFIIRM_PASSWORD_EMPTY = "CONFIIRM_PASSWORD_EMPTY"; - String SAME_PASSWORD_ERROR = "SAME_PASSWORD_ERROR"; - String ENDORSED_USER_ID_REQUIRED = "ENDORSED_USER_ID_REQUIRED"; - String CAN_NOT_ENDORSE = "CAN_NOT_ENDORSE"; - String INVALID_ORG_TYPE_ID_ERROR = "INVALID_ORG_TYPE_ID_ERROR"; - String INVALID_ORG_TYPE_ERROR = "INVALID_ORG_TYPE_ERROR"; - String TABLE_OR_DOC_NAME_ERROR = "TABLE_OR_DOC_NAME_ERROR"; - String EMAIL_OR_PHONE_MISSING = "EMAIL_OR_PHONE_MISSING"; - String EMAIL_OR_PHONE_OR_MANAGEDBY_MISSING = "EMAIL_OR_PHONE_OR_MANAGEDBY_MISSING"; - String ONLY_EMAIL_OR_PHONE_OR_MANAGEDBY_REQUIRED = "ONLY_EMAIL_OR_PHONE_OR_MANAGEDBY_REQUIRED"; - String PHONE_ALREADY_IN_USE = "PHONE_ALREADY_IN_USE"; - String INVALID_CLIENT_NAME = "INVALID_CLIENT_NAME"; - String INVALID_CLIENT_ID = "INVALID_CLIENT_ID"; - String USER_PHONE_UPDATE_FAILED = "USER_PHONE_UPDATE_FAILED"; - String ES_UPDATE_FAILED = "ES_UPDATE_FAILED"; - String UPDATE_FAILED = "UPDATE_FAILED"; - String INVALID_TYPE_VALUE = "INVALID_TYPE_VALUE"; - String INVALID_LOCATION_ID = "INVALID_LOCATION_ID"; - String INVALID_HASHTAG_ID = "INVALID_HASHTAG_ID"; - String INVALID_USR_ORG_DATA = "INVALID_USR_ORG_DATA"; - String INVALID_VISIBILITY_REQUEST = "INVALID_VISIBILITY_REQUEST"; - String INVALID_TOPIC_NAME = "INVALID_TOPIC_NAME"; - String INVALID_TOPIC_DATA = "INVALID_TOPIC_DATA"; - String INVALID_NOTIFICATION_TYPE = "INVALID_NOTIFICATION_TYPE"; - String INVALID_NOTIFICATION_TYPE_SUPPORT = "INVALID_NOTIFICATION_TYPE_SUPPORT"; - String INVALID_PHONE_NUMBER = "INVALID_PHONE_NUMBER"; - String INVALID_COUNTRY_CODE = "INVALID_COUNTRY_CODE"; - String LOCATION_ID_REQUIRED = "LOCATION_ID_REQUIRED"; - String NOT_SUPPORTED = "NOT_SUPPORTED"; - String USERNAME_USERID_MISSING = "USERNAME_USERID_MISSING"; - String CHANNEL_REG_FAILED = "CHANNEL_REG_FAILED"; - String INVALID_COURSE_CREATOR_ID = "INVALID_COURSE_CREATOR_ID"; - String USER_NOT_ASSOCIATED_TO_ROOT_ORG = "USER_NOT_ASSOCIATED_TO_ROOT_ORG"; - String SLUG_IS_NOT_UNIQUE = "SLUG_IS_NOT_UNIQUE"; - String INVALID_CREATE_BADGE_ISSUER_DATA = "INVALID_CREATE_BADGE_ISSUER_DATA"; - String RECIPIENT_ID_REQUIRED = "RECIPIENT_ID_REQUIRED"; - String RECIPIENT_TYPE_REQUIRED = "RECIPIENT_TYPE_REQUIRED"; - String BADGING_SERVER_ERROR = "BADGING_SERVER_ERROR"; - String RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND"; - String MAX_ALLOWED_SIZE_LIMIT_EXCEED = "MAX_ALLOWED_SIZE_LIMIT_EXCEED"; - String SLUG_REQUIRED = "SLUG_REQUIRED"; - String INVALID_ISSUER_ID = "INVALID_ISSUER_ID"; - String REVOCATION_REASON_REQUIRED = "REVOCATION_REASON_REQUIRED"; - String ALREADY_REVOKED = "ALREADY_REVOKED"; - String INVALID_RECIPIENT_TYPE = "INVALID_RECIPIENT_TYPE"; - String CUSTOM_CLIENT_ERROR = "CLIENT_ERROR"; - String CUSTOM_RESOURCE_NOT_FOUND_ERROR = "RESOURCE_NOT_FOUND"; - String CUSTOM_SERVER_ERROR = "SERVER_ERROR"; - String INACTIVE_USER = "INACTIVE_USER"; - String USER_INACTIVE_FOR_THIS_ORG = "USER_INACTIVE_FOR_THIS_ORG"; - String USER_UPDATE_FAILED_FOR_THIS_ORG = "USER_UPDATE_FAILED_FOR_THIS_ORG"; - String PREFERENCE_KEY_MISSING = "PREFERENCE_KEY_MISSING"; - String PAGE_NOT_EXIST = "PAGE_NOT_EXIST"; - String SECTION_NOT_EXIST = "SECTION_NOT_EXIST"; - String ORG_NOT_EXIST = "ORG_NOT_EXIST"; - String INVALID_PAGE_SOURCE = "INVALID_PAGE_SOURCE"; - String BADGE_SUBTYPE_REQUIRED = "BADGE_SUBTYPE_REQUIRED"; - String LOCATION_TYPE_REQUIRED = "LOCATION_TYPE_REQUIRED"; - String INVALID_REQUEST_DATA_FOR_LOCATION = "INVALID_REQUEST_DATA_CREATE_LOCATION"; - String ALREADY_EXISTS = "ALREADY_EXISTS"; - String INVALID_VALUE = "INVALID_VALUE"; - String PARENT_CODE_AND_PARENT_ID_MISSING = "PARENT_CODE_AND_PARENT_ID_MISSING"; - String INVALID_PARAMETER = "INVALID_PARAMETER"; - String INVALID_PARENT_ID = "INVALID_PARENT_ID"; - String INVALID_LOCATION_DELETE_REQUEST = "INVALID_LOCATION_DELETE_REQUEST"; - String LOCATION_TYPE_CONFLICTS = "LOCATION_TYPE_CONFLICTS"; - String MANDATORY_PARAMETER_MISSING = "MANDATORY_PARAMETER_MISSING"; - String ERROR_MANDATORY_PARAMETER_EMPTY = "ERROR_MANDATORY_PARAMETER_EMPTY"; - String ERROR_NO_FRAMEWORK_FOUND = "ERROR_NO_FRAMEWORK_FOUND"; - String INVALID_LOCN_ID = "INVALID_LOCATION_ID"; - String UPDATE_NOT_ALLOWED = "UPDATE_NOT_ALLOWED"; - String MANDATORY_HEADER_MISSING = "MANDATORY_HEADER_MISSING"; - String INVALID_PARAMETER_VALUE = "INVALID_PARAMETER_VALUE"; - String PARENT_NOT_ALLOWED = "PARENT_NOT_ALLOWED"; - String MISSING_FILE_ATTACHMENT = "MISSING_FILE_ATTACHMENT"; - String FILE_ATTACHMENT_SIZE_NOT_CONFIGURED = "ATTACHMENT_SIZE_NOT_CONFIGURED"; - String EMPTY_FILE = "EMPTY_FILE"; - String INVALID_COLUMNS = "INVALID_COLUMNS"; - String INVALID_COLUMN = "INVALID_COLUMN"; - String CONFLICTING_ORG_LOCATIONS = "CONFLICTING_ORG_LOCATIONS"; - String UNABLE_TO_COMMUNICATE_WITH_ACTOR = "UNABLE_TO_COMMUNICATE_WITH_ACTOR"; - String EMPTY_HEADER_LINE = "EMPTY_HEADER_LINE"; - String INVALID_REQUEST_PARAMETER = "INVALID_REQUEST_PARAMETER"; - String ROOT_ORG_ASSOCIATION_ERROR = "ROOT_ORG_ASSOCIATION_ERROR"; - String DEPENDENT_PARAMETER_MISSING = "DEPENDENT_PARAMETER_MISSING"; - String EXTERNALID_NOT_FOUND = "EXTERNALID_NOT_FOUND"; - String EXTERNALID_ASSIGNED_TO_OTHER_USER = "EXTERNALID_ASSIGNED_TO_OTHER_USER"; - String MANDATORY_CONFIG_PARAMETER_MISSING = "MANDATORY_CONFIG_PARAMETER_MISSING"; - String CASSANDRA_CONNECTION_ESTABLISHMENT_FAILED = "CASSANDRA_CONNECTION_ESTABLISHMENT_FAILED"; - String COMMON_ATTRIBUTE_MISMATCH = "COMMON_ATTRIBUTE_MISMATCH"; - String MULTIPLE_COURSES_FOR_BATCH = "MULTIPLE_COURSES_FOR_BATCH"; - String ERROR_JSON_TRANSFORM_INVALID_TYPE_CONFIG = "ERROR_JSON_TRANSFORM_INVALID_TYPE_CONFIG"; - String ERROR_JSON_TRANSFORM_INVALID_DATE_FORMAT = "ERROR_JSON_TRANSFORM_INVALID_DATE_FORMAT"; - String ERROR_JSON_TRANSFORM_INVALID_INPUT = "ERROR_JSON_TRANSFORM_INVALID_INPUT"; - String ERROR_JSON_TRANSFORM_INVALID_ENUM_INPUT = "ERROR_JSON_TRANSFORM_INVALID_ENUM_INPUT"; - String ERROR_JSON_TRANSFORM_ENUM_VALUES_EMPTY = "ERROR_JSON_TRANSFORM_ENUM_VALUES_EMPTY"; - String ERROR_JSON_TRANSFORM_BASIC_CONFIG_MISSING = "ERROR_JSON_TRANSFORM_BASIC_CONFIG_MISSING"; - String ERROR_JSON_TRANSFORM_INVALID_FILTER_CONFIG = - "ERROR_JSON_TRANSFORM_INVALID_FILTER_CONFIG"; - String ERROR_LOAD_CONFIG = "ERROR_LOAD_CONFIG"; - String ERROR_REGISTRY_CLIENT_CREATION = "ERROR_REGISTRY_CLIENT_CREATION"; - String ERROR_REGISTRY_ADD_ENTITY = "ERROR_REGISTRY_ADD_ENTITY"; - String ERROR_REGISTRY_READ_ENTITY = "ERROR_REGISTRY_READ_ENTITY"; - String ERROR_REGISTRY_UPDATE_ENTITY = "ERROR_REGISTRY_UPDATE_ENTITY"; - String ERROR_REGISTRY_DELETE_ENTITY = "ERROR_REGISTRY_DELETE_ENTITY"; - String ERROR_REGISTRY_PARSE_RESPONSE = "ERROR_REGISTRY_PARSE_RESPONSE"; - String ERROR_REGISTRY_ENTITY_TYPE_BLANK = "ERROR_REGISTRY_ENTITY_TYPE_BLANK"; - String ERROR_REGISTRY_ENTITY_ID_BLANK = "ERROR_REGISTRY_ENTITY_ID_BLANK"; - String ERROR_REGISTRY_ACCESS_TOKEN_BLANK = "ERROR_REGISTRY_ACCESS_TOKEN_BLANK"; - String DUPLICATE_EXTERNAL_IDS = "DUPLICATE_EXTERNAL_IDS"; - String INVALID_DUPLICATE_VALUE = "INVALID_DUPLICATE_VALUE"; - String EMAIL_RECIPIENTS_EXCEEDS_MAX_LIMIT = "EMAIL_RECIPIENTS_EXCEEDS_MAX_LIMIT"; - String NO_EMAIL_RECIPIENTS = "NO_EMAIL_RECIPIENTS"; - String PARAMETER_MISMATCH = "PARAMETER_MISMATCH"; - String FORBIDDEN = "FORBIDDEN"; - String ERROR_CONFIG_LOAD_EMPTY_STRING = "ERROR_CONFIG_LOAD_EMPTY_STRING"; - String ERROR_CONFIG_LOAD_PARSE_STRING = "ERROR_CONFIG_LOAD_PARSE_STRING"; - String ERROR_CONFIG_LOAD_EMPTY_CONFIG = "ERROR_CONFIG_LOAD_EMPTY_CONFIG"; - String ERROR_CONFLICTING_FIELD_CONFIGURATION = "ERROR_CONFLICTING_FIELD_CONFIGURATION"; - String ERROR_SYSTEM_SETTING_NOT_FOUND = "ERROR_SYSTEM_SETTING_NOT_FOUND"; - String ERROR_NO_ROOT_ORG_ASSOCIATED = "ERROR_NO_ROOT_ORG_ASSOCIATED"; - String ERROR_INACTIVE_CUSTODIAN_ORG = "ERROR_INACTIVE_CUSTODIAN_ORG"; - String ERROR_UNSUPPORTED_CLOUD_STORAGE = "ERROR_ UNSUPPORTED_CLOUD_STORAGE"; - String ERROR_UNSUPPORTED_FIELD = "ERROR_UNSUPPORTED_FIELD"; - String ERROR_GENERATE_DOWNLOAD_LINK = "ERROR_GENERATING_DOWNLOAD_LINK"; - String ERROR_DOWNLOAD_LINK_UNAVAILABLE = "ERROR_DOWNLOAD_LINK_UNAVAILABLE"; - String ERROR_SAVING_STORAGE_DETAILS = "ERROR_SAVING_STORAGE_DETAILS"; - String ERROR_CSV_NO_DATA_ROWS = "ERROR_CSV_NO_DATA_ROWS"; - String ERROR_INACTIVE_ORG = "ERROR_INACTIVE_ORG"; - String ERROR_DUPLICATE_ENTRIES = "ERROR_DUPLICATE_ENTRIES"; - String ERROR_CONFLICTING_VALUES = "ERROR_CONFLICTING_VALUES"; - String ERROR_CONFLICTING_ROOT_ORG_ID = "ERROR_CONFLICTING_ROOT_ORG_ID"; - String ERROR_UPDATE_SETTING_NOT_ALLOWED = "ERROR_UPDATE_SETTING_NOT_ALLOWED"; - String ERROR_CREATING_FILE = "ERROR_CREATING_FILE"; - String ERROR_PROCESSING_REQUEST = "ERROR_PROCESSING_REQUEST"; - String ERROR_UNAVAILABLE_CERTIFICATE = "ERROR_UNAVAILABLE_CERTIFICATE"; - String INVALID_TEXTBOOK = "INVALID_TEXTBOOK"; - String CSV_ROWS_EXCEEDS = "CSV_ROWS_EXCEEDS"; - String INVALID_TEXTBOOK_NAME = "INVALID_TEXTBOOK_NAME"; - String DUPLICATE_ROWS = "DUPLICATE_ROWS"; - String ERROR_INVALID_OTP = "ERROR_INVALID_OTP"; - String REQUIRED_HEADER_MISSING = "REQUIRED_HEADER_MISSING"; - String REQUIRED_FIELD_MISSING = "REQUIRED_FIELD_MISSING"; - String BLANK_CSV_DATA = "BLANK_CSV_DATA"; - String EXCEEDS_MAX_CHILDREN = "EXCEEDS_MAX_CHILDREN"; - String TEXTBOOK_CHILDREN_EXISTS = "TEXTBOOK_CHILDREN_EXISTS"; - String TEXTBOOK_UPDATE_FAILURE = "TEXTBOOK_UPDATE_FAILURE"; - String TEXTBOOK_CHILDREN_NOT_EXISTS = "TEXTBOOK_CHILDREN_NOT_EXISTS"; - String TEXTBOOK_NOT_FOUND = "TEXTBOOK_NOT_FOUND"; - String ERROR_PROCESSING_FILE = "ERROR_PROCESSING_FILE"; - String ERR_FILE_NOT_FOUND = "ERR_FILE_NOT_FOUND"; - String ERROR_TB_UPDATE = "ERROR_TB_UPDATE"; - String ERROR_INVALID_PARAMETER_SIZE = "ERROR_INVALID_PARAMETER_SIZE"; - String INVALID_PAGE_SECTION = "INVALID_PAGE_SECTION"; - String ERROR_RATE_LIMIT_EXCEEDED = "ERROR_RATE_LIMIT_EXCEEDED"; - String ERROR_INVALID_CONFIG_PARAM_VALUE = "ERROR_INVALID_CONFIG_PARAM_VALUE"; - String ERROR_MAX_SIZE_EXCEEDED = "ERROR_MAX_SIZE_EXCEEDED"; - String ERROR_INVALID_DIAL_CODE = "ERROR_INVALID_DIAL_CODE"; - String ERROR_INVALID_TOPIC = "ERROR_INVALID_TOPIC"; - String ERROR_DIAL_CODE_DUPLICATE_ENTRY = "ERROR_DIAL_CODE_DUPLICATE_ENTRY"; - String ERROR_DIAL_CODE_ALREADY_ASSOCIATED = "ERROR_DIAL_CODE_ALREADY_ASSOCIATED"; - String DIAL_CODE_LINKING_FAILED = "DIAL_CODE_LINKING_FAILED"; - String ERROR_TEXTBOOK_UPDATE = "ERROR_TEXTBOOK_UPDATE"; - String ERROR_INVALID_LINKED_CONTENT_ID = "ERROR_INVALID_LINKED_CONTENT_ID"; - String ERROR_DUPLICATE_LINKED_CONTENT = "DUPLICATE_LINKED_CONTENT"; - String TEACHER_CANNOT_BELONG_TO_CUSTODIAN_ORG = "TEACHER_CANNOT_BELONG_TO_CUSTODIAN_ORG"; - String ERROR_DUPLICATE_QR_CODE_ENTRY = "ERROR_DUPLICATE_QR_CODE_ENTRY"; - String ERROR_INVALID_TEXTBOOK_UNIT_ID = "ERROR_INVALID_TEXTBOOK_UNIT_ID"; - String INVALID_REQUEST_TIMEOUT = "INVALID_REQUEST_TIMEOUT"; - String ERROR_BGMS_MISMATCH = "ERROR_BGMS_MISMATCH"; - String ERROR_USER_MIGRATION_FAILED = "ERROR_USER_MIGRATION_FAILED"; - String VALID_IDENTIFIER_ABSENSE = "IDENTIFIER IN LIST IS NOT SUPPORTED OR INCORRECT"; - String FROM_ACCOUNT_ID_MISSING = "FROM_ACCOUNT_ID_MISSING"; - String TO_ACCOUNT_ID_MISSING = "TO_ACCOUNT_ID_MISSING"; - String FROM_ACCOUNT_ID_NOT_EXISTS = "FROM_ACCOUNT_ID_NOT_EXISTS"; - String PARAM_NOT_MATCH = "%s-NOT-MATCH"; - String MANDATORY_HEADER_PARAMETER_MISSING = "MANDATORY_HEADER_PARAMETER_MISSING"; - String RECOVERY_PARAM_MATCH_EXCEPTION = "RECOVERY_PARAM_MATCH_EXCEPTION"; - String EMPTY_CONTENTS_FOR_UPDATE_BATCH_STATUS = "EMPTY_CONTENTS_FOR_UPDATE_BATCH_STATUS"; - String ERROR_USER_HAS_NOT_CREATED_ANY_COURSE = "USER_HAS_NOT_CREATED_ANY_COURSE"; - String ERROR_UPLOAD_QRCODE_CSV_FAILED = "ERROR_UPLOAD_QRCODE_CSV_FAILED"; - String ERROR_NO_DIALCODES_LINKED = "ERROR_NO_DIALCODES_LINKED"; - String EVENTS_DATA_MISSING = "EVENTS_DATA_MISSING"; - String ACCOUNT_NOT_FOUND = "ACCOUNT_NOT_FOUND"; - String INVALID_EXT_USER_ID = "INVALID_EXT_USER_ID"; - String USER_MIGRATION_FAILED = "USER_MIGRATION_FAILED"; - String INVALID_ELEMENT_IN_LIST = "INVALID_ELEMENT_IN_LIST"; - String INVALID_PASSWORD = "INVALID_PASSWORD"; - String OTP_VERIFICATION_FAILED = "OTP_VERIFICATION_FAILED"; - String SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"; - String MISSING_CODE = "ERR_COURSE_CREATE_FIELDS_MISSING"; - String MANAGED_BY_NOT_ALLOWED = "MANAGED_BY_NOT_ALLOWED"; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/package-info.java deleted file mode 100644 index b6c7ea9e2..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.responsecode; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/ProfileCompletenessService.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/ProfileCompletenessService.java deleted file mode 100644 index 63d0e10ec..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/ProfileCompletenessService.java +++ /dev/null @@ -1,21 +0,0 @@ -/** */ -package org.sunbird.common.services; - -import java.util.Map; - -/** - * This interface will have method to compute the profile completeness. - * - * @author Manzarul - */ -public interface ProfileCompletenessService { - - /** - * This method will compute the user profile completeness percentage based on attribute weighted - * settings. it will provide completeness percentage value and list of all missing keys. - * - * @param profileData Map - * @return Map - */ - Map computeProfile(Map profileData); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessFactory.java deleted file mode 100644 index d544cf95f..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/** */ -package org.sunbird.common.services.impl; - -import org.sunbird.common.services.ProfileCompletenessService; - -/** @author Manzarul */ -public class ProfileCompletenessFactory { - - /** @return */ - public static ProfileCompletenessService getInstance() { - return new ProfileCompletenessServiceImpl(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessServiceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessServiceImpl.java deleted file mode 100644 index e14dbbbda..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/ProfileCompletenessServiceImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -/** */ -package org.sunbird.common.services.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.services.ProfileCompletenessService; - -/** @author Manzarul */ -public class ProfileCompletenessServiceImpl implements ProfileCompletenessService { - - @Override - public Map computeProfile(Map profileData) { - Map response = new HashMap<>(); - float completedCount = 0; - if (profileData == null || profileData.size() == 0) { - response.put(JsonKey.COMPLETENESS, (int) Math.ceil(completedCount)); - response.put(JsonKey.MISSING_FIELDS, findMissingAttribute(profileData)); - return response; - } - Iterator> itr = profileData.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - Object value = entry.getValue(); - if (value instanceof List) { - List list = (List) value; - if (list.size() > 0) { - completedCount = completedCount + getValue(entry.getKey()); - } - } else if (value instanceof Map) { - Map map = (Map) value; - if (map != null && map.size() > 0) { - completedCount = completedCount + getValue(entry.getKey()); - } - } else { - if (value != null && !StringUtils.isBlank(value.toString())) { - completedCount = completedCount + getValue(entry.getKey()); - } - } - } - response.put(JsonKey.COMPLETENESS, (int) Math.ceil(completedCount)); - response.put(JsonKey.MISSING_FIELDS, findMissingAttribute(profileData)); - return response; - } - - /** - * This method will provide weighted value for particular attribute - * - * @param key String - * @return float - */ - private float getValue(String key) { - return PropertiesCache.getInstance().attributePercentageMap.get(key) != null - ? PropertiesCache.getInstance().attributePercentageMap.get(key) - : 0; - } - - /** - * This method will provide all the missing filed list - * - * @param profileData Map - * @return List - */ - private List findMissingAttribute(Map profileData) { - List attribute = new ArrayList<>(); - Iterator> itr = - PropertiesCache.getInstance().attributePercentageMap.entrySet().iterator(); - while (itr.hasNext()) { - Entry entry = itr.next(); - if (profileData == null || !profileData.containsKey(entry.getKey())) { - attribute.add(entry.getKey()); - } else { - Object val = profileData.get(entry.getKey()); - if (val == null) { - attribute.add(entry.getKey()); - } else if (val instanceof List) { - List list = (List) val; - if (list.size() == 0) { - attribute.add(entry.getKey()); - } - } else if (val instanceof Map) { - Map map = (Map) val; - if (map == null || map.size() == 0) { - attribute.add(entry.getKey()); - } - } else { - if (StringUtils.isBlank(val.toString())) { - attribute.add(entry.getKey()); - } - } - } - } - return attribute; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/package-info.java deleted file mode 100644 index 9513083f3..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/impl/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.services.impl; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/package-info.java deleted file mode 100644 index 38e8eba94..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/services/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.common.services; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/CloudStorageUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/CloudStorageUtil.java deleted file mode 100644 index cbb632433..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/CloudStorageUtil.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.sunbird.common.util; - -import java.util.HashMap; -import java.util.Map; -import org.sunbird.cloud.storage.IStorageService; -import org.sunbird.cloud.storage.factory.StorageConfig; -import org.sunbird.cloud.storage.factory.StorageServiceFactory; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import scala.Option; -import scala.Some; - -public class CloudStorageUtil { - private static final int STORAGE_SERVICE_API_RETRY_COUNT = 3; - - private static final Map storageServiceMap = new HashMap<>(); - - public enum CloudStorageType { - AZURE("azure"); - private String type; - - private CloudStorageType(String type) { - this.type = type; - } - - public String getType() { - return this.type; - } - - public static CloudStorageType getByName(String type) { - if (AZURE.type.equals(type)) { - return CloudStorageType.AZURE; - } else { - ProjectCommonException.throwClientErrorException( - ResponseCode.errorUnsupportedCloudStorage, - ProjectUtil.formatMessage( - ResponseCode.errorUnsupportedCloudStorage.getErrorMessage(), type)); - return null; - } - } - } - - public static String upload( - CloudStorageType storageType, String container, String objectKey, String filePath) { - - IStorageService storageService = getStorageService(storageType); - - return storageService.upload( - container, - filePath, - objectKey, - Option.apply(false), - Option.apply(1), - Option.apply(STORAGE_SERVICE_API_RETRY_COUNT), - Option.empty()); - } - - public static String getSignedUrl( - CloudStorageType storageType, String container, String objectKey) { - IStorageService storageService = getStorageService(storageType); - return getSignedUrl(storageService, storageType, container, objectKey); - } - - public static String getAnalyticsSignedUrl( - CloudStorageType storageType, String container, String objectKey) { - IStorageService analyticsStorageService = getAnalyticsStorageService(storageType); - return getSignedUrl(analyticsStorageService, storageType, container, objectKey); - } - - public static String getSignedUrl( - IStorageService storageService, - CloudStorageType storageType, - String container, - String objectKey) { - int timeoutInSeconds = getTimeoutInSeconds(); - return storageService.getSignedURL( - container, objectKey, Some.apply(timeoutInSeconds), Some.apply("r")); - } - - private static IStorageService getStorageService(CloudStorageType storageType) { - String storageKey = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_NAME); - String storageSecret = PropertiesCache.getInstance().getProperty(JsonKey.ACCOUNT_KEY); - return getStorageService(storageType, storageKey, storageSecret); - } - - private static IStorageService getAnalyticsStorageService(CloudStorageType storageType) { - String storageKey = PropertiesCache.getInstance().getProperty(JsonKey.ANALYTICS_ACCOUNT_NAME); - String storageSecret = PropertiesCache.getInstance().getProperty(JsonKey.ANALYTICS_ACCOUNT_KEY); - return getStorageService(storageType, storageKey, storageSecret); - } - - private static IStorageService getStorageService( - CloudStorageType storageType, String storageKey, String storageSecret) { - String compositeKey = storageType.getType() + "-" + storageKey; - if (storageServiceMap.containsKey(compositeKey)) { - return storageServiceMap.get(compositeKey); - } - synchronized (CloudStorageUtil.class) { - StorageConfig storageConfig = - new StorageConfig(storageType.getType(), storageKey, storageSecret); - IStorageService storageService = StorageServiceFactory.getStorageService(storageConfig); - storageServiceMap.put(compositeKey, storageService); - } - return storageServiceMap.get(compositeKey); - } - - private static int getTimeoutInSeconds() { - String timeoutInSecondsStr = ProjectUtil.getConfigValue(JsonKey.DOWNLOAD_LINK_EXPIRY_TIMEOUT); - return Integer.parseInt(timeoutInSecondsStr); - } - - public static String getUri( - CloudStorageType storageType, String container, String prefix, boolean isDirectory) { - IStorageService storageService = getStorageService(storageType); - return storageService.getUri(container, prefix, Option.apply(isDirectory)); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/ConfigUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/ConfigUtil.java deleted file mode 100644 index 50a0be8ee..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/ConfigUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.sunbird.common.util; - -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * This util class for providing type safe config to any service that requires it. - * - * @author Manzarul - */ -public class ConfigUtil { - - private static Config config; - private static final String DEFAULT_TYPE_SAFE_CONFIG_FILE_NAME = "service.conf"; - private static final String INVALID_FILE_NAME = "Please provide a valid file name."; - - /** Private default constructor. */ - private ConfigUtil() {} - - /** - * This method will create a type safe config object and return to caller. It will read the config - * value from System env first and as a fall back it will use service.conf file. - * - * @return Type safe config object - */ - public static Config getConfig() { - if (config == null) { - synchronized (ConfigUtil.class) { - config = createConfig(DEFAULT_TYPE_SAFE_CONFIG_FILE_NAME); - } - } - return config; - } - - /** - * This method will create a type safe config object and return to caller. It will read the config - * value from System env first and as a fall back it will use provided file name. If file name is - * null or empty then it will throw ProjectCommonException with status code as 500. - * - * @return Type safe config object - */ - public static Config getConfig(String fileName) { - if (StringUtils.isBlank(fileName)) { - ProjectLogger.log( - "ConfigUtil:getConfigWithFilename: Given file name is null or empty: " + fileName, - LoggerEnum.INFO.name()); - throw new ProjectCommonException( - ResponseCode.internalError.getErrorCode(), - INVALID_FILE_NAME, - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - if (config == null) { - synchronized (ConfigUtil.class) { - config = createConfig(fileName); - } - } - return config; - } - - public static void validateMandatoryConfigValue(String configParameter) { - if (StringUtils.isBlank(configParameter)) { - ProjectLogger.log( - "ConfigUtil:validateMandatoryConfigValue: Missing mandatory configuration parameter: " - + configParameter, - LoggerEnum.ERROR.name()); - throw new ProjectCommonException( - ResponseCode.mandatoryConfigParamMissing.getErrorCode(), - ResponseCode.mandatoryConfigParamMissing.getErrorMessage(), - ResponseCode.SERVER_ERROR.getResponseCode(), - configParameter); - } - } - - private static Config createConfig(String fileName) { - Config defaultConf = ConfigFactory.load(fileName); - Config envConf = ConfigFactory.systemEnvironment(); - return envConf.withFallback(defaultConf); - } - - /* - * Parse configuration in JSON format and return a type safe config object. - * - * @param jsonString Configuration in JSON format - * @return Type safe config object - */ - public static Config getConfigFromJsonString(String jsonString, String configType) { - ProjectLogger.log("ConfigUtil: getConfigFromJsonString called", LoggerEnum.DEBUG.name()); - - if (null == jsonString || StringUtils.isBlank(jsonString)) { - ProjectLogger.log( - "ConfigUtil:getConfigFromJsonString: Empty string", LoggerEnum.ERROR.name()); - ProjectCommonException.throwServerErrorException( - ResponseCode.errorConfigLoadEmptyString, - ProjectUtil.formatMessage( - ResponseCode.errorConfigLoadEmptyString.getErrorMessage(), configType)); - } - - Config jsonConfig = null; - try { - jsonConfig = ConfigFactory.parseString(jsonString); - } catch (Exception e) { - ProjectLogger.log( - "ConfigUtil:getConfigFromJsonString: Exception occurred during parse with error message = " - + e.getMessage(), - LoggerEnum.ERROR.name()); - ProjectCommonException.throwServerErrorException( - ResponseCode.errorConfigLoadParseString, - ProjectUtil.formatMessage( - ResponseCode.errorConfigLoadParseString.getErrorMessage(), configType)); - } - - if (null == jsonConfig || jsonConfig.isEmpty()) { - ProjectLogger.log( - "ConfigUtil:getConfigFromJsonString: Empty configuration", LoggerEnum.ERROR.name()); - ProjectCommonException.throwServerErrorException( - ResponseCode.errorConfigLoadEmptyConfig, - ProjectUtil.formatMessage( - ResponseCode.errorConfigLoadEmptyConfig.getErrorMessage(), configType)); - } - - ProjectLogger.log( - "ConfigUtil:getConfigFromJsonString: Successfully constructed type safe configuration", - LoggerEnum.DEBUG.name()); - - return jsonConfig; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/KeycloakRequiredActionLinkUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/KeycloakRequiredActionLinkUtil.java deleted file mode 100644 index f0c8b52bc..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/KeycloakRequiredActionLinkUtil.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.sunbird.common.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mashape.unirest.http.HttpResponse; -import com.mashape.unirest.http.JsonNode; -import com.mashape.unirest.http.Unirest; -import com.mashape.unirest.request.BaseRequest; -import com.mashape.unirest.request.body.RequestBodyEntity; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.MediaType; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpHeaders; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; - -/** - * Keycloak utility to create required action links. - * - * @author Amit Kumar - */ -public class KeycloakRequiredActionLinkUtil { - - public static final String VERIFY_EMAIL = "VERIFY_EMAIL"; - public static final String UPDATE_PASSWORD = "UPDATE_PASSWORD"; - private static final String CLIENT_ID = "clientId"; - private static final String REQUIRED_ACTION = "requiredAction"; - private static final String USERNAME = "userName"; - private static final String EXPIRATION_IN_SEC = "expirationInSecs"; - private static final String REDIRECT_URI = "redirectUri"; - private static final String ACCESS_TOKEN = "access_token"; - private static final String SUNBIRD_KEYCLOAK_LINK_EXPIRATION_TIME = - "sunbird_keycloak_required_action_link_expiration_seconds"; - private static final String SUNBIRD_KEYCLOAK_REQD_ACTION_LINK = "/get-required-action-link"; - private static final String LINK = "link"; - - private static ObjectMapper mapper = new ObjectMapper(); - - /** - * Get generated link for specified type and user from Keycloak service. - * - * @param userName User name - * @param requiredAction Type of link to be generated. Supported types are UPDATE_PASSWORD and - * VERIFY_EMAIL. - * @return Generated link from Keycloak service - */ - public static String getLink(String userName, String redirectUri, String requiredAction) { - Map request = new HashMap<>(); - - request.put(CLIENT_ID, ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_CLIENT_ID)); - request.put(USERNAME, userName); - request.put(REQUIRED_ACTION, requiredAction); - - String expirationInSecs = ProjectUtil.getConfigValue(SUNBIRD_KEYCLOAK_LINK_EXPIRATION_TIME); - if (StringUtils.isNotBlank(expirationInSecs)) { - request.put(EXPIRATION_IN_SEC, expirationInSecs); - } - request.put(REDIRECT_URI, redirectUri); - - try { - Thread.sleep( - Integer.parseInt(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SYNC_READ_WAIT_TIME))); - return generateLink(request); - } catch (Exception ex) { - ProjectLogger.log( - "KeycloakRequiredActionLinkUtil:getLink: Exception occurred with error message = " - + ex.getMessage(), - ex); - } - return null; - } - - private static String generateLink(Map request) throws Exception { - Map headers = new HashMap<>(); - - headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - headers.put(JsonKey.AUTHORIZATION, JsonKey.BEARER + getAdminAccessToken()); - - ProjectLogger.log( - "KeycloakRequiredActionLinkUtil:generateLink: complete URL " - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_URL) - + "realms/" - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_RELAM) - + SUNBIRD_KEYCLOAK_REQD_ACTION_LINK, - LoggerEnum.INFO.name()); - ProjectLogger.log( - "KeycloakRequiredActionLinkUtil:generateLink: request body " - + mapper.writeValueAsString(request), - LoggerEnum.INFO.name()); - RequestBodyEntity baseRequest = - Unirest.post( - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_URL) - + "realms/" - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_RELAM) - + SUNBIRD_KEYCLOAK_REQD_ACTION_LINK) - .headers(headers) - .body(mapper.writeValueAsString(request)); - HttpResponse response = baseRequest.asJson(); - - ProjectLogger.log( - "KeycloakRequiredActionLinkUtil:generateLink: Response status = " - + response.getStatus() - + " body " - + response.getBody(), - LoggerEnum.INFO.name()); - - return response.getBody().getObject().getString(LINK); - } - - public static String getAdminAccessToken() throws Exception { - Map headers = new HashMap<>(); - headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); - BaseRequest request = - Unirest.post( - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_URL) - + "realms/" - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_RELAM) - + "/protocol/openid-connect/token") - .headers(headers) - .field("client_id", ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_CLIENT_ID)) - .field("client_secret", ProjectUtil.getConfigValue(JsonKey.SUNBIRD_SSO_CLIENT_SECRET)) - .field("grant_type", "client_credentials"); - - HttpResponse response = request.asJson(); - ProjectLogger.log( - "KeycloakRequiredActionLinkUtil:getAdminAccessToken: Response status = " - + response.getStatus(), - LoggerEnum.INFO.name()); - - return response.getBody().getObject().getString(ACCESS_TOKEN); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/Matcher.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/Matcher.java deleted file mode 100644 index 148321605..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/Matcher.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sunbird.common.util; - -import org.apache.commons.lang3.StringUtils; - -/** this class is used to match the identifiers. */ -public class Matcher { - - /** - * this method will match the two arguments , equal or not if two string is null or empty this - * method will return true - * - * @param firstVal - * @param secondVal - * @return boolean - */ - public static boolean matchIdentifiers(String firstVal, String secondVal) { - return StringUtils.equalsIgnoreCase(firstVal, secondVal); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/InstructionEventGenerator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/InstructionEventGenerator.java deleted file mode 100644 index b148e0d13..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/InstructionEventGenerator.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.sunbird.kafka.client; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.telemetry.dto.TelemetryBJREvent; - -public class InstructionEventGenerator { - - private static ObjectMapper mapper = new ObjectMapper(); - private static String beJobRequesteventId = "BE_JOB_REQUEST"; - private static int iteration = 1; - - private static String actorId = "Sunbird LMS Samza Job"; - private static String actorType = "System"; - private static String pdataId = "org.sunbird.platform"; - private static String pdataVersion = "1.0"; - - public static void pushInstructionEvent(String topic, Map data) throws Exception { - pushInstructionEvent("", topic, data); - } - - public static void pushInstructionEvent(String key, String topic, Map data) - throws Exception { - String beJobRequestEvent = generateInstructionEventMetadata(data); - if (StringUtils.isBlank(beJobRequestEvent)) { - throw new ProjectCommonException( - "BE_JOB_REQUEST_EXCEPTION", - "Event is not generated properly.", - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - if (StringUtils.isNotBlank(topic)) { - if (StringUtils.isNotBlank(key)) KafkaClient.send(key, beJobRequestEvent, topic); - else KafkaClient.send(beJobRequestEvent, topic); - } else { - throw new ProjectCommonException( - "BE_JOB_REQUEST_EXCEPTION", - "Invalid topic id.", - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - private static String generateInstructionEventMetadata(Map data) { - Map actor = new HashMap<>(); - Map context = new HashMap<>(); - Map object = new HashMap<>(); - Map edata = new HashMap<>(); - if (MapUtils.isNotEmpty((Map) data.get("actor"))) { - actor.putAll((Map) data.get("actor")); - } else { - actor.put("id", actorId); - actor.put("type", actorType); - } - - if (MapUtils.isNotEmpty((Map) data.get("context"))) { - context.putAll((Map) data.get("context")); - } - Map pdata = new HashMap<>(); - pdata.put("id", pdataId); - pdata.put("ver", pdataVersion); - context.put("pdata", pdata); - if (MapUtils.isNotEmpty((Map) data.get("object"))) object.putAll((Map) data.get("object")); - - if (MapUtils.isNotEmpty((Map) data.get("edata"))) edata.putAll((Map) data.get("edata")); - - if (StringUtils.isNotBlank((String) data.get("action"))) - edata.put("action", data.get("action")); - - return logInstructionEvent(actor, context, object, edata); - } - - private static String logInstructionEvent( - Map actor, - Map context, - Map object, - Map edata) { - - TelemetryBJREvent te = new TelemetryBJREvent(); - long unixTime = System.currentTimeMillis(); - String mid = "LP." + System.currentTimeMillis() + "." + UUID.randomUUID(); - edata.put("iteration", iteration); - - te.setEid(beJobRequesteventId); - te.setEts(unixTime); - te.setMid(mid); - te.setActor(actor); - te.setContext(context); - te.setObject(object); - te.setEdata(edata); - - String jsonMessage = null; - try { - jsonMessage = mapper.writeValueAsString(te); - } catch (Exception e) { - ProjectLogger.log("Error logging BE_JOB_REQUEST event: " + e.getMessage(), e); - } - return jsonMessage; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/KafkaClient.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/KafkaClient.java deleted file mode 100644 index 0e22edc1b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/kafka/client/KafkaClient.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.sunbird.kafka.client; - -import java.util.List; -import java.util.Map; -import java.util.Properties; -import org.apache.kafka.clients.consumer.Consumer; -import org.apache.kafka.clients.consumer.ConsumerConfig; -import org.apache.kafka.clients.consumer.KafkaConsumer; -import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; -import org.apache.kafka.clients.producer.ProducerConfig; -import org.apache.kafka.clients.producer.ProducerRecord; -import org.apache.kafka.common.PartitionInfo; -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; - -/** - * Helper class for creating a Kafka consumer and producer. - * - * @author Pradyumna - */ -public class KafkaClient { - - private static final String BOOTSTRAP_SERVERS = ProjectUtil.getConfigValue("kafka_urls"); - private static Producer producer; - private static Consumer consumer; - private static volatile Map> topics; - - static { - loadProducerProperties(); - loadConsumerProperties(); - loadTopics(); - } - - private static void loadProducerProperties() { - Properties props = new Properties(); - props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); - props.put(ProducerConfig.CLIENT_ID_CONFIG, "KafkaClientProducer"); - props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); - props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); - props.put(ProducerConfig.LINGER_MS_CONFIG, ProjectUtil.getConfigValue("kafka_linger_ms")); - producer = new KafkaProducer(props); - } - - private static void loadTopics() { - if (consumer == null) { - loadConsumerProperties(); - } - topics = consumer.listTopics(); - ProjectLogger.log( - "KafkaClient:loadTopics Kafka topic infos =>" + topics, LoggerEnum.INFO.name()); - } - - private static void loadConsumerProperties() { - Properties props = new Properties(); - props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); - props.put(ConsumerConfig.CLIENT_ID_CONFIG, "KafkaClientConsumer"); - props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); - props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); - consumer = new KafkaConsumer<>(props); - } - - public static Producer getProducer() { - return producer; - } - - public static Consumer getConsumer() { - return consumer; - } - - public static void send(String event, String topic) throws Exception { - if (validate(topic)) { - final Producer producer = getProducer(); - ProducerRecord record = new ProducerRecord(topic, event); - producer.send(record); - } else { - ProjectLogger.log("Topic id: " + topic + ", does not exists.", LoggerEnum.ERROR); - throw new ProjectCommonException( - "TOPIC_NOT_EXISTS_EXCEPTION", - "Topic id: " + topic + ", does not exists.", - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - public static void send(String key, String event, String topic) throws Exception { - if (validate(topic)) { - final Producer producer = getProducer(); - ProducerRecord record = new ProducerRecord(topic, key, event); - producer.send(record); - } else { - ProjectLogger.log("Topic id: " + topic + ", does not exists.", LoggerEnum.ERROR); - throw new ProjectCommonException( - "TOPIC_NOT_EXISTS_EXCEPTION", - "Topic id: " + topic + ", does not exists.", - ResponseCode.CLIENT_ERROR.getResponseCode()); - } - } - - private static boolean validate(String topic) throws Exception { - if (topics == null) { - loadTopics(); - } - return topics.keySet().contains(topic); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOManager.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOManager.java deleted file mode 100644 index 472681836..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOManager.java +++ /dev/null @@ -1,131 +0,0 @@ -/** */ -package org.sunbird.services.sso; - -import java.util.Map; - -/** @author Manzarul This interface will handle all call related to single sign out. */ -public interface SSOManager { - - /** - * This method will verify user access token and provide userId if token is valid. in case of - * invalid access token it will throw ProjectCommon exception with 401. - * - * @param token String JWT access token - * @return String - */ - String verifyToken(String token); - - /** Update password in SSO server (keycloak). */ - boolean updatePassword(String userId, String password); - - /** - * Method to update user account in keycloak on basis of userId. - * - * @param request - * @return - */ - String updateUser(Map request); - - /** - * Method to remove user from keycloak account on basis of userId . - * - * @param request - * @return - */ - String removeUser(Map request); - - /** - * This method will check email is verified by user or not. - * - * @param userId String - * @return boolean - */ - boolean isEmailVerified(String userId); - - /** - * Method to deactivate user from keycloak , it is like soft delete . - * - * @param request - * @return - */ - String deactivateUser(Map request); - - /** - * Method to activate user from keycloak , it is like soft delete . - * - * @param request - * @return - */ - String activateUser(Map request); - - /** - * This method will read user last login time from key claok. - * - * @param userId String - * @return String (as epoch value or null) - */ - String getLastLoginTime(String userId); - - /** - * This method will add user current login time to keycloak. - * - * @param userId String - * @return boolean - */ - boolean addUserLoginTime(String userId); - - /** - * this method will set emailVerified flag of keycloak as false. - * - * @param userId - */ - String setEmailVerifiedAsFalse(String userId); - - /** - * This method will set email verified flag on keycloak. - * - * @param userId String - * @param flag boolean (true/false) - */ - void setEmailVerifiedUpdatedFlag(String userId, String flag); - - /** - * This method will provide the user already set attribute under keycloak. - * - * @param userId String - * @return String - */ - String getEmailVerifiedUpdatedFlag(String userId); - - /** - * This method will do the data sync from cassandra db to keyclaok. - * - * @param request Map - * @return String - */ - String syncUserData(Map request); - - /** - * This method will do the user password update. - * - * @param userId String - * @param password String - * @return boolean true/false - */ - boolean doPasswordUpdate(String userId, String password); - - String setEmailVerifiedTrue(String userId); - - void setRequiredAction(String userId, String requiredAction); - - String getUsernameById(String userId); - /** - * This method will verify user access token and provide userId if token is valid. in case of - * invalid access token it will throw ProjectCommon exception with 401. - * - * @param token String JWT access token - * @param url token will be validated against this url - * @return String - */ - String verifyToken(String token, String url); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOServiceFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOServiceFactory.java deleted file mode 100644 index dfc12406d..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOServiceFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sunbird.services.sso; - -import org.sunbird.services.sso.impl.KeyCloakServiceImpl; - -/** @author Amit Kumar */ -public class SSOServiceFactory { - private static SSOManager ssoManager = null; - - private SSOServiceFactory() {} - - /** - * On call of this method , it will provide a new KeyCloakServiceImpl instance on each call. - * - * @return SSOManager - */ - public static SSOManager getInstance() { - if (null == ssoManager) { - ssoManager = new KeyCloakServiceImpl(); - } - return ssoManager; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcher.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcher.java deleted file mode 100644 index 49cfc3f50..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcher.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.sunbird.services.sso.impl; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.math.BigInteger; -import java.security.KeyFactory; -import java.security.PublicKey; -import java.security.spec.RSAPublicKeySpec; -import java.util.Base64; -import java.util.Base64.Decoder; -import java.util.HashMap; -import java.util.Map; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; - -/** Class to fetch SSO public key from Keycloak server using 'certs' HTTP API call. */ -public class KeyCloakRsaKeyFetcher { - private static final String MODULUS = "modulusBase64"; - private static final String EXPONENT = "exponentBase64"; - - /** - * This method will accept keycloak base URL and realm name. Based on provided values it will - * fetch public key from keycloak. - * - * @param url A string value having keycloak base URL - * @param realm Keycloak realm name - * @return Public key used to verify user access token. - */ - public PublicKey getPublicKeyFromKeyCloak(String url, String realm) { - try { - Map valueMap = null; - Decoder urlDecoder = Base64.getUrlDecoder(); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - String publicKeyString = requestKeyFromKeycloak(url, realm); - if (publicKeyString != null) { - valueMap = getValuesFromJson(publicKeyString); - if (valueMap != null) { - BigInteger modulus = new BigInteger(1, urlDecoder.decode(valueMap.get(MODULUS))); - BigInteger publicExponent = new BigInteger(1, urlDecoder.decode(valueMap.get(EXPONENT))); - PublicKey key = keyFactory.generatePublic(new RSAPublicKeySpec(modulus, publicExponent)); - saveToCache(key); - return key; - } - } - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakRsaKeyFetcher:getPublicKeyFromKeyCloak: Exception occurred with message = " - + e.getMessage(), - LoggerEnum.ERROR); - } - return null; - } - - /** - * This method will save the public key string value to cache - * - * @param key Public key to save in cache - */ - private void saveToCache(PublicKey key) { - byte[] encodedPublicKey = key.getEncoded(); - String publicKey = Base64.getEncoder().encodeToString(encodedPublicKey); - PropertiesCache cache = PropertiesCache.getInstance(); - cache.saveConfigProperty(JsonKey.SSO_PUBLIC_KEY, publicKey); - } - - /** - * This method will connect to keycloak server using API call for getting public key. - * - * @param url A string value having keycloak base URL - * @param realm Keycloak realm name - * @return Public key JSON response string - */ - private String requestKeyFromKeycloak(String url, String realm) { - HttpClient client = HttpClientBuilder.create().build(); - HttpGet request = new HttpGet(url + "realms/" + realm + "/protocol/openid-connect/certs"); - - try { - HttpResponse response = client.execute(request); - HttpEntity entity = response.getEntity(); - - if (entity != null) { - return EntityUtils.toString(entity); - } else { - ProjectLogger.log( - "KeyCloakRsaKeyFetcher:requestKeyFromKeycloak: Not able to fetch SSO public key from keycloak server", - LoggerEnum.ERROR); - } - } catch (IOException e) { - ProjectLogger.log( - "KeyCloakRsaKeyFetcher:requestKeyFromKeycloak: Exception occurred with message = " - + e.getMessage(), - LoggerEnum.ERROR); - } - return null; - } - - /** - * This method will return a map containing values extracted from public key JSON string. - * - * @param response Public key JSON response string - */ - private Map getValuesFromJson(String response) { - ObjectMapper mapper = new ObjectMapper(); - Map values = new HashMap<>(); - try { - JsonNode res = mapper.readTree(response); - JsonNode keys = res.get("keys"); - if (keys != null) { - - JsonNode value = keys.get(0); - values.put(MODULUS, value.get("n").asText()); - values.put(EXPONENT, value.get("e").asText()); - } - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakRsaKeyFetcher:getValuesFromJson: Exception occurred with message = " - + e.getMessage(), - LoggerEnum.ERROR); - return null; - } - - return values; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakServiceImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakServiceImpl.java deleted file mode 100644 index bf08b0980..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/KeyCloakServiceImpl.java +++ /dev/null @@ -1,629 +0,0 @@ -package org.sunbird.services.sso.impl; - -import static java.util.Arrays.asList; -import static org.sunbird.common.models.util.ProjectUtil.isNotNull; -import static org.sunbird.common.models.util.ProjectUtil.isNull; - -import java.security.KeyFactory; -import java.security.PublicKey; -import java.security.spec.X509EncodedKeySpec; -import java.util.ArrayList; -import java.util.Base64; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.keycloak.RSATokenVerifier; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.UserResource; -import org.keycloak.representations.AccessToken; -import org.keycloak.representations.idm.CredentialRepresentation; -import org.keycloak.representations.idm.UserRepresentation; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.KeyCloakConnectionProvider; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.common.util.KeycloakRequiredActionLinkUtil; -import org.sunbird.services.sso.SSOManager; - -/** - * Single sign out service implementation with Key Cloak. - * - * @author Manzarul - */ -public class KeyCloakServiceImpl implements SSOManager { - - private Keycloak keycloak = KeyCloakConnectionProvider.getConnection(); - private static final String URL = - KeyCloakConnectionProvider.SSO_URL - + "realms/" - + KeyCloakConnectionProvider.SSO_REALM - + "/protocol/openid-connect/token"; - - private static PublicKey SSO_PUBLIC_KEY = null; - - public PublicKey getPublicKey() { - if (null == SSO_PUBLIC_KEY) { - SSO_PUBLIC_KEY = - new KeyCloakRsaKeyFetcher() - .getPublicKeyFromKeyCloak( - KeyCloakConnectionProvider.SSO_URL, KeyCloakConnectionProvider.SSO_REALM); - } - return SSO_PUBLIC_KEY; - } - - @Override - public String verifyToken(String accessToken) { - return verifyToken(accessToken, null); - } - - /** - * This method will generate Public key form keycloak realm publickey String - * - * @param publicKeyString String - * @return PublicKey - */ - private PublicKey toPublicKey(String publicKeyString) { - try { - byte[] publicBytes = Base64.getDecoder().decode(publicKeyString); - X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicBytes); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - return keyFactory.generatePublic(keySpec); - } catch (Exception e) { - return null; - } - } - - @Override - public boolean updatePassword(String userId, String password) { - try { - String fedUserId = getFederatedUserId(userId); - UserResource ur = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - CredentialRepresentation cr = new CredentialRepresentation(); - cr.setType(CredentialRepresentation.PASSWORD); - cr.setValue(password); - ur.resetPassword(cr); - return true; - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakServiceImpl:updatePassword: Exception occurred with error message = " + e, - LoggerEnum.ERROR.name()); - } - return false; - } - - @Override - public String updateUser(Map request) { - String userId = (String) request.get(JsonKey.USER_ID); - String fedUserId = getFederatedUserId(userId); - UserRepresentation ur = null; - UserResource resource = null; - boolean needTobeUpdate = false; - try { - resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - ur = resource.toRepresentation(); - } catch (Exception e) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - - // set the UserRepresantation with the map value... - if (isNotNull(request.get(JsonKey.FIRST_NAME))) { - needTobeUpdate = true; - ur.setFirstName((String) request.get(JsonKey.FIRST_NAME)); - } - if (isNotNull(request.get(JsonKey.LAST_NAME))) { - needTobeUpdate = true; - ur.setLastName((String) request.get(JsonKey.LAST_NAME)); - } - if (isNotNull(request.get(JsonKey.EMAIL))) { - needTobeUpdate = true; - ur.setEmail((String) request.get(JsonKey.EMAIL)); - ur.setEmailVerified(false); - - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - list.add("false"); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.EMAIL_VERIFIED_UPDATED, list); - ur.setAttributes(map); - } - if (!StringUtils.isBlank((String) request.get(JsonKey.PHONE))) { - needTobeUpdate = true; - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - list.add((String) request.get(JsonKey.PHONE)); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.PHONE, list); - ur.setAttributes(map); - } - - if (!StringUtils.isBlank((String) request.get(JsonKey.COUNTRY_CODE))) { - needTobeUpdate = true; - Map> map = ur.getAttributes(); - if (map == null) { - map = new HashMap<>(); - } - List list = new ArrayList<>(); - list.add(PropertiesCache.getInstance().getProperty("sunbird_default_country_code")); - if (!StringUtils.isBlank((String) request.get(JsonKey.COUNTRY_CODE))) { - list.add(0, (String) request.get(JsonKey.COUNTRY_CODE)); - } - map.put(JsonKey.COUNTRY_CODE, list); - ur.setAttributes(map); - } - - try { - // if user sending any basic profile data - // then no need to make api call to keycloak to update profile. - if (needTobeUpdate) { - resource.update(ur); - } - } catch (Exception ex) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - return JsonKey.SUCCESS; - } - - @Override - public String syncUserData(Map request) { - String userId = (String) request.get(JsonKey.USER_ID); - String fedUserId = getFederatedUserId(userId); - UserRepresentation ur = null; - UserResource resource = null; - boolean needTobeUpdate = false; - try { - resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - ur = resource.toRepresentation(); - } catch (Exception e) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - - // set the UserRepresantation with the map value... - if (isNotNull(request.get(JsonKey.FIRST_NAME))) { - needTobeUpdate = true; - ur.setFirstName((String) request.get(JsonKey.FIRST_NAME)); - } - if (isNotNull(request.get(JsonKey.LAST_NAME))) { - needTobeUpdate = true; - ur.setLastName((String) request.get(JsonKey.LAST_NAME)); - } - - if (isNotNull(request.get(JsonKey.EMAIL))) { - needTobeUpdate = true; - ur.setEmail((String) request.get(JsonKey.EMAIL)); - } - ProjectLogger.log( - "check user email is verified or not ,resource.toRepresentation().isEmailVerified() :" - + resource.toRepresentation().isEmailVerified() - + " for userId :" - + userId); - if (!resource.toRepresentation().isEmailVerified()) { - needTobeUpdate = true; - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - list.add("false"); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.EMAIL_VERIFIED_UPDATED, list); - ur.setAttributes(map); - } else { - needTobeUpdate = true; - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - list.add("true"); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.EMAIL_VERIFIED_UPDATED, list); - ur.setAttributes(map); - } - - if (isNotNull(request.get(JsonKey.LOGIN_ID))) { - needTobeUpdate = true; - ur.setUsername((String) request.get(JsonKey.LOGIN_ID)); - } - if (!StringUtils.isBlank((String) request.get(JsonKey.PHONE))) { - needTobeUpdate = true; - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - list.add((String) request.get(JsonKey.PHONE)); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.PHONE, list); - ur.setAttributes(map); - } - Map> map = ur.getAttributes(); - if (map == null) { - map = new HashMap<>(); - } - List list = new ArrayList<>(); - list.add(PropertiesCache.getInstance().getProperty("sunbird_default_country_code")); - map.put(JsonKey.COUNTRY_CODE, list); - if (!StringUtils.isBlank((String) request.get(JsonKey.COUNTRY_CODE))) { - needTobeUpdate = true; - list.add(0, (String) request.get(JsonKey.COUNTRY_CODE)); - map.put(JsonKey.COUNTRY_CODE, list); - } - ur.setAttributes(map); - try { - // if user sending any basic profile data - // then no need to make api call to keycloak to update profile. - if (needTobeUpdate) { - resource.update(ur); - } - } catch (Exception ex) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - return JsonKey.SUCCESS; - } - - /** - * Method to remove the user on basis of user id. - * - * @param request Map - * @return boolean true if success otherwise false . - */ - @Override - public String removeUser(Map request) { - Keycloak keycloak = KeyCloakConnectionProvider.getConnection(); - String userId = (String) request.get(JsonKey.USER_ID); - try { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - if (isNotNull(resource)) { - resource.remove(); - } - } catch (Exception ex) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - return JsonKey.SUCCESS; - } - - /** - * Method to deactivate the user on basis of user id. - * - * @param request Map - * @return boolean true if success otherwise false . - */ - @Override - public String deactivateUser(Map request) { - String userId = (String) request.get(JsonKey.USER_ID); - makeUserActiveOrInactive(userId, false); - return JsonKey.SUCCESS; - } - - /** - * Method to activate the user on basis of user id. - * - * @param request Map - * @return boolean true if success otherwise false . - */ - @Override - public String activateUser(Map request) { - String userId = (String) request.get(JsonKey.USER_ID); - makeUserActiveOrInactive(userId, true); - return JsonKey.SUCCESS; - } - - /** - * This method will take userid and boolean status to update user status - * - * @param userId String - * @param status boolean - * @throws ProjectCommonException - */ - private void makeUserActiveOrInactive(String userId, boolean status) { - try { - String fedUserId = getFederatedUserId(userId); - ProjectLogger.log( - "KeyCloakServiceImpl:makeUserActiveOrInactive: fedration id formed: " + fedUserId, - LoggerEnum.INFO.name()); - validateUserId(fedUserId); - Keycloak keycloak = KeyCloakConnectionProvider.getConnection(); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation ur = resource.toRepresentation(); - ur.setEnabled(status); - if (isNotNull(resource)) { - resource.update(ur); - } - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakServiceImpl:makeUserActiveOrInactive:error occurred while blocking user: " + e, - LoggerEnum.ERROR.name()); - ProjectUtil.createAndThrowInvalidUserDataException(); - } - } - - /** - * This method will check userId value, if value is null or empty then it will throw - * ProjectCommonException - * - * @param userId String - * @throws ProjectCommonException - */ - private void validateUserId(String userId) { - if (StringUtils.isBlank(userId)) { - ProjectUtil.createAndThrowInvalidUserDataException(); - } - } - - @Override - public boolean isEmailVerified(String userId) { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - if (isNull(resource)) { - return false; - } - return resource.toRepresentation().isEmailVerified(); - } - - @Override - public void setEmailVerifiedUpdatedFlag(String userId, String flag) { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation user = resource.toRepresentation(); - Map> map = user.getAttributes(); - List list = new ArrayList<>(); - list.add(flag); - if (map == null) { - map = new HashMap<>(); - } - map.put(JsonKey.EMAIL_VERIFIED_UPDATED, list); - user.setAttributes(map); - resource.update(user); - } - - @Override - public String getEmailVerifiedUpdatedFlag(String userId) { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation user = resource.toRepresentation(); - Map> map = user.getAttributes(); - List list = null; - if (MapUtils.isNotEmpty(map)) { - list = map.get(JsonKey.EMAIL_VERIFIED_UPDATED); - } - if (CollectionUtils.isNotEmpty(list)) { - return list.get(0); - } else { - return ""; - } - } - - /** - * This method will do the user password update. - * - * @param userId String - * @param password String - * @return boolean true/false - */ - @Override - public boolean doPasswordUpdate(String userId, String password) { - boolean response = false; - try { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - CredentialRepresentation newCredential = new CredentialRepresentation(); - newCredential.setValue(password); - newCredential.setType(CredentialRepresentation.PASSWORD); - newCredential.setTemporary(true); - resource.resetPassword(newCredential); - response = true; - } catch (Exception ex) { - ProjectLogger.log(ex.getMessage(), ex); - } - return response; - } - - @Override - public String getLastLoginTime(String userId) { - String lastLoginTime = null; - try { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation ur = resource.toRepresentation(); - Map> map = ur.getAttributes(); - if (map == null) { - map = new HashMap<>(); - } - List list = map.get(JsonKey.LAST_LOGIN_TIME); - if (list != null && !list.isEmpty()) { - lastLoginTime = list.get(0); - } - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - return lastLoginTime; - } - - @Override - public boolean addUserLoginTime(String userId) { - boolean response = true; - try { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation ur = resource.toRepresentation(); - Map> map = ur.getAttributes(); - List list = new ArrayList<>(); - if (map == null) { - map = new HashMap<>(); - } - List currentLogTime = map.get(JsonKey.CURRENT_LOGIN_TIME); - if (currentLogTime == null || currentLogTime.isEmpty()) { - currentLogTime = new ArrayList<>(); - currentLogTime.add(Long.toString(System.currentTimeMillis())); - } else { - list.add(currentLogTime.get(0)); - currentLogTime.clear(); - currentLogTime.add(0, Long.toString(System.currentTimeMillis())); - } - map.put(JsonKey.CURRENT_LOGIN_TIME, currentLogTime); - map.put(JsonKey.LAST_LOGIN_TIME, list); - ur.setAttributes(map); - resource.update(ur); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - response = false; - } - return response; - } - - private String getFederatedUserId(String userId) { - return String.join( - ":", - "f", - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID), - userId); - } - - @Override - public String setEmailVerifiedTrue(String userId) { - updateEmailVerifyStatus(userId, true); - return JsonKey.SUCCESS; - } - - @Override - public String setEmailVerifiedAsFalse(String userId) { - updateEmailVerifyStatus(userId, false); - return JsonKey.SUCCESS; - } - - /** - * This method will update user email verified status - * - * @param userId String - * @param status boolean - * @throws ProjectCommonException - */ - private void updateEmailVerifyStatus(String userId, boolean status) { - try { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation ur = resource.toRepresentation(); - ur.setEmailVerified(status); - if (isNotNull(resource)) { - resource.update(ur); - } - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - ProjectUtil.createAndThrowInvalidUserDataException(); - } - } - - @Override - public void setRequiredAction(String userId, String requiredAction) { - String fedUserId = getFederatedUserId(userId); - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - - UserRepresentation userRepresentation = resource.toRepresentation(); - userRepresentation.setRequiredActions(asList(requiredAction)); - if (KeycloakRequiredActionLinkUtil.VERIFY_EMAIL.equalsIgnoreCase(requiredAction)) { - userRepresentation.setEmailVerified(false); - } - resource.update(userRepresentation); - } - - @Override - public String getUsernameById(String userId) { - String fedUserId = getFederatedUserId(userId); - try { - UserResource resource = - keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); - UserRepresentation ur = resource.toRepresentation(); - return ur.getUsername(); - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakServiceImpl:getUsernameById: User not found for userId = " - + userId - + " error message = " - + e.getMessage(), - e); - } - ProjectLogger.log( - "KeyCloakServiceImpl:getUsernameById: User not found for userId = " + userId, - LoggerEnum.INFO.name()); - return ""; - } - - @Override - public String verifyToken(String accessToken, String url) { - - try { - PublicKey publicKey = getPublicKey(); - if (publicKey == null) { - ProjectLogger.log( - "KeyCloakServiceImpl: SSO_PUBLIC_KEY is NULL. Keycloak server may need to be started. Read value from environment variable.", - LoggerEnum.INFO); - publicKey = toPublicKey(System.getenv(JsonKey.SSO_PUBLIC_KEY)); - } - if (publicKey != null) { - String ssoUrl = (url != null ? url : KeyCloakConnectionProvider.SSO_URL); - AccessToken token = - RSATokenVerifier.verifyToken( - accessToken, - publicKey, - ssoUrl + "realms/" + KeyCloakConnectionProvider.SSO_REALM, - true, - true); - ProjectLogger.log( - token.getId() - + " " - + token.issuedFor - + " " - + token.getProfile() - + " " - + token.getSubject() - + " Active: " - + token.isActive() - + " isExpired: " - + token.isExpired() - + " " - + token.issuedNow().getExpiration(), - LoggerEnum.INFO.name()); - String tokenSubject = token.getSubject(); - if (StringUtils.isNotBlank(tokenSubject)) { - int pos = tokenSubject.lastIndexOf(":"); - return tokenSubject.substring(pos + 1); - } - return token.getSubject(); - } else { - ProjectLogger.log( - "KeyCloakServiceImpl:verifyToken: SSO_PUBLIC_KEY is NULL.", LoggerEnum.ERROR); - throw new ProjectCommonException( - ResponseCode.keyCloakDefaultError.getErrorCode(), - ResponseCode.keyCloakDefaultError.getErrorMessage(), - ResponseCode.keyCloakDefaultError.getResponseCode()); - } - } catch (Exception e) { - ProjectLogger.log( - "KeyCloakServiceImpl:verifyToken: Exception occurred with message = " + e.getMessage(), - LoggerEnum.ERROR); - throw new ProjectCommonException( - ResponseCode.unAuthorized.getErrorCode(), - ResponseCode.unAuthorized.getErrorMessage(), - ResponseCode.UNAUTHORIZED.getResponseCode()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/package-info.java deleted file mode 100644 index af2698a92..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.services.sso.impl; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/package-info.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/package-info.java deleted file mode 100644 index 47a89ebb8..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -/** */ -/** @author Manzarul */ -package org.sunbird.services.sso; diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryAssemblerFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryAssemblerFactory.java deleted file mode 100644 index 86d4e8988..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryAssemblerFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sunbird.telemetry.collector; - -/** Created by arvind on 16/1/18. */ -public class TelemetryAssemblerFactory { - - private static TelemetryDataAssembler telemetryDataAssembler = null; - - public static TelemetryDataAssembler get() { - if (telemetryDataAssembler == null) { - synchronized (TelemetryAssemblerFactory.class) { - if (telemetryDataAssembler == null) { - telemetryDataAssembler = new TelemetryDataAssemblerImpl(); - } - } - } - return telemetryDataAssembler; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssembler.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssembler.java deleted file mode 100644 index 748b3315b..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssembler.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sunbird.telemetry.collector; - -import java.util.Map; - -/** Created by arvind on 16/1/18. */ -public interface TelemetryDataAssembler { - - public String audit(Map context, Map params); - - public String search(Map context, Map params); - - public String log(Map context, Map params); - - public String error(Map context, Map params); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssemblerImpl.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssemblerImpl.java deleted file mode 100644 index 7047c3849..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssemblerImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.sunbird.telemetry.collector; - -import java.util.Map; -import org.sunbird.telemetry.util.TelemetryGenerator; - -/** Created by arvind on 5/1/18. */ -public class TelemetryDataAssemblerImpl implements TelemetryDataAssembler { - - @Override - public String audit(Map context, Map params) { - return TelemetryGenerator.audit(context, params); - } - - @Override - public String search(Map context, Map params) { - return TelemetryGenerator.search(context, params); - } - - @Override - public String log(Map context, Map params) { - return TelemetryGenerator.log(context, params); - } - - @Override - public String error(Map context, Map params) { - return TelemetryGenerator.error(context, params); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Actor.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Actor.java deleted file mode 100644 index c69b605b1..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Actor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.sunbird.telemetry.dto; - -public class Actor { - - private String id; - private String type; - - public Actor() {} - - public Actor(String id, String type) { - super(); - this.id = id; - this.type = type; - } - - /** @return the id */ - public String getId() { - return id; - } - - /** @param id the id to set */ - public void setId(String id) { - this.id = id; - } - - /** @return the type */ - public String getType() { - return type; - } - - /** @param type the type to set */ - public void setType(String type) { - this.type = type; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Context.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Context.java deleted file mode 100644 index 9ba76faca..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Context.java +++ /dev/null @@ -1,85 +0,0 @@ -/** */ -package org.sunbird.telemetry.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@JsonInclude(Include.NON_NULL) -public class Context { - - private String channel; - private Producer pdata; - private String env; - private String did; - private List> cdata = new ArrayList<>(); - private Map rollup = new HashMap<>(); - - public Context() {} - - public Context(String channel, String env, Producer pdata) { - super(); - this.channel = channel; - this.env = env; - this.pdata = pdata; - } - - public Map getRollup() { - return rollup; - } - - public void setRollup(Map rollup) { - this.rollup = rollup; - } - - public List> getCdata() { - return cdata; - } - - public void setCdata(List> cdata) { - this.cdata = cdata; - } - - /** @return the channel */ - public String getChannel() { - return channel; - } - - /** @param channel the channel to set */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** @return the pdata */ - public Producer getPdata() { - return pdata; - } - - /** @param pdata the pdata to set */ - public void setPdata(Producer pdata) { - this.pdata = pdata; - } - - /** @return the env */ - public String getEnv() { - return env; - } - - /** @param env the env to set */ - public void setEnv(String env) { - this.env = env; - } - - /** @return the did */ - public String getDid() { - return did; - } - - /** @param did the did to set */ - public void setDid(String did) { - this.did = did; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Producer.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Producer.java deleted file mode 100644 index be56b1e05..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Producer.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.sunbird.telemetry.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -@JsonInclude(Include.NON_NULL) -public class Producer { - - private String id; - private String pid; - private String ver; - - public Producer() {} - - public Producer(String id, String ver) { - super(); - this.id = id; - this.ver = ver; - } - - public Producer(String id, String pid, String ver) { - this.id = id; - this.pid = pid; - this.ver = ver; - } - - /** @return the id */ - public String getId() { - return id; - } - - /** @param id the id to set */ - public void setId(String id) { - this.id = id; - } - - /** @return the pid */ - public String getPid() { - return pid; - } - - /** @param pid the pid to set */ - public void setPid(String pid) { - this.pid = pid; - } - - /** @return the ver */ - public String getVer() { - return ver; - } - - /** @param ver the ver to set */ - public void setVer(String ver) { - this.ver = ver; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Target.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Target.java deleted file mode 100644 index 071311494..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Target.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.sunbird.telemetry.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.Map; - -@JsonInclude(Include.NON_NULL) -public class Target { - - private String id; - private String type; - private String ver; - private Map rollup; - - public Target() {} - - public Target(String id, String type) { - super(); - this.id = id; - this.type = type; - } - - public Map getRollup() { - return rollup; - } - - public void setRollup(Map rollup) { - this.rollup = rollup; - } - - /** @return the id */ - public String getId() { - return id; - } - - /** @param id the id to set */ - public void setId(String id) { - this.id = id; - } - - /** @return the type */ - public String getType() { - return type; - } - - /** @param type the type to set */ - public void setType(String type) { - this.type = type; - } - - /** @return the ver */ - public String getVer() { - return ver; - } - - /** @param ver the ver to set */ - public void setVer(String ver) { - this.ver = ver; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Telemetry.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Telemetry.java deleted file mode 100644 index d468b92ae..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Telemetry.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.sunbird.telemetry.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** Telemetry V3 POJO to generate telemetry event. */ -@JsonInclude(Include.NON_NULL) -public class Telemetry { - - private String eid; - private long ets = System.currentTimeMillis(); - private String ver = "3.0"; - private String mid = System.currentTimeMillis() + "." + UUID.randomUUID(); - private Actor actor; - private Context context; - private Target object; - private Map edata; - private List tags; - - public Telemetry() {} - - public Telemetry( - String eid, Actor actor, Context context, Map edata, Target object) { - super(); - this.eid = eid; - this.actor = actor; - this.context = context; - this.edata = edata; - this.object = object; - } - - public Telemetry(String eid, Actor actor, Context context, Map edata) { - super(); - this.eid = eid; - this.actor = actor; - this.context = context; - this.edata = edata; - } - - /** @return the eid */ - public String getEid() { - return eid; - } - - /** @param eid the eid to set */ - public void setEid(String eid) { - this.eid = eid; - } - - /** @return the ets */ - public long getEts() { - return ets; - } - - /** @param ets the ets to set */ - public void setEts(long ets) { - this.ets = ets; - } - - /** @return the ver */ - public String getVer() { - return ver; - } - - /** @param ver the ver to set */ - public void setVer(String ver) { - this.ver = ver; - } - - /** @return the mid */ - public String getMid() { - return mid; - } - - /** @param mid the mid to set */ - public void setMid(String mid) { - this.mid = mid; - } - - /** @return the actor */ - public Actor getActor() { - return actor; - } - - /** @param actor the actor to set */ - public void setActor(Actor actor) { - this.actor = actor; - } - - /** @return the context */ - public Context getContext() { - return context; - } - - /** @param context the context to set */ - public void setContext(Context context) { - this.context = context; - } - - /** @return the object */ - public Target getObject() { - return object; - } - - /** @param object the object to set */ - public void setObject(Target object) { - this.object = object; - } - - /** @return the edata */ - public Map getEdata() { - return edata; - } - - /** @param edata the edata to set */ - public void setEdata(Map edata) { - this.edata = edata; - } - - /** @return the tags */ - public List getTags() { - return tags; - } - - /** @param tags the tags to set */ - public void setTags(List tags) { - this.tags = tags; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBEEvent.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBEEvent.java deleted file mode 100644 index c82a58594..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBEEvent.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.sunbird.telemetry.dto; - -import java.util.HashMap; -import java.util.Map; - -public class TelemetryBEEvent { - - private String eid; - private long ets; - private String mid; - private String ver; - private String channel; - private Map pdata; - private Map edata; - - public String getEid() { - return eid; - } - - public void setEid(String eid) { - this.eid = eid; - } - - public long getEts() { - return ets; - } - - public void setEts(long ets) { - this.ets = ets; - } - - public String getVer() { - return ver; - } - - public void setVer(String ver) { - this.ver = ver; - } - - public Map getPdata() { - return pdata; - } - - public void setPdata(Map pdata) { - this.pdata = pdata; - } - - public Map getEdata() { - return edata; - } - - public void setEdata(Map eks) { - this.edata = new HashMap<>(); - edata.put("eks", eks); - } - - public void setPdata(String id, String pid, String ver, String uid) { - this.pdata = new HashMap<>(); - this.pdata.put("id", id); - this.pdata.put("pid", pid); - this.pdata.put("ver", ver); - } - - public void setEdata( - String cid, - Object status, - Object prevState, - Object size, - Object pkgVersion, - Object concepts) { - this.edata = new HashMap<>(); - Map eks = new HashMap<>(); - eks.put("cid", cid); - eks.put("state", status); - eks.put("prevstate", prevState); - eks.put("size", size); - eks.put("pkgVersion", pkgVersion); - eks.put("concepts", concepts); - edata.put("eks", eks); - } - - public void setEdata(String query, Object filters, Object sort, String correlationId, int size) { - this.edata = new HashMap<>(); - Map eks = new HashMap<>(); - eks.put("query", query); - eks.put("filters", filters); - eks.put("sort", sort); - eks.put("correlationid", correlationId); - eks.put("size", size); - edata.put("eks", eks); - } - - public void setEdata(String id, Object state, Object prevState, Object lemma) { - this.edata = new HashMap<>(); - Map eks = new HashMap<>(); - eks.put("id", id); - eks.put("state", state); - eks.put("prevstate", prevState); - eks.put("lemma", lemma); - edata.put("eks", eks); - } - - public String getMid() { - return mid; - } - - public void setMid(String mid) { - this.mid = mid; - } - - public String getChannel() { - if (null == channel) { - channel = ""; - } - return channel; - } - - public void setChannel(String channel) { - String tempChannel = channel; - if (null == channel) { - tempChannel = ""; - } - this.channel = tempChannel; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBJREvent.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBJREvent.java deleted file mode 100644 index a94a365d3..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBJREvent.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.sunbird.telemetry.dto; - -import java.util.Map; - -public class TelemetryBJREvent { - - private String eid; - private long ets; - private String mid; - private Map actor; - private Map context; - private Map object; - private Map edata; - - public String getEid() { - return eid; - } - - public void setEid(String eid) { - this.eid = eid; - } - - public long getEts() { - return ets; - } - - public void setEts(long ets) { - this.ets = ets; - } - - public String getMid() { - return mid; - } - - public void setMid(String mid) { - this.mid = mid; - } - - public Map getActor() { - return actor; - } - - public void setActor(Map actor) { - this.actor = actor; - } - - public Map getContext() { - return context; - } - - public void setContext(Map context) { - this.context = context; - } - - public Map getObject() { - return object; - } - - public void setObject(Map object) { - this.object = object; - } - - public Map getEdata() { - return edata; - } - - public void setEdata(Map edata) { - this.edata = edata; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/SunbirdTelemetryEventConsumer.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/SunbirdTelemetryEventConsumer.java deleted file mode 100644 index 57e3b9b94..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/SunbirdTelemetryEventConsumer.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.ws.rs.core.MediaType; -import org.apache.http.HttpHeaders; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.request.Request; -import org.sunbird.common.request.TelemetryV3Request; - -/** - * Dispatcher for telemetry data to Sunbird telemetry service. Sunbird telemetry service is - * responsible for storing telemetry data in Sunbird and/or Ekstep platform based on configuration. - * - * @author Manzarul - */ -public class SunbirdTelemetryEventConsumer { - - private static SunbirdTelemetryEventConsumer consumer = new SunbirdTelemetryEventConsumer(); - - private SunbirdTelemetryEventConsumer() {} - - public static SunbirdTelemetryEventConsumer getInstance() { - if (null == consumer) { - consumer = new SunbirdTelemetryEventConsumer(); - } - return consumer; - } - - public void consume(Request request) { - ProjectLogger.log("SunbirdTelemetryEventConsumer:consume called.", LoggerEnum.INFO.name()); - if (request != null) { - ObjectMapper mapper = new ObjectMapper(); - try { - String telemetryReq = mapper.writeValueAsString(getTelemetryRequest(request)); - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:consume telemetry request:" + telemetryReq, - LoggerEnum.DEBUG.name()); - try { - String response = HttpUtil.sendPostRequest(getTelemetryUrl(), telemetryReq, getHeaders()); - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:consume: Request process status = " + response, - LoggerEnum.INFO.name()); - } catch (Exception e) { - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:consume: Generic exception occurred in sending telemetry request = " - + e.getMessage(), - e); - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:consume: Failure request = " - + mapper.writeValueAsString(getTelemetryRequest(request)), - LoggerEnum.DEBUG.name()); - } - } catch (Exception e) { - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:consume: Failure converting to String " - + e.getMessage(), - e); - } - } - } - - public Map getHeaders() { - Map headers = new HashMap<>(); - headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - return headers; - } - - /** - * This method will return telemetry url. it will read sunbird_lms_base_url key for base url . - * First it will try to read value from environment in case of absence it will read value from - * property cache. - * - * @return Complete url for telemetry service. - */ - public String getTelemetryUrl() { - String telemetryBaseUrl = - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_TELEMETRY_BASE_URL) - + PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_TELEMETRY_API_PATH); - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:getTelemetryUrl: url = " + telemetryBaseUrl, - LoggerEnum.INFO.name()); - return telemetryBaseUrl; - } - - /** - * This method will transform incoming requested data to Telemetry request structure. - * - * @param request Request that contains telemetry data generated by Sunbird. - * @return Telemetry request structure. - */ - @SuppressWarnings({"unchecked", "rawtypes"}) - public TelemetryV3Request getTelemetryRequest(Request request) { - TelemetryV3Request telemetryV3Request = new TelemetryV3Request(); - if (request.getRequest().get(JsonKey.ETS) != null - && request.getRequest().get(JsonKey.ETS) instanceof BigInteger) { - telemetryV3Request.setEts(((BigInteger) request.getRequest().get(JsonKey.ETS)).longValue()); - } - if (request.getRequest().get(JsonKey.EVENTS) != null - && request.getRequest().get(JsonKey.EVENTS) instanceof List - && !(((List) request.getRequest().get(JsonKey.EVENTS)).isEmpty())) { - List> events = - (List>) request.getRequest().get(JsonKey.EVENTS); - telemetryV3Request.setEvents(events); - ProjectLogger.log( - "SunbirdTelemetryEventConsumer:getTelemetryRequest: Events count = " + events.size(), - LoggerEnum.INFO.name()); - } - return telemetryV3Request; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryConstant.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryConstant.java deleted file mode 100644 index b4394cc25..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryConstant.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.sunbird.telemetry.util; - -/** - * Class contains Constants for telemetry. - * - * @author arvind. - */ -public class TelemetryConstant { - - public static final String LOG_LEVEL_ERROR = "error"; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryEvents.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryEvents.java deleted file mode 100644 index 76d8b6114..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryEvents.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sunbird.telemetry.util; - -/** - * enum for telemetry events - * - * @author arvind. - */ -public enum TelemetryEvents { - AUDIT("AUDIT"), - SEARCH("SEARCH"), - LOG("LOG"), - ERROR("ERROR"); - private String name; - - TelemetryEvents(String name) { - this.name = name; - } - - public String getName() { - return name; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryFlush.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryFlush.java deleted file mode 100644 index 63cb7a3af..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryFlush.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.request.Request; - -/** - * Class to Receive the telemetry messages and once queue reached threshold value flush the messages - * to the appropriate consumer - * - * @author arvind - */ -public class TelemetryFlush { - - private Queue queue = new ConcurrentLinkedQueue<>(); - private int thresholdSize = 20; - private static ObjectMapper mapper = new ObjectMapper(); - private static TelemetryFlush telemetryFlush; - SunbirdTelemetryEventConsumer consumer = SunbirdTelemetryEventConsumer.getInstance(); - - public static TelemetryFlush getInstance() { - if (telemetryFlush == null) { - synchronized (TelemetryFlush.class) { - if (telemetryFlush == null) { - telemetryFlush = new TelemetryFlush(); - } - } - } - return telemetryFlush; - } - - /** Constructor that initialize the telemetry flush attributes like queue threshold size */ - public TelemetryFlush() { - String queueThreshold = ProjectUtil.getConfigValue(JsonKey.TELEMETRY_QUEUE_THRESHOLD_VALUE); - if (!StringUtils.isBlank(queueThreshold) - && !queueThreshold.equalsIgnoreCase(JsonKey.TELEMETRY_QUEUE_THRESHOLD_VALUE)) { - try { - this.thresholdSize = Integer.parseInt(queueThreshold.trim()); - } catch (Exception ex) { - ProjectLogger.log( - "TelemetryFlush:TelemetryFlush: Threshold size from config is not integer", ex); - } - } - } - - /** - * Method to flush the telemetry message to the destination - * - * @param message Telemetry message - */ - public void flushTelemetry(String message) { - writeToQueue(message); - } - - private void writeToQueue(String message) { - queue.offer(message); - if (queue.size() >= thresholdSize) { - List list = new ArrayList<>(); - for (int i = 1; i <= thresholdSize; i++) { - String obj = queue.poll(); - if (obj == null) { - break; - } else { - list.add(obj); - } - } - Request req = createTelemetryRequest(list); - consumer.consume(req); - } - } - - public Request createTelemetryRequest(List eventList) { - Request req = null; - try { - List> jsonList = - mapper.readValue(eventList.toString(), new TypeReference>>() {}); - Map map = new HashMap<>(); - map.put(JsonKey.ETS, System.currentTimeMillis()); - map.put(JsonKey.EVENTS, jsonList); - req = new Request(); - req.getRequest().putAll(map); - return req; - } catch (Exception e) { - ProjectLogger.log( - "TelemetryFlush:createTelemetryRequest: Failed to create request for telemetry flush.", - e); - } - return req; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryGenerator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryGenerator.java deleted file mode 100644 index fe1f0f430..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryGenerator.java +++ /dev/null @@ -1,358 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.models.util.TelemetryEnvKey; -import org.sunbird.telemetry.dto.Actor; -import org.sunbird.telemetry.dto.Context; -import org.sunbird.telemetry.dto.Producer; -import org.sunbird.telemetry.dto.Target; -import org.sunbird.telemetry.dto.Telemetry; - -/** - * class to transform the request data to telemetry events - * - * @author Arvind - */ -public class TelemetryGenerator { - - private static ObjectMapper mapper = new ObjectMapper(); - - private TelemetryGenerator() {} - - /** - * To generate api_access LOG telemetry JSON string. - * - * @param context Map contains the telemetry context info like actor info, env info etc. - * @param params Map contains the telemetry event data info - * @return Telemetry event - */ - public static String audit(Map context, Map params) { - if (!validateRequest(context, params)) { - return ""; - } - String actorId = (String) context.get(JsonKey.ACTOR_ID); - String actorType = (String) context.get(JsonKey.ACTOR_TYPE); - Actor actor = new Actor(actorId, StringUtils.capitalize(actorType)); - Target targetObject = - generateTargetObject((Map) params.get(JsonKey.TARGET_OBJECT)); - Context eventContext = getContext(context); - // assign cdata into context from params correlated objects... - if (params.containsKey(JsonKey.CORRELATED_OBJECTS)) { - setCorrelatedDataToContext(params.get(JsonKey.CORRELATED_OBJECTS), eventContext); - } - - // assign request id into context cdata ... - String reqId = (String) context.get(JsonKey.REQUEST_ID); - if (!StringUtils.isBlank(reqId)) { - Map map = new HashMap<>(); - map.put(JsonKey.ID, reqId); - map.put(JsonKey.TYPE, TelemetryEnvKey.REQUEST_UPPER_CAMEL); - eventContext.getCdata().add(map); - } - - Map edata = generateAuditEdata(params); - - Telemetry telemetry = - new Telemetry(TelemetryEvents.AUDIT.getName(), actor, eventContext, edata, targetObject); - return getTelemetry(telemetry); - } - - private static void setCorrelatedDataToContext(Object correlatedObjects, Context eventContext) { - ArrayList> list = (ArrayList>) correlatedObjects; - ArrayList> targetList = new ArrayList<>(); - if (null != list && !list.isEmpty()) { - for (Map m : list) { - Map map = new HashMap<>(); - map.put(JsonKey.ID, m.get(JsonKey.ID)); - map.put(JsonKey.TYPE, StringUtils.capitalize((String) m.get(JsonKey.TYPE))); - targetList.add(map); - } - } - eventContext.setCdata(targetList); - } - - private static Target generateTargetObject(Map targetObject) { - - Target target = - new Target( - (String) targetObject.get(JsonKey.ID), - StringUtils.capitalize((String) targetObject.get(JsonKey.TYPE))); - if (targetObject.get(JsonKey.ROLLUP) != null) { - target.setRollup((Map) targetObject.get(JsonKey.ROLLUP)); - } - return target; - } - - private static Map generateAuditEdata(Map params) { - - Map edata = new HashMap<>(); - Map props = (Map) params.get(JsonKey.PROPS); - // TODO: need to rethink about this one .. if map is null then what to do - if (null != props) { - edata.put(JsonKey.PROPS, getProps(props)); - } - - Map target = (Map) params.get(JsonKey.TARGET_OBJECT); - if (target.get(JsonKey.CURRENT_STATE) != null) { - edata.put(JsonKey.STATE, StringUtils.capitalize((String) target.get(JsonKey.CURRENT_STATE))); - if (JsonKey.UPDATE.equalsIgnoreCase((String) target.get(JsonKey.CURRENT_STATE)) - && edata.get(props) != null) { - removeAttributes((Map) edata.get(props), JsonKey.ID); - } - } - return edata; - } - - private static void removeAttributes(Map map, String... properties) { - for (String property : properties) { - map.remove(property); - } - } - - private static List getProps(Map map) { - try { - return map.entrySet() - .stream() - .map(entry -> entry.getKey()) - .map( - key -> { - if (map.get(key) instanceof Map) { - List keys = getProps((Map) map.get(key)); - return keys.stream() - .map(childKey -> key + "." + childKey) - .collect(Collectors.toList()); - } else { - return Arrays.asList(key); - } - }) - .flatMap(List::stream) - .collect(Collectors.toList()); - } catch (Exception e) { - ProjectLogger.log("TelemetryGenerator:getProps error =" + e, LoggerEnum.ERROR.name()); - } - return new ArrayList<>(); - } - - private static Context getContext(Map context) { - String channel = (String) context.get(JsonKey.CHANNEL); - String env = (String) context.get(JsonKey.ENV); - String did = (String) context.get(JsonKey.DEVICE_ID); - Producer producer = getProducer(context); - Context eventContext = new Context(channel, StringUtils.capitalize(env), producer); - eventContext.setDid(did); - if (context.get(JsonKey.ROLLUP) != null - && !((Map) context.get(JsonKey.ROLLUP)).isEmpty()) { - eventContext.setRollup((Map) context.get(JsonKey.ROLLUP)); - } - return eventContext; - } - - private static Producer getProducer(Map context) { - String id = ""; - if (context != null && context.size() != 0) { - if (StringUtils.isNotBlank((String) context.get(JsonKey.APP_ID))) { - id = (String) context.get(JsonKey.APP_ID); - } else { - id = (String) context.get(JsonKey.PDATA_ID); - } - String pid = (String) context.get(JsonKey.PDATA_PID); - String ver = (String) context.get(JsonKey.PDATA_VERSION); - return new Producer(id, pid, ver); - } else { - return new Producer("", "", ""); - } - } - - private static String getTelemetry(Telemetry telemetry) { - String event = ""; - try { - event = mapper.writeValueAsString(telemetry); - ProjectLogger.log("TelemetryGenerator:getTelemetry = Telemetry Event : " + event, LoggerEnum.DEBUG.name()); - } catch (Exception e) { - ProjectLogger.log("TelemetryGenerator:getTelemetry = Telemetry Event: failed to generate audit events:" +e, LoggerEnum.ERROR.name()); } - return event; - } - - /** - * Method to generate the search type telemetry event. - * - * @param context Map contains the telemetry context info like actor info, env info etc. - * @param params Map contains the telemetry event data info - * @return Search Telemetry event - */ - public static String search(Map context, Map params) { - - if (!validateRequest(context, params)) { - return ""; - } - String actorId = (String) context.get(JsonKey.ACTOR_ID); - String actorType = (String) context.get(JsonKey.ACTOR_TYPE); - Actor actor = new Actor(actorId, StringUtils.capitalize(actorType)); - - Context eventContext = getContext(context); - - // assign request id into context cdata ... - String reqId = (String) context.get(JsonKey.REQUEST_ID); - if (!StringUtils.isBlank(reqId)) { - Map map = new HashMap<>(); - map.put(JsonKey.ID, reqId); - map.put(JsonKey.TYPE, TelemetryEnvKey.REQUEST_UPPER_CAMEL); - eventContext.getCdata().add(map); - } - Map edata = generateSearchEdata(params); - Telemetry telemetry = - new Telemetry(TelemetryEvents.SEARCH.getName(), actor, eventContext, edata); - return getTelemetry(telemetry); - } - - private static Map generateSearchEdata(Map params) { - - Map edata = new HashMap<>(); - String type = (String) params.get(JsonKey.TYPE); - String query = (String) params.get(JsonKey.QUERY); - Map filters = (Map) params.get(JsonKey.FILTERS); - Map sort = (Map) params.get(JsonKey.SORT); - Long size = (Long) params.get(JsonKey.SIZE); - List topn = (List) params.get(JsonKey.TOPN); - - edata.put(JsonKey.TYPE, StringUtils.capitalize(type)); - if (null == query) { - query = ""; - } - edata.put(JsonKey.QUERY, query); - edata.put(JsonKey.FILTERS, filters); - edata.put(JsonKey.SORT, sort); - edata.put(JsonKey.SIZE, size); - edata.put(JsonKey.TOPN, topn); - return edata; - } - - /** - * Method to generate the log type telemetry event. - * - * @param context Map contains the telemetry context info like actor info, env info etc. - * @param params Map contains the telemetry event data info - * @return Search Telemetry event - */ - public static String log(Map context, Map params) { - - if (!validateRequest(context, params)) { - return ""; - } - String actorId = (String) context.get(JsonKey.ACTOR_ID); - String actorType = (String) context.get(JsonKey.ACTOR_TYPE); - Actor actor = new Actor(actorId, StringUtils.capitalize(actorType)); - - Context eventContext = getContext(context); - - // assign request id into context cdata ... - String reqId = (String) context.get(JsonKey.REQUEST_ID); - if (!StringUtils.isBlank(reqId)) { - Map map = new HashMap<>(); - map.put(JsonKey.ID, reqId); - map.put(JsonKey.TYPE, TelemetryEnvKey.REQUEST_UPPER_CAMEL); - eventContext.getCdata().add(map); - } - - Map edata = generateLogEdata(params); - Telemetry telemetry = new Telemetry(TelemetryEvents.LOG.getName(), actor, eventContext, edata); - return getTelemetry(telemetry); - } - - private static Map generateLogEdata(Map params) { - - Map edata = new HashMap<>(); - String logType = (String) params.get(JsonKey.LOG_TYPE); - String logLevel = (String) params.get(JsonKey.LOG_LEVEL); - String message = (String) params.get(JsonKey.MESSAGE); - - edata.put(JsonKey.TYPE, StringUtils.capitalize(logType)); - edata.put(JsonKey.LEVEL, logLevel); - edata.put(JsonKey.MESSAGE, message != null ? message : ""); - - edata.put( - JsonKey.PARAMS, - getParamsList(params, Arrays.asList(JsonKey.LOG_TYPE, JsonKey.LOG_LEVEL, JsonKey.MESSAGE))); - return edata; - } - - private static List> getParamsList( - Map params, List ignore) { - List> paramsList = new ArrayList>(); - if (null != params && !params.isEmpty()) { - for (Entry entry : params.entrySet()) { - if (!ignore.contains(entry.getKey())) { - Map param = new HashMap(); - param.put(entry.getKey(), entry.getValue()); - paramsList.add(param); - } - } - } - return paramsList; - } - - /** - * Method to generate the error type telemetry event. - * - * @param context Map contains the telemetry context info like actor info, env info etc. - * @param params Map contains the error event data info - * @return Search Telemetry event - */ - public static String error(Map context, Map params) { - - if (!validateRequest(context, params)) { - return ""; - } - String actorId = (String) context.get(JsonKey.ACTOR_ID); - String actorType = (String) context.get(JsonKey.ACTOR_TYPE); - Actor actor = new Actor(actorId, StringUtils.capitalize(actorType)); - - Context eventContext = getContext(context); - - // assign request id into context cdata ... - String reqId = (String) context.get(JsonKey.REQUEST_ID); - if (!StringUtils.isBlank(reqId)) { - Map map = new HashMap<>(); - map.put(JsonKey.ID, reqId); - map.put(JsonKey.TYPE, TelemetryEnvKey.REQUEST_UPPER_CAMEL); - eventContext.getCdata().add(map); - } - - Map edata = generateErrorEdata(params); - Telemetry telemetry = - new Telemetry(TelemetryEvents.ERROR.getName(), actor, eventContext, edata); - return getTelemetry(telemetry); - } - - private static Map generateErrorEdata(Map params) { - Map edata = new HashMap<>(); - String error = (String) params.get(JsonKey.ERROR); - String errorType = (String) params.get(JsonKey.ERR_TYPE); - String stackTrace = (String) params.get(JsonKey.STACKTRACE); - edata.put(JsonKey.ERROR, error); - edata.put(JsonKey.ERR_TYPE, errorType); - edata.put(JsonKey.STACKTRACE, ProjectUtil.getFirstNCharacterString(stackTrace, 100)); - return edata; - } - - private static boolean validateRequest(Map context, Map params) { - - boolean flag = true; - if (null == context || context.isEmpty() || params == null || params.isEmpty()) { - flag = false; - } - return flag; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryLmaxWriter.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryLmaxWriter.java deleted file mode 100644 index 93c6fa786..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryLmaxWriter.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.lmax.disruptor.dsl.Disruptor; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.request.Request; - -/** - * Lmax Disruptor engine to receive the telemetry request and forward the request to event handler - * - * @author arvind - */ -public class TelemetryLmaxWriter { - - private static Disruptor disruptor; - private WriteEventProducer writeEventProducer; - private int ringBufferSize; - private static TelemetryLmaxWriter lmaxWriter; - - private TelemetryLmaxWriter() { - init(); - registerShutDownHook(); - } - - /** - * Method to get the singleton object of TelemetryLmaxWriter - * - * @return TelemetryLmaxWriter singleton object - */ - public static TelemetryLmaxWriter getInstance() { - if (lmaxWriter != null) { - return lmaxWriter; - } - synchronized (TelemetryLmaxWriter.class) { - if (null == lmaxWriter) { - lmaxWriter = new TelemetryLmaxWriter(); - lmaxWriter.setRingBufferSize(8); - } - } - return lmaxWriter; - } - - public void setRingBufferSize(int ringBufferSize) { - this.ringBufferSize = ringBufferSize; - } - - /** Initialize the disruptor engine. */ - @SuppressWarnings("unchecked") - private void init() { - // create a thread pool executor to be used by disruptor - Executor executor = Executors.newCachedThreadPool(); - - // initialize our event factory - WriteEventFactory factory = new WriteEventFactory(); - - if (ringBufferSize == 0) { - ringBufferSize = 65536; - } - - // ring buffer size always has to be the power of 2. - // so if it is not, make it equal to the nearest integer. - double power = Math.log(ringBufferSize) / Math.log(2); - if (power % 1 != 0) { - power = Math.ceil(power); - ringBufferSize = (int) Math.pow(2, power); - ProjectLogger.log("New ring buffer size = " + ringBufferSize); - } - - // initialize our event handler. - WriteEventHandler handler = new WriteEventHandler(); - - // initialize the disruptor - disruptor = new Disruptor(factory, ringBufferSize, executor); - disruptor.handleEventsWith(handler); - - // start the disruptor and get the generated ring buffer instance - disruptor.start(); - - // initialize the event producer to submit messages - writeEventProducer = new WriteEventProducer(disruptor); - } - - /** - * Method to receive the message (represents telemetry event) - * - * @param message telemetry request which contains telemetry event - */ - public void submitMessage(Request message) { - if (writeEventProducer != null) { - // publish the messages via event producer - writeEventProducer.onData(message); - } - } - - /** - * Clean up thread to gracefully shutdown TelemetryLmaxWriter - * - * @author Manzarul - */ - static class ResourceCleanUp extends Thread { - public void run() { - ProjectLogger.log("started resource cleanup."); - if (disruptor != null) { - disruptor.halt(); - disruptor.shutdown(); - } - ProjectLogger.log("completed resource cleanup."); - } - } - - /** Register a shutdown hook to gracefully shutdown TelemetryLmaxWriter */ - public static void registerShutDownHook() { - Runtime runtime = Runtime.getRuntime(); - runtime.addShutdownHook(new ResourceCleanUp()); - ProjectLogger.log("ShutDownHook registered."); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryParams.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryParams.java deleted file mode 100644 index 82df24f79..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryParams.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.sunbird.telemetry.util; - -public enum TelemetryParams { - CHANNEL, - ENV, - ACTOR; -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryUtil.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryUtil.java deleted file mode 100644 index 97e470ecd..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryUtil.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.sunbird.telemetry.util; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.ExecutionContext; -import org.sunbird.common.request.HeaderParam; -import org.sunbird.common.request.Request; - -/** @author arvind */ -public final class TelemetryUtil { - - private TelemetryUtil() {} - - public static Map generateTargetObject( - String id, String type, String currentState, String prevState) { - - Map target = new HashMap<>(); - target.put(JsonKey.ID, id); - target.put(JsonKey.TYPE, StringUtils.capitalize(type)); - target.put(JsonKey.CURRENT_STATE, currentState); - target.put(JsonKey.PREV_STATE, prevState); - return target; - } - - public static Map genarateTelemetryRequest( - Map targetObject, - List> correlatedObject, - String eventType, - Map params) { - - Map map = new HashMap<>(); - map.put(JsonKey.TARGET_OBJECT, targetObject); - map.put(JsonKey.CORRELATED_OBJECTS, correlatedObject); - map.put(JsonKey.TELEMETRY_EVENT_TYPE, eventType); - map.put(JsonKey.PARAMS, params); - - // combine context info into one i.e. request level and system level info into - // one place... - - Map context = getTelemetryContext(); - map.put(JsonKey.CONTEXT, context); - return map; - } - - public static void generateCorrelatedObject( - String id, String type, String corelation, List> correlationList) { - - Map correlatedObject = new HashMap<>(); - correlatedObject.put(JsonKey.ID, id); - correlatedObject.put(JsonKey.TYPE, StringUtils.capitalize(type)); - correlatedObject.put(JsonKey.RELATION, corelation); - - correlationList.add(correlatedObject); - } - - public static Map genarateTelemetryInfoForError(String objectType) { - - Map map = new HashMap<>(); - Map contextInfo = TelemetryUtil.getTelemetryContext(); - - Map params = new HashMap<>(); - params.put(JsonKey.OBJECT_TYPE, objectType); - params.put(JsonKey.ERR_TYPE, JsonKey.API_ACCESS); - - map.put(JsonKey.CONTEXT, contextInfo); - map.put(JsonKey.PARAMS, params); - return map; - } - - public static Map getTelemetryContext() { - - Map context = new HashMap<>(); - context.putAll(ExecutionContext.getCurrent().getRequestContext()); - context.putAll(ExecutionContext.getCurrent().getGlobalContext()); - return context; - } - - public static void addTargetObjectRollUp( - Map rollUpMap, Map targetObject) { - targetObject.put(JsonKey.ROLLUP, rollUpMap); - } - - public static void telemetryProcessingCall( - Map request, - Map targetObject, - List> correlatedObject) { - Map params = new HashMap<>(); - // set additional props for edata related things that will be used for getting the requested - // fields name while telemetry processing - params.put(JsonKey.PROPS, request); - Request req = new Request(); - req.setRequest( - TelemetryUtil.genarateTelemetryRequest( - targetObject, correlatedObject, TelemetryEvents.AUDIT.getName(), params)); - generateTelemetry(req); - } - - public static void telemetryProcessingCall( - Map request, - Map targetObject, - List> correlatedObject, - String eventType) { - - if (eventType.equalsIgnoreCase(TelemetryEvents.AUDIT.getName())) { - Map params = new HashMap<>(); - // set additional props for edata related things ... - params.put( - JsonKey.PROPS, - request.entrySet().stream().map(entry -> entry.getKey()).collect(Collectors.toList())); - - Request req = new Request(); - req.setRequest( - TelemetryUtil.genarateTelemetryRequest( - targetObject, correlatedObject, TelemetryEvents.AUDIT.getName(), params)); - generateTelemetry(req); - } else if (eventType.equalsIgnoreCase(TelemetryEvents.LOG.getName())) { - Map logInfo = request; - long endTime = System.currentTimeMillis(); - logInfo.put(JsonKey.END_TIME, endTime); - Request req = new Request(); - req.setRequest( - generateTelemetryRequest(eventType, logInfo, TelemetryUtil.getTelemetryContext())); - generateTelemetry(req); - } - } - - private static Map generateTelemetryRequest( - String eventType, Map params, Map context) { - - Map map = new HashMap<>(); - map.put(JsonKey.TELEMETRY_EVENT_TYPE, eventType); - map.put(JsonKey.CONTEXT, context); - map.put(JsonKey.PARAMS, params); - return map; - } - - private static void generateTelemetry(Request request) { - // set request id to the context so that can be captured into the telemetry c-data section ... - ExecutionContext.getCurrent() - .getRequestContext() - .put( - JsonKey.REQUEST_ID, - ExecutionContext.getCurrent() - .getGlobalContext() - .get(HeaderParam.REQUEST_ID.getParamName())); - request - .getContext() - .put(JsonKey.TELEMETRY_CONTEXT, ExecutionContext.getCurrent().getRequestContext()); - TelemetryLmaxWriter.getInstance().submitMessage(request); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventFactory.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventFactory.java deleted file mode 100644 index bd7a417ff..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.lmax.disruptor.EventFactory; -import org.sunbird.common.request.Request; - -/** @author Manzarul */ -public class WriteEventFactory implements EventFactory { - @Override - public Request newInstance() { - return new Request(); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventHandler.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventHandler.java deleted file mode 100644 index 069849d77..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventHandler.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.lmax.disruptor.EventHandler; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.LoggerEnum; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.request.Request; -import org.sunbird.telemetry.collector.TelemetryAssemblerFactory; -import org.sunbird.telemetry.collector.TelemetryDataAssembler; -import org.sunbird.telemetry.validator.TelemetryObjectValidator; -import org.sunbird.telemetry.validator.TelemetryObjectValidatorV3; - -/** - * Handler class for telemetry write event - * - * @author arvind - */ -public class WriteEventHandler implements EventHandler { - - private TelemetryFlush telemetryFlush = TelemetryFlush.getInstance(); - private TelemetryDataAssembler telemetryDataAssembler = TelemetryAssemblerFactory.get(); - private TelemetryObjectValidator telemetryObjectValidator = new TelemetryObjectValidatorV3(); - private SunbirdTelemetryEventConsumer consumer = SunbirdTelemetryEventConsumer.getInstance(); - - @Override - public void onEvent(Request request, long l, boolean b) throws Exception { - try { - String eventType = (String) request.getRequest().get(JsonKey.TELEMETRY_EVENT_TYPE); - - if (TelemetryEvents.AUDIT.getName().equalsIgnoreCase(eventType)) { - processAuditEvent(request); - } else if (TelemetryEvents.SEARCH.getName().equalsIgnoreCase(eventType)) { - processSearchEvent(request); - } else if (TelemetryEvents.ERROR.getName().equalsIgnoreCase(eventType)) { - processErrorEvent(request); - } else if (TelemetryEvents.LOG.getName().equalsIgnoreCase(eventType)) { - processLogEvent(request); - } - } catch (Exception ex) { - ProjectLogger.log( - "WriteEventHandler:onEvent: Exception in disruptor consumer - index: " - + l - + " exception = " - + ex, - LoggerEnum.ERROR.name()); - } - } - - private boolean processLogEvent(Request request) { - - boolean success = false; - Map context = (Map) request.getRequest().get(JsonKey.CONTEXT); - Map params = (Map) request.getRequest().get(JsonKey.PARAMS); - String telemetry = telemetryDataAssembler.log(context, params); - if (StringUtils.isNotBlank(telemetry) && telemetryObjectValidator.validateLog(telemetry)) { - telemetryFlush.flushTelemetry(telemetry); - success = true; - } else { - ProjectLogger.log( - "WriteEventHandler:processLogEvent: Audit Telemetry validation failed: ", - telemetry, - LoggerEnum.ERROR.name()); - } - return success; - } - - private boolean processErrorEvent(Request request) { - - boolean success = false; - Map context = (Map) request.get(JsonKey.CONTEXT); - Map params = (Map) request.get(JsonKey.PARAMS); - String telemetry = telemetryDataAssembler.error(context, params); - if (StringUtils.isNotBlank(telemetry) && telemetryObjectValidator.validateError(telemetry)) { - telemetryFlush.flushTelemetry(telemetry); - success = true; - } else { - ProjectLogger.log( - "WriteEventHandler:processLogEvent: Error Telemetry validation failed: ", - telemetry, - LoggerEnum.ERROR.name()); - } - return success; - } - - private boolean processSearchEvent(Request request) { - - boolean success = false; - Map context = (Map) request.get(JsonKey.CONTEXT); - Map params = (Map) request.get(JsonKey.PARAMS); - String telemetry = telemetryDataAssembler.search(context, params); - if (StringUtils.isNotBlank(telemetry) && telemetryObjectValidator.validateSearch(telemetry)) { - telemetryFlush.flushTelemetry(telemetry); - success = true; - } else { - ProjectLogger.log( - "WriteEventHandler:processLogEvent: Search Telemetry validation failed: ", - telemetry, - LoggerEnum.ERROR.name()); - } - return success; - } - - private boolean processAuditEvent(Request request) { - boolean success = false; - Map context = (Map) request.get(JsonKey.CONTEXT); - Map targetObject = (Map) request.get(JsonKey.TARGET_OBJECT); - List> correlatedObjects = - (List>) request.get(JsonKey.CORRELATED_OBJECTS); - Map params = (Map) request.get(JsonKey.PARAMS); - params.put(JsonKey.TARGET_OBJECT, targetObject); - params.put(JsonKey.CORRELATED_OBJECTS, correlatedObjects); - String telemetry = telemetryDataAssembler.audit(context, params); - if (StringUtils.isNotBlank(telemetry) && telemetryObjectValidator.validateAudit(telemetry)) { - if (!Boolean.parseBoolean( - ProjectUtil.getConfigValue(JsonKey.SUNBIRD_AUDIT_EVENT_BATCH_ALLOWED))) { - ProjectLogger.log( - "WriteEventHandler:processLogEvent: Audit Event is going to be processed = ", - LoggerEnum.INFO.name()); - List list = new ArrayList(); - list.add(telemetry); - Request auditRequest = telemetryFlush.createTelemetryRequest(list); - consumer.consume(auditRequest); - } else { - telemetryFlush.flushTelemetry(telemetry); - } - success = true; - } else { - ProjectLogger.log( - "WriteEventHandler:processLogEvent: Audit Telemetry validation failed: ", - telemetry, - LoggerEnum.ERROR.name()); - } - return success; - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventProducer.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventProducer.java deleted file mode 100644 index 10b6a5d7c..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/WriteEventProducer.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.sunbird.telemetry.util; - -import com.lmax.disruptor.EventTranslatorOneArg; -import com.lmax.disruptor.dsl.Disruptor; -import org.sunbird.common.request.Request; - -/** @author Manzarul */ -public class WriteEventProducer { - - private final Disruptor disruptor; - - public WriteEventProducer(Disruptor disruptor) { - this.disruptor = disruptor; - } - - private static final EventTranslatorOneArg TRANSLATOR_ONE_ARG = - new EventTranslatorOneArg() { - public void translateTo(Request writeEvent, long sequence, Request request) { - writeEvent.setRequest(request.getRequest()); - } - }; - - public void onData(Request request) { - // publish the message to disruptor - disruptor.publishEvent(TRANSLATOR_ONE_ARG, request); - } -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidator.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidator.java deleted file mode 100644 index fe5a281d5..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidator.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.sunbird.telemetry.validator; - -/** @author arvind */ -public interface TelemetryObjectValidator { - - public boolean validateAudit(String jsonString); - - public boolean validateSearch(String jsonString); - - public boolean validateLog(String jsonString); - - public boolean validateError(String jsonString); -} diff --git a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidatorV3.java b/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidatorV3.java deleted file mode 100644 index 3624e8117..000000000 --- a/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidatorV3.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.sunbird.telemetry.validator; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.telemetry.dto.Telemetry; -import org.sunbird.telemetry.util.TelemetryEvents; - -/** @author arvind */ -public class TelemetryObjectValidatorV3 implements TelemetryObjectValidator { - - ObjectMapper mapper = new ObjectMapper(); - - @Override - public boolean validateAudit(String jsonString) { - - boolean validationSuccess = true; - List missingFields = new ArrayList<>(); - Telemetry telemetryObj = null; - try { - telemetryObj = mapper.readValue(jsonString, Telemetry.class); - validateBasics(telemetryObj, missingFields); - validateAuditEventData(telemetryObj.getEdata(), missingFields); - if (!missingFields.isEmpty()) { - ProjectLogger.log( - "Telemetry Object Creation Error for event : " - + TelemetryEvents.AUDIT.getName() - + " missing required fields :" - + String.join(",", missingFields)); - validationSuccess = false; - } - } catch (IOException e) { - validationSuccess = false; - ProjectLogger.log(e.getMessage(), e); - } - return validationSuccess; - } - - @Override - public boolean validateSearch(String jsonString) { - - boolean validationSuccess = true; - List missingFields = new ArrayList<>(); - Telemetry telemetryObj = null; - try { - telemetryObj = mapper.readValue(jsonString, Telemetry.class); - validateBasics(telemetryObj, missingFields); - validateSearchEventData(telemetryObj.getEdata(), missingFields); - if (!missingFields.isEmpty()) { - ProjectLogger.log( - "Telemetry Object Creation Error for event : " - + TelemetryEvents.SEARCH.getName() - + " missing required fields :" - + String.join(",", missingFields)); - validationSuccess = false; - } - } catch (IOException e) { - validationSuccess = false; - ProjectLogger.log(e.getMessage(), e); - } - return validationSuccess; - } - - private void validateSearchEventData(Map edata, List missingFields) { - - if (edata == null || edata.isEmpty()) { - missingFields.add("edata"); - } else { - if (null == edata.get(JsonKey.QUERY)) { - missingFields.add(JsonKey.QUERY); - } - if (null == edata.get(JsonKey.SIZE)) { - missingFields.add(JsonKey.SIZE); - } - if (null == edata.get(JsonKey.TOPN)) { - missingFields.add(JsonKey.TOPN); - } - } - } - - private void validateAuditEventData(Map edata, List missingFields) { - if (edata == null) { - missingFields.add("edata"); - } - } - - private void validateBasics(Telemetry telemetryObj, List missingFields) { - - if (StringUtils.isBlank(telemetryObj.getEid())) { - missingFields.add("eid"); - } - if (StringUtils.isBlank(telemetryObj.getMid())) { - missingFields.add("mid"); - } - if (StringUtils.isBlank(telemetryObj.getVer())) { - missingFields.add("ver"); - } - - if (null == telemetryObj.getActor()) { - missingFields.add("actor"); - } else { - if (StringUtils.isBlank(telemetryObj.getActor().getId())) { - missingFields.add("actor.id"); - } - if (StringUtils.isBlank(telemetryObj.getActor().getType())) { - missingFields.add("actor.type"); - } - } - - if (null == telemetryObj.getContext()) { - missingFields.add(JsonKey.CONTEXT); - } else { - if (StringUtils.isBlank(telemetryObj.getContext().getChannel())) { - missingFields.add(JsonKey.CONTEXT + "." + JsonKey.CHANNEL); - } - if (StringUtils.isBlank(telemetryObj.getContext().getEnv())) { - missingFields.add(JsonKey.CONTEXT + "." + JsonKey.ENV); - } - } - } - - @Override - public boolean validateLog(String jsonString) { - - boolean validationSuccess = true; - List missingFields = new ArrayList<>(); - Telemetry telemetryObj = null; - try { - telemetryObj = mapper.readValue(jsonString, Telemetry.class); - validateBasics(telemetryObj, missingFields); - validateLogEventData(telemetryObj.getEdata(), missingFields); - if (!missingFields.isEmpty()) { - ProjectLogger.log( - "Telemetry Object Creation Error for event : " - + TelemetryEvents.LOG.getName() - + " missing required fields :" - + String.join(",", missingFields)); - validationSuccess = false; - } - } catch (IOException e) { - validationSuccess = false; - ProjectLogger.log(e.getMessage(), e); - } - return validationSuccess; - } - - private void validateLogEventData(Map edata, List missingFields) { - if (edata == null || edata.isEmpty()) { - missingFields.add("edata"); - } else { - if (StringUtils.isBlank((String) edata.get(JsonKey.TYPE))) { - missingFields.add(JsonKey.TYPE); - } - if (StringUtils.isBlank((String) edata.get(JsonKey.LEVEL))) { - missingFields.add(JsonKey.LEVEL); - } - // TODO: remember and make this change at the time of re-factoring. - if (StringUtils.isBlank((String) edata.get(JsonKey.MESSAGE))) { - edata.remove(JsonKey.MESSAGE); - } - } - } - - @Override - public boolean validateError(String jsonString) { - - boolean validationSuccess = true; - List missingFields = new ArrayList<>(); - Telemetry telemetryObj = null; - try { - telemetryObj = mapper.readValue(jsonString, Telemetry.class); - validateBasics(telemetryObj, missingFields); - validateErrorEventData(telemetryObj.getEdata(), missingFields); - if (!missingFields.isEmpty()) { - ProjectLogger.log( - "Telemetry Object Creation Error for event : " - + TelemetryEvents.ERROR.getName() - + " missing required fields :" - + String.join(",", missingFields)); - validationSuccess = false; - } - } catch (IOException e) { - validationSuccess = false; - ProjectLogger.log(e.getMessage(), e); - } - return validationSuccess; - } - - private void validateErrorEventData(Map edata, List missingFields) { - if (edata == null || edata.isEmpty()) { - missingFields.add("edata"); - } else { - if (StringUtils.isBlank((String) edata.get(JsonKey.ERROR))) { - missingFields.add(JsonKey.ERROR); - } - if (StringUtils.isBlank((String) edata.get(JsonKey.ERR_TYPE))) { - missingFields.add(JsonKey.ERR_TYPE); - } - if (StringUtils.isBlank((String) edata.get(JsonKey.STACKTRACE))) { - missingFields.add(JsonKey.STACKTRACE); - } - } - } -} diff --git a/sunbird-platform-core/common-util/src/main/resources/OTPSMSTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/OTPSMSTemplate.vm deleted file mode 100644 index 3273ff366..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/OTPSMSTemplate.vm +++ /dev/null @@ -1 +0,0 @@ -One time password to verify your phone number on $installationName is $otp. This is valid for $otpExpiryInMinutes minutes only. \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/acceptFlagMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/acceptFlagMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/acceptFlagMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/cassandra.config.properties b/sunbird-platform-core/common-util/src/main/resources/cassandra.config.properties deleted file mode 100644 index d673fd554..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/cassandra.config.properties +++ /dev/null @@ -1,8 +0,0 @@ -coreConnectionsPerHostForLocal=4 -coreConnectionsPerHostForRemote=2 -maxConnectionsPerHostForLocal=10 -maxConnectionsPerHostForRemote=4 -maxRequestsPerConnection=32768 -heartbeatIntervalSeconds=60 -poolTimeoutMillis=0 -queryLoggerConstantThreshold=300 \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/cassandratablecolumn.properties b/sunbird-platform-core/common-util/src/main/resources/cassandratablecolumn.properties deleted file mode 100644 index 0382f0fa8..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/cassandratablecolumn.properties +++ /dev/null @@ -1,254 +0,0 @@ -id=id -courseid=courseId -coursename=courseName -userid=userId -enrolleddate=enrolledDate -description=description -tocurl=tocUrl -status=status -active=active -delta=delta -courseversion=courseVersion -grade=grade -progress=progress -lastreadcontentid=lastReadContentId -lastreadcontentstatus=lastReadContentStatus -lastreadcontentversion=lastReadContentVersion -datetime=dateTime -contentid=contentId -viewposition=viewPosition -viewcount=viewCount -lastaccesstime=lastAccessTime -completedcount=completedCount -position=position -result=result -score= score -contentversion=contentVersion -lastupdatedtime=lastUpdatedTime -lastcompletedtime=lastCompletedTime -facultyid=facultyId -facultyname=facultyName -organisationid=organisationId -organisationname=organisationName -enrollementstartdate=enrollementStartDate -enrollmentenddate=enrollmentEndDate -courseduration=courseDuration -addedbyid=addedById -addedbyname=addedByName -publishedbyid=publishedById -publishedbyname=publishedByName -createddate=createdDate -publisheddate=publishedDate -updateddate=updatedDate -updatedbyid=updatedById -updatedbyname=updatedByName -createdfor=createdFor -tutor=tutor -email=email -phone=phone -aadhaarno=aadhaarNo -updatedby=updatedBy -lastlogintime=lastLoginTime -firstname=firstName -lastname=lastName -password=password -avatar=avatar -gender=gender -language=language -state=state -city=city -zipcode=zipcode -username=userName -pagename=pageName -pagesectionname=pageSectionName -sectionorder=sectionOrder -description=description -imgurl=imgUrl -searchquery=searchQuery -searchurl=searchUrl -applicablefor=applicableFor -createdby=createdBy -courselogourl=courseLogoUrl -name=name -portalmap=portalMap -appmap=appMap -sectiondatatype=sectionDataType -addedby=addedBy -updatedby=updatedBy -usercount=userCount -timetaken=timeTaken -assessmentitemid=assessmentItemId -maxscore=maxScore -attemptid=attemptId -assessmenttype=assessmentType -attempteddate=attemptedDate -evaluationstatus=evaluationStatus -processingstatus=processingStatus -attemptedcount=attemptedCount -rootorgid=rootOrgId -regorgid=regOrgId -addtype=addType -addressline1=addressLine1 -addressline2=addressLine2 -yearofpassing=yearOfPassing -boardoruniversity=boardOrUniversity -jobname=jobName -joiningdate=joiningDate -enddate=endDate -orgid=orgId -orgname=orgName -boardname=boardName -addressid=addressId -isrejected=isRejected -isverified=isVerified -verifiedby=verifiedBy -verifieddate=verifiedDate -externalidvalue=externalIdValue -externalid=externalId -loginid=loginId -parentorgid=parentOrgId -isrootorg=isRootOrg -orgidone=orgIdOne -orgidtwo=orgIdTwo -parentof=parentOf -orgtype=orgType -childof=childOf -rootorg=rootOrg -approveddate=approvedDate -approvedbyname=approvedByName -iscurrentjob=isCurrentJob -noofmembers=noOfMembers -homeurl=homeUrl -isapproved=isApproved -orgcode=orgCode -approvedby=approvedBy -preferredlanguage=preferredLanguage -communityid=communityId -isdeleted=isDeleted -profilesummary=profileSummary -orgleftdate=orgLeftDate -isdefault=isDefault -leafnodescount=leafNodesCount -processstarttime=processStartTime -successresult=successResult -failureresult=failureResult -objecttype=objectType -uploadedby=uploadedBy -uploadeddate=uploadedDate -processendtime=processEndTime -enrollmenttype=enrollmentType -participant=participant -enrolmenttype=enrolmentType -startdate=startDate -enddate=endDate -lastupdatedon=lastUpdatedOn -createdfor=createdFor -coursecreator=courseCreator -courseadditionalinfo=courseAdditionalInfo -submitdate=submitDate -objectids=objectIds -countincrementstatus=countIncrementStatus -countincrementdate=countIncrementDate -countdecrementstatus=countDecrementStatus -countdecrementdate=countDecrementDate -contactdetail=contactDetail -hashtagid=hashTagId -theme =theme -batchid=batchId -isactive=isActive -badgetypeid=badgeTypeId -receiveddate=receivedDate -receiverid=receiverId -providerid=providerId -providername=providerName -provideremail=providerEmail -providerphone=providerPhone -validitydate=validityDate -expirydate=expiryDate -isverified=isVerified -isexpired=isExpired -isrevoked=isRevoked -revocationreason=revocationReason -revocationdate=revocationDate -revokedby=revokedBy -verifiedby=verifiedBy -verifieddate=verifiedDate -fileurl=fileUrl -trycount=tryCount -resourceid=resourceId -missingfields=missingFields -webpages=webPages -temppassword=tempPassword -currentlogintime=currentLoginTime -skillname=skillName -skillnametolowercase=skillNameToLowercase -addedby=addedBy -addedat=addedAt -endorsementcount=endorsementCount -endorsers=endorsers -profilevisibility=profileVisibility -orgtypeid=orgTypeId -retrycount=retryCount -tcstatus=tcStatus -tcupdatedat=tcUpdatedAt -tcupdateddate=tcUpdatedDate -clientname=clientName -masterkey=masterKey -locationid=locationId -countrycode=countryCode -endorserslist=endorsersList -emailverified=emailVerified -locationids=locationIds -userlistreq=userListReq -estimatedcountreq=estimatedCountReq -usercountttl=userCountTTL -issuerid=issuerId -resourcename=resourceName -badgeid=badgeId -badgeclassimage=badgeClassImage -assertionid=assertionId -badgeclassname=badgeClassName -parentid=parentId -taskcount=taskCount -sequenceid=sequenceId -iterationid=iterationId -processid=processId -createdon=createdOn -registryid=registryId -lastupdatedby=lastUpdatedBy -idtype=idType -originalexternalid=originalExternalId -originalprovider=originalProvider -originalidtype=originalIdType -rolegroupid=roleGroupId -url_action_ids=url_Action_Ids -usertype=userType -storagedetails=storageDetails -completedon=completedOn -tncacceptedon=tncAcceptedOn -tncacceptedversion=tncAcceptedVersion -phoneverified=phoneVerified -datasource=dataSource -maskedemail=maskedEmail -maskedphone=maskedPhone -prevusedemail=prevUsedEmail -prevusedphone=prevUsedPhone -otherlink=otherLink -recoveryemail=recoveryEmail -recoveryphone=recoveryPhone -userextid=userExtId -orgextid=orgExtId -userstatus=userStatus -claimstatus=claimStatus -claimedon=claimedOn -updatedon=updatedOn -flagsvalue=flagsValue -userids=userIds -telemetrycontext=telemetryContext -isssoenabled=isSSOEnabled -dynamicfilters=dynamicFilters -managedby=managedBy -membershiptype=membershipType -groupid=groupId -removedby=removedBy -removedon=removedOn \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/contentFlaggedMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/contentFlaggedMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/contentFlaggedMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/contentReviewMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/contentReviewMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/contentReviewMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/dbconfig.properties b/sunbird-platform-core/common-util/src/main/resources/dbconfig.properties deleted file mode 100644 index 564bec920..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/dbconfig.properties +++ /dev/null @@ -1,6 +0,0 @@ -db.ip=127.0.0.1 -db.port=9042 -db.username= -db.password= -db.keyspace=sunbird - diff --git a/sunbird-platform-core/common-util/src/main/resources/elasticsearch.config.properties b/sunbird-platform-core/common-util/src/main/resources/elasticsearch.config.properties deleted file mode 100644 index 564aaedcb..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/elasticsearch.config.properties +++ /dev/null @@ -1,3 +0,0 @@ -es.cluster.name= -es.host.name=localhost -es.host.port=9300 \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/emailtemplate.vm b/sunbird-platform-core/common-util/src/main/resources/emailtemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/emailtemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/externalresource.properties b/sunbird-platform-core/common-util/src/main/resources/externalresource.properties deleted file mode 100644 index b2df73767..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/externalresource.properties +++ /dev/null @@ -1,201 +0,0 @@ -content_url=/content/v3/hierarchy/ -ekstep_content_search_url=/v3/search -ekstep_telemetry_api_url=/data/v3/telemetry -ekstep_authorization= -ekstep_course_publish_url=/content/v3/publish -ekstep_metrics_api_url=/metrics/consumption/content-usage -ekstep_es_metrics_api_url=/metrics/creation/content-snapshot -ekstep.tag.api.url=/tag/register -ekstep.content.update.url=/system/v3/content/update/ -sunbird.content.badge.assign.url=/v1/content/badge/assign/ -sunbird.content.badge.revoke.url=/v1/content/badge/revoke/ -sunbird_installation=sunbird -sunbird_analytics_api_base_url=https://dev.ekstep.in/api/data/v3 -sunbird_search_service_api_base_url=https://dev.ekstep.in/api/search -ekstep_api_base_url=https://dev.ekstep.in/api -sunbird_user_org_api_base_url=https://dev.sunbirded.org/api -sunbird_search_organisation_api=/v1/org/search -sunbird_read_user_api=/v1/user/read -sunbird_search_user_api=/v1/user/search -sunbird_send_email_notifictaion_api=/v1/notification/email -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 -ekstep_concept_base_url=/domain/v3/{domain}/concepts/list -ekstep_domain_url=/domain/v3/list -quartz_course_batch_timer=0 0 0/4 1/1 * ? * -quartz_upload_timer=0 0 23 1/1 * ? * -quartz_course_publish_timer=0 0 0/1 1/1 * ? * -quartz_matrix_report_timer=0 0 0/4 1/1 * ? * -quartz_shadow_user_migration_timer=0 0 2 1/1 * ? * -sunbird_account_name= -sunbird_account_key= -download_link_expiry_timeout=300 -sunbird_encryption_key=SunBird -sunbird_encryption_mode=local -quartz_metrics_timer =0 0 0/4 * * ? * -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 -bulk_upload_batch_data_size=200 -user_relations=address,education,jobProfile,orgUser -org_relations=orgUser,address -batch_relations= -default_date_range=7 -sunbird_web_url=https://dev.sunbirded.org -sunbird_app_url= -sunbird_channel_read_api=/v1/channel/read -sunbird_framework_read_api=/v1/framework/read -# background actor modes {local,remote} -background_actor_provider=remote -# actor modes {local,remote} -api_actor_provider=local -# cassandra modes {standalone,embedded} -sunbird_cassandra_mode=standalone -embeddedCassandra_TimeOut=20000000000 -embedded_cassandra_host=127.0.0.1 -embedded_cassandra_port=9142 -#file to load cassandra DB into memory. -embedded_cql_file_name=cassandra.cql -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 -es_search_url=http://localhost:9200 -es_metrics_port=9200 -system_settings_properties=phoneUnique,emailUnique -sunbird_default_welcome_sms=Welcome to DIKSHA. -quartz_update_user_count_timer=0 0 2 1/1 * ? * -sunbird_url_shortner_base_url=https://api-ssl.bitly.com/v3/shorten?access_token= -sunbird_url_shortner_access_token= -ekstep.channel.reg.api.url=/channel/v3/create -ekstep.channel.list.api.url=/channel/v3/list -quartz_channel_reg_timer=0 0 1 1/1 * ? * -sunbird_otp_allowed_attempt=2 - -#Telemetry producer related info -telemetry_pdata_id=local.sunbird.learning.service -telemetry_pdata_pid=learning-service -telemetry_pdata_ver=2.10.0 -#elastic search top n result count for telemetry -searchTopN=5 -telemetry_queue_threshold_value=200 -ekstep.channel.update.api.url=/channel/v3/update -sunbird_badger_baseurl=http://localhost:8000 -# badge related info. -badging_authorization_key= -badging_assertion_list_size=5 -sunbird_valid_badge_subtypes=award,certificate,endorsement,authorization -sunbird_valid_badge_roles=TEACHER_BADGE_ISSUER,OFFICIAL_TEXTBOOK_BADGE_ISSUER -sunbird_learner_service_url=http://localhost:9000 -sunbird_content_read=/content/v3/read -# Sunbird lms telemetry url -sunbird_lms_base_url=http://localhost:9000 -sunbird_telemetry_api_path=/v1/telemetry -sunbird_lms_authorization= -# Sunbird Installation mail -sunbird_installation_email=dummy@dummy.org -sunbird_valid_location_types=state,district,block;cluster -# 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_telemetry_base_url=http://localhost:9000 -sunbird_cs_search_path=/composite/v1/search -# Sunbird OpenSaber Integration -sunbird_open_saber_bridge_enable=false -sunbird_default_user_type=teacher -sunbird_installation_display_name=sunbird -sunbird_app_name= -sunbird_email_max_recipients_limit=100 -sunbird_user_max_encryption_limit=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_user_profile_field_default_visibility=public -sunbird_api_request_lower_case_fields=source,externalId,userName,provider,loginId,email,prevUsedEmail -# Textbook TOC Api -sunbird_content_read_api=/content/v3/read -textbook_toc_allowed_content_types=TextBook,Collection,LessonPlan -sunbird_get_hierarchy_api=/content/v3/hierarchy -sunbird_update_hierarchy_api=/content/v3/hierarchy/update -textbook_toc_max_csv_rows=6500 -textbook_toc_input_mapping={\"identifier\":\"Identifier\",\"frameworkCategories\":{\"board\":\"Board\",\"medium\":\"Medium\",\"gradeLevel\":\"Grade\",\"subject\":\"Subject\"},\"hierarchy\":{\"Textbook\":\"Textbook Name\",\"L:1\":\"Level 1 Textbook Unit\",\"L:2\":\"Level 2 Textbook Unit\",\"L:3\":\"Level 3 Textbook Unit\",\"L:4\":\"Level 4 Textbook Unit\"},\"metadata\":{\"description\":\"Description\",\"topic\":\"Mapped Topics\",\"keywords\":\"Keywords\",\"purpose\":\"Purpose of Content to be linked\",\"dialcodeRequired\":\"QR Code Required?\",\"dialcodes\":\"QR Code\"}} -textbook_toc_file_suppress_column_names=true -sunbird_texbook_toc_csv_ttl=86400 -textbook_toc_mandatory_fields={\"Textbook\":\"Textbook Name\",\"L:1\":\"Level 1 Textbook Unit\"} -sunbird_toc_linked_content_column_name=Linked Content {0} -sunbird_toc_max_first_level_units=30 -sunbird_content_cloud_storage_type=azure -sunbird_content_azure_storage_container=sunbird-content-dev -sunbird_cloud_content_folder=content -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 -framework_read_api_url=/framework/v3/read -sunbird_link_dial_code_api=/collection/v3/dialcode/link -sunbird_linked_content_base_url=https://dev.sunbirded.org/play/content/ -textbook_toc_output_mapping={\"identifier\":\"Identifier\",\"frameworkCategories\":{\"board\":\"Board\",\"medium\":\"Medium\",\"gradeLevel\":\"Grade\",\"subject\":\"Subject\"},\"hierarchy\":{\"Textbook\":\"Textbook Name\",\"L:1\":\"Level 1 Textbook Unit\",\"L:2\":\"Level 2 Textbook Unit\",\"L:3\":\"Level 3 Textbook Unit\",\"L:4\":\"Level 4 Textbook Unit\"},\"metadata\":{\"description\":\"Description\",\"topic\":\"Mapped Topics\",\"keywords\":\"Keywords\",\"purpose\":\"Purpose of Content to be linked\",\"dialcodeRequired\":\"QR Code Required?\",\"dialcodes\":\"QR Code\"},\"linkedContent\":{\"Linked Content 1\":\"Linked Content 1\",\"Linked Content 2\":\"Linked Content 2\",\"Linked Content 3\":\"Linked Content 3\",\"Linked Content 4\":\"Linked Content 4\",\"Linked Content 5\":\"Linked Content 5\",\"Linked Content 6\":\"Linked Content 6\",\"Linked Content 7\":\"Linked Content 7\",\"Linked Content 8\":\"Linked Content 8\",\"Linked Content 9\":\"Linked Content 9\",\"Linked Content 10\":\"Linked Content 10\",\"Linked Content 11\":\"Linked Content 11\",\"Linked Content 12\":\"Linked Content 12\",\"Linked Content 13\":\"Linked Content 13\",\"Linked Content 14\":\"Linked Content 14\",\"Linked Content 15\":\"Linked Content 15\",\"Linked Content 16\":\"Linked Content 16\",\"Linked Content 17\":\"Linked Content 17\",\"Linked Content 18\":\"Linked Content 18\",\"Linked Content 19\":\"Linked Content 19\",\"Linked Content 20\":\"Linked Content 20\",\"Linked Content 21\":\"Linked Content 21\",\"Linked Content 22\":\"Linked Content 22\",\"Linked Content 23\":\"Linked Content 23\",\"Linked Content 24\":\"Linked Content 24\",\"Linked Content 25\":\"Linked Content 25\"},\"Linked Content 26\":\"Linked Content 26\",\"Linked Content 27\":\"Linked Content 27\",\"Linked Content 28\":\"Linked Content 28\",\"Linked Content 29\":\"Linked Content 29\",\"Linked Content 30\":\"Linked Content 30\"} -# For other environments -sunbird_content_search_url=/v1/content/search -# For Local -# sunbird_content_search_url=/content/v1/search -sunbird_time_zone=Asia/Kolkata -# For other environments -sunbird_dialcode_search_api=/v1/dialcode/list -# For Local -# sunbird_dialcode_search_api=/dialcode/v1/list -sunbird_cs_base_url=https://dev.sunbirded.org/api -sunbird_health_check_enable=true -sunbird_sync_read_wait_time=1500 -sunbird_course_metrics_container=reports -sunbird_course_metrics_report_folder=course-progress-reports -sunbird_assessment_report_folder=assessment-reports -sunbird_gzip_size_threshold=262144 -sunbird_analytics_blob_account_name= -sunbird_analytics_blob_account_key= -sunbird_redis_port=6379 -sunbird_redis_host=127.0.0.1 -sunbird_redis_scan_interval=2000 -sunbird_cache_enable=false -sunbird_redis_connection_pool_size=250 -kafka_topics_instruction=local.coursebatch.job.request -kafka_urls=localhost:9092 -sunbird_audit_event_batch_allowed=false -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_topics_certificate_instruction=local.certificate.job.request -kafka_linger_ms=5 -sunbird_cert_service_base_url= -sunbird_cert_download_uri=/v1/user/certs/download -#{0} instancename , {1} toaccountemail or phone in mask , {2} from account email/phone in mask -sunbird_account_merge_body=All your {0} usage details are merged into your account {1} . The account {2} has been deleted -sunbird_user_upload_error_visualization_threshold=20001 -sunbird_course_completion_certificate_name=100PercentCompletionCertificate -sunbird_migrate_user_body=You can now access your {0} state teacher account using {1}. Please log out and login once again to see updated details. -kafka_assessment_topic=local.telemetry.assess -sunbird_account_merge_subject=Account merged successfully -sunbird_pass_regex=(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!\"#$%&'()*+,-./:;<=>?@\\[\\]^_`{|}~])(?=\\S+$).{8,} -sunbird_cert_template_url=/cert/v1/template/read -sunbird_user_create_sync_type=ES -sunbird_user_create_sync_topic=local.user.events -sigterm_stop_delay=40 -sunbird_user_qrcode_courses_limit=5000 diff --git a/sunbird-platform-core/common-util/src/main/resources/forgotPasswordWithOTP.vm b/sunbird-platform-core/common-util/src/main/resources/forgotPasswordWithOTP.vm deleted file mode 100644 index 66325cf60..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/forgotPasswordWithOTP.vm +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - -
  -
- - - - - - - - - - -
- - - - - - -
- - - - - - - - - - -
-

Someone just requested to change your $realmName account's credentials. If this was you, use below OTP to reset your credentials. -

-
-

OTP : $otp

-
-

This OTP will expire within $ttl Minute.

- -
-

If you don't want to reset your credentials, just ignore this message and nothing will be changed.

-
-
-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/forgotpassword.vm b/sunbird-platform-core/common-util/src/main/resources/forgotpassword.vm deleted file mode 100644 index d772a3a52..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/forgotpassword.vm +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - -
  -
- - - - - - - - - - -
- - - - - - -
-

Hi $name,

- - - - - - - - - -
-

Please find the temporary password below, do the password change after first login: -

- -

Password : $tempPassword

- -
-

- - - - - - - -
-

- #if ($webUrl) - Web acccess URL : Click here - #end -

-

- #if ($appUrl) - Download App : Click here - #end -

- -
-
-

Thank You,

-

Team $orgName

-

#if ($note) - $note $fromEmail. - #end -

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/mailTemplates.properties b/sunbird-platform-core/common-util/src/main/resources/mailTemplates.properties deleted file mode 100644 index 0a2f67f88..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/mailTemplates.properties +++ /dev/null @@ -1,5 +0,0 @@ -orgName=Diksha -onboarding_mail_subject=Welcome to {0} -onboarding_welcome_message=Welcome to {0} -onboarding_welcome_mail_body=Please ensure that you change your password according to instructions when you log in for the first time. -mail_note=Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to diff --git a/sunbird-platform-core/common-util/src/main/resources/profilecompleteness.properties b/sunbird-platform-core/common-util/src/main/resources/profilecompleteness.properties deleted file mode 100644 index 4eb3f3ae2..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/profilecompleteness.properties +++ /dev/null @@ -1,6 +0,0 @@ -user.profile.attribute=firstName,lastName,dob,avatar,gender,grade,language,location,profileSummary,subject,userName,address,education,jobProfile -#if u want equal weighted then don't provide any values here.By default all the key will be equally divided by 100%. -#you can provide your weighted in same attribute order. if you are providing values make sure sum of all values is 100 and either -#provide for all attribute or none. value should be either int or float -#6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25,6.25 -user.profile.weighted= \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/publishContentMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/publishContentMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/publishContentMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/rejectContentMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/rejectContentMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/rejectContentMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/rejectFlagMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/rejectFlagMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/rejectFlagMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/sso.properties b/sunbird-platform-core/common-util/src/main/resources/sso.properties deleted file mode 100644 index ce3a6507a..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/sso.properties +++ /dev/null @@ -1,4 +0,0 @@ -sso.url= -sso.realm=sunbird -sso.connection.pool.size=20 -sso.enabled=true diff --git a/sunbird-platform-core/common-util/src/main/resources/unlistedPublishContentMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/unlistedPublishContentMailTemplate.vm deleted file mode 100644 index 50ff99ca9..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/unlistedPublishContentMailTemplate.vm +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - -
  -
- - - - - - - - -
- - - - - - - -
- - #if ($orgImageUrl) -

logo

- #end -
- #if ($name) -

Hi $name,

- #end -

$body

- - - - - - -
- - - #if ($actionUrl) - - - - #end - -
#if ($actionName) $actionName #end
-
-

Regards,

-

Team - #if ($orgName) - $orgName - #end -

-

Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to $fromEmail.

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/userencryption.properties b/sunbird-platform-core/common-util/src/main/resources/userencryption.properties deleted file mode 100644 index 794ad22de..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/userencryption.properties +++ /dev/null @@ -1,6 +0,0 @@ -userkey.encryption=email,phone,userName,location,loginId,prevUsedEmail,prevUsedPhone,recoveryEmail,recoveryPhone -addresskey.encryption=addressLine1,addressLine2,city,state,country,zipcode,userId,updatedBy,createdBy -userkey.decryption=encEmail,encPhone,userName,location,loginId,email,phone,prevUsedEmail,prevUsedPhone,recoveryEmail,recoveryPhone -userkey.masked=email,phone,recoveryEmail,recoveryPhone,prevUsedPhone,recoveryEmail,prevUsedEmail -userkey.phonetypeattributes=phone,recoveryPhone,prevUsedPhone -userkey.emailtypeattributes=email,recoveryEmail,prevUsedEmail \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/welcomeMailTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/welcomeMailTemplate.vm deleted file mode 100644 index 0e7ae7796..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/welcomeMailTemplate.vm +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - -
  -
- - - - - - - - - - -
- - - - - - -
-

$welcomeMessage,

- - - - - - - - - -
-

Your user account has now been created. Click on the link below to #if ($setPasswordLink) set a password #else verify your email ID #end and start using your account: -

-

- - #if ($setPasswordLink) - Set Password - #else - Verify Email - #end - -

-
-
-

Regards,

-

Team $orgName

-

#if ($note) - $note $fromEmail. - #end -

-
-
- -
-
 
- - \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/main/resources/welcomeSmsTemplate.vm b/sunbird-platform-core/common-util/src/main/resources/welcomeSmsTemplate.vm deleted file mode 100644 index e66670b65..000000000 --- a/sunbird-platform-core/common-util/src/main/resources/welcomeSmsTemplate.vm +++ /dev/null @@ -1,2 +0,0 @@ -Welcome to $instanceName. Your user account has now been created. Click on the link below to #if ($setPasswordLink) set a password #else verify your email ID #end and start using your account:$newline -$link \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/exception/ExceptionTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/exception/ExceptionTest.java deleted file mode 100644 index f1d336165..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/exception/ExceptionTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/** */ -package org.sunbird.common.exception; - -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class ExceptionTest { - - @Test - public void testProjectCommonException() { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.apiKeyRequired.getErrorCode(), - ResponseCode.apiKeyRequired.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - Assert.assertEquals(exception.getCode(), ResponseCode.apiKeyRequired.getErrorCode()); - Assert.assertEquals(exception.getMessage(), ResponseCode.apiKeyRequired.getErrorMessage()); - Assert.assertEquals(exception.getResponseCode(), ResponseCode.CLIENT_ERROR.getResponseCode()); - } - - @Test - public void testProjectCommonExceptionUsingSetters() { - ProjectCommonException exception = - new ProjectCommonException( - ResponseCode.apiKeyRequired.getErrorCode(), - ResponseCode.apiKeyRequired.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode()); - Assert.assertEquals(exception.getCode(), ResponseCode.apiKeyRequired.getErrorCode()); - Assert.assertEquals(exception.getMessage(), ResponseCode.apiKeyRequired.getErrorMessage()); - Assert.assertEquals(exception.getResponseCode(), ResponseCode.CLIENT_ERROR.getResponseCode()); - exception.setCode(ResponseCode.userAlreadyExists.getErrorCode()); - exception.setMessage(ResponseCode.userAlreadyExists.getErrorMessage()); - exception.setResponseCode(ResponseCode.SERVER_ERROR.getResponseCode()); - Assert.assertEquals(exception.getCode(), ResponseCode.userAlreadyExists.getErrorCode()); - Assert.assertEquals(exception.getMessage(), ResponseCode.userAlreadyExists.getErrorMessage()); - Assert.assertEquals(exception.getResponseCode(), ResponseCode.SERVER_ERROR.getResponseCode()); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/AppTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/AppTest.java deleted file mode 100644 index 80d4d9353..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/AppTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -package org.sunbird.common.models; - -import java.util.HashMap; -import java.util.Map; - -import jdk.nashorn.internal.ir.annotations.Ignore; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.sunbird.common.models.util.BaseHttpTest; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.common.models.util.PropertiesCache; -@Ignore -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -public class AppTest extends BaseHttpTest { - private static final String data = - "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"; - private static Map headers = new HashMap(); - - @BeforeClass - public static void init() { - headers.put("content-type", "application/json"); - headers.put("accept", "application/json"); - headers.put("user-id", "mahesh"); - String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); - if (StringUtils.isBlank(header)) { - header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); - } - headers.put("authorization", "Bearer " + header); - } - - @Test - public void testSendPostRequestSuccess() throws Exception { - String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL); - if (StringUtils.isBlank(ekStepBaseUrl)) { - ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL); - } - String response = HttpUtil.sendPostRequest(ekStepBaseUrl + "/content/v3/list", data, headers); - Assert.assertNotNull(response); - } - - @Test() - public void testSendPostRequestFailureWithWrongUrl() { - String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL); - if (StringUtils.isBlank(ekStepBaseUrl)) { - ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL); - } - String response = null; - try { - Map data = new HashMap<>(); - data.put("search", "\"contentType\": [\"Story\"]"); - response = HttpUtil.sendPostRequest(ekStepBaseUrl + "/content/wrong/v3/list", data, headers); - } catch (Exception e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertNull(response); - } - @Ignore - @Test - public void testSendPatchRequestSuccess() { - String response = null; - try { - String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL); - if (StringUtils.isBlank(ekStepBaseUrl)) { - ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL); - } - response = - HttpUtil.sendPatchRequest( - ekStepBaseUrl - + PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_TAG_API_URL) - + "/" - + "testt123", - "{}", - headers); - } catch (Exception e) { - } - Assert.assertNotNull(response); - } -} -*/ diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ClientErrorResponseTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ClientErrorResponseTest.java deleted file mode 100644 index 8e5d64b88..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ClientErrorResponseTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.sunbird.common.models; - -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.response.ResponseParams; -import org.sunbird.common.responsecode.ResponseCode; - -public class ClientErrorResponseTest { - - @Test - public void responseCreate() { - org.sunbird.common.models.response.Response response = - new org.sunbird.common.models.response.ClientErrorResponse(); - response.setId("test"); - response.setTs("1233444555"); - response.setVer("v1"); - ResponseParams params = new ResponseParams(); - params.setErr("Server Error"); - params.setErrmsg("test msg"); - params.setMsgid("123"); - params.setResmsgid("4566"); - params.setStatus("OK"); - response.setParams(params); - Assert.assertEquals(response.getId(), "test"); - Assert.assertEquals(response.getTs(), "1233444555"); - Assert.assertEquals(response.getVer(), "v1"); - Assert.assertEquals(response.getParams(), params); - Assert.assertEquals(response.getResponseCode(), ResponseCode.CLIENT_ERROR); - Assert.assertEquals(response.getParams().getErr(), params.getErr()); - Assert.assertEquals(response.getParams().getErrmsg(), params.getErrmsg()); - Assert.assertEquals(response.getParams().getMsgid(), params.getMsgid()); - Assert.assertEquals(response.getParams().getResmsgid(), params.getResmsgid()); - Assert.assertEquals(response.getParams().getStatus(), params.getStatus()); - Assert.assertEquals(response.getResult().size(), 0); - Assert.assertNotEquals(response.get("Test"), "test"); - response.putAll(new HashMap()); - response.put("test", "test123"); - org.sunbird.common.models.response.Response responseClone = response.clone(response); - Assert.assertNotEquals(response, responseClone); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/RequestParamsTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/RequestParamsTest.java deleted file mode 100644 index 3a2178e13..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/RequestParamsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** */ -package org.sunbird.common.models; - -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.request.RequestParams; - -/** @author Manzarul */ -public class RequestParamsTest { - - @Test - public void testResponseParamBean() { - RequestParams params = new RequestParams(); - params.setAuthToken("auth_1233"); - params.setCid("cid"); - params.setDid("deviceId"); - params.setKey("account key"); - params.setMsgid("uniqueMsgId"); - params.setSid("sid"); - params.setUid("UUID"); - Assert.assertEquals(params.getAuthToken(), "auth_1233"); - Assert.assertEquals(params.getCid(), "cid"); - Assert.assertEquals(params.getMsgid(), "uniqueMsgId"); - Assert.assertEquals(params.getDid(), "deviceId"); - Assert.assertEquals(params.getKey(), "account key"); - Assert.assertEquals(params.getSid(), "sid"); - Assert.assertEquals(params.getUid(), "UUID"); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseParamsTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseParamsTest.java deleted file mode 100644 index 36ec08b42..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseParamsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** */ -package org.sunbird.common.models; - -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.response.ResponseParams; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class ResponseParamsTest { - - @Test - public void testResponseParamBean() { - ResponseParams params = new ResponseParams(); - params.setErr(ResponseCode.addressError.getErrorCode()); - params.setErrmsg(ResponseCode.addressError.getErrorMessage()); - params.setMsgid("test"); - params.setResmsgid("test-1"); - params.setStatus("OK"); - Assert.assertEquals(params.getErr(), ResponseCode.addressError.getErrorCode()); - Assert.assertEquals(params.getErrmsg(), ResponseCode.addressError.getErrorMessage()); - Assert.assertEquals(params.getMsgid(), "test"); - Assert.assertEquals(params.getResmsgid(), "test-1"); - Assert.assertEquals(params.getStatus(), "OK"); - Assert.assertEquals(ResponseParams.StatusType.FAILED.name(), "FAILED"); - Assert.assertEquals(ResponseParams.StatusType.SUCCESSFUL.name(), "SUCCESSFUL"); - Assert.assertEquals(ResponseParams.StatusType.WARNING.name(), "WARNING"); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseTest.java deleted file mode 100644 index 484c86487..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/** */ -package org.sunbird.common.models; - -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.response.ResponseParams; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class ResponseTest { - - @Test - public void responseCreate() { - org.sunbird.common.models.response.Response response = - new org.sunbird.common.models.response.Response(); - response.setId("test"); - response.setResponseCode(ResponseCode.SERVER_ERROR); - response.setTs("1233444555"); - response.setVer("v1"); - ResponseParams params = new ResponseParams(); - params.setErr("Server Error"); - params.setErrmsg("test msg"); - params.setMsgid("123"); - params.setResmsgid("4566"); - params.setStatus("OK"); - response.setParams(params); - Assert.assertEquals(response.getId(), "test"); - Assert.assertEquals(response.getTs(), "1233444555"); - Assert.assertEquals(response.getVer(), "v1"); - Assert.assertEquals(response.getParams(), params); - Assert.assertEquals(response.getResponseCode(), ResponseCode.SERVER_ERROR); - Assert.assertEquals(response.getParams().getErr(), params.getErr()); - Assert.assertEquals(response.getParams().getErrmsg(), params.getErrmsg()); - Assert.assertEquals(response.getParams().getMsgid(), params.getMsgid()); - Assert.assertEquals(response.getParams().getResmsgid(), params.getResmsgid()); - Assert.assertEquals(response.getParams().getStatus(), params.getStatus()); - Assert.assertEquals(response.getResult().size(), 0); - Assert.assertNotEquals(response.get("Test"), "test"); - response.putAll(new HashMap()); - response.put("test", "test123"); - org.sunbird.common.models.response.Response responseClone = response.clone(response); - Assert.assertNotEquals(response, responseClone); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ActorOperationTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ActorOperationTest.java deleted file mode 100644 index 570622797..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ActorOperationTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import org.junit.Assert; -import org.junit.Test; - -/** @author Manzarul */ -public class ActorOperationTest { - - @Test - public void testActorOperation() { - Assert.assertEquals("enrollCourse", ActorOperations.ENROLL_COURSE.getValue()); - Assert.assertEquals("getCourse", ActorOperations.GET_COURSE.getValue()); - Assert.assertEquals("getContent", ActorOperations.GET_CONTENT.getValue()); - Assert.assertEquals("addContent", ActorOperations.ADD_CONTENT.getValue()); - Assert.assertEquals("createCourse", ActorOperations.CREATE_COURSE.getValue()); - Assert.assertEquals("updateCourse", ActorOperations.UPDATE_COURSE.getValue()); - Assert.assertEquals("publishCourse", ActorOperations.PUBLISH_COURSE.getValue()); - Assert.assertEquals("searchCourse", ActorOperations.SEARCH_COURSE.getValue()); - Assert.assertEquals("deleteCourse", ActorOperations.DELETE_COURSE.getValue()); - Assert.assertEquals("sendNotification", ActorOperations.SEND_NOTIFICATION.getValue()); - Assert.assertEquals("syncKeycloak", ActorOperations.SYNC_KEYCLOAK.getValue()); - Assert.assertEquals("updateSystemSettings", ActorOperations.UPDATE_SYSTEM_SETTINGS.getValue()); - Assert.assertEquals("deleteGeoLocation", ActorOperations.DELETE_GEO_LOCATION.getValue()); - Assert.assertEquals("getUserCount", ActorOperations.GET_USER_COUNT.getValue()); - Assert.assertEquals("updateGeoLocation", ActorOperations.UPDATE_GEO_LOCATION.getValue()); - Assert.assertEquals("getGeoLocation", ActorOperations.GET_GEO_LOCATION.getValue()); - Assert.assertEquals("registerClient", ActorOperations.REGISTER_CLIENT.getValue()); - Assert.assertEquals("updateClientKey", ActorOperations.UPDATE_CLIENT_KEY.getValue()); - Assert.assertEquals("getClientKey", ActorOperations.GET_CLIENT_KEY.getValue()); - Assert.assertEquals("createGeoLocation", ActorOperations.CREATE_GEO_LOCATION.getValue()); - Assert.assertEquals( - "updateTenantPreference", ActorOperations.UPDATE_TENANT_PREFERENCE.getValue()); - Assert.assertEquals("getTenantPreference", ActorOperations.GET_TENANT_PREFERENCE.getValue()); - Assert.assertEquals("addSkill", ActorOperations.ADD_SKILL.getValue()); - Assert.assertEquals("getSkill", ActorOperations.GET_SKILL.getValue()); - Assert.assertEquals("getSkillsList", ActorOperations.GET_SKILLS_LIST.getValue()); - Assert.assertEquals("profileVisibility", ActorOperations.PROFILE_VISIBILITY.getValue()); - Assert.assertEquals( - "createTanentPreference", ActorOperations.CREATE_TENANT_PREFERENCE.getValue()); - Assert.assertEquals("createUser", ActorOperations.CREATE_USER.getValue()); - Assert.assertEquals("updateUser", ActorOperations.UPDATE_USER.getValue()); - Assert.assertEquals("userAuth", ActorOperations.USER_AUTH.getValue()); - Assert.assertEquals("getUserProfile", ActorOperations.GET_USER_PROFILE.getValue()); - Assert.assertEquals("createOrg", ActorOperations.CREATE_ORG.getValue()); - Assert.assertEquals("updateOrg", ActorOperations.UPDATE_ORG.getValue()); - Assert.assertEquals("updateOrgStatus", ActorOperations.UPDATE_ORG_STATUS.getValue()); - Assert.assertEquals("getOrgDetails", ActorOperations.GET_ORG_DETAILS.getValue()); - Assert.assertEquals("userAuth", ActorOperations.USER_AUTH.getValue()); - Assert.assertEquals("createPage", ActorOperations.CREATE_PAGE.getValue()); - Assert.assertEquals("updatePage", ActorOperations.UPDATE_PAGE.getValue()); - Assert.assertEquals("deletePage", ActorOperations.DELETE_PAGE.getValue()); - Assert.assertEquals("getPageSettings", ActorOperations.GET_PAGE_SETTINGS.getValue()); - Assert.assertEquals("getPageData", ActorOperations.GET_PAGE_DATA.getValue()); - Assert.assertEquals("createSection", ActorOperations.CREATE_SECTION.getValue()); - Assert.assertEquals("updateSection", ActorOperations.UPDATE_SECTION.getValue()); - Assert.assertEquals("getAllSection", ActorOperations.GET_ALL_SECTION.getValue()); - Assert.assertEquals("getSection", ActorOperations.GET_SECTION.getValue()); - Assert.assertEquals("getCourseById", ActorOperations.GET_COURSE_BY_ID.getValue()); - Assert.assertEquals("updateUserCount", ActorOperations.UPDATE_USER_COUNT.getValue()); - Assert.assertEquals( - "getRecommendedCourses", ActorOperations.GET_RECOMMENDED_COURSES.getValue()); - Assert.assertEquals( - "updateUserInfoToElastic", ActorOperations.UPDATE_USER_INFO_ELASTIC.getValue()); - Assert.assertEquals("getRoles", ActorOperations.GET_ROLES.getValue()); - Assert.assertEquals("approveOrganisation", ActorOperations.APPROVE_ORGANISATION.getValue()); - Assert.assertEquals( - "addMemberOrganisation", ActorOperations.ADD_MEMBER_ORGANISATION.getValue()); - Assert.assertEquals( - "removeMemberOrganisation", ActorOperations.REMOVE_MEMBER_ORGANISATION.getValue()); - Assert.assertEquals("compositeSearch", ActorOperations.COMPOSITE_SEARCH.getValue()); - Assert.assertEquals( - "getUserDetailsByLoginId", ActorOperations.GET_USER_DETAILS_BY_LOGINID.getValue()); - Assert.assertEquals( - "updateOrgInfoToElastic", ActorOperations.UPDATE_ORG_INFO_ELASTIC.getValue()); - Assert.assertEquals( - "insertOrgInfoToElastic", ActorOperations.INSERT_ORG_INFO_ELASTIC.getValue()); - Assert.assertEquals("downlaodOrg", ActorOperations.DOWNLOAD_ORGS.getValue()); - Assert.assertEquals("blockUser", ActorOperations.BLOCK_USER.getValue()); - Assert.assertEquals("deleteByIdentifier", ActorOperations.DELETE_BY_IDENTIFIER.getValue()); - Assert.assertEquals("bulkUpload", ActorOperations.BULK_UPLOAD.getValue()); - Assert.assertEquals("processBulkUpload", ActorOperations.PROCESS_BULK_UPLOAD.getValue()); - Assert.assertEquals("assignRoles", ActorOperations.ASSIGN_ROLES.getValue()); - Assert.assertEquals("unblockUser", ActorOperations.UNBLOCK_USER.getValue()); - Assert.assertEquals("createBatch", ActorOperations.CREATE_BATCH.getValue()); - Assert.assertEquals("updateBatch", ActorOperations.UPDATE_BATCH.getValue()); - Assert.assertEquals("removeBatch", ActorOperations.REMOVE_BATCH.getValue()); - Assert.assertEquals("addUserBatch", ActorOperations.ADD_USER_TO_BATCH.getValue()); - Assert.assertEquals("removeUserFromBatch", ActorOperations.REMOVE_USER_FROM_BATCH.getValue()); - Assert.assertEquals("getBatch", ActorOperations.GET_BATCH.getValue()); - Assert.assertEquals("insertCourseBatchToEs", ActorOperations.INSERT_COURSE_BATCH_ES.getValue()); - Assert.assertEquals("updateCourseBatchToEs", ActorOperations.UPDATE_COURSE_BATCH_ES.getValue()); - Assert.assertEquals("getBulkOpStatus", ActorOperations.GET_BULK_OP_STATUS.getValue()); - Assert.assertEquals("orgCreationMetrics", ActorOperations.ORG_CREATION_METRICS.getValue()); - Assert.assertEquals( - "orgConsumptionMetrics", ActorOperations.ORG_CONSUMPTION_METRICS.getValue()); - Assert.assertEquals( - "orgCreationMetricsData", ActorOperations.ORG_CREATION_METRICS_DATA.getValue()); - Assert.assertEquals( - "courseProgressMetrics", ActorOperations.COURSE_PROGRESS_METRICS.getValue()); - Assert.assertEquals( - "courseConsumptionMetrics", ActorOperations.COURSE_CREATION_METRICS.getValue()); - Assert.assertEquals("userCreationMetrics", ActorOperations.USER_CREATION_METRICS.getValue()); - Assert.assertEquals( - "userConsumptionMetrics", ActorOperations.USER_CONSUMPTION_METRICS.getValue()); - Assert.assertEquals("getCourseBatchDetail", ActorOperations.GET_COURSE_BATCH_DETAIL.getValue()); - Assert.assertEquals("updateUserOrgES", ActorOperations.UPDATE_USER_ORG_ES.getValue()); - Assert.assertEquals("removeUserOrgES", ActorOperations.REMOVE_USER_ORG_ES.getValue()); - Assert.assertEquals("updateUserRoles", ActorOperations.UPDATE_USER_ROLES_ES.getValue()); - Assert.assertEquals("sync", ActorOperations.SYNC.getValue()); - Assert.assertEquals( - "insertUserCoursesInfoToElastic", - ActorOperations.INSERT_USR_COURSES_INFO_ELASTIC.getValue()); - Assert.assertEquals( - "updateUserCoursesInfoToElastic", - ActorOperations.UPDATE_USR_COURSES_INFO_ELASTIC.getValue()); - Assert.assertEquals("scheduleBulkUpload", ActorOperations.SCHEDULE_BULK_UPLOAD.getValue()); - Assert.assertEquals( - "courseProgressMetricsReport", ActorOperations.COURSE_PROGRESS_METRICS_REPORT.getValue()); - Assert.assertEquals( - "courseConsumptionMetricsReport", - ActorOperations.COURSE_CREATION_METRICS_REPORT.getValue()); - Assert.assertEquals( - "orgCreationMetricsReport", ActorOperations.ORG_CREATION_METRICS_REPORT.getValue()); - Assert.assertEquals( - "orgConsumptionMetricsReport", ActorOperations.ORG_CONSUMPTION_METRICS_REPORT.getValue()); - Assert.assertEquals("fileStorageService", ActorOperations.FILE_STORAGE_SERVICE.getValue()); - Assert.assertEquals("addUserBadgebackground", ActorOperations.ADD_USER_BADGE_BKG.getValue()); - Assert.assertEquals( - "fileGenerationAndUpload", ActorOperations.FILE_GENERATION_AND_UPLOAD.getValue()); - Assert.assertEquals("healthCheck", ActorOperations.HEALTH_CHECK.getValue()); - Assert.assertEquals("sendMail", ActorOperations.SEND_MAIL.getValue()); - Assert.assertEquals("processData", ActorOperations.PROCESS_DATA.getValue()); - Assert.assertEquals("actor", ActorOperations.ACTOR.getValue()); - Assert.assertEquals("cassandra", ActorOperations.CASSANDRA.getValue()); - Assert.assertEquals("es", ActorOperations.ES.getValue()); - Assert.assertEquals("ekstep", ActorOperations.EKSTEP.getValue()); - Assert.assertEquals("getOrgTypeList", ActorOperations.GET_ORG_TYPE_LIST.getValue()); - Assert.assertEquals("createOrgType", ActorOperations.CREATE_ORG_TYPE.getValue()); - Assert.assertEquals("updateOrgType", ActorOperations.UPDATE_ORG_TYPE.getValue()); - Assert.assertEquals("createNote", ActorOperations.CREATE_NOTE.getValue()); - Assert.assertEquals("updateNote", ActorOperations.UPDATE_NOTE.getValue()); - Assert.assertEquals("searchNote", ActorOperations.SEARCH_NOTE.getValue()); - Assert.assertEquals("getNote", ActorOperations.GET_NOTE.getValue()); - Assert.assertEquals("deleteNote", ActorOperations.DELETE_NOTE.getValue()); - Assert.assertEquals( - "insertUserNotesToElastic", ActorOperations.INSERT_USER_NOTES_ES.getValue()); - Assert.assertEquals("encryptUserData", ActorOperations.ENCRYPT_USER_DATA.getValue()); - Assert.assertEquals("decryptUserData", ActorOperations.DECRYPT_USER_DATA.getValue()); - Assert.assertEquals( - "updateUserNotesToElastic", ActorOperations.UPDATE_USER_NOTES_ES.getValue()); - Assert.assertEquals("userCurrentLogin", ActorOperations.USER_CURRENT_LOGIN.getValue()); - Assert.assertEquals("getMediaTypes", ActorOperations.GET_MEDIA_TYPES.getValue()); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/AuditLogTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/AuditLogTest.java deleted file mode 100644 index 88309fb62..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/AuditLogTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; - -/** @author Manzarul */ -public class AuditLogTest { - - @Test - public void createAuditLog() { - AuditLog log = new AuditLog(); - log.setDate("2017-12-29"); - log.setObjectId("objectId"); - log.setObjectType("User"); - log.setOperationType("create"); - log.setRequestId("requesterId"); - log.setUserId("userId"); - Map map = new HashMap<>(); - log.setLogRecord(map); - Assert.assertEquals("2017-12-29", log.getDate()); - Assert.assertEquals("objectId", log.getObjectId()); - Assert.assertEquals("User", log.getObjectType()); - Assert.assertEquals("create", log.getOperationType()); - Assert.assertEquals("requesterId", log.getRequestId()); - Assert.assertEquals("userId", log.getUserId()); - Assert.assertEquals(0, log.getLogRecord().size()); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/BaseHttpTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/BaseHttpTest.java deleted file mode 100644 index 642e1fd45..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/BaseHttpTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.sunbird.common.models.util; - -import static org.powermock.api.mockito.PowerMockito.doThrow; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import org.apache.http.impl.client.HttpClients; -import org.junit.Assert; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.util.KeycloakRequiredActionLinkUtil; -import org.sunbird.services.sso.impl.KeyCloakServiceImpl; - -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -@PrepareForTest({ - OutputStreamWriter.class, - URL.class, - BufferedReader.class, - HttpUtil.class, - HttpClients.class, - KeyCloakConnectionProvider.class, - KeyCloakServiceImpl.class, KeycloakRequiredActionLinkUtil.class -}) -public abstract class BaseHttpTest { - - @Before - public void addMockRules() { - - mockHttpUrlResponse("content/v3/list", "not-empty-output"); - mockHttpUrlResponse("/search/health", "not-empty-output"); - mockHttpUrlResponse("/content/wrong/v3/list", null, true, null); - mockHttpUrlResponse("v1/issuer/issuers", "{\"message\":\"success\"}"); - mockHttpUrlResponse("https://dev.ekstep.in/api/data/v3", "{\"message\":\"success\"}"); - } - - protected void mockHttpUrlResponse(String urlContains, String outputExpected) { - mockHttpUrlResponse(urlContains, outputExpected, false, null); - } - - protected void mockHttpUrlResponse( - String urlContains, String outputExpected, boolean throwError, String paramContains) { - URL url = mock(URL.class); - HttpURLConnection connection = mock(HttpURLConnection.class); - OutputStream outStream = mock(OutputStream.class); - OutputStreamWriter outStreamWriter = mock(OutputStreamWriter.class); - InputStream inStream = mock(InputStream.class); - BufferedReader reader = mock(BufferedReader.class); - try { - - whenNew(URL.class).withArguments(Mockito.contains(urlContains)).thenReturn(url); - whenNew(OutputStreamWriter.class).withAnyArguments().thenReturn(outStreamWriter); - when(url.openConnection()).thenReturn(connection); - when(connection.getOutputStream()).thenReturn(outStream); - if (paramContains != null && throwError) { - doThrow(new FileNotFoundException()).when(outStreamWriter).write(Mockito.anyString()); - } - if (throwError) { - when(connection.getInputStream()).thenThrow(FileNotFoundException.class); - } else { - when(connection.getInputStream()).thenReturn(inStream); - } - whenNew(BufferedReader.class).withAnyArguments().thenReturn(reader); - when(reader.readLine()).thenReturn(outputExpected, null); - } catch (Exception e) { - Assert.fail("Mock rules addition failed " + e.getMessage()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/EmailTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/EmailTest.java deleted file mode 100644 index e3ac07c6b..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/EmailTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** */ -package org.sunbird.common.models.util; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.jvnet.mock_javamail.Mailbox; -import org.sunbird.common.models.util.mail.GMailAuthenticator; -import org.sunbird.common.models.util.mail.SendMail; - -import javax.mail.PasswordAuthentication; - -/** @author Manzarul */ -public class EmailTest { - - private static GMailAuthenticator authenticator = null; - - @BeforeClass - public static void setUp() { - authenticator = new GMailAuthenticator("test123", "test"); - // clear Mock JavaMail box - Mailbox.clearAll(); - } - - @Test - public void createGmailAuthInstance() { - GMailAuthenticator authenticator = new GMailAuthenticator("test123", "test"); - Assert.assertNotEquals(null, authenticator); - } - - @Test - public void passwordAuthTest() { - PasswordAuthentication authentication = authenticator.getPasswordAuthentication(); - Assert.assertEquals("test", authentication.getPassword()); - } - - - @Test - public void initialiseFromPropertyTest() { - SendMail.initialiseFromProperty(); - Assert.assertTrue(true); - } - - @AfterClass - public static void tearDown() { - authenticator = null; - Mailbox.clearAll(); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ExcelFileUtilTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ExcelFileUtilTest.java deleted file mode 100644 index 38e1078cf..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ExcelFileUtilTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.sunbird.common.models.util; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -public class ExcelFileUtilTest { - - @Test - public void testWriteToFile() { - String fileName = "test"; - List> data = new ArrayList<>(); - List dataObjects = new ArrayList<>(); - dataObjects.add("test1"); - dataObjects.add(new ArrayList<>()); - dataObjects.add(1); - dataObjects.add(2.0D); - data.add(dataObjects); - ExcelFileUtil excelFileUtil = new ExcelFileUtil(); - File file = excelFileUtil.writeToFile(fileName, data); - String[] expectedFileName = StringUtils.split(file.getName(), '.'); - Assert.assertEquals("test", expectedFileName[0]); - Assert.assertEquals("xlsx", expectedFileName[1]); - } - - @Test - public void testgetFileUtil() { - FileUtil util = FileUtil.getFileUtil("Excel"); - Assert.assertNotNull(util); - } - - @Test - public void testgetListValue() { - List list = new ArrayList<>(); - list.add("column1"); - list.add("column2"); - String response = FileUtil.getListValue(list); - Assert.assertEquals("column1,column2", response); - list.clear(); - response = FileUtil.getListValue(list); - Assert.assertEquals("", response); - } - - @After - public void deleteFileGenerated() { - File file = new File("test.xlsx"); - if (file.exists()) { - file.delete(); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/HttpUtilTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/HttpUtilTest.java deleted file mode 100644 index 9f60eb795..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/HttpUtilTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.sunbird.common.models.util; - -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.when; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.HttpVersion; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicStatusLine; -import org.junit.Test; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.sunbird.common.util.KeycloakRequiredActionLinkUtil; -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -public class HttpUtilTest extends BaseHttpTest { - public static final String JSON_STRING_DATA = "asdasasfasfsdfdsfdsfgsd"; - - @Test - public void testPostFormDataSuccess() { - Map reqData = new HashMap<>(); - reqData.put("field1", "value1"); - reqData.put("field2", "value2"); - - Map fileData = new HashMap<>(); - fileData.put("file1", ("asd".getBytes())); - - Map headers = new HashMap<>(); - headers.put("Authorization", "123456"); - String url = "http://localhost:8000/v1/issuer/issuers"; - try { - String response = (String) HttpUtil.postFormData(reqData, fileData, headers, url).getBody(); - assertTrue("{\"message\":\"success\"}".equals(response)); - } catch (IOException e) { - ProjectLogger.log(e.getMessage()); - } - } - - @Test - public void testSendPatchRequestSuccess() { - - Map headers = new HashMap<>(); - headers.put("Authorization", "123456"); - String url = "http://localhost:8000/v1/issuer/issuers"; - try { - CloseableHttpResponse closeableHttpResponseMock = - PowerMockito.mock(CloseableHttpResponse.class); - HttpEntity httpEntity = PowerMockito.mock(HttpEntity.class); - PowerMockito.when(closeableHttpResponseMock.getStatusLine()) - .thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "FINE!")); - - PowerMockito.when(closeableHttpResponseMock.getEntity()).thenReturn(httpEntity); - closeableHttpResponseMock.setEntity(httpEntity); - PowerMockito.when(closeableHttpResponseMock.getEntity()).thenReturn(httpEntity); - PowerMockito.when(closeableHttpResponseMock.getEntity().getContent()) - .thenReturn(new ByteArrayInputStream("{\"message\":\"success\"}".getBytes())); - - CloseableHttpClient closeableHttpClientMocked = PowerMockito.mock(CloseableHttpClient.class); - PowerMockito.mockStatic(HttpClients.class); - PowerMockito.when(HttpClients.createDefault()).thenReturn(closeableHttpClientMocked); - - PowerMockito.when(closeableHttpClientMocked.execute(Mockito.any(HttpPost.class))) - .thenReturn(closeableHttpResponseMock); - - String response = HttpUtil.sendPatchRequest(url, "{\"message\":\"success\"}", headers); - assertTrue("SUCCESS".equals(response)); - } catch (IOException e) { - ProjectLogger.log(e.getMessage()); - } - } - - @Test - public void testSendPostRequestSuccess() { - Map headers = new HashMap<>(); - headers.put("Authorization", "123456"); - String url = "http://localhost:8000/v1/issuer/issuers"; - try { - String response = HttpUtil.sendPostRequest(url, "{\"message\":\"success\"}", headers); - assertTrue("{\"message\":\"success\"}".equals(response)); - } catch (IOException e) { - ProjectLogger.log(e.getMessage()); - } - } - - @Test - public void testSendGetRequestSuccess() { - Map headers = new HashMap<>(); - headers.put("Authorization", "123456"); - String urlString = "http://localhost:8000/v1/issuer/issuers"; - try { - String response = HttpUtil.sendGetRequest(urlString, headers); - assertTrue("{\"message\":\"success\"}".equals(response)); - } catch (Exception e) { - ProjectLogger.log(e.getMessage()); - } - } - - @Test - public void testGetHeaderWithInput() throws Exception { - PowerMockito.mockStatic(KeycloakRequiredActionLinkUtil.class); - when(KeycloakRequiredActionLinkUtil.getAdminAccessToken()).thenReturn("testAuthToken"); - Map input = new HashMap(){{ - put("x-channel-id", "test-channel"); - put("x-device-id", "test-device"); - }}; - Map headers = HttpUtil.getHeader(input); - assertTrue(!headers.isEmpty()); - assertTrue(headers.size()==4); - assertTrue(headers.containsKey("x-authenticated-user-token")); - assertTrue(headers.containsKey("Content-Type")); - assertTrue(headers.containsKey("x-channel-id")); - assertTrue(headers.containsKey("x-device-id")); - } - - @Test - public void testGetHeaderWithoutInput() throws Exception { - PowerMockito.mockStatic(KeycloakRequiredActionLinkUtil.class); - when(KeycloakRequiredActionLinkUtil.getAdminAccessToken()).thenReturn("testAuthToken"); - Map headers = HttpUtil.getHeader(null); - assertTrue(!headers.isEmpty()); - assertTrue(headers.size()==2); - assertTrue(headers.containsKey("x-authenticated-user-token")); - assertTrue(headers.containsKey("Content-Type")); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ProjectUtilTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ProjectUtilTest.java deleted file mode 100644 index c8483a82d..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/ProjectUtilTest.java +++ /dev/null @@ -1,457 +0,0 @@ -package org.sunbird.common.models.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; -import org.apache.commons.lang3.StringUtils; -import org.apache.velocity.VelocityContext; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.request.Request; -import org.sunbird.common.responsecode.ResponseCode; -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -/** Created by arvind on 6/10/17. */ -public class ProjectUtilTest extends BaseHttpTest { - - private PropertiesCache propertiesCache = ProjectUtil.propertiesCache; - - private static Map headers = new HashMap(); - - @BeforeClass - public static void init() { - headers.put("content-type", "application/json"); - headers.put("accept", "application/json"); - headers.put("user-id", "mahesh"); - String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); - if (StringUtils.isBlank(header)) { - header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); - } - headers.put("authorization", "Bearer " + header); - } - - @Ignore - public void testGetContextFailureWithNameAbsent() { - - Map templateMap = new HashMap<>(); - templateMap.put(JsonKey.ACTION_URL, "googli.com"); - - VelocityContext context = ProjectUtil.getContext(templateMap); - assertEquals(false, context.internalContainsKey(JsonKey.NAME)); - } - - @Test - public void testGetContextFailureWithoutActionUrl() { - - Map templateMap = new HashMap<>(); - templateMap.put(JsonKey.NAME, "userName"); - - VelocityContext context = ProjectUtil.getContext(templateMap); - assertEquals(false, context.internalContainsKey(JsonKey.ACTION_URL)); - } - - @Test - public void testGetContextSuccessWithFromMail() { - - Map templateMap = new HashMap<>(); - templateMap.put(JsonKey.ACTION_URL, "googli.com"); - templateMap.put(JsonKey.NAME, "userName"); - - boolean envVal = !StringUtils.isBlank(System.getenv(JsonKey.EMAIL_SERVER_FROM)); - boolean cacheVal = propertiesCache.getProperty(JsonKey.EMAIL_SERVER_FROM) != null; - - VelocityContext context = ProjectUtil.getContext(templateMap); - if (envVal) { - assertEquals( - System.getenv(JsonKey.EMAIL_SERVER_FROM), context.internalGet(JsonKey.FROM_EMAIL)); - } else if (cacheVal) { - assertEquals( - propertiesCache.getProperty(JsonKey.EMAIL_SERVER_FROM), - context.internalGet(JsonKey.FROM_EMAIL)); - } - } - - @Test - public void testGetContextSuccessWithOrgImageUrl() { - - Map templateMap = new HashMap<>(); - templateMap.put(JsonKey.ACTION_URL, "googli.com"); - templateMap.put(JsonKey.NAME, "userName"); - - boolean envVal = !StringUtils.isBlank(System.getenv(JsonKey.SUNBIRD_ENV_LOGO_URL)); - boolean cacheVal = propertiesCache.getProperty(JsonKey.SUNBIRD_ENV_LOGO_URL) != null; - - VelocityContext context = ProjectUtil.getContext(templateMap); - if (envVal) { - assertEquals( - System.getenv(JsonKey.SUNBIRD_ENV_LOGO_URL), context.internalGet(JsonKey.ORG_IMAGE_URL)); - } else if (cacheVal) { - assertEquals( - propertiesCache.getProperty(JsonKey.SUNBIRD_ENV_LOGO_URL), - context.internalGet(JsonKey.ORG_IMAGE_URL)); - } - } - - @Test - public void testCreateAuthTokenSuccess() { - String authToken = ProjectUtil.createAuthToken("test", "tset1234"); - assertNotNull(authToken); - } - - @Test - public void testValidatePhoneNumberFailureWithInvalidPhoneNumber() { - assertFalse(ProjectUtil.validatePhoneNumber("312")); - } - - @Test - public void testValidatePhoneNumberSuccess() { - assertTrue(ProjectUtil.validatePhoneNumber("9844016699")); - } - - @Test - public void testGenerateRandomPasswordSuccess() { - assertNotNull(ProjectUtil.generateRandomPassword()); - } - - @Test - public void testCreateCheckResponseSuccess() { - Map responseMap = - ProjectUtil.createCheckResponse("LearnerService", false, null); - assertEquals(true, responseMap.get(JsonKey.Healthy)); - } - - @Test - public void testCreateCheckResponseFailureWithException() { - Map responseMap = - ProjectUtil.createCheckResponse( - "LearnerService", - true, - new ProjectCommonException( - ResponseCode.invalidObjectType.getErrorCode(), - ResponseCode.invalidObjectType.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode())); - assertEquals(false, responseMap.get(JsonKey.Healthy)); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), responseMap.get(JsonKey.ERROR)); - assertEquals( - ResponseCode.invalidObjectType.getErrorMessage(), responseMap.get(JsonKey.ERRORMSG)); - } - - @Ignore - public void testSetRequestSuccessWithLowerCaseValues() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SOURCE, "Test"); - requestObj.put(JsonKey.LOGIN_ID, "SunbirdUser"); - requestObj.put(JsonKey.EXTERNAL_ID, "testExternal"); - requestObj.put(JsonKey.USER_NAME, "username"); - requestObj.put(JsonKey.USERNAME, "userName"); - requestObj.put(JsonKey.PROVIDER, "Provider"); - requestObj.put(JsonKey.ID, "TEST123"); - request.setRequest(requestObj); - assertEquals("test", requestObj.get(JsonKey.SOURCE)); - assertEquals("sunbirduser", requestObj.get(JsonKey.LOGIN_ID)); - assertEquals("testexternal", requestObj.get(JsonKey.EXTERNAL_ID)); - assertEquals("username", requestObj.get(JsonKey.USER_NAME)); - assertEquals("username", requestObj.get(JsonKey.USERNAME)); - assertEquals("provider", requestObj.get(JsonKey.PROVIDER)); - assertEquals("TEST123", requestObj.get(JsonKey.ID)); - } - - @Test - public void testFormatMessageSuccess() { - String msg = ProjectUtil.formatMessage("Hello {0}", "user"); - assertEquals("Hello user", msg); - } - - @Test - public void testFormatMessageFailureWithInvalidVariable() { - String msg = ProjectUtil.formatMessage("Hello ", "user"); - assertNotEquals("Hello user", msg); - } - - @Test - public void testIsEmailValidFailureWithWrongEmail() { - boolean msg = ProjectUtil.isEmailvalid("Hello "); - assertFalse(msg); - } - - @Test - public void testIsDateValidFormatSuccess() { - boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", "2017-12-18"); - assertTrue(bool); - } - - @Test - public void testIsDateValidFormatFailureWithEmptyDate() { - boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", ""); - assertFalse(bool); - } - - @Test - public void testIsDateValidFormatFailureWithInvalidDate() { - boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", "2017-12-18"); - assertTrue(bool); - } - - @Test - public void testIsDateValidFormatFailureWithEmptyDateTime() { - boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd HH:mm:ss:SSSZ", ""); - assertFalse(bool); - } - - @Test - public void testGetEkstepHeaderSuccess() { - Map map = ProjectUtil.getEkstepHeader(); - assertEquals(map.get("Content-Type"), "application/json"); - assertNotNull(map.get(JsonKey.AUTHORIZATION)); - } - - @Test - public void testReportTrackingStatusSuccess() { - assertEquals(0, ProjectUtil.ReportTrackingStatus.NEW.getValue()); - assertEquals(1, ProjectUtil.ReportTrackingStatus.GENERATING_DATA.getValue()); - assertEquals(2, ProjectUtil.ReportTrackingStatus.UPLOADING_FILE.getValue()); - assertEquals(3, ProjectUtil.ReportTrackingStatus.UPLOADING_FILE_SUCCESS.getValue()); - assertEquals(4, ProjectUtil.ReportTrackingStatus.SENDING_MAIL.getValue()); - assertEquals(5, ProjectUtil.ReportTrackingStatus.SENDING_MAIL_SUCCESS.getValue()); - assertEquals(9, ProjectUtil.ReportTrackingStatus.FAILED.getValue()); - } - - @Test - public void testEsTypeSuccess() { - assertEquals("content", ProjectUtil.EsType.content.getTypeName()); - assertEquals("cbatch", ProjectUtil.EsType.course.getTypeName()); - assertEquals("course-batch", ProjectUtil.EsType.courseBatch.getTypeName()); - assertEquals("user", ProjectUtil.EsType.user.getTypeName()); - assertEquals("org", ProjectUtil.EsType.organisation.getTypeName()); - assertEquals("user-courses", ProjectUtil.EsType.usercourses.getTypeName()); - assertEquals("usernotes", ProjectUtil.EsType.usernotes.getTypeName()); - assertEquals("userprofilevisibility", ProjectUtil.EsType.userprofilevisibility.getTypeName()); - } - - @Test - public void testEsIndexSuccess() { - assertEquals("searchindex", ProjectUtil.EsIndex.sunbird.getIndexName()); - } - - @Test - public void testUserRoleSuccess() { - assertEquals("PUBLIC", ProjectUtil.UserRole.PUBLIC.getValue()); - assertEquals("CONTENT_CREATOR", ProjectUtil.UserRole.CONTENT_CREATOR.getValue()); - assertEquals("CONTENT_REVIEWER", ProjectUtil.UserRole.CONTENT_REVIEWER.getValue()); - assertEquals("ORG_ADMIN", ProjectUtil.UserRole.ORG_ADMIN.getValue()); - assertEquals("ORG_MEMBER", ProjectUtil.UserRole.ORG_MEMBER.getValue()); - } - - @Test - public void testBulkProcessStatusSuccess() { - assertEquals(0, ProjectUtil.BulkProcessStatus.NEW.getValue()); - assertEquals(1, ProjectUtil.BulkProcessStatus.IN_PROGRESS.getValue()); - assertEquals(2, ProjectUtil.BulkProcessStatus.INTERRUPT.getValue()); - assertEquals(3, ProjectUtil.BulkProcessStatus.COMPLETED.getValue()); - assertEquals(9, ProjectUtil.BulkProcessStatus.FAILED.getValue()); - } - - @Test - public void testOrgStatusSuccess() { - assertEquals(new Integer(0), ProjectUtil.OrgStatus.INACTIVE.getValue()); - assertEquals(new Integer(1), ProjectUtil.OrgStatus.ACTIVE.getValue()); - assertEquals(new Integer(2), ProjectUtil.OrgStatus.BLOCKED.getValue()); - assertEquals(new Integer(3), ProjectUtil.OrgStatus.RETIRED.getValue()); - } - - @Test - public void testCourseMgmtStatusSuccess() { - assertEquals("draft", ProjectUtil.CourseMgmtStatus.DRAFT.getValue()); - assertEquals("live", ProjectUtil.CourseMgmtStatus.LIVE.getValue()); - assertEquals("retired", ProjectUtil.CourseMgmtStatus.RETIRED.getValue()); - } - - @Test - public void testProgressStatusSuccess() { - assertEquals(0, ProjectUtil.ProgressStatus.NOT_STARTED.getValue()); - assertEquals(1, ProjectUtil.ProgressStatus.STARTED.getValue()); - assertEquals(2, ProjectUtil.ProgressStatus.COMPLETED.getValue()); - } - - @Test - public void testEnvironmentSuccess() { - assertEquals(1, ProjectUtil.Environment.dev.getValue()); - assertEquals(2, ProjectUtil.Environment.qa.getValue()); - assertEquals(3, ProjectUtil.Environment.prod.getValue()); - } - - @Test - public void testObjectTypesSuccess() { - assertEquals("batch", ProjectUtil.ObjectTypes.batch.getValue()); - assertEquals("user", ProjectUtil.ObjectTypes.user.getValue()); - assertEquals("organisation", ProjectUtil.ObjectTypes.organisation.getValue()); - } - - @Test - public void testSourceSuccess() { - assertEquals("web", ProjectUtil.Source.WEB.getValue()); - assertEquals("android", ProjectUtil.Source.ANDROID.getValue()); - assertEquals("ios", ProjectUtil.Source.IOS.getValue()); - } - - @Test - public void testSectionDataTypeSuccess() { - assertEquals("course", ProjectUtil.SectionDataType.course.getTypeName()); - assertEquals("content", ProjectUtil.SectionDataType.content.getTypeName()); - } - - @Test - public void testStatusSuccess() { - assertEquals(1, ProjectUtil.Status.ACTIVE.getValue()); - assertEquals(0, ProjectUtil.Status.INACTIVE.getValue()); - assertEquals(false, ProjectUtil.ActiveStatus.INACTIVE.getValue()); - assertEquals(true, ProjectUtil.ActiveStatus.ACTIVE.getValue()); - assertEquals("orgimg", ProjectUtil.AzureContainer.orgImage.getName()); - assertEquals("userprofileimg", ProjectUtil.AzureContainer.userProfileImg.getName()); - } - - @Test - public void testCreateAndThrowServerErrorSuccess() { - try { - ProjectUtil.createAndThrowServerError(); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.SERVER_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.SERVER_ERROR.getErrorCode(), e.getCode()); - } - } - - @Test - public void testCreateAndThrowInvalidUserDataExceptionSuccess() { - try { - ProjectUtil.createAndThrowInvalidUserDataException(); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidUsrData.getErrorCode(), e.getCode()); - } - } - - @Test - public void testGetDateRangeSuccess() { - int noOfDays = 7; - Map map = ProjectUtil.getDateRange(noOfDays); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, -noOfDays); - assertEquals(map.get("startDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); - cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, -1); - assertEquals(map.get("endDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); - } - - @Test - public void testGetDateRangeFailure() { - int noOfDays = 14; - Map map = ProjectUtil.getDateRange(noOfDays); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, -noOfDays); - assertEquals(map.get("startDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); - cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.add(Calendar.DATE, noOfDays); - assertNotEquals(map.get("endDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); - } - - @Test - public void testGetDateRangeFailureWithZeroDays() { - int noOfDays = 0; - Map map = ProjectUtil.getDateRange(noOfDays); - assertNull(map.get("startDate")); - assertNull(map.get("endDate")); - } - - @Test - public void testGetDateRangeFailureWithNegativeValue() { - int noOfDays = -100; - Map map = ProjectUtil.getDateRange(noOfDays); - assertNull(map.get("startDate")); - assertNull(map.get("endDate")); - } - - @Test - public void testIsEmailValidFailureWithInvalidFormat() { - boolean bool = ProjectUtil.isEmailvalid("amit.kumartarento.com"); - Assert.assertFalse(bool); - } - - @Test - public void testIsEmailValidSuccess() { - boolean bool = ProjectUtil.isEmailvalid("amit.kumar@tarento.com"); - assertTrue(bool); - } - - @Test - public void testSendGetRequestSuccessWithEkStepBaseUrl() throws Exception { - String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL); - if (StringUtils.isBlank(ekStepBaseUrl)) { - ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL); - } - String response = HttpUtil.sendGetRequest(ekStepBaseUrl + "/search/health", headers); - assertNotNull(response); - } - - @Test - public void testGetLmsUserIdSuccessWithoutFedUserId() { - String userid = ProjectUtil.getLmsUserId("1234567890"); - assertEquals("1234567890", userid); - } - - @Test - public void testGetLmsUserIdSuccessWithFedUserId() { - String userid = - ProjectUtil.getLmsUserId( - "f:" - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) - + ":" - + "1234567890"); - assertEquals("1234567890", userid); - } - - @Test - public void testMigrateActionAcceptValueFailure() { - Assert.assertNotEquals("ok", ProjectUtil.MigrateAction.ACCEPT.getValue()); - } - - @Test - public void testMigrateActionRejectValueFailure() { - Assert.assertNotEquals("no", ProjectUtil.MigrateAction.REJECT.getValue()); - } - - @Test - public void testMigrateActionAcceptValueSuccess() { - Assert.assertEquals("accept", ProjectUtil.MigrateAction.ACCEPT.getValue()); - } - - @Test - public void testMigrateActionRejectValueSuccess() { - Assert.assertEquals("reject", ProjectUtil.MigrateAction.REJECT.getValue()); - } - - @Test - public void testValidateCountryCode() { - boolean isValid = ProjectUtil.validateCountryCode("+91"); - assertTrue(isValid); - } - - @Test - public void testValidateUUID() { - boolean isValid = ProjectUtil.validateUUID("1df03f56-ceba-4f2d-892c-2b1609e7b05f"); - assertTrue(isValid); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/SlugTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/SlugTest.java deleted file mode 100644 index e5b819662..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/SlugTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sunbird.common.models.util; - -import org.junit.Assert; -import org.junit.Test; - -public class SlugTest { - - @Test - public void createSlugWithNullValue() { - String slug = Slug.makeSlug(null, true); - Assert.assertEquals(null, slug); - } - - @Test - public void createSlug() { - String val = "NTP@#Test"; - String slug = Slug.makeSlug(val, true); - Assert.assertEquals("ntptest", slug); - } - - @Test - public void removeDuplicateChar() { - String val = Slug.removeDuplicateChars("ntpntest"); - Assert.assertEquals("ntpes", val); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/URLShortnerImplTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/URLShortnerImplTest.java deleted file mode 100644 index bec50deaf..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/URLShortnerImplTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.sunbird.common.models.util; - -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.util.url.URLShortner; -import org.sunbird.common.models.util.url.URLShortnerImpl; - -public class URLShortnerImplTest { - - @Test - public void urlShortTest() { - URLShortner shortner = new URLShortnerImpl(); - String url = shortner.shortUrl("https://staging.open-sunbird.org/"); - Assert.assertNotNull(url); - } - - @Test - public void getShortUrlTest() { - - String SUNBIRD_WEB_URL = "sunbird_web_url"; - - String webUrl = System.getenv(SUNBIRD_WEB_URL); - if (StringUtils.isBlank(webUrl)) { - webUrl = PropertiesCache.getInstance().getProperty(SUNBIRD_WEB_URL); - } - - URLShortnerImpl shortnerImpl = new URLShortnerImpl(); - String url = shortnerImpl.getUrl(); - Assert.assertEquals(url, webUrl); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/azure/AzureServiceFactoryTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/azure/AzureServiceFactoryTest.java deleted file mode 100644 index 1f67ad521..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/azure/AzureServiceFactoryTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/** */ -package org.sunbird.common.models.util.azure; - -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - -import com.microsoft.azure.storage.CloudStorageAccount; -import com.microsoft.azure.storage.blob.CloudBlobClient; -import com.microsoft.azure.storage.blob.CloudBlobContainer; -import com.microsoft.azure.storage.blob.ListBlobItem; -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -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; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -/** @author Manzarul */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - CloudStorageAccount.class, - CloudBlobClient.class, - CloudBlobContainer.class, - ListBlobItem.class -}) -@PowerMockIgnore({ - "javax.management.*", - "javax.net.ssl.*", - "javax.security.*", - "com.microsoft.azure.storage.*","jdk.internal.reflect.*" -}) -public class AzureServiceFactoryTest { - - private static Object obj = null; - private static CloudBlobContainer container = null; - private static CloudBlobContainer container1 = null; - private static String containerName = "testcontainerxyz"; - - @BeforeClass - public static void getObject() { - obj = CloudServiceFactory.get("Azure"); - Assert.assertTrue(obj instanceof CloudService); - Assert.assertNotNull(obj); - } - - @Before - public void addMockRules() { - CloudStorageAccount cloudStorageAccount = mock(CloudStorageAccount.class); - CloudBlobClient cloudBlobClient = mock(CloudBlobClient.class); - CloudBlobContainer cloudBlobContainer = mock(CloudBlobContainer.class); - - ListBlobItem listBlobItem = mock(ListBlobItem.class); - List lst = new ArrayList<>(); - lst.add(listBlobItem); - PowerMockito.mockStatic(CloudStorageAccount.class); - try { - doReturn(cloudStorageAccount).when(CloudStorageAccount.class, "parse", Mockito.anyString()); - doReturn(cloudBlobClient).when(cloudStorageAccount).createCloudBlobClient(); - doReturn(cloudBlobContainer).when(cloudBlobClient).getContainerReference(Mockito.anyString()); - doReturn(true).when(cloudBlobContainer).exists(); - when(cloudBlobContainer.listBlobs()).thenReturn(lst); - when(listBlobItem.getUri()).thenReturn(new URI("http://www.google.com")); - - } catch (Exception e) { - Assert.fail("Could not initalize mocks, underlying reason " + e.getLocalizedMessage()); - } - } - - @Test - public void testGetFailureWithWrongType() { - Object obj = CloudServiceFactory.get("Azure12"); - Assert.assertNull(obj); - } - - @Test - public void testGetSuccess() { - Object obj1 = CloudServiceFactory.get("Azure"); - Assert.assertNotNull(obj1); - Assert.assertTrue(obj.equals(obj1)); - } - - @Test - public void testGetContainerSuccessWithAccessPublic() { - container = AzureConnectionManager.getContainer(containerName, true); - Assert.assertNotNull(container); - } - - @Test - public void testGetContainerReferenceSuccess() { - container1 = AzureConnectionManager.getContainerReference(containerName); - Assert.assertNotNull(container1); - } - - @Test - public void testUploadFileSuccess() { - CloudService service = (CloudService) obj; - String url = service.uploadFile(containerName, new File("test.txt")); - Assert.assertEquals(null, url); - } - - @Test - public void testUploadFileFailureWithoutContainerName() { - CloudService service = (CloudService) obj; - String url = service.uploadFile("", new File("test.txt")); - Assert.assertEquals(null, url); - } - - @Test - public void testUploadFileSuccessWithMultiplePath() { - CloudService service = (CloudService) obj; - String url = service.uploadFile("/tez/po/" + containerName, new File("test.txt")); - Assert.assertEquals(null, url); - } - - @Test - public void testUploadFileSuccessWithFileLocation() { - CloudService service = (CloudService) obj; - String url = service.uploadFile(containerName, "test.txt", ""); - Assert.assertEquals(null, url); - } - - @Test - public void testListAllFilesSuccess() { - CloudService service = (CloudService) obj; - List filesList = service.listAllFiles(containerName); - Assert.assertEquals(1, filesList.size()); - } - - @Test - public void testDownloadFileSuccess() { - CloudService service = (CloudService) obj; - Boolean isFileDeleted = service.downLoadFile(containerName, "test1.txt", ""); - Assert.assertFalse(isFileDeleted); - } - - @Test - public void testDeleteFileSuccess() { - CloudService service = (CloudService) obj; - Boolean isFileDeleted = service.deleteFile(containerName, "test1.txt"); - Assert.assertFalse(isFileDeleted); - } - - @Test - public void testDeleteFileSuccessWithoutContainerName() { - CloudService service = (CloudService) obj; - Boolean isFileDeleted = service.deleteFile("", "test.abc"); - Assert.assertFalse(isFileDeleted); - } - - @Test - public void testDeleteContainerSuccess() { - CloudService service = (CloudService) obj; - boolean response = service.deleteContainer(containerName); - Assert.assertTrue(response); - } - - @AfterClass - public static void shutDown() { - container1 = null; - container = null; - obj = null; - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/EncryptionDecriptionServiceTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/EncryptionDecriptionServiceTest.java deleted file mode 100644 index d6af62789..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/EncryptionDecriptionServiceTest.java +++ /dev/null @@ -1,252 +0,0 @@ -package org.sunbird.common.models.util.datasecurity.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.PropertiesCache; -import org.sunbird.common.models.util.datasecurity.DataMaskingService; -import org.sunbird.common.models.util.datasecurity.DecryptionService; -import org.sunbird.common.models.util.datasecurity.EncryptionService; - -/** @author Amit Kumar */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class EncryptionDecriptionServiceTest { - - private static String data = "hello sunbird"; - private static String encryptedData = ""; - private static String decryptedData = ""; - private static EncryptionService encryptionService = null; - private static DecryptionService decryptionService = null; - private static DataMaskingService maskingService = null; - private static Map map = null; - private static List> mapList = null; - private static Map map2 = null; - private static List> mapList2 = null; - private static String sunbirdEncryption = ""; - - @BeforeClass - public static void setUp() { - sunbirdEncryption = System.getenv(JsonKey.SUNBIRD_ENCRYPTION); - if (StringUtils.isBlank(sunbirdEncryption)) { - sunbirdEncryption = PropertiesCache.getInstance().getProperty(JsonKey.SUNBIRD_ENCRYPTION); - } - map = new HashMap<>(); - map.put(JsonKey.FIRST_NAME, "Amit"); - map.put(JsonKey.LAST_NAME, "KUMAR"); - mapList = new ArrayList<>(); - mapList.add(map); - map2 = new HashMap<>(); - map2.put(JsonKey.EMAIL, "amit.ec006@gmail.com"); - map2.put(JsonKey.FIRST_NAME, "Amit"); - map2.put(JsonKey.LAST_NAME, "KUMAR"); - mapList2 = new ArrayList<>(); - mapList2.add(map2); - encryptionService = ServiceFactory.getEncryptionServiceInstance(null); - decryptionService = ServiceFactory.getDecryptionServiceInstance(null); - maskingService = ServiceFactory.getMaskingServiceInstance(null); - try { - encryptedData = encryptionService.encryptData(data); - decryptedData = decryptionService.decryptData(encryptedData); - } catch (Exception e) { - } - } - - @Test - public void testDataDecryptionFrMap() { - try { - assertEquals( - decryptionService - .decryptData(encryptionService.encryptData(map2)) - .get(JsonKey.FIRST_NAME), - "Amit"); - } catch (Exception e) { - } - } - - @Test - public void testDataDecryptionFrMapWithNullValue() { - try { - map2.put(JsonKey.LOCATION, null); - assertEquals( - decryptionService.decryptData(encryptionService.encryptData(map2)).get(JsonKey.LOCATION), - null); - } catch (Exception e) { - } - } - - @Test - public void testDataDecryptionFrMapWithEmptyValue() { - try { - map2.put(JsonKey.LOCATION, ""); - assertEquals( - decryptionService.decryptData(encryptionService.encryptData(map2)).get(JsonKey.LOCATION), - ""); - } catch (Exception e) { - } - } - - @Test - public void testDataDecryptionFrMapWithMapList() { - try { - map2.put(JsonKey.LOCATION, ""); - assertEquals( - decryptionService - .decryptData(encryptionService.encryptData(mapList2)) - .get(0) - .get(JsonKey.LOCATION), - ""); - } catch (Exception e) { - } - } - - @Test - public void testDataEncryptionFrMap() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - assertNotEquals(encryptionService.encryptData(map).get(JsonKey.FIRST_NAME), "Amit"); - } - } catch (Exception e) { - } - } - - @Test - public void testDataEncryptionFrListMap() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - assertNotEquals( - encryptionService.encryptData(mapList).get(0).get(JsonKey.FIRST_NAME), "Amit"); - } - } catch (Exception e) { - } - } - - @Test - public void testDataEncryptionFrMapWithNullValue() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - map.put(JsonKey.LAST_NAME, null); - assertEquals(encryptionService.encryptData(map).get(JsonKey.LAST_NAME), null); - } - } catch (Exception e) { - } - } - - @Test - public void testDataEncryptionFrMapWithEmptyValue() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - map.put(JsonKey.LAST_NAME, ""); - assertNotEquals(encryptionService.encryptData(map).get(JsonKey.LAST_NAME), ""); - } - } catch (Exception e) { - } - } - - @Test - public void testDataEncryption() { - try { - assertEquals(encryptedData, encryptionService.encryptData(data)); - } catch (Exception e) { - } - } - - @Test - public void testDataDecryption() { - try { - assertEquals(decryptedData, decryptionService.decryptData(encryptedData)); - } catch (Exception e) { - } - } - - @Test - public void testADataEncryption() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - assertNotEquals("Hello", encryptionService.encryptData("Hello")); - } else { - assertEquals("Hello", encryptionService.encryptData("Hello")); - } - } catch (Exception e) { - } - } - - @Test - public void testADataDecryption() { - try { - assertEquals("Hello", decryptionService.decryptData(encryptionService.encryptData("Hello"))); - } catch (Exception e) { - } - } - - @Test - public void testBDataDecryption() { - try { - if (JsonKey.ON.equalsIgnoreCase(sunbirdEncryption)) { - assertNotEquals( - encryptionService.encryptData("Hello"), - decryptionService.decryptData(encryptionService.encryptData("Hello"))); - } - } catch (Exception e) { - } - } - - @Test - public void testEmptyPhoneMasking() { - assertEquals(maskingService.maskPhone(""), ""); - } - - @Test - public void testNullPhoneMasking() { - assertEquals(maskingService.maskPhone(null), null); - } - - @Test - public void testPhoneMasking() { - assertEquals(maskingService.maskPhone("1234567890"), "******7890"); - } - - @Test - public void testEmptyEmailMasking() { - assertEquals(maskingService.maskEmail(""), ""); - } - - @Test - public void testNullEmailMasking() { - assertEquals(maskingService.maskEmail(null), null); - } - - @Test - public void testEmailMasking() { - assertEquals(maskingService.maskEmail("amit.ec006@gmail.com"), "am********@gmail.com"); - } - - @Test - public void testEmptyDataMasking() { - assertEquals(maskingService.maskData(""), ""); - } - - @Test - public void testNullDataMasking() { - assertEquals(maskingService.maskData(null), null); - } - - @Test - public void testDataMasking() { - assertEquals(maskingService.maskData("qwerty"), "**erty"); - } - - @Test - public void testDataOfLengthLessThanEqualTo4Masking() { - assertEquals(maskingService.maskData("qwer"), "qwer"); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImplTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImplTest.java deleted file mode 100644 index ac9940422..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImplTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.sunbird.common.models.util.datasecurity.impl; - -import org.junit.Test; -import org.sunbird.common.request.UserRequestValidator; - -import java.util.HashMap; - -import static org.junit.Assert.*; - -public class LogMaskServiceImplTest { - private LogMaskServiceImpl logMaskService = new LogMaskServiceImpl(); - - @Test - public void maskEmail() { - HashMap emailMaskExpectations = new HashMap(){ - { - put("abc@gmail.com", "ab*@gmail.com"); - put("abcd@yahoo.com", "ab**@yahoo.com"); - put("abcdefgh@testmail.org", "abcd****@testmail.org"); - } - }; - emailMaskExpectations.forEach((email, expectedResult) -> { - assertEquals(expectedResult, logMaskService.maskEmail(email)); - }); - } - - @Test - public void maskPhone() { - HashMap phoneMaskExpectations = new HashMap(){ - { - put("0123456789", "012345678*"); - put("123-456-789", "123-456-7**"); - put("123", "123"); - } - }; - phoneMaskExpectations.forEach((phone, expectedResult) -> { - assertEquals(expectedResult, logMaskService.maskPhone(phone)); - }); - } - - @Test - public void maskOTP() { - HashMap phoneMaskExpectations = new HashMap(){ - { - put("123456", "12345*"); - put("1234567", "12345**"); - - put("1234", "123*"); - put("123", "123"); - } - }; - phoneMaskExpectations.forEach((otp, expectedResult) -> { - assertEquals(expectedResult, logMaskService.maskOTP(otp)); - }); - } -} \ No newline at end of file diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/OnWayhashingTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/OnWayhashingTest.java deleted file mode 100644 index 3af48865a..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/OnWayhashingTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** */ -package org.sunbird.common.models.util.datasecurity.impl; - -import static org.junit.Assert.assertEquals; - -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.util.datasecurity.OneWayHashing; - -/** @author Manzarul */ -public class OnWayhashingTest { - public static String data = "test1234$5"; - - @Test - public void validateDataHashingSuccess() { - String encryptval = OneWayHashing.encryptVal("test1234$5"); - Assert.assertNotEquals(encryptval.length(), 0); - assertEquals(encryptval, OneWayHashing.encryptVal(data)); - } - - @Test - public void validateDataHashingFailure() { - assertEquals(OneWayHashing.encryptVal(null).length(), 0); - } - - @Test - public void validateDataHashingWithEmptyKey() { - Assert.assertNotEquals((OneWayHashing.encryptVal("")).length(), 0); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/fcm/FCMNotificationTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/fcm/FCMNotificationTest.java deleted file mode 100644 index d9b0490c7..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/fcm/FCMNotificationTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** */ -package org.sunbird.common.models.util.fcm; - -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.http.impl.client.HttpClients; -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.AdditionalMatchers; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.models.util.HttpUtil; -import org.sunbird.common.models.util.JsonKey; - -/** - * Test cases for FCM notification service. - * - * @author Manzarul - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - HttpClients.class, - URL.class, - BufferedReader.class, - HttpUtil.class, - System.class, - Notification.class -}) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -public class FCMNotificationTest { - - @Test - public void testSendNotificationSuccessWithListAndStringData() { - Map map = new HashMap<>(); - map.put("title", "some title"); - map.put("summary", "some value"); - List list = new ArrayList<>(); - list.add("test12"); - list.add("test45"); - map.put("extra", list); - Map innerMap = new HashMap<>(); - innerMap.put("title", "some value"); - innerMap.put("link", "https://google.com"); - map.put("map", innerMap); - - String val = Notification.sendNotification("nameOFTopic", map, Notification.FCM_URL); - Assert.assertNotEquals(JsonKey.FAILURE, val); - } - - @Test - public void testSendNotificationSuccessWithStringData() { - Map map = new HashMap<>(); - map.put("title", "some title"); - map.put("summary", "some value"); - String val = Notification.sendNotification("nameOFTopic", map, Notification.FCM_URL); - Assert.assertNotEquals(JsonKey.FAILURE, val); - } - - @Test - public void testSendNotificationFailureWithEmptyFcmUrl() { - Map map = new HashMap<>(); - map.put("title", "some title"); - map.put("summary", "some value"); - String val = Notification.sendNotification("nameOFTopic", map, ""); - Assert.assertEquals(JsonKey.FAILURE, val); - } - - @Test - public void testSendNotificationFailureWithNullData() { - Map map = null; - String val = Notification.sendNotification("nameOFTopic", map, ""); - Assert.assertEquals(JsonKey.FAILURE, val); - } - - @Test - public void testSendNotificationFailureWithEmptyTopic() { - Map map = new HashMap<>(); - map.put("title", "some title"); - map.put("summary", "some value"); - String val = Notification.sendNotification("", map, ""); - Assert.assertEquals(JsonKey.FAILURE, val); - } - - @Before - public void addMockRules() { - PowerMockito.mockStatic(System.class); - URL url = mock(URL.class); - HttpURLConnection connection = mock(HttpURLConnection.class); - OutputStream outStream = mock(OutputStream.class); - InputStream inStream = mock(InputStream.class); - BufferedReader reader = mock(BufferedReader.class); - try { - when(System.getenv(JsonKey.SUNBIRD_FCM_ACCOUNT_KEY)).thenReturn("FCM_KEY"); - when(System.getenv(AdditionalMatchers.not(Mockito.eq(JsonKey.SUNBIRD_FCM_ACCOUNT_KEY)))) - .thenCallRealMethod(); - - whenNew(URL.class).withAnyArguments().thenReturn(url); - when(url.openConnection()).thenReturn(connection); - when(connection.getOutputStream()).thenReturn(outStream); - when(connection.getInputStream()).thenReturn(inStream); - whenNew(BufferedReader.class).withAnyArguments().thenReturn(reader); - when(reader.readLine()).thenReturn("{\"" + JsonKey.MESSAGE_Id + "\": 123}", (String) null); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Mock rules addition failed " + e.getMessage()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/BaseRequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/BaseRequestValidatorTest.java deleted file mode 100644 index ba0d20c27..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/BaseRequestValidatorTest.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.text.MessageFormat; -import java.util.*; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** Created by rajatgupta on 20/03/19. */ -public class BaseRequestValidatorTest { - private static final BaseRequestValidator baseRequestValidator = new BaseRequestValidator(); - - @Test - public void testValidateSearchRequestFailureWithInvalidFieldType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.FILTERS, new HashMap<>()); - requestObj.put(JsonKey.FIELDS, "invalid"); - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - assertEquals( - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.FIELDS, "List"), - e.getMessage()); - } - } - - @Test - public void testValidateSearchRequestFailureWithInvalidFieldsValueInList() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.FILTERS, new HashMap<>()); - requestObj.put(JsonKey.FIELDS, Arrays.asList(1)); - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - assertEquals( - MessageFormat.format( - ResponseCode.dataTypeError.getErrorMessage(), JsonKey.FIELDS, "List of String"), - e.getMessage()); - } - } - - @Test - public void testValidateSearchRequestFailureWithInvalidFiltersKeyAsNull() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - Map filterMap = new HashMap<>(); - filterMap.put(null, "data"); - requestObj.put(JsonKey.FILTERS, filterMap); - - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals( - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), null, JsonKey.FILTERS), - e.getMessage()); - } - } - - @Test - public void testValidateSearchRequestFailureWithInvalidFiltersNullValueInList() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - Map filterMap = new HashMap<>(); - List data = new ArrayList<>(); - data.add(null); - filterMap.put(JsonKey.FIRST_NAME, data); - requestObj.put(JsonKey.FILTERS, filterMap); - - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals( - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), null, JsonKey.FIRST_NAME), - e.getMessage()); - } - } - - @Test - public void testValidateSearchRequestFailureWithInvalidFiltersNullValueInMap() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - Map filterMap = new HashMap<>(); - Map data = new HashMap<>(); - data.put(JsonKey.FIRST_NAME, null); - filterMap.put(JsonKey.FIELD, data); - requestObj.put(JsonKey.FILTERS, filterMap); - - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals( - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), null, JsonKey.FIRST_NAME), - e.getMessage()); - } - } - - @Test - public void testValidateSearchRequestFailureWithInvalidFiltersNullValueInString() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - Map data = new HashMap<>(); - data.put(JsonKey.FIRST_NAME, null); - - requestObj.put(JsonKey.FILTERS, data); - - request.setRequest(requestObj); - try { - baseRequestValidator.validateSearchRequest(request); - } catch (ProjectCommonException e) { - assertEquals( - MessageFormat.format( - ResponseCode.invalidParameterValue.getErrorMessage(), null, JsonKey.FIRST_NAME), - e.getMessage()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/CourseBatchValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/CourseBatchValidatorTest.java deleted file mode 100644 index d7ae70a35..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/CourseBatchValidatorTest.java +++ /dev/null @@ -1,440 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class CourseBatchValidatorTest { - - private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - - @Test - public void validateCreateBatchSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.STATUS, 1); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateUpdateCourseBatch() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateUpdateCourseBatchReq(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateCreateBatchWithOutCourseId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, ""); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidCourseId.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithOutName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.courseNameRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithOutStartDate() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.NAME, "TestCourse"); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.courseBatchStartDateRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithPastStartDate() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.START_DATE, "2017-01-05"); - requestObj.put(JsonKey.NAME, "TestCourse"); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.courseBatchStartDateError.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithInvalidStartDateFormat() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.START_DATE, format.format(new Date()) + " 23:58:59"); - requestObj.put(JsonKey.NAME, "TestCourse"); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithEmptyEndDate() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.START_DATE, "2017-01-05"); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, ""); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.courseBatchStartDateError.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithPastEndDate() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, -2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime())); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.endDateError.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateCreateBatchWithInvalidEndDateFormat() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "do_123233434"); - requestObj.put(JsonKey.ENROLLMENT_TYPE, "Open"); - requestObj.put(JsonKey.NAME, "TestCourse"); - requestObj.put(JsonKey.START_DATE, format.format(new Date())); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 2); - requestObj.put(JsonKey.END_DATE, format.format(cal.getTime()) + " 23:59:59+Z:50"); - List userIds = new ArrayList(); - userIds.add("test123345"); - request.put(JsonKey.COURSE_CREATED_FOR, userIds); - request.setRequest(requestObj); - try { - RequestValidator.validateCreateBatchReq(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateAddBatchCourse() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.BATCH_ID, "cassandra batch id"); - List list = new ArrayList<>(); - list.add("user id whome need to join"); - requestObj.put(JsonKey.USER_IDs, list); - request.setRequest(requestObj); - try { - RequestValidator.validateAddBatchCourse(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateAddBatchCourseWithEmptyBatchId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - List list = new ArrayList<>(); - list.add("user id whome need to join"); - requestObj.put(JsonKey.USER_IDs, list); - request.setRequest(requestObj); - try { - RequestValidator.validateAddBatchCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.courseBatchIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } - - @Test - public void validateAddBatchCourseWithEmptyUserId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.BATCH_ID, "cassandra batch id"); - request.setRequest(requestObj); - try { - RequestValidator.validateAddBatchCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.userIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } - - @Test - public void validateGetBatchCourse() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.BATCH_ID, "cassandra batch id"); - request.setRequest(requestObj); - try { - RequestValidator.validateGetBatchCourse(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateGetBatchCourseWithOutBatchId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - try { - RequestValidator.validateGetBatchCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.courseBatchIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } - - @Test - public void validateUpdateCourse() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "cassandra batch id"); - request.setRequest(requestObj); - try { - RequestValidator.validateUpdateCourse(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateUpdateCourseWithOurBatchId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - try { - RequestValidator.validateUpdateCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.courseIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } - - @Test - public void validatePublishedCourse() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "cassandra batch id"); - request.setRequest(requestObj); - try { - RequestValidator.validatePublishCourse(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validatePublishedCourseWithOutCourseId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - try { - RequestValidator.validatePublishCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.courseIdRequiredError.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } - - @Test - public void validateDeleteCourse() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.COURSE_ID, "cassandra batch id"); - request.setRequest(requestObj); - try { - RequestValidator.validateDeleteCourse(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateDeleteCourseWithOutCourseId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - try { - RequestValidator.validateDeleteCourse(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.courseIdRequiredError.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, response); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotesRequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotesRequestValidatorTest.java deleted file mode 100644 index a0ded1328..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotesRequestValidatorTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** Test class for notes request validation */ -public class NotesRequestValidatorTest { - - /** Method to test create note when userId in request is empty */ - @Test - public void testCreateNoteBlankUserId() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, ""); - requestObj.put(JsonKey.TITLE, "test title"); - requestObj.put(JsonKey.NOTE, "This is a test Note"); - requestObj.put(JsonKey.COURSE_ID, "org.ekstep.test"); - requestObj.put(JsonKey.CONTENT_ID, "org.ekstep.test"); - request.setRequest(requestObj); - RequestValidator.validateNote(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.userIdRequired.getErrorCode(), e.getCode()); - } - } - - /** Method to test create note when title in request is empty */ - @Test - public void testCreateNoteBlankTitle() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "testUser"); - requestObj.put(JsonKey.TITLE, ""); - requestObj.put(JsonKey.NOTE, "This is a test Note"); - requestObj.put(JsonKey.COURSE_ID, "org.ekstep.test"); - requestObj.put(JsonKey.CONTENT_ID, "org.ekstep.test"); - request.setRequest(requestObj); - RequestValidator.validateNote(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.titleRequired.getErrorCode(), e.getCode()); - } - } - - /** Method to test create note when note in request is empty */ - @Test - public void testCreateNoteBlankNote() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "testUser"); - requestObj.put(JsonKey.TITLE, "test title"); - requestObj.put(JsonKey.NOTE, ""); - requestObj.put(JsonKey.COURSE_ID, "org.ekstep.test"); - requestObj.put(JsonKey.CONTENT_ID, "org.ekstep.test"); - request.setRequest(requestObj); - RequestValidator.validateNote(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.noteRequired.getErrorCode(), e.getCode()); - } - } - - /** Method to test create note without courseId and contentId in request */ - @Test - public void testCreateNoteWithoutCourseAndContentId() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "testUser"); - requestObj.put(JsonKey.TITLE, "test title"); - requestObj.put(JsonKey.NOTE, "This is a test Note"); - requestObj.put(JsonKey.COURSE_ID, ""); - requestObj.put(JsonKey.CONTENT_ID, ""); - request.setRequest(requestObj); - RequestValidator.validateNote(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.contentIdError.getErrorCode(), e.getCode()); - } - } - - /** Method to test create note when tags in request is string */ - @Test - public void testCreateNoteWithTagsAsString() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "testUser"); - requestObj.put(JsonKey.TITLE, "test title"); - requestObj.put(JsonKey.NOTE, "This is a test Note"); - requestObj.put(JsonKey.COURSE_ID, "org.ekstep.test"); - requestObj.put(JsonKey.TAGS, "test tag"); - request.setRequest(requestObj); - RequestValidator.validateNote(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidTags.getErrorCode(), e.getCode()); - } - } - - /** Method to test validate node id when note id is empty */ - @Test - public void testValidateNoteOperationWithOutNoteId() { - try { - String noteId = ""; - RequestValidator.validateNoteId(noteId); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidNoteId.getErrorCode(), e.getCode()); - } - } - - /** Method to test validate node id when note id is null */ - @Test - public void testValidateNoteOperationWithNoteIdAsNull() { - try { - String noteId = null; - RequestValidator.validateNoteId(noteId); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidNoteId.getErrorCode(), e.getCode()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotificationRequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotificationRequestValidatorTest.java deleted file mode 100644 index ccc09d11f..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/NotificationRequestValidatorTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class NotificationRequestValidatorTest { - - @Test - public void validateSendNotificationSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - requestObj.put(JsonKey.TYPE, "FCM"); - Map data = new HashMap<>(); - data.put("url", "www.google.com"); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void validateSendNotificationWithOutTOParam() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TYPE, "FCM"); - Map data = new HashMap<>(); - data.put("url", "www.google.com"); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidTopic.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateSendNotificationWithOutType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - Map data = new HashMap<>(); - data.put("url", "www.google.com"); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidNotificationType.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateSendNotificationWithWrongType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - requestObj.put(JsonKey.TYPE, "GCM"); - Map data = new HashMap<>(); - data.put("url", "www.google.com"); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.notificationTypeSupport.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateSendNotificationWithEmptyData() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - requestObj.put(JsonKey.TYPE, "FCM"); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidTopicData.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateSendNotificationWithWrongObjectType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - requestObj.put(JsonKey.TYPE, "FCM"); - List data = new ArrayList(); - data.add("www.google.com"); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidTopicData.getErrorCode(), e.getCode()); - } - } - - @Test - public void validateSendNotificationWithEmptyDataMap() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.TO, "test"); - requestObj.put(JsonKey.TYPE, "FCM"); - Map data = new HashMap<>(); - requestObj.put(JsonKey.DATA, data); - request.setRequest(requestObj); - try { - RequestValidator.validateSendNotification(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidTopicData.getErrorCode(), e.getCode()); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/OrgValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/OrgValidatorTest.java deleted file mode 100644 index d41dfa8a9..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/OrgValidatorTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.request.orgvalidator.OrgRequestValidator; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class OrgValidatorTest { - - @Test - public void validateCreateOrgSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateCreateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", requestObj.get("ext")); - } - - @Test - public void validateCreateRootOrgWithLicenseSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - requestObj.put(JsonKey.LICENSE, "Test license"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateCreateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", requestObj.get("ext")); - } - - @Test - public void validateCreateRootOrgWithEmptyLicenseFailure() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - requestObj.put(JsonKey.LICENSE, ""); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateCreateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - assertEquals(requestObj.get("ext"), null); - } - - @Test - public void validateCreateOrgWithOutName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateCreateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.mandatoryParamsMissing.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } - - @Test - public void validateCreateOrgWithRootOrgTrueAndWithOutChannel() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, ""); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateCreateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.dependentParamsMissing.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } - - @Test - public void validateUpdateCreateOrgSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.ORGANISATION_ID, "test12344"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", requestObj.get("ext")); - } - - @Test - public void validateUpdateOrgFailure() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORGANISATION_ID, "test2344"); - requestObj.put(JsonKey.ROOT_ORG_ID, ""); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.invalidRootOrganisationId.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } - - @Test - public void validateUpdateOrgWithStatus() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.STATUS, "true"); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, "tpp"); - requestObj.put(JsonKey.ORGANISATION_ID, "test123444"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.invalidRequestParameter.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } - - @Test - public void validateUpdateOrgWithEmptyChannel() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.IS_ROOT_ORG, true); - requestObj.put(JsonKey.CHANNEL, ""); - requestObj.put(JsonKey.ORGANISATION_ID, "test123444"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.dependentParamsMissing.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } - - @Test - public void validateUpdateOrgStatus() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.STATUS, 2); - requestObj.put(JsonKey.ORGANISATION_ID, "test-12334"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgStatusRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", requestObj.get("ext")); - } - - @Test - public void validateUpdateOrgStatusWithInvalidStatus() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORG_NAME, "test"); - requestObj.put(JsonKey.STATUS, "true"); - requestObj.put(JsonKey.ORGANISATION_ID, "test-12334"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - new OrgRequestValidator().validateUpdateOrgStatusRequest(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.invalidRequestData.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, requestObj.get("ext")); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/PageSectionValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/PageSectionValidatorTest.java deleted file mode 100644 index 9f0d387bd..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/PageSectionValidatorTest.java +++ /dev/null @@ -1,284 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class PageSectionValidatorTest { - - @Test - public void testValidateGetPageDataSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SOURCE, "web"); - requestObj.put(JsonKey.PAGE_NAME, "resource"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateGetPageData(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", (String) requestObj.get("ext")); - } - - @Test - public void testValidateGetPageDataFailureWithoutSource() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PAGE_NAME, "resource"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateGetPageData(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sourceRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateGetPageDataFailureWithoutPageName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SOURCE, "web"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateGetPageData(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.pageNameRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateCreateSectionSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SECTION_NAME, "latest resource"); - requestObj.put( - JsonKey.SECTION_DATA_TYPE, "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateCreateSection(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", (String) requestObj.get("ext")); - } - - @Test - public void testValidateCreateSectionFailureWithoutSectionName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put( - JsonKey.SECTION_DATA_TYPE, "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateCreateSection(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sectionNameRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateCreateSectionFailureWithoutSectionDataType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SECTION_NAME, "latest resource"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateCreateSection(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sectionDataTypeRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateUpdateSectionSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SECTION_NAME, "latest resource"); - requestObj.put( - JsonKey.SECTION_DATA_TYPE, "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"); - requestObj.put(JsonKey.ID, "some section id"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdateSection(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", (String) requestObj.get("ext")); - } - - @Test - public void testValidateUpdateSectionFailureWithoutId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SECTION_NAME, "latest resource"); - requestObj.put( - JsonKey.SECTION_DATA_TYPE, "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdateSection(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sectionIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateUpdateSectionFailureWithoutSectioName() { - Request request = new Request(); - boolean reqSuccess = false; - Map requestObj = new HashMap<>(); - requestObj.put( - JsonKey.SECTION_DATA_TYPE, "{\"request\": { \"search\": {\"contentType\": [\"Story\"] }}}"); - requestObj.put(JsonKey.ID, "some section id"); - requestObj.put(JsonKey.SECTION_NAME, ""); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdateSection(request); - reqSuccess = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sectionNameRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, reqSuccess); - } - - @Test - public void testValidateUpdateSectionFailureWithoutSectioData() { - Request request = new Request(); - boolean reqSuccess = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SECTION_NAME, "latest resource"); - requestObj.put(JsonKey.SECTION_DATA_TYPE, ""); - requestObj.put(JsonKey.ID, "some section id"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdateSection(request); - reqSuccess = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.sectionDataTypeRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, reqSuccess); - } - - @Test - public void testValidateCreatePageSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PAGE_NAME, "some page name that need to be build"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateCreatePage(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", (String) requestObj.get("ext")); - } - - @Test - public void testValidateCreatePageFailureWithoutPageName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateCreatePage(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.pageNameRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } - - @Test - public void testValidateUpdatePageSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PAGE_NAME, "some page name that need to be build"); - requestObj.put(JsonKey.ID, "identifier of the page"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdatepage(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals("success", requestObj.get("ext")); - } - - @Test - public void testValidateUpdatePageFailureWithoutPageName() { - boolean reqSuccess = false; - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ID, "identifier of the page"); - requestObj.put(JsonKey.PAGE_NAME, null); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdatepage(request); - reqSuccess = false; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.pageNameRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(false, reqSuccess); - } - - @Test - public void testValidateUpdatePageFailureWithoutId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PAGE_NAME, "some page name that need to be build"); - request.setRequest(requestObj); - try { - // this method will either throw projectCommonException or it return void - RequestValidator.validateUpdatepage(request); - requestObj.put("ext", "success"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.pageIdRequired.getErrorCode(), e.getCode()); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - assertEquals(null, (String) requestObj.get("ext")); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestTest.java deleted file mode 100644 index db29d28dc..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; - -/** @author Manzarul */ -public class RequestTest { - - @Test - public void testRequestBeanWithDefaultConstructor() { - Request request = new Request(); - request.setEnv(1); - long val = System.currentTimeMillis(); - request.setId(val + ""); - request.setManagerName("name"); - request.setOperation("operation name"); - request.setRequestId("unique req id"); - request.setTs(val + ""); - request.setVer("v1"); - request.setContext(new HashMap<>()); - request.setRequest(new HashMap<>()); - request.setParams(new RequestParams()); - Assert.assertEquals(request.getEnv(), 1); - Assert.assertEquals(request.getId(), val + ""); - Assert.assertEquals(request.getManagerName(), "name"); - Assert.assertEquals(request.getOperation(), "operation name"); - Assert.assertEquals(request.getRequestId(), "unique req id"); - Assert.assertEquals(request.getTs(), val + ""); - Assert.assertEquals(request.getVer(), "v1"); - Assert.assertEquals(request.getContext().size(), 0); - Assert.assertEquals(request.getRequest().size(), 0); - Assert.assertNotNull(request.getParams()); - Assert.assertNotNull(request.toString()); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestValidatorTest.java deleted file mode 100644 index b5de217b5..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestValidatorTest.java +++ /dev/null @@ -1,476 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; - -/** @author Manzarul */ -public class RequestValidatorTest { - - @Test - public void testValidateUpdateContentSuccess() { - Request request = new Request(); - boolean response = false; - List> listOfMap = new ArrayList<>(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CONTENT_ID, "do_1233343"); - requestObj.put(JsonKey.STATUS, "Completed"); - listOfMap.add(requestObj); - Map innerMap = new HashMap<>(); - innerMap.put(JsonKey.CONTENTS, listOfMap); - request.setRequest(innerMap); - try { - RequestValidator.validateUpdateContent(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValdateUpdateContentFailureWithNullContentId() { - Request request = new Request(); - boolean response = false; - List> listOfMap = new ArrayList<>(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CONTENT_ID, null); - requestObj.put(JsonKey.STATUS, "Completed"); - listOfMap.add(requestObj); - Map innerMap = new HashMap<>(); - innerMap.put(JsonKey.CONTENTS, listOfMap); - request.setRequest(innerMap); - try { - RequestValidator.validateUpdateContent(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - assertEquals(false, response); - } - - @Test - public void testValidteUpdateContentFailureWithoutContentId() { - Request request = new Request(); - List> listOfMap = new ArrayList<>(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.STATUS, "Completed"); - listOfMap.add(requestObj); - Map innerMap = new HashMap<>(); - innerMap.put(JsonKey.CONTENTS, listOfMap); - request.setRequest(innerMap); - try { - RequestValidator.validateUpdateContent(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.contentIdRequiredError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidteUpdateContentFailureWithoutStatus() { - Request request = new Request(); - List> listOfMap = new ArrayList<>(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CONTENT_ID, "do_1233343"); - listOfMap.add(requestObj); - Map innerMap = new HashMap<>(); - innerMap.put(JsonKey.CONTENTS, listOfMap); - request.setRequest(innerMap); - try { - RequestValidator.validateUpdateContent(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.contentStatusRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidteUpdateContentFailureWithEmptyContents() { - Request request = new Request(); - List> listOfMap = new ArrayList<>(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CONTENT_ID, "do_1233343"); - Map innerMap = new HashMap<>(); - innerMap.put(JsonKey.CONTENTS, listOfMap); - request.setRequest(innerMap); - try { - RequestValidator.validateUpdateContent(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.contentIdRequiredError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateRegisterClientFailureWithEmptyClientName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CLIENT_NAME, ""); - request.setRequest(requestObj); - try { - RequestValidator.validateRegisterClient(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidClientName.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateRegisterClientSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CLIENT_NAME, "1234"); - request.setRequest(requestObj); - try { - RequestValidator.validateRegisterClient(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidClientName.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateUpdateClientKeyFailureWithEmptyToken() { - try { - RequestValidator.validateUpdateClientKey("1234", ""); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidRequestData.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateUpdateClientKeySuccess() { - try { - RequestValidator.validateUpdateClientKey("1234", "test123"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidRequestData.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateClientIdFailureWithEmptyId() { - try { - RequestValidator.validateClientId(""); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidClientId.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateFileUploadFailureWithoutContainerName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.CONTAINER, ""); - request.setRequest(requestObj); - try { - RequestValidator.validateFileUpload(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.storageContainerNameMandatory.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateSendEmailSuccess() { - boolean response = false; - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SUBJECT, "test123"); - requestObj.put(JsonKey.BODY, "test"); - List data = new ArrayList<>(); - data.add("test123@gmail.com"); - requestObj.put(JsonKey.RECIPIENT_EMAILS, data); - requestObj.put(JsonKey.RECIPIENT_USERIDS, new ArrayList<>()); - request.setRequest(requestObj); - try { - RequestValidator.validateSendMail(request); - response = true; - } catch (ProjectCommonException e) { - - } - assertTrue(response); - } - - @Test - public void testValidateSendMailFailureWithNullRecipients() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SUBJECT, "test123"); - requestObj.put(JsonKey.BODY, "test"); - requestObj.put(JsonKey.RECIPIENT_EMAILS, null); - request.setRequest(requestObj); - try { - RequestValidator.validateSendMail(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.mandatoryParamsMissing.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateSendMailFailureWithEmptyBody() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SUBJECT, "test123"); - requestObj.put(JsonKey.BODY, ""); - request.setRequest(requestObj); - try { - RequestValidator.validateSendMail(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailBodyError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateSendMailFailureWithEmptySubject() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.SUBJECT, ""); - request.setRequest(requestObj); - try { - RequestValidator.validateSendMail(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailSubjectError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateEnrolmentTypeFailureWithEmptyType() { - try { - RequestValidator.validateEnrolmentType(""); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.enrolmentTypeRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateEnrolmentTypeFailureWithWrongType() { - try { - RequestValidator.validateEnrolmentType("test"); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.enrolmentIncorrectValue.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateEnrolmentTypeSuccessWithOpenType() { - boolean response = false; - try { - RequestValidator.validateEnrolmentType(ProjectUtil.EnrolmentType.open.getVal()); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateEnrolmentTypeSuccessWithInviteType() { - boolean response = false; - try { - RequestValidator.validateEnrolmentType(ProjectUtil.EnrolmentType.inviteOnly.getVal()); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateSyncRequestSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.OPERATION_FOR, "keycloak"); - requestObj.put(JsonKey.OBJECT_TYPE, JsonKey.USER); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateSyncRequest(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateSyncRequestFailureWithNullObjectType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.OPERATION_FOR, "not keycloack"); - requestObj.put(JsonKey.OBJECT_TYPE, null); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateSyncRequest(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateSyncRequestFailureWithInvalidObjectType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.OPERATION_FOR, "not keycloack"); - List objectLsit = new ArrayList<>(); - objectLsit.add("testval"); - requestObj.put(JsonKey.OBJECT_TYPE, objectLsit); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateSyncRequest(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidObjectType.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateUserOrgTypeSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NAME, "orgtypeName"); - requestObj.put(JsonKey.ID, "orgtypeId"); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateUpdateOrgType(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateUserOrgTypeFailureWithEmptyName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NAME, ""); - requestObj.put(JsonKey.ID, "orgtypeId"); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateUpdateOrgType(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.orgTypeMandatory.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateUserOrgTypeFailureWithEmptyId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NAME, "orgTypeName"); - requestObj.put(JsonKey.ID, ""); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateUpdateOrgType(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.orgTypeIdRequired.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateCreateOrgTypeSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NAME, "OrgTypeName"); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateCreateOrgType(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateCreateOrgTypeFailureWithNullName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NAME, null); - request.setRequest(requestObj); - boolean response = false; - try { - RequestValidator.validateCreateOrgType(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.orgTypeMandatory.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateGetClientKeySuccess() { - boolean response = false; - try { - RequestValidator.validateGetClientKey("clientId", "clientType"); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateGetClientKeyFailureWithEmptyClientId() { - boolean response = false; - try { - RequestValidator.validateGetClientKey("", "clientType"); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidClientId.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateGetClientKeyFailureWithEmptyClientType() { - boolean response = false; - try { - RequestValidator.validateGetClientKey("clientId", ""); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidRequestData.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserProfileRequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserProfileRequestValidatorTest.java deleted file mode 100644 index 19cc0ff2b..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserProfileRequestValidatorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.sunbird.common.request; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; - -public class UserProfileRequestValidatorTest { - - private static final UserProfileRequestValidator userProfileRequestValidator = - new UserProfileRequestValidator(); - - @Test - public void testValidateProfileVisibilityFailureWithFieldInPrivateAndPublic() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "9878888888"); - List publicList = new ArrayList<>(); - publicList.add("Education"); - requestObj.put(JsonKey.PUBLIC, publicList); - List privateList = new ArrayList<>(); - privateList.add("Education"); - requestObj.put(JsonKey.PRIVATE, privateList); - request.setRequest(requestObj); - try { - userProfileRequestValidator.validateProfileVisibility(request); - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - } - - @Test - public void testValidateProfileVisibilityFailureWithEmptyUserId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, ""); - request.setRequest(requestObj); - try { - userProfileRequestValidator.validateProfileVisibility(request); - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - } - - @Test - public void testValidateProfileVisibilityFailureWithInvalidPrivateType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "123"); - requestObj.put(JsonKey.PRIVATE, ""); - request.setRequest(requestObj); - try { - userProfileRequestValidator.validateProfileVisibility(request); - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - } - - @Test - public void testValidateProfileVisibilityFailureWithInvalidPublicType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "123"); - requestObj.put(JsonKey.PUBLIC, ""); - request.setRequest(requestObj); - try { - userProfileRequestValidator.validateProfileVisibility(request); - } catch (ProjectCommonException e) { - Assert.assertNotNull(e); - } - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserRequestValidatorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserRequestValidatorTest.java deleted file mode 100644 index 07e6a805f..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/UserRequestValidatorTest.java +++ /dev/null @@ -1,1442 +0,0 @@ -/** */ -package org.sunbird.common.request; - -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.responsecode.ResponseCode; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class UserRequestValidatorTest { - - private static final UserRequestValidator userRequestValidator = new UserRequestValidator(); - - @Test - public void testValidatePasswordFailure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.passwordValidation.getErrorCode(), e.getCode()); - } - } - - @Test - public void testIsGoodPassword() { - HashMap passwordExpectations = new HashMap(){ - { - // Bad ones. - put("Test 1234", false); // space is not a valid char - put("hello1234", false); // no uppercase - put("helloABCD", false); // no numeral - put("hello#$%&'", false); // no uppercase/numeral - put("sho!1", false); // too short, not 8 char - put("B1!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~", false); // no lowercase - put("Test @1234", false); // contains space - - // Good ones. - put("Test123!", true); // good - put("ALongPassword@123", true); // more than 8 char - put("Abc1!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~", true); // with all spl char, PASS - } - }; - - passwordExpectations.forEach((pwd, expectedResult) -> { - assertEquals(expectedResult, UserRequestValidator.isGoodPassword(pwd)); - }); - } - - @Test - public void testValidateCreateUserBasicValidationFailure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.ROLES, "admin"); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateFieldsNotAllowedFailure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.PROVIDER, "AP"); - request.setRequest(requestObj); - try { - userRequestValidator.fieldsNotAllowed( - Arrays.asList( - JsonKey.REGISTERED_ORG_ID, - JsonKey.ROOT_ORG_ID, - JsonKey.PROVIDER, - JsonKey.EXTERNAL_ID, - JsonKey.EXTERNAL_ID_PROVIDER, - JsonKey.EXTERNAL_ID_TYPE, - JsonKey.ID_TYPE), - request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidRequestParameter.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateValidateCreateUserV3RequestSuccess() { - boolean response = false; - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.PASSWORD, "Password@1"); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserV3Request(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidatePasswordSuccess() { - boolean response = false; - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.PASSWORD, "Password@1"); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateUserCreateV3Success() { - boolean response = false; - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.PASSWORD, "Password@1"); - request.setRequest(requestObj); - try { - userRequestValidator.validateUserCreateV3(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateUserCreateV3Failure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.FIRST_NAME, ""); - request.setRequest(requestObj); - try { - userRequestValidator.validateUserCreateV3(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.mandatoryParamsMissing.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateUserNameFailure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.put(JsonKey.USERNAME, ""); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserV1Request(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.mandatoryParamsMissing.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateLocationCodesSuccess() { - boolean response = false; - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - List location = new ArrayList<>(); - location.add("KA"); - location.add("AP"); - requestObj.put(JsonKey.LOCATION_CODES, location); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - assertEquals(true, response); - } - - @Test - public void testValidateLocationCodesFailure() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - - requestObj.put(JsonKey.LOCATION_CODES, "AP"); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateForgotPasswordSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "manzarul07"); - request.setRequest(requestObj); - try { - userRequestValidator.validateForgotPassword(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateForgotPasswordFailureWithEmptyName() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, ""); - request.setRequest(requestObj); - userRequestValidator.validateForgotPassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.userNameRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateForgotPasswordFailureWithoutName() { - try { - Request request = new Request(); - Map requestObj = new HashMap<>(); - request.setRequest(requestObj); - userRequestValidator.validateForgotPassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.userNameRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateChangePasswordSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NEW_PASSWORD, "password1"); - requestObj.put(JsonKey.PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateChangePassword(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateChangePasswordFailureWithEmptyNewPassword() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NEW_PASSWORD, ""); - requestObj.put(JsonKey.PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateChangePassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.newPasswordEmpty.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateChangePasswordFailureWithoutNewPassword() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateChangePassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.newPasswordRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateChangePasswordFailureWithSameOldPassword() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NEW_PASSWORD, "password"); - requestObj.put(JsonKey.PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateChangePassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.samePasswordError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateChangePasswordFailureWithPasswordMissing() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.NEW_PASSWORD, "password"); - request.setRequest(requestObj); - try { - userRequestValidator.validateChangePassword(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.passwordRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testCreateUserSuccess() { - boolean response = false; - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - List roles = new ArrayList(); - roles.add("PUBLIC"); - roles.add("CONTENT-CREATOR"); - requestObj.put(JsonKey.ROLE, roles); - List language = new ArrayList<>(); - language.add("English"); - requestObj.put(JsonKey.LANGUAGE, language); - List> addressList = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.ADDRESS_LINE1, "test"); - map.put(JsonKey.CITY, "Bangalore"); - map.put(JsonKey.COUNTRY, "India"); - map.put(JsonKey.ADD_TYPE, "current"); - addressList.add(map); - requestObj.put(JsonKey.ADDRESS, addressList); - - List> educationList = new ArrayList<>(); - Map map1 = new HashMap<>(); - map1.put(JsonKey.COURSE_NAME, "M.C.A"); - map1.put(JsonKey.DEGREE, "Master"); - map1.put(JsonKey.NAME, "CUSAT"); - educationList.add(map1); - requestObj.put(JsonKey.EDUCATION, educationList); - - List> jobProfileList = new ArrayList<>(); - map1 = new HashMap<>(); - map1.put(JsonKey.JOB_NAME, "SE"); - map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); - jobProfileList.add(map1); - requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateCreateUserFailureWithWrongAddType() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - List roles = new ArrayList(); - roles.add("PUBLIC"); - roles.add("CONTENT-CREATOR"); - requestObj.put(JsonKey.ROLE, roles); - List language = new ArrayList<>(); - language.add("English"); - requestObj.put(JsonKey.LANGUAGE, language); - List> addressList = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.ADDRESS_LINE1, "test"); - map.put(JsonKey.CITY, "Bangalore"); - map.put(JsonKey.COUNTRY, "India"); - map.put(JsonKey.ADD_TYPE, "lmlkmkl"); - addressList.add(map); - requestObj.put(JsonKey.ADDRESS, addressList); - - List> educationList = new ArrayList<>(); - Map map1 = new HashMap<>(); - map1.put(JsonKey.COURSE_NAME, "M.C.A"); - map1.put(JsonKey.DEGREE, "Master"); - map1.put(JsonKey.NAME, "CUSAT"); - educationList.add(map1); - requestObj.put(JsonKey.EDUCATION, educationList); - - List> jobProfileList = new ArrayList<>(); - map1 = new HashMap<>(); - map1.put(JsonKey.JOB_NAME, "SE"); - map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); - jobProfileList.add(map1); - requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.addressTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyAddType() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - List roles = new ArrayList(); - roles.add("PUBLIC"); - roles.add("CONTENT-CREATOR"); - requestObj.put(JsonKey.ROLE, roles); - List language = new ArrayList<>(); - language.add("English"); - requestObj.put(JsonKey.LANGUAGE, language); - List> addressList = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.ADDRESS_LINE1, "test"); - map.put(JsonKey.CITY, "Bangalore"); - map.put(JsonKey.COUNTRY, "India"); - map.put(JsonKey.ADD_TYPE, ""); - addressList.add(map); - requestObj.put(JsonKey.ADDRESS, addressList); - - List> educationList = new ArrayList<>(); - Map map1 = new HashMap<>(); - map1.put(JsonKey.COURSE_NAME, "M.C.A"); - map1.put(JsonKey.DEGREE, "Master"); - map1.put(JsonKey.NAME, "CUSAT"); - educationList.add(map1); - requestObj.put(JsonKey.EDUCATION, educationList); - - List> jobProfileList = new ArrayList<>(); - map1 = new HashMap<>(); - map1.put(JsonKey.JOB_NAME, "SE"); - map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); - jobProfileList.add(map1); - requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testPhoneValidationSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testPhoneValidationFailureWithInvalidPhone() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "+9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.invalidPhoneNumber.getErrorCode(), e.getCode()); - } - } - - @Test - public void testPhoneValidationFailureWithInvalidCountryCode() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "+9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91968"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.invalidCountryCode.getErrorCode(), e.getCode()); - } - } - - @Test - public void testPhoneValidationFailureWithEmptyPhoneVerified() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, ""); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testPhoneValidationFailureWithPhoneVerifiedFalse() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, false); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testPhoneValidationFailureWithPhoneVerifiedNull() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.COUNTRY_CODE, "+91"); - requestObj.put(JsonKey.PROVIDER, "sunbird"); - requestObj.put(JsonKey.PHONE_VERIFIED, null); - request.setRequest(requestObj); - try { - userRequestValidator.phoneValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testUpdateUserSuccess() { - Request request = initailizeRequest(); - Map requestObj = request.getRequest(); - requestObj.remove(JsonKey.USERNAME); - requestObj.put(JsonKey.USER_ID, "userId"); - - List roles = new ArrayList(); - roles.add("PUBLIC"); - roles.add("CONTENT-CREATOR"); - requestObj.put(JsonKey.ROLE, roles); - List language = new ArrayList<>(); - language.add("English"); - requestObj.put(JsonKey.LANGUAGE, language); - List> addressList = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.ADDRESS_LINE1, "test"); - map.put(JsonKey.CITY, "Bangalore"); - map.put(JsonKey.COUNTRY, "India"); - map.put(JsonKey.ADD_TYPE, "current"); - addressList.add(map); - requestObj.put(JsonKey.ADDRESS, addressList); - - List> educationList = new ArrayList<>(); - Map map1 = new HashMap<>(); - map1.put(JsonKey.COURSE_NAME, "M.C.A"); - map1.put(JsonKey.DEGREE, "Master"); - map1.put(JsonKey.NAME, "CUSAT"); - educationList.add(map1); - requestObj.put(JsonKey.EDUCATION, educationList); - - List> jobProfileList = new ArrayList<>(); - map1 = new HashMap<>(); - map1.put(JsonKey.JOB_NAME, "SE"); - map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); - jobProfileList.add(map1); - requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); - boolean response = false; - request.setRequest(requestObj); - try { - userRequestValidator.validateUpdateUserRequest(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateUploadUserSuccessWithOrgId() { - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.ORGANISATION_ID, "ORG-1233"); - requestObj.put(JsonKey.EXTERNAL_ID_PROVIDER, "EXT_ID_PROVIDER"); - requestObj.put(JsonKey.FILE, "EXT_ID_PROVIDER"); - - try { - RequestValidator.validateUploadUser(requestObj); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateUploadUserSuccessWithExternalId() { - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PROVIDER, "ORG-provider"); - requestObj.put(JsonKey.EXTERNAL_ID, "ORG-1233"); - requestObj.put(JsonKey.ORGANISATION_ID, "ORG-1233"); - requestObj.put(JsonKey.ORG_PROVIDER, "ORG-Provider"); - requestObj.put(JsonKey.FILE, "ORG-Provider"); - try { - RequestValidator.validateUploadUser(requestObj); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateAssignRoleSuccess() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USER_ID, "ORG-provider"); - requestObj.put(JsonKey.EXTERNAL_ID, "EXT_ID"); - requestObj.put(JsonKey.ORGANISATION_ID, "ORG_ID"); - requestObj.put(JsonKey.ORG_PROVIDER, "ORG_PROVIDER"); - List roles = new ArrayList<>(); - roles.add("PUBLIC"); - requestObj.put(JsonKey.ROLES, roles); - request.setRequest(requestObj); - try { - userRequestValidator.validateAssignRole(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateAssignRoleSuccessWithProviderAndExternalId() { - Request request = new Request(); - boolean response = false; - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PROVIDER, "ORG-provider"); - requestObj.put(JsonKey.EXTERNAL_ID, "ORG-1233"); - requestObj.put(JsonKey.USER_ID, "User1"); - List roles = new ArrayList<>(); - roles.add("PUBLIC"); - requestObj.put(JsonKey.ROLES, roles); - request.setRequest(requestObj); - try { - userRequestValidator.validateAssignRole(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - assertEquals(true, response); - } - - @Test - public void testValidateWebPagesFailureWithEmptyWebPages() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.WEB_PAGES, new ArrayList<>()); - request.setRequest(requestObj); - try { - userRequestValidator.validateWebPages(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidWebPageData.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateWebPagesFailureWithNullWebPages() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.WEB_PAGES, null); - request.setRequest(requestObj); - try { - userRequestValidator.validateWebPages(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidWebPageData.getErrorCode(), e.getCode()); - } - } - - @Ignore - public void testCreateUserBasicValidationFailureWithEmptyFirstName() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.FIRST_NAME, ""); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.firstNameRequired.getErrorCode(), e.getCode()); - } - } - - @Ignore - public void testCreateUserBasicValidationFailureWithInvalidDOB() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.DOB, "20-10-15"); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testCreateUserBasicValidationFailureWithoutEmailAndPhone() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.DOB, "2018-10-15"); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailorPhoneorManagedByRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testCreateUserBasicValidationFailureWithInvalidEmail() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.DOB, "2018-10-15"); - requestObj.put(JsonKey.EMAIL, "asd@as"); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailFormatError.getErrorCode(), e.getCode()); - } - } - - @Ignore - public void testCreateUserBasicValidationFailureWithInvalidRoles() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.ROLES, ""); - request.setRequest(requestObj); - try { - userRequestValidator.createUserBasicValidation(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserRequestFailureWithInvalidLanguage() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.EMAIL, "test123@test.com"); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.LANGUAGE, ""); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserRequestFailureWithInvalidAddress() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL, "test123@test.com"); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.ADDRESS, ""); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidaeCreateUserRequestFailureWithInvalidEducation() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL, "test123@test.com"); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.EDUCATION, ""); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserRequestFailureWithInvalidAddressType() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL, "test123@test.com"); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - List> addressList = new ArrayList<>(); - Map map = new HashMap<>(); - map.put(JsonKey.ADDRESS_LINE1, "test"); - map.put(JsonKey.CITY, "Bangalore"); - map.put(JsonKey.COUNTRY, "India"); - map.put(JsonKey.ADD_TYPE, "localr"); - addressList.add(map); - requestObj.put(JsonKey.ADDRESS, addressList); - request.setRequest(requestObj); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.addressTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserRequestFailureWithInvalidCountryCode() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.EMAIL, "test123@test.com"); - requestObj.put(JsonKey.EMAIL_VERIFIED, true); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - request.setRequest(requestObj); - request.getRequest().put(JsonKey.COUNTRY_CODE, "+as"); - - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.invalidCountryCode.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserRequestFailureWithEmptyEmailAndPhone() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - requestObj.put(JsonKey.EMAIL, ""); - requestObj.put(JsonKey.PHONE, ""); - request.setRequest(requestObj); - - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailorPhoneorManagedByRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithInvalidEmail() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.EMAIL, "am@ds@cmo"); - - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.emailFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithoutPhoneVerified() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE, "7894561230"); - - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserSuccess() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE, "7894561230"); - request.getRequest().put(JsonKey.PHONE_VERIFIED, ""); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithPhoneVerifiedFalse() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE, "7894561230"); - request.getRequest().put(JsonKey.PHONE_VERIFIED, false); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyEducationName() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - Map map = new HashMap<>(); - map.put(JsonKey.NAME, ""); - List> list = new ArrayList<>(); - list.add(map); - - request.getRequest().put(JsonKey.EDUCATION, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.educationNameError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyEducationDegree() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - Map map = new HashMap<>(); - map.put(JsonKey.NAME, "name"); - map.put(JsonKey.DEGREE, ""); - List> list = new ArrayList<>(); - list.add(map); - - request.getRequest().put(JsonKey.EDUCATION, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.educationDegreeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyEducationAddress() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - Map map = new HashMap<>(); - map.put(JsonKey.NAME, "name"); - map.put(JsonKey.DEGREE, "degree"); - Map address = new HashMap<>(); - address.put(JsonKey.ADDRESS_LINE1, ""); - map.put(JsonKey.ADDRESS, address); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.EDUCATION, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyEducationCity() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - - Map map = new HashMap<>(); - map.put(JsonKey.NAME, "name"); - map.put(JsonKey.DEGREE, "degree"); - Map address = new HashMap<>(); - address.put(JsonKey.ADDRESS_LINE1, "line1"); - address.put(JsonKey.CITY, ""); - map.put(JsonKey.ADDRESS, address); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.EDUCATION, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyJobProfile() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - request.getRequest().put(JsonKey.JOB_PROFILE, ""); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyJobName() { - Request request = initailizeRequest(); - Map map = new HashMap<>(); - map.put(JsonKey.JOB_NAME, ""); - map.put(JsonKey.ORG_NAME, "degree"); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.JOB_PROFILE, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.jobNameError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithInvalidJobProfileJoiningDate() { - Request request = initailizeRequest(); - Map map = new HashMap<>(); - map.put(JsonKey.JOB_NAME, "kijklo"); - map.put(JsonKey.ORG_NAME, "degree"); - map.put(JsonKey.JOINING_DATE, "20-15-18"); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.JOB_PROFILE, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithInvalidJobProfileEndDate() { - Request request = initailizeRequest(); - Map map = new HashMap<>(); - map.put(JsonKey.JOB_NAME, "kijklo"); - map.put(JsonKey.ORG_NAME, "degree"); - map.put(JsonKey.END_DATE, "20-15-18"); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.JOB_PROFILE, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyJobProfileOrgName() { - Request request = initailizeRequest(); - Map map = new HashMap<>(); - map.put(JsonKey.JOB_NAME, "kijklo"); - map.put(JsonKey.ORG_NAME, ""); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.JOB_PROFILE, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.organisationNameError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithEmptyJobProfileCity() { - Request request = initailizeRequest(); - Map map = new HashMap<>(); - map.put(JsonKey.JOB_NAME, "jabName"); - map.put(JsonKey.ORG_NAME, "orgName"); - Map address = new HashMap<>(); - address.put(JsonKey.ADDRESS_LINE1, "line1"); - address.put(JsonKey.CITY, ""); - map.put(JsonKey.ADDRESS, address); - List> list = new ArrayList<>(); - list.add(map); - request.getRequest().put(JsonKey.JOB_PROFILE, list); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateCreateUserFailureWithInvalidPhoneFormat() { - Request request = new Request(); - request.getRequest().put(JsonKey.EMAIL, "asd@asd.com"); - request.getRequest().put(JsonKey.EMAIL_VERIFIED, true); - request.getRequest().put(JsonKey.PHONE, "9874561230"); - request.getRequest().put(JsonKey.COUNTRY_CODE, "+001"); - request.getRequest().put(JsonKey.USERNAME, "98745"); - request.getRequest().put(JsonKey.FIRST_NAME, "98745"); - try { - userRequestValidator.validateCreateUserRequest(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.phoneNoFormatError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateGerUserCountFailureWithInvalidLocationIds() { - Request request = new Request(); - request.getRequest().put(JsonKey.LOCATION_IDS, ""); - - try { - RequestValidator.validateGetUserCount(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateGerUserCountFailureWithEmptyLocationIds() { - Request request = new Request(); - List list = new ArrayList<>(); - list.add(""); - request.getRequest().put(JsonKey.LOCATION_IDS, list); - - try { - RequestValidator.validateGetUserCount(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.locationIdRequired.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateGerUserCountFailureWithInvalidUserLstReq() { - Request request = new Request(); - List list = new ArrayList<>(); - list.add("4645"); - request.getRequest().put(JsonKey.LOCATION_IDS, list); - request.getRequest().put(JsonKey.USER_LIST_REQ, null); - - try { - RequestValidator.validateGetUserCount(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateGerUserCountFailureWithUserLstReqTrue() { - Request request = new Request(); - List list = new ArrayList<>(); - list.add("4645"); - request.getRequest().put(JsonKey.LOCATION_IDS, list); - request.getRequest().put(JsonKey.USER_LIST_REQ, true); - - try { - RequestValidator.validateGetUserCount(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.functionalityMissing.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateGerUserCountFailureWithEmptyEstCntReq() { - Request request = new Request(); - List list = new ArrayList<>(); - list.add("4645"); - request.getRequest().put(JsonKey.LOCATION_IDS, list); - request.getRequest().put(JsonKey.ESTIMATED_COUNT_REQ, ""); - - try { - RequestValidator.validateGetUserCount(request); - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - } - - @Test - public void testValidateVerifyUserSuccess() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.LOGIN_ID, "username@provider"); - request.setRequest(requestObj); - boolean response = false; - try { - new UserRequestValidator().validateVerifyUser(request); - response = true; - } catch (ProjectCommonException e) { - Assert.assertNull(e); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateGerUserCountFailureWithEstCntReqTrue() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.LOGIN_ID, ""); - request.setRequest(requestObj); - boolean response = false; - try { - new UserRequestValidator().validateVerifyUser(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.loginIdRequired.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void validateUserCreateV3Sussess() { - boolean response = true; - try { - Request request = new Request(); - request.getRequest().put(JsonKey.FIRST_NAME, "test name"); - request.getRequest().put(JsonKey.EMAIL, "test@test.com"); - request.getRequest().put(JsonKey.EMAIL_VERIFIED, true); - request.getRequest().put(JsonKey.PHONE, "9663890445"); - request.getRequest().put(JsonKey.PHONE_VERIFIED, true); - new UserRequestValidator().validateUserCreateV3(request); - } catch (Exception e) { - response = false; - } - Assert.assertTrue(response); - } - - private Request initailizeRequest() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.USERNAME, "test123"); - requestObj.put(JsonKey.PHONE, "9321234123"); - requestObj.put(JsonKey.PHONE_VERIFIED, true); - requestObj.put(JsonKey.FIRST_NAME, "test123"); - request.setRequest(requestObj); - return request; - } - - @Test - public void testValidateVerifyUserFailureWithEmptyId() { - Request request = new Request(); - Map requestObj = new HashMap<>(); - requestObj.put(JsonKey.LOGIN_ID, ""); - request.setRequest(requestObj); - boolean response = false; - try { - userRequestValidator.validateVerifyUser(request); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.loginIdRequired.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateMandatoryFrameworkFieldsSuccess() { - Request request = initailizeRequest(); - request.getRequest().put(JsonKey.FRAMEWORK, createFrameWork()); - boolean response = false; - try { - new UserRequestValidator() - .validateMandatoryFrameworkFields( - request.getRequest(), getSupportedFileds(), getMandatoryFields()); - response = true; - } catch (Exception e) { - Assert.assertTrue(response); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateMandatoryFrameworkFieldValueAsString() { - Request request = initailizeRequest(); - Map frameworkMap = createFrameWork(); - frameworkMap.put("medium", "hindi"); - request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); - boolean response = false; - try { - new UserRequestValidator() - .validateMandatoryFrameworkFields( - request.getRequest(), getSupportedFileds(), getMandatoryFields()); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateFrameworkUnknownField() { - Request request = initailizeRequest(); - Map frameworkMap = createFrameWork(); - frameworkMap.put("school", Arrays.asList("school1")); - request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); - boolean response = false; - try { - new UserRequestValidator() - .validateMandatoryFrameworkFields( - request.getRequest(), getSupportedFileds(), getMandatoryFields()); - response = true; - } catch (ProjectCommonException e) { - assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - assertEquals(ResponseCode.errorUnsupportedField.getErrorCode(), e.getCode()); - } - Assert.assertFalse(response); - } - - @Test - public void testValidateFrameworkWithEmptyValue() { - Request request = initailizeRequest(); - Map frameworkMap = createFrameWork(); - frameworkMap.put("medium", Arrays.asList()); - request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); - boolean response = false; - try { - new UserRequestValidator() - .validateMandatoryFrameworkFields( - request.getRequest(), getSupportedFileds(), getMandatoryFields()); - response = true; - } catch (Exception e) { - Assert.assertTrue(response); - } - Assert.assertTrue(response); - } - - @Test - public void testValidateFrameworkWithNullValue() { - Request request = initailizeRequest(); - Map frameworkMap = createFrameWork(); - frameworkMap.put("medium", null); - request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); - - boolean response = false; - try { - new UserRequestValidator() - .validateMandatoryFrameworkFields( - request.getRequest(), getSupportedFileds(), getMandatoryFields()); - response = true; - } catch (Exception e) { - Assert.assertTrue(response); - } - Assert.assertTrue(response); - } - - private static Map createFrameWork() { - Map frameworkMap = new HashMap(); - frameworkMap.put("gradeLevel", Arrays.asList("Kindergarten")); - frameworkMap.put("subject", Arrays.asList("English")); - frameworkMap.put("id", Arrays.asList("NCF")); - return frameworkMap; - } - - private static List getSupportedFileds() { - List frameworkSupportedFields = new ArrayList(); - frameworkSupportedFields.add("id"); - frameworkSupportedFields.add("gradeLevel"); - frameworkSupportedFields.add("subject"); - frameworkSupportedFields.add("board"); - frameworkSupportedFields.add("medium"); - return frameworkSupportedFields; - } - - private static List getMandatoryFields() { - List frameworkMandatoryFields = new ArrayList(1); - frameworkMandatoryFields.add("id"); - return frameworkMandatoryFields; - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/responsecode/ResponseCodeTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/responsecode/ResponseCodeTest.java deleted file mode 100644 index fbe99401e..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/responsecode/ResponseCodeTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.sunbird.common.responsecode; - -import static org.junit.Assert.assertEquals; - -import org.junit.Assert; -import org.junit.Test; - -public class ResponseCodeTest { - - @Test - public void testGetHeaderResponseCodeClientError() { - ResponseCode respCode = - ResponseCode.getHeaderResponseCode(ResponseCode.CLIENT_ERROR.getResponseCode()); - assertEquals(ResponseCode.CLIENT_ERROR, respCode); - } - - @Test - public void testGetHeaderResponseCodeServerError() { - ResponseCode respCode = ResponseCode.getHeaderResponseCode(0); - assertEquals(ResponseCode.SERVER_ERROR, respCode); - } - - @Test - public void testGetResponse() { - ResponseCode respCode = ResponseCode.getResponse(ResponseCode.invalidData.getErrorCode()); - assertEquals(ResponseCode.invalidData, respCode); - } - - @Test - public void testGetResponseNullCheck() { - ResponseCode respCode = ResponseCode.getResponse(null); - Assert.assertNull(respCode); - } - - @Test - public void testGetResponseMessage() { - String respMsg = ResponseCode.getResponseMessage(ResponseCode.unAuthorized.getErrorCode()); - assertEquals(ResponseCode.unAuthorized.getErrorMessage(), respMsg); - } - - @Test - public void testGetResponseMessageEmpty() { - String respMsg = ResponseCode.getResponseMessage(""); - assertEquals("", respMsg); - } - - @Test - public void testInvalidElementValueSuccess() { - ResponseCode respCode = - ResponseCode.getResponse(ResponseCode.invalidElementInList.getErrorCode()); - assertEquals(ResponseCode.invalidElementInList, respCode); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/CloudStorageUtilTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/CloudStorageUtilTest.java deleted file mode 100644 index e4a2902e7..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/CloudStorageUtilTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.sunbird.common.util; - -import static org.junit.Assert.assertTrue; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.cloud.storage.BaseStorageService; -import org.sunbird.cloud.storage.factory.StorageServiceFactory; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.util.CloudStorageUtil.CloudStorageType; -import scala.Option; - -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*","jdk.internal.reflect.*"}) -@PrepareForTest({StorageServiceFactory.class, CloudStorageUtil.class}) -public class CloudStorageUtilTest { - - private static final String SIGNED_URL = "singedUrl"; - private static final String UPLOAD_URL = "uploadUrl"; - - @Before - public void initTest() { - BaseStorageService service = mock(BaseStorageService.class); - mockStatic(StorageServiceFactory.class); - - try { - when(StorageServiceFactory.class, "getStorageService", Mockito.any()).thenReturn(service); - - when(service.upload( - Mockito.anyString(), - Mockito.anyString(), - Mockito.anyString(), - Mockito.any(Option.class), - Mockito.any(Option.class), - Mockito.any(Option.class), - Mockito.any(Option.class))) - .thenReturn(UPLOAD_URL); - - when(service.getSignedURL( - Mockito.anyString(), - Mockito.anyString(), - Mockito.any(Option.class), - Mockito.any(Option.class))) - .thenReturn(SIGNED_URL); - - } catch (Exception e) { - Assert.fail(e.getMessage()); - } - } - - @Test - public void testGetStorageTypeSuccess() { - CloudStorageType storageType = CloudStorageType.getByName("azure"); - assertTrue(CloudStorageType.AZURE.equals(storageType)); - } - - @Test(expected = ProjectCommonException.class) - public void testGetStorageTypeFailureWithWrongType() { - CloudStorageType.getByName("wrongstorage"); - } - - @Test - @Ignore - public void testUploadSuccess() { - String result = - CloudStorageUtil.upload(CloudStorageType.AZURE, "container", "key", "/file/path"); - assertTrue(UPLOAD_URL.equals(result)); - } - - @Test - @Ignore - public void testGetSignedUrlSuccess() { - String signedUrl = CloudStorageUtil.getSignedUrl(CloudStorageType.AZURE, "container", "key"); - assertTrue(SIGNED_URL.equals(signedUrl)); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/ConfigUtilTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/ConfigUtilTest.java deleted file mode 100644 index 633d6ccd7..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/util/ConfigUtilTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.sunbird.common.util; - -import static org.junit.Assert.assertTrue; - -import com.typesafe.config.Config; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.responsecode.ResponseCode; - -@PrepareForTest(ConfigUtil.class) -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*", - "jdk.internal.reflect.*"}) -public class ConfigUtilTest { - - private String configType = "user"; - private String validJson = "{\"key\" : \"value\"}"; - private static ConfigUtil configUtilMock; - - @BeforeClass - public static void setup() throws Exception { - configUtilMock = Mockito.mock(ConfigUtil.class); - PowerMockito.whenNew(ConfigUtil.class).withAnyArguments().thenReturn(configUtilMock); - } - - @Test(expected = ProjectCommonException.class) - public void testGetConfigFromJsonStringFailureWithNullString() { - try { - ConfigUtil.getConfigFromJsonString(null, configType); - } catch (ProjectCommonException e) { - assertTrue(e.getCode().equals(ResponseCode.errorConfigLoadEmptyString.getErrorCode())); - throw e; - } - } - - @Test(expected = ProjectCommonException.class) - public void testGetConfigFromJsonStringFailureWithEmptyString() { - try { - ConfigUtil.getConfigFromJsonString("", configType); - } catch (ProjectCommonException e) { - assertTrue(e.getCode().equals(ResponseCode.errorConfigLoadEmptyString.getErrorCode())); - throw e; - } - } - - @Test(expected = ProjectCommonException.class) - public void testGetConfigFromJsonStringFailureWithInvalidJsonString() { - try { - ConfigUtil.getConfigFromJsonString("{dummy}", configType); - } catch (ProjectCommonException e) { - assertTrue(e.getCode().equals(ResponseCode.errorConfigLoadParseString.getErrorCode())); - throw e; - } - } - - @Test - public void testGetConfigFromJsonStringSuccess() { - Config config = ConfigUtil.getConfigFromJsonString(validJson, configType); - assertTrue("value".equals(config.getString("key"))); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/service/profile/ProfileCompletenessTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/service/profile/ProfileCompletenessTest.java deleted file mode 100644 index bd77fb61a..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/service/profile/ProfileCompletenessTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/** */ -package org.sunbird.service.profile; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.services.ProfileCompletenessService; -import org.sunbird.common.services.impl.ProfileCompletenessFactory; - -/** - * This test class have the assumption that each profile attribute have the same weighted. - * for more details look at profilecompleteness.properties. - * - * @author Manzarul - */ -public class ProfileCompletenessTest { - - private ProfileCompletenessService service = ProfileCompletenessFactory.getInstance(); - - @Test - public void allCompleteProfilePercentageTest() { - Map requestMap = new HashMap<>(); - requestMap.put(JsonKey.FIRST_NAME, "test"); - requestMap.put(JsonKey.LAST_NAME, "dsj"); - requestMap.put(JsonKey.EMAIL, "test@test.com"); - requestMap.put(JsonKey.PHONE, "3455556656"); - requestMap.put(JsonKey.PROFILE_SUMMARY, "profile is completed"); - requestMap.put(JsonKey.SUBJECT, "Math,Physics"); - requestMap.put(JsonKey.LANGUAGE, "Hindi"); - requestMap.put(JsonKey.DOB, "1995-08-09"); - requestMap.put("avatar", "some img url"); - requestMap.put(JsonKey.GRADE, "5th,6th,7th"); - requestMap.put(JsonKey.GENDER, "MALE"); - requestMap.put(JsonKey.LOCATION, "hdsvdjdjsfkf"); - requestMap.put(JsonKey.USERNAME, "test@test"); - Map address = new HashMap<>(); - address.put(JsonKey.CITY, "Bangalore"); - address.put(JsonKey.STATE, "sdkjdfjks"); - List> list = new ArrayList<>(); - list.add(address); - requestMap.put(JsonKey.ADDRESS, list); - Map edu = new HashMap<>(); - edu.put(JsonKey.COURSE, "M.C.A"); - edu.put(JsonKey.PERCENTAGE, 98); - List> eduList = new ArrayList<>(); - eduList.add(edu); - requestMap.put(JsonKey.EDUCATION, eduList); - Map job = new HashMap<>(); - job.put(JsonKey.JOB_NAME, "teacher"); - List> jobList = new ArrayList<>(); - jobList.add(job); - requestMap.put(JsonKey.JOB_PROFILE, jobList); - Map response = service.computeProfile(requestMap); - int val = (int) response.get(JsonKey.COMPLETENESS); - if(val>100) {val =100;} - Assert.assertEquals(100, val); - } - - @Test - public void allCompleteProfileErrorFieldTest() { - Map requestMap = new HashMap<>(); - requestMap.put(JsonKey.FIRST_NAME, "test"); - requestMap.put(JsonKey.LAST_NAME, "dsj"); - requestMap.put(JsonKey.EMAIL, "test@test.com"); - requestMap.put(JsonKey.PHONE, "3455556656"); - requestMap.put(JsonKey.PROFILE_SUMMARY, "profile is completed"); - requestMap.put(JsonKey.SUBJECT, "Math,Physics"); - requestMap.put(JsonKey.LANGUAGE, "Hindi"); - requestMap.put(JsonKey.DOB, "1995-08-09"); - requestMap.put("avatar", "some img url"); - requestMap.put(JsonKey.GRADE, "5th,6th,7th"); - requestMap.put(JsonKey.GENDER, "MALE"); - requestMap.put(JsonKey.LOCATION, "hdsvdjdjsfkf"); - requestMap.put(JsonKey.USERNAME, "test@test"); - Map address = new HashMap<>(); - address.put(JsonKey.CITY, "Bangalore"); - address.put(JsonKey.STATE, "sdkjdfjks"); - List> list = new ArrayList<>(); - list.add(address); - requestMap.put(JsonKey.ADDRESS, list); - Map edu = new HashMap<>(); - edu.put(JsonKey.COURSE, "M.C.A"); - edu.put(JsonKey.PERCENTAGE, 98); - List> eduList = new ArrayList<>(); - eduList.add(edu); - requestMap.put(JsonKey.EDUCATION, eduList); - Map job = new HashMap<>(); - job.put(JsonKey.JOB_NAME, "teacher"); - List> jobList = new ArrayList<>(); - jobList.add(job); - requestMap.put(JsonKey.JOB_PROFILE, jobList); - Map response = service.computeProfile(requestMap); - List val = (List) response.get(JsonKey.MISSING_FIELDS); - Assert.assertEquals(0, val.size()); - } - - @Test - public void zeroPercentageTest() { - Map requestMap = new HashMap<>(); - Map response = service.computeProfile(requestMap); - int val = - (int) (response.get(JsonKey.COMPLETENESS) != null ? response.get(JsonKey.COMPLETENESS) : 0); - Assert.assertEquals(0, val); - } - - @Test - public void zeroPercentageErrorTest() { - Map requestMap = new HashMap<>(); - Map response = service.computeProfile(requestMap); - List val = (List) response.get(JsonKey.MISSING_FIELDS); - Assert.assertEquals(14, val.size()); - } - - @Test - public void basicProfilePercentageTest() { - Map requestMap = new HashMap<>(); - requestMap.put(JsonKey.FIRST_NAME, "test"); - requestMap.put(JsonKey.LAST_NAME, "dsj"); - requestMap.put(JsonKey.EMAIL, "test@test.com"); - requestMap.put(JsonKey.PHONE, "3455556656"); - requestMap.put(JsonKey.PROFILE_SUMMARY, "profile is completed"); - requestMap.put(JsonKey.SUBJECT, "Math,Physics"); - requestMap.put(JsonKey.LANGUAGE, "Hindi"); - requestMap.put(JsonKey.DOB, "1995-08-09"); - requestMap.put("avatar", "some img url"); - requestMap.put(JsonKey.GRADE, "5th,6th,7th"); - requestMap.put(JsonKey.GENDER, "MALE"); - requestMap.put(JsonKey.LOCATION, "hdsvdjdjsfkf"); - requestMap.put(JsonKey.USERNAME, "test@test"); - Map response = service.computeProfile(requestMap); - int val = (int) response.get(JsonKey.COMPLETENESS); - Assert.assertEquals(79, val); - requestMap.remove("avatar"); - response = service.computeProfile(requestMap); - val = (int) response.get(JsonKey.COMPLETENESS); - Assert.assertEquals(72, val); - requestMap.put("avatar", "some value"); - response = service.computeProfile(requestMap); - val = (int) response.get(JsonKey.COMPLETENESS); - Assert.assertEquals(79, val); - Map address = new HashMap<>(); - address.put(JsonKey.CITY, "Bangalore"); - address.put(JsonKey.STATE, "sdkjdfjks"); - List> list = new ArrayList<>(); - list.add(address); - requestMap.put(JsonKey.ADDRESS, list); - response = service.computeProfile(requestMap); - val = (int) response.get(JsonKey.COMPLETENESS); - Assert.assertEquals(86, val); - } - - @Test - public void profileCompletenessWithNullAttribute() { - Map requestMap = null; - Map response = service.computeProfile(requestMap); - int val = - (int) (response.get(JsonKey.COMPLETENESS) != null ? response.get(JsonKey.COMPLETENESS) : 0); - Assert.assertEquals(0, val); - } - - @Test - public void profileCompletenessWithList() { - Map requestMap = new HashMap<>(); - List attribute = new ArrayList<>(); - attribute.add("pro"); - requestMap.put("list", attribute); - Map response = service.computeProfile(requestMap); - int val = - (int) (response.get(JsonKey.COMPLETENESS) != null ? response.get(JsonKey.COMPLETENESS) : 0); - Assert.assertEquals(0, val); - } - - @Test - public void profileCompletenessWithMap() { - Map requestMap = new HashMap<>(); - Map attribute = new HashMap<>(); - attribute.put("pro", "test"); - requestMap.put("list", attribute); - Map response = service.computeProfile(requestMap); - int val = - (int) (response.get(JsonKey.COMPLETENESS) != null ? response.get(JsonKey.COMPLETENESS) : 0); - Assert.assertEquals(0, val); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcherTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcherTest.java deleted file mode 100644 index 498ea3679..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakRsaKeyFetcherTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.sunbird.services.sso.impl; - -import static org.powermock.api.mockito.PowerMockito.when; - -import java.security.PublicKey; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -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; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.sunbird.common.models.util.KeyCloakConnectionProvider; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -// ** @author kirti. Junit test cases *//* - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - HttpClientBuilder.class, - CloseableHttpClient.class, - HttpGet.class, - CloseableHttpResponse.class, - HttpResponse.class, - HttpEntity.class, - EntityUtils.class, -}) -@PowerMockIgnore({ - "javax.management.*", - "javax.net.ssl.*", - "javax.security.*", - "jdk.internal.reflect.*" -}) -public class KeyCloakRsaKeyFetcherTest { - - public static final String FALSE_REALM = "false-realm"; - private static final HttpClientBuilder httpClientBuilder = - PowerMockito.mock(HttpClientBuilder.class); - private static CloseableHttpClient client = null; - private static CloseableHttpResponse response; - private static HttpEntity httpEntity; - - @Before - public void setUp() throws Exception { - - client = PowerMockito.mock(CloseableHttpClient.class); - PowerMockito.mockStatic(HttpClientBuilder.class); - when(HttpClientBuilder.create()).thenReturn(httpClientBuilder); - when(httpClientBuilder.build()).thenReturn(client); - httpEntity = PowerMockito.mock(HttpEntity.class); - PowerMockito.mockStatic(EntityUtils.class); - } - - @Test - public void testGetPublicKeyFromKeyCloakSuccess() throws Exception { - - response = PowerMockito.mock(CloseableHttpResponse.class); - when(client.execute(Mockito.any())).thenReturn(response); - when(response.getEntity()).thenReturn(httpEntity); - - String jsonString = - "{\"keys\":[{\"kid\":\"YOw4KbDjM0_HIdGkf_QhRfKc9qHc4W_8Bni91nKFyck\",\"kty\":\"RSA\",\"alg\":\"RS256\",\"use\":\"sig\",\"n\":\"" - + "5OwCfx4UZTUfUDSBjOg65HuE4ReOg9GhZyoDJNqbWFrsY3dz7C12lmM3rewBHoY0F5_KW0A7rniS9LcqDg2RODvV8pRtJZ_Ge-jsnPMBY5nDJeEW35PH9ewaBhbY3Dj0bZQda2KdHGwiQ" - + "zItMT4vw0uITKsFq9o1bcYj0QvPq10AE_wOx3T5xsysuTTkcvQ6evbbs6P5yz_SHhQFRTk7_ZhMwhBeTolvg9wF4yl4qwr220A1ORsLAwwydpmfMHU9RD97nzHDlhXTBAOhDoA3Z3wA8KG6V" - + "i3LxqTLNRVS4hgq310fHzWfCX7shFQxygijW9zit-X1WVXaS1NxazuLJw\",\"e\":\"AQAB\"}]}"; - - when(EntityUtils.toString(httpEntity)).thenReturn(jsonString); - - PublicKey key = - new KeyCloakRsaKeyFetcher() - .getPublicKeyFromKeyCloak( - KeyCloakConnectionProvider.SSO_URL, KeyCloakConnectionProvider.SSO_REALM); - - Assert.assertNotNull(key); - } - - @Test - public void testGetPublicKeyFromKeyCloakFailure() throws Exception { - - PublicKey key = - new KeyCloakRsaKeyFetcher() - .getPublicKeyFromKeyCloak(KeyCloakConnectionProvider.SSO_URL, FALSE_REALM); - - Assert.assertEquals(key, null); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakServiceImplTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakServiceImplTest.java deleted file mode 100644 index d286ca80e..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/services/sso/impl/KeyCloakServiceImplTest.java +++ /dev/null @@ -1,343 +0,0 @@ -package org.sunbird.services.sso.impl; - -import static org.powermock.api.mockito.PowerMockito.*; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import javax.ws.rs.core.Response; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RealmResource; -import org.keycloak.admin.client.resource.UserResource; -import org.keycloak.admin.client.resource.UsersResource; -import org.keycloak.representations.idm.UserRepresentation; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.sunbird.common.exception.ProjectCommonException; -import org.sunbird.common.models.util.BaseHttpTest; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.KeyCloakConnectionProvider; -import org.sunbird.common.models.util.ProjectUtil; -import org.sunbird.common.responsecode.ResponseCode; -import org.sunbird.services.sso.SSOManager; -import org.sunbird.services.sso.SSOServiceFactory; - -@PowerMockIgnore({ - "javax.management.*", - "javax.net.ssl.*", - "javax.security.*", - "jdk.internal.reflect.*" -}) -public class KeyCloakServiceImplTest extends BaseHttpTest { - - private SSOManager keyCloakService = SSOServiceFactory.getInstance(); - - private static Map userId = new HashMap<>(); - private static final String userName = UUID.randomUUID().toString().replaceAll("-", ""); - private static Class t = null; - - private static final Map USER_SUCCESS = new HashMap<>(); - - static { - USER_SUCCESS.put(JsonKey.USERNAME, userName); - USER_SUCCESS.put(JsonKey.PASSWORD, "password"); - USER_SUCCESS.put(JsonKey.FIRST_NAME, "A"); - USER_SUCCESS.put(JsonKey.LAST_NAME, "B"); - USER_SUCCESS.put(JsonKey.PHONE, "9870060000"); - USER_SUCCESS.put(JsonKey.EMAIL, userName.substring(0, 10)); - } - - private static final Map USER_SAME_EMAIL = new HashMap<>(); - - static { - USER_SAME_EMAIL.put(JsonKey.USERNAME, userName); - USER_SAME_EMAIL.put(JsonKey.PASSWORD, "password"); - USER_SAME_EMAIL.put(JsonKey.FIRST_NAME, "A"); - USER_SAME_EMAIL.put(JsonKey.LAST_NAME, "B"); - USER_SAME_EMAIL.put(JsonKey.PHONE, "9870060000"); - USER_SAME_EMAIL.put(JsonKey.EMAIL, userName.substring(0, 10)); - } - - private static UsersResource usersRes = mock(UsersResource.class); - - @BeforeClass - public static void init() { - try { - t = Class.forName("org.sunbird.services.sso.SSOServiceFactory"); - } catch (ClassNotFoundException e) { - } - Keycloak kcp = mock(Keycloak.class); - RealmResource realmRes = mock(RealmResource.class); - UserResource userRes = mock(UserResource.class); - UserRepresentation userRep = mock(UserRepresentation.class); - Response response = mock(Response.class); - PowerMockito.mockStatic(KeyCloakConnectionProvider.class); - try { - - doReturn(kcp).when(KeyCloakConnectionProvider.class, "getConnection"); - doReturn(realmRes).when(kcp).realm(Mockito.anyString()); - doReturn(usersRes).when(realmRes).users(); - doReturn(response) - .doThrow( - new ProjectCommonException( - ResponseCode.emailANDUserNameAlreadyExistError.getErrorCode(), - ResponseCode.emailANDUserNameAlreadyExistError.getErrorMessage(), - ResponseCode.CLIENT_ERROR.getResponseCode())) - .doReturn(response) - .when(usersRes) - .create(Mockito.any(UserRepresentation.class)); - doReturn(201).when(response).getStatus(); - doReturn("userdata").when(response).getHeaderString(Mockito.eq("Location")); - - doReturn(userRes).when(usersRes).get(Mockito.anyString()); - doReturn(userRep).when(userRes).toRepresentation(); - doNothing().when(userRes).update(Mockito.any(UserRepresentation.class)); - - doNothing().when(userRes).remove(); - - Map map = new HashMap<>(); - map.put(JsonKey.LAST_LOGIN_TIME, Arrays.asList(String.valueOf(System.currentTimeMillis()))); - doReturn(map).when(userRep).getAttributes(); - when(userRep.getUsername()).thenReturn("userName"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail( - "Failed in initialization of mock rules, underlying error: " + e.getLocalizedMessage()); - } - } - - @Test - public void testNewInstanceSucccess() { - Exception exp = null; - try { - Constructor constructor = t.getDeclaredConstructor(); - constructor.setAccessible(true); - SSOServiceFactory application = constructor.newInstance(); - Assert.assertNotNull(application); - } catch (Exception e) { - exp = e; - } - Assert.assertNull(exp); - } - - @Test - public void testGetUsernameById() { - String result = keyCloakService.getUsernameById("1234-567-890"); - Assert.assertNotNull(result); - } - - @Test - public void testUserUpdateTestSuccessWithAllData() { - Map request = new HashMap(); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - request.put(JsonKey.FIRST_NAME, userName); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USERNAME, userName); - request.put(JsonKey.PROVIDER, "ntp"); - String result = keyCloakService.updateUser(request); - Assert.assertNotNull(result); - } - - @Test - public void testUpdateUserSuccessWithoutProvider() { - Map request = new HashMap(); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - request.put(JsonKey.FIRST_NAME, userName); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.COUNTRY_CODE, "+91"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USERNAME, userName); - String result = keyCloakService.updateUser(request); - Assert.assertNotNull(result); - } - - @Test - public void testUpdateUserSuccessWithoutProviderAndCountryCode() { - Map request = new HashMap(); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - request.put(JsonKey.FIRST_NAME, userName); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USERNAME, userName); - String result = keyCloakService.updateUser(request); - Assert.assertNotNull(result); - } - - @Test - public void testUpdateUserSuccessWithoutAnyField() { - - Map request = new HashMap(); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - String result = keyCloakService.updateUser(request); - Assert.assertNotNull(result); - } - - - @Test(expected = ProjectCommonException.class) - public void testVerifyTokenSuccess() { - keyCloakService.verifyToken( - "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI5emhhVnZDbl81OEtheHpldHBzYXNZQ2lEallkemJIX3U2LV93SDk4SEc0In0.eyJqdGkiOiI5ZmQzNzgzYy01YjZmLTQ3OWQtYmMzYy0yZWEzOGUzZmRmYzgiLCJleHAiOjE1MDUxMTQyNDYsIm5iZiI6MCwiaWF0IjoxNTA1MTEzNjQ2LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvbWFzdGVyIiwiYXVkIjoic2VjdXJpdHktYWRtaW4tY29uc29sZSIsInN1YiI6ImIzYTZkMTY4LWJjZmQtNDE2MS1hYzVmLTljZjYyODIyNzlmMyIsInR5cCI6IkJlYXJlciIsImF6cCI6InNlY3VyaXR5LWFkbWluLWNvbnNvbGUiLCJub25jZSI6ImMxOGVlMDM2LTAyMWItNGVlZC04NWVhLTc0MjMyYzg2ZmI4ZSIsImF1dGhfdGltZSI6MTUwNTExMzY0Niwic2Vzc2lvbl9zdGF0ZSI6ImRiZTU2NDlmLTY4MDktNDA3NS05Njk5LTVhYjIyNWMwZTkyMiIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOltdLCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiTWFuemFydWwgaGFxdWUiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0MTIzNDU2NyIsImdpdmVuX25hbWUiOiJNYW56YXJ1bCBoYXF1ZSIsImVtYWlsIjoidGVzdDEyM0B0LmNvbSJ9.Xdjqe16MSkiR94g-Uj_pVZ2L3gnIdKpkJ6aB82W_w_c3yEmx1mXYBdkxe4zMz3ks4OX_PWwSFEbJECHcnujUwF6Ula0xtXTfuESB9hFyiWHtVAhuh5UlCCwPnsihv5EqK6u-Qzo0aa6qZOiQK3Zo7FLpnPUDxn4yHyo3mRZUiWf76KTl8PhSMoXoWxcR2vGW0b-cPixILTZPV0xXUZoozCui70QnvTgOJDWqr7y80EWDkS4Ptn-QM3q2nJlw63mZreOG3XTdraOlcKIP5vFK992dyyHlYGqWVzigortS9Ah4cprFVuLlX8mu1cQvqHBtW-0Dq_JlcTMaztEnqvJ6XA"); - } - - @Test - public void testAddUserLoginTimeSuccess() { - boolean response = keyCloakService.addUserLoginTime(userId.get(JsonKey.USER_ID)); - Assert.assertEquals(true, response); - } - - @Ignore - public void testActiveUserSuccess() { - Map reqMap = new HashMap<>(); - reqMap.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - String response = keyCloakService.activateUser(reqMap); - Assert.assertEquals(JsonKey.SUCCESS, response); - } - - @Test - public void testActivateUserFailureWithEmptyUserId() { - Map reqMap = new HashMap<>(); - reqMap.put(JsonKey.USER_ID, ""); - try { - keyCloakService.activateUser(reqMap); - } catch (ProjectCommonException e) { - Assert.assertEquals(ResponseCode.invalidUsrData.getErrorCode(), e.getCode()); - Assert.assertEquals(ResponseCode.invalidUsrData.getErrorMessage(), e.getMessage()); - Assert.assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - } - - @Test - public void testIsEmailVerifiedSuccess() { - boolean response = keyCloakService.isEmailVerified(userId.get(JsonKey.USER_ID)); - Assert.assertEquals(false, response); - } - - @Test - public void testSetEmailVerifiedSuccessWithVerifiedFalse() { - keyCloakService.setEmailVerifiedAsFalse(userId.get(JsonKey.USER_ID)); - boolean response = keyCloakService.isEmailVerified(userId.get(JsonKey.USER_ID)); - Assert.assertNotEquals(true, response); - } - - @Test - public void testSetEmailVerifiedSuccessWithVerifiedUpdateFalse() { - keyCloakService.setEmailVerifiedUpdatedFlag(userId.get(JsonKey.USER_ID), "false"); - String response = keyCloakService.getEmailVerifiedUpdatedFlag(userId.get(JsonKey.USER_ID)); - Assert.assertEquals(false + "", response); - } - - @Test - public void testSetEmailVerifiedTrueSuccessWithVerifiedTrue() { - keyCloakService.setEmailVerifiedUpdatedFlag(userId.get(JsonKey.USER_ID), "true"); - String response = keyCloakService.getEmailVerifiedUpdatedFlag(userId.get(JsonKey.USER_ID)); - Assert.assertEquals(true + "", response); - } - - @Test - public void testSetEmailVerifiedSuccessWithVerifiedTrue() { - String response = keyCloakService.setEmailVerifiedTrue(userId.get(JsonKey.USER_ID)); - Assert.assertEquals(JsonKey.SUCCESS, response); - } - - @Test - public void testSyncUserDataSuccess() { - Map request = new HashMap(); - request.put(JsonKey.USERNAME, userName); - request.put(JsonKey.PROVIDER, "ntp"); - request.put(JsonKey.PASSWORD, "password"); - request.put(JsonKey.FIRST_NAME, "A"); - request.put(JsonKey.LAST_NAME, "B"); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.COUNTRY_CODE, "+91"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - String response = keyCloakService.syncUserData(request); - Assert.assertEquals(JsonKey.SUCCESS, response); - } - - @Test - public void testSyncUserDataSuccessWithoutCountryCode() { - Map request = new HashMap(); - request.put(JsonKey.USERNAME, userName); - request.put(JsonKey.PROVIDER, "ntp"); - request.put(JsonKey.PASSWORD, "password"); - request.put(JsonKey.FIRST_NAME, "A"); - request.put(JsonKey.LAST_NAME, "B"); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - String response = keyCloakService.syncUserData(request); - Assert.assertEquals(JsonKey.SUCCESS, response); - } - - @Test - public void testSyncUserDataSuccessWithoutProvider() { - Map request = new HashMap(); - request.put(JsonKey.USERNAME, userName); - request.put(JsonKey.PASSWORD, "password"); - request.put(JsonKey.FIRST_NAME, "A"); - request.put(JsonKey.LAST_NAME, "B"); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USER_ID, userId.get(JsonKey.USER_ID)); - String response = keyCloakService.syncUserData(request); - Assert.assertEquals(JsonKey.SUCCESS, response); - } - - @Test - public void testSyncUserDataSuccessWithInvalidUser() { - Map request = new HashMap(); - request.put(JsonKey.USERNAME, userName); - request.put(JsonKey.PASSWORD, "password"); - request.put(JsonKey.FIRST_NAME, "A"); - request.put(JsonKey.LAST_NAME, "B"); - request.put(JsonKey.PHONE, "9870060000"); - request.put(JsonKey.EMAIL, userName.substring(0, 10)); - request.put(JsonKey.USER_ID, "xey123-23sss-cbdsgdgdg"); - try { - keyCloakService.syncUserData(request); - } catch (ProjectCommonException e) { - Assert.assertEquals(ResponseCode.invalidUsrData.getErrorCode(), e.getCode()); - Assert.assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); - } - } - - @Test - public void testDoPasswordUpdateSuccess() { - boolean response = keyCloakService.doPasswordUpdate(userId.get(JsonKey.USER_ID), "password"); - Assert.assertEquals(true, response); - } - - @Test - public void testGetFederatedUserId() - throws ClassNotFoundException, InstantiationException, IllegalAccessException, - NoSuchMethodException, SecurityException, IllegalArgumentException, - InvocationTargetException { - KeyCloakServiceImpl.class.getDeclaredMethods(); - Method m = KeyCloakServiceImpl.class.getDeclaredMethod("getFederatedUserId", String.class); - m.setAccessible(true); - SSOManager keyCloakService = SSOServiceFactory.getInstance(); - String fedUserId = (String) m.invoke(keyCloakService, "userId"); - Assert.assertEquals( - "f:" - + ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) - + ":userId", - fedUserId); - } - - @Test - public void testUpdatePassword() throws Exception { - boolean updated = keyCloakService.updatePassword(userId.get(JsonKey.USER_ID), "password"); - Assert.assertTrue(updated); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryGeneratorTest.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryGeneratorTest.java deleted file mode 100644 index b5a11e6e1..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryGeneratorTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.sunbird.telemetry.util.validator; - -import static org.junit.Assert.*; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.telemetry.dto.Context; -import org.sunbird.telemetry.dto.Producer; -import org.sunbird.telemetry.util.TelemetryGenerator; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({TelemetryGenerator.class}) -@PowerMockIgnore({ - "javax.management.*", - "javax.net.ssl.*", - "javax.security.*", - "jdk.internal.reflect.*" -}) -public class TelemetryGeneratorTest { - - private static Map context; - private static Map rollup; - - @Before - public void setUp() throws Exception { - context = new HashMap(); - rollup = new HashMap(); - context.put("actorType", "consumer"); - context.put("telemetry_pdata_pid", "learning-service"); - context.put("actorId", "X-Consumer-ID"); - context.put("requestId", "8e27cbf5-e299-43b0-bca7-8347f7e5abcf"); - context.put("channel", "ORG_001"); - context.put("telemetry_pdata_ver", "1.15"); - context.put("REQUEST_ID", "8e27cbf5-e299-43b0-bca7-8347f7e5abcf"); - context.put("env", "User"); - context.put("did", "postman"); - } - - @Test - public void testGetContextWithoutRollUp() - throws InvocationTargetException, IllegalAccessException { - Method method = Whitebox.getMethod(TelemetryGenerator.class, "getContext", Map.class); - Context ctx = (Context) method.invoke(null, context); - assertEquals("postman", ctx.getDid()); - assertEquals("ORG_001", ctx.getChannel()); - assertEquals("User", ctx.getEnv()); - } - - @Test - public void testGetContextWithRollUp() throws InvocationTargetException, IllegalAccessException { - rollup.put("id", 1); - context.put("rollup", rollup); - Method method = Whitebox.getMethod(TelemetryGenerator.class, "getContext", Map.class); - Context ctx = (Context) method.invoke(null, context); - assertTrue(rollup.equals(ctx.getRollup())); - } - - @Test - public void testRemoveAttributes() throws InvocationTargetException, IllegalAccessException { - Method method = - Whitebox.getMethod(TelemetryGenerator.class, "removeAttributes", Map.class, String.class); - String[] removableProperty = {JsonKey.DEVICE_ID}; - method.invoke(null, context, removableProperty); - assertFalse(context.containsKey(JsonKey.DEVICE_ID)); - } - - @Test() - public void testGetProducerWithContextNull() - throws InvocationTargetException, IllegalAccessException { - - Map nullContext = null; - Method method = Whitebox.getMethod(TelemetryGenerator.class, "getProducer", Map.class); - Producer producer = (Producer) method.invoke(null, nullContext); - assertEquals("", producer.getId()); - assertEquals("", producer.getPid()); - assertEquals("", producer.getVer()); - } - - @Test - public void testGetProducerWithAppId() throws InvocationTargetException, IllegalAccessException { - context.put("appId", "random"); - Method method = Whitebox.getMethod(TelemetryGenerator.class, "getProducer", Map.class); - Producer producer = (Producer) method.invoke(null, context); - assertEquals("random", producer.getId()); - } - - @Test - public void testGetProducerWithoutAppId() - throws InvocationTargetException, IllegalAccessException { - context.put("telemetry_pdata_id", "local.sunbird.learning.service"); - Method method = Whitebox.getMethod(TelemetryGenerator.class, "getProducer", Map.class); - Producer producer = (Producer) method.invoke(null, context); - assertEquals("local.sunbird.learning.service", producer.getId()); - } - - @AfterClass - public static void tearDown() throws Exception { - context.clear(); - } -} diff --git a/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryObjectValidatorV3Test.java b/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryObjectValidatorV3Test.java deleted file mode 100644 index f47bf968d..000000000 --- a/sunbird-platform-core/common-util/src/test/java/org/sunbird/telemetry/util/validator/TelemetryObjectValidatorV3Test.java +++ /dev/null @@ -1,385 +0,0 @@ -package org.sunbird.telemetry.util.validator; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.sunbird.common.models.util.JsonKey; -import org.sunbird.common.models.util.ProjectLogger; -import org.sunbird.telemetry.dto.Actor; -import org.sunbird.telemetry.dto.Context; -import org.sunbird.telemetry.dto.Telemetry; -import org.sunbird.telemetry.util.TelemetryEvents; -import org.sunbird.telemetry.validator.TelemetryObjectValidatorV3; - -/** Created by arvind on 30/1/18. */ -public class TelemetryObjectValidatorV3Test { - - private TelemetryObjectValidatorV3 validatorV3 = new TelemetryObjectValidatorV3(); - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testAuditWithValidData() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.AUDIT.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map auditEdata = new HashMap<>(); - List props = new ArrayList<>(); - props.add("username"); - props.add("org"); - auditEdata.put(JsonKey.PROPS, props); - telemetry.setEdata(auditEdata); - - boolean result = false; - try { - result = validatorV3.validateAudit(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertTrue(result); - } - - @Test - public void testAuditWithoutActor() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.AUDIT.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map auditEdata = new HashMap<>(); - List props = new ArrayList<>(); - props.add("username"); - props.add("org"); - auditEdata.put(JsonKey.PROPS, props); - telemetry.setEdata(auditEdata); - - boolean result = true; - try { - result = validatorV3.validateAudit(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testAuditWithoutChannel() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.AUDIT.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - // context.setChannel("channel"); - - telemetry.setContext(context); - - Map auditEdata = new HashMap<>(); - List props = new ArrayList<>(); - props.add("username"); - props.add("org"); - auditEdata.put(JsonKey.PROPS, props); - telemetry.setEdata(auditEdata); - - boolean result = true; - try { - result = validatorV3.validateAudit(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testAuditWithoutEnv() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.AUDIT.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - // context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map auditEdata = new HashMap<>(); - List props = new ArrayList<>(); - props.add("username"); - props.add("org"); - auditEdata.put(JsonKey.PROPS, props); - telemetry.setEdata(auditEdata); - - boolean result = true; - try { - result = validatorV3.validateAudit(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testAuditWithoutEData() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.AUDIT.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - boolean result = true; - try { - result = validatorV3.validateAudit(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testSearchWithValidData() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.SEARCH.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map searchEdata = new HashMap<>(); - searchEdata.put(JsonKey.TYPE, "user"); - searchEdata.put( - JsonKey.QUERY, - "\"filters\":{\n" + " \"lastName\": \"Test\"\n" + " \n" + " }"); - searchEdata.put(JsonKey.SIZE, new Long(10)); - searchEdata.put(JsonKey.TOPN, new ArrayList<>()); - telemetry.setEdata(searchEdata); - - boolean result = false; - try { - result = validatorV3.validateSearch(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertTrue(result); - } - - @Test - public void testSearchWithoutQuerySize() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.SEARCH.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map searchEdata = new HashMap<>(); - searchEdata.put(JsonKey.TYPE, "user"); - telemetry.setEdata(searchEdata); - - boolean result = true; - try { - result = validatorV3.validateSearch(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testLogWithValidData() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.LOG.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map logEdata = new HashMap<>(); - logEdata.put(JsonKey.TYPE, "info"); - logEdata.put(JsonKey.LEVEL, JsonKey.API_ACCESS); - logEdata.put(JsonKey.MESSAGE, ""); - telemetry.setEdata(logEdata); - - boolean result = false; - try { - result = validatorV3.validateLog(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertTrue(result); - } - - @Test - public void testLogWithoutLogLevelType() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.LOG.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - - telemetry.setContext(context); - - Map logEdata = new HashMap<>(); - logEdata.put(JsonKey.MESSAGE, ""); - telemetry.setEdata(logEdata); - - boolean result = true; - try { - result = validatorV3.validateLog(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } - - @Test - public void testErrorWithValidData() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.ERROR.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - telemetry.setContext(context); - - Map errorEdata = new HashMap<>(); - errorEdata.put(JsonKey.ERROR, "invalid user"); - errorEdata.put(JsonKey.ERR_TYPE, JsonKey.API_ACCESS); - errorEdata.put(JsonKey.STACKTRACE, "error msg"); - telemetry.setEdata(errorEdata); - - boolean result = false; - try { - result = validatorV3.validateError(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertTrue(result); - } - - @Test - public void testErrorWithoutErrorTypeStackTrace() { - - Telemetry telemetry = new Telemetry(); - telemetry.setEid(TelemetryEvents.ERROR.getName()); - telemetry.setMid("dummy msg id"); - telemetry.setVer("3.0"); - - Actor actor = new Actor(); - actor.setId("1"); - actor.setType(JsonKey.USER); - telemetry.setActor(actor); - - Context context = new Context(); - context.setEnv(JsonKey.ORGANISATION); - context.setChannel("channel"); - telemetry.setContext(context); - - Map errorEdata = new HashMap<>(); - telemetry.setEdata(errorEdata); - - boolean result = true; - try { - result = validatorV3.validateError(mapper.writeValueAsString(telemetry)); - } catch (JsonProcessingException e) { - ProjectLogger.log(e.getMessage(), e); - } - Assert.assertFalse(result); - } -} diff --git a/sunbird-platform-core/pom.xml b/sunbird-platform-core/pom.xml deleted file mode 100644 index 6cdfd1d80..000000000 --- a/sunbird-platform-core/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - org.sunbird - sunbird-platform-core - 1.0-SNAPSHOT - pom - sunbird-platform-core - - - common-util - actor-util - actor-core - sunbird-commons - - diff --git a/sunbird-platform-core/sunbird-commons/.gitignore b/sunbird-platform-core/sunbird-commons/.gitignore deleted file mode 100644 index b83d22266..000000000 --- a/sunbird-platform-core/sunbird-commons/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/sunbird-platform-core/sunbird-commons/dependency-reduced-pom.xml b/sunbird-platform-core/sunbird-commons/dependency-reduced-pom.xml deleted file mode 100644 index 2a6d86668..000000000 --- a/sunbird-platform-core/sunbird-commons/dependency-reduced-pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 4.0.0 - org.sunbird - sunbird-commons - Sunbird Commons - 1.0-SNAPSHOT - - - - maven-shade-plugin - 3.0.0 - - - package - - shade - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - com.google.guava:guava - - - - - reference.conf - - - org.sunbird.middleware.Application - - - - - - - - - - - UTF-8 - - - diff --git a/sunbird-platform-core/sunbird-commons/pom.xml b/sunbird-platform-core/sunbird-commons/pom.xml deleted file mode 100644 index 5b1e492f3..000000000 --- a/sunbird-platform-core/sunbird-commons/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - 4.0.0 - org.sunbird - sunbird-commons - 1.0-SNAPSHOT - jar - Sunbird Commons - - UTF-8 - - - - org.sunbird - actor-core - 1.0-SNAPSHOT - - - org.sunbird - actor-util - 0.0.1-SNAPSHOT - - - org.sunbird - common-util - 0.0.1-SNAPSHOT - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.0.0 - - - package - - shade - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - com.google.guava:guava - - - - - reference.conf - - - org.sunbird.middleware.Application - - - - - - - - - - diff --git a/svg_template_migration/template-migration/README.md b/svg_template_migration/template-migration/README.md deleted file mode 100644 index 24778511e..000000000 --- a/svg_template_migration/template-migration/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# SVG Template migration for sunbird-RC - -**Command to run the jar:** - -1. To migrate template - -`java -jar sunbird-java-tool.jar "domain_url" "offset" "limit"` - -**Example:** - -java -jar sunbird-java-tool.jar "staging.sunbirded.org" "0" "500" - -**Note:** -1. Run above command multiple times to migrate all the svg template based on the total count. diff --git a/svg_template_migration/template-migration/svg-migrator.jar b/svg_template_migration/template-migration/svg-migrator.jar deleted file mode 100644 index 599ad71d5..000000000 Binary files a/svg_template_migration/template-migration/svg-migrator.jar and /dev/null differ diff --git a/svg_template_migration/template-upload/README.md b/svg_template_migration/template-upload/README.md deleted file mode 100644 index 76a309627..000000000 --- a/svg_template_migration/template-upload/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# SVG Template upload for sunbird-RC - -**Command to run the jar:** - -1. To re-upload the migrated template - -`java -jar sunbird-java-tool.jar "domain url" "offset" "limit" "container account" "container key" "location of migrated template" - -**Example:** - -java -jar sunbird-java-tool.jar "dev.sunbirded.org" "0" "250" "account" "QYNH9YV5yjGogM" "/home/test/amit/sunbird/sunbird-java-tool/newFiles" diff --git a/svg_template_migration/template-upload/svg-uploader.jar b/svg_template_migration/template-upload/svg-uploader.jar deleted file mode 100644 index eb7df8e88..000000000 Binary files a/svg_template_migration/template-upload/svg-uploader.jar and /dev/null differ diff --git a/tools/java-format/google-java-format-1.5-all-deps.jar b/tools/java-format/google-java-format-1.5-all-deps.jar deleted file mode 100644 index ada76955d..000000000 Binary files a/tools/java-format/google-java-format-1.5-all-deps.jar and /dev/null differ diff --git a/uploader/dependency-reduced-pom.xml b/uploader/dependency-reduced-pom.xml deleted file mode 100644 index 000bdd32b..000000000 --- a/uploader/dependency-reduced-pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - sunbird-util - org.sunbird - 1.0-SNAPSHOT - - 4.0.0 - uploader - - svg-uploader - - - maven-shade-plugin - 2.4.3 - - - package - - shade - - - - - - org.sunbird.cloud.FileUploader - 1.0 - - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - 11 - 11 - - - diff --git a/uploader/pom.xml b/uploader/pom.xml deleted file mode 100644 index 155bdb1ef..000000000 --- a/uploader/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - sunbird-util - org.sunbird - 1.0-SNAPSHOT - - 4.0.0 - - uploader - - - 11 - 11 - - - - - org.apache.tika - tika-core - 1.16 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.1 - - - - com.microsoft.azure - azure-storage - 5.4.0 - - - org.apache.httpcomponents - httpclient - 4.5 - - - org.apache.commons - commons-collections4 - 4.4 - - - - org.sunbird - cloud-store-sdk_2.12 - 1.4.6 - - - org.slf4j - slf4j-log4j12 - - - com.fasterxml.jackson.core - jackson-databind - - - - - - svg-uploader - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.3 - - - package - - shade - - - - - - org.sunbird.cloud.FileUploader - 1.0 - - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - \ No newline at end of file diff --git a/uploader/src/main/java/org/sunbird/cloud/FileUploader.java b/uploader/src/main/java/org/sunbird/cloud/FileUploader.java deleted file mode 100644 index 2dc0ca725..000000000 --- a/uploader/src/main/java/org/sunbird/cloud/FileUploader.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.sunbird.cloud; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.sunbird.cloud.storage.BaseStorageService; -import org.sunbird.util.HttpClientUtil; -import org.sunbird.cloud.storage.factory.StorageConfig; -import org.sunbird.cloud.storage.factory.StorageServiceFactory; -import scala.Option; -import scala.Some; - -public class FileUploader { - public static void main(String[] args) { - String domain = args[0]; - String offset = args[1]; - String limit = args[2]; - String accountName = args[3]; - String accountKey = args[4]; - String svgLocation = args[5]; - String cloudStorageType = "azure"; - String endpoint = ""; - String region = ""; - if (args.length > 6) { - cloudStorageType = args[6]; - } - if (args.length > 7) { - endpoint = args[7]; - } - if (args.length > 8) { - region = args[8]; - } - - List fileList = listAllFiles(svgLocation); - Map doidFileMap = new HashMap(); - Iterator var10 = fileList.iterator(); - BaseStorageService storeService = StorageServiceFactory.getStorageService(new StorageConfig(cloudStorageType, accountName, accountKey, new Some(endpoint), new Some(region))); - - String url; - while(var10.hasNext()) { - File file = (File)var10.next(); - System.out.println(file.getAbsolutePath()); - String filePath = file.getAbsolutePath(); - String[] strArray = filePath.split("/"); - url = strArray[strArray.length - 2]; - doidFileMap.put(url, file); - } - - List> doidUrlMapList = getContentSearchResponse(domain, offset, limit); - Map urlFileMap = new HashMap(); - Iterator var22 = doidUrlMapList.iterator(); - - while(var22.hasNext()) { - Map doidUrlMap = (Map)var22.next(); - File file = (File)doidFileMap.get(doidUrlMap.get("identifier")); - if (file != null) { - urlFileMap.put((String)doidUrlMap.get("artifactUrl"), file); - } - } - - var22 = urlFileMap.entrySet().iterator(); - - while(var22.hasNext()) { - Entry urlFileEntry = (Entry)var22.next(); - url = (String)urlFileEntry.getKey(); - File file = (File)urlFileEntry.getValue(); - String[] container = url.split("/"); - StringBuilder containerPath = new StringBuilder(); - - containerPath.append(container[4]); - for(int i = 5; i < container.length - 1; ++i) { - containerPath.append("/").append(container[i]); - } - containerPath.append("/"); - String uploadedUrl = storeService.upload(container[3], file.getAbsolutePath(), containerPath + file.getName(), Option.apply(false), Option.apply(1), Option.apply(5), Option.empty()); - System.out.println(uploadedUrl); - } - System.out.println("Execution finished"); - System.exit(0); - } - - public static List> getContentSearchResponse(String domain, String offset, String limit) { - ArrayList doidUrlMapList = new ArrayList(); - - try { - String uri = "https://" + domain + "/api/content/v1/search"; - Map req = new HashMap(); - Map request = new HashMap(); - Map filters = new HashMap(); - List certTypes = new ArrayList(); - certTypes.add("cert template layout"); - certTypes.add("cert template"); - filters.put("certType", certTypes); - filters.put("mediaType", "image"); - request.put("filters", filters); - String[] fields = new String[]{"artifactUrl", "identifier"}; - request.put("fields", fields); - request.put("offset", Integer.parseInt(offset)); - request.put("limit", Integer.parseInt(limit)); - req.put("request", request); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Accept", "application/json"); - Map response = post(req, headers, uri); - System.out.println("Response : " + response); - if (MapUtils.isNotEmpty(response)) { - Map result = (Map)response.get("result"); - if (MapUtils.isNotEmpty(result)) { - int count = (Integer)result.get("count"); - List> list = (List)result.get("content"); - if (count > 0 && CollectionUtils.isNotEmpty(list)) { - Iterator var16 = list.iterator(); - - while(var16.hasNext()) { - Map map = (Map)var16.next(); - String url = (String)map.get("artifactUrl"); - String identifier = (String)map.get("identifier"); - Map doidUrlMap = new HashMap(); - doidUrlMap.put("identifier", identifier); - doidUrlMap.put("artifactUrl", url); - doidUrlMapList.add(doidUrlMap); - } - } - } - } - } catch (Exception var20) { - System.out.println("Exception while writing file"); - var20.printStackTrace(); - } - - return doidUrlMapList; - } - - public static Map post(Map requestBody, Map headers, String uri) { - try { - ObjectMapper mapper = new ObjectMapper(); - HttpClientUtil client = HttpClientUtil.getInstance(); - String reqBody = mapper.writeValueAsString(requestBody); - System.out.println("Composite search api called."); - String response = client.post(uri, reqBody, headers); - System.out.println("Composite search api response." + response); - return (Map)mapper.readValue(response, new TypeReference>() { - }); - } catch (Exception var7) { - System.out.println("Composite search api call: Exception occurred = "); - var7.printStackTrace(); - return new HashMap(); - } - } - - public static List listAllFiles(String directoryName) { - File directory = new File(directoryName); - List resultList = new ArrayList(); - File[] fList = directory.listFiles(); - File[] var7 = fList; - int var6 = fList.length; - - for(int var5 = 0; var5 < var6; ++var5) { - File file = var7[var5]; - if (file.isFile()) { - resultList.add(file); - } else if (file.isDirectory()) { - resultList.addAll(listAllFiles(file.getAbsolutePath())); - } - } - - return resultList; - } -} \ No newline at end of file diff --git a/uploader/src/main/java/org/sunbird/util/HttpClientUtil.java b/uploader/src/main/java/org/sunbird/util/HttpClientUtil.java deleted file mode 100644 index 0d66acc0a..000000000 --- a/uploader/src/main/java/org/sunbird/util/HttpClientUtil.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.sunbird.util; - -import org.apache.commons.collections4.MapUtils; -import org.apache.http.HeaderElement; -import org.apache.http.HttpEntity; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ConnectionKeepAliveStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.message.BasicHeaderElementIterator; -import org.apache.http.util.EntityUtils; - -import java.io.PrintStream; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; - -public class HttpClientUtil { - private static CloseableHttpClient httpclient = null; - private static HttpClientUtil httpClientUtil; - - private HttpClientUtil() { - ConnectionKeepAliveStrategy keepAliveStrategy = (response, context) -> { - BasicHeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator("Keep-Alive")); - - String param; - String value; - do { - if (!it.hasNext()) { - return 180000L; - } - - HeaderElement he = it.nextElement(); - param = he.getName(); - value = he.getValue(); - } while(value == null || !param.equalsIgnoreCase("timeout")); - - return Long.parseLong(value) * 1000L; - }; - PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); - connectionManager.setMaxTotal(200); - connectionManager.setDefaultMaxPerRoute(150); - connectionManager.closeIdleConnections(180L, TimeUnit.SECONDS); - httpclient = HttpClients.custom().setConnectionManager(connectionManager).useSystemProperties().setKeepAliveStrategy(keepAliveStrategy).build(); - } - - public static HttpClientUtil getInstance() { - if (httpClientUtil == null) { - Class var0 = HttpClientUtil.class; - synchronized(HttpClientUtil.class) { - if (httpClientUtil == null) { - httpClientUtil = new HttpClientUtil(); - } - } - } - - return httpClientUtil; - } - - public String post(String requestURL, String params, Map headers) { - CloseableHttpResponse response = null; - - String var6; - try { - HttpPost httpPost = new HttpPost(requestURL); - if (MapUtils.isNotEmpty(headers)) { - Iterator var24 = headers.entrySet().iterator(); - - while(var24.hasNext()) { - Entry entry = (Entry)var24.next(); - httpPost.addHeader((String)entry.getKey(), (String)entry.getValue()); - } - } - - StringEntity entity = new StringEntity(params); - httpPost.setEntity(entity); - response = httpclient.execute(httpPost); - int status = response.getStatusLine().getStatusCode(); - if (status >= 200 && status < 300) { - HttpEntity httpEntity = response.getEntity(); - byte[] bytes = EntityUtils.toByteArray(httpEntity); - StatusLine sl = response.getStatusLine(); - PrintStream var10000 = System.out; - int var10001 = sl.getStatusCode(); - var10000.println("Response from post call : " + var10001 + " - " + sl.getReasonPhrase()); - String var11 = new String(bytes); - return var11; - } - - String var8 = ""; - return var8; - } catch (Exception var22) { - System.out.println("Exception occurred while calling post method"); - var22.printStackTrace(); - var6 = ""; - } finally { - if (null != response) { - try { - response.close(); - } catch (Exception var21) { - System.out.println("Exception occurred while closing post response object"); - } - } - - } - - return var6; - } -} \ No newline at end of file