Skip to content

Commit ad82f67

Browse files
author
AlexMcGil
committed
support after bumping version. actually ktor
1 parent 1d8adb7 commit ad82f67

File tree

36 files changed

+153
-130
lines changed

36 files changed

+153
-130
lines changed

activators/caila/src/main/kotlin/com/justai/jaicf/activator/caila/client/CailaKtorClient.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import com.justai.jaicf.activator.caila.JSON
55
import com.justai.jaicf.activator.caila.dto.*
66
import com.justai.jaicf.helpers.logging.WithLogger
77
import io.ktor.client.*
8+
import io.ktor.client.call.body
89
import io.ktor.client.engine.*
910
import io.ktor.client.engine.cio.*
10-
import io.ktor.client.features.json.*
11-
import io.ktor.client.features.json.serializer.*
12-
import io.ktor.client.features.logging.*
11+
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
12+
import io.ktor.serialization.kotlinx.json.*
13+
import io.ktor.client.plugins.logging.DEFAULT
14+
import io.ktor.client.plugins.logging.LogLevel
15+
import io.ktor.client.plugins.logging.Logger
16+
import io.ktor.client.plugins.logging.Logging
1317
import io.ktor.client.request.*
1418
import io.ktor.http.*
1519
import kotlinx.coroutines.runBlocking
@@ -30,8 +34,8 @@ class CailaKtorClient(
3034
logger = Logger.DEFAULT
3135
level = logLevel
3236
}
33-
install(JsonFeature) {
34-
serializer = KotlinxSerializer()
37+
install(ContentNegotiation) {
38+
json(JSON)
3539
}
3640
}
3741

@@ -45,9 +49,9 @@ class CailaKtorClient(
4549
}
4650

