diff --git a/docs/modules/ROOT/pages/devops/update.adoc b/docs/modules/ROOT/pages/devops/update.adoc index d4e37fdc..be454fd5 100644 --- a/docs/modules/ROOT/pages/devops/update.adoc +++ b/docs/modules/ROOT/pages/devops/update.adoc @@ -119,10 +119,20 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip $ ./gradlew wrapper --gradle-version 8.5 ---- -And Make sure intellij setup matches +.Make sure Java version in github setup workflow action is https://github.com/actions/setup-java?tab=readme-ov-file#supported-version-syntax[available] and matches your local dev setup: +---- +$ more ../.github/workflows/kotlin.yml + - name: Set up Eclipse Temurin JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 21 +---- + +Make sure Intellij config matches the Java and Gradle versions / paths used on the commandline -* IntelliJ -> Preferences -> Build Tools -> Gradle -> Specified Location -> use the 8.5 Path -* Make sure Gradle JVM is the same as File -> Project Structure -> Project SDK +* IntelliJ -> Preferences -> Build Tools -> Gradle -> Specified Location -> Use the 8.x.x Path (not the softlink) +* IntelliJ -> Project Structure -> Project SDK: Make sure Gradle JVM is the same as on OS Level === API Dockerfile diff --git a/kotlin/build.gradle.kts b/kotlin/build.gradle.kts index 0493f090..fafeeff0 100644 --- a/kotlin/build.gradle.kts +++ b/kotlin/build.gradle.kts @@ -45,13 +45,13 @@ plugins { // Plugin to determine which dependencies have updates, including updates for gradle itself. id("com.github.ben-manes.versions") version versionsVersion // Gradle plugin for running SonarQube analysis. https://plugins.gradle.org/plugin/org.sonarqube - id("org.sonarqube") version "4.3.1.3277" // "4.3.1.3277" // "4.0.0.2929" // new ones has issues + id("org.sonarqube") version "4.3.1.3277" // new ones may cause issues against sonarcloud.io, so test first kotlin("jvm") version kotlinVersion kotlin("plugin.spring") version kotlinVersion kotlin("plugin.jpa") version kotlinVersion // The no-arg compiler plugin generates an additional zero-argument constructor for classes with a specific annotation. - // (...) is synthetic so it can’t be directly called from Java or Kotlin, but it can be called using reflection. + // (...) is synthetic, so it can’t be directly called from Java or Kotlin, but it can be called using reflection. // https://kotlinlang.org/docs/no-arg-plugin.html // As with the kotlin-spring plugin wrapped on top of all-open, kotlin-jpa is wrapped on top of no-arg. // The plugin specifies @Entity, @Embeddable, and @MappedSuperclass no-arg annotations automatically. @@ -118,9 +118,7 @@ dependencies { val hypersistenceUtilsVersion: String by System.getProperties() implementation(libs.postgresql) implementation(libs.flyway.core) - - // implementation("org.flywaydb:flyway-core:$flywayVersion") // looks for classpath:db/migration - implementation("io.hypersistence:hypersistence-utils-hibernate-62:$hypersistenceUtilsVersion") // https://vladmihalcea.com/how-to-map-java-and-sql-arrays-with-jpa-and-hibernate/ + implementation(libs.hypersistence.utils.hibernate) // Jackson JSON Parsing Dependencies // For Gradle users, if you use the Spring Boot Gradle plugin you can omit the version number to adopt @@ -146,7 +144,7 @@ dependencies { val greenmailVersion: String by System.getProperties() // Mockito Inline required to mock final classes (https://stackoverflow.com/a/14292888/4292075) testImplementation("org.mockito:mockito-inline:$mockitoInlineVersion") - testImplementation( "com.github.tomakehurst:wiremock:$wiremockVersion") + testImplementation( libs.wiremock) testImplementation("com.tngtech.archunit:archunit-junit5-api:$archUnitVersion") testImplementation("com.icegreen:greenmail:$greenmailVersion") testRuntimeOnly("com.tngtech.archunit:archunit-junit5-engine:$archUnitVersion") @@ -157,7 +155,7 @@ tasks.test { useJUnitPlatform() finalizedBy("jacocoTestReport") doLast { - println("Code coverage report at: file://$buildDir/reports/jacoco/test/html/index.html") + println("Code coverage report at: file://${layout.buildDirectory}/reports/jacoco/test/html/index.html") } } @@ -178,10 +176,11 @@ tasks.bootJar { } jacoco { - toolVersion = "0.8.11" + // why get()? See https://github.com/gradle/gradle/issues/20392 + toolVersion = libs.versions.jacoco.get() } -// Configure which reports are generated by Jacococ coverage tool +// Configure which reports are generated by Jacoco coverage tool // https://kevcodez.de/posts/2018-08-19-test-coverage-in-kotlin-with-jacoco/ tasks.jacocoTestReport { reports { @@ -220,7 +219,7 @@ tasks.register("bootRunProd") { // https://github.com/ben-manes/gradle-versions-plugin#tasks // disallow release candidates as upgradable versions from stable versions fun isNonStable(version: String): Boolean { - val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } + val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) } val regex = "^[0-9,.v-]+(-r)?$".toRegex() val isStable = stableKeyword || regex.matches(version) return isStable.not() @@ -238,7 +237,7 @@ sonarqube { property("sonar.projectName", "Angkor API") property("sonar.projectDescription", "API for Angular Kotlin Rest App") property("sonar.coverage.jacoco.xmlReportPaths","build/reports/jacoco/test/jacocoTestReport.xml") - // domain objects are mostly data classes which don't support inheritance really well, so we exlude + // domain objects are mostly data classes which don't support inheritance really well, so we exclude // them from duplication detection (cf. https://docs.sonarqube.org/7.4/analysis/analysis-parameters/) property("sonar.cpd.exclusions","src/main/kotlin/net/timafe/angkor/domain/**/*") } diff --git a/kotlin/gradle.properties b/kotlin/gradle.properties index f3eabea7..b57e9f4e 100644 --- a/kotlin/gradle.properties +++ b/kotlin/gradle.properties @@ -16,7 +16,7 @@ systemProp.romeVersion=1.19.0 #systemProp.springBootVersion=3.1.3 systemProp.unirestVersion=1.4.9 systemProp.versionsVersion=0.47.0 -systemProp.wiremockVersion=3.0.0-beta-10 +#systemProp.wiremockVersion=3.0.0-beta-10 # enable to support incremental processing # https://medium.com/@daniel_novak/making-incremental-kapt-work-speed-up-your-kotlin-projects-539db1a771cf diff --git a/kotlin/gradle/libs.versions.toml b/kotlin/gradle/libs.versions.toml index ff9f9bfc..132987b4 100644 --- a/kotlin/gradle/libs.versions.toml +++ b/kotlin/gradle/libs.versions.toml @@ -9,9 +9,9 @@ # dependencies we use in our build and tests. Next we must add a section [plugins] where we can define our plugin # dependencies. We can use the full power of the version catalog here, the only thing we need to remember is to use the # id property of we use the longer notation option. With the shorthand notation we can simply define a string value -# with the id of the plugin, a colon (:) and the version." +# with the id of the plugin, a colon : and the version." # -# You can use separators such as -, _, . that will be normalized +# You can use separators such as -, _, . that will be normalized # by Gradle to . in the catalog and allow you to create subsections. # File: gradle/libs.versions.toml @@ -23,25 +23,38 @@ # 10.4.1 newest causes java.lang.NoSuchMethodError at FlywayAutoConfiguration.java:254 flyway = "9.22.3" postgresql="42.7.1" +jacoco = "0.8.11" +wiremock = "3.0.1" + +# implementation("io.hypersistence:hypersistence-utils-hibernate-62:$hypersistenceUtilsVersion") // https://vladmihalcea.com/how-to-map-java-and-sql-arrays-with-jpa-and-hibernate/ # plugins Were added in Gradle 7.2, are used (obviouly) to define plugins. [plugins] # We can use shorthand notation with the plugin id and version. # use like "alias(libs.plugins.spring.boot)" in build.gradle.kts plugins section -spring-boot = "org.springframework.boot:3.1.5" +spring-boot = "org.springframework.boot:3.2.0" # 3.1.5 # We can use the longer notation option where we set # the id and version for the plugin. -spring-dep-mgmt = { id = "io.spring.dependency-management", version = "1.1.3" } +spring-dep-mgmt = { id = "io.spring.dependency-management", version = "1.1.4" } # Here we use the longer notation and version.ref to reference # the version defined in the [versions] section. flyway-plugin = { id = "org.flywaydb.flyway", version.ref = "flyway" } # Define the libraries that will be later accessed in our Gradle files. -# use like "implementation(libs.flyway.core)" in build.gradle.kts dependencies section +# use like "implementation(libs.flyway.core)" in build.gradle.kts dependencies section +# replace hyphens in name with dots: flyway-core -> flyway.core [libraries] flyway-core = { module = "org.flywaydb:flyway-core", version.ref = "flyway" } postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" } +# make sure to align module AND version with the hibernate version used by Spring Boot (Releases Notes) +# Example: Spring Boot 3.2 uses Hibernate 6.3, so the module is hypersistence-utils-hibernate-63 +hypersistence-utils-hibernate = { module = "io.hypersistence:hypersistence-utils-hibernate-63", version="3.7.0"} + +# testImplementation +# testImplementation( "com.github.tomakehurst:wiremock:$wiremockVersion") +# Use standalone b/c of issue "jetty 12 / springboot 3.2 #2395" https://github.com/wiremock/wiremock/issues/2395 +wiremock = { module= "com.github.tomakehurst:wiremock-standalone", version="3.0.1"} # 3.0.0-beta-10 # bundles? maybe coming soon. maybe not diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/Application.kt b/kotlin/src/main/kotlin/net/timafe/angkor/Application.kt index 6dc96dfc..c4ceab5a 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/Application.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/Application.kt @@ -1,5 +1,7 @@ package net.timafe.angkor +import jakarta.annotation.PostConstruct +import jakarta.annotation.PreDestroy import net.timafe.angkor.config.AppProperties import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.Event @@ -19,8 +21,6 @@ import org.springframework.core.env.Environment import org.springframework.data.jpa.repository.config.EnableJpaAuditing import org.springframework.data.jpa.repository.config.EnableJpaRepositories import java.util.* -import jakarta.annotation.PostConstruct -import jakarta.annotation.PreDestroy @SpringBootApplication @EnableJpaRepositories diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/AbstractBaseEntity.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/AbstractBaseEntity.kt index 3242c57e..eb7b29ce 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/AbstractBaseEntity.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/AbstractBaseEntity.kt @@ -1,8 +1,8 @@ package net.timafe.angkor.domain -import java.util.* import jakarta.persistence.Id import jakarta.persistence.MappedSuperclass +import java.util.* /** * New superclass for all Entities that use pre-generated UUIDs diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Area.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Area.kt index 6fe6345e..b1d88674 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Area.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Area.kt @@ -1,12 +1,15 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +// with 6.3 we can use org.hibernate.dialect.PostgreSQLEnumJdbcType import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType -import net.timafe.angkor.domain.enums.AreaLevel +import jakarta.persistence.* +import net.timafe.angkor.domain.enums.Area_Level import net.timafe.angkor.domain.interfaces.Mappable +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type +import org.hibernate.dialect.PostgreSQLEnumJdbcType import java.util.* -import jakarta.persistence.* /** * Area code (Managed Domain Entity) @@ -23,10 +26,12 @@ data class Area( var name: String, var parentCode: String, + // As of 6.3: @Type(PostgreSQLEnumType::class) -> @JdbcTypeCode(SqlTypes.NAMED_ENUM) + // https://github.com/vladmihalcea/hypersistence-utils/issues/657#issuecomment-1824018550 @Enumerated(EnumType.STRING) @Column(columnDefinition = "level") - @Type(PostgreSQLEnumType::class) - var level: AreaLevel = AreaLevel.COUNTRY, + @JdbcType(PostgreSQLEnumJdbcType::class) + var level: Area_Level = Area_Level.COUNTRY, /** * Adjectival representation of the name, e.g. France => French @@ -38,7 +43,7 @@ data class Area( name = "coordinates", columnDefinition = "double precision[]" ) - override var coordinates: List = listOf(), /* lon, lat */ + override var coordinates: List = listOf(),/* lon, lat */ ) : Mappable { diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Dish.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Dish.kt index 749395a0..d36ac888 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Dish.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Dish.kt @@ -1,13 +1,16 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +import jakarta.persistence.* import net.timafe.angkor.config.annotations.EntityTypeInfo import net.timafe.angkor.domain.enums.AuthScope import net.timafe.angkor.domain.interfaces.EventSupport import net.timafe.angkor.domain.interfaces.Taggable import net.timafe.angkor.service.EntityEventListener +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type +import org.hibernate.dialect.PostgreSQLEnumJdbcType import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -15,7 +18,6 @@ import org.springframework.data.annotation.LastModifiedDate import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.time.ZonedDateTime import java.util.* -import jakarta.persistence.* /** * Local Dish (Managed Domain Entity) @@ -51,7 +53,8 @@ data class Dish( @Enumerated(EnumType.STRING) @Column(columnDefinition = "scope") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) override var authScope: AuthScope = AuthScope.PUBLIC, @Type(ListArrayType::class) diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Event.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Event.kt index 99bf7b3a..446ce479 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Event.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Event.kt @@ -1,12 +1,12 @@ package net.timafe.angkor.domain +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Id import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import java.time.ZonedDateTime import java.util.* -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id @Entity data class Event( diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Link.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Link.kt index 75877f5c..b649e6e2 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Link.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Link.kt @@ -1,23 +1,25 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonInclude import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType import io.hypersistence.utils.hibernate.type.basic.PostgreSQLHStoreType +import jakarta.persistence.* import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.enums.AuthScope import net.timafe.angkor.domain.enums.EntityType -import net.timafe.angkor.domain.enums.LinkMediaType +import net.timafe.angkor.domain.enums.Media_Type import net.timafe.angkor.domain.interfaces.AuthScoped import net.timafe.angkor.domain.interfaces.Mappable +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type +import org.hibernate.dialect.PostgreSQLEnumJdbcType import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.time.ZonedDateTime import java.util.* -import jakarta.persistence.* @Entity @EntityListeners(AuditingEntityListener::class) @@ -35,14 +37,16 @@ data class Link( @Enumerated(EnumType.STRING) @Column(columnDefinition = "media_type") - @Type(PostgreSQLEnumType::class) - var mediaType: LinkMediaType = LinkMediaType.DEFAULT, + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) + var mediaType: Media_Type = Media_Type.DEFAULT, var entityId: UUID? = null, @Enumerated(EnumType.STRING) @Column(columnDefinition = "entity_type") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) var entityType: EntityType? = null, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Constants.JACKSON_DATE_TIME_FORMAT) @@ -55,7 +59,8 @@ data class Link( @Enumerated(EnumType.STRING) @Column(columnDefinition = "scope") // @Type(type = "pgsql_enum") -> @Type(PostgreSQLEnumType::class) - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) override var authScope: AuthScope = AuthScope.PUBLIC, // @Type(type = "list-array") -> @Type(ListArrayType::class) diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/LocatableEntity.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/LocatableEntity.kt index d3452af1..159ab3b5 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/LocatableEntity.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/LocatableEntity.kt @@ -1,11 +1,14 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +// import org.hibernate.annotations.TypeDef +// import org.hibernate.annotations.TypeDefs import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonProperty -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLHStoreType import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +import io.hypersistence.utils.hibernate.type.basic.PostgreSQLHStoreType +import jakarta.persistence.* import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.enums.AuthScope import net.timafe.angkor.domain.enums.EntityType @@ -14,9 +17,9 @@ import net.timafe.angkor.domain.interfaces.EventSupport import net.timafe.angkor.domain.interfaces.Mappable import net.timafe.angkor.domain.interfaces.Taggable import net.timafe.angkor.service.EntityEventListener +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type -// import org.hibernate.annotations.TypeDef -// import org.hibernate.annotations.TypeDefs +import org.hibernate.dialect.PostgreSQLEnumJdbcType import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -25,7 +28,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.io.Serializable import java.time.ZonedDateTime import java.util.* -import jakarta.persistence.* /** * Base class for anything that qualifies as a [LocatableEntity] @@ -81,7 +83,8 @@ open class LocatableEntity( @Enumerated(EnumType.STRING) @Column(columnDefinition = "scope") // https://vladmihalcea.com/the-best-way-to-map-an-enum-type-with-jpa-and-hibernate/ - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) override var authScope: AuthScope = AuthScope.PUBLIC, /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Note.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Note.kt index 49e734b2..d9c5d7a4 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Note.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Note.kt @@ -1,8 +1,9 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType import com.fasterxml.jackson.annotation.JsonFormat import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +import jakarta.persistence.* import net.timafe.angkor.config.Constants import net.timafe.angkor.config.annotations.EntityTypeInfo import net.timafe.angkor.domain.enums.AuthScope @@ -10,7 +11,9 @@ import net.timafe.angkor.domain.enums.NoteStatus import net.timafe.angkor.domain.interfaces.EventSupport import net.timafe.angkor.domain.interfaces.Taggable import net.timafe.angkor.service.EntityEventListener +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type +import org.hibernate.dialect.PostgreSQLEnumJdbcType import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -19,7 +22,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.time.LocalDate import java.time.ZonedDateTime import java.util.* -import jakarta.persistence.* @Entity @EntityListeners(AuditingEntityListener::class, EntityEventListener::class) @@ -53,7 +55,8 @@ data class Note( @Enumerated(EnumType.STRING) @Column(columnDefinition = "status") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) var status: NoteStatus = NoteStatus.OPEN, @Type(ListArrayType::class) @@ -65,7 +68,8 @@ data class Note( @Enumerated(EnumType.STRING) @Column(columnDefinition = "scope") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) override var authScope: AuthScope = AuthScope.PUBLIC ) : Taggable, EventSupport { diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Photo.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Photo.kt index 69c280b4..3fd49cca 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Photo.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Photo.kt @@ -1,8 +1,8 @@ package net.timafe.angkor.domain -import net.timafe.angkor.config.annotations.EntityTypeInfo import jakarta.persistence.DiscriminatorValue import jakarta.persistence.Entity +import net.timafe.angkor.config.annotations.EntityTypeInfo /** * Entity that represents a Photo diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Place.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Place.kt index a1aaa0e6..f7fc0527 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Place.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Place.kt @@ -1,11 +1,12 @@ package net.timafe.angkor.domain -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +import jakarta.persistence.* import net.timafe.angkor.config.annotations.EntityTypeInfo import net.timafe.angkor.domain.enums.LocationType -import org.hibernate.annotations.Type +import org.hibernate.annotations.JdbcType +import org.hibernate.dialect.PostgreSQLEnumJdbcType import java.time.LocalDate -import jakarta.persistence.* /** * Place 2 Go (Managed Domain Entity) @@ -22,7 +23,8 @@ class Place( @Enumerated(EnumType.STRING) @Column(name = "ltype") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) var locationType: LocationType = LocationType.PLACE, ) : LocatableEntity() diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Post.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Post.kt index b515326a..dd770e6d 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Post.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Post.kt @@ -1,8 +1,8 @@ package net.timafe.angkor.domain -import net.timafe.angkor.config.annotations.EntityTypeInfo import jakarta.persistence.DiscriminatorValue import jakarta.persistence.Entity +import net.timafe.angkor.config.annotations.EntityTypeInfo /** * Entity that represents a Blog Post, diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tag.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tag.kt index 6dec1c97..1332ca6e 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tag.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tag.kt @@ -1,13 +1,15 @@ package net.timafe.angkor.domain +// import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType import com.fasterxml.jackson.annotation.JsonInclude import io.hypersistence.utils.hibernate.type.array.ListArrayType -import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType +import jakarta.persistence.* import net.timafe.angkor.domain.enums.EntityType +import org.hibernate.annotations.JdbcType import org.hibernate.annotations.Type +import org.hibernate.dialect.PostgreSQLEnumJdbcType import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.util.* -import jakarta.persistence.* @Entity @EntityListeners(AuditingEntityListener::class) @@ -22,7 +24,8 @@ data class Tag( @Enumerated(EnumType.STRING) @Column(columnDefinition = "entity_type") - @Type(PostgreSQLEnumType::class) + // @Type(PostgreSQLEnumType::class) + @JdbcType(PostgreSQLEnumJdbcType::class) var entityType: EntityType? = null, @Type(ListArrayType::class) diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tour.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tour.kt index 10577319..9b5c1207 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tour.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Tour.kt @@ -1,9 +1,9 @@ package net.timafe.angkor.domain +import jakarta.persistence.DiscriminatorValue import jakarta.persistence.Entity import net.timafe.angkor.config.annotations.EntityTypeInfo import java.time.LocalDate -import jakarta.persistence.DiscriminatorValue /** * Entity that represents a Tour, diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/User.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/User.kt index 42f6d06f..07ce8ead 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/User.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/User.kt @@ -2,10 +2,6 @@ package net.timafe.angkor.domain import com.fasterxml.jackson.annotation.JsonFormat import io.hypersistence.utils.hibernate.type.array.ListArrayType -import net.timafe.angkor.config.Constants -import org.hibernate.annotations.Type -import java.time.ZonedDateTime -import java.util.* import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Id @@ -13,6 +9,10 @@ import jakarta.persistence.Table import jakarta.validation.constraints.Email import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Size +import net.timafe.angkor.config.Constants +import org.hibernate.annotations.Type +import java.time.ZonedDateTime +import java.util.* @Entity @Table(name = "app_user") diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Video.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Video.kt index 2a969573..d47c107c 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/Video.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/Video.kt @@ -1,9 +1,9 @@ package net.timafe.angkor.domain -import net.timafe.angkor.config.annotations.EntityTypeInfo import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue import jakarta.persistence.Entity +import net.timafe.angkor.config.annotations.EntityTypeInfo /** * Entity that represents a Video diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/AreaLevel.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/AreaLevel.kt deleted file mode 100644 index b344c677..00000000 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/AreaLevel.kt +++ /dev/null @@ -1,9 +0,0 @@ -package net.timafe.angkor.domain.enums - -enum class AreaLevel { - PLANET, - CONTINENT, - CONT_SECT, - COUNTRY, - REGION -} diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Area_Level.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Area_Level.kt new file mode 100644 index 00000000..66878f82 --- /dev/null +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Area_Level.kt @@ -0,0 +1,11 @@ +package net.timafe.angkor.domain.enums + +// Use underscore Area_Level since as opposed to the classic PostgreSQLEnumType, the bew +// Hibernate build-in PostgreSQLEnumJdbcType does not translate AreaLevel (kotlin) to area_level (postgres) +enum class Area_Level { + PLANET, + CONTINENT, + CONT_SECT, + COUNTRY, + REGION +} diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/LinkMediaType.kt b/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Media_Type.kt similarity index 95% rename from kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/LinkMediaType.kt rename to kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Media_Type.kt index 68a539e3..4f1687d3 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/LinkMediaType.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/domain/enums/Media_Type.kt @@ -4,7 +4,7 @@ package net.timafe.angkor.domain.enums * CREATE TYPE media_type AS ENUM ( 'VIDEO','AUDIO','IMAGE','PDF','DEFAULT'); * Source for icon keys: https://fonts.google.com/icons?selected=Material+Icons */ -enum class LinkMediaType( +enum class Media_Type( val label: String, val icon: String? ) { diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/repo/AreaRepository.kt b/kotlin/src/main/kotlin/net/timafe/angkor/repo/AreaRepository.kt index 593d4993..01cf18c8 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/repo/AreaRepository.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/repo/AreaRepository.kt @@ -1,7 +1,7 @@ package net.timafe.angkor.repo import net.timafe.angkor.domain.Area -import net.timafe.angkor.domain.enums.AreaLevel +import net.timafe.angkor.domain.enums.Area_Level import org.springframework.cache.annotation.Cacheable import org.springframework.data.domain.Sort import org.springframework.data.jpa.repository.Query @@ -21,15 +21,17 @@ interface AreaRepository : CrudRepository { fun findAll(sort: Sort): List - fun findByLevelOrderByName(level: AreaLevel): List + fun findByLevelOrderByName(level: Area_Level): List // This is how you use enums in none native JPA queries @Cacheable(COUNTRIES_AND_REGIONS_CACHE) - @Query( """ + @Query( + """ SELECT a FROM Area a - WHERE a.level IN(net.timafe.angkor.domain.enums.AreaLevel.COUNTRY,net.timafe.angkor.domain.enums.AreaLevel.REGION) + WHERE a.level IN(net.timafe.angkor.domain.enums.Area_Level.COUNTRY,net.timafe.angkor.domain.enums.Area_Level.REGION) ORDER BY a.name - """) + """ + ) fun findAllCountriesAndRegions(): List } diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/repo/LinkRepository.kt b/kotlin/src/main/kotlin/net/timafe/angkor/repo/LinkRepository.kt index 1e47977d..1e468b6d 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/repo/LinkRepository.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/repo/LinkRepository.kt @@ -1,7 +1,7 @@ package net.timafe.angkor.repo import net.timafe.angkor.domain.Link -import net.timafe.angkor.domain.enums.LinkMediaType +import net.timafe.angkor.domain.enums.Media_Type import org.springframework.cache.annotation.Cacheable import org.springframework.data.jpa.repository.Query import org.springframework.data.repository.CrudRepository @@ -20,13 +20,13 @@ interface LinkRepository : CrudRepository { /* Feeds */ @Cacheable(FEED_CACHE) - @Query("SELECT l FROM Link l where l.mediaType = net.timafe.angkor.domain.enums.LinkMediaType.FEED ORDER BY l.createdAt") + @Query("SELECT l FROM Link l where l.mediaType = net.timafe.angkor.domain.enums.Media_Type.FEED ORDER BY l.createdAt") fun findAllFeeds(): List - @Query("SELECT COUNT(l) FROM Link l where l.mediaType = net.timafe.angkor.domain.enums.LinkMediaType.FEED") + @Query("SELECT COUNT(l) FROM Link l where l.mediaType = net.timafe.angkor.domain.enums.Media_Type.FEED") fun feedCount(): Long // todo add index on name, append OrderByName - fun findByMediaType(mediaType: LinkMediaType): List + fun findByMediaType(mediaType: Media_Type): List } diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/repo/VideoRepository.kt b/kotlin/src/main/kotlin/net/timafe/angkor/repo/VideoRepository.kt index bff0d82d..5b370e5b 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/repo/VideoRepository.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/repo/VideoRepository.kt @@ -1,6 +1,5 @@ package net.timafe.angkor.repo -import net.timafe.angkor.domain.Tour import net.timafe.angkor.domain.Video import net.timafe.angkor.domain.enums.AuthScope import net.timafe.angkor.repo.interfaces.AuthScopeSupport diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/DishService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/DishService.kt index d41625e2..b3d79ecd 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/DishService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/DishService.kt @@ -4,7 +4,7 @@ import net.timafe.angkor.domain.Area import net.timafe.angkor.domain.Dish import net.timafe.angkor.domain.Event import net.timafe.angkor.domain.dto.DishSummary -import net.timafe.angkor.domain.enums.AreaLevel +import net.timafe.angkor.domain.enums.Area_Level import net.timafe.angkor.domain.enums.EntityType import net.timafe.angkor.domain.enums.EventTopic import net.timafe.angkor.repo.DishRepository @@ -68,7 +68,7 @@ class DishService( */ private fun getArea(areaCode: String): Area? { val area = areaService.countriesAndRegions().find { it.code == areaCode } - return if (area?.level == AreaLevel.REGION) { + return if (area?.level == Area_Level.REGION) { // resolve to parent areaService.countriesAndRegions().find { it.code == area.parentCode } } else { diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/EntityEventListener.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/EntityEventListener.kt index 89533da9..9cedb5c2 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/EntityEventListener.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/EntityEventListener.kt @@ -2,6 +2,9 @@ package net.timafe.angkor.service +import jakarta.persistence.PostPersist +import jakarta.persistence.PostRemove +import jakarta.persistence.PostUpdate import net.timafe.angkor.config.annotations.EntityTypeInfo import net.timafe.angkor.domain.Event import net.timafe.angkor.domain.enums.EntityType @@ -12,9 +15,6 @@ import net.timafe.angkor.security.SecurityAuditorAware import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext -import jakarta.persistence.PostPersist -import jakarta.persistence.PostRemove -import jakarta.persistence.PostUpdate /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/EventService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/EventService.kt index 1fcded19..9f4bb4b7 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/EventService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/EventService.kt @@ -3,6 +3,7 @@ package net.timafe.angkor.service import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature +import jakarta.annotation.PostConstruct import net.timafe.angkor.config.AppProperties import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.Event @@ -27,7 +28,6 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.time.Duration import java.util.* -import jakarta.annotation.PostConstruct /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/GeoService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/GeoService.kt index 7e89092e..f059a878 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/GeoService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/GeoService.kt @@ -5,6 +5,7 @@ import com.mashape.unirest.http.JsonNode import com.mashape.unirest.http.Unirest import io.github.bucket4j.Bandwidth import io.github.bucket4j.Bucket +import jakarta.annotation.PostConstruct import net.timafe.angkor.domain.dto.Coordinates import net.timafe.angkor.domain.dto.GeoPoint import org.json.JSONObject @@ -14,7 +15,6 @@ import org.springframework.http.HttpStatus import org.springframework.stereotype.Service import org.springframework.web.server.ResponseStatusException import java.time.Duration -import jakarta.annotation.PostConstruct /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/HongKongPhooey.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/HongKongPhooey.kt index 65d2dd81..c6cca7f7 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/HongKongPhooey.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/HongKongPhooey.kt @@ -1,5 +1,6 @@ package net.timafe.angkor.service +import jakarta.persistence.EntityManager import net.timafe.angkor.domain.Event import net.timafe.angkor.domain.dto.BulkResult import net.timafe.angkor.domain.enums.EventTopic @@ -14,7 +15,6 @@ import java.time.Duration import java.time.ZonedDateTime import java.util.* import java.util.concurrent.TimeUnit -import jakarta.persistence.EntityManager /** * Our Janitor Class for regular tasks such as event cleanup diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/LinkService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/LinkService.kt index 893f95e6..0f3f84cf 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/LinkService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/LinkService.kt @@ -11,7 +11,7 @@ import net.timafe.angkor.domain.Link import net.timafe.angkor.domain.dto.Feed import net.timafe.angkor.domain.dto.FeedItem import net.timafe.angkor.domain.enums.EntityType -import net.timafe.angkor.domain.enums.LinkMediaType +import net.timafe.angkor.domain.enums.Media_Type import net.timafe.angkor.repo.LinkRepository import org.springframework.cache.annotation.Cacheable import org.springframework.http.HttpStatus @@ -38,7 +38,7 @@ class LinkService( // Try generic method instead @Transactional(readOnly = true) - fun findByMediaType(mediaType: LinkMediaType): List = repo.findByMediaType(mediaType) + fun findByMediaType(mediaType: Media_Type): List = repo.findByMediaType(mediaType) // Todo handle regular expiry @Cacheable(cacheNames = [FEED_CACHE]) diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/LocationSearchService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/LocationSearchService.kt index 6be12512..d602adde 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/LocationSearchService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/LocationSearchService.kt @@ -1,5 +1,9 @@ package net.timafe.angkor.service +import jakarta.persistence.EntityManager +import jakarta.persistence.criteria.Order +import jakarta.persistence.criteria.Predicate +import jakarta.persistence.criteria.Selection import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.* import net.timafe.angkor.domain.dto.LocationPOI @@ -12,10 +16,6 @@ import net.timafe.angkor.security.SecurityUtils import org.slf4j.LoggerFactory import org.springframework.data.domain.Sort import org.springframework.stereotype.Service -import jakarta.persistence.EntityManager -import jakarta.persistence.criteria.Order -import jakarta.persistence.criteria.Predicate -import jakarta.persistence.criteria.Selection import kotlin.reflect.KClass /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/MailService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/MailService.kt index 56b736a6..4ce86c89 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/MailService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/MailService.kt @@ -1,6 +1,7 @@ package net.timafe.angkor.service import jakarta.annotation.PostConstruct +import jakarta.mail.internet.MimeMessage import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.mail.MailProperties @@ -8,7 +9,6 @@ import org.springframework.mail.javamail.JavaMailSender import org.springframework.mail.javamail.MimeMessageHelper import org.springframework.mail.javamail.MimeMessagePreparator import org.springframework.stereotype.Service -import jakarta.mail.internet.MimeMessage /** Mail Service see https://www.baeldung.com/spring-email */ @Service diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/PlaceService.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/PlaceService.kt index cb9ceaca..fb2df194 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/PlaceService.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/PlaceService.kt @@ -3,7 +3,7 @@ package net.timafe.angkor.service import net.timafe.angkor.domain.Area import net.timafe.angkor.domain.Place -import net.timafe.angkor.domain.enums.AreaLevel +import net.timafe.angkor.domain.enums.Area_Level import net.timafe.angkor.domain.enums.EntityType import net.timafe.angkor.repo.PlaceRepository import net.timafe.angkor.repo.TagRepository @@ -50,7 +50,7 @@ class PlaceService( */ private fun getArea(areaCode: String): Area? { val area = areaService.countriesAndRegions().find { it.code == areaCode } - return if (area?.level == AreaLevel.REGION) { + return if (area?.level == Area_Level.REGION) { // resolve to parent areaService.countriesAndRegions().find { it.code == area.parentCode } } else { diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/service/SessionListener.kt b/kotlin/src/main/kotlin/net/timafe/angkor/service/SessionListener.kt index 8f8323ee..34e4ff8b 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/service/SessionListener.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/service/SessionListener.kt @@ -1,9 +1,9 @@ package net.timafe.angkor.service -import org.slf4j.LoggerFactory -import java.util.concurrent.atomic.AtomicInteger import jakarta.servlet.http.HttpSessionEvent import jakarta.servlet.http.HttpSessionListener +import org.slf4j.LoggerFactory +import java.util.concurrent.atomic.AtomicInteger /** diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/web/ErrorController.kt b/kotlin/src/main/kotlin/net/timafe/angkor/web/ErrorController.kt index 49525e0f..8ca04678 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/web/ErrorController.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/web/ErrorController.kt @@ -1,12 +1,12 @@ package net.timafe.angkor.web +import jakarta.servlet.RequestDispatcher +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.springframework.boot.web.servlet.error.ErrorController import org.springframework.http.HttpStatus import org.springframework.stereotype.Controller import org.springframework.web.bind.annotation.RequestMapping -import jakarta.servlet.RequestDispatcher -import jakarta.servlet.http.HttpServletRequest -import jakarta.servlet.http.HttpServletResponse /** * Custom Error Page instead of Whitelabel Error Page diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/web/LinkController.kt b/kotlin/src/main/kotlin/net/timafe/angkor/web/LinkController.kt index 445f2d3b..fe2bb499 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/web/LinkController.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/web/LinkController.kt @@ -3,7 +3,7 @@ package net.timafe.angkor.web import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.Link import net.timafe.angkor.domain.dto.Feed -import net.timafe.angkor.domain.enums.LinkMediaType +import net.timafe.angkor.domain.enums.Media_Type import net.timafe.angkor.service.LinkService import net.timafe.angkor.web.vm.ListItem import org.slf4j.LoggerFactory @@ -43,7 +43,7 @@ class LinkController( @GetMapping("/feeds") // sub path /api/v1/links/feeds fun getFeeds(): List { - val items = service.findByMediaType(LinkMediaType.FEED) + val items = service.findByMediaType(Media_Type.FEED) log.info("getFeeds returned ${items.size} feeds") return items } @@ -56,7 +56,7 @@ class LinkController( @GetMapping("/media-types") // sub path /api/v1/links/media-types fun getLinkMediaTypes(): List { - return LinkMediaType.values() + return Media_Type.values() .sortedBy{it.label} .map { mt -> ListItem(mt.name, mt.label, mt.icon) } } diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/web/LocationSearchController.kt b/kotlin/src/main/kotlin/net/timafe/angkor/web/LocationSearchController.kt index 4c0dca00..e99d7d36 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/web/LocationSearchController.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/web/LocationSearchController.kt @@ -1,12 +1,12 @@ package net.timafe.angkor.web +import jakarta.validation.Valid import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.dto.LocationPOI import net.timafe.angkor.domain.dto.LocationSummary import net.timafe.angkor.domain.dto.SearchRequest import net.timafe.angkor.service.LocationSearchService import org.springframework.web.bind.annotation.* -import jakarta.validation.Valid @RestController diff --git a/kotlin/src/main/kotlin/net/timafe/angkor/web/LogoutResource.kt b/kotlin/src/main/kotlin/net/timafe/angkor/web/LogoutResource.kt index cc1e115a..4261e102 100644 --- a/kotlin/src/main/kotlin/net/timafe/angkor/web/LogoutResource.kt +++ b/kotlin/src/main/kotlin/net/timafe/angkor/web/LogoutResource.kt @@ -1,5 +1,6 @@ package net.timafe.angkor.web +import jakarta.servlet.http.HttpServletRequest import net.timafe.angkor.config.Constants import net.timafe.angkor.domain.Event import net.timafe.angkor.domain.enums.EventTopic @@ -15,7 +16,6 @@ import org.springframework.security.oauth2.core.oidc.OidcIdToken import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController -import jakarta.servlet.http.HttpServletRequest /** * REST controller for managing global OIDC logout. diff --git a/kotlin/src/test/kotlin/net/timafe/angkor/IntegrationTests.kt b/kotlin/src/test/kotlin/net/timafe/angkor/IntegrationTests.kt index 6228339f..982d2ccf 100644 --- a/kotlin/src/test/kotlin/net/timafe/angkor/IntegrationTests.kt +++ b/kotlin/src/test/kotlin/net/timafe/angkor/IntegrationTests.kt @@ -172,7 +172,7 @@ class IntegrationTests( fun testFeeds() { val items = linkController.getFeeds() assertThat(items.size).isGreaterThan(0) - assertThat(items[0].mediaType).isEqualTo(LinkMediaType.FEED) + assertThat(items[0].mediaType).isEqualTo(Media_Type.FEED) val id = items[0].id assertThat(linkController.getFeed(id!!).items.size).isGreaterThan(0) } diff --git a/kotlin/src/test/kotlin/net/timafe/angkor/domain/enums/LinkMediaTypeUT.kt b/kotlin/src/test/kotlin/net/timafe/angkor/domain/enums/LinkMediaTypeUT.kt index 97f1ad0e..e002cbfb 100644 --- a/kotlin/src/test/kotlin/net/timafe/angkor/domain/enums/LinkMediaTypeUT.kt +++ b/kotlin/src/test/kotlin/net/timafe/angkor/domain/enums/LinkMediaTypeUT.kt @@ -11,7 +11,7 @@ class LinkMediaTypeUT { @Test fun testLinkMediaTypes() { val types = LinkController(Mockito.mock(LinkService::class.java)).getLinkMediaTypes() - Assertions.assertThat(types.size).isEqualTo(LinkMediaType.values().size) + Assertions.assertThat(types.size).isEqualTo(Media_Type.values().size) types.forEach{ Assertions.assertThat(it.icon).isNotBlank() } types.forEach{ Assertions.assertThat(it.label).isNotBlank() } }