From df69a71edef89c6b813883d792e803aba592ad76 Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Tue, 21 May 2024 08:22:33 +0300 Subject: [PATCH 1/3] Revert "Bump nokogiri from 1.15.6 to 1.16.5 in /docs (#482)" This reverts commit fe5985bff43b2efcc71ac45455f33e0e85bfb46d. --- docs/Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 327b25c1..831816dd 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -229,14 +229,14 @@ GEM jekyll-seo-tag (~> 2.1) minitest (5.22.3) mutex_m (0.2.0) - nokogiri (1.16.5) + nokogiri (1.15.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.5-java) + nokogiri (1.15.6-java) racc (~> 1.4) - nokogiri (1.16.5-x64-mingw32) + nokogiri (1.15.6-x64-mingw32) racc (~> 1.4) - nokogiri (1.16.5-x86-mingw32) + nokogiri (1.15.6-x86-mingw32) racc (~> 1.4) octokit (4.25.1) faraday (>= 1, < 3) From a2a5b7d39a7f98ff07ce204a5c1c4c5eb0d9a026 Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Tue, 21 May 2024 08:22:38 +0300 Subject: [PATCH 2/3] Revert "Bump rexml from 3.2.6 to 3.2.8 in /docs (#484)" This reverts commit 7793d9441d55ce15666d52273ed633230fa14022. --- docs/Gemfile.lock | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 831816dd..62b3ff5a 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -249,8 +249,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.2.6) rouge (3.30.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -265,8 +264,6 @@ GEM faraday (>= 0.17.3, < 3) simpleidn (0.2.2) unf (~> 0.1.4) - strscan (3.1.0) - strscan (3.1.0-java) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) typhoeus (1.4.1) From d7c62115483720a907c8a3f72f2ae0b21cffa677 Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Tue, 21 May 2024 08:22:45 +0300 Subject: [PATCH 3/3] Revert "Spring3 migration (#479)" This reverts commit 278554687666bc783faa087dd4ff4a076d93b099. --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 20 +++------ .devcontainer/docker-compose.yml | 6 +-- .github/workflows/codeql-analysis.yml | 13 ++---- build.gradle | 13 ++++-- config/application-devcontainer.yml | 2 +- .../wisv/events/ChConnectConfiguration.java | 42 ++++++++----------- .../ch/wisv/events/EventsApplication.java | 13 ++++++ .../java/ch/wisv/events/WebConfiguration.java | 15 ------- .../controller/DashboardIndexController.java | 1 + .../api/controller/OrderRestController.java | 3 ++ .../wisv/events/api/request/ProductDto.java | 2 +- .../events/core/model/customer/Customer.java | 11 ++--- .../events/core/model/document/Document.java | 6 +-- .../wisv/events/core/model/event/Event.java | 22 +++++----- .../wisv/events/core/model/order/Order.java | 23 +++++----- .../events/core/model/order/OrderProduct.java | 4 +- .../events/core/model/product/Product.java | 2 +- .../wisv/events/core/model/ticket/Ticket.java | 12 +++--- .../events/core/model/webhook/Webhook.java | 8 ++-- .../core/model/webhook/WebhookTask.java | 10 ++--- .../service/customer/CustomerServiceImpl.java | 6 +-- .../core/service/event/EventServiceImpl.java | 3 +- .../core/service/mail/MailServiceImpl.java | 9 ++-- .../service/product/ProductServiceImpl.java | 3 +- .../service/ticket/TicketServiceImpl.java | 2 +- .../controller/WebshopIndexController.java | 2 +- .../controller/WebshopTicketController.java | 2 +- .../webshop/service/PaymentsServiceImpl.java | 2 +- src/main/resources/dev/data/orders.json | 28 ++++--------- .../templates/admin/customers/customer.html | 6 +-- .../templates/admin/customers/index.html | 6 +-- .../templates/admin/customers/view.html | 6 +-- .../templates/admin/events/event.html | 6 +-- .../templates/admin/events/index.html | 6 +-- .../templates/admin/events/overview.html | 6 +-- .../templates/admin/events/view.html | 6 +-- src/main/resources/templates/admin/index.html | 4 +- .../templates/admin/orders/index.html | 6 +-- .../templates/admin/orders/view.html | 6 +-- .../templates/admin/products/index.html | 6 +-- .../templates/admin/products/overview.html | 6 +-- .../templates/admin/products/product.html | 6 +-- .../templates/admin/products/view.html | 6 +-- .../templates/admin/salesexport/index.html | 6 +-- .../resources/templates/admin/sidebar.html | 24 +++++++---- .../templates/admin/tasks/index.html | 6 +-- .../templates/admin/treasurer/index.html | 6 +-- .../templates/admin/webhooks/index.html | 6 +-- .../templates/admin/webhooks/view.html | 6 +-- .../templates/admin/webhooks/webhook.html | 6 +-- src/main/resources/templates/error.html | 2 +- .../resources/templates/index.example.html | 6 +-- src/main/resources/templates/sales/index.html | 2 +- .../templates/sales/scan/barcode/barcode.html | 2 +- .../templates/sales/scan/event/barcode.html | 2 +- .../templates/sales/scan/event/code.html | 4 +- .../templates/sales/scan/event/qrcode.html | 2 +- .../resources/templates/sales/scan/index.html | 4 +- .../templates/sales/sell/customer/create.html | 4 +- .../templates/sales/sell/customer/rfid.html | 4 +- .../resources/templates/sales/sell/index.html | 4 +- .../templates/sales/sell/order/cancelled.html | 4 +- .../templates/sales/sell/order/complete.html | 4 +- .../templates/sales/sell/order/index.html | 4 +- .../templates/sales/stats/event/index.html | 4 +- .../templates/sales/stats/index.html | 4 +- .../templates/sales/stats/products/index.html | 4 +- .../templates/sales/stats/sidebar.html | 6 ++- .../templates/webshop/checkout/create.html | 4 +- .../templates/webshop/checkout/customer.html | 4 +- .../templates/webshop/checkout/index.html | 4 +- .../resources/templates/webshop/complete.html | 8 ++-- .../resources/templates/webshop/event.html | 2 +- .../resources/templates/webshop/index.html | 4 +- .../templates/webshop/overview/index.html | 4 +- .../templates/webshop/payment/index.html | 4 +- .../templates/webshop/return/cancelled.html | 5 +-- .../templates/webshop/return/error.html | 4 +- .../templates/webshop/return/expired.html | 4 +- .../templates/webshop/return/pending.html | 4 +- .../templates/webshop/return/reservation.html | 5 +-- .../templates/webshop/return/success.html | 4 +- .../templates/webshop/tickets/transfer.html | 4 +- .../java/ch/wisv/events/ControllerTest.java | 3 +- .../DashboardEventControllerTest.java | 41 ++++++++++-------- .../DashboardOrderControllerTest.java | 2 +- .../DashboardProductControllerTest.java | 1 + .../DashboardTasksControllerTest.java | 2 + .../DashboardTreasurerControllerTest.java | 3 ++ .../core/model/order/PaymentMethodTest.java | 6 +++ .../core/service/TicketServiceTest.java | 2 +- .../core/service/TicketTransferTest.java | 2 + .../core/tasks/OrderTaskSchedulerTest.java | 1 + .../stats/SalesStatsControllersTest.java | 3 ++ 95 files changed, 313 insertions(+), 312 deletions(-) delete mode 100644 src/main/java/ch/wisv/events/WebConfiguration.java diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6392f2fe..1d9daf17 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/java:17 +FROM mcr.microsoft.com/devcontainers/java:0-17 RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8442c4ac..21d4f154 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,24 +14,14 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // This can be used to network with other containers or with the host. "forwardPorts": [ - 1080, // Mailcatcher - 5432, // PostgreSQL - 8080, // Events - 8082 // Adminer + 1080, + 80, + 8082 ], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "gradle bootRun", + "postCreateCommand": "gradle bootRun", // Configure tool-specific properties. // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - "remoteUser": "root", - "customizations": { - "vscode": { - "extensions": [ - "vmware.vscode-boot-dev-pack", - "vscjava.vscode-gradle", - "vscjava.vscode-java-pack" - ] - } - } + "remoteUser": "root" } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index ca18713e..1e479343 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -26,7 +26,7 @@ services: - mailcatcher postgres: - image: docker.io/library/postgres:latest + image: postgres:latest restart: unless-stopped volumes: - postgres-data:/var/lib/postgresql/data @@ -36,7 +36,7 @@ services: POSTGRES_HOST_AUTH_METHOD: trust adminer: - image: docker.io/library/adminer:latest + image: adminer restart: always depends_on: - postgres @@ -44,6 +44,6 @@ services: - "8082:8080" mailcatcher: - image: docker.io/schickling/mailcatcher:latest + image: schickling/mailcatcher restart: on-failure network_mode: service:postgres diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f4e6e787..6c374a5e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,15 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' + uses: actions/checkout@v3 - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v2 - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v2 diff --git a/build.gradle b/build.gradle index 22ba892c..c72e6dc5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '3.2.5' + springBootVersion = '2.7.18' } repositories { mavenCentral() @@ -56,11 +56,16 @@ dependencies { //TEMP APPLICATION PROPERTIES HELPER runtimeOnly 'org.springframework.boot:spring-boot-properties-migrator' + + implementation 'javax.el:javax.el-api:2.2.5' implementation "be.woutschoovaerts:mollie:3.6.1" - implementation 'org.thymeleaf:thymeleaf-spring6' - implementation 'org.thymeleaf:thymeleaf' - implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6' + + implementation 'org.thymeleaf:thymeleaf-spring5' + implementation 'org.thymeleaf:thymeleaf' + implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' + implementation 'org.thymeleaf.extras:thymeleaf-extras-java8time' + implementation 'com.google.guava:guava:32.0.0-jre' implementation 'org.hibernate.validator:hibernate-validator' diff --git a/config/application-devcontainer.yml b/config/application-devcontainer.yml index a21987c8..a0dca394 100644 --- a/config/application-devcontainer.yml +++ b/config/application-devcontainer.yml @@ -76,7 +76,7 @@ logging.level.web: DEBUG # Serve connect server: - port: 8080 + port: 80 servlet.context-path: / # CH Connect Configuration diff --git a/src/main/java/ch/wisv/events/ChConnectConfiguration.java b/src/main/java/ch/wisv/events/ChConnectConfiguration.java index 56d1f8c4..eb146c0f 100644 --- a/src/main/java/ch/wisv/events/ChConnectConfiguration.java +++ b/src/main/java/ch/wisv/events/ChConnectConfiguration.java @@ -9,10 +9,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService; @@ -20,7 +20,6 @@ import org.springframework.security.oauth2.core.oidc.OidcIdToken; import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser; import org.springframework.security.oauth2.core.oidc.user.OidcUser; -import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.csrf.CookieCsrfTokenRepository; import org.springframework.validation.annotation.Validated; import org.springframework.web.cors.CorsConfigurationSource; @@ -33,11 +32,11 @@ */ @Configuration @EnableWebSecurity -@EnableMethodSecurity(prePostEnabled = true) +@EnableGlobalMethodSecurity(prePostEnabled = true) @ConfigurationProperties(prefix = "wisvch.connect") @Validated @Profile("!test") -public class ChConnectConfiguration { +public class ChConnectConfiguration extends WebSecurityConfigurerAdapter { /** * Groups that are admin in the system. @@ -65,29 +64,24 @@ public class ChConnectConfiguration { * @param http * @throws Exception */ - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + public void configure(HttpSecurity http) throws Exception { http - .cors(Customizer.withDefaults()) - .csrf(Customizer.withDefaults()) - .authorizeHttpRequests((authorize) -> authorize - .requestMatchers("/administrator/**").hasRole("ADMIN") - .requestMatchers("/", "/management/health").permitAll() + .cors() + .and() + .csrf() + .and().authorizeRequests() + .antMatchers("/administrator/**").hasRole("ADMIN") + .antMatchers("/", "/management/health").permitAll() .anyRequest().permitAll() - ) - .logout(logout -> logout + .and() + .logout() .logoutSuccessUrl("/") - ) - .csrf(csrf -> csrf + .and() + .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) - .ignoringRequestMatchers("/api/v1/**") - ) - .oauth2Login(oauth -> oauth - .userInfoEndpoint(userInfo -> userInfo - .oidcUserService(oidcUserService()) - ) - ); - return http.build(); + .ignoringAntMatchers("/api/v1/**") + .and() + .oauth2Login().userInfoEndpoint().oidcUserService(oidcUserService()); } /** diff --git a/src/main/java/ch/wisv/events/EventsApplication.java b/src/main/java/ch/wisv/events/EventsApplication.java index 346d92d1..58db039e 100644 --- a/src/main/java/ch/wisv/events/EventsApplication.java +++ b/src/main/java/ch/wisv/events/EventsApplication.java @@ -3,8 +3,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import org.springframework.scheduling.annotation.EnableScheduling; +import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect; /** * EventsApplication class. @@ -23,4 +25,15 @@ public class EventsApplication { public static void main(String[] args) { SpringApplication.run(EventsApplication.class, args); } + + /** + * Enables Time formating in thymeleaf. + * + * @return Java8TimeDialect + */ + @Bean + public Java8TimeDialect java8TimeDialect() { + return new Java8TimeDialect(); + } + } diff --git a/src/main/java/ch/wisv/events/WebConfiguration.java b/src/main/java/ch/wisv/events/WebConfiguration.java deleted file mode 100644 index 2a3ea9af..00000000 --- a/src/main/java/ch/wisv/events/WebConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package ch.wisv.events; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class WebConfiguration implements WebMvcConfigurer { - - @Override - public void configurePathMatch(PathMatchConfigurer configurer) { - configurer.setUseTrailingSlashMatch(true); - } - -} \ No newline at end of file diff --git a/src/main/java/ch/wisv/events/admin/controller/DashboardIndexController.java b/src/main/java/ch/wisv/events/admin/controller/DashboardIndexController.java index c5a239a6..c27e0497 100644 --- a/src/main/java/ch/wisv/events/admin/controller/DashboardIndexController.java +++ b/src/main/java/ch/wisv/events/admin/controller/DashboardIndexController.java @@ -5,6 +5,7 @@ import ch.wisv.events.core.repository.EventRepository; import ch.wisv.events.core.service.customer.CustomerService; import ch.wisv.events.core.service.event.EventService; +import ch.wisv.events.core.service.ticket.TicketService; import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/ch/wisv/events/api/controller/OrderRestController.java b/src/main/java/ch/wisv/events/api/controller/OrderRestController.java index 79da0311..4bca7733 100644 --- a/src/main/java/ch/wisv/events/api/controller/OrderRestController.java +++ b/src/main/java/ch/wisv/events/api/controller/OrderRestController.java @@ -1,6 +1,8 @@ package ch.wisv.events.api.controller; +import ch.wisv.events.core.service.order.OrderService; import ch.wisv.events.webshop.service.PaymentsService; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -8,6 +10,7 @@ /** * OrderRestController class. */ +@Slf4j @RestController @RequestMapping("/api/v1/orders") public class OrderRestController { diff --git a/src/main/java/ch/wisv/events/api/request/ProductDto.java b/src/main/java/ch/wisv/events/api/request/ProductDto.java index 69f02910..480331d5 100644 --- a/src/main/java/ch/wisv/events/api/request/ProductDto.java +++ b/src/main/java/ch/wisv/events/api/request/ProductDto.java @@ -1,6 +1,6 @@ package ch.wisv.events.api.request; -import jakarta.validation.constraints.NotNull; +import javax.validation.constraints.NotNull; import ch.wisv.events.core.util.VatRate; import lombok.Getter; diff --git a/src/main/java/ch/wisv/events/core/model/customer/Customer.java b/src/main/java/ch/wisv/events/core/model/customer/Customer.java index 3bfd0ecd..2521e0a0 100644 --- a/src/main/java/ch/wisv/events/core/model/customer/Customer.java +++ b/src/main/java/ch/wisv/events/core/model/customer/Customer.java @@ -5,15 +5,16 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import jakarta.persistence.Column; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import javax.persistence.Column; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import lombok.AccessLevel; import lombok.Data; import lombok.Getter; import lombok.Setter; +import org.springframework.beans.factory.annotation.Value; /** * Customer object. diff --git a/src/main/java/ch/wisv/events/core/model/document/Document.java b/src/main/java/ch/wisv/events/core/model/document/Document.java index 6baa8960..fa24a0aa 100644 --- a/src/main/java/ch/wisv/events/core/model/document/Document.java +++ b/src/main/java/ch/wisv/events/core/model/document/Document.java @@ -1,8 +1,8 @@ package ch.wisv.events.core.model.document; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import lombok.Data; /** diff --git a/src/main/java/ch/wisv/events/core/model/event/Event.java b/src/main/java/ch/wisv/events/core/model/event/Event.java index 41e6d7e7..b9df4761 100644 --- a/src/main/java/ch/wisv/events/core/model/event/Event.java +++ b/src/main/java/ch/wisv/events/core/model/event/Event.java @@ -6,22 +6,22 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OrderBy; -import jakarta.validation.constraints.NotNull; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Setter; -import jakarta.validation.constraints.NotEmpty; +import javax.validation.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; diff --git a/src/main/java/ch/wisv/events/core/model/order/Order.java b/src/main/java/ch/wisv/events/core/model/order/Order.java index a56a1c62..2126284b 100644 --- a/src/main/java/ch/wisv/events/core/model/order/Order.java +++ b/src/main/java/ch/wisv/events/core/model/order/Order.java @@ -6,16 +6,16 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; -import jakarta.validation.constraints.NotNull; +import javax.validation.constraints.NotNull; import ch.wisv.events.core.util.VatRate; import lombok.AccessLevel; @@ -23,7 +23,6 @@ import lombok.Getter; import lombok.Setter; import org.springframework.format.annotation.DateTimeFormat; - import static org.springframework.format.annotation.DateTimeFormat.ISO; @Entity @@ -52,7 +51,7 @@ public class Order { * Field customer customer that order this. */ @ManyToOne - // @NotNull + @NotNull private Customer owner; /** @@ -121,8 +120,6 @@ public Order() { this.createdAt = LocalDateTime.now(); this.status = OrderStatus.ANONYMOUS; this.orderProducts = new ArrayList<>(); - this.createdBy = "ANONYMOUS"; - this.amount = 0d; } /** diff --git a/src/main/java/ch/wisv/events/core/model/order/OrderProduct.java b/src/main/java/ch/wisv/events/core/model/order/OrderProduct.java index a88a84b3..3eb6f30b 100644 --- a/src/main/java/ch/wisv/events/core/model/order/OrderProduct.java +++ b/src/main/java/ch/wisv/events/core/model/order/OrderProduct.java @@ -2,8 +2,8 @@ import ch.wisv.events.core.model.product.Product; -import jakarta.persistence.*; -import jakarta.validation.constraints.NotNull; +import javax.persistence.*; +import javax.validation.constraints.NotNull; import ch.wisv.events.core.util.VatRate; import lombok.AccessLevel; diff --git a/src/main/java/ch/wisv/events/core/model/product/Product.java b/src/main/java/ch/wisv/events/core/model/product/Product.java index 65782ac9..dc95d8ee 100644 --- a/src/main/java/ch/wisv/events/core/model/product/Product.java +++ b/src/main/java/ch/wisv/events/core/model/product/Product.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import jakarta.persistence.*; +import javax.persistence.*; import ch.wisv.events.core.model.event.Event; import ch.wisv.events.core.util.VatRate; diff --git a/src/main/java/ch/wisv/events/core/model/ticket/Ticket.java b/src/main/java/ch/wisv/events/core/model/ticket/Ticket.java index 69ce0643..e76f9fa5 100644 --- a/src/main/java/ch/wisv/events/core/model/ticket/Ticket.java +++ b/src/main/java/ch/wisv/events/core/model/ticket/Ticket.java @@ -8,11 +8,11 @@ import java.time.LocalDateTime; import java.util.UUID; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; -import jakarta.validation.constraints.NotNull; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Data; @@ -39,7 +39,7 @@ public class Ticket { /** * Customer which owns the Ticket. */ - @ManyToOne(cascade = {jakarta.persistence.CascadeType.ALL}) + @ManyToOne(cascade = {javax.persistence.CascadeType.ALL}) public Order order; /** diff --git a/src/main/java/ch/wisv/events/core/model/webhook/Webhook.java b/src/main/java/ch/wisv/events/core/model/webhook/Webhook.java index 40278ac0..97d3897a 100644 --- a/src/main/java/ch/wisv/events/core/model/webhook/Webhook.java +++ b/src/main/java/ch/wisv/events/core/model/webhook/Webhook.java @@ -3,10 +3,10 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import lombok.Data; @Entity diff --git a/src/main/java/ch/wisv/events/core/model/webhook/WebhookTask.java b/src/main/java/ch/wisv/events/core/model/webhook/WebhookTask.java index 5fc89edb..a22a5bd7 100644 --- a/src/main/java/ch/wisv/events/core/model/webhook/WebhookTask.java +++ b/src/main/java/ch/wisv/events/core/model/webhook/WebhookTask.java @@ -1,11 +1,11 @@ package ch.wisv.events.core.model.webhook; import java.time.LocalDateTime; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; import lombok.Data; import org.json.simple.JSONObject; diff --git a/src/main/java/ch/wisv/events/core/service/customer/CustomerServiceImpl.java b/src/main/java/ch/wisv/events/core/service/customer/CustomerServiceImpl.java index 5a8b2d46..0649b0fc 100644 --- a/src/main/java/ch/wisv/events/core/service/customer/CustomerServiceImpl.java +++ b/src/main/java/ch/wisv/events/core/service/customer/CustomerServiceImpl.java @@ -176,16 +176,16 @@ public Customer createByOidcUser(OidcUser userInfo) throws CustomerInvalidExcept */ @Override public void update(Customer customer) throws CustomerInvalidException, CustomerNotFoundException { - this.assertIsValidCustomer(customer); - Customer model = this.getByKey(customer.getKey()); - + model.setName(customer.getName()); model.setEmail(customer.getEmail()); model.setRfidToken(customer.getRfidToken()); model.setLdapGroups(customer.getLdapGroups()); model.setVerifiedChMember(customer.isVerifiedChMember()); + this.assertIsValidCustomer(model); + customerRepository.save(model); } diff --git a/src/main/java/ch/wisv/events/core/service/event/EventServiceImpl.java b/src/main/java/ch/wisv/events/core/service/event/EventServiceImpl.java index 7027ba5f..6b36acc8 100644 --- a/src/main/java/ch/wisv/events/core/service/event/EventServiceImpl.java +++ b/src/main/java/ch/wisv/events/core/service/event/EventServiceImpl.java @@ -163,8 +163,6 @@ public void create(Event event) throws EventInvalidException { */ @Override public void update(Event event) throws EventNotFoundException, EventInvalidException { - this.assertIsValidEvent(event); - Event update = this.getByKey(event.getKey()); this.updateLinkedProducts(event, update.getProducts(), false); @@ -186,6 +184,7 @@ public void update(Event event) throws EventNotFoundException, EventInvalidExcep update.setImageUrl(event.getImageUrl()); } + this.assertIsValidEvent(event); this.updateLinkedProducts(event, update.getProducts(), true); eventRepository.save(update); } diff --git a/src/main/java/ch/wisv/events/core/service/mail/MailServiceImpl.java b/src/main/java/ch/wisv/events/core/service/mail/MailServiceImpl.java index 68d79fea..65d20e39 100644 --- a/src/main/java/ch/wisv/events/core/service/mail/MailServiceImpl.java +++ b/src/main/java/ch/wisv/events/core/service/mail/MailServiceImpl.java @@ -11,9 +11,9 @@ import java.net.URL; import java.util.List; import java.util.Locale; -import jakarta.mail.MessagingException; -import jakarta.mail.internet.MimeMessage; -import jakarta.validation.constraints.NotNull; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import javax.validation.constraints.NotNull; import ch.wisv.events.core.service.ticket.TicketService; import ch.wisv.events.core.util.QrCode; @@ -29,7 +29,8 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; import org.thymeleaf.context.Context; -import org.thymeleaf.spring6.SpringTemplateEngine; +import org.thymeleaf.spring5.SpringTemplateEngine; + /** * MailService implementation. */ diff --git a/src/main/java/ch/wisv/events/core/service/product/ProductServiceImpl.java b/src/main/java/ch/wisv/events/core/service/product/ProductServiceImpl.java index e0a2fbb9..4f5fc526 100644 --- a/src/main/java/ch/wisv/events/core/service/product/ProductServiceImpl.java +++ b/src/main/java/ch/wisv/events/core/service/product/ProductServiceImpl.java @@ -108,8 +108,6 @@ public Product create(ProductDto productDto) throws ProductInvalidException { */ @Override public void update(Product product) throws ProductNotFoundException, ProductInvalidException { - this.assertIsValidProduct(product); - Product model = this.getByKey(product.getKey()); this.updateLinkedProducts(product, model.getProducts(), false); @@ -130,6 +128,7 @@ public void update(Product product) throws ProductNotFoundException, ProductInva model.setSold(product.getSold()); } + this.assertIsValidProduct(product); this.updateLinkedProducts(product, model.getProducts(), true); productRepository.save(model); } diff --git a/src/main/java/ch/wisv/events/core/service/ticket/TicketServiceImpl.java b/src/main/java/ch/wisv/events/core/service/ticket/TicketServiceImpl.java index 4a50c351..14bd68f8 100644 --- a/src/main/java/ch/wisv/events/core/service/ticket/TicketServiceImpl.java +++ b/src/main/java/ch/wisv/events/core/service/ticket/TicketServiceImpl.java @@ -24,7 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; -import jakarta.validation.constraints.NotNull; +import javax.validation.constraints.NotNull; /** * TicketServiceImpl class. diff --git a/src/main/java/ch/wisv/events/webshop/controller/WebshopIndexController.java b/src/main/java/ch/wisv/events/webshop/controller/WebshopIndexController.java index a6c94c3d..e7702ddd 100644 --- a/src/main/java/ch/wisv/events/webshop/controller/WebshopIndexController.java +++ b/src/main/java/ch/wisv/events/webshop/controller/WebshopIndexController.java @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import jakarta.validation.constraints.NotNull; +import javax.validation.constraints.NotNull; /** * WebshopIndexController class. diff --git a/src/main/java/ch/wisv/events/webshop/controller/WebshopTicketController.java b/src/main/java/ch/wisv/events/webshop/controller/WebshopTicketController.java index 3e4d05cd..39913a96 100644 --- a/src/main/java/ch/wisv/events/webshop/controller/WebshopTicketController.java +++ b/src/main/java/ch/wisv/events/webshop/controller/WebshopTicketController.java @@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; -import jakarta.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.IOException; diff --git a/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java b/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java index 8ab5e02d..63bb17cf 100644 --- a/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java +++ b/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java @@ -15,7 +15,7 @@ import ch.wisv.events.core.service.mail.MailService; import ch.wisv.events.core.service.order.OrderService; -import jakarta.validation.constraints.NotNull; +import javax.validation.constraints.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/resources/dev/data/orders.json b/src/main/resources/dev/data/orders.json index 8918fced..33895536 100644 --- a/src/main/resources/dev/data/orders.json +++ b/src/main/resources/dev/data/orders.json @@ -2,50 +2,36 @@ { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" }, { "orderStatus" : "PAID", "paymentMethod" : "IDEAL", - "customerRfid" : "3061a041", - "owner" : 1, - "createdBy" : "Sven Popping" + "customerRfid" : "3061a041" } ] \ No newline at end of file diff --git a/src/main/resources/templates/admin/customers/customer.html b/src/main/resources/templates/admin/customers/customer.html index 3ce1aeb5..9b435b1c 100644 --- a/src/main/resources/templates/admin/customers/customer.html +++ b/src/main/resources/templates/admin/customers/customer.html @@ -32,17 +32,17 @@ - +
- +

