From 2ff5250f66eae684e61f4a434e64cf8de84b410e Mon Sep 17 00:00:00 2001 From: Fabien Crespel Date: Wed, 27 Dec 2023 23:30:13 +0100 Subject: [PATCH] Upgrade to Spring Boot 3 (#141) --- .github/workflows/build.yml | 4 +- .github/workflows/codeql.yml | 29 +++++---- pom.xml | 40 ++++-------- src/main/appengine/app.yaml | 8 +-- .../appengine/files/application.example.yml | 10 --- src/main/docker/Dockerfile | 3 +- .../crespel/karaplan/config/CacheConfig.java | 16 ++--- .../karaplan/config/JacksonConfig.java | 6 +- .../karaplan/config/SecurityConfig.java | 44 ++++++------- .../me/crespel/karaplan/domain/Artist.java | 20 +++--- .../me/crespel/karaplan/domain/Playlist.java | 32 +++++----- .../karaplan/domain/PlaylistComment.java | 22 +++---- .../crespel/karaplan/domain/PlaylistSong.java | 26 ++++---- .../java/me/crespel/karaplan/domain/Song.java | 30 ++++----- .../crespel/karaplan/domain/SongComment.java | 22 +++---- .../me/crespel/karaplan/domain/SongVote.java | 24 +++---- .../java/me/crespel/karaplan/domain/User.java | 20 +++--- .../model/karafunweb/KarafunWebResponse.java | 6 +- .../crespel/karaplan/web/HomeController.java | 11 +++- .../web/api/v1/PlaylistController.java | 2 +- .../karaplan/web/api/v1/SongController.java | 2 +- src/main/nodejs/src/index.html | 4 +- src/main/resources/application.yml | 23 +++---- src/main/resources/ehcache.xml | 64 ++++++------------- src/main/resources/logback-spring.xml | 19 +++--- 25 files changed, 220 insertions(+), 267 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 46efa96..071ad84 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: temurin cache: maven settings-path: ${{ github.workspace }}/.mvn diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2c0ae61..002dcec 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -4,7 +4,6 @@ on: push: branches: [ "master" ] pull_request: - # The branches below must be a subset of the branches above branches: [ "master" ] schedule: - cron: '36 13 * * 3' @@ -21,31 +20,39 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'java', 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + language: [ 'java-kotlin', 'javascript-typescript' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: temurin # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -54,10 +61,10 @@ jobs: # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/pom.xml b/pom.xml index 521e817..8f5d720 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.18 + 3.1.7 @@ -19,7 +19,7 @@ - 11 + 17 me.crespel.karaplan.KaraplanApplication ${basedir}/src/main/nodejs ${project.build.directory}/nodejs @@ -44,8 +44,8 @@ v18.19.0 10.2.3 1.0.1 - 3.7.4 - 1.7.0 + 4.9.0 + 2.3.0 @@ -86,14 +86,6 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.boot - spring-boot-starter-data-rest - org.springframework.boot spring-boot-starter-oauth2-client @@ -129,17 +121,13 @@ org.springframework.session - spring-session-data-redis + spring-session-jdbc org.springdoc - springdoc-openapi-security - - - org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui @@ -148,8 +136,9 @@ commons-csv - net.sf.ehcache + org.ehcache ehcache + jakarta com.google.guava @@ -161,7 +150,7 @@ com.fasterxml.jackson.datatype - jackson-datatype-hibernate5 + jackson-datatype-hibernate6 org.projectlombok @@ -236,12 +225,7 @@ org.springdoc - springdoc-openapi-security - ${springdoc.version} - - - org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui ${springdoc.version} @@ -262,8 +246,8 @@ - pl.project13.maven - git-commit-id-plugin + io.github.git-commit-id + git-commit-id-maven-plugin false diff --git a/src/main/appengine/app.yaml b/src/main/appengine/app.yaml index 76524c8..3ac4b65 100644 --- a/src/main/appengine/app.yaml +++ b/src/main/appengine/app.yaml @@ -1,4 +1,4 @@ -runtime: java11 +runtime: java17 instance_class: F4 entrypoint: java -jar karaplan-thin.jar handlers: @@ -20,7 +20,7 @@ handlers: secure: always script: auto env_variables: - JAVA_TOOL_OPTIONS: "-XX:MaxRAM=1024m -Xms512m -Xmx512m -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -agentpath:/opt/cdbg/cdbg_java_agent.so=--log_dir=/var/log" + JAVA_TOOL_OPTIONS: "-XX:MaxRAM=1024m -Xms512m -Xmx512m -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1" SPRING_PROFILES_ACTIVE: "gcp,appengine" automatic_scaling: min_instances: 0 @@ -34,7 +34,3 @@ automatic_scaling: target_cpu_utilization: 0.9 inbound_services: - warmup -# Uncomment and configure the following block to allow access to VPC resources such as Memorystore (Redis) -# See: https://cloud.google.com/vpc/docs/configure-serverless-vpc-access -#vpc_access_connector: -# name: "projects//locations//connectors/" diff --git a/src/main/appengine/files/application.example.yml b/src/main/appengine/files/application.example.yml index 3bfaa89..d14fcc3 100644 --- a/src/main/appengine/files/application.example.yml +++ b/src/main/appengine/files/application.example.yml @@ -3,8 +3,6 @@ spring: username: karaplan password: "toComplete" url: "jdbc:mysql:///karaplan?useSSL=false&socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance=toComplete" - jpa: - database-platform: org.hibernate.dialect.MySQL5InnoDBDialect security: oauth2: client: @@ -18,11 +16,3 @@ spring: facebook: client-id: "toComplete" client-secret: "toComplete" - session: - store-type: redis - redis: - configure-action: none - redis: - host: "toComplete" -server: - port: ${PORT} diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index cc6e7d6..73bf400 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,6 +1,5 @@ -FROM eclipse-temurin:11-jre +FROM eclipse-temurin:17-jre WORKDIR @docker.app.directory@ -VOLUME /tmp # Copy files COPY WEB-INF/lib ./lib diff --git a/src/main/java/me/crespel/karaplan/config/CacheConfig.java b/src/main/java/me/crespel/karaplan/config/CacheConfig.java index bed79de..ec41814 100644 --- a/src/main/java/me/crespel/karaplan/config/CacheConfig.java +++ b/src/main/java/me/crespel/karaplan/config/CacheConfig.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.lang.reflect.Method; -import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.CachingConfigurer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator; @@ -12,7 +12,7 @@ @Configuration @EnableCaching -public class CacheConfig extends CachingConfigurerSupport { +public class CacheConfig implements CachingConfigurer { @Bean public KeyGenerator keyGenerator() { @@ -23,31 +23,31 @@ public static class MethodAndArgsKeyGenerator implements KeyGenerator { @Override public Object generate(Object target, Method method, Object... params) { - return new MethodAndArgsKey(method, SimpleKeyGenerator.generateKey(params)); + return new MethodAndArgsKey(method.toString(), SimpleKeyGenerator.generateKey(params)); } } public static class MethodAndArgsKey implements Serializable { - private Method method; + private String methodKey; private Object paramsKey; - public MethodAndArgsKey(Method method, Object paramsKey) { - this.method = method; + public MethodAndArgsKey(String methodKey, Object paramsKey) { + this.methodKey = methodKey; this.paramsKey = paramsKey; } @Override public boolean equals(Object other) { return this == other || (other instanceof MethodAndArgsKey && - this.method.equals(((MethodAndArgsKey)other).method) && + this.methodKey.equals(((MethodAndArgsKey)other).methodKey) && this.paramsKey.equals(((MethodAndArgsKey)other).paramsKey)); } @Override public int hashCode() { - return 31 * method.hashCode() + paramsKey.hashCode(); + return 31 * methodKey.hashCode() + paramsKey.hashCode(); } } diff --git a/src/main/java/me/crespel/karaplan/config/JacksonConfig.java b/src/main/java/me/crespel/karaplan/config/JacksonConfig.java index ca9ac6d..fc29e1c 100644 --- a/src/main/java/me/crespel/karaplan/config/JacksonConfig.java +++ b/src/main/java/me/crespel/karaplan/config/JacksonConfig.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; +import com.fasterxml.jackson.datatype.hibernate6.Hibernate6Module; @Configuration public class JacksonConfig { @@ -25,8 +25,8 @@ public Module simpleModule() { @Bean public Module hibernateModule() { - Hibernate5Module module = new Hibernate5Module(); - module.disable(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION); + Hibernate6Module module = new Hibernate6Module(); + module.disable(Hibernate6Module.Feature.USE_TRANSIENT_ANNOTATION); return module; } diff --git a/src/main/java/me/crespel/karaplan/config/SecurityConfig.java b/src/main/java/me/crespel/karaplan/config/SecurityConfig.java index 63a4831..e8555e1 100644 --- a/src/main/java/me/crespel/karaplan/config/SecurityConfig.java +++ b/src/main/java/me/crespel/karaplan/config/SecurityConfig.java @@ -13,6 +13,7 @@ import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.csrf.CookieCsrfTokenRepository; +import org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler; import org.springframework.security.web.firewall.HttpFirewall; import org.springframework.security.web.firewall.StrictHttpFirewall; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @@ -25,34 +26,29 @@ public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + CsrfTokenRequestAttributeHandler csrfHandler = new CsrfTokenRequestAttributeHandler(); + csrfHandler.setCsrfRequestAttributeName(null); // Force loading CSRF token on every request return http - .authorizeRequests() - .antMatchers("/", "/home").permitAll() - .antMatchers("/**/*.css", "/**/*.js", "/**/*.js.map", "/**/*.jpg", "/**/*.png", "/**/*.svg", "/**/*.ico", "/webjars/**", "/site.webmanifest", "/browserconfig.xml").permitAll() - .antMatchers("/api", "/v*/api-docs/**", "/swagger-resources/**", "/swagger-ui/**", "/csrf").permitAll() - .antMatchers("/api/v1/account/**").permitAll() - .antMatchers("/actuator/health", "/actuator/health/liveness", "/actuator/health/readiness", "/actuator/info").permitAll() - .antMatchers("/actuator/**").hasRole("ADMIN") - .antMatchers("/login").permitAll() - .antMatchers("/_ah/**").permitAll() - .anyRequest().authenticated() - .and() - .csrf() + .authorizeHttpRequests(requests -> requests + .requestMatchers("/", "/home").permitAll() + .requestMatchers("/*.css", "/*.js", "/*.js.map", "/*.jpg", "/*.png", "/*.svg", "/*.ico", "/assets/**", "/webjars/**", "/site.webmanifest", "/browserconfig.xml").permitAll() + .requestMatchers("/api", "/v3/api-docs/**", "/swagger-resources/**", "/swagger-ui/**", "/csrf").permitAll() + .requestMatchers("/api/v1/account/**").permitAll() + .requestMatchers("/actuator/health", "/actuator/health/liveness", "/actuator/health/readiness", "/actuator/info").permitAll() + .requestMatchers("/actuator/**").hasRole("ADMIN") + .requestMatchers("/login").permitAll() + .requestMatchers("/_ah/**").permitAll() + .anyRequest().authenticated()) + .csrf(csrf -> csrf .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) - .and() - .logout() - .deleteCookies("JSESSIONID") - .and() - .oauth2Login() + .csrfTokenRequestHandler(csrfHandler)) + .oauth2Login(login -> login .loginPage("/login") - .userInfoEndpoint() + .userInfoEndpoint(userinfo -> userinfo .userService(oauth2UserService()) - .oidcUserService(oidcUserService()) - .and() - .and() - .exceptionHandling() - .defaultAuthenticationEntryPointFor(new BearerTokenAuthenticationEntryPoint(), new AntPathRequestMatcher("/api/**")) - .and() + .oidcUserService(oidcUserService()))) + .exceptionHandling(handling -> handling + .defaultAuthenticationEntryPointFor(new BearerTokenAuthenticationEntryPoint(), new AntPathRequestMatcher("/api/**"))) .build(); } diff --git a/src/main/java/me/crespel/karaplan/domain/Artist.java b/src/main/java/me/crespel/karaplan/domain/Artist.java index 65b139b..11e3261 100644 --- a/src/main/java/me/crespel/karaplan/domain/Artist.java +++ b/src/main/java/me/crespel/karaplan/domain/Artist.java @@ -5,16 +5,16 @@ import java.util.Comparator; import java.util.SortedSet; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.SortComparator; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/Playlist.java b/src/main/java/me/crespel/karaplan/domain/Playlist.java index f4fb980..28dce25 100644 --- a/src/main/java/me/crespel/karaplan/domain/Playlist.java +++ b/src/main/java/me/crespel/karaplan/domain/Playlist.java @@ -6,22 +6,22 @@ import java.util.Set; import java.util.SortedSet; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.SortComparator; import org.springframework.data.annotation.CreatedBy; diff --git a/src/main/java/me/crespel/karaplan/domain/PlaylistComment.java b/src/main/java/me/crespel/karaplan/domain/PlaylistComment.java index 2c106ef..c20bd4d 100644 --- a/src/main/java/me/crespel/karaplan/domain/PlaylistComment.java +++ b/src/main/java/me/crespel/karaplan/domain/PlaylistComment.java @@ -4,17 +4,17 @@ import java.util.Calendar; import java.util.Comparator; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/PlaylistSong.java b/src/main/java/me/crespel/karaplan/domain/PlaylistSong.java index 3304da7..fea351f 100644 --- a/src/main/java/me/crespel/karaplan/domain/PlaylistSong.java +++ b/src/main/java/me/crespel/karaplan/domain/PlaylistSong.java @@ -5,19 +5,19 @@ import java.util.Comparator; import java.util.stream.Stream; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/Song.java b/src/main/java/me/crespel/karaplan/domain/Song.java index c6e1244..b13c75a 100644 --- a/src/main/java/me/crespel/karaplan/domain/Song.java +++ b/src/main/java/me/crespel/karaplan/domain/Song.java @@ -6,21 +6,21 @@ import java.util.Set; import java.util.SortedSet; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import javax.validation.constraints.NotNull; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.Transient; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.SortComparator; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/SongComment.java b/src/main/java/me/crespel/karaplan/domain/SongComment.java index 54665b7..9285719 100644 --- a/src/main/java/me/crespel/karaplan/domain/SongComment.java +++ b/src/main/java/me/crespel/karaplan/domain/SongComment.java @@ -4,17 +4,17 @@ import java.util.Calendar; import java.util.Comparator; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/SongVote.java b/src/main/java/me/crespel/karaplan/domain/SongVote.java index 972f67f..f3edbd1 100644 --- a/src/main/java/me/crespel/karaplan/domain/SongVote.java +++ b/src/main/java/me/crespel/karaplan/domain/SongVote.java @@ -4,18 +4,18 @@ import java.util.Calendar; import java.util.Comparator; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.UniqueConstraint; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.UniqueConstraint; +import jakarta.validation.constraints.NotNull; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/domain/User.java b/src/main/java/me/crespel/karaplan/domain/User.java index dadec46..988da3d 100644 --- a/src/main/java/me/crespel/karaplan/domain/User.java +++ b/src/main/java/me/crespel/karaplan/domain/User.java @@ -5,16 +5,16 @@ import java.util.Locale; import java.util.SortedSet; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.SortComparator; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/me/crespel/karaplan/model/karafunweb/KarafunWebResponse.java b/src/main/java/me/crespel/karaplan/model/karafunweb/KarafunWebResponse.java index e52806b..37a9588 100644 --- a/src/main/java/me/crespel/karaplan/model/karafunweb/KarafunWebResponse.java +++ b/src/main/java/me/crespel/karaplan/model/karafunweb/KarafunWebResponse.java @@ -1,7 +1,5 @@ package me.crespel.karaplan.model.karafunweb; -import javax.xml.bind.annotation.XmlAttribute; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; @@ -49,7 +47,7 @@ public boolean shouldDisconnect() { @Data public static class KarafunWebError { - @XmlAttribute + @JacksonXmlProperty(localName = "action", isAttribute = true) private String action; @JacksonXmlText @@ -62,7 +60,7 @@ public String toString() { @Data public static class KarafunWebMessage { - @XmlAttribute + @JacksonXmlProperty(localName = "action", isAttribute = true) private String display; @JacksonXmlText diff --git a/src/main/java/me/crespel/karaplan/web/HomeController.java b/src/main/java/me/crespel/karaplan/web/HomeController.java index 70ff3ec..8c3d28b 100644 --- a/src/main/java/me/crespel/karaplan/web/HomeController.java +++ b/src/main/java/me/crespel/karaplan/web/HomeController.java @@ -2,6 +2,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import jakarta.servlet.http.HttpServletRequest; @Controller public class HomeController { @@ -15,8 +19,11 @@ public class HomeController { "/user/**", "/about/**" }) - public String index() { - return "index"; + public ModelAndView index(HttpServletRequest req) { + ModelAndView model = new ModelAndView("index"); + model.addObject("baseUrl", ServletUriComponentsBuilder.fromRequest(req).replacePath("").toUriString()); + model.addObject("currentUrl", ServletUriComponentsBuilder.fromRequest(req).toUriString()); + return model; } } diff --git a/src/main/java/me/crespel/karaplan/web/api/v1/PlaylistController.java b/src/main/java/me/crespel/karaplan/web/api/v1/PlaylistController.java index ff1fe8a..fa0b0d0 100644 --- a/src/main/java/me/crespel/karaplan/web/api/v1/PlaylistController.java +++ b/src/main/java/me/crespel/karaplan/web/api/v1/PlaylistController.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Set; -import org.springdoc.api.annotations.ParameterObject; +import org.springdoc.core.annotations.ParameterObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.io.ByteArrayResource; diff --git a/src/main/java/me/crespel/karaplan/web/api/v1/SongController.java b/src/main/java/me/crespel/karaplan/web/api/v1/SongController.java index 4286861..d75717b 100644 --- a/src/main/java/me/crespel/karaplan/web/api/v1/SongController.java +++ b/src/main/java/me/crespel/karaplan/web/api/v1/SongController.java @@ -2,7 +2,7 @@ import java.util.Set; -import org.springdoc.api.annotations.ParameterObject; +import org.springdoc.core.annotations.ParameterObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; diff --git a/src/main/nodejs/src/index.html b/src/main/nodejs/src/index.html index 0879557..4a31904 100644 --- a/src/main/nodejs/src/index.html +++ b/src/main/nodejs/src/index.html @@ -15,8 +15,8 @@ - - + + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b56cc83..d9acdd2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,12 +1,12 @@ spring: application: name: karaplan - data: - redis: - repositories: - enabled: false - rest: - detection-strategy: annotated + cache: + jcache: + config: classpath:ehcache.xml + h2: + console: + enabled: false jackson: default-property-inclusion: non-empty jpa: @@ -14,6 +14,7 @@ spring: open-in-view: true properties: hibernate.globally_quoted_identifiers: true + hibernate.id.db_structure_naming_strategy: legacy main: lazy-initialization: true security: @@ -31,9 +32,8 @@ spring: client-id: toComplete client-secret: toComplete session: - store-type: none - redis: - namespace: karaplan:session + jdbc: + initialize-schema: always web: resources: cache: @@ -50,7 +50,7 @@ springdoc: csrf: enabled: true server: - port: 8080 + port: ${PORT:8080} compression: enabled: true error: @@ -72,9 +72,6 @@ management: health: probes: enabled: true - health: - redis: - enabled: false karaplan: karafun: remote: diff --git a/src/main/resources/ehcache.xml b/src/main/resources/ehcache.xml index 5a35bdf..1224c74 100644 --- a/src/main/resources/ehcache.xml +++ b/src/main/resources/ehcache.xml @@ -1,44 +1,20 @@ - - - - - - - - - - - - - - - - \ No newline at end of file + + + + java.lang.Object + java.lang.Object + + 24 + + + 1000 + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 36ad1fa..d049beb 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,15 +1,18 @@ - - - - + + + - - + + + + + + - - + +