Skip to content

Commit

Permalink
Upgrade deps, fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 8, 2024
1 parent dbd8073 commit fc5a6b5
Show file tree
Hide file tree
Showing 26 changed files with 507 additions and 638 deletions.
88 changes: 30 additions & 58 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:3.1.2"
classpath "org.springframework.boot:spring-boot-gradle-plugin:3.3.0"
}
}

plugins {
id "java"
id "application"
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
id "org.springframework.boot" version "3.3.0"
id "io.spring.dependency-management" version "1.1.5"
id "com.diffplug.spotless" version "6.25.0"
}

java {
sourceCompatibility = '21'
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

apply plugin: "org.springframework.boot"
Expand All @@ -27,85 +28,56 @@ version = "2.0.0-SNAPSHOT"
dependencies {
annotationProcessor(
// Used to generate Record Builder classes
"io.soabase.record-builder:record-builder-processor:37",

// Used to generate useful configuration metadata for IDEs
"org.springframework.boot:spring-boot-configuration-processor:3.1.2",
"io.soabase.record-builder:record-builder-processor:41",
)

implementation(
// Used to generate Record Builder classes
"io.soabase.record-builder:record-builder-core:37",
"io.soabase.record-builder:record-builder-core:41",

// Used to handle SQL specific errors
"org.postgresql:postgresql:42.6.0",
"org.postgresql:postgresql:42.7.3",

// Spring Boot
"org.springframework.boot:spring-boot:3.1.2",
"org.springframework.boot:spring-boot-autoconfigure:3.1.2",
"org.springframework.boot:spring-boot-starter-data-jpa:3.1.2",
"org.springframework.boot:spring-boot-starter-security:3.1.2",
"org.springframework.boot:spring-boot-starter-validation:3.1.2",
"org.springframework.boot:spring-boot-starter-websocket:3.1.2",

// OAuth2 Server
"org.springframework.security:spring-security-oauth2-authorization-server:1.2.3",
"org.springframework.boot:spring-boot:3.3.0",
"org.springframework.boot:spring-boot-autoconfigure:3.3.0",
"org.springframework.boot:spring-boot-starter-data-jpa:3.3.0",
"org.springframework.boot:spring-boot-starter-security:3.3.0",
"org.springframework.boot:spring-boot-starter-validation:3.3.0",
"org.springframework.boot:spring-boot-starter-web:3.3.0",
"org.springframework.boot:spring-boot-starter-oauth2-authorization-server:3.3.0",

// Spring session
"org.springframework.session:spring-session-core:3.1.1",
"org.springframework.session:spring-session-data-redis:3.1.1",

// Jackson (JSON)
'com.fasterxml.jackson.core:jackson-core:2.14.2',
'com.fasterxml.jackson.core:jackson-databind:2.14.2',
'com.fasterxml.jackson.core:jackson-annotations:2.14.2',
"org.springframework.session:spring-session-core:3.3.0",
"org.springframework.session:spring-session-data-redis:3.3.0",

// Redis
'org.springframework.data:spring-data-redis:3.1.2',
"org.springframework.data:spring-data-redis:3.3.0",
)

runtimeOnly(
runtimeOnly(
// FlywayDB (Database migration)
"org.flywaydb:flyway-core:9.21.0",

// Spring Boot
"org.springframework.boot:spring-boot-devtools:3.1.2",
"org.springframework.boot:spring-boot-starter-data-redis:3.1.2",
"org.springframework.boot:spring-boot-devtools:3.3.0",
"org.springframework.boot:spring-boot-starter-data-redis:3.3.0",

// Thymeleaf
"org.springframework.boot:spring-boot-starter-thymeleaf:3.1.2",
"org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE",
"org.springframework.boot:spring-boot-starter-thymeleaf:3.3.0",
"org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.2.RELEASE",

// web dependencies
'org.webjars.npm:htmx.org:1.9.10',
'org.webjars.npm:hyperscript.org:0.9.12',
"org.webjars.npm:htmx.org:1.9.12",
"org.webjars.npm:hyperscript.org:0.9.12",
"org.webjars.npm:picocss__pico:2.0.6"
)

testImplementation(
"com.tngtech.archunit:archunit:1.0.0",
"io.rest-assured:json-path:5.3.1",
"io.rest-assured:rest-assured:5.3.1",
"io.rest-assured:xml-path:5.3.1",
"org.flywaydb:flyway-core:9.21.0",
"org.mockito:mockito-inline:5.2.0",
"org.springframework.boot:spring-boot-starter-test:3.1.2",
"org.springframework.security:spring-security-test:6.1.2",
"org.testcontainers:junit-jupiter:1.18.3",
"org.testcontainers:postgresql:1.18.3"
developmentOnly(
"org.springframework.boot:spring-boot-docker-compose:3.3.0"
)
}

dependencyManagement {
imports {
mavenBom "org.testcontainers:testcontainers-bom:1.19.3"
}
}

test {
useJUnitPlatform()
}

repositories {
mavenCentral()
}
Expand All @@ -119,12 +91,12 @@ spotless {
}

yaml {
target 'src/**/*.yml'
target "src/**/*.yml"
jackson()
}

json {
target 'src/**/*.json'
target "src/**/*.json"
jackson()
}
}
24 changes: 24 additions & 0 deletions app/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3"
services:
db:
image: postgres:16
environment:
POSTGRES_DB: db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
ports:
- '5432'

redis:
image: redis:5.0
ports:
- '6379'

gotify:
image: cthit/gotify
environment:
GOTIFY_PRE-SHARED-KEY: "123abc"
GOTIFY_MOCK-MODE: "true"
GOTIFY_DEBUG-MODE: "true"
ports:
- '8080'
1 change: 0 additions & 1 deletion app/src/main/java/it/chalmers/gamma/GammaApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@ConfigurationPropertiesScan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,51 @@
import it.chalmers.gamma.app.client.domain.ClientUid;
import it.chalmers.gamma.app.migration.ClientApproving;
import it.chalmers.gamma.app.user.domain.UserId;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;

/**
* This is only used as a part of migration from old gamma to new gamma.
* We want to transfer the accepting of a client for certain project,
* such as HubbIT and BookIT.
* This is only used as a part of migration from old gamma to new gamma. We want to transfer the
* accepting of a client for certain project, such as HubbIT and BookIT.
*/
@Controller
public class ClientApprovingController {

private final ClientApproving clientApproving;
private final ClientApproving clientApproving;

public ClientApprovingController(ClientApproving clientApproving) {
this.clientApproving = clientApproving;
}

public record ClientApprovingForm(String clientUid, String userIds) { }

@GetMapping("/client-approving")
public ModelAndView getClientApproving(@RequestHeader(value = "HX-Request", required = false) boolean htmxRequest) {
ModelAndView mv = new ModelAndView();
if (htmxRequest) {
mv.setViewName("pages/client-approving");
} else {
mv.setViewName("index");
mv.addObject("page", "pages/client-approving");
}
public ClientApprovingController(ClientApproving clientApproving) {
this.clientApproving = clientApproving;
}

mv.addObject("form", new ClientApprovingForm("", ""));
public record ClientApprovingForm(String clientUid, String userIds) {}

return mv;
@GetMapping("/client-approving")
public ModelAndView getClientApproving(
@RequestHeader(value = "HX-Request", required = false) boolean htmxRequest) {
ModelAndView mv = new ModelAndView();
if (htmxRequest) {
mv.setViewName("pages/client-approving");
} else {
mv.setViewName("index");
mv.addObject("page", "pages/client-approving");
}

@PostMapping("/client-approving")
public ModelAndView massApproveClient(ClientApprovingForm form) {
List<UserId> userIds = Arrays.stream(form.userIds.split(",")).map(UserId::valueOf).toList();
mv.addObject("form", new ClientApprovingForm("", ""));

clientApproving.approve(ClientUid.valueOf(form.clientUid), userIds);
return mv;
}

return new ModelAndView("redirect:/clients/" + form.clientUid);
}
@PostMapping("/client-approving")
public ModelAndView massApproveClient(ClientApprovingForm form) {
List<UserId> userIds = Arrays.stream(form.userIds.split(",")).map(UserId::valueOf).toList();

clientApproving.approve(ClientUid.valueOf(form.clientUid), userIds);

return new ModelAndView("redirect:/clients/" + form.clientUid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public ModelAndView deleteYourAccount(
try {
this.meFacade.deleteMe(form.password);
} catch (IllegalArgumentException e) {
bindingResult.addError(
new FieldError("form", "password", "Incorrect password"));
bindingResult.addError(new FieldError("form", "password", "Incorrect password"));

ModelAndView mv = new ModelAndView();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import it.chalmers.gamma.app.user.UserFacade;
import java.util.*;
import java.util.stream.Collectors;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -96,8 +95,15 @@ public ModelAndView getGroup(

boolean canEditImages = false;
if (SecurityContextHolder.getContext().getAuthentication()
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages = group.get().groupMembers().stream().anyMatch(groupMember -> groupMember.user().id().equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages =
group.get().groupMembers().stream()
.anyMatch(
groupMember ->
groupMember
.user()
.id()
.equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
}

mv.addObject("canEditImages", canEditImages);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import it.chalmers.gamma.app.image.ImageFacade;
import it.chalmers.gamma.app.image.domain.ImageService;
import java.util.UUID;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
Expand All @@ -23,8 +22,8 @@ public class GroupsImageController {
private final ImageFacade imageFacade;

public GroupsImageController(GroupFacade groupFacade, ImageFacade imageFacade) {
this.groupFacade = groupFacade;
this.imageFacade = imageFacade;
this.groupFacade = groupFacade;
this.imageFacade = imageFacade;
}

@PutMapping("/groups/avatar/{id}")
Expand All @@ -49,8 +48,15 @@ public ModelAndView editGroupAvatar(

boolean canEditImages = false;
if (SecurityContextHolder.getContext().getAuthentication()
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages = group.get().groupMembers().stream().anyMatch(groupMember -> groupMember.user().id().equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages =
group.get().groupMembers().stream()
.anyMatch(
groupMember ->
groupMember
.user()
.id()
.equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
}

mv.addObject("canEditImages", canEditImages);
Expand Down Expand Up @@ -80,8 +86,15 @@ public ModelAndView editGroupBanner(

boolean canEditImages = false;
if (SecurityContextHolder.getContext().getAuthentication()
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages = group.get().groupMembers().stream().anyMatch(groupMember -> groupMember.user().id().equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
instanceof UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) {
canEditImages =
group.get().groupMembers().stream()
.anyMatch(
groupMember ->
groupMember
.user()
.id()
.equals(UUID.fromString(usernamePasswordAuthenticationToken.getName())));
}

mv.addObject("canEditImages", canEditImages);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant;

@Entity
@Table(name = "g_user_activation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant;
import java.util.UUID;

@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import it.chalmers.gamma.app.user.passwordreset.domain.PasswordResetRepository;
import it.chalmers.gamma.app.user.passwordreset.domain.PasswordResetToken;
import jakarta.transaction.Transactional;
import java.time.Instant;
import java.util.Optional;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.chalmers.gamma.adapter.secondary.jpa.util;

import jakarta.persistence.*;

import java.time.Instant;
import java.util.Objects;
import org.springframework.data.domain.Persistable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;

import java.time.Instant;

@MappedSuperclass
Expand Down
Loading

0 comments on commit fc5a6b5

Please sign in to comment.