Skip to content

Commit

Permalink
Merge branch 'release/2024.04.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattboll committed Apr 17, 2024
2 parents aa557d1 + fc6c8e9 commit 3ae2668
Show file tree
Hide file tree
Showing 345 changed files with 1,987 additions and 1,518 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mockstorage/
static-front/
logs/
hs_err_pid*.log
tmp

### STS ###
.apt_generated
Expand Down Expand Up @@ -41,3 +42,4 @@ hs_err_pid*.log

# Used in test
7fdad8b1*

File renamed without changes.
67 changes: 26 additions & 41 deletions dossierfacile-api-owner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<version>3.2.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>fr.dossierfacile.api</groupId>
Expand All @@ -15,10 +15,12 @@
<description>Owner api for DossierFacile</description>
<properties>
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<lombok.version>1.18.30</lombok.version>
<keycloak.version>21.1.2</keycloak.version>
<spring-security.version>5.8.9</spring-security.version>
<springdoc.version>1.7.0</springdoc.version>
<keycloak.version>22.0.3</keycloak.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -46,44 +48,23 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
Expand All @@ -97,7 +78,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.7</version>
<version>${springdoc.version}</version>
</dependency>
<!-- Caution - transitive dependencies on sendinblue itself are not compatible -->
<dependency>
Expand Down Expand Up @@ -139,6 +120,17 @@
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
<!-- For testing -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -148,21 +140,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.1.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand All @@ -174,12 +155,16 @@
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=spring
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.1.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.dossierfacile.api.dossierfacileapiowner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
Expand All @@ -13,7 +12,6 @@
@EnableJpaRepositories(basePackages = "fr.dossierfacile")
@EnableAsync
@EnableScheduling
@Slf4j
public class DossierfacileApiOwnerApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package fr.dossierfacile.api.dossierfacileapiowner.config;

import fr.dossierfacile.common.config.AbstractConnectionContextFilter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.jwt.Jwt;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.TreeMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public RealmResource getRealmResource() {
.clientId(clientId)
.clientSecret(clientSecret)
.build();
keycloak.tokenManager().getAccessToken();

return keycloak.realm(keycloakRealm);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package fr.dossierfacile.api.dossierfacileapiowner.config;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
Expand All @@ -24,7 +23,6 @@


@EnableWebSecurity
@RequiredArgsConstructor
@Configuration
public class ResourceServerConfig {
@Value("${callback.http.auth.token}")
Expand All @@ -50,11 +48,10 @@ SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
.permitAll()
.anyRequest().hasAuthority("SCOPE_dossier")
)
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
.oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt -> jwt.jwtAuthenticationConverter(new JwtAuthenticationConverter())));

return http.build();
}

@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package fr.dossierfacile.api.dossierfacileapiowner.config;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.NegatedRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package fr.dossierfacile.api.dossierfacileapiowner.log;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import fr.dossierfacile.common.entity.Log;
import fr.dossierfacile.common.entity.Owner;
import fr.dossierfacile.common.entity.OwnerLog;
import fr.dossierfacile.common.enums.OwnerLogType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.dossierfacile.api.dossierfacileapiowner.mail;

public class ConfirmMailParams {
String tokenUrl;
final String tokenUrl;

public ConfirmMailParams(String tokenUrl) {
this.tokenUrl = tokenUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ public class LightPropertyModel {
private Double rentCost;
private Double chargesCost;
private Double livingSpace;
private String token;
private Boolean validated;
private PropertyType type;
private PropertyFurniture furniture;
private String address;
private Integer co2Emission;
private Integer energyConsumption;
private Integer propertyApartmentSharingCount;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package fr.dossierfacile.api.dossierfacileapiowner.property;

import com.fasterxml.jackson.annotation.JsonInclude;
import fr.dossierfacile.common.entity.ApartmentSharing;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fr.dossierfacile.common.entity.Property;
import fr.dossierfacile.common.entity.PropertyApartmentSharing;
import fr.dossierfacile.common.enums.LogType;
import fr.dossierfacile.common.exceptions.NotFoundException;
import fr.dossierfacile.common.service.interfaces.LogService;
import lombok.AllArgsConstructor;
import org.apache.http.client.HttpResponseException;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class PropertyController {
private final PropertyApartmentSharingService propertyApartmentSharingService;
private final AuthenticationFacade authenticationFacade;
private final OwnerMapper ownerMapper;
private final PropertyMapper propertyMapper;

@PutMapping
public ResponseEntity<PropertyModel> createOrUpdate(@RequestBody PropertyForm Property) {
Expand All @@ -55,6 +57,12 @@ public ResponseEntity<List<PropertyModel>> getAll() {
return ok(properties);
}

@GetMapping("/{id}")
public ResponseEntity<PropertyModel> getProperty(@PathVariable Long id) {
Property property = propertyService.getProperty(id).orElseThrow(NotFoundException::new);
return ok(propertyMapper.toPropertyModel(property));
}

@DeleteMapping("/{id}")
public ResponseEntity<OwnerModel> delete(@PathVariable Long id) {
propertyService.delete(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import fr.dossierfacile.common.enums.PropertyFurniture;
import fr.dossierfacile.common.enums.PropertyType;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@Data
@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fr.dossierfacile.api.dossierfacileapiowner.property;

import fr.dossierfacile.common.entity.ApartmentSharing;
import fr.dossierfacile.common.entity.Property;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.stereotype.Component;

@Component
@Mapper(componentModel = "spring")
public abstract class PropertyMapper {

public abstract PropertyModel toPropertyModel(Property property);

@Mapping( target="totalSalary", expression="java(apartmentSharing.totalSalary())" )
@Mapping( target="totalGuarantorSalary", expression="java(apartmentSharing.totalGuarantorSalary())" )
public abstract ApartmentSharingModel apartmentSharingToApartmentSharingModel(ApartmentSharing apartmentSharing);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.dossierfacile.api.dossierfacileapiowner.property;

import com.fasterxml.jackson.annotation.JsonInclude;
import fr.dossierfacile.common.entity.PropertyApartmentSharing;
import fr.dossierfacile.common.enums.PropertyFurniture;
import fr.dossierfacile.common.enums.PropertyType;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public void delete(Long id) {

@Override
public Optional<Property> getProperty(Long id) {
return propertyRepository.findById(id);
Owner owner = authenticationFacade.getOwner();
return propertyRepository.findByIdAndOwnerId(id, owner.getId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.dossierfacile.api.dossierfacileapiowner.property;

import fr.dossierfacile.common.entity.Property;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException;
Expand All @@ -12,7 +13,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Optional;

import static org.springframework.http.ResponseEntity.ok;
Expand Down
Loading

0 comments on commit 3ae2668

Please sign in to comment.