diff --git a/build/content-service/Dockerfile b/build/content-service/Dockerfile
index d63a4ac84..68fd6ea7f 100644
--- a/build/content-service/Dockerfile
+++ b/build/content-service/Dockerfile
@@ -1,7 +1,6 @@
FROM --platform=linux/x86_64 eclipse-temurin:11.0.20.1_1-jdk-focal
RUN apt-get update \
- && apt-get install unzip \
- && apt-get install curl \
+ && apt-get install -y unzip curl \
&& adduser --uid 1001 --home /home/sunbird/ --disabled-login sunbird \
&& mkdir -p /home/sunbird \
&& chown -R sunbird:sunbird /home/sunbird
diff --git a/content-api/content-actors/pom.xml b/content-api/content-actors/pom.xml
index 980458409..45e1e286a 100644
--- a/content-api/content-actors/pom.xml
+++ b/content-api/content-actors/pom.xml
@@ -36,6 +36,16 @@
org.sunbird
mimetype-manager
1.0-SNAPSHOT
+
+
+ io.netty
+ netty-transport-native-epoll
+
+
+ io.netty
+ netty-transport-classes-epoll
+
+
jar
diff --git a/content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala b/content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala
index c3a9e509f..76fb73ebb 100644
--- a/content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala
+++ b/content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala
@@ -28,6 +28,8 @@ object DIALManager {
val DIAL_SEARCH_API_URL: String = Platform.config.getString("dial_service.api.base_url") + Platform.config.getString("dial_service.api.search")
val DIALCODE_GENERATE_URI: String = Platform.config.getString("dial_service.api.base_url") + Platform.config.getString("dial_service.api.generate")
+ val CLOUD_BASE_URL = Platform.getString("cloudstorage.read_base_path", "https://dev.knowlg.sunbird.org")
+ val DIAL_CONTAINER: String = Platform.getString("cloud_storage_dial_container", "dial")
val DIAL_API_AUTH_KEY: String = ContentConstants.BEARER + Platform.config.getString("dial_service.api.auth_key")
val PASSPORT_KEY: String = Platform.config.getString("graph.passport.key.base")
private val kfClient = new KafkaClient
@@ -319,7 +321,6 @@ object DIALManager {
val response = ResponseHandler.OK()
val updatedSuccessResponse = getDIALReserveUpdateResponse(response, updateDialCodes.size.asInstanceOf[Integer], contentId, updatedNode)
updatedSuccessResponse.getResult.put(DIALConstants.VERSION_KEY, updatedNode.getMetadata.get(DIALConstants.VERSION_KEY))
- println(" publisher ", request.getRequest)
val dialcodes: Map[String, AnyRef] =
updatedSuccessResponse.getResult
.get("reservedDialcodes")
@@ -340,24 +341,44 @@ object DIALManager {
* prepare qr data
* */
+
def createRequest(data: Map[String, AnyRef], channel: String, publisher: Option[String], rspObj: Response, request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext) = {
+ val qrCodeSpecString = request.getRequestString("qrcodespec", "") // Assuming this is a JSON string
+ val qrCodeSpec = JSON.parseFull(qrCodeSpecString) match {
+ case Some(map: Map[String, Any]) => map
+ case _ => Map.empty[String, Any]
+ }
+ val mergedConfig: Mmap[String, Any] = defaultConfig.++(qrCodeSpec)
+
val dialCodesMap = data.map { case (dialcode, index) =>
val fileName = s"$index" + "_" + s"$dialcode"
val dialData = Map(
- "data" -> s"https://dev.knowlg.sunbird.org/dial/$dialcode",
+ "data" -> s"$CLOUD_BASE_URL/$DIAL_CONTAINER/$dialcode",
"text" -> dialcode,
"id" -> fileName
)
+ val imageData = new util.HashMap[String, AnyRef]()
+ imageData.put("dialcode", dialcode)
+ imageData.put("config", mergedConfig.mapValues(_.toString).asJava)
+ imageData.put("status", Int.box(0))
+ imageData.put("identifier", fileName)
+ imageData.put("channel", channel)
+ imageData.put("publisher", publisher.getOrElse(""))
+ val imageReq = new Request()
+ val imageContext = new util.HashMap[String, Object]()
+ imageContext.putAll(request.getContext)
+ imageReq.setContext(imageContext)
+ imageReq.getContext.put("schemaName", "dialcode_image")
+ imageReq.getContext.put("objectType", "content")
+ imageReq.putAll(imageData)
+
+ oec.dialgraphService.saveExternalProps(imageReq)
+
dialData
}
- val qrCodeSpecString = request.getRequestString("qrcodespec", "") // Assuming this is a JSON string
- val qrCodeSpec = JSON.parseFull(qrCodeSpecString) match {
- case Some(map: Map[String, Any]) => map
- case _ => Map.empty[String, Any]
- }
- val mergedConfig: Mmap[String, Any] = defaultConfig.++(qrCodeSpec)
+
val processId = UUID.randomUUID
val dialcodes = dialCodesMap.map(_("text")).toList.asJava
rspObj.getResult.put(DIALConstants.PROCESS_ID, processId)
@@ -414,6 +435,7 @@ object DIALManager {
val topic: String = DIALTOPIC
val dialEvent = ScalaJsonUtils.serialize(event)
if (StringUtils.isBlank(dialEvent)) throw new ClientException("DIAL_REQUEST_EXCEPTION", "Event is not generated properly.")
+
kfClient.send(dialEvent, topic)
}
@@ -555,7 +577,6 @@ object DIALManager {
}})
}})
}}
-
val headerParam = new util.HashMap[String, String]{put(DIALConstants.X_CHANNEL_ID, channelId); put(DIALConstants.AUTHORIZATION, DIAL_API_AUTH_KEY);}
val generateResponse = oec.httpUtil.post(DIALCODE_GENERATE_URI, requestMap, headerParam)
if (generateResponse.getResponseCode == ResponseCode.OK || generateResponse.getResponseCode == ResponseCode.PARTIAL_SUCCESS) {
diff --git a/content-api/content-service/conf/application.conf b/content-api/content-service/conf/application.conf
index c4806d061..bcee84d2d 100644
--- a/content-api/content-service/conf/application.conf
+++ b/content-api/content-service/conf/application.conf
@@ -380,8 +380,8 @@ content.keyspace = "content_store"
content.metadata.visibility.parent=["textbookunit", "courseunit", "lessonplanunit", "event"]
# Cassandra Configuration
-//content.keyspace.name=content_store
-//content.keyspace.table=content_data
+//content.keyspace.name=dev_content_store
+//content.keyspace.table=dev_content_data
#TODO: Add Configuration for assessment. e.g: question_data
orchestrator.keyspace.name=question_store
orchestrator.keyspace.table=question_data
@@ -495,6 +495,7 @@ dialcode.object_type="DialCode"
#DIAL Code Reserve configuration
kafka.dial.request.topic="sunbirddev.qrimage.request"
dialcode.keyspace=dialcodes
+dialcode_image.keyspace=dialcodes
framework.max_term_creation_limit=200
@@ -762,6 +763,7 @@ cloud_storage_key=""
cloud_storage_secret=""
cloud_storage_container=""
cloud_storage_endpoint=""
+cloud_storage_dial_container=""
cloudstorage.metadata.replace_absolute_path=false
cloudstorage.relative_path_prefix= "CONTENT_STORAGE_BASE_PATH"
diff --git a/schemas/dialcode_image/1.0/config.json b/schemas/dialcode_image/1.0/config.json
new file mode 100644
index 000000000..f01868774
--- /dev/null
+++ b/schemas/dialcode_image/1.0/config.json
@@ -0,0 +1,47 @@
+{
+ "objectType": "dialcode_image",
+ "version": "disable",
+ "versionCheckMode": "OFF",
+ "external": {
+ "tableName": "dialcode_images",
+ "properties": {
+ "filename": {
+ "type": "string"
+ },
+ "created_on": {
+ "type": "string"
+ },
+ "dialcode": {
+ "type": "string"
+ },
+ "channel": {
+ "type": "string"
+ },
+ "publisher": {
+ "type": "string"
+ },
+ "config": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z0-9_]+$": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "status": {
+ "type": "integer",
+ "enum": [
+ 0,
+ 1,
+ 2
+ ]
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "primaryKey": ["filename"]
+ },
+ "schema_restrict_api": false
+}
diff --git a/schemas/dialcode_image/1.0/schema.json b/schemas/dialcode_image/1.0/schema.json
new file mode 100644
index 000000000..30269439a
--- /dev/null
+++ b/schemas/dialcode_image/1.0/schema.json
@@ -0,0 +1,53 @@
+{
+ "$id": "dialcode-image-schema.json",
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "Dialcode Image",
+ "type": "object",
+ "required": [
+ "filename",
+ "dialcode",
+ "channel",
+ "publisher",
+ "config",
+ "status",
+ "url"
+ ],
+ "properties": {
+ "filename": {
+ "type": "string"
+ },
+ "created_on": {
+ "type": "string",
+ "description": "Creation timestamp, likely in ISO 8601 format"
+ },
+ "dialcode": {
+ "type": "string"
+ },
+ "channel": {
+ "type": "string"
+ },
+ "publisher": {
+ "type": "string"
+ },
+ "config": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z0-9_]+$": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "status": {
+ "type": "integer",
+ "enum": [
+ 0,
+ 1,
+ 2
+ ]
+ },
+ "url": {
+ "type": "string"
+ }
+ }
+}