Skip to content

Commit

Permalink
Merge branch 'release/2024.01.03'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien committed Jan 3, 2024
2 parents bc559f4 + 1c016cb commit 2936a66
Show file tree
Hide file tree
Showing 67 changed files with 868 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '18'
java-version: '21'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 20
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '20'
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build & test
Expand Down
10 changes: 7 additions & 3 deletions dossierfacile-api-tenant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
Expand Down Expand Up @@ -166,8 +166,8 @@
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.77</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -233,6 +233,10 @@
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ResponseEntity<Void> confirmAccount(@PathVariable String token) {
public ResponseEntity<TenantModel> names(@Validated(Dossier.class) @RequestBody NamesForm namesForm) {
var tenant = authenticationFacade.getTenant(namesForm.getTenantId() );
TenantModel tenantModel = tenantService.saveStepRegister(tenant, namesForm, StepRegister.NAMES);
logService.saveLog(LogType.ACCOUNT_EDITED, tenantModel.getId());
logService.saveStepLog(tenantModel.getId(), StepRegister.NAMES.getClazz().getSimpleName());
Tenant loggedTenant = (namesForm.getTenantId() == null) ? tenant : authenticationFacade.getLoggedTenant();
return ok(tenantMapper.toTenantModel(loggedTenant));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;

import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -46,13 +47,21 @@ public class DfcTenantsController {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseWrapper<List<TenantUpdate>, ListMetadata>> list(@RequestParam(value = "after", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime after,
@RequestParam(value = "limit", defaultValue = "1000") Long limit,
@RequestParam(value = "includeDeleted", defaultValue = "false") boolean includeDeleted
@RequestParam(value = "includeDeleted", defaultValue = "false") boolean includeDeleted,
@RequestParam(value = "includeRevoked", defaultValue = "false") boolean includeRevoked
) {
UserApi userApi = clientAuthenticationFacade.getClient();
List<TenantUpdate> result = tenantService.findTenantUpdateByLastUpdateAndPartner(after, userApi, limit, includeDeleted);
LocalDateTime nextTimeToken = (result.size() == 0) ? after : result.get(result.size() - 1).getLastUpdateDate();
List<TenantUpdate> result = tenantService.findTenantUpdateByLastUpdateAndPartner(after, userApi, limit, includeDeleted, includeRevoked);

LocalDateTime nextTimeToken = result.isEmpty() ? after : result.get(result.size() - 1).getLastUpdateDate();

String nextLink = UriComponentsBuilder.fromPath(PATH)
.queryParam("limit", limit)
.queryParam("after", nextTimeToken)
.queryParam("includeDeleted", includeDeleted)
.queryParam("includeRevoked", includeRevoked)
.build().encode().toUriString();

String nextLink = PATH + "?limit=" + limit + "&after=" + nextTimeToken + "&includeDeleted=" + includeDeleted;
return ok(ResponseWrapper.<List<TenantUpdate>, ListMetadata>builder()
.metadata(ListMetadata.builder()
.limit(limit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<TenantModel> account(@Validated(ApiPartner.class) @Request
public ResponseEntity<TenantModel> names(@Validated(ApiPartner.class) @RequestBody NamesForm namesForm) {
var tenant = tenantService.findById(namesForm.getTenantId());
var tenantModel = tenantService.saveStepRegister(tenant, namesForm, StepRegister.NAMES);
logService.saveLog(LogType.ACCOUNT_EDITED, tenantModel.getId());
logService.saveStepLog(tenantModel.getId(), StepRegister.NAMES.getClazz().getSimpleName());
return ok(tenantModel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;

import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -46,27 +47,36 @@ public class ApiPartnerTenantController {
public ResponseEntity<ResponseWrapper<List<TenantUpdate>, ListMetadata>> list(@RequestParam(value = "after", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime after,
@RequestParam(value = "limit", defaultValue = "1000") Long limit,
@RequestParam(value = "orderBy", defaultValue = "LAST_UPDATE_DATE") TenantSortType orderBy,
@RequestParam(value = "includeDeleted", defaultValue = "false") boolean includeDeleted
@RequestParam(value = "includeDeleted", defaultValue = "false") boolean includeDeleted,
@RequestParam(value = "includeRevoked", defaultValue = "false") boolean includeRevoked
) {
System.out.println("after = " + after);
UserApi userApi = clientAuthenticationFacade.getClient();
List<TenantUpdate> result;
LocalDateTime nextTimeToken;
switch (orderBy) {
case CREATION_DATE -> {
if (includeDeleted){
throw new IllegalArgumentException("includeDelete is not available with creationDate order");
if (includeDeleted || includeRevoked) {
throw new IllegalArgumentException("includeDelete and includeRevoked are not available with creationDate order");
}
result = tenantService.findTenantUpdateByCreatedAndPartner(after, userApi, limit);
nextTimeToken = (result.size() == 0) ? after : result.get(result.size() - 1).getCreationDate();
nextTimeToken = result.isEmpty() ? after : result.get(result.size() - 1).getCreationDate();
}
case LAST_UPDATE_DATE -> {
result = tenantService.findTenantUpdateByLastUpdateAndPartner(after, userApi, limit, includeDeleted);
nextTimeToken = (result.size() == 0) ? after : result.get(result.size() - 1).getLastUpdateDate();
result = tenantService.findTenantUpdateByLastUpdateAndPartner(after, userApi, limit, includeDeleted, includeRevoked);
nextTimeToken = result.isEmpty() ? after : result.get(result.size() - 1).getLastUpdateDate();
}
default -> throw new IllegalArgumentException();
}

String nextLink = "/api-partner/tenant?limit=" + limit + "&orderBy=" + orderBy + "&after=" + nextTimeToken + "&includeDeleted=" + includeDeleted;
String nextLink = UriComponentsBuilder.fromPath("/api-partner/tenant")
.queryParam("limit", limit)
.queryParam("orderBy", orderBy)
.queryParam("after", nextTimeToken)
.queryParam("includeDeleted", includeDeleted)
.queryParam("includeRevoked", includeRevoked)
.build().encode().toUriString();

return ok(ResponseWrapper.<List<TenantUpdate>, ListMetadata>builder()
.metadata(ListMetadata.builder()
.limit(limit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import fr.dossierfacile.common.entity.Tenant;
import fr.dossierfacile.common.enums.PartnerCallBackType;
import fr.dossierfacile.common.enums.TenantFileStatus;
import fr.dossierfacile.common.model.log.EditionType;
import fr.dossierfacile.common.repository.TenantCommonRepository;
import fr.dossierfacile.common.service.interfaces.LogService;
import fr.dossierfacile.common.service.interfaces.PartnerCallBackService;
Expand Down Expand Up @@ -46,7 +47,7 @@ public TenantModel saveStep(Tenant tenant, T documentForm) {
}

Document document = saveDocument(tenant, documentForm);
logService.saveDocumentEditedLog(document, tenant);
logService.saveDocumentEditedLog(document, tenant, EditionType.ADD);
documentService.markDocumentAsEdited(document);

TransactionalUtil.afterCommit(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,39 @@

@Getter
public enum StepRegister {
ACCOUNT_PARTNER_API(AccountApiPartner.class.getName()),
ACCOUNT(Account.class.getName()),
NAMES(Names.class.getName()),
APPLICATION_V1(ApplicationV1.class.getName()),
APPLICATION(Application.class.getName()),
HONOR_DECLARATION(HonorDeclaration.class.getName()),
DOCUMENT_IDENTIFICATION(DocumentIdentification.class.getName()),
DOCUMENT_RESIDENCY(DocumentResidency.class.getName()),
DOCUMENT_PROFESSIONAL(DocumentProfessional.class.getName()),
DOCUMENT_FINANCIAL(DocumentFinancial.class.getName()),
DOCUMENT_TAX(DocumentTax.class.getName()),
NAME_GUARANTOR_NATURAL_PERSON(NameGuarantorNaturalPerson.class.getName()),
DOCUMENT_IDENTIFICATION_GUARANTOR_NATURAL_PERSON_FILE(DocumentIdentificationGuarantorNaturalPersonFile.class.getName()),
DOCUMENT_IDENTIFICATION_GUARANTOR_NATURAL_PERSON(DocumentIdentificationGuarantorNaturalPerson.class.getName()),
DOCUMENT_RESIDENCY_GUARANTOR_NATURAL_PERSON(DocumentResidencyGuarantorNaturalPerson.class.getName()),
DOCUMENT_PROFESSIONAL_GUARANTOR_NATURAL_PERSON(DocumentProfessionalGuarantorNaturalPerson.class.getName()),
DOCUMENT_FINANCIAL_GUARANTOR_NATURAL_PERSON(DocumentFinancialGuarantorNaturalPerson.class.getName()),
DOCUMENT_TAX_GUARANTOR_NATURAL_PERSON(DocumentTaxGuarantorNaturalPerson.class.getName()),
DOCUMENT_IDENTIFICATION_GUARANTOR_ORGANISM(DocumentIdentificationGuarantorOrganism.class.getName()),
DOCUMENT_IDENTIFICATION_GUARANTOR_LEGAL_PERSON(DocumentIdentificationGuarantorLegalPerson.class.getName()),
DOCUMENT_IDENTIFICATION_REPRESENTANT_GUARANTOR_LEGAL_PERSON(DocumentIdentificationRepresentanGuarantorLegalPerson.class.getName()),
GUARANTOR_TYPE(GuarantorType.class.getName()),
NAME_GUARANTOR_LEGAL_PERSON(NameGuarantorLegalPerson.class.getName()),
NAME_IDENTIFICATION_REPRESENTANT_GUARANTOR_LEGAL_PERSON(NameRepresentantGuarantorLegalPerson.class.getName());
private final String label;
ACCOUNT_PARTNER_API(AccountApiPartner.class),
ACCOUNT(Account.class),
NAMES(Names.class),
APPLICATION_V1(ApplicationV1.class),
APPLICATION(Application.class),
HONOR_DECLARATION(HonorDeclaration.class),
DOCUMENT_IDENTIFICATION(DocumentIdentification.class),
DOCUMENT_RESIDENCY(DocumentResidency.class),
DOCUMENT_PROFESSIONAL(DocumentProfessional.class),
DOCUMENT_FINANCIAL(DocumentFinancial.class),
DOCUMENT_TAX(DocumentTax.class),
NAME_GUARANTOR_NATURAL_PERSON(NameGuarantorNaturalPerson.class),
DOCUMENT_IDENTIFICATION_GUARANTOR_NATURAL_PERSON_FILE(DocumentIdentificationGuarantorNaturalPersonFile.class),
DOCUMENT_IDENTIFICATION_GUARANTOR_NATURAL_PERSON(DocumentIdentificationGuarantorNaturalPerson.class),
DOCUMENT_RESIDENCY_GUARANTOR_NATURAL_PERSON(DocumentResidencyGuarantorNaturalPerson.class),
DOCUMENT_PROFESSIONAL_GUARANTOR_NATURAL_PERSON(DocumentProfessionalGuarantorNaturalPerson.class),
DOCUMENT_FINANCIAL_GUARANTOR_NATURAL_PERSON(DocumentFinancialGuarantorNaturalPerson.class),
DOCUMENT_TAX_GUARANTOR_NATURAL_PERSON(DocumentTaxGuarantorNaturalPerson.class),
DOCUMENT_IDENTIFICATION_GUARANTOR_ORGANISM(DocumentIdentificationGuarantorOrganism.class),
DOCUMENT_IDENTIFICATION_GUARANTOR_LEGAL_PERSON(DocumentIdentificationGuarantorLegalPerson.class),
DOCUMENT_IDENTIFICATION_REPRESENTANT_GUARANTOR_LEGAL_PERSON(DocumentIdentificationRepresentanGuarantorLegalPerson.class),
GUARANTOR_TYPE(GuarantorType.class),
NAME_GUARANTOR_LEGAL_PERSON(NameGuarantorLegalPerson.class),
NAME_IDENTIFICATION_REPRESENTANT_GUARANTOR_LEGAL_PERSON(NameRepresentantGuarantorLegalPerson.class);

StepRegister(String label) {
this.label = label;
private final Class<?> clazz;

StepRegister(Class<?> clazz) {
this.clazz = clazz;
}

public String getLabel() {
return clazz.getName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ protected void linkEmailToTenants(Tenant tenantCreate, List<Pair<Tenant, String>
}
}

TenantModel saveStep(Tenant tenant, ApplicationType applicationType, List<Tenant> tenantToDelete, List<CoTenantForm> tenantToCreate) {
TenantModel saveStep(Tenant tenant, ApplicationType newApplicationType, List<Tenant> tenantToDelete, List<CoTenantForm> tenantToCreate) {
ApartmentSharing apartmentSharing = tenant.getApartmentSharing();
apartmentSharing.setApplicationType(applicationType);
ApplicationType currentApplicationType = apartmentSharing.getApplicationType();
apartmentSharing.setApplicationType(newApplicationType);
apartmentSharingService.resetDossierPdfGenerated(apartmentSharing);

deleteCoTenants(tenantToDelete);
logService.saveApplicationTypeChangedLog(apartmentSharing.getTenants(), currentApplicationType, newApplicationType);
createCoTenants(tenant, tenantToCreate, apartmentSharing);

LocalDateTime now = LocalDateTime.now();
Expand Down Expand Up @@ -226,7 +228,7 @@ private void createCoTenants(Tenant tenantCreate, List<CoTenantForm> tenants, Ap
}

private void deleteCoTenants(List<Tenant> tenantToDelete) {
tenantToDelete.stream().forEach(t -> userService.deleteAccount(t));
tenantToDelete.forEach(userService::deleteAccount);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
import fr.dossierfacile.api.front.service.interfaces.TenantStatusService;
import fr.dossierfacile.api.front.util.TransactionalUtil;
import fr.dossierfacile.common.entity.Document;
import fr.dossierfacile.common.entity.DocumentAnalysisReport;
import fr.dossierfacile.common.entity.File;
import fr.dossierfacile.common.entity.Person;
import fr.dossierfacile.common.entity.StorageFile;
import fr.dossierfacile.common.entity.Tenant;
import fr.dossierfacile.common.enums.DocumentCategory;
import fr.dossierfacile.common.enums.DocumentStatus;
import fr.dossierfacile.common.enums.TenantFileStatus;
import fr.dossierfacile.common.model.log.EditionType;
import fr.dossierfacile.common.repository.DocumentAnalysisReportRepository;
import fr.dossierfacile.common.repository.StorageFileRepository;
import fr.dossierfacile.common.service.interfaces.DocumentHelperService;
import fr.dossierfacile.common.service.interfaces.LogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -46,6 +47,7 @@ public class DocumentServiceImpl implements DocumentService {
private final ApartmentSharingService apartmentSharingService;
private final DocumentHelperService documentHelperService;
private final MinifyFileProducer minifyFileProducer;
private final LogService logService;
private final Producer producer;

@Override
Expand Down Expand Up @@ -98,6 +100,7 @@ public void delete(Long documentId, Tenant referenceTenant) {
Document document = documentRepository.findByIdForApartmentSharing(documentId, referenceTenant.getApartmentSharing().getId())
.orElseThrow(() -> new DocumentNotFoundException(documentId));
delete(document);
logService.saveDocumentEditedLog(document, referenceTenant, EditionType.DELETE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
import fr.dossierfacile.common.entity.File;
import fr.dossierfacile.common.entity.Tenant;
import fr.dossierfacile.common.enums.DocumentStatus;
import fr.dossierfacile.common.model.log.EditionType;
import fr.dossierfacile.common.service.interfaces.LogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
@AllArgsConstructor
@Slf4j
Expand All @@ -36,7 +35,7 @@ public Document delete(Long id, Tenant tenant) {
document.getFiles().remove(file);
fileRepository.delete(file);

logService.saveDocumentEditedLog(document, tenant);
logService.saveDocumentEditedLog(document, tenant, EditionType.DELETE);
documentService.markDocumentAsEdited(document);

if (document.getFiles().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import fr.dossierfacile.common.entity.Tenant;
import fr.dossierfacile.common.entity.TenantUserApi;
import fr.dossierfacile.common.entity.UserApi;
import fr.dossierfacile.common.repository.TenantCommonRepository;
import fr.dossierfacile.common.repository.TenantUserApiRepository;
import fr.dossierfacile.common.service.interfaces.LogService;
import fr.dossierfacile.common.service.interfaces.PartnerCallBackService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
Expand All @@ -26,6 +28,7 @@ public class PartnerAccessServiceImpl implements PartnerAccessService {

private final TenantUserApiRepository tenantUserApiRepository;
private final PartnerCallBackService partnerCallBackService;
private final TenantCommonRepository tenantRepository;
private final PartnerAccessMapper partnerAccessMapper;
private final KeycloakService keycloakService;
private final MailService mailService;
Expand All @@ -46,8 +49,10 @@ public void deleteAccess(Tenant tenant, Long userApiId) {
}

private void deleteAccess(TenantUserApi tenantUserApi) {
Tenant tenant = tenantUserApi.getTenant();
UserApi userApi = tenantUserApi.getUserApi();
Tenant tenant = tenantUserApi.getTenant();
tenant.setLastUpdateDate(LocalDateTime.now());
tenantRepository.save(tenant);

tenantUserApiRepository.delete(tenantUserApi);
partnerCallBackService.sendRevokedAccessCallback(tenant, userApi);
Expand Down
Loading

0 comments on commit 2936a66

Please sign in to comment.