Create/update customer

-
+
diff --git a/src/main/resources/templates/admin/customers/index.html b/src/main/resources/templates/admin/customers/index.html index 4b0a20ad..a68932c8 100644 --- a/src/main/resources/templates/admin/customers/index.html +++ b/src/main/resources/templates/admin/customers/index.html @@ -32,11 +32,11 @@ - +
- +

Customers @@ -45,7 +45,7 @@

Customers

-
+
diff --git a/src/main/resources/templates/admin/customers/view.html b/src/main/resources/templates/admin/customers/view.html index 1c998b6e..529f0c79 100644 --- a/src/main/resources/templates/admin/customers/view.html +++ b/src/main/resources/templates/admin/customers/view.html @@ -32,12 +32,12 @@ - +
- +

[[${customer.getName()}]] @@ -46,7 +46,7 @@

[[${customer.getName()}]]

-
+
diff --git a/src/main/resources/templates/admin/events/event.html b/src/main/resources/templates/admin/events/event.html index 895395dc..a1bbe03a 100644 --- a/src/main/resources/templates/admin/events/event.html +++ b/src/main/resources/templates/admin/events/event.html @@ -36,12 +36,12 @@ - +
- +

Create/update event @@ -62,7 +62,7 @@

-
+
diff --git a/src/main/resources/templates/admin/events/index.html b/src/main/resources/templates/admin/events/index.html index e97e1418..3d3a3499 100644 --- a/src/main/resources/templates/admin/events/index.html +++ b/src/main/resources/templates/admin/events/index.html @@ -32,11 +32,11 @@ - +
- +

