Skip to content

Commit

Permalink
Merge branch 'release-4.8.0' into readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayaprakash8887 authored Apr 4, 2022
2 parents 30d04fd + 92e5e0c commit cbd1370
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --par
```

### Running Content Service:

### (Content V3+V4 APIs, Collection V4 APIs, Assets V4 APIs, Channel V3 APIs, License V3 APIs, Event V4 APIs, EventSet V4 APIs)

1. Go to the path: /knowledge-platform and run the below maven command to build the application.
```shell
mvn clean install -DskipTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class QuestionActor @Inject()(implicit oec: OntologyEngineContext) extends BaseA
val propsToRemove = Platform.getStringList("import.remove_props.question", java.util.Arrays.asList()).asScala.toList
val topicName = Platform.config.getString("import.output_topic_name")
val reqLimit = Platform.getInteger("import.request_size_limit", 200)
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove)
val validSourceStatus = Platform.getStringList("import.valid_source_status", java.util.Arrays.asList("Live", "Unlisted")).asScala.toList
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove, validSourceStatus)
}

def systemUpdate(request: Request): Future[Response] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ class QuestionSetActor @Inject()(implicit oec: OntologyEngineContext) extends Ba
val propsToRemove = Platform.getStringList("import.remove_props.questionset", java.util.Arrays.asList()).asScala.toList
val topicName = Platform.config.getString("import.output_topic_name")
val reqLimit = Platform.getInteger("import.request_size_limit", 200)
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove)
val validSourceStatus = Platform.getStringList("import.valid_source_status", java.util.Arrays.asList("Live", "Unlisted")).asScala.toList
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove, validSourceStatus)
}

