Skip to content

Commit

Permalink
Issue #SB-30224 merge: Merge pull request #843 from project-sunbird/r…
Browse files Browse the repository at this point in the history
…elease-4.9.0

Issue #SB-30224 merge: Merging release-4.9.0 to master
  • Loading branch information
AmiableAnil authored Jun 7, 2022
2 parents 39eac28 + a74aae9 commit 60b2795
Show file tree
Hide file tree
Showing 44 changed files with 1,382 additions and 95 deletions.
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

Repository for Knowledge Platform - 2.0

## Content-Service local setup
## Knowledge-platform local setup
This readme file contains the instruction to set up and run the content-service in local machine.

### System Requirements:

### Prerequisites:
* Neo4j
* Redis
* Cassandra
* Java 11

### Prepare folders for database data and logs

Expand Down Expand Up @@ -140,7 +141,10 @@ Example:
kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic test_topic
```

### Running content-service:
### 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 All @@ -149,7 +153,35 @@ mvn clean install -DskipTests
```shell
mvn play2:run
```
3. Using the below command we can verify whether the databases(neoj,redis & cassandra) connection is established or not. If all connections are good, health is shown as 'true' otherwise it will be 'false'.
3. Using the below command we can verify whether the databases(neo4j,redis & cassandra) connection is established or not. If all connections are good, health is shown as 'true' otherwise it will be 'false'.
```shell
curl http://localhost:9000/health
```

### Running Assets/Composite Search Service:
1. Go to the path: /knowledge-platform and run the below maven command to build the application.
```shell
mvn clean install -DskipTests
```
2. Go to the path: /knowledge-platform/search-api/search-service and run the below maven command to run the netty server.
```shell
mvn play2:run
```
3. Using the below command we can verify whether the databases(neo4j,redis & cassandra) connection is established or not. If all connections are good, health is shown as 'true' otherwise it will be 'false'.
```shell
curl http://localhost:9000/health
```

### Running Object Category Service:
1. Go to the path: /knowledge-platform and run the below maven command to build the application.
```shell
mvn clean install -DskipTests
```
2. Go to the path: /knowledge-platform/taxonomy-api/taxonomy-service and run the below maven command to run the netty server.
```shell
mvn play2:run
```
3. Using the below command we can verify whether the databases(neo4j,redis & cassandra) connection is established or not. If all connections are good, health is shown as 'true' otherwise it will be 'false'.
```shell
curl http://localhost:9000/health
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.sunbird.common.{DateUtils, Platform}
import org.sunbird.graph.OntologyEngineContext
import org.sunbird.graph.nodes.DataNode
import org.sunbird.graph.utils.NodeUtil
import org.sunbird.managers.AssessmentManager
import org.sunbird.managers.{AssessmentManager, CopyManager}
import org.sunbird.utils.RequestUtil

import java.util
Expand Down Expand Up @@ -36,6 +36,7 @@ class QuestionActor @Inject()(implicit oec: OntologyEngineContext) extends BaseA
case "systemUpdateQuestion" => systemUpdate(request)
case "listQuestions" => listQuestions(request)
case "rejectQuestion" => reject(request)
case "copyQuestion" => copy(request)
case _ => ERROR(request.getOperation)
}

Expand Down Expand Up @@ -85,7 +86,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 Expand Up @@ -127,4 +129,9 @@ class QuestionActor @Inject()(implicit oec: OntologyEngineContext) extends BaseA
AssessmentManager.updateNode(updateRequest)
})
}

def copy(request: Request): Future[Response] ={
RequestUtil.restrictProperties(request)
CopyManager.copy(request)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.sunbird.actors

import java.util

import javax.inject.Inject
import org.apache.commons.collections4.CollectionUtils
import org.sunbird.`object`.importer.{ImportConfig, ImportManager}
Expand All @@ -13,7 +12,7 @@ import org.sunbird.graph.OntologyEngineContext
import org.sunbird.graph.nodes.DataNode
import org.sunbird.graph.dac.model.Node
import org.sunbird.managers.HierarchyManager.hierarchyPrefix
import org.sunbird.managers.{AssessmentManager, HierarchyManager, UpdateHierarchyManager}
import org.sunbird.managers.{AssessmentManager, CopyManager, HierarchyManager, UpdateHierarchyManager}
import org.sunbird.utils.RequestUtil

import scala.collection.JavaConverters._
Expand All @@ -40,6 +39,7 @@ class QuestionSetActor @Inject()(implicit oec: OntologyEngineContext) extends Ba
case "rejectQuestionSet" => reject(request)
case "importQuestionSet" => importQuestionSet(request)
case "systemUpdateQuestionSet" => systemUpdate(request)
case "copyQuestionSet" => copy(request)
case _ => ERROR(request.getOperation)
}

Expand Down 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 All @@ -156,4 +157,8 @@ class QuestionSetActor @Inject()(implicit oec: OntologyEngineContext) extends Ba
}).map(node => ResponseHandler.OK.put("identifier", identifier).put("status", "success"))
}

def copy(request: Request): Future[Response] ={
RequestUtil.restrictProperties(request)
CopyManager.copy(request)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.sunbird.graph.nodes.DataNode
import org.sunbird.graph.utils.NodeUtil
import org.sunbird.telemetry.logger.TelemetryManager
import org.sunbird.telemetry.util.LogTelemetryEventUtil
import org.sunbird.utils.RequestUtil

import scala.concurrent.{ExecutionContext, Future}
import scala.collection.JavaConversions._
Expand All @@ -27,6 +28,7 @@ object AssessmentManager {
val visibility: String = request.getRequest.getOrDefault("visibility", "").asInstanceOf[String]
if (StringUtils.isNotBlank(visibility) && StringUtils.equalsIgnoreCase(visibility, "Parent"))
throw new ClientException(errCode, "Visibility cannot be Parent!")
RequestUtil.restrictProperties(request)
DataNode.create(request).map(node => {
val response = ResponseHandler.OK
response.putAll(Map("identifier" -> node.getIdentifier, "versionKey" -> node.getMetadata.get("versionKey")).asJava)
Expand Down Expand Up @@ -176,7 +178,6 @@ object AssessmentManager {
val keys = List("identifier", "children").asJava
hierarchy.keySet().retainAll(keys)
val children = hierarchy.getOrDefault("children", new util.ArrayList[java.util.Map[String, AnyRef]]).asInstanceOf[util.List[java.util.Map[String, AnyRef]]]
hierarchy.put("status", status)
val childrenToUpdate: List[String] = updateChildrenRecursive(children, status, List(), rootUserId)
(hierarchy, childrenToUpdate.asJava)
}
Expand All @@ -189,7 +190,6 @@ object AssessmentManager {
content.put("lastStatusChangedOn", DateUtils.formatCurrentDate)
content.put("prevStatus", content.getOrDefault("status", "Draft"))
content.put("status", status)
content.put("prevStatus", "Draft")
content.put("lastUpdatedOn", DateUtils.formatCurrentDate)
if(StringUtils.equalsAnyIgnoreCase(objectType, "Question")) content.get("identifier").asInstanceOf[String] :: idList else idList
} else idList
Expand Down
Loading

0 comments on commit 60b2795

Please sign in to comment.