Skip to content

Commit

Permalink
Merge pull request #57 from RADAR-base/release-0.8.2
Browse files Browse the repository at this point in the history
Release 0.8.2
  • Loading branch information
blootsvoets authored Mar 14, 2022
2 parents 90126f8 + 519d6f0 commit 1cc4b1e
Show file tree
Hide file tree
Showing 27 changed files with 178 additions and 128 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Cache
uses: actions/cache@v2
with:
# Cache gradle directories
path: |
~/.gradle/caches
~/.gradle/wrapper
# Key for restoring and saving the cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Compile the code
- name: Compile code
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/publish_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ jobs:
id: is-snapshot
run: grep 'version = ".*-SNAPSHOT"' build.gradle.kts

- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Cache
uses: actions/cache@v2
with:
# Cache gradle directories
path: |
~/.gradle/caches
~/.gradle/wrapper
# Key for restoring and saving the cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Install gpg secret key
run: |
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,13 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Cache
uses: actions/cache@v2
with:
# Cache gradle directories
path: |
~/.gradle/caches
~/.gradle/wrapper
# Key for restoring and saving the cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Compile code
- name: Compile code
Expand All @@ -50,4 +42,4 @@ jobs:
env:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew -Psigning.gnupg.keyName=CBEF2CF0 -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} publish closeAndReleaseSonatypeStagingRepository
run: ./gradlew -Psigning.gnupg.keyName=${{ secrets.OSSRH_GPG_SECRET_KEY_ID }} -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} publish closeAndReleaseSonatypeStagingRepository
22 changes: 17 additions & 5 deletions .github/workflows/scheduled_snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ jobs:
REPORT_FILE: test.json
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/gradle-jdk11@master
- uses: snyk/actions/setup@master

- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Run Snyk
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: test
args: --json-file-output=${{ env.REPORT_FILE }}
run: >
snyk test
--configuration-matching='^runtimeClasspath$'
--configuration-matching='^compileClasspath$'
--json-file-output=${{ env.REPORT_FILE }}
--org=radar-base
--sub-project=radar-jersey
--sub-project=radar-jersey-hibernate
- name: Report new vulnerabilities
uses: thehyve/report-vulnerability@master
with:
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@ jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/gradle-jdk11@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
- uses: actions/checkout@master
- uses: snyk/actions/setup@master

- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run Snyk to check for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: >
snyk test
--configuration-matching='^runtimeClasspath$'
--configuration-matching='^compileClasspath$'
--fail-on=upgradable
--org=radar-base
--sub-project=radar-jersey
--sub-project=radar-jersey-hibernate
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,5 @@ Desktop.ini
######################
.eslintcache

# output directory
out/