Events @@ -45,7 +45,7 @@

Events

-
+
diff --git a/src/main/resources/templates/admin/events/overview.html b/src/main/resources/templates/admin/events/overview.html index 14fdf099..81d4b792 100644 --- a/src/main/resources/templates/admin/events/overview.html +++ b/src/main/resources/templates/admin/events/overview.html @@ -33,17 +33,17 @@ - +
- +

Ticket [[${event.getTitle()}]]

-
+
diff --git a/src/main/resources/templates/admin/events/view.html b/src/main/resources/templates/admin/events/view.html index f27db91a..cc238b51 100644 --- a/src/main/resources/templates/admin/events/view.html +++ b/src/main/resources/templates/admin/events/view.html @@ -35,12 +35,12 @@ - +
- +

[[${event.getTitle()}]] @@ -49,7 +49,7 @@

[[${event.getTitle()}]]

-
+
diff --git a/src/main/resources/templates/admin/index.html b/src/main/resources/templates/admin/index.html index abf625af..3b9442e9 100644 --- a/src/main/resources/templates/admin/index.html +++ b/src/main/resources/templates/admin/index.html @@ -32,12 +32,12 @@ - +
- +

Overview

diff --git a/src/main/resources/templates/admin/orders/index.html b/src/main/resources/templates/admin/orders/index.html index bc1dd187..bacca124 100644 --- a/src/main/resources/templates/admin/orders/index.html +++ b/src/main/resources/templates/admin/orders/index.html @@ -32,16 +32,16 @@ - +
- +

