From 66e85ddafac6898197805aa68e27582012bd1968 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Thu, 23 May 2024 21:33:22 +0200 Subject: [PATCH] Fix authentication issue --- java-sdk/build.gradle.kts | 6 ++++++ java-sdk/buildSrc/src/main/kotlin/Versions.kt | 2 +- java-sdk/radar-schemas-registration/build.gradle.kts | 4 ---- .../org/radarbase/schema/registration/SchemaRegistry.kt | 9 ++++++--- java-sdk/radar-schemas-tools/build.gradle.kts | 4 ---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/java-sdk/build.gradle.kts b/java-sdk/build.gradle.kts index bb1c88b9..c60a8c3b 100644 --- a/java-sdk/build.gradle.kts +++ b/java-sdk/build.gradle.kts @@ -23,6 +23,12 @@ val githubIssueUrl = "https://github.com/$githubRepoName/issues" subprojects { apply(plugin = "org.radarbase.radar-kotlin") + repositories{ + mavenCentral() + gradlePluginPortal() + maven(url = "https://jitpack.io") + } + radarKotlin { javaVersion.set(Versions.java) kotlinVersion.set(Versions.kotlin) diff --git a/java-sdk/buildSrc/src/main/kotlin/Versions.kt b/java-sdk/buildSrc/src/main/kotlin/Versions.kt index 500a6baa..3da93e40 100644 --- a/java-sdk/buildSrc/src/main/kotlin/Versions.kt +++ b/java-sdk/buildSrc/src/main/kotlin/Versions.kt @@ -5,7 +5,7 @@ object Versions { const val java = 17 const val avroGenerator = "1.9.1" - const val radarCommons = "1.1.2" + const val radarCommons = "1.1.3-SNAPSHOT" const val avro = "1.11.3" const val jackson = "2.16.1" const val argparse = "0.9.0" diff --git a/java-sdk/radar-schemas-registration/build.gradle.kts b/java-sdk/radar-schemas-registration/build.gradle.kts index e70db27b..8d398e6a 100644 --- a/java-sdk/radar-schemas-registration/build.gradle.kts +++ b/java-sdk/radar-schemas-registration/build.gradle.kts @@ -1,9 +1,5 @@ description = "RADAR Schemas specification and validation tools" -repositories { - maven(url = "https://jitpack.io") -} - dependencies { api(project(":radar-schemas-commons")) api(project(":radar-schemas-core")) diff --git a/java-sdk/radar-schemas-registration/src/main/java/org/radarbase/schema/registration/SchemaRegistry.kt b/java-sdk/radar-schemas-registration/src/main/java/org/radarbase/schema/registration/SchemaRegistry.kt index 3728f5e5..ede1c83a 100644 --- a/java-sdk/radar-schemas-registration/src/main/java/org/radarbase/schema/registration/SchemaRegistry.kt +++ b/java-sdk/radar-schemas-registration/src/main/java/org/radarbase/schema/registration/SchemaRegistry.kt @@ -15,6 +15,8 @@ */ package org.radarbase.schema.registration +import io.ktor.client.HttpClient +import io.ktor.client.engine.cio.CIO import io.ktor.client.plugins.auth.Auth import io.ktor.client.plugins.auth.providers.BasicAuthCredentials import io.ktor.client.plugins.auth.providers.basic @@ -44,6 +46,7 @@ import org.radarcns.kafka.ObservationKey import org.slf4j.LoggerFactory import java.io.IOException import java.net.MalformedURLException +import java.net.URI import java.time.Duration import kotlin.streams.asSequence import kotlin.time.Duration.Companion.seconds @@ -62,7 +65,7 @@ class SchemaRegistry( private val topicConfiguration: Map = emptyMap(), ) { private val schemaClient: SchemaRetriever = schemaRetriever(baseUrl) { - httpClient { + httpClient = HttpClient(CIO) { timeout(10.seconds) if (apiKey != null && apiSecret != null) { install(Auth) { @@ -94,7 +97,7 @@ class SchemaRegistry( .mapNotNull { try { httpClient.request> { - url("subjects") + url(URI(baseUrl).resolve("subjects").toString()) if (apiKey != null && apiSecret != null) { basicAuth(apiKey, apiSecret) } @@ -224,7 +227,7 @@ class SchemaRegistry( logger.info("Setting compatibility to {}", compatibility) return try { httpClient.requestEmpty { - url("config") + url(URI(baseUrl).resolve("config").toString()) method = HttpMethod.Put contentType(ContentType("application", "vnd.schemaregistry.v1+json")) setBody("{\"compatibility\": \"${compatibility.name}\"}") diff --git a/java-sdk/radar-schemas-tools/build.gradle.kts b/java-sdk/radar-schemas-tools/build.gradle.kts index e48fd8e1..03904060 100644 --- a/java-sdk/radar-schemas-tools/build.gradle.kts +++ b/java-sdk/radar-schemas-tools/build.gradle.kts @@ -1,9 +1,5 @@ description = "RADAR Schemas specification and validation tools." -repositories { - maven(url = "https://jitpack.io") -} - dependencies { implementation(project(":radar-schemas-registration")) implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.jackson}"))