diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 4246454..0000000 --- a/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.idea -.cache -.gradle -gradle -out -browser-extension \ No newline at end of file diff --git a/.envrc b/.envrc deleted file mode 100644 index f8420eb..0000000 --- a/.envrc +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Project-specific direnv definitions (environment variables, PATH modifications etc.) -## (Check out https://direnv.net/ for more info) -## -############################################################################## - -source_up - -export PGHOST="127.0.0.1" -export PGDATABASE="kotlink" -export PGPORT=55432 -export PGUSER="kotlinkuser" -export PGPASSWORD="kotlinkpass" - -export KOTLINK_ENV="local" -export KOTLINK_HOME=$(pwd) - -PATH_add environment/bin diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54f5527..27e32ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,12 @@ jobs: java-version: '11' distribution: 'adopt' - name: Run Tests & Build JAR - run: ./environment/bin/kotlink_ci + run: ./gradlew clean build jacocoTestReport - name: Upload JAR File uses: actions/upload-artifact@v2 with: name: jar_file - path: build/libs/kotlink.jar + path: server-spring/build/libs/kotlink.jar - name: Report Detekt Issues if: github.ref == 'refs/heads/master' uses: github/codeql-action/upload-sarif@v1 @@ -44,7 +44,7 @@ jobs: uses: actions/download-artifact@v2 with: name: jar_file - path: build/libs/ + path: server-spring/build/libs/ - name: Login To DockerHub uses: docker/login-action@v1 with: @@ -53,7 +53,7 @@ jobs: - name: Build & Push Image uses: docker/build-push-action@v2 with: - context: . + context: ./server-spring/ platforms: linux/amd64 push: true tags: ilya40umov/kotlink:develop @@ -67,7 +67,7 @@ jobs: uses: actions/download-artifact@v2 with: name: jar_file - path: build/libs/ + path: server-spring/build/libs/ - name: Login To DockerHub uses: docker/login-action@v1 with: @@ -83,7 +83,7 @@ jobs: - name: Build & Push Image uses: docker/build-push-action@v2 with: - context: . + context: ./server-spring/ platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index c5fce46..0000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -PHONY: up down ci dep-updates-check -DEFAULT_TARGET: build - -up: - ./environment/bin/kotlink_env_up - -down: - ./environment/bin/kotlink_env_down - -ci: - ./environment/bin/kotlink_ci - -dep-updates-check: - ./gradlew dependencyUpdates diff --git a/README.md b/README.md index 435d3b4..6d66c04 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ by typing *kk␣vim␣shortcuts↵*, the user will be redirected to the actual l Please beware that to make use of the browser extension, you will first need to set up a dedicated KotLink server, -as it's going to store all of the links / namespaces for your team. +as it's going to store all the links / namespaces for your team. ### Supported Browsers @@ -55,9 +55,16 @@ KotLink server requires an instance of PostgreSQL as the backend store, and encapsulates all the logic around storing / resolving URL aliases, as well as UI for creating / editing them. -For evaluation purposes, you can run KotLink server on your machine with the following commands, -given that you have [Docker](https://en.wikipedia.org/wiki/Docker_(software)) installed -(you may have to add `sudo` before all calls to `docker` depending on your system): +Assuming you have [Docker](https://en.wikipedia.org/wiki/Docker_(software)) and `docker-compose` installed, +you can run KotLink server on your machine for evaluation purposes with the following commands: + +``` +git clone https://github.com/ilya40umov/KotLink.git && cd KotLink +./gradlew bootRun +``` + +Alternatively, if you don't want to clone the repository, you can use the following set of commands: + ``` docker network create kotlink-network @@ -97,6 +104,10 @@ Through environment variables, you will also be able to restrict who can access When you are done evaluating, you can run the following command to clean up containers from your machine: +```./gradlew composeDownForce``` + +or if you chose the second approach: + ```docker rm -f kotlink-postgres && docker network rm kotlink-network``` For the detailed instructions on how to permanently set up your own KotLink server, diff --git a/build.gradle.kts b/build.gradle.kts index dd99ddd..822ec66 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,80 +1,101 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask +import io.gitlab.arturbosch.detekt.Detekt import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -group = "org.kotlink" - -repositories { - mavenCentral() -} - plugins { - // built-in plugins - java jacoco - // versions of all kotlin plugins are resolved by logic in 'settings.gradle.kts' - kotlin("jvm") - kotlin("kapt") - kotlin("plugin.spring") - kotlin("plugin.allopen") - // version of spring boot plugin is also resolved by 'settings.gradle.kts' - id("org.springframework.boot") - // other plugins require a version to be mentioned - id("io.spring.dependency-management") version "1.0.11.RELEASE" - id("io.gitlab.arturbosch.detekt") version "1.17.0" + + val kotlinVersion = "1.6.0" + kotlin("jvm") version kotlinVersion apply false + kotlin("kapt") version kotlinVersion apply false + kotlin("plugin.spring") version kotlinVersion apply false + kotlin("plugin.allopen") version kotlinVersion apply false + + id("io.gitlab.arturbosch.detekt") version "1.19.0" + id("org.jlleitschuh.gradle.ktlint") version "10.1.0" id("com.github.ben-manes.versions") version "0.39.0" } -configure { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 +allprojects { + group = "org.kotlink" + version = "0.0.1-SNAPSHOT" + + repositories { + mavenLocal() + mavenCentral() + } } -jacoco { - toolVersion = "0.8.7" +subprojects { + apply() + apply() + + configure { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + tasks { + withType { + kotlinOptions { + jvmTarget = "11" + freeCompilerArgs = listOf("-Xjsr305=strict") + } + } + withType { + testLogging.apply { + events("passed", "skipped", "failed") + exceptionFormat = TestExceptionFormat.FULL + debug { + showStandardStreams = true + } + } + } + } +} + +dependencies { + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0") } -detekt { - buildUponDefaultConfig = true - config = files("src/main/resources/detekt-config.yml") - reports { - html.enabled = true - xml.enabled = true - txt.enabled = true - sarif.enabled = true +ktlint { + enableExperimentalRules.set(false) + disabledRules.set(setOf("final-newline")) + filter { + disabledRules.set(setOf("final-newline", "indent")) + } + filter { + exclude("**.kts") } } tasks { - withType { - kotlinOptions { - jvmTarget = "11" - freeCompilerArgs = listOf("-Xjsr305=strict") + val detekt by named("detekt", Detekt::class) { + description = "Runs Detekt to perform code analysis" + buildUponDefaultConfig = true + config.setFrom(files(projectDir.resolve("detekt.yml"))) + setSource(files(*subprojects.map { "${it.projectDir}/src" }.toTypedArray())) + autoCorrect = false + ignoreFailures = false + reports { + sarif.required.set(true) } } - withType { - useJUnitPlatform { - val properties = mapOf( - "spring.datasource.url" to "jdbc:postgresql://localhost:55432/kotlink", - "spring.redis.url" to "redis://localhost:6379" - ) - properties.forEach { (name, defaultValue) -> - systemProperty(name, System.getProperty(name) ?: defaultValue) - } - } - testLogging.apply { - events("passed", "skipped", "failed") - exceptionFormat = TestExceptionFormat.FULL - } + val check by registering { + dependsOn(detekt) } - withType { - reports { - xml.apply { - isEnabled = true - } - html.apply { - isEnabled = false - } + register("build") { + dependsOn(check) + } + register("jacocoAggregatedReport", JacocoReport::class) { + reports.html.required.set(true) + reports.xml.required.set(true) + subprojects.filter { it.name != "assembly" }.forEach { subProject -> + dependsOn(subProject.tasks.findByPath("test")) + executionData(subProject.tasks.findByPath("test")) + additionalSourceDirs(files("${subProject.projectDir}/src/kotlin/main")) + additionalClassDirs(files("${subProject.buildDir}/classes/kotlin/main")) } } @@ -93,64 +114,4 @@ tasks { isNonStable(candidate.version) && !isNonStable(currentVersion) } } -} - -dependencies { - - val exposedVersion = "0.31.1" - val logbackVersion = "1.2.3" - - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlin:kotlin-reflect") - - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-aop") - implementation("org.springframework.boot:spring-boot-starter-cache") - implementation("org.springframework.boot:spring-boot-starter-validation") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-webflux") - implementation("org.springframework.boot:spring-boot-starter-thymeleaf") - implementation("org.springframework.boot:spring-boot-starter-jdbc") - implementation("org.springframework.boot:spring-boot-starter-data-redis") - implementation("org.springframework.boot:spring-boot-starter-security") - implementation("org.springframework.boot:spring-boot-starter-oauth2-client") - implementation("org.springframework.session:spring-session-jdbc") - implementation("org.springframework.session:spring-session-data-redis") - implementation("org.springframework.boot:spring-boot-devtools") - - compileOnly("org.springframework.boot:spring-boot-configuration-processor") - kapt("org.springframework.boot:spring-boot-configuration-processor") - - implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity5") - - implementation("com.github.ben-manes.caffeine:caffeine") - implementation("io.micrometer:micrometer-registry-prometheus") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation("io.github.microutils:kotlin-logging:2.0.6") - implementation("org.slf4j:slf4j-api:1.7.30") - implementation("ch.qos.logback:logback-classic:$logbackVersion") - implementation("ch.qos.logback:logback-core:$logbackVersion") - implementation("ch.qos.logback:logback-access:$logbackVersion") - implementation("org.apache.logging.log4j:log4j-to-slf4j:2.14.1") - implementation("org.postgresql:postgresql:42.2.20") - implementation("org.flywaydb:flyway-core:7.9.1") - - implementation("org.jetbrains.exposed:exposed-core:$exposedVersion") - implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion") - implementation("org.jetbrains.exposed:spring-transaction:$exposedVersion") - - implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.5.3") - - val jupiterVersion = "5.7.2" - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.security:spring-security-test") - testImplementation("org.junit.jupiter:junit-jupiter-api:$jupiterVersion") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion") - testImplementation("org.amshove.kluent:kluent:1.65") - testImplementation("io.projectreactor:reactor-test") - testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0") - testImplementation("org.mockito:mockito-junit-jupiter:3.10.0") - - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.17.0") -} +} \ No newline at end of file diff --git a/src/main/resources/detekt-config.yml b/detekt.yml similarity index 60% rename from src/main/resources/detekt-config.yml rename to detekt.yml index a16caca..e5cf5be 100644 --- a/src/main/resources/detekt-config.yml +++ b/detekt.yml @@ -1,16 +1,22 @@ # https://detekt.github.io/detekt/configurations.html +config: + excludes: '' + build: maxIssues: 25 complexity: TooManyFunctions: + excludes: ['**/integrationTest/**', '**/test/**', '**/*Test.kt', '**/*Spec.kt'] thresholdInClasses: 20 thresholdInInterfaces: 20 LongParameterList: constructorThreshold: 10 style: + MagicNumber: + excludes: ['**/integrationTest/**', '**/test/**', '**/*Test.kt', '**/*Spec.kt'] NewLineAtEndOfFile: active: false diff --git a/docs/deployment-guide.md b/docs/deployment-guide.md index b83c105..feb7390 100644 --- a/docs/deployment-guide.md +++ b/docs/deployment-guide.md @@ -78,7 +78,7 @@ for more details. To enable using Redis as a backing store for cache (by default lives in memory) and for session information (by default is stored in Postgres), -which in turn will help improving performance and availability +which in turn will help to improve performance and availability (e.g. without a stand-alone cache you can only have a single-node deployment of KotLink server, as local caches on each node will quickly become stale and cause issues), you can tweak the following properties: diff --git a/docs/engineering-guide.md b/docs/engineering-guide.md index a2a4822..a615ca7 100644 --- a/docs/engineering-guide.md +++ b/docs/engineering-guide.md @@ -1,24 +1,22 @@ # KotLink - Engineering Guide ### Required Software -* jdk 8+ -* direnv +* jdk 11+ * docker * docker-compose * Intellij IDEA (recommended) ### How To Develop Locally -* First of all, `cd` into the project directory and run `direnv allow` -* Then, start dependencies with `kotlink_env_up` -* Run application in Terminal with `./gradlew bootRun` (or in Intellij IDEA) +* To run the server in Terminal use `./gradlew bootRun` +* To be able to run the server in IDE you will need to run `./gradlew composeUp` first * Go to `http://localhost:8080` in your browser and create your namespaces / links * Both Chrome and FireFox can be pointed at `browser-extension` directory to load the extension (or you can install it from the store) -* Stop dependencies with `kotlink_env_down` (this command will also remove all data from Postgres) -* You can run the CI pipeline with `kotlink_ci` (can be run in parallel with the app) +* To run the test suit execute `./gradlew check` ### Best Practices * Use Intellij IDEA to format the files you touched before committing them -* Strive for high test coverage, especially for backend code that is way easier to unit-test than UI -* Run CI locally before pushing -* Test UI manually as well, as the existing tests don't provide a good guarantee that nothing there is broken \ No newline at end of file +* Strive for high test coverage, especially for backend code that is easy to unit-test +* Run `./gradlew detekt` to see if you have violated any of the code style checks +* Run the whole test suit locally before pushing your changes (e.g. with `./gradlew check`) +* Test UI manually as well, as the existing tests don't provide any guarantee that nothing isn't broken there \ No newline at end of file diff --git a/docs/extension-guide.md b/docs/extension-guide.md index 6508e81..4527dd0 100644 --- a/docs/extension-guide.md +++ b/docs/extension-guide.md @@ -24,15 +24,8 @@ with your actual data. ### Safari -Safari is currently only partially supported via 3rd-party -[Safari Omnikey](http://marioestrada.github.io/safari-omnikey/) extension. - -In order to make it work, first install the extension, then click on the extension icon (looks like a magnifying glass), -click *Add Site* and use prefix `kk` with the following URL `http://YOUR_SERVER_ADDRESS/api/link/redirect?link={search}` - -Please, make sure to replace `YOUR_SERVER_ADDRESS` in the URL with your actual server address. -Also, it's worth to mention that unlike regular KotLink extension for Chrome / FireFox, -*Safari Omnikey* does not support autocomplete. +It used to be possible to get partial support via [Safari Omnikey](http://marioestrada.github.io/safari-omnikey/), +but since Safari 13 it does not seem to function anymore. ### KotLink Extension Options diff --git a/environment/bin/kotlink_ci b/environment/bin/kotlink_ci deleted file mode 100755 index b13f36e..0000000 --- a/environment/bin/kotlink_ci +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -function destroy_environment() { - if [[ $? -gt 0 ]]; then - echo -e "\033[31mERROR\033[m: CI pipeline has failed!" - fi - ./environment/lib/env_down ci -} - -trap destroy_environment EXIT - -./environment/lib/env_up ci - -export GRADLE_OPTS="-Dorg.gradle.daemon=false" -./gradlew clean build jacocoTestReport \ - -Dspring.datasource.url=jdbc:postgresql://localhost:45432/kotlink \ - -Dspring.redis.url=redis://localhost:46379 \ No newline at end of file diff --git a/environment/bin/kotlink_env_down b/environment/bin/kotlink_env_down deleted file mode 100755 index 0aaaae9..0000000 --- a/environment/bin/kotlink_env_down +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -./environment/lib/env_down local \ No newline at end of file diff --git a/environment/bin/kotlink_env_up b/environment/bin/kotlink_env_up deleted file mode 100755 index 59e0cd5..0000000 --- a/environment/bin/kotlink_env_up +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -./environment/lib/env_up local \ No newline at end of file diff --git a/environment/docker-compose-ci.yaml b/environment/docker-compose-ci.yaml deleted file mode 100644 index c26a33b..0000000 --- a/environment/docker-compose-ci.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3.2' - -services: - postgresql: - ports: - - 45432:5432 - tmpfs: - - /tmp - - /var/run/postgresql - - /var/lib/postgresql/data - redis: - ports: - - 46379:6379 - tmpfs: - - /data - -networks: - default: - ipam: - config: - - subnet: 172.177.18.0/24 \ No newline at end of file diff --git a/environment/lib/env_down b/environment/lib/env_down deleted file mode 100755 index fbcf2a5..0000000 --- a/environment/lib/env_down +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z $1 ]]; then - echo -e "\033[31mERROR\033[m: Missing the environment argument!" - exit 1 -fi - -ENV=$1 -PROJECT_NAME="kotlink${ENV}" - -docker-compose -p $PROJECT_NAME -f environment/docker-compose.yaml -f environment/docker-compose-$ENV.yaml down -v \ No newline at end of file diff --git a/environment/lib/env_up b/environment/lib/env_up deleted file mode 100755 index 3762b76..0000000 --- a/environment/lib/env_up +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z $1 ]]; then - echo -e "\033[31mERROR\033[m: Missing the environment argument!" - exit 1 -fi - -ENV=$1 -PROJECT_NAME="kotlink${ENV}" - -docker-compose -p $PROJECT_NAME -f environment/docker-compose.yaml -f environment/docker-compose-$ENV.yaml up --build -d \ No newline at end of file diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index be12da0..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -kotlinVersion=1.5.10 -springBootVersion=2.5.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/Dockerfile b/server-spring/Dockerfile similarity index 87% rename from Dockerfile rename to server-spring/Dockerfile index 7ea726a..1289cd6 100644 --- a/Dockerfile +++ b/server-spring/Dockerfile @@ -1,4 +1,4 @@ -FROM adoptopenjdk/openjdk11:jre-11.0.12_7-alpine +FROM eclipse-temurin:11.0.13_8-jre-alpine LABEL maintainer="illia.sorokoumov@gmail.com" diff --git a/server-spring/build.gradle.kts b/server-spring/build.gradle.kts new file mode 100644 index 0000000..55a639a --- /dev/null +++ b/server-spring/build.gradle.kts @@ -0,0 +1,151 @@ +import com.avast.gradle.dockercompose.ComposeSettings +import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation +import org.springframework.boot.gradle.tasks.bundling.BootJar +import org.springframework.boot.gradle.tasks.run.BootRun + +plugins { + `jvm-test-suite` + + kotlin("jvm") + kotlin("kapt") + kotlin("plugin.spring") + kotlin("plugin.allopen") + + id("org.springframework.boot") version "2.6.1" + id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("com.avast.gradle.docker-compose") version "0.14.11" +} + +dockerCompose { + projectName = "kotlink" + projectNamePrefix = "kotlink_" + useComposeFiles.set(listOf("docker-compose.yaml", "docker-compose-local.yaml")) + // when set to "false", the plugin automatically tries to reconnect to the containers from the previous run + stopContainers.set(false) + + createNested("integrationTest").apply { + projectName = "kotlink-ci" + projectNamePrefix = "kotlink_ci_" + useComposeFiles.set(listOf("docker-compose.yaml", "docker-compose-ci.yaml")) + } +} + +fun ComposeSettings.postgresUrl() = + "jdbc:postgresql://localhost:${servicesInfos["postgresql"]?.port ?: 5432}/kotlink" + +fun ComposeSettings.redisUrl() = + "redis://localhost:${servicesInfos["redis"]?.port ?: 6379}" + +testing { + suites { + val test by getting(JvmTestSuite::class) { + useJUnitJupiter() + } + register("integrationTest", JvmTestSuite::class) { + useJUnitJupiter() + addExtendsFromRelation( + extendingConfigurationName = "integrationTestImplementation", + extendsFromConfigurationName = "testImplementation", + forced = true + ) + dependencies { + implementation(project) + } + targets { + all { + testTask.configure { + shouldRunAfter(test) + dependsOn("integrationTestComposeUp") + doFirst { + systemProperty("spring.datasource.url", dockerCompose.nested("integrationTest").postgresUrl()) + systemProperty("spring.redis.url", dockerCompose.nested("integrationTest").redisUrl()) + } + } + } + } + } + } +} + +tasks { + named("check") { + dependsOn(testing.suites.named("integrationTest")) + } + withType { + dependsOn("composeUp") + doFirst { + systemProperty("spring.datasource.url", dockerCompose.postgresUrl()) + systemProperty("spring.redis.url", dockerCompose.redisUrl()) + } + } + withType { + archiveFileName.set("kotlink.jar") + } + register("psql") { + dependsOn("composeUp") + doFirst { + val port = dockerCompose.servicesInfos["postgresql"]?.port ?: 5432 + println("To connect to db, use the following commands:") + println("export PGPASSWORD=kotlinkpass") + println("psql -h 127.0.0.1 -p $port -U kotlinkuser kotlink") + } + } +} + +dependencies { + + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-starter-aop") + implementation("org.springframework.boot:spring-boot-starter-cache") + implementation("org.springframework.boot:spring-boot-starter-validation") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-webflux") + implementation("org.springframework.boot:spring-boot-starter-thymeleaf") + implementation("org.springframework.boot:spring-boot-starter-jdbc") + implementation("org.springframework.boot:spring-boot-starter-data-redis") + implementation("org.springframework.boot:spring-boot-starter-security") + implementation("org.springframework.boot:spring-boot-starter-oauth2-client") + implementation("org.springframework.session:spring-session-jdbc") + implementation("org.springframework.session:spring-session-data-redis") + implementation("org.springframework.boot:spring-boot-devtools") + + compileOnly("org.springframework.boot:spring-boot-configuration-processor") + kapt("org.springframework.boot:spring-boot-configuration-processor") + + implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity5") + + implementation("com.github.ben-manes.caffeine:caffeine") + implementation("io.micrometer:micrometer-registry-prometheus") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("io.github.microutils:kotlin-logging:2.1.0") + implementation("org.slf4j:slf4j-api:1.7.32") + + val logbackVersion = "1.2.7" + implementation("ch.qos.logback:logback-classic:$logbackVersion") + implementation("ch.qos.logback:logback-core:$logbackVersion") + implementation("ch.qos.logback:logback-access:$logbackVersion") + + implementation("org.apache.logging.log4j:log4j-to-slf4j:2.14.1") + implementation("org.postgresql:postgresql:42.3.1") + implementation("org.flywaydb:flyway-core:8.2.0") + + val exposedVersion = "0.36.2" + implementation("org.jetbrains.exposed:exposed-core:$exposedVersion") + implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion") + implementation("org.jetbrains.exposed:spring-transaction:$exposedVersion") + + implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0") + + + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.springframework.security:spring-security-test") + + val jupiterVersion = "5.8.2" + testImplementation("org.junit.jupiter:junit-jupiter-api:$jupiterVersion") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion") + + testImplementation("org.amshove.kluent:kluent:1.68") + testImplementation("io.projectreactor:reactor-test") + testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0") + testImplementation("org.mockito:mockito-junit-jupiter:4.1.0") +} diff --git a/server-spring/docker-compose-ci.yaml b/server-spring/docker-compose-ci.yaml new file mode 100644 index 0000000..4db5c1c --- /dev/null +++ b/server-spring/docker-compose-ci.yaml @@ -0,0 +1,11 @@ +version: '3.2' + +services: + postgresql: + tmpfs: + - /tmp + - /var/run/postgresql + - /var/lib/postgresql/data + redis: + tmpfs: + - /data \ No newline at end of file diff --git a/environment/docker-compose-local.yaml b/server-spring/docker-compose-local.yaml similarity index 61% rename from environment/docker-compose-local.yaml rename to server-spring/docker-compose-local.yaml index 083532d..ba17772 100644 --- a/environment/docker-compose-local.yaml +++ b/server-spring/docker-compose-local.yaml @@ -3,12 +3,12 @@ version: '3.2' services: postgresql: ports: - - 55432:5432 + - "55432:5432" volumes: - postgresql:/var/lib/postgresql/data redis: ports: - - 6379:6379 + - "6379:6379" volumes: - redis:/data @@ -16,10 +16,4 @@ volumes: postgresql: driver: local redis: - driver: local - -networks: - default: - ipam: - config: - - subnet: 172.177.17.0/24 \ No newline at end of file + driver: local \ No newline at end of file diff --git a/environment/docker-compose.yaml b/server-spring/docker-compose.yaml similarity index 93% rename from environment/docker-compose.yaml rename to server-spring/docker-compose.yaml index 6649b3b..6602e2d 100644 --- a/environment/docker-compose.yaml +++ b/server-spring/docker-compose.yaml @@ -4,7 +4,7 @@ services: postgresql: image: postgres:13.3 ports: - - 5432 + - "5432" environment: - POSTGRES_DB=kotlink - POSTGRES_USER=kotlinkuser @@ -17,7 +17,7 @@ services: redis: image: redis:6.2.4 ports: - - 6379 + - "6379" healthcheck: test: [ "CMD", "redis-cli","ping" ] interval: 15s diff --git a/src/test/kotlin/org/kotlink/ExposedRepoTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/ExposedRepoTest.kt similarity index 93% rename from src/test/kotlin/org/kotlink/ExposedRepoTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/ExposedRepoTest.kt index 66be14f..1603e21 100644 --- a/src/test/kotlin/org/kotlink/ExposedRepoTest.kt +++ b/server-spring/src/integrationTest/kotlin/org/kotlink/ExposedRepoTest.kt @@ -39,9 +39,7 @@ internal class ExposedRepoTypeExcludeFilter(testClass: Class<*>) : AnnotationCus override fun hasAnnotation(): Boolean = this.annotation != null - override fun getFilters( - type: AnnotationCustomizableTypeExcludeFilter.FilterType - ): Array = emptyArray() + override fun getFilters(type: FilterType): Array = emptyArray() override fun isUseDefaultFilters(): Boolean = true diff --git a/src/test/kotlin/org/kotlink/KotLinkSecurityAndIntegrationTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/KotLinkSecurityAndIntegrationTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/KotLinkSecurityAndIntegrationTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/KotLinkSecurityAndIntegrationTest.kt diff --git a/src/test/kotlin/org/kotlink/core/account/UserAccountRepoImplTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/core/account/UserAccountRepoImplTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/account/UserAccountRepoImplTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/core/account/UserAccountRepoImplTest.kt diff --git a/src/test/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt index d18405e..9b49df3 100644 --- a/src/test/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt +++ b/server-spring/src/integrationTest/kotlin/org/kotlink/core/alias/AliasRepoImplTest.kt @@ -1,10 +1,10 @@ package org.kotlink.core.alias import org.amshove.kluent.shouldBe +import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeGreaterThan import org.amshove.kluent.shouldContain import org.amshove.kluent.shouldEndWith -import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldNotBe import org.amshove.kluent.shouldStartWith import org.amshove.kluent.shouldThrow diff --git a/src/test/kotlin/org/kotlink/core/namespace/NamespaceRepoImplTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/core/namespace/NamespaceRepoImplTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/namespace/NamespaceRepoImplTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/core/namespace/NamespaceRepoImplTest.kt diff --git a/src/test/kotlin/org/kotlink/core/secret/ApiSecretRepoImplTest.kt b/server-spring/src/integrationTest/kotlin/org/kotlink/core/secret/ApiSecretRepoImplTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/secret/ApiSecretRepoImplTest.kt rename to server-spring/src/integrationTest/kotlin/org/kotlink/core/secret/ApiSecretRepoImplTest.kt diff --git a/src/main/kotlin/org/kotlink/DefaultNamespaceAppropriator.kt b/server-spring/src/main/kotlin/org/kotlink/DefaultNamespaceAppropriator.kt similarity index 100% rename from src/main/kotlin/org/kotlink/DefaultNamespaceAppropriator.kt rename to server-spring/src/main/kotlin/org/kotlink/DefaultNamespaceAppropriator.kt diff --git a/src/main/kotlin/org/kotlink/KotLinkApplication.kt b/server-spring/src/main/kotlin/org/kotlink/KotLinkApplication.kt similarity index 100% rename from src/main/kotlin/org/kotlink/KotLinkApplication.kt rename to server-spring/src/main/kotlin/org/kotlink/KotLinkApplication.kt diff --git a/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionController.kt b/server-spring/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionController.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/resolution/LinkResolutionController.kt rename to server-spring/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionController.kt diff --git a/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionService.kt b/server-spring/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionService.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/resolution/LinkResolutionService.kt rename to server-spring/src/main/kotlin/org/kotlink/api/resolution/LinkResolutionService.kt diff --git a/src/main/kotlin/org/kotlink/api/resolution/OpenSearchSuggestions.kt b/server-spring/src/main/kotlin/org/kotlink/api/resolution/OpenSearchSuggestions.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/resolution/OpenSearchSuggestions.kt rename to server-spring/src/main/kotlin/org/kotlink/api/resolution/OpenSearchSuggestions.kt diff --git a/src/main/kotlin/org/kotlink/api/security/SecretAuthFailureHandler.kt b/server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthFailureHandler.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/security/SecretAuthFailureHandler.kt rename to server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthFailureHandler.kt diff --git a/src/main/kotlin/org/kotlink/api/security/SecretAuthFilter.kt b/server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthFilter.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/security/SecretAuthFilter.kt rename to server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthFilter.kt diff --git a/src/main/kotlin/org/kotlink/api/security/SecretAuthToken.kt b/server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthToken.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/security/SecretAuthToken.kt rename to server-spring/src/main/kotlin/org/kotlink/api/security/SecretAuthToken.kt diff --git a/src/main/kotlin/org/kotlink/api/security/SecretValidator.kt b/server-spring/src/main/kotlin/org/kotlink/api/security/SecretValidator.kt similarity index 100% rename from src/main/kotlin/org/kotlink/api/security/SecretValidator.kt rename to server-spring/src/main/kotlin/org/kotlink/api/security/SecretValidator.kt diff --git a/src/main/kotlin/org/kotlink/config/ActuatorSecurityConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/ActuatorSecurityConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/ActuatorSecurityConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/ActuatorSecurityConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/CachingConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/CachingConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/CachingConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/CachingConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/ExposedConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/ExposedConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/ExposedConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/ExposedConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/OAuthSecurityConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/OAuthSecurityConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/OAuthSecurityConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/OAuthSecurityConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/RedisSessionConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/RedisSessionConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/RedisSessionConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/RedisSessionConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/SecretAuthSecurityConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/SecretAuthSecurityConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/SecretAuthSecurityConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/SecretAuthSecurityConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/TomcatWebServerCustomizer.kt b/server-spring/src/main/kotlin/org/kotlink/config/TomcatWebServerCustomizer.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/TomcatWebServerCustomizer.kt rename to server-spring/src/main/kotlin/org/kotlink/config/TomcatWebServerCustomizer.kt diff --git a/src/main/kotlin/org/kotlink/config/WebMvcConfig.kt b/server-spring/src/main/kotlin/org/kotlink/config/WebMvcConfig.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/WebMvcConfig.kt rename to server-spring/src/main/kotlin/org/kotlink/config/WebMvcConfig.kt diff --git a/src/main/kotlin/org/kotlink/config/configOrder.kt b/server-spring/src/main/kotlin/org/kotlink/config/configOrder.kt similarity index 100% rename from src/main/kotlin/org/kotlink/config/configOrder.kt rename to server-spring/src/main/kotlin/org/kotlink/config/configOrder.kt diff --git a/src/main/kotlin/org/kotlink/core/CurrentUser.kt b/server-spring/src/main/kotlin/org/kotlink/core/CurrentUser.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/CurrentUser.kt rename to server-spring/src/main/kotlin/org/kotlink/core/CurrentUser.kt diff --git a/src/main/kotlin/org/kotlink/core/KotLinkException.kt b/server-spring/src/main/kotlin/org/kotlink/core/KotLinkException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/KotLinkException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/KotLinkException.kt diff --git a/src/main/kotlin/org/kotlink/core/OperationDeniedException.kt b/server-spring/src/main/kotlin/org/kotlink/core/OperationDeniedException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/OperationDeniedException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/OperationDeniedException.kt diff --git a/src/main/kotlin/org/kotlink/core/Page.kt b/server-spring/src/main/kotlin/org/kotlink/core/Page.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/Page.kt rename to server-spring/src/main/kotlin/org/kotlink/core/Page.kt diff --git a/src/main/kotlin/org/kotlink/core/account/UserAccount.kt b/server-spring/src/main/kotlin/org/kotlink/core/account/UserAccount.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/account/UserAccount.kt rename to server-spring/src/main/kotlin/org/kotlink/core/account/UserAccount.kt diff --git a/src/main/kotlin/org/kotlink/core/account/UserAccountRepo.kt b/server-spring/src/main/kotlin/org/kotlink/core/account/UserAccountRepo.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/account/UserAccountRepo.kt rename to server-spring/src/main/kotlin/org/kotlink/core/account/UserAccountRepo.kt diff --git a/src/main/kotlin/org/kotlink/core/account/UserAccountService.kt b/server-spring/src/main/kotlin/org/kotlink/core/account/UserAccountService.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/account/UserAccountService.kt rename to server-spring/src/main/kotlin/org/kotlink/core/account/UserAccountService.kt diff --git a/src/main/kotlin/org/kotlink/core/alias/Alias.kt b/server-spring/src/main/kotlin/org/kotlink/core/alias/Alias.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/alias/Alias.kt rename to server-spring/src/main/kotlin/org/kotlink/core/alias/Alias.kt diff --git a/src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt b/server-spring/src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt similarity index 98% rename from src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt rename to server-spring/src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt index 2375a45..0af6453 100644 --- a/src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt +++ b/server-spring/src/main/kotlin/org/kotlink/core/alias/AliasRepo.kt @@ -156,7 +156,7 @@ class AliasRepoImpl : AliasRepo { return Aliases.withJoins .select { Namespaces.keyword.eq(namespace) and - (Aliases.link.psqlRegexp(regexp) or Aliases.description.psqlRegexp(regexp)) + (Aliases.link.psqlRegexp(regexp) or Aliases.description.psqlRegexp(regexp)) } .orderBy(Namespaces.keyword, order = SortOrder.ASC) .orderBy(Aliases.link, order = SortOrder.ASC) diff --git a/src/main/kotlin/org/kotlink/core/alias/AliasService.kt b/server-spring/src/main/kotlin/org/kotlink/core/alias/AliasService.kt similarity index 93% rename from src/main/kotlin/org/kotlink/core/alias/AliasService.kt rename to server-spring/src/main/kotlin/org/kotlink/core/alias/AliasService.kt index 3065c9f..31bd8fd 100644 --- a/src/main/kotlin/org/kotlink/core/alias/AliasService.kt +++ b/server-spring/src/main/kotlin/org/kotlink/core/alias/AliasService.kt @@ -55,11 +55,11 @@ class AliasService( return when { namespace != null && terms.size == 1 -> aliasRepo.findByNamespace(namespace.keyword) + - aliasRepo.findWithAtLeastOneOfTerms(terms) + aliasRepo.findWithAtLeastOneOfTerms(terms) namespace != null -> aliasRepo.findByNamespaceAndWithAtLeastOneOfTerms(namespace.keyword, terms.subList(1, terms.size)) + - aliasRepo.findByNamespace(namespace.keyword) + - aliasRepo.findWithAtLeastOneOfTerms(terms) + aliasRepo.findByNamespace(namespace.keyword) + + aliasRepo.findWithAtLeastOneOfTerms(terms) else -> aliasRepo.findWithAtLeastOneOfTerms(terms) }.toSet().toList() @@ -109,7 +109,7 @@ class AliasService( } foundAlias.verifyCanModify(currentUser) { "Only the link owner (${foundAlias.ownerAccount.email}) " + - "or the namespace owner (${foundAlias.namespace.ownerAccount.email}) can modify the link" + "or the namespace owner (${foundAlias.namespace.ownerAccount.email}) can modify the link" } return aliasRepo.update(alias) } @@ -123,7 +123,7 @@ class AliasService( val foundAlias = aliasRepo.findByIdOrThrow(id) foundAlias.verifyCanModify(currentUser) { "Only the link owner (${foundAlias.ownerAccount.email}) " + - "or the namespace owner (${foundAlias.namespace.ownerAccount.email}) can remove the link" + "or the namespace owner (${foundAlias.namespace.ownerAccount.email}) can remove the link" } aliasRepo.deleteById(id) return foundAlias diff --git a/src/main/kotlin/org/kotlink/core/alias/FullLinkExistsException.kt b/server-spring/src/main/kotlin/org/kotlink/core/alias/FullLinkExistsException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/alias/FullLinkExistsException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/alias/FullLinkExistsException.kt diff --git a/src/main/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializer.kt b/server-spring/src/main/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializer.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializer.kt rename to server-spring/src/main/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializer.kt diff --git a/src/main/kotlin/org/kotlink/core/exposed/DatabaseException.kt b/server-spring/src/main/kotlin/org/kotlink/core/exposed/DatabaseException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/exposed/DatabaseException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/exposed/DatabaseException.kt diff --git a/src/main/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspect.kt b/server-spring/src/main/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspect.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspect.kt rename to server-spring/src/main/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspect.kt diff --git a/src/main/kotlin/org/kotlink/core/exposed/RecordNotFoundException.kt b/server-spring/src/main/kotlin/org/kotlink/core/exposed/RecordNotFoundException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/exposed/RecordNotFoundException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/exposed/RecordNotFoundException.kt diff --git a/src/main/kotlin/org/kotlink/core/exposed/exposedExtensions.kt b/server-spring/src/main/kotlin/org/kotlink/core/exposed/exposedExtensions.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/exposed/exposedExtensions.kt rename to server-spring/src/main/kotlin/org/kotlink/core/exposed/exposedExtensions.kt diff --git a/src/main/kotlin/org/kotlink/core/ipblock/EditOp.kt b/server-spring/src/main/kotlin/org/kotlink/core/ipblock/EditOp.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/ipblock/EditOp.kt rename to server-spring/src/main/kotlin/org/kotlink/core/ipblock/EditOp.kt diff --git a/src/main/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspect.kt b/server-spring/src/main/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspect.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspect.kt rename to server-spring/src/main/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspect.kt diff --git a/src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt b/server-spring/src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt similarity index 79% rename from src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt rename to server-spring/src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt index 3ddb111..af25e86 100644 --- a/src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt +++ b/server-spring/src/main/kotlin/org/kotlink/core/metrics/micrometerExtensions.kt @@ -3,5 +3,5 @@ package org.kotlink.core.metrics import io.micrometer.core.instrument.Timer fun Timer.recording(call: () -> T): T { - return this.record(call) + return this.record(call)!! } \ No newline at end of file diff --git a/src/main/kotlin/org/kotlink/core/namespace/KeywordTakenException.kt b/server-spring/src/main/kotlin/org/kotlink/core/namespace/KeywordTakenException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/namespace/KeywordTakenException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/namespace/KeywordTakenException.kt diff --git a/src/main/kotlin/org/kotlink/core/namespace/Namespace.kt b/server-spring/src/main/kotlin/org/kotlink/core/namespace/Namespace.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/namespace/Namespace.kt rename to server-spring/src/main/kotlin/org/kotlink/core/namespace/Namespace.kt diff --git a/src/main/kotlin/org/kotlink/core/namespace/NamespaceRepo.kt b/server-spring/src/main/kotlin/org/kotlink/core/namespace/NamespaceRepo.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/namespace/NamespaceRepo.kt rename to server-spring/src/main/kotlin/org/kotlink/core/namespace/NamespaceRepo.kt diff --git a/src/main/kotlin/org/kotlink/core/namespace/NamespaceService.kt b/server-spring/src/main/kotlin/org/kotlink/core/namespace/NamespaceService.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/namespace/NamespaceService.kt rename to server-spring/src/main/kotlin/org/kotlink/core/namespace/NamespaceService.kt diff --git a/src/main/kotlin/org/kotlink/core/namespace/UntouchableNamespaceException.kt b/server-spring/src/main/kotlin/org/kotlink/core/namespace/UntouchableNamespaceException.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/namespace/UntouchableNamespaceException.kt rename to server-spring/src/main/kotlin/org/kotlink/core/namespace/UntouchableNamespaceException.kt diff --git a/src/main/kotlin/org/kotlink/core/oauth/OAuthAuthoritiesMapper.kt b/server-spring/src/main/kotlin/org/kotlink/core/oauth/OAuthAuthoritiesMapper.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/oauth/OAuthAuthoritiesMapper.kt rename to server-spring/src/main/kotlin/org/kotlink/core/oauth/OAuthAuthoritiesMapper.kt diff --git a/src/main/kotlin/org/kotlink/core/oauth/OAuthFailureHandler.kt b/server-spring/src/main/kotlin/org/kotlink/core/oauth/OAuthFailureHandler.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/oauth/OAuthFailureHandler.kt rename to server-spring/src/main/kotlin/org/kotlink/core/oauth/OAuthFailureHandler.kt diff --git a/src/main/kotlin/org/kotlink/core/secret/ApiSecret.kt b/server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecret.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/secret/ApiSecret.kt rename to server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecret.kt diff --git a/src/main/kotlin/org/kotlink/core/secret/ApiSecretRepo.kt b/server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecretRepo.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/secret/ApiSecretRepo.kt rename to server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecretRepo.kt diff --git a/src/main/kotlin/org/kotlink/core/secret/ApiSecretService.kt b/server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecretService.kt similarity index 100% rename from src/main/kotlin/org/kotlink/core/secret/ApiSecretService.kt rename to server-spring/src/main/kotlin/org/kotlink/core/secret/ApiSecretService.kt diff --git a/src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt b/server-spring/src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt similarity index 86% rename from src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt rename to server-spring/src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt index 9c65f67..962078b 100644 --- a/src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt +++ b/server-spring/src/main/kotlin/org/kotlink/core/security/ActuatorAuthenticationProvider.kt @@ -18,7 +18,7 @@ class ActuatorAuthenticationProvider( override fun authenticate(authentication: Authentication?): Authentication { return when { authentication is UsernamePasswordAuthenticationToken && - authentication.principal == username && authentication.credentials == password -> + authentication.principal == username && authentication.credentials == password -> UsernamePasswordAuthenticationToken(username, password, authorities) else -> throw BadCredentialsException("Invalid credentials") } @@ -26,6 +26,6 @@ class ActuatorAuthenticationProvider( override fun supports(authentication: Class<*>?): Boolean { return authentication != null && - UsernamePasswordAuthenticationToken::class.java.isAssignableFrom(authentication) + UsernamePasswordAuthenticationToken::class.java.isAssignableFrom(authentication) } } \ No newline at end of file diff --git a/src/main/kotlin/org/kotlink/ui/LoginController.kt b/server-spring/src/main/kotlin/org/kotlink/ui/LoginController.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/LoginController.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/LoginController.kt diff --git a/src/main/kotlin/org/kotlink/ui/UiErrorViewResolver.kt b/server-spring/src/main/kotlin/org/kotlink/ui/UiErrorViewResolver.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/UiErrorViewResolver.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/UiErrorViewResolver.kt diff --git a/src/main/kotlin/org/kotlink/ui/ViewUtils.kt b/server-spring/src/main/kotlin/org/kotlink/ui/ViewUtils.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/ViewUtils.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/ViewUtils.kt diff --git a/src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt b/server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt similarity index 98% rename from src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt index 3ae90a4..1db59ae 100644 --- a/src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt +++ b/server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiController.kt @@ -53,8 +53,7 @@ class AliasUiController( @GetMapping("/new") @SelectView(UiView.NEW_ALIAS) fun newAlias(model: Model): String { - model.addFormAttributes(AliasUiValue() - .apply { ownerAccountEmail = currentUser.getEmail() }) + model.addFormAttributes(AliasUiValue().apply { ownerAccountEmail = currentUser.getEmail() }) return "alias/new" } diff --git a/src/main/kotlin/org/kotlink/ui/alias/AliasUiValue.kt b/server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiValue.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/alias/AliasUiValue.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiValue.kt diff --git a/src/main/kotlin/org/kotlink/ui/alias/AliasUiValueConverter.kt b/server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiValueConverter.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/alias/AliasUiValueConverter.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/alias/AliasUiValueConverter.kt diff --git a/src/main/kotlin/org/kotlink/ui/help/SetupInstructionsUiController.kt b/server-spring/src/main/kotlin/org/kotlink/ui/help/SetupInstructionsUiController.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/help/SetupInstructionsUiController.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/help/SetupInstructionsUiController.kt diff --git a/src/main/kotlin/org/kotlink/ui/mvcExtensions.kt b/server-spring/src/main/kotlin/org/kotlink/ui/mvcExtensions.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/mvcExtensions.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/mvcExtensions.kt diff --git a/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt b/server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt similarity index 95% rename from src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt index 9b45c56..ec40fb5 100644 --- a/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt +++ b/server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiController.kt @@ -10,6 +10,7 @@ import org.kotlink.ui.addErrorMessage import org.kotlink.ui.addSuccessMessage import org.springframework.stereotype.Controller import org.springframework.ui.Model +import org.springframework.ui.set import org.springframework.validation.BindingResult import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping @@ -33,17 +34,16 @@ class NamespaceUiController( @GetMapping @SelectView(UiView.LIST_NAMESPACES) fun listNamespaces(model: Model): String { - val namespaces = namespaceService.findAll() - model.addAttribute("namespaces", namespaces) + model["namespaces"] = namespaceService.findAll() return "namespace/list" } @GetMapping("/new") @SelectView(UiView.NEW_NAMESPACE) fun newNamespace(model: Model): String { - model.addAttribute("namespace", NamespaceUiValue().apply { + model["namespace"] = NamespaceUiValue().apply { ownerAccountEmail = currentUser.getEmail() - }) + } return "namespace/new" } @@ -56,7 +56,7 @@ class NamespaceUiController( ): String { if (bindResult.hasErrors()) { logger.warn { "User input $namespaceUiValue has failed validation ${bindResult.allErrors}" } - model.addAttribute("namespace", namespaceUiValue) + model["namespace"] = namespaceUiValue return "namespace/new" } return try { diff --git a/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValue.kt b/server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValue.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValue.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValue.kt diff --git a/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValueConverter.kt b/server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValueConverter.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValueConverter.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/namespace/NamespaceUiValueConverter.kt diff --git a/src/main/kotlin/org/kotlink/ui/search/LinkSearchUiController.kt b/server-spring/src/main/kotlin/org/kotlink/ui/search/LinkSearchUiController.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/search/LinkSearchUiController.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/search/LinkSearchUiController.kt diff --git a/src/main/kotlin/org/kotlink/ui/selectedView.kt b/server-spring/src/main/kotlin/org/kotlink/ui/selectedView.kt similarity index 100% rename from src/main/kotlin/org/kotlink/ui/selectedView.kt rename to server-spring/src/main/kotlin/org/kotlink/ui/selectedView.kt diff --git a/src/main/resources/application-local.yaml b/server-spring/src/main/resources/application-local.yaml similarity index 100% rename from src/main/resources/application-local.yaml rename to server-spring/src/main/resources/application-local.yaml diff --git a/src/main/resources/application-prod.yaml b/server-spring/src/main/resources/application-prod.yaml similarity index 100% rename from src/main/resources/application-prod.yaml rename to server-spring/src/main/resources/application-prod.yaml diff --git a/src/main/resources/application.yaml b/server-spring/src/main/resources/application.yaml similarity index 91% rename from src/main/resources/application.yaml rename to server-spring/src/main/resources/application.yaml index 1dfad84..0f0c2a9 100644 --- a/src/main/resources/application.yaml +++ b/server-spring/src/main/resources/application.yaml @@ -1,6 +1,10 @@ spring: profiles: active: local + mvc: + hiddenmethod: + filter: + enabled: true datasource: driver-class-name: org.postgresql.Driver url: jdbc:postgresql://localhost:55432/kotlink @@ -56,7 +60,7 @@ kotlink: security: oauth: allowed-email-regex: .* - allowed-emails: [] + allowed-emails: [ ] restrict-edits-to-ip-regex: .* restrict-edits-to-ip-cidrs: 0.0.0.0/0,::/0 logging: @@ -70,4 +74,4 @@ management: endpoints: web: exposure: - include: ["health", "metrics", "prometheus"] \ No newline at end of file + include: [ "health", "metrics", "prometheus" ] \ No newline at end of file diff --git a/src/main/resources/banner.txt b/server-spring/src/main/resources/banner.txt similarity index 100% rename from src/main/resources/banner.txt rename to server-spring/src/main/resources/banner.txt diff --git a/server-spring/src/main/resources/db/migration/V1__add_namespace_table.sql b/server-spring/src/main/resources/db/migration/V1__add_namespace_table.sql new file mode 100644 index 0000000..82256dc --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V1__add_namespace_table.sql @@ -0,0 +1,13 @@ +CREATE SEQUENCE namespace_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE CACHE 1; + +CREATE TABLE namespace +( + id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('namespace_id_seq'::regclass), + keyword CHARACTER VARYING(128) NOT NULL + CONSTRAINT ns_kwd_unique UNIQUE, + description CHARACTER VARYING(512) NOT NULL DEFAULT '' +); \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V2__add_alias_table.sql b/server-spring/src/main/resources/db/migration/V2__add_alias_table.sql new file mode 100644 index 0000000..dab9c71 --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V2__add_alias_table.sql @@ -0,0 +1,16 @@ +CREATE SEQUENCE alias_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE CACHE 1; + +CREATE TABLE alias +( + id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('alias_id_seq'::regclass), + namespace_id BIGINT NOT NULL REFERENCES namespace ON DELETE RESTRICT, + link CHARACTER VARYING(128) NOT NULL, + redirect_url CHARACTER VARYING(2048) NOT NULL, + description CHARACTER VARYING(512) NOT NULL DEFAULT '' +); + +CREATE UNIQUE INDEX alias_ns_id_link on alias (namespace_id, link); \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V3__add_user_account_table.sql b/server-spring/src/main/resources/db/migration/V3__add_user_account_table.sql new file mode 100644 index 0000000..3ebfa45 --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V3__add_user_account_table.sql @@ -0,0 +1,13 @@ +CREATE SEQUENCE user_account_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE CACHE 1; + +CREATE TABLE user_account +( + id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('user_account_id_seq'::regclass), + email CHARACTER VARYING(1024) NOT NULL +); + +CREATE UNIQUE INDEX user_account_email ON user_account (email); \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V4__add_api_secret_table.sql b/server-spring/src/main/resources/db/migration/V4__add_api_secret_table.sql new file mode 100644 index 0000000..671cbcf --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V4__add_api_secret_table.sql @@ -0,0 +1,15 @@ +CREATE SEQUENCE api_secret_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE CACHE 1; + +CREATE TABLE api_secret +( + id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('api_secret_id_seq'::regclass), + secret CHARACTER VARYING(64) NOT NULL + CONSTRAINT api_secret_unique UNIQUE, + user_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT +); + +CREATE UNIQUE INDEX api_secret_account_id on api_secret (user_account_id); \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V5__add_owner_account_id_column.sql b/server-spring/src/main/resources/db/migration/V5__add_owner_account_id_column.sql new file mode 100644 index 0000000..f8c1253 --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V5__add_owner_account_id_column.sql @@ -0,0 +1,5 @@ +ALTER TABLE namespace + ADD COLUMN owner_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT; + +ALTER TABLE alias + ADD COLUMN owner_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT; \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V6__add_default_namespace.sql b/server-spring/src/main/resources/db/migration/V6__add_default_namespace.sql new file mode 100644 index 0000000..29d3b41 --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V6__add_default_namespace.sql @@ -0,0 +1,8 @@ +-- a fake user account that will own "default" namespace +INSERT INTO user_account (email) +VALUES ('admin@kotlink.org'); + +-- the "default" (has empty keyword) namespace for aliases +INSERT INTO namespace (keyword, description, owner_account_id) +VALUES ('', 'Namespace for links without a common prefix', + (SELECT id FROM user_account WHERE email = 'admin@kotlink.org')); \ No newline at end of file diff --git a/server-spring/src/main/resources/db/migration/V7__add_spring_session_tables.sql b/server-spring/src/main/resources/db/migration/V7__add_spring_session_tables.sql new file mode 100644 index 0000000..4f49c68 --- /dev/null +++ b/server-spring/src/main/resources/db/migration/V7__add_spring_session_tables.sql @@ -0,0 +1,26 @@ +CREATE TABLE SPRING_SESSION +( + PRIMARY_ID CHAR(36) NOT NULL, + SESSION_ID CHAR(36) NOT NULL, + CREATION_TIME BIGINT NOT NULL, + LAST_ACCESS_TIME BIGINT NOT NULL, + MAX_INACTIVE_INTERVAL INT NOT NULL, + EXPIRY_TIME BIGINT NOT NULL, + PRINCIPAL_NAME VARCHAR(100), + CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID) +); + +CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID); +CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME); +CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME); + +CREATE TABLE SPRING_SESSION_ATTRIBUTES +( + SESSION_PRIMARY_ID CHAR(36) NOT NULL, + ATTRIBUTE_NAME VARCHAR(200) NOT NULL, + ATTRIBUTE_BYTES BYTEA NOT NULL, + CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME), + CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION (PRIMARY_ID) ON DELETE CASCADE +); + +CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID); \ No newline at end of file diff --git a/src/main/resources/db/migration/V8__add_full_link_field.sql b/server-spring/src/main/resources/db/migration/V8__add_full_link_field.sql similarity index 58% rename from src/main/resources/db/migration/V8__add_full_link_field.sql rename to server-spring/src/main/resources/db/migration/V8__add_full_link_field.sql index 683ba88..b0308ac 100644 --- a/src/main/resources/db/migration/V8__add_full_link_field.sql +++ b/server-spring/src/main/resources/db/migration/V8__add_full_link_field.sql @@ -1,10 +1,9 @@ ALTER TABLE alias -ADD COLUMN full_link CHARACTER VARYING(256) NULL; + ADD COLUMN full_link CHARACTER VARYING(256) NULL; UPDATE alias -SET full_link = trim(concat(namespace.keyword, ' ', alias.link)) -FROM namespace +SET full_link = trim(concat(namespace.keyword, ' ', alias.link)) FROM namespace WHERE alias.namespace_id = namespace.id; ALTER TABLE alias -ALTER COLUMN full_link SET NOT NULL; \ No newline at end of file + ALTER COLUMN full_link SET NOT NULL; \ No newline at end of file diff --git a/src/main/resources/logback-access.xml b/server-spring/src/main/resources/logback-access.xml similarity index 100% rename from src/main/resources/logback-access.xml rename to server-spring/src/main/resources/logback-access.xml diff --git a/src/main/resources/logback.xml b/server-spring/src/main/resources/logback.xml similarity index 100% rename from src/main/resources/logback.xml rename to server-spring/src/main/resources/logback.xml diff --git a/src/main/resources/static/css/main.css b/server-spring/src/main/resources/static/css/main.css similarity index 100% rename from src/main/resources/static/css/main.css rename to server-spring/src/main/resources/static/css/main.css diff --git a/src/main/resources/static/css/material-table.css b/server-spring/src/main/resources/static/css/material-table.css similarity index 97% rename from src/main/resources/static/css/material-table.css rename to server-spring/src/main/resources/static/css/material-table.css index 4fdacec..3e201cd 100644 --- a/src/main/resources/static/css/material-table.css +++ b/server-spring/src/main/resources/static/css/material-table.css @@ -24,11 +24,11 @@ } /*.mdl-data-table tbody tr.is-selected {*/ - /*background-color: #e0e0e0;*/ +/*background-color: #e0e0e0;*/ /*}*/ /*.mdl-data-table tbody tr:hover {*/ - /*background-color: #eeeeee;*/ +/*background-color: #eeeeee;*/ /*}*/ .mdl-data-table td, .mdl-data-table th { diff --git a/src/main/resources/static/favicon.ico b/server-spring/src/main/resources/static/favicon.ico similarity index 100% rename from src/main/resources/static/favicon.ico rename to server-spring/src/main/resources/static/favicon.ico diff --git a/src/main/resources/static/img/extension-options-chrome.png b/server-spring/src/main/resources/static/img/extension-options-chrome.png similarity index 100% rename from src/main/resources/static/img/extension-options-chrome.png rename to server-spring/src/main/resources/static/img/extension-options-chrome.png diff --git a/src/main/resources/static/img/extension-options-ff.png b/server-spring/src/main/resources/static/img/extension-options-ff.png similarity index 100% rename from src/main/resources/static/img/extension-options-ff.png rename to server-spring/src/main/resources/static/img/extension-options-ff.png diff --git a/src/main/resources/static/img/logo.png b/server-spring/src/main/resources/static/img/logo.png similarity index 100% rename from src/main/resources/static/img/logo.png rename to server-spring/src/main/resources/static/img/logo.png diff --git a/src/main/resources/static/js/main.js b/server-spring/src/main/resources/static/js/main.js similarity index 100% rename from src/main/resources/static/js/main.js rename to server-spring/src/main/resources/static/js/main.js diff --git a/src/main/resources/static/js/ready.js b/server-spring/src/main/resources/static/js/ready.js similarity index 100% rename from src/main/resources/static/js/ready.js rename to server-spring/src/main/resources/static/js/ready.js diff --git a/src/main/resources/templates/alias/_form.html b/server-spring/src/main/resources/templates/alias/_form.html similarity index 100% rename from src/main/resources/templates/alias/_form.html rename to server-spring/src/main/resources/templates/alias/_form.html diff --git a/src/main/resources/templates/alias/edit.html b/server-spring/src/main/resources/templates/alias/edit.html similarity index 100% rename from src/main/resources/templates/alias/edit.html rename to server-spring/src/main/resources/templates/alias/edit.html diff --git a/src/main/resources/templates/alias/list.html b/server-spring/src/main/resources/templates/alias/list.html similarity index 100% rename from src/main/resources/templates/alias/list.html rename to server-spring/src/main/resources/templates/alias/list.html diff --git a/src/main/resources/templates/alias/new.html b/server-spring/src/main/resources/templates/alias/new.html similarity index 100% rename from src/main/resources/templates/alias/new.html rename to server-spring/src/main/resources/templates/alias/new.html diff --git a/src/main/resources/templates/error/401.html b/server-spring/src/main/resources/templates/error/401.html similarity index 100% rename from src/main/resources/templates/error/401.html rename to server-spring/src/main/resources/templates/error/401.html diff --git a/src/main/resources/templates/error/404.html b/server-spring/src/main/resources/templates/error/404.html similarity index 100% rename from src/main/resources/templates/error/404.html rename to server-spring/src/main/resources/templates/error/404.html diff --git a/src/main/resources/templates/error/4xx.html b/server-spring/src/main/resources/templates/error/4xx.html similarity index 100% rename from src/main/resources/templates/error/4xx.html rename to server-spring/src/main/resources/templates/error/4xx.html diff --git a/src/main/resources/templates/error/500.html b/server-spring/src/main/resources/templates/error/500.html similarity index 100% rename from src/main/resources/templates/error/500.html rename to server-spring/src/main/resources/templates/error/500.html diff --git a/src/main/resources/templates/fragment/_error_dialog.html b/server-spring/src/main/resources/templates/fragment/_error_dialog.html similarity index 100% rename from src/main/resources/templates/fragment/_error_dialog.html rename to server-spring/src/main/resources/templates/fragment/_error_dialog.html diff --git a/src/main/resources/templates/fragment/_pagination.html b/server-spring/src/main/resources/templates/fragment/_pagination.html similarity index 100% rename from src/main/resources/templates/fragment/_pagination.html rename to server-spring/src/main/resources/templates/fragment/_pagination.html diff --git a/src/main/resources/templates/fragment/_success_dialog.html b/server-spring/src/main/resources/templates/fragment/_success_dialog.html similarity index 100% rename from src/main/resources/templates/fragment/_success_dialog.html rename to server-spring/src/main/resources/templates/fragment/_success_dialog.html diff --git a/src/main/resources/templates/help/setup_instructions.html b/server-spring/src/main/resources/templates/help/setup_instructions.html similarity index 100% rename from src/main/resources/templates/help/setup_instructions.html rename to server-spring/src/main/resources/templates/help/setup_instructions.html diff --git a/src/main/resources/templates/layout.html b/server-spring/src/main/resources/templates/layout.html similarity index 100% rename from src/main/resources/templates/layout.html rename to server-spring/src/main/resources/templates/layout.html diff --git a/src/main/resources/templates/login.html b/server-spring/src/main/resources/templates/login.html similarity index 100% rename from src/main/resources/templates/login.html rename to server-spring/src/main/resources/templates/login.html diff --git a/src/main/resources/templates/namespace/_form.html b/server-spring/src/main/resources/templates/namespace/_form.html similarity index 100% rename from src/main/resources/templates/namespace/_form.html rename to server-spring/src/main/resources/templates/namespace/_form.html diff --git a/src/main/resources/templates/namespace/edit.html b/server-spring/src/main/resources/templates/namespace/edit.html similarity index 100% rename from src/main/resources/templates/namespace/edit.html rename to server-spring/src/main/resources/templates/namespace/edit.html diff --git a/src/main/resources/templates/namespace/list.html b/server-spring/src/main/resources/templates/namespace/list.html similarity index 100% rename from src/main/resources/templates/namespace/list.html rename to server-spring/src/main/resources/templates/namespace/list.html diff --git a/src/main/resources/templates/namespace/new.html b/server-spring/src/main/resources/templates/namespace/new.html similarity index 100% rename from src/main/resources/templates/namespace/new.html rename to server-spring/src/main/resources/templates/namespace/new.html diff --git a/src/main/resources/templates/search/results.html b/server-spring/src/main/resources/templates/search/results.html similarity index 100% rename from src/main/resources/templates/search/results.html rename to server-spring/src/main/resources/templates/search/results.html diff --git a/src/test/kotlin/org/kotlink/DefaultNamespaceAppropriatorTest.kt b/server-spring/src/test/kotlin/org/kotlink/DefaultNamespaceAppropriatorTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/DefaultNamespaceAppropriatorTest.kt rename to server-spring/src/test/kotlin/org/kotlink/DefaultNamespaceAppropriatorTest.kt diff --git a/src/test/kotlin/org/kotlink/MockMvcExtras.kt b/server-spring/src/test/kotlin/org/kotlink/MockMvcExtras.kt similarity index 100% rename from src/test/kotlin/org/kotlink/MockMvcExtras.kt rename to server-spring/src/test/kotlin/org/kotlink/MockMvcExtras.kt diff --git a/src/test/kotlin/org/kotlink/WithMockMvcSetUp.kt b/server-spring/src/test/kotlin/org/kotlink/WithMockMvcSetUp.kt similarity index 100% rename from src/test/kotlin/org/kotlink/WithMockMvcSetUp.kt rename to server-spring/src/test/kotlin/org/kotlink/WithMockMvcSetUp.kt diff --git a/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionControllerTest.kt b/server-spring/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionControllerTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/api/resolution/LinkResolutionControllerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionControllerTest.kt diff --git a/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionServiceTest.kt b/server-spring/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionServiceTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/api/resolution/LinkResolutionServiceTest.kt rename to server-spring/src/test/kotlin/org/kotlink/api/resolution/LinkResolutionServiceTest.kt diff --git a/src/test/kotlin/org/kotlink/api/resolution/OpenSearchSuggestionsSerializerTest.kt b/server-spring/src/test/kotlin/org/kotlink/api/resolution/OpenSearchSuggestionsSerializerTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/api/resolution/OpenSearchSuggestionsSerializerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/api/resolution/OpenSearchSuggestionsSerializerTest.kt diff --git a/src/test/kotlin/org/kotlink/core/CurrentUserTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/CurrentUserTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/CurrentUserTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/CurrentUserTest.kt diff --git a/src/test/kotlin/org/kotlink/core/PageTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/PageTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/PageTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/PageTest.kt diff --git a/src/test/kotlin/org/kotlink/core/account/UserAccountServiceTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/account/UserAccountServiceTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/account/UserAccountServiceTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/account/UserAccountServiceTest.kt diff --git a/src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt index 4408582..a595056 100644 --- a/src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt +++ b/server-spring/src/test/kotlin/org/kotlink/core/alias/AliasServiceTest.kt @@ -5,9 +5,9 @@ import com.nhaarman.mockitokotlin2.argThat import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.whenever import org.amshove.kluent.shouldBe +import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldContain import org.amshove.kluent.shouldContainAll -import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldThrow import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializerTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializerTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/cache/JacksonCacheValueSerializerTest.kt diff --git a/src/test/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspectTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspectTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspectTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/exposed/DatabaseExceptionAspectTest.kt diff --git a/src/test/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspectTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspectTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspectTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/ipblock/EditOpIpBasedRestrictingAspectTest.kt diff --git a/src/test/kotlin/org/kotlink/core/namespace/NamespaceServiceTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/namespace/NamespaceServiceTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/namespace/NamespaceServiceTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/namespace/NamespaceServiceTest.kt diff --git a/src/test/kotlin/org/kotlink/core/oauth/GrantedAuthoritiesMapperTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/oauth/GrantedAuthoritiesMapperTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/oauth/GrantedAuthoritiesMapperTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/oauth/GrantedAuthoritiesMapperTest.kt diff --git a/src/test/kotlin/org/kotlink/core/secret/ApiSecretServiceTest.kt b/server-spring/src/test/kotlin/org/kotlink/core/secret/ApiSecretServiceTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/core/secret/ApiSecretServiceTest.kt rename to server-spring/src/test/kotlin/org/kotlink/core/secret/ApiSecretServiceTest.kt diff --git a/src/test/kotlin/org/kotlink/mockMvcExtensions.kt b/server-spring/src/test/kotlin/org/kotlink/mockMvcExtensions.kt similarity index 100% rename from src/test/kotlin/org/kotlink/mockMvcExtensions.kt rename to server-spring/src/test/kotlin/org/kotlink/mockMvcExtensions.kt diff --git a/src/test/kotlin/org/kotlink/testConstants.kt b/server-spring/src/test/kotlin/org/kotlink/testConstants.kt similarity index 100% rename from src/test/kotlin/org/kotlink/testConstants.kt rename to server-spring/src/test/kotlin/org/kotlink/testConstants.kt diff --git a/src/test/kotlin/org/kotlink/ui/UiErrorViewResolverTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/UiErrorViewResolverTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/ui/UiErrorViewResolverTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/UiErrorViewResolverTest.kt diff --git a/src/test/kotlin/org/kotlink/ui/UiTestConfig.kt b/server-spring/src/test/kotlin/org/kotlink/ui/UiTestConfig.kt similarity index 100% rename from src/test/kotlin/org/kotlink/ui/UiTestConfig.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/UiTestConfig.kt diff --git a/src/test/kotlin/org/kotlink/ui/ViewUtilsTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/ViewUtilsTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/ui/ViewUtilsTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/ViewUtilsTest.kt diff --git a/src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt similarity index 98% rename from src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt index 80d8b70..98407aa 100644 --- a/src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt +++ b/server-spring/src/test/kotlin/org/kotlink/ui/alias/AliasUiControllerTest.kt @@ -42,9 +42,9 @@ class AliasUiControllerTest( @TestConfiguration class Config { @Bean - fun uiValueConverter() = AliasUiValueConverter(mock { - on { findByUserEmail(any()) } doReturn TEST_ACCOUNT - }) + fun uiValueConverter() = AliasUiValueConverter( + mock { on { findByUserEmail(any()) } doReturn TEST_ACCOUNT } + ) } @Test diff --git a/src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt similarity index 98% rename from src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt index 6ce476c..edf1837 100644 --- a/src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt +++ b/server-spring/src/test/kotlin/org/kotlink/ui/namespace/NamespaceUiControllerTest.kt @@ -43,9 +43,9 @@ class NamespaceUiControllerTest( @TestConfiguration class Config { @Bean - fun uiValueConverter() = NamespaceUiValueConverter(mock { - on { findByUserEmail(any()) } doReturn TEST_ACCOUNT - }) + fun uiValueConverter() = NamespaceUiValueConverter( + mock { on { findByUserEmail(any()) } doReturn TEST_ACCOUNT } + ) } @Test diff --git a/src/test/kotlin/org/kotlink/ui/search/LinkSearchUiControllerTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/search/LinkSearchUiControllerTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/ui/search/LinkSearchUiControllerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/search/LinkSearchUiControllerTest.kt diff --git a/src/test/kotlin/org/kotlink/ui/secret/SetupInstructionsUiControllerTest.kt b/server-spring/src/test/kotlin/org/kotlink/ui/secret/SetupInstructionsUiControllerTest.kt similarity index 100% rename from src/test/kotlin/org/kotlink/ui/secret/SetupInstructionsUiControllerTest.kt rename to server-spring/src/test/kotlin/org/kotlink/ui/secret/SetupInstructionsUiControllerTest.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 9afa92b..e6886d1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,16 +1,5 @@ rootProject.name = "kotlink" -pluginManagement { - repositories { - gradlePluginPortal() - } - resolutionStrategy { - eachPlugin { - if (requested.id.id.startsWith("org.jetbrains.kotlin")) { - gradle.rootProject.extra["kotlinVersion"]?.let { useVersion(it as String) } - } else if (requested.id.id == "org.springframework.boot") { - gradle.rootProject.extra["springBootVersion"]?.let { useVersion(it as String) } - } - } - } -} +include( + "server-spring" +) diff --git a/src/main/resources/db/migration/V1__add_namespace_table.sql b/src/main/resources/db/migration/V1__add_namespace_table.sql deleted file mode 100644 index b996482..0000000 --- a/src/main/resources/db/migration/V1__add_namespace_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE SEQUENCE namespace_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -CREATE TABLE namespace ( - id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('namespace_id_seq'::regclass), - keyword CHARACTER VARYING(128) NOT NULL CONSTRAINT ns_kwd_unique UNIQUE, - description CHARACTER VARYING(512) NOT NULL DEFAULT '' -); \ No newline at end of file diff --git a/src/main/resources/db/migration/V2__add_alias_table.sql b/src/main/resources/db/migration/V2__add_alias_table.sql deleted file mode 100644 index 2166029..0000000 --- a/src/main/resources/db/migration/V2__add_alias_table.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE SEQUENCE alias_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -CREATE TABLE alias ( - id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('alias_id_seq'::regclass), - namespace_id BIGINT NOT NULL REFERENCES namespace ON DELETE RESTRICT, - link CHARACTER VARYING(128) NOT NULL, - redirect_url CHARACTER VARYING(2048) NOT NULL, - description CHARACTER VARYING(512) NOT NULL DEFAULT '' -); - -CREATE UNIQUE INDEX alias_ns_id_link on alias (namespace_id, link); \ No newline at end of file diff --git a/src/main/resources/db/migration/V3__add_user_account_table.sql b/src/main/resources/db/migration/V3__add_user_account_table.sql deleted file mode 100644 index 57a942a..0000000 --- a/src/main/resources/db/migration/V3__add_user_account_table.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE SEQUENCE user_account_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -CREATE TABLE user_account ( - id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('user_account_id_seq'::regclass), - email CHARACTER VARYING(1024) NOT NULL -); - -CREATE UNIQUE INDEX user_account_email ON user_account (email); \ No newline at end of file diff --git a/src/main/resources/db/migration/V4__add_api_secret_table.sql b/src/main/resources/db/migration/V4__add_api_secret_table.sql deleted file mode 100644 index 78c2a57..0000000 --- a/src/main/resources/db/migration/V4__add_api_secret_table.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE SEQUENCE api_secret_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -CREATE TABLE api_secret ( - id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('api_secret_id_seq'::regclass), - secret CHARACTER VARYING(64) NOT NULL CONSTRAINT api_secret_unique UNIQUE, - user_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT -); - -CREATE UNIQUE INDEX api_secret_account_id on api_secret (user_account_id); \ No newline at end of file diff --git a/src/main/resources/db/migration/V5__add_owner_account_id_column.sql b/src/main/resources/db/migration/V5__add_owner_account_id_column.sql deleted file mode 100644 index d211787..0000000 --- a/src/main/resources/db/migration/V5__add_owner_account_id_column.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE namespace -ADD COLUMN owner_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT; - -ALTER TABLE alias -ADD COLUMN owner_account_id BIGINT NOT NULL REFERENCES user_account ON DELETE RESTRICT; \ No newline at end of file diff --git a/src/main/resources/db/migration/V6__add_default_namespace.sql b/src/main/resources/db/migration/V6__add_default_namespace.sql deleted file mode 100644 index 8730d24..0000000 --- a/src/main/resources/db/migration/V6__add_default_namespace.sql +++ /dev/null @@ -1,6 +0,0 @@ --- a fake user account that will own "default" namespace -INSERT INTO user_account (email) VALUES ('admin@kotlink.org'); - --- the "default" (has empty keyword) namespace for aliases -INSERT INTO namespace (keyword, description, owner_account_id) -VALUES ('', 'Namespace for links without a common prefix', (SELECT id FROM user_account WHERE email = 'admin@kotlink.org')); \ No newline at end of file diff --git a/src/main/resources/db/migration/V7__add_spring_session_tables.sql b/src/main/resources/db/migration/V7__add_spring_session_tables.sql deleted file mode 100644 index c152f70..0000000 --- a/src/main/resources/db/migration/V7__add_spring_session_tables.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE SPRING_SESSION ( - PRIMARY_ID CHAR(36) NOT NULL, - SESSION_ID CHAR(36) NOT NULL, - CREATION_TIME BIGINT NOT NULL, - LAST_ACCESS_TIME BIGINT NOT NULL, - MAX_INACTIVE_INTERVAL INT NOT NULL, - EXPIRY_TIME BIGINT NOT NULL, - PRINCIPAL_NAME VARCHAR(100), - CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID) -); - -CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID); -CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME); -CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME); - -CREATE TABLE SPRING_SESSION_ATTRIBUTES ( - SESSION_PRIMARY_ID CHAR(36) NOT NULL, - ATTRIBUTE_NAME VARCHAR(200) NOT NULL, - ATTRIBUTE_BYTES BYTEA NOT NULL, - CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME), - CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE -); - -CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID); \ No newline at end of file