Orders

-
+
diff --git a/src/main/resources/templates/admin/orders/view.html b/src/main/resources/templates/admin/orders/view.html index ceafb55b..809ae90a 100644 --- a/src/main/resources/templates/admin/orders/view.html +++ b/src/main/resources/templates/admin/orders/view.html @@ -32,16 +32,16 @@ - +
- +

Order #[[${order.getId()}]]

-
+
diff --git a/src/main/resources/templates/admin/products/index.html b/src/main/resources/templates/admin/products/index.html index 3773134c..e93a883c 100644 --- a/src/main/resources/templates/admin/products/index.html +++ b/src/main/resources/templates/admin/products/index.html @@ -32,12 +32,12 @@ - +
- +

Products @@ -46,7 +46,7 @@

Products

-
+
diff --git a/src/main/resources/templates/admin/products/overview.html b/src/main/resources/templates/admin/products/overview.html index bac1b22f..3913e87f 100644 --- a/src/main/resources/templates/admin/products/overview.html +++ b/src/main/resources/templates/admin/products/overview.html @@ -33,17 +33,17 @@ - +
- +

Sold ticket [[${product.getTitle()}]]

-
+
diff --git a/src/main/resources/templates/admin/products/product.html b/src/main/resources/templates/admin/products/product.html index 487ee726..162ad210 100644 --- a/src/main/resources/templates/admin/products/product.html +++ b/src/main/resources/templates/admin/products/product.html @@ -33,12 +33,12 @@ - +
- +