# don't ignore jars in /libs
!libs/**/*.jar
5 changes: 5 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ ignore:
- '*':
reason: No path to create alias
expires: 2022-02-22T00:00:00.000Z
SNYK-JAVA-ORGJETBRAINSKOTLIN-2393744:
- '*':
reason: Not using Kotlin Files interface
expires: 2022-12-13T08:35:54.696Z
created: 2022-03-14T08:35:54.706Z
patch: {}
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}
dependencies {
api("org.radarbase:radar-jersey:0.8.1")
api("org.radarbase:radar-jersey:0.8.2")
}
```

Expand Down Expand Up @@ -52,7 +52,7 @@ class MyEnhancerFactory(private val config: MyConfigClass): EnhancerFactory {
override fun createEnhancers(): List<JerseyResourceEnhancer> {
val authConfig = AuthConfig(
managementPortal = MPConfig(
url = "http://...",
url = "https://...",
),
jwtResourceName = "res_MyResource",
)
Expand Down Expand Up @@ -114,7 +114,7 @@ fun main(args: Array<String>) {

Errors are handled by adding the `ConfigLoader.Enhancers.httpException` enhancer. This adds error handling for `org.radarbase.jersey.exception.HttpApplicationException` exceptions and its subclasses can be used and extended to serve detailed error messages with customized logging and HTML templating. They can be thrown from any resource.

To serve custom HTML error messages for error codes 400 to 599, add a Mustache template to the classpath in directory `org/radarbase/jersey/exception/mapper/<code>.html`. You can use special cases `4xx.html` and `5xx.html` as a catch-all template. The templates can use variables `status` for the HTTP status code, `code` for short-hand code for the specific error, and an optional `detailedMessage` for a human-readable message.
To serve custom HTML error messages for error codes 400 to 599, add a Mustache template to the classpath in directory `org/radarbase/jersey/exception/mapper/<code>.html`. You can use special cases `4xx.html` and `5xx.html` as a catch-all template. The templates can use variables `status` for the HTTP status code, `code` for shorthand code for the specific error, and an optional `detailedMessage` for a human-readable message.

Any other uncaught exceptions can be handled by adding the `ConfigLoader.Enhancers.generalException`.

Expand Down Expand Up @@ -143,8 +143,10 @@ If Logback is used instead, import the following dependencies to gradle:

```kotlin
dependencies {
runtimeOnly("ch.qos.logback:logback-classic:1.2.3")
implementation("org.slf4j:jul-to-slf4j:1.7.32")
val logbackVersion: String by project
runtimeOnly("ch.qos.logback:logback-classic:$logbackVersion")
val slf4jVersion: String by project
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
}
```

Expand Down
26 changes: 19 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ plugins {
`maven-publish`
signing
id("org.jetbrains.dokka") apply false
id("com.github.ben-manes.versions") version "0.41.0"
id("com.github.ben-manes.versions") version "0.42.0"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

allprojects {
group = "org.radarbase"
version = "0.8.1"
version = "0.8.2"
}

subprojects {
Expand Down Expand Up @@ -46,6 +46,18 @@ subprojects {
configurations["dokkaPlugin"](platform("com.fasterxml.jackson:jackson-bom:$jacksonVersion"))
configurations["dokkaRuntime"](platform("com.fasterxml.jackson:jackson-bom:$jacksonVersion"))

val jacksonKotlinModuleVersion: String by project
configurations["dokkaPlugin"]("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonKotlinModuleVersion") {
version {
strictly(jacksonKotlinModuleVersion)
}
}
configurations["dokkaRuntime"]("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonKotlinModuleVersion") {
version {
strictly(jacksonKotlinModuleVersion)
}
}

val jsoupVersion: String by project
configurations["dokkaPlugin"]("org.jsoup:jsoup:$jsoupVersion")
configurations["dokkaRuntime"]("org.jsoup:jsoup:$jsoupVersion")
Expand Down Expand Up @@ -78,8 +90,8 @@ subprojects {
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
apiVersion = "1.5"
languageVersion = "1.5"
apiVersion = "1.6"
languageVersion = "1.6"
}
}

Expand Down Expand Up @@ -128,7 +140,7 @@ subprojects {
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
Expand All @@ -152,7 +164,7 @@ subprojects {
}
organization {
name.set("RADAR-base")
url.set("http://radar-base.org")
url.set("https://radar-base.org")
}
scm {
connection.set("scm:git:$githubUrl")
Expand Down Expand Up @@ -208,5 +220,5 @@ nexusPublishing {
}

tasks.wrapper {
gradleVersion = "7.3.3"
gradleVersion = "7.4.1"
}
25 changes: 13 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@ kotlinVersion=1.6.10
dokkaVersion=1.6.10
jsoupVersion=1.14.3

jerseyVersion=3.0.3
jerseyVersion=3.0.4
grizzlyVersion=3.0.1
okhttpVersion=4.9.3
junitVersion=5.8.2
hamcrestVersion=2.2
mockitoKotlinVersion=4.0.0

hk2Version=3.0.2
managementPortalVersion=0.8.0
javaJwtVersion=3.18.2
managementPortalVersion=0.8.1
javaJwtVersion=3.18.3
jakartaWsRsVersion=3.0.0
jakartaAnnotationVersion=2.0.0
jacksonVersion=2.12.6
slf4jVersion=1.7.32
log4j2Version=2.17.1
jacksonVersion=2.13.2
jacksonKotlinModuleVersion=2.13.1
slf4jVersion=1.7.36
log4j2Version=2.17.2
jakartaXmlBindVersion=3.0.1
jakartaJaxbCoreVersion=3.0.2
jakartaJaxbRuntimeVersion=3.0.2
javaxValidationVersion=2.0.1.Final
jakartaActivation=2.0.1
swaggerVersion=2.1.12
jakartaActivation=2.1.0
swaggerVersion=2.1.13
mustacheVersion=0.9.10

hibernateVersion=5.6.3.Final
liquibaseVersion=4.6.2
postgresVersion=42.3.1
h2Version=2.0.206
hibernateVersion=5.6.5.Final
liquibaseVersion=4.8.0
postgresVersion=42.3.3
h2Version=2.1.210
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.radarbase.jersey.hibernate

import jakarta.inject.Provider
import jakarta.ws.rs.core.Context
import org.radarbase.jersey.hibernate.RadarEntityManagerFactory.Companion.connection
import org.radarbase.jersey.hibernate.config.DatabaseConfig
import org.radarbase.jersey.service.HealthService
import org.radarbase.jersey.service.HealthService.Metric
import org.radarbase.jersey.util.CacheConfig
import org.radarbase.jersey.util.CachedValue
import java.time.Duration
import jakarta.inject.Provider
import javax.persistence.Cache
import javax.persistence.EntityManager
import jakarta.ws.rs.core.Context

class DatabaseHealthMetrics(
@Context private val entityManager: Provider<EntityManager>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.radarbase.jersey.hibernate

import jakarta.ws.rs.core.Context
import org.glassfish.jersey.internal.inject.DisposableSupplier
import org.hibernate.engine.spi.SharedSessionContractImplementor
import org.hibernate.internal.SessionImpl
import org.slf4j.LoggerFactory
import jakarta.inject.Provider
import java.sql.Connection
import javax.persistence.EntityManager
import javax.persistence.EntityManagerFactory
import jakarta.ws.rs.core.Context

class RadarEntityManagerFactory(
@Context private val emf: EntityManagerFactory
Expand All @@ -28,6 +27,6 @@ class RadarEntityManagerFactory(
companion object {
private val logger = LoggerFactory.getLogger(RadarEntityManagerFactory::class.java)

fun EntityManager.connection() = unwrap(SessionImpl::class.java).connection()
fun EntityManager.connection(): Connection = unwrap(SessionImpl::class.java).connection()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RadarEntityManagerFactoryFactory(

/**
* Use an EntityManager for the duration of [method]. No reference of the passed
* [EntityManager] should be returned back, either directly or indirectly.
* [EntityManager] should be returned, either directly or indirectly.
*/
@Suppress("unused")
inline fun <T> EntityManagerFactory.useEntityManager(method: (EntityManager) -> T): T {
Expand Down
Loading

0 comments on commit 1cc4b1e

Please sign in to comment.