diff --git a/.gitignore b/.gitignore
index 988dd5398..e5665a3fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
.DS_Store
**/target/**
**/.idea/**
-*.iml
+**/*.iml
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..f023b9410
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,13 @@
+FROM openjdk:8-jre-alpine
+RUN apk update \
+ && apk add unzip \
+ && apk add curl \
+ && adduser -u 1001 -h /home/sunbird/ -D sunbird \
+ && mkdir -p /home/sunbird
+RUN chown -R sunbird:sunbird /home/sunbird
+USER sunbird
+COPY ./learning-api/learning-service/target/learning-service-1.0-SNAPSHOT-dist.zip /home/sunbird/
+RUN unzip /home/sunbird/learning-service-1.0-SNAPSHOT-dist.zip -d /home/sunbird/
+RUN rm /home/sunbird/learning-service-1.0-SNAPSHOT-dist.zip
+WORKDIR /home/sunbird/
+CMD java -cp '/home/sunbird/learning-service-1.0-SNAPSHOT/lib/*' play.core.server.ProdServerStart /home/sunbird/learning-service-1.0-SNAPSHOT
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 000000000..46401792f
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,56 @@
+node('build-slave') {
+ try {
+ String ANSI_GREEN = "\u001B[32m"
+ String ANSI_NORMAL = "\u001B[0m"
+ String ANSI_BOLD = "\u001B[1m"
+ String ANSI_RED = "\u001B[31m"
+ String ANSI_YELLOW = "\u001B[33m"
+
+ ansiColor('xterm') {
+ stage('Checkout') {
+ if (!env.hub_org) {
+ println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL)
+ error 'Please resolve the errors and rerun..'
+ } else
+ println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL)
+ }
+ cleanWs()
+ if (params.github_release_tag == "") {
+ checkout scm
+ commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
+ branch_name = sh(script: 'git name-rev --name-only HEAD | rev | cut -d "/" -f1| rev', returnStdout: true).trim()
+ build_tag = branch_name + "_" + commit_hash
+ println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag not specified, using the latest commit hash: " + commit_hash + ANSI_NORMAL)
+ } else {
+ def scmVars = checkout scm
+ checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/$params.github_release_tag"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
+ build_tag = params.github_release_tag
+ println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from tag: " + params.github_release_tag + ANSI_NORMAL)
+ }
+ echo "build_tag: " + build_tag
+
+ stage('Build') {
+ env.NODE_ENV = "build"
+ print "Environment will be : ${env.NODE_ENV}"
+ sh 'mvn clean install -DskipTests=true '
+
+ }
+
+ stage('Package') {
+ dir('learning-api') {
+ sh 'mvn play2:dist -pl learning-service'
+ }
+ sh('chmod 777 ./build.sh')
+ sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}")
+ }
+ stage('ArchiveArtifacts') {
+ archiveArtifacts "metadata.json"
+ currentBuild.description = "${build_tag}"
+ }
+ }
+ }
+ catch (err) {
+ currentBuild.result = "FAILURE"
+ throw err
+ }
+}
diff --git a/build.sh b/build.sh
new file mode 100755
index 000000000..fe7888c0b
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Build script
+set -eo pipefail
+
+build_tag=$1
+name=learning-service
+node=$2
+org=$3
+
+docker build -f ./Dockerfile --label commitHash=$(git rev-parse --short HEAD) -t ${org}/${name}:${build_tag} .
+echo {\"image_name\" : \"${name}\", \"image_tag\" : \"${build_tag}\", \"node_name\" : \"$node\"} > metadata.json
diff --git a/learning-api/learning-manager/conf/logback.xml b/learning-api/learning-manager/conf/logback.xml
deleted file mode 100644
index 7c3291fdc..000000000
--- a/learning-api/learning-manager/conf/logback.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
- /data/logs/learning_service_mw.log
-
- /data/logs/learning_service_mw_${timestamp}-%i.log
- 1
- 20
-
-
- 5MB
-
-
- %d %msg%n
-
-
-
- 1024
- 0
- true
-
-
-
-
-
-
-
- /data/logs/learning_telemetry_event_mw.log
-
- /data/logs/learning_telemetry_event_mw_${timestamp}-%i.log
- 1
- 20
-
-
- 5MB
-
-
- %d %msg%n
-
-
-
- 1024
- 0
- true
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/learning-api/learning-manager/.gitignore b/learning-api/learning-service/.gitignore
similarity index 100%
rename from learning-api/learning-manager/.gitignore
rename to learning-api/learning-service/.gitignore
diff --git a/learning-api/learning-manager/app/Module.scala b/learning-api/learning-service/app/Module.scala
similarity index 100%
rename from learning-api/learning-manager/app/Module.scala
rename to learning-api/learning-service/app/Module.scala
diff --git a/learning-api/learning-manager/app/controllers/BaseController.scala b/learning-api/learning-service/app/controllers/BaseController.scala
similarity index 100%
rename from learning-api/learning-manager/app/controllers/BaseController.scala
rename to learning-api/learning-service/app/controllers/BaseController.scala
diff --git a/learning-api/learning-manager/app/controllers/HealthController.scala b/learning-api/learning-service/app/controllers/HealthController.scala
similarity index 100%
rename from learning-api/learning-manager/app/controllers/HealthController.scala
rename to learning-api/learning-service/app/controllers/HealthController.scala
diff --git a/learning-api/learning-manager/app/controllers/v3/ContentController.scala b/learning-api/learning-service/app/controllers/v3/ContentController.scala
similarity index 100%
rename from learning-api/learning-manager/app/controllers/v3/ContentController.scala
rename to learning-api/learning-service/app/controllers/v3/ContentController.scala
diff --git a/learning-api/learning-manager/app/utils/ActorNames.scala b/learning-api/learning-service/app/utils/ActorNames.scala
similarity index 100%
rename from learning-api/learning-manager/app/utils/ActorNames.scala
rename to learning-api/learning-service/app/utils/ActorNames.scala
diff --git a/learning-api/learning-manager/app/utils/JavaJsonUtils.scala b/learning-api/learning-service/app/utils/JavaJsonUtils.scala
similarity index 100%
rename from learning-api/learning-manager/app/utils/JavaJsonUtils.scala
rename to learning-api/learning-service/app/utils/JavaJsonUtils.scala
diff --git a/learning-api/learning-manager/conf/application.conf b/learning-api/learning-service/conf/application.conf
similarity index 58%
rename from learning-api/learning-manager/conf/application.conf
rename to learning-api/learning-service/conf/application.conf
index 9ba3edf60..c07afc26c 100644
--- a/learning-api/learning-manager/conf/application.conf
+++ b/learning-api/learning-service/conf/application.conf
@@ -271,209 +271,4 @@ play.filters {
}
}
-# Learning-Service Configuration
-content.metadata.visibility.parent=["textbookunit", "courseunit", "lessonplanunit"]
-
-# Cassandra Configuration
-content.keyspace.name=content_store
-content.keyspace.table=content_data
-#TODO: Add Configuration for assessment. e.g: question_data
-orchestrator.keyspace.name=script_store
-orchestrator.keyspace.table=script_data
-cassandra.lp.connection="127.0.0.1:9042,127.0.0.2:9042,127.0.0.3:9042"
-cassandra.lpa.connection="127.0.0.1:9042,127.0.0.2:9042,127.0.0.3:9042"
-
-# Redis Configuration
-redis.host=localhost
-redis.port=6379
-redis.maxConnections=128
-
-#Condition to enable publish locally
-content.publish_task.enabled=true
-
-#directory location where store unzip file
-dist.directory=/data/tmp/dist/
-output.zipfile=/data/tmp/story.zip
-source.folder=/data/tmp/temp2/
-save.directory=/data/tmp/temp/
-
-# Content 2 vec analytics URL
-CONTENT_TO_VEC_URL="http://172.31.27.233:9000/content-to-vec"
-
-# FOR CONTENT WORKFLOW PIPELINE (CWP)
-
-#--Content Workflow Pipeline Mode
-OPERATION_MODE=TEST
-
-#--Maximum Content Package File Size Limit in Bytes (50 MB)
-MAX_CONTENT_PACKAGE_FILE_SIZE_LIMIT=52428800
-
-#--Maximum Asset File Size Limit in Bytes (20 MB)
-MAX_ASSET_FILE_SIZE_LIMIT=20971520
-
-#--No of Retry While File Download Fails
-RETRY_ASSET_DOWNLOAD_COUNT=1
-
-#Google-vision-API
-google.vision.tagging.enabled = false
-
-#Orchestrator env properties
-env="https://dev.ekstep.in/api/learning"
-
-#Current environment
-cloud_storage.env=dev
-
-
-#Folder configuration
-cloud_storage.content.folder=content
-cloud_storage.asset.folder=assets
-cloud_storage.artefact.folder=artifact
-cloud_storage.bundle.folder=bundle
-cloud_storage.media.folder=media
-cloud_storage.ecar.folder=ecar_files
-
-# Media download configuration
-content.media.base.url="https://dev.open-sunbird.org"
-plugin.media.base.url="https://dev.open-sunbird.org"
-
-# Configuration
-graph.dir=/data/graphDB
-akka.request_timeout=30
-environment.id=10000000
-graph.ids=["domain"]
-graph.passport.key.base=31b6fd1c4d64e745c867e61a45edc34a
-route.domain="bolt://localhost:7687"
-route.bolt.write.domain="bolt://localhost:7687"
-route.bolt.read.domain="bolt://localhost:7687"
-route.bolt.comment.domain="bolt://localhost:7687"
-route.all="bolt://localhost:7687"
-route.bolt.write.all="bolt://localhost:7687"
-route.bolt.read.all="bolt://localhost:7687"
-route.bolt.comment.all="bolt://localhost:7687"
-
-shard.id=1
-platform.auth.check.enabled=false
-platform.cache.ttl=3600000
-
-# Elasticsearch properties
-search.es_conn_info="localhost:9200"
-search.fields.query=["name^100","title^100","lemma^100","code^100","tags^100","domain","subject","description^10","keywords^25","ageGroup^10","filter^10","theme^10","genre^10","objects^25","contentType^100","language^200","teachingMode^25","skills^10","learningObjective^10","curriculum^100","gradeLevel^100","developer^100","attributions^10","owner^50","text","words","releaseNotes"]
-search.fields.date=["lastUpdatedOn","createdOn","versionDate","lastSubmittedOn","lastPublishedOn"]
-search.batch.size=500
-search.connection.timeout=30
-platform-api-url="http://localhost:8080/language-service"
-MAX_ITERATION_COUNT_FOR_SAMZA_JOB=2
-
-# DIAL Code Configuration
-dialcode.keyspace.name="dialcode_store"
-dialcode.keyspace.table="dial_code"
-dialcode.max_count=1000
-
-# System Configuration
-system.config.keyspace.name="dialcode_store"
-system.config.table="system_config"
-
-#Publisher Configuration
-publisher.keyspace.name="dialcode_store"
-publisher.keyspace.table="publisher"
-
-#DIAL Code Generator Configuration
-dialcode.strip.chars="0"
-dialcode.length=6.0
-dialcode.large.prime_number=1679979167
-
-#DIAL Code ElasticSearch Configuration
-dialcode.index=true
-dialcode.object_type="DialCode"
-
-framework.max_term_creation_limit=200
-
-# Enable Suggested Framework in Get Channel API.
-channel.fetch.suggested_frameworks=true
-
-# Kafka configuration details
-kafka.topics.instruction="local.learning.job.request"
-kafka.urls="localhost:9092"
-
-#Youtube Standard Licence Validation
-learning.content.youtube.validate.license=true
-learning.content.youtube.application.name=fetch-youtube-license
-youtube.license.regex.pattern=["\\?vi?=([^&]*)", "watch\\?.*v=([^&]*)", "(?:embed|vi?)/([^/?]*)","^([A-Za-z0-9\\-\\_]*)"]
-
-#Top N Config for Search Telemetry
-telemetry_env=dev
-telemetry.search.topn=5
-
-installation.id=ekstep
-
-learning.content.copy.invalid_status_list=["Flagged","FlaggedDraft","FraggedReview","Retired", "Processing"]
-learning.content.copy.props_to_remove=["downloadUrl", "artifactUrl", "variants",
- "createdOn", "collections", "children", "lastUpdatedOn", "SYS_INTERNAL_LAST_UPDATED_ON",
- "versionKey", "s3Key", "status", "pkgVersion", "toc_url", "mimeTypesCount",
- "contentTypesCount", "leafNodesCount", "childNodes", "prevState", "lastPublishedOn",
- "flagReasons", "compatibilityLevel", "size", "publishChecklist", "publishComment",
- "LastPublishedBy", "rejectReasons", "rejectComment", "gradeLevel", "subject",
- "medium", "board", "topic", "purpose", "subtopic", "contentCredits",
- "owner", "collaborators", "creators", "contributors", "badgeAssertions", "dialcodes",
- "concepts", "keywords", "reservedDialcodes", "dialcodeRequired", "leafNodes"]
-
-# Metadata to be added to copied content from origin
-learning.content.copy.origin_data=["name", "author", "license", "organisation"]
-
-learning.content.type.not.copied.list=["Asset"]
-
-channel.default="in.ekstep"
-
-# DialCode Link API Config
-learning.content.link_dialcode_validation=true
-dialcode.api.search.url="http://localhost:8080/learning-service/v3/dialcode/search"
-dialcode.api.authorization=auth_key
-
-# Language-Code Configuration
-language.graph_ids=["as","bn","en","gu","hi","hoc","jun","ka","mai","mr","unx","or","san","sat","ta","te","urd", "pj"]
-
-# Kafka send event to topic enable
-kafka.topic.send.enable=false
-
-learning.valid_license=["creativeCommon"]
-learning.service_provider=["youtube"]
-
-stream.mime.type=video/mp4
-compositesearch.index.name="compositesearch"
-
-hierarchy.keyspace.name=hierarchy_store
-content.hierarchy.table=content_hierarchy
-framework.hierarchy.table=framework_hierarchy
-
-# Kafka topic for definition update event.
-kafka.topic.system.command="dev.system.command"
-
-learning.reserve_dialcode.content_type=["TextBook"]
-# restrict.metadata.objectTypes=["Content", "ContentImage", "AssessmentItem", "Channel", "Framework", "Category", "CategoryInstance", "Term"]
-
-#restrict.metadata.objectTypes="Content,ContentImage"
-
-publish.collection.fullecar.disable=true
-
-# Consistency Level for Multi Node Cassandra cluster
-cassandra.lp.consistency.level=QUORUM
-
-
-content.tagging.backward_enable=true
-content.tagging.property="subject,medium"
-
-content.nested.fields="badgeAssertions,targets,badgeAssociations"
-
-content.cache.ttl=86400
-content.cache.read=true
-content.cache.hierarchy=true
-content.discard.status=["Draft","FlagDraft"]
-
-framework.categories_cached=["subject", "medium", "gradeLevel", "board"]
-framework.cache.ttl=86400
-framework.cache.read=true
-
-
-# Max size(width/height) of thumbnail in pixels
-max.thumbnail.size.pixels=150
diff --git a/learning-api/learning-service/conf/logback.xml b/learning-api/learning-service/conf/logback.xml
new file mode 100644
index 000000000..73529d622
--- /dev/null
+++ b/learning-api/learning-service/conf/logback.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+ %d %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/learning-api/learning-manager/conf/routes b/learning-api/learning-service/conf/routes
similarity index 100%
rename from learning-api/learning-manager/conf/routes
rename to learning-api/learning-service/conf/routes
diff --git a/learning-api/learning-manager/conf/schemas/content-1.0/config.json b/learning-api/learning-service/conf/schemas/content-1.0/config.json
similarity index 100%
rename from learning-api/learning-manager/conf/schemas/content-1.0/config.json
rename to learning-api/learning-service/conf/schemas/content-1.0/config.json
diff --git a/learning-api/learning-manager/conf/schemas/content-1.0/schema.json b/learning-api/learning-service/conf/schemas/content-1.0/schema.json
similarity index 100%
rename from learning-api/learning-manager/conf/schemas/content-1.0/schema.json
rename to learning-api/learning-service/conf/schemas/content-1.0/schema.json
diff --git a/learning-api/learning-manager/pom.xml b/learning-api/learning-service/pom.xml
similarity index 98%
rename from learning-api/learning-manager/pom.xml
rename to learning-api/learning-service/pom.xml
index b496cc69e..1b44a810a 100755
--- a/learning-api/learning-manager/pom.xml
+++ b/learning-api/learning-service/pom.xml
@@ -1,8 +1,8 @@
4.0.0
- learning-manager
- learning-manager
+ learning-service
+ learning-service
play2
org.sunbird
diff --git a/learning-api/orchestrator/src/main/java/org/sunbird/actors/content/ContentActor.java b/learning-api/orchestrator/src/main/java/org/sunbird/actors/content/ContentActor.java
index e19f7539f..d4e1702a3 100644
--- a/learning-api/orchestrator/src/main/java/org/sunbird/actors/content/ContentActor.java
+++ b/learning-api/orchestrator/src/main/java/org/sunbird/actors/content/ContentActor.java
@@ -1,13 +1,14 @@
package org.sunbird.actors.content;
-import akka.dispatch.Futures;
import akka.dispatch.Mapper;
import org.apache.commons.lang3.StringUtils;
import org.sunbird.actor.core.BaseActor;
+import org.sunbird.common.ContentParams;
import org.sunbird.common.dto.Request;
import org.sunbird.common.dto.Response;
import org.sunbird.common.dto.ResponseHandler;
import org.sunbird.common.exception.ResponseCode;
+import org.sunbird.common.exception.ClientException;
import org.sunbird.graph.dac.model.Node;
import org.sunbird.graph.nodes.DataNode;
import org.sunbird.utils.NodeUtils;
@@ -18,7 +19,6 @@
import java.util.Map;
import java.util.stream.Collectors;
-
public class ContentActor extends BaseActor {
public Future onReceive(Request request) throws Throwable {
String operation = request.getOperation();
@@ -32,6 +32,7 @@ public Future onReceive(Request request) throws Throwable {
}
private Future create(Request request) throws Exception {
+ populateDefaultersForCreation(request);
return DataNode.create(request, getContext().dispatcher())
.map(new Mapper() {
@Override
@@ -53,7 +54,7 @@ private Future read(Request request) throws Exception {
@Override
public Response apply(Node node) {
if(NodeUtils.isRetired(node))
- return ResponseHandler.ERROR(ResponseCode.RESOURCE_NOT_FOUND, ResponseCode.RESOURCE_NOT_FOUND.code(), "Content not found with identifier: " + node.getIdentifier())
+ return ResponseHandler.ERROR(ResponseCode.RESOURCE_NOT_FOUND, ResponseCode.RESOURCE_NOT_FOUND.name(), "Content not found with identifier: " + node.getIdentifier())
Map metadata = NodeUtils.serialize(node, fields);
Response response = ResponseHandler.OK();
response.put("content", metadata);
@@ -65,4 +66,40 @@ public Response apply(Node node) {
private void update(Request request) {
}
+ private static void populateDefaultersForCreation(Request request) {
+ setDefaultsBasedOnMimeType(request, ContentParams.create.name());
+ validateLicense(request);
+ }
+
+ private static void validateLicense(Request request) {
+ //TODO: for license validation
+ }
+
+ private static void setDefaultsBasedOnMimeType(Request request, String operation) {
+
+ String mimeType = (String) request.get(ContentParams.mimeType.name());
+ if (StringUtils.isNotBlank(mimeType) && operation.equalsIgnoreCase(ContentParams.create.name())) {
+ if(StringUtils.equalsIgnoreCase("application/vnd.ekstep.plugin-archive", mimeType)) {
+ String code = (String) request.get(ContentParams.code.name());
+ if (null == code || StringUtils.isBlank(code))
+ throw new ClientException("ERR_PLUGIN_CODE_REQUIRED", "Unique code is mandatory for plugins");
+ request.put(ContentParams.identifier.name(), request.get(ContentParams.code.name()));
+ } else {
+ request.put(ContentParams.osId.name(), "org.ekstep.quiz.app");
+ }
+
+ if (mimeType.endsWith("archive") || mimeType.endsWith("vnd.ekstep.content-collection")
+ || mimeType.endsWith("epub"))
+ request.put(ContentParams.contentEncoding.name(), ContentParams.gzip.name());
+ else
+ request.put(ContentParams.contentEncoding.name(), ContentParams.identity.name());
+
+ if (mimeType.endsWith("youtube") || mimeType.endsWith("x-url"))
+ request.put(ContentParams.contentDisposition.name(), ContentParams.online.name());
+ else
+ request.put(ContentParams.contentDisposition.name(), ContentParams.inline.name());
+ }
+ }
+
+
}
diff --git a/learning-api/pom.xml b/learning-api/pom.xml
index ff9d375f4..c26c8c135 100755
--- a/learning-api/pom.xml
+++ b/learning-api/pom.xml
@@ -21,7 +21,7 @@
2.11.8
- learning-manager
+ learning-service
orchestrator
diff --git a/platform-core/platform-common/src/main/java/org/sunbird/common/ContentParams.java b/platform-core/platform-common/src/main/java/org/sunbird/common/ContentParams.java
new file mode 100644
index 000000000..f40cd9473
--- /dev/null
+++ b/platform-core/platform-common/src/main/java/org/sunbird/common/ContentParams.java
@@ -0,0 +1,5 @@
+package org.sunbird.common;
+
+public enum ContentParams {
+ contentEncoding,gzip,identity,contentDisposition,online,inline,identifier,code,osId,mimeType,create
+}
diff --git a/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/BaseSchemaValidator.java b/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/BaseSchemaValidator.java
index d65623bf6..6296fb7f4 100644
--- a/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/BaseSchemaValidator.java
+++ b/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/BaseSchemaValidator.java
@@ -18,6 +18,8 @@
import javax.json.JsonReader;
import javax.json.JsonReaderFactory;
import java.io.IOException;
+import java.io.InputStream;
+
import java.io.StringReader;
import java.net.URI;
import java.nio.file.Path;
@@ -41,7 +43,7 @@ public BaseSchemaValidator(String name, String version) {
this.name = name;
this.version = version;
this.schemaReaderFactory = service.createSchemaReaderFactoryBuilder()
- .withSchemaResolver(this::resolveSchema)
+// .withSchemaResolver(this::resolveSchema)
.build();
}
@@ -59,11 +61,11 @@ public Config getConfig() {
/**
* Reads the JSON schema from the specified path.
*
- * @param path the path to the schema.
+ * @param stream the InputStream for the schema.
* @return the read schema.
*/
- protected JsonSchema readSchema(Path path) {
- try (JsonSchemaReader reader = schemaReaderFactory.createSchemaReader(path)) {
+ protected JsonSchema readSchema(InputStream stream) {
+ try (JsonSchemaReader reader = schemaReaderFactory.createSchemaReader(stream)) {
return reader.read();
}
}
diff --git a/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/JsonSchemaValidator.java b/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/JsonSchemaValidator.java
index 937e731e7..233ea6ee9 100644
--- a/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/JsonSchemaValidator.java
+++ b/platform-core/schema-validator/src/main/java/org/sunbird/schema/impl/JsonSchemaValidator.java
@@ -3,32 +3,34 @@
import com.typesafe.config.ConfigFactory;
import org.leadpony.justify.api.JsonSchema;
+import java.io.InputStream;
import java.net.URI;
+import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
public class JsonSchemaValidator extends BaseSchemaValidator {
- private static String basePath = "schemas/";
+ private static String basePath = "https://sunbirddev.blob.core.windows.net/sunbird-content-dev/schemas/";
public JsonSchemaValidator(String name, String version) throws Exception {
super(name, version);
- basePath = basePath + name.toLowerCase() + "-" + version + "/";
+ basePath = basePath + name.toLowerCase() + "/" + version + "/";
loadSchema();
loadConfig();
}
private void loadSchema() throws Exception {
- URI uri = getClass().getClassLoader().getResource( basePath + "schema.json").toURI();
- Path schemaPath = Paths.get(uri);
- this.schema = readSchema(schemaPath);
+ System.out.println("Schema path: " + basePath + "schema.json");
+ InputStream stream = new URL( basePath + "schema.json").openStream();
+ this.schema = readSchema(stream);
}
private void loadConfig() throws Exception {
- URI uri = getClass().getClassLoader().getResource( basePath + "config.json").toURI();
- Path configPath = Paths.get(uri);
- this.config = ConfigFactory.parseFile(configPath.toFile());
+// URI uri = getClass().getClassLoader().getResource( basePath + "config.json").toURI();
+ System.out.println("Config path: " + basePath + "config.json");
+ this.config = ConfigFactory.parseURL(new URL( basePath + "config.json"));
}
@@ -41,12 +43,12 @@ private void loadConfig() throws Exception {
*/
public JsonSchema resolveSchema(URI id) {
// The schema is available in the local filesystem.
- try {
- Path path = Paths.get( getClass().getClassLoader().getResource(basePath + id.getPath()).toURI());
- return readSchema(path);
- } catch (Exception e) {
- e.printStackTrace();
- }
+// try {
+// Path path = Paths.get( getClass().getClassLoader().getResource(basePath + id.getPath()).toURI());
+// return readSchema(path);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
return null;
}
}