Skip to content

Commit

Permalink
Merge branch 'release/2025.01.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
poissoj committed Jan 22, 2025
2 parents f4df1c9 + 66c9e63 commit 6506cd1
Show file tree
Hide file tree
Showing 22 changed files with 262 additions and 48 deletions.
9 changes: 9 additions & 0 deletions dossierfacile-api-owner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# API Propriétaire (dossierfacile-api-owner)

## Description
API REST dédiée à l'espace propriétaires, permettant la gestion et la consultation des dossiers des locataires.

## Fonctionnalités principales
- Création et gestion des comptes propriétaires
- Partage de ses propriétés avec les candidats locataires
- Consultation des dossiers partagés par les locataires
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import fr.dossierfacile.common.entity.ApartmentSharing;
import fr.dossierfacile.common.entity.Owner;
import fr.dossierfacile.common.entity.Property;
import fr.dossierfacile.common.enums.TenantFileStatus;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -20,7 +23,15 @@ public abstract class OwnerMapper {
@Mapping( target="totalGuarantorSalary", expression="java(apartmentSharing.totalGuarantorSalary())" )
public abstract ApartmentSharingModel apartmentSharingToApartmentSharingModel(ApartmentSharing apartmentSharing);

@Mapping( target="propertyApartmentSharingCount", expression="java(property.getPropertiesApartmentSharing().size())" )
@Mapping( source="dpeDate", target="dpeDate", dateFormat="yyyy-MM-dd")
@Mapping( source="property", target="propertyApartmentSharingCount", qualifiedByName="validApplicationsCount" )
@Mapping( source="dpeDate", target="dpeDate", dateFormat="yyyy-MM-dd" )
public abstract LightPropertyModel toLightPropertyModel(Property property);

@Named("validApplicationsCount")
public static int getValidApplicationsCount(Property property) {
long count = property.getPropertiesApartmentSharing().stream()
.filter(p -> !p.getApartmentSharing().getStatus().equals(TenantFileStatus.ARCHIVED))
.count();
return (int) count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ logging.level.root=info
logging.file.path=logs
logging.logstash.destination=

application.api.version=3
application.api.version=4
application.name=api-owner
environment=

Expand Down
14 changes: 14 additions & 0 deletions dossierfacile-api-tenant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# API Locataire (dossierfacile-api-tenant)

## Description
API REST dédiée aux locataires, permettant la gestion des dossiers de location.
API REST dédiée aux utilisateurs de DossierFacile (DFC), permettant la visualisation des informations des locataires.

## Fonctionnalités principales
- Création et gestion de comptes locataires
- Téléversement et gestion des justificatifs
- Création et modification de dossiers
- Partage de dossiers

## Documentation de l'API DFC
La documentation Swagger est accessible [ici](https://api-preprod.dossierfacile.fr/swagger-ui/index.html?urls.primaryName=API%20DFC).
2 changes: 1 addition & 1 deletion dossierfacile-api-tenant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>26.0.2</version>
<version>26.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package fr.dossierfacile.api.front.log;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.Context;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CustomAppender extends AppenderBase<ILoggingEvent> {
private static final Map<String, List<LogModel>> logsByRequestId = new ConcurrentHashMap<>();

@Override
protected void append(ILoggingEvent eventObject) {
String requestId = MDC.get("request_id");
if (requestId != null) {
String message = eventObject.getFormattedMessage();

if (eventObject.getLevel().isGreaterOrEqual(Level.ERROR)) {
IThrowableProxy throwableProxy = eventObject.getThrowableProxy();
if (throwableProxy != null) {
StringBuilder stackTrace = new StringBuilder();
for (StackTraceElementProxy line : throwableProxy.getStackTraceElementProxyArray()) {
stackTrace.append(line).append("\n");
}
message += "\n" + stackTrace;
}
}

LogModel log = new LogModel(message, eventObject.getLevel());
logsByRequestId.computeIfAbsent(requestId, id -> new ArrayList<>())
.add(log);
}
}

public static List<LogModel> getLogsForRequest(String requestId) {
return logsByRequestId.getOrDefault(requestId, List.of());
}

public static void clearLogsForRequest(String requestId) {
logsByRequestId.remove(requestId);
}

public static void attachToRootLogger() {
Logger rootLogger = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
CustomAppender customAppender = new CustomAppender();
customAppender.setName("CUSTOM");
Context context = rootLogger.getLoggerContext();
customAppender.setContext(context);
customAppender.start();
rootLogger.addAppender(customAppender);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fr.dossierfacile.api.front.log;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

@ExceptionHandler(Exception.class)
public ResponseEntity<String> handleException(Exception e) {
log.error("Unhandled exception: ", e);
return new ResponseEntity<>("Internal Server Error", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package fr.dossierfacile.api.front.log;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggingEvent;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.logstash.logback.appender.LogstashTcpSocketAppender;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class LogAggregationFilter extends OncePerRequestFilter {
private LogstashTcpSocketAppender logstashAppender;

@PostConstruct
public void init() {
Logger rootLogger = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
logstashAppender = (LogstashTcpSocketAppender) rootLogger.getAppender("LOGSTASH");
if (logstashAppender == null) {
throw new IllegalStateException("Logstash appender (LOGSTASH) not found in Logback configuration.");
}
}

@Override
protected void doFilterInternal(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String requestId = MDC.get("request_id");
try {
filterChain.doFilter(request, response);
} finally {
List<LogModel> logs = CustomAppender.getLogsForRequest(requestId);
String logMessage = logs.stream().map(LogModel::getMessage).collect(Collectors.joining());

String enrichedLogs = String.format(
"Request completed: URI:%s, Method:%s, Status:%d, Logs:%s",
request.getRequestURI(),
request.getMethod(),
response.getStatus(),
logMessage
);

Level logLevel = logs.stream().map(LogModel::getLevel).max(Comparator.comparingInt(Level::toInt)).orElse(Level.INFO);

LoggingEvent enrichedEvent = new LoggingEvent();
enrichedEvent.setTimeStamp(System.currentTimeMillis());
enrichedEvent.setLoggerName("AggregatedHttpLogger");
enrichedEvent.setLevel(logLevel);
enrichedEvent.setThreadName(Thread.currentThread().getName());
enrichedEvent.setMessage(enrichedLogs);

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
enrichedEvent.setLoggerContext(loggerContext);

logstashAppender.doAppend(enrichedEvent);

CustomAppender.clearLogsForRequest(requestId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.dossierfacile.api.front.log;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class LogConfiguration {

@PostConstruct
public void setupCustomLogging() {
CustomAppender.attachToRootLogger();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fr.dossierfacile.api.front.log;

import ch.qos.logback.classic.Level;
import lombok.Getter;

@Getter
public class LogModel {
String message;
Level level;

public LogModel(String message, Level level) {
this.message = message;
this.level = level;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ logging.logstash.destination=

# Swagger
springdoc.api-docs.groups.enabled=true
application.api.version=3
application.api.version=4
application.name=api-tenant
application.base.url=
tenant.base.url=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
</encoder>
</appender>

<appender name="CUSTOM" class="fr.dossierfacile.api.front.log.CustomAppender"/>

<root level="${LOG_LEVEL}">
<appender-ref ref="LOGSTASH"/>
<appender-ref ref="CUSTOM"/>
<appender-ref ref="STDOUT"/>
<springProfile name="dev">
<appender-ref ref="FILE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ logging.logstash.destination=
file.retention.days=1
cron.process.cleanup=0 0 0 * * ?

application.api.version=3
application.api.version=4
application.name=api-watermark
environment=
2 changes: 1 addition & 1 deletion dossierfacile-bo/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ logging.level.root=info
logging.file.path=logs
logging.logstash.destination=

application.api.version=3
application.api.version=4
application.name=bo
environment=
application.base.url=
Expand Down
11 changes: 9 additions & 2 deletions dossierfacile-common-library/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# DossierFacile-common-library
# Bibliothèque commune (dossierfacile-common-library)

This project contains shared models, repositories, mappers, services, ... used by Dossier-Facile's services.
## Description
Bibliothèque partagée contenant les composants communs utilisés par les différents services du projet.

## Composants principaux
- Entités JPA communes
- Services partagés
- Configurations communes
- Ressources utilitaires
41 changes: 6 additions & 35 deletions dossierfacile-pdf-generator/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
# Dossier-Facile-Pdf-Generator
Dossier Facile PDF Generator
# Générateur de fichiers PDF (dossierfacile-pdf-generator)

## Description
Service dédié à la génération de documents PDF.

# Install and run

To build: `mvn clean install`
To run: `mvn spring-boot:run `

## Requirements
- running DossierFacile database
- running rabbitMQ service

## Configure

We use Github package to store common library `dossierfacile-common-library` .
Thus you need to authenticate yourself to get it on github package.

Configure the following environement variables:
```
GITHUB_USERNAME
GITHUB_TOKEN
```
Or use your global maven settings: <code> .m2/settings.xml</code>
```
<settings>
...
<servers>
<server>
<id>github</id>
<username>GITHUB_USERNAME</username>
<password>GITHUB_TOKEN</password>
</server>
</servers>
...
</settings>
```
## Fonctionnalités principales
- Conversion de documents et fichiers en PDF avec filigrane
- Génération de dossiers de location au format PDF
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ logging.level.root=info
logging.file.path=logs
logging.logstash.destination=

application.api.version=3
application.api.version=4
application.name=pdf-generator
environment=

Expand Down
9 changes: 9 additions & 0 deletions dossierfacile-process-file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Service de traitement asynchrone des fichiers et docuemnts (dossierfacile-process-file)

## Description
Service responsable du traitement asynchrone des documents et des fichiers.

## Fonctionnalités principales
- Miniaturisation des fichiers
- Extraction des données (OCR, lecture 2D Doc, ...)
- Analyse des documents
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ logging.level.root=info
logging.file.path=logs
logging.logstash.destination=

application.api.version=3
application.api.version=4
application.name=process-file
environment=

Expand Down
Loading

0 comments on commit 6506cd1

Please sign in to comment.