Create/update product @@ -59,7 +59,7 @@

-
+
diff --git a/src/main/resources/templates/admin/products/view.html b/src/main/resources/templates/admin/products/view.html index 75149a62..738947b7 100644 --- a/src/main/resources/templates/admin/products/view.html +++ b/src/main/resources/templates/admin/products/view.html @@ -32,12 +32,12 @@ - +
- +

[[${product.getTitle()}]] @@ -46,7 +46,7 @@

[[${product.getTitle()}]]

-
+
diff --git a/src/main/resources/templates/admin/salesexport/index.html b/src/main/resources/templates/admin/salesexport/index.html index b28412ff..ce0bc076 100644 --- a/src/main/resources/templates/admin/salesexport/index.html +++ b/src/main/resources/templates/admin/salesexport/index.html @@ -72,11 +72,11 @@ - +
- +

@@ -85,7 +85,7 @@

Old Treasurer Tab

-
+
diff --git a/src/main/resources/templates/admin/treasurer/index.html b/src/main/resources/templates/admin/treasurer/index.html index 3ec50a7b..95f26b19 100644 --- a/src/main/resources/templates/admin/treasurer/index.html +++ b/src/main/resources/templates/admin/treasurer/index.html @@ -32,16 +32,16 @@ - +
- +

Mollie Overview