def systemUpdate(request: Request): Future[Response] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ class QuestionActorTest extends BaseSpec with MockFactory {
resp.put("question", new util.HashMap[String, AnyRef](){{
put("framework", "NCF")
put("channel", "test")
put("status", "Live")
}})
(hUtil.get(_: String, _: String, _: util.Map[String, String])).expects(*, *, *).returns(resp)
(oec.kafkaClient _).expects().returns(kfClient)
(kfClient.send(_: String, _: String)).expects(*, *).returns(None)
val request = getQuestionRequest()
request.getRequest.put("question", new util.HashMap[String, AnyRef](){{
put("source", "https://dock.sunbirded.org/api/question/v1/read/do_11307822356267827219477")
put("source", "https://dock.sunbirded.org/api/question/v1/read/do_113486481122729984143")
put("metadata", new util.HashMap[String, AnyRef](){{
put("name", "Test Question")
put("description", "Test Question")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,14 @@ class QuestionSetActorTest extends BaseSpec with MockFactory {
resp.put("questionset", new util.HashMap[String, AnyRef](){{
put("framework", "NCF")
put("channel", "test")
put("status", "Live")
}})
(hUtil.get(_: String, _: String, _: util.Map[String, String])).expects(*, *, *).returns(resp)
(oec.kafkaClient _).expects().returns(kfClient)
(kfClient.send(_: String, _: String)).expects(*, *).returns(None)
val request = getQuestionSetRequest()
request.getRequest.put("questionset", new util.HashMap[String, AnyRef](){{
put("source", "https://dock.sunbirded.org/api/questionset/v1/read/do_11307822356267827219477")
put("source", "https://dock.sunbirded.org/api/questionset/v1/read/do_113486480153952256140")
put("metadata", new util.HashMap[String, AnyRef](){{
put("name", "Test QuestionSet")
put("description", "Test QuestionSet")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ class ContentActor @Inject() (implicit oec: OntologyEngineContext, ss: StorageSe
val propsToRemove = Platform.getStringList("import.remove_props", java.util.Arrays.asList("downloadUrl", "variants", "previewUrl", "streamingUrl", "itemSets")).asScala.toList
val topicName = Platform.config.getString("import.output_topic_name")
val reqLimit = Platform.getInteger("import.request_size_limit", 200)
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove)
val validSourceStatus = Platform.getStringList("import.valid_source_status", java.util.Arrays.asList()).asScala.toList
ImportConfig(topicName, reqLimit, requiredProps, validStages, propsToRemove, validSourceStatus)
}

def systemUpdate(request: Request): Future[Response] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.collection.mutable
import scala.concurrent.{ExecutionContext, Future}


case class ImportConfig(topicName: String, requestLimit: Integer, requiredProps: List[String], validContentStage: List[String], propsToRemove: List[String])
case class ImportConfig(topicName: String, requestLimit: Integer, requiredProps: List[String], validContentStage: List[String], propsToRemove: List[String], validSourceStatus: List[String])

class ImportManager(config: ImportConfig) {

Expand Down Expand Up @@ -58,6 +58,8 @@ class ImportManager(config: ImportConfig) {
val stage: String = obj.getOrDefault(ImportConstants.STAGE, "").toString
val reqMetadata: util.Map[String, AnyRef] = obj.getOrDefault(ImportConstants.METADATA, new util.HashMap[String, AnyRef]()).asInstanceOf[util.Map[String, AnyRef]]
val sourceMetadata: util.Map[String, AnyRef] = getMetadata(source, request.getContext.get("objectType").asInstanceOf[String].toLowerCase())
if(StringUtils.isNotBlank(source) && config.validSourceStatus.nonEmpty && MapUtils.isNotEmpty(sourceMetadata) && !config.validSourceStatus.contains(sourceMetadata.getOrDefault("status", "").asInstanceOf[String]))
throw new ClientException(ImportErrors.ERR_SOURCE_STATUS_VALIDATION, ImportErrors.ERR_SOURCE_STATUS_VALIDATION_MSG + config.validSourceStatus.asJava)
val finalMetadata: util.Map[String, AnyRef] = if (MapUtils.isNotEmpty(sourceMetadata)) {
sourceMetadata.putAll(reqMetadata)
sourceMetadata.put(ImportConstants.SOURCE, source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object ImportErrors {
val ERR_REQUIRED_PROPS_VALIDATION: String = "ERR_REQUIRED_PROPS_VALIDATION"
val BE_JOB_REQUEST_EXCEPTION: String = "BE_JOB_REQUEST_EXCEPTION"
val ERR_OBJECT_STAGE_VALIDATION: String = "ERR_OBJECT_STAGE_VALIDATION"
val ERR_SOURCE_STATUS_VALIDATION: String = "ERR_SOURCE_STATUS_VALIDATION"

//Error Messages
val ERR_INVALID_IMPORT_REQUEST_MSG: String = "Invalid Request! Please Provide Valid Request."
Expand All @@ -17,4 +18,5 @@ object ImportErrors {
val ERR_REQUIRED_PROPS_VALIDATION_MSG: String = "Validation Failed! Mandatory Properties Are "
val BE_JOB_REQUEST_EXCEPTION_MSG: String = "Kafka Event Is Not Generated Properly."
val ERR_OBJECT_STAGE_VALIDATION_MSG: String = "Object Stage Validation Failed! Valid Object Stages Are "
val ERR_SOURCE_STATUS_VALIDATION_MSG: String = "Source Object Status Not Qualified For Import Operation. Please Provide Valid Source With Status "
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ImportManagerTest extends AsyncFlatSpec with Matchers with AsyncMockFactor
val REQUIRED_PROPS = List("name", "code", "mimeType", "contentType", "artifactUrl", "framework")
val VALID_OBJECT_STAGE = List("create", "upload", "review", "publish")
val PROPS_TO_REMOVE = List("downloadUrl","variants","previewUrl","streamingUrl","itemSets")
lazy val importConfig = ImportConfig(AUTO_CREATE_TOPIC_NAME, REQUEST_LIMIT, REQUIRED_PROPS, VALID_OBJECT_STAGE, PROPS_TO_REMOVE)
lazy val importConfig = ImportConfig(AUTO_CREATE_TOPIC_NAME, REQUEST_LIMIT, REQUIRED_PROPS, VALID_OBJECT_STAGE, PROPS_TO_REMOVE, List())
lazy val importMgr = new ImportManager(importConfig)

"getRequest with list input" should "return request data as list with java types" in {
Expand Down
6 changes: 6 additions & 0 deletions schemas/question/1.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@
"items": {
"type": "object"
}
},
"origin": {
"type": "string"
},
"originData": {
"type": "object"
}
},
"additionalProperties": false
Expand Down
6 changes: 6 additions & 0 deletions schemas/questionset/1.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@
"outcomeDeclaration": {
"type": "object",
"description": "External Property"
},
"origin": {
"type": "string"
},
"originData": {
"type": "object"
}
},
"additionalProperties": false
Expand Down

0 comments on commit cbd1370

Please sign in to comment.