Skip to content

Commit

Permalink
Merge pull request #115 from RADAR-base/release-0.5.1
Browse files Browse the repository at this point in the history
Release 0.5.1
  • Loading branch information
mpgxvii authored Jan 23, 2024
2 parents 7a30950 + 7d9711b commit d91b327
Show file tree
Hide file tree
Showing 16 changed files with 832 additions and 182 deletions.
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Suppress("ConstPropertyName", "MemberVisibilityCanBePrivate")
object Versions {
const val project = "0.5.0"
const val project = "0.5.1"

const val java = 11
const val kotlin = "1.9.10"
Expand All @@ -11,6 +11,8 @@ object Versions {
const val kafka = "$confluent-ce"
const val avro = "1.11.0"

const val managementPortal = "2.0.0"

// From image
const val jackson = "2.14.2"

Expand Down
2 changes: 2 additions & 0 deletions kafka-connect-fitbit-source/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ dependencies {
api("io.confluent:kafka-connect-avro-converter:${Versions.confluent}")
api("org.radarbase:radar-schemas-commons:${Versions.radarSchemas}")
implementation("org.radarbase:radar-commons-kotlin:${Versions.radarCommons}")
implementation("org.radarbase:oauth-client-util:${Versions.managementPortal}")

api("com.squareup.okhttp3:okhttp:${Versions.okhttp}")
implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.jackson}"))
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

package org.radarbase.connect.rest.fitbit;

import static io.ktor.http.URLUtilsKt.URLBuilder;
import static org.apache.kafka.common.config.ConfigDef.NO_DEFAULT_VALUE;

import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -30,9 +31,9 @@
import java.util.List;
import java.util.Map;

import io.ktor.http.URLParserException;
import io.ktor.http.Url;
import okhttp3.Headers;
import okhttp3.HttpUrl;

import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.common.config.ConfigDef.Importance;
import org.apache.kafka.common.config.ConfigDef.NonEmptyString;
Expand Down Expand Up @@ -331,6 +332,39 @@ public String toString() {
Width.SHORT,
FITBIT_INTRADAY_HEART_RATE_TOPIC_DISPLAY)

.define(FITBIT_INTRADAY_HEART_RATE_VARIABILITY_TOPIC_CONFIG,
Type.STRING,
FITBIT_INTRADAY_HEART_RATE_VARIABILITY_TOPIC_DEFAULT,
nonControlChar,
Importance.LOW,
FITBIT_INTRADAY_HEART_RATE_VARIABILITY_TOPIC_DOC,
group,
++orderInGroup,
Width.SHORT,
FITBIT_INTRADAY_HEART_RATE_VARIABILITY_TOPIC_DISPLAY)

.define(FITBIT_BREATHING_RATE_TOPIC_CONFIG,
Type.STRING,
FITBIT_BREATHING_RATE_TOPIC_DEFAULT,
nonControlChar,
Importance.LOW,
FITBIT_BREATHING_RATE_TOPIC_DOC,
group,
++orderInGroup,
Width.SHORT,
FITBIT_BREATHING_RATE_TOPIC_DISPLAY)

.define(FITBIT_SKIN_TEMPERATURE_TOPIC_CONFIG,
Type.STRING,
FITBIT_SKIN_TEMPERATURE_TOPIC_DEFAULT,
nonControlChar,
Importance.LOW,
FITBIT_SKIN_TEMPERATURE_TOPIC_DOC,
group,
++orderInGroup,
Width.SHORT,
FITBIT_SKIN_TEMPERATURE_TOPIC_DISPLAY)

.define(FITBIT_RESTING_HEART_RATE_TOPIC_CONFIG,
Type.STRING,
FITBIT_RESTING_HEART_RATE_TOPIC_DEFAULT,
Expand Down Expand Up @@ -497,18 +531,18 @@ public Path getFitbitUserCredentialsPath() {
return Paths.get(getString(FITBIT_USER_CREDENTIALS_DIR_CONFIG));
}

public Url getFitbitUserRepositoryUrl() {
public HttpUrl getFitbitUserRepositoryUrl() {
String urlString = getString(FITBIT_USER_REPOSITORY_URL_CONFIG).trim();
if (urlString.charAt(urlString.length() - 1) != '/') {
urlString += '/';
}
try {
return URLBuilder(urlString).build();
} catch (URLParserException ex) {
HttpUrl url = HttpUrl.parse(urlString);
if (url == null) {
throw new ConfigException(FITBIT_USER_REPOSITORY_URL_CONFIG,
getString(FITBIT_USER_REPOSITORY_URL_CONFIG),
"User repository URL " + urlString + " cannot be parsed as URL: " + ex);
"User repository URL " + urlString + " cannot be parsed as URL.");
}
return url;
}

public Headers getClientCredentials() {
Expand Down Expand Up @@ -551,17 +585,15 @@ public String getFitbitUserRepositoryClientSecret() {
return getPassword(FITBIT_USER_REPOSITORY_CLIENT_SECRET_CONFIG).value();
}

public Url getFitbitUserRepositoryTokenUrl() {
public URL getFitbitUserRepositoryTokenUrl() {
String value = getString(FITBIT_USER_REPOSITORY_TOKEN_URL_CONFIG);
if (value == null || value.isEmpty()) {
return null;
} else {
try {
return URLBuilder(value).build();
} catch (URLParserException ex) {
throw new ConfigException(FITBIT_USER_REPOSITORY_URL_CONFIG,
getString(FITBIT_USER_REPOSITORY_URL_CONFIG),
"Fitbit user repository token URL " + value + " cannot be parsed as URL: " + ex);
return new URL(getString(FITBIT_USER_REPOSITORY_TOKEN_URL_CONFIG));
} catch (MalformedURLException ex) {
throw new ConfigException("Fitbit user repository token URL is invalid.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import io.ktor.client.statement.request
import io.ktor.http.ContentType
import io.ktor.http.HttpMethod
import io.ktor.http.HttpStatusCode
import io.ktor.http.URLBuilder
import io.ktor.http.Url
import io.ktor.http.contentLength
import io.ktor.http.contentType
Expand Down Expand Up @@ -85,8 +86,8 @@ class ServiceUserRepository : UserRepository {
val containedUsers = config.fitbitUsers.toHashSet()

client = createClient(
baseUrl = config.fitbitUserRepositoryUrl,
tokenUrl = config.fitbitUserRepositoryTokenUrl,
baseUrl = URLBuilder(config.fitbitUserRepositoryUrl.toString()).build(),
tokenUrl = URLBuilder(config.fitbitUserRepositoryTokenUrl.toString()).build(),
clientId = config.fitbitUserRepositoryClientId,
clientSecret = config.fitbitUserRepositoryClientSecret,
)
Expand Down
Loading

0 comments on commit d91b327

Please sign in to comment.