-
+
diff --git a/src/main/resources/templates/admin/webhooks/index.html b/src/main/resources/templates/admin/webhooks/index.html index 158b7168..9ca42ad2 100644 --- a/src/main/resources/templates/admin/webhooks/index.html +++ b/src/main/resources/templates/admin/webhooks/index.html @@ -32,11 +32,11 @@ - +
- +

Webhooks @@ -45,7 +45,7 @@

Webhooks

-
+
diff --git a/src/main/resources/templates/admin/webhooks/view.html b/src/main/resources/templates/admin/webhooks/view.html index 90a08133..c2e069e0 100644 --- a/src/main/resources/templates/admin/webhooks/view.html +++ b/src/main/resources/templates/admin/webhooks/view.html @@ -32,12 +32,12 @@ - +
- +

Webhook #[[${webhook.getId()}]] @@ -46,7 +46,7 @@

Webhook #[[${webhook.getId()}]]

-
+
diff --git a/src/main/resources/templates/admin/webhooks/webhook.html b/src/main/resources/templates/admin/webhooks/webhook.html index ff6a1bac..318083ca 100644 --- a/src/main/resources/templates/admin/webhooks/webhook.html +++ b/src/main/resources/templates/admin/webhooks/webhook.html @@ -32,17 +32,17 @@ - +
- +

