From 9488e734d719edb6d3d82c058e0c910b73057abb Mon Sep 17 00:00:00 2001 From: Vincenzo Ingenito Date: Fri, 22 Sep 2023 11:16:51 +0200 Subject: [PATCH] feat: Remove EDS flow --- .../dispatcher/client/impl/ConfigClient.java | 2 +- .../client/impl/ValidatorClient.java | 26 ++++------ .../controller/impl/PublicationCTL.java | 51 +++---------------- .../gtw/dispatcher/enums/EdsStrategyEnum.java | 1 - .../repository/mongo/impl/EngineRepo.java | 1 - .../ms/gtw/dispatcher/service/IConfigSRV.java | 1 - .../dispatcher/service/impl/ConfigSRV.java | 21 +++----- 7 files changed, 24 insertions(+), 79 deletions(-) diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ConfigClient.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ConfigClient.java index e06d767f..ba32053b 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ConfigClient.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ConfigClient.java @@ -84,7 +84,7 @@ public String getGatewayName() { @Override public String getEDSStrategy() { - String output = EdsStrategyEnum.NO_EDS.name(); + String output = EdsStrategyEnum.NO_EDS_WITH_LOG.name(); if(isReachable()) { String endpoint = msUrlCFG.getConfigHost() + "/v1/config-items/props?type=GENERIC&props=eds-strategy"; output = restTemplate.getForObject(endpoint,String.class); diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ValidatorClient.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ValidatorClient.java index 832fc1b6..b2eeb025 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ValidatorClient.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/ValidatorClient.java @@ -11,8 +11,17 @@ */ package it.finanze.sanita.fse2.ms.gtw.dispatcher.client.impl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.ResourceAccessException; +import org.springframework.web.client.RestTemplate; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IValidatorClient; import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.impl.base.AbstractClient; @@ -24,25 +33,10 @@ import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response.client.ValidationResDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.ErrorInstanceEnum; import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.RestExecutionResultEnum; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ConnectionRefusedException; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ValidationException; -import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IValidatorClient; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.impl.base.AbstractClient; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.config.MicroservicesURLCFG; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.ValidationInfoDTO; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.client.ValidationRequestDTO; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response.client.ValidationResDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.SystemTypeEnum; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ConnectionRefusedException; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ValidationException; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Component; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.ResourceAccessException; -import org.springframework.web.client.RestTemplate; /** * Production implemention of Validator Client. diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java index b7d3538d..76f793e7 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java @@ -14,8 +14,6 @@ import static it.finanze.sanita.fse2.ms.gtw.dispatcher.config.Constants.App.MISSING_WORKFLOW_PLACEHOLDER; import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventStatusEnum.BLOCKING_ERROR; import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventStatusEnum.SUCCESS; -import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.EDS_DELETE; -import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.EDS_UPDATE; import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.INI_DELETE; import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.INI_UPDATE; import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.RIFERIMENTI_INI; @@ -32,12 +30,10 @@ import static it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.StringUtility.isNullOrEmpty; import java.util.Date; -import java.util.Objects; import javax.servlet.http.HttpServletRequest; import javax.validation.constraints.Size; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.*; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +44,6 @@ import com.google.gson.Gson; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IEdsClient; import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IIniClient; import it.finanze.sanita.fse2.ms.gtw.dispatcher.config.AccreditationSimulationCFG; import it.finanze.sanita.fse2.ms.gtw.dispatcher.config.Constants; @@ -62,7 +57,6 @@ import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.ValidationCreationInputDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.ValidationDataDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.DeleteRequestDTO; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.EdsMetadataUpdateReqDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.IniMetadataUpdateReqDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.IniReferenceRequestDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.MergedMetadatiRequestDTO; @@ -91,12 +85,17 @@ import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.SystemTypeEnum; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.BusinessException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ConnectionRefusedException; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.EdsException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.IniException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.MockEnabledException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.NoRecordFoundException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.ValidationException; import it.finanze.sanita.fse2.ms.gtw.dispatcher.logging.LoggerHelper; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IAccreditamentoSimulationSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IDocumentReferenceSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IErrorHandlerSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IJwtSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IKafkaSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.ISignSRV; import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.facade.ICdaFacadeSRV; import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.impl.IniEdsInvocationSRV; import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.CdaUtility; @@ -132,12 +131,6 @@ public class PublicationCTL extends AbstractCTL implements IPublicationCTL { @Autowired private IIniClient iniClient; - @Autowired - private IEdsClient edsClient; - - @Autowired - private IConfigSRV edsStrategy; - @Autowired private ValidationCFG validationCFG; @@ -297,17 +290,6 @@ public ResponseWifDTO updateMetadata(final String idDoc, final PublicationMetada kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, SUCCESS, jwtPayloadToken, "Merge metadati effettuato correttamente", RIFERIMENTI_INI); } - // Omit if strategy is no-eds - if(edsStrategy.isNoFhirEds()) { - EdsResponseDTO edsResponse = edsClient.update(new EdsMetadataUpdateReqDTO(idDoc, wif, requestBody)); - if (edsResponse.isEsito()) { - kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, SUCCESS, jwtPayloadToken, "Update EDS effettuato correttamente", EDS_UPDATE); - } else { - kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, BLOCKING_ERROR, jwtPayloadToken, "Update EDS fallito", EDS_UPDATE); - throw new EdsException(edsResponse.getMessageError()); - } - } - // Keep going independently of the strategy if (regimeDiMock) { kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, SUCCESS, jwtPayloadToken, "Regime di mock", @@ -502,26 +484,7 @@ public ResponseWifDTO delete(String idDoc, HttpServletRequest request) { } EdsResponseDTO edsResponse = new EdsResponseDTO(true,"EDS Mock","EDS Mock"); - - if(edsStrategy.isNoFhirEds()) { - // ============================== - // [2] Send delete request to EDS - // ============================== - edsResponse = edsClient.delete(idDoc); - // Exit if necessary - Objects.requireNonNull(edsResponse, "PublicationCTL returned an error - edsResponse is null!"); - - if (!edsResponse.isEsito()) { - // Update transaction status - kafkaSRV.sendDeleteStatus(info.getTraceID(), workflowInstanceId, idDoc, edsResponse.getMessageError(), BLOCKING_ERROR, jwtPayloadToken, EDS_DELETE); - throw new EdsException("Error encountered while sending delete information to EDS client"); - } else { - // Update transaction status - kafkaSRV.sendDeleteStatus(info.getTraceID(), workflowInstanceId, idDoc, "Delete effettuata su eds", SUCCESS, jwtPayloadToken, EDS_DELETE); - } - } - - + // ============================== // [3] Send delete request to INI // ============================== diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/enums/EdsStrategyEnum.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/enums/EdsStrategyEnum.java index ab3306c5..c568dad3 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/enums/EdsStrategyEnum.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/enums/EdsStrategyEnum.java @@ -2,6 +2,5 @@ public enum EdsStrategyEnum { NO_EDS, - NO_FHIR_EDS, NO_EDS_WITH_LOG } diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/repository/mongo/impl/EngineRepo.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/repository/mongo/impl/EngineRepo.java index 9d341305..0df765bb 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/repository/mongo/impl/EngineRepo.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/repository/mongo/impl/EngineRepo.java @@ -27,7 +27,6 @@ import static org.springframework.data.mongodb.core.query.Criteria.where; @Repository -@Slf4j public class EngineRepo implements IEngineRepo { @Autowired diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/IConfigSRV.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/IConfigSRV.java index 54c56754..ae681d01 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/IConfigSRV.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/IConfigSRV.java @@ -6,5 +6,4 @@ public interface IConfigSRV { boolean isNoEds(); - boolean isNoFhirEds(); } diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/ConfigSRV.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/ConfigSRV.java index 19fb16e0..147fdf2d 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/ConfigSRV.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/ConfigSRV.java @@ -1,18 +1,17 @@ package it.finanze.sanita.fse2.ms.gtw.dispatcher.service.impl; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IConfigClient; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EdsStrategyEnum; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IConfigSRV; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.StringUtility; +import java.util.Date; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import java.util.Date; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IConfigClient; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EdsStrategyEnum; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IConfigSRV; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.StringUtility; @Service public class ConfigSRV implements IConfigSRV { @@ -50,18 +49,10 @@ public String getEdsStrategy() { return edsStrategy; } - @Override - public boolean isNoFhirEds() { - // Trigger refresh if necessary - String out = getEdsStrategy(); - // Evaluate - return StringUtils.isNotBlank(out) && EdsStrategyEnum.NO_FHIR_EDS.name().equalsIgnoreCase(out); - } - //Se la strategy รจ null si setta come default no_eds (quindi non verranno emesse loggate) @Override public boolean isNoEds() { String out = getEdsStrategy(); - return StringUtility.isNullOrEmpty(out) || EdsStrategyEnum.NO_EDS.name().equalsIgnoreCase(out); + return !StringUtility.isNullOrEmpty(out) && EdsStrategyEnum.NO_EDS.name().equalsIgnoreCase(out); } }