4751
private suspend fun simpleInferenceAsync(query: String): CailaInferenceResultData? {
48-
val response = client.get<String>(inferenceUrl) {
52+
val response: String = client.get(inferenceUrl) {
4953
parameter("query", query)
50-
}
54+
}.body()
5155
logger.info(response)
5256
JSON.parseToJsonElement(response).jsonObject["intent"] ?: return null
5357
return JSON.decodeFromString(CailaInferenceResultData.serializer(), response)
@@ -63,10 +67,10 @@ class CailaKtorClient(
6367
}
6468

6569
private suspend fun entitiesLookupAsync(query: String, showAll: Boolean = true): CailaEntitiesLookupResults {
66-
val response = client.get<String>(entitiesLookupUrl) {
70+
val response: String = client.get(entitiesLookupUrl) {
6771
parameter("query", query)
6872
parameter("showAll", showAll)
69-
}
73+
}.body()
7074
logger.info(response)
7175
return JSON.decodeFromString(CailaEntitiesLookupResults.serializer(), response)
7276
}
@@ -91,10 +95,10 @@ class CailaKtorClient(
9195
}
9296

9397
private suspend fun analyzeAsync(requestData: CailaAnalyzeRequestData): CailaAnalyzeResponseData {
94-
val response = client.post<String>(analyzeUrl) {
98+
val response: String = client.post(analyzeUrl) {
9599
contentType(ContentType.Application.Json)
96-
body = requestData
97-
}
100+
setBody(requestData)
101+
}.body()
98102
logger.info(response)
99103
return JSON.decodeFromString(CailaAnalyzeResponseData.serializer(), response)
100104
}

activators/rasa/src/main/kotlin/com/justai/jaicf/activator/rasa/api/RasaApi.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ package com.justai.jaicf.activator.rasa.api
33
import com.justai.jaicf.helpers.http.toUrl
44
import com.justai.jaicf.helpers.logging.WithLogger
55
import io.ktor.client.HttpClient
6+
import io.ktor.client.call.body
67
import io.ktor.client.engine.HttpClientEngine
78
import io.ktor.client.engine.cio.CIO
8-
import io.ktor.client.features.json.JsonFeature
9-
import io.ktor.client.features.json.serializer.KotlinxSerializer
10-
import io.ktor.client.features.logging.*
9+
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
10+
import io.ktor.client.plugins.logging.LogLevel
11+
import io.ktor.client.plugins.logging.Logging
1112
import io.ktor.client.request.post
13+
import io.ktor.client.request.setBody
1214
import io.ktor.http.ContentType
1315
import io.ktor.http.contentType
16+
import io.ktor.serialization.kotlinx.json.json
1417
import kotlinx.coroutines.runBlocking
1518
import kotlinx.serialization.json.Json
1619

@@ -25,8 +28,8 @@ class RasaApi(
2528
private val client = HttpClient(httpClient) {
2629
expectSuccess = true
2730

28-
install(JsonFeature) {
29-
serializer = KotlinxSerializer(Json)
31+
install(ContentNegotiation) {
32+
json(Json)
3033
}
3134

3235
install(Logging) {
@@ -36,10 +39,10 @@ class RasaApi(
3639

3740
fun parseMessage(request: RasaParseMessageRequest): String? = runBlocking {
3841
try {
39-
client.post<String>("$uri/model/parse".toUrl()) {
42+
client.post("$uri/model/parse".toUrl()) {
4043
contentType(ContentType.Application.Json)
41-
body = request
42-
}
44+
setBody(request)
45+
}.body()
4346
} catch (e: Exception) {
4447
logger.error("Cannot parse $request", e)
4548
null

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,3 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope
22
import org.gradle.kotlin.dsl.project
33

44
fun DependencyHandlerScope.core() = "implementation"(project(":core"))
5-
fun DependencyHandlerScope.ktor(module: String): String = "io.ktor:$module" version { ktor }
6-
fun DependencyHandlerScope.jackson(): String = "com.fasterxml.jackson.module:jackson-module-kotlin" version { jackson }
7-
fun DependencyHandlerScope.slf4j(module: String): String = "org.slf4j:$module" version { slf4j }
8-
fun DependencyHandlerScope.`coroutines-core`(): String = "org.jetbrains.kotlinx:kotlinx-coroutines-core" version { coroutinesCore }
9-
fun DependencyHandlerScope.kotlinx(module: String): String = "org.jetbrains.kotlinx:$module"
10-
fun DependencyHandlerScope.`tomcat-servlet`(): String = "org.apache.tomcat:servlet-api" version { tomcatServletApi }
11-
fun DependencyHandlerScope.okHttp(module: String): String = "com.squareup.okhttp3:$module" version { okHttp }

buildSrc/src/main/kotlin/plugins/github/JaicfGithubReleasePlugin.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class JaicfGithubRelease(project: Project) : PluginAdapter(project) {
3434
override fun Project.afterEvaluated() {
3535
configure<GithubReleaseExtension> {
3636
setToken(githubToken)
37-
setOwner(githubOwner)
38-
setRepo(githubRepo)
39-
setTagName(githubTagName)
40-
setReleaseName(githubReleaseName)
41-
setOverwrite(true)
37+
owner.set(githubOwner)
38+
repo.set(githubRepo)
39+
tagName.set(githubTagName)
40+
releaseName.set(githubReleaseName)
41+
overwrite.set(true)
4242
}
4343
}
4444
}

buildSrc/src/main/kotlin/plugins/publish/CentralPublishPlugin.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private const val MAVEN_CENTRAL = "MavenCentral"
4343

4444
class CentralPublishPlugin : Plugin<Project> by apply<CentralPublish>()
4545

46-
@Suppress("DuplicatedCode", "UnstableApiUsage")
46+
@Suppress("DuplicatedCode")
4747
class CentralPublish(project: Project) : PluginAdapter(project) {
4848
private val properties by lazy { loadLocalProperties() }
4949
private val secKey by lazy { properties.getProperty(SIGNING_KEY) }
@@ -62,7 +62,7 @@ class CentralPublish(project: Project) : PluginAdapter(project) {
6262
val dokkaJavadoc = tasks.getByName("dokkaJavadoc", DokkaTask::class) {
6363
dokkaSourceSets {
6464
configureEach {
65-
outputDirectory.set(File("$buildDir/javadoc"))
65+
outputDirectory.set(File("${layout.buildDirectory.get()}/javadoc"))
6666
noStdlibLink.set(true)
6767
noJdkLink.set(true)
6868
}
@@ -139,7 +139,7 @@ private val Project.isMavenCentralPublication: Boolean
139139
private fun Project.extraProperty(name: String) =
140140
project.extra.properties[name] as? String ?: error("No $name defined")
141141

142-
@Suppress("UnstableApiUsage", "DuplicatedCode")
142+
@Suppress("DuplicatedCode")
143143
private fun MavenPublication.configurePom(
144144
pomName: String,
145145
pomDescription: String

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/JaicpConnector.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.justai.jaicf.channel.jaicp.http.ChatAdapterConnector
1010
import com.justai.jaicf.helpers.http.toUrl
1111
import com.justai.jaicf.helpers.logging.WithLogger
1212
import io.ktor.client.*
13+
import java.util.Locale
1314
import java.util.concurrent.Executor
1415
import java.util.concurrent.Executors
1516

@@ -106,10 +107,10 @@ abstract class JaicpConnector(
106107
abstract fun getRunningChannels(): Map<String, JaicpBotChannel>
107108

108109
protected fun getChannelProxyUrl(config: ChannelConfig) =
109-
"$proxyUrl/${config.channel}/${config.channelType.toLowerCase()}".toUrl()
110+
"$proxyUrl/${config.channel}/${config.channelType.lowercase(Locale.getDefault())}".toUrl()
110111

111112
private fun getApiProxyUrl(config: ChannelConfig) =
112-
"$apiProxyUrl/${config.channel}/${config.channelType.toLowerCase()}".toUrl()
113+
"$apiProxyUrl/${config.channel}/${config.channelType.lowercase(Locale.getDefault())}".toUrl()
113114

114115
protected open fun processJaicpRequest(request: JaicpBotRequest, channel: JaicpBotChannel): JaicpResponse =
115116
jaicpExecutor.executeSync(request, channel)

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/JaicpPollingConnector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.justai.jaicf.channel.jaicp.http.HttpClientFactory
77
import com.justai.jaicf.channel.jaicp.polling.Dispatcher
88
import com.justai.jaicf.helpers.logging.WithLogger
99
import io.ktor.client.*
10-
import io.ktor.client.features.logging.*
10+
import io.ktor.client.plugins.logging.LogLevel
1111
import java.util.concurrent.Executor
1212
import java.util.concurrent.Executors
1313

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/JaicpServer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import com.justai.jaicf.channel.jaicp.channels.JaicpNativeBotChannel
66
import com.justai.jaicf.channel.jaicp.endpoints.ktor.channelCheckEndpoint
77
import com.justai.jaicf.channel.jaicp.endpoints.ktor.healthCheckEndpoint
88
import com.justai.jaicf.channel.jaicp.endpoints.ktor.reloadConfigEndpoint
9-
import io.ktor.routing.*
109
import io.ktor.server.engine.*
1110
import io.ktor.server.netty.*
11+
import io.ktor.server.routing.routing
1212

1313

1414
/**

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/JaicpServlet.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import com.justai.jaicf.channel.http.HttpBotChannelServlet
55
import com.justai.jaicf.channel.jaicp.endpoints.CHANNEL_CHECK_URL
66
import com.justai.jaicf.channel.jaicp.endpoints.HEALTH_CHECK_URL
77
import com.justai.jaicf.channel.jaicp.endpoints.RELOAD_CONFIGS_URL
8-
import javax.servlet.http.HttpServletRequest
9-
import javax.servlet.http.HttpServletResponse
8+
import jakarta.servlet.http.HttpServletRequest
9+
import jakarta.servlet.http.HttpServletResponse
1010

1111
/**
1212
* HttpServlet implementation that processes POST through the [HttpBotChannel] and creates service endpoints for JAICP.
@@ -37,13 +37,13 @@ open class JaicpServlet(private val connector: JaicpWebhookConnector) : HttpBotC
3737
}
3838

3939
private fun HttpServletResponse.ok() {
40-
setStatus(HttpServletResponse.SC_OK)
40+
status = HttpServletResponse.SC_OK
4141
writer.write("OK")
4242
writer.flush()
4343
}
4444

4545
private fun HttpServletResponse.notFound(message: String) {
46-
setStatus(HttpServletResponse.SC_NOT_FOUND)
46+
status = HttpServletResponse.SC_NOT_FOUND
4747
writer.write(message)
4848
writer.flush()
4949
}

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/JaicpWebhookConnector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import com.justai.jaicf.channel.jaicp.endpoints.ktor.reloadConfigEndpoint
1717
import com.justai.jaicf.channel.jaicp.http.HttpClientFactory
1818
import com.justai.jaicf.helpers.logging.WithLogger
1919
import io.ktor.client.*
20-
import io.ktor.client.features.logging.*
20+
import io.ktor.client.plugins.logging.LogLevel
2121
import java.util.concurrent.Executor
2222
import java.util.concurrent.Executors
2323

0 commit comments

Comments
 (0)