Create/update webhook

-
+
diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index deb12068..73e825c4 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -32,7 +32,7 @@ - +
diff --git a/src/main/resources/templates/index.example.html b/src/main/resources/templates/index.example.html index 0db1476e..a3cff8f9 100644 --- a/src/main/resources/templates/index.example.html +++ b/src/main/resources/templates/index.example.html @@ -32,11 +32,11 @@ - +
- +

Example @@ -45,7 +45,7 @@

Example

-
+
diff --git a/src/main/resources/templates/sales/index.html b/src/main/resources/templates/sales/index.html index 4a63fbb0..7ea0727f 100644 --- a/src/main/resources/templates/sales/index.html +++ b/src/main/resources/templates/sales/index.html @@ -30,7 +30,7 @@ - +
diff --git a/src/main/resources/templates/sales/scan/barcode/barcode.html b/src/main/resources/templates/sales/scan/barcode/barcode.html index f1c01038..9ab4a66a 100644 --- a/src/main/resources/templates/sales/scan/barcode/barcode.html +++ b/src/main/resources/templates/sales/scan/barcode/barcode.html @@ -32,7 +32,7 @@ - +
diff --git a/src/main/resources/templates/sales/scan/event/barcode.html b/src/main/resources/templates/sales/scan/event/barcode.html index 5aa5a632..1508ab52 100644 --- a/src/main/resources/templates/sales/scan/event/barcode.html +++ b/src/main/resources/templates/sales/scan/event/barcode.html @@ -87,7 +87,7 @@ - +
diff --git a/src/main/resources/templates/sales/scan/event/code.html b/src/main/resources/templates/sales/scan/event/code.html index db186f01..78bf24ed 100644 --- a/src/main/resources/templates/sales/scan/event/code.html +++ b/src/main/resources/templates/sales/scan/event/code.html @@ -45,13 +45,13 @@ - +
-
+

diff --git a/src/main/resources/templates/sales/scan/event/qrcode.html b/src/main/resources/templates/sales/scan/event/qrcode.html index 14ac3136..7bf366c3 100644 --- a/src/main/resources/templates/sales/scan/event/qrcode.html +++ b/src/main/resources/templates/sales/scan/event/qrcode.html @@ -63,7 +63,7 @@ - +