From 352ed16b0d3b1852014e7c619aa03b2a83db3f73 Mon Sep 17 00:00:00 2001 From: Alessio Gallitano <25105748+galales@users.noreply.github.com> Date: Tue, 1 Aug 2023 09:14:34 +0200 Subject: [PATCH] UAT Release (#17) Co-authored-by: gdellorusso <121239135+gdellorusso@users.noreply.github.com> Co-authored-by: melissa-dellorco <102969723+melissa-dellorco@users.noreply.github.com> Co-authored-by: gdellorusso Co-authored-by: Melissa Co-authored-by: alessio-creo <124075593+alessio-creo@users.noreply.github.com> Co-authored-by: angelaantoniaceaa <107028078+angelaantoniaceaa@users.noreply.github.com> Co-authored-by: luigifortunato00 <128594108+luigifortunato00@users.noreply.github.com> Co-authored-by: angelaantonia.cea Co-authored-by: AlessandroColucci <107028283+AlessandroColucci@users.noreply.github.com> Co-authored-by: acolucci --- docs/openapi/probing-service-v1.yaml | 2 +- docs/xsd/probing_v1.xsd | 2 +- .../caller/client/FeignSoapClient.java | 2 +- .../probing/caller/util/ClientUtil.java | 26 ++++++++++++------- .../util/constant/ProjectConstants.java | 1 + .../probing/caller/util/logging/Logger.java | 2 ++ .../caller/util/logging/impl/LoggerImpl.java | 5 ++++ src/main/resources/application.properties | 5 +--- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/docs/openapi/probing-service-v1.yaml b/docs/openapi/probing-service-v1.yaml index 11284c2..7223841 100644 --- a/docs/openapi/probing-service-v1.yaml +++ b/docs/openapi/probing-service-v1.yaml @@ -21,7 +21,7 @@ tags: Read data operations. paths: - '/interop/probing/v1': + '/interop/probing': get: summary: Provides the status of the E-Service tags: diff --git a/docs/xsd/probing_v1.xsd b/docs/xsd/probing_v1.xsd index 70be942..24996ef 100644 --- a/docs/xsd/probing_v1.xsd +++ b/docs/xsd/probing_v1.xsd @@ -1,6 +1,6 @@ diff --git a/src/main/java/it/pagopa/interop/probing/caller/client/FeignSoapClient.java b/src/main/java/it/pagopa/interop/probing/caller/client/FeignSoapClient.java index 76d9cc4..df1a32a 100644 --- a/src/main/java/it/pagopa/interop/probing/caller/client/FeignSoapClient.java +++ b/src/main/java/it/pagopa/interop/probing/caller/client/FeignSoapClient.java @@ -13,7 +13,7 @@ public interface FeignSoapClient { @RequestLine("POST") - @Headers({"SOAPAction: probing/v1", "Content-Type: text/xml;charset=UTF-8", + @Headers({"SOAPAction: interop/probing", "Content-Type: text/xml;charset=UTF-8", "Authorization:Bearer {Authorization}", "Accept: text/xml"}) ProbingResponse probing(URI url, ProbingRequest body, @Param(HttpHeaders.AUTHORIZATION) String authorizationHeader); diff --git a/src/main/java/it/pagopa/interop/probing/caller/util/ClientUtil.java b/src/main/java/it/pagopa/interop/probing/caller/util/ClientUtil.java index c936cfb..4ee0669 100644 --- a/src/main/java/it/pagopa/interop/probing/caller/util/ClientUtil.java +++ b/src/main/java/it/pagopa/interop/probing/caller/util/ClientUtil.java @@ -3,9 +3,11 @@ import java.io.IOException; import java.net.URI; import java.nio.charset.StandardCharsets; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import com.amazonaws.SdkBaseException; import com.amazonaws.xray.AWSXRay; import com.fasterxml.jackson.databind.ObjectMapper; import feign.Response; @@ -17,6 +19,7 @@ import it.pagopa.interop.probing.caller.dtos.Problem; import it.pagopa.interop.probing.caller.soap.probing.ObjectFactory; import it.pagopa.interop.probing.caller.soap.probing.ProbingResponse; +import it.pagopa.interop.probing.caller.util.constant.ProjectConstants; import it.pagopa.interop.probing.caller.util.logging.Logger; @Component @@ -48,9 +51,11 @@ public TelemetryDto callProbing(EserviceContentDto service) { } else { telemetryResult = callSoap(telemetryResult, service); } - - } catch (Exception e) { + } catch (SdkBaseException e) { logger.logMessageException(e); + throw e; + } catch (Exception e) { + logger.logMessageHandledException(e); telemetryResult.status(EserviceStatus.KO).koReason(e.getMessage()); } logger.logMessageResponseCallProbing(telemetryResult); @@ -61,9 +66,11 @@ private TelemetryDto callRest(TelemetryDto telemetryResult, EserviceContentDto s throws IOException { long before = System.currentTimeMillis(); telemetryResult.checkTime(String.valueOf(before)); - AWSXRay.beginSubsegment("Rest_call_to :".concat(service.basePath()[0])); - Response response = restClientConfig.feignRestClient() - .probing(URI.create(service.basePath()[0]), jwtBuilder.buildJWT(service.audience())); + String eserviceUrl = StringUtils.removeEnd(service.basePath()[0], "/") + + ProjectConstants.PROBING_ENDPOINT_SUFFIX; + AWSXRay.beginSubsegment("Rest_call_to :".concat(eserviceUrl)); + Response response = restClientConfig.feignRestClient().probing(URI.create(eserviceUrl), + jwtBuilder.buildJWT(service.audience())); AWSXRay.endSubsegment(); long elapsedTime = System.currentTimeMillis() - before; return receiverResponse(response.status(), telemetryResult, decodeReason(response, elapsedTime), @@ -74,10 +81,11 @@ private TelemetryDto callSoap(TelemetryDto telemetryResult, EserviceContentDto s ObjectFactory o = new ObjectFactory(); long before = System.currentTimeMillis(); telemetryResult.checkTime(String.valueOf(before)); - AWSXRay.beginSubsegment("Soap_call_to :".concat(service.basePath()[0])); - ProbingResponse response = - soapClientConfig.feignSoapClient().probing(URI.create(service.basePath()[0]), - o.createProbingRequest(), jwtBuilder.buildJWT(service.audience())); + String eserviceUrl = StringUtils.removeEnd(service.basePath()[0], "/") + + ProjectConstants.PROBING_ENDPOINT_SUFFIX; + AWSXRay.beginSubsegment("Soap_call_to :".concat(eserviceUrl)); + ProbingResponse response = soapClientConfig.feignSoapClient().probing(URI.create(eserviceUrl), + o.createProbingRequest(), jwtBuilder.buildJWT(service.audience())); AWSXRay.endSubsegment(); long elapsedTime = System.currentTimeMillis() - before; return receiverResponse(Integer.valueOf(response.getStatus()), telemetryResult, diff --git a/src/main/java/it/pagopa/interop/probing/caller/util/constant/ProjectConstants.java b/src/main/java/it/pagopa/interop/probing/caller/util/constant/ProjectConstants.java index 486f7d8..fd603f4 100644 --- a/src/main/java/it/pagopa/interop/probing/caller/util/constant/ProjectConstants.java +++ b/src/main/java/it/pagopa/interop/probing/caller/util/constant/ProjectConstants.java @@ -8,6 +8,7 @@ private ProjectConstants() { public static final String SQS_TELEMETRY_LOG_LABEL = "Telemetry result"; public static final String SQS_POLLING_LOG_LABEL = "Polling result"; + public static final String PROBING_ENDPOINT_SUFFIX = "/interop/probing"; public static final String JWT_SIGNING_ALGORITHM = "RSASSA_PKCS1_V1_5_SHA_256"; } diff --git a/src/main/java/it/pagopa/interop/probing/caller/util/logging/Logger.java b/src/main/java/it/pagopa/interop/probing/caller/util/logging/Logger.java index 4b4325f..d69ca15 100644 --- a/src/main/java/it/pagopa/interop/probing/caller/util/logging/Logger.java +++ b/src/main/java/it/pagopa/interop/probing/caller/util/logging/Logger.java @@ -10,6 +10,8 @@ public interface Logger { void logMessageException(Exception exception); + void logMessageHandledException(Exception exception); + void logMessageCallProbing(String technology, String url); void logResultCallProbing(int code, String body, long elapsedTime); diff --git a/src/main/java/it/pagopa/interop/probing/caller/util/logging/impl/LoggerImpl.java b/src/main/java/it/pagopa/interop/probing/caller/util/logging/impl/LoggerImpl.java index 3c6102b..763e91d 100644 --- a/src/main/java/it/pagopa/interop/probing/caller/util/logging/impl/LoggerImpl.java +++ b/src/main/java/it/pagopa/interop/probing/caller/util/logging/impl/LoggerImpl.java @@ -42,4 +42,9 @@ public void logMessageException(Exception exception) { log.error(ExceptionUtils.getStackTrace(exception)); } + @Override + public void logMessageHandledException(Exception exception) { + log.info(ExceptionUtils.getStackTrace(exception)); + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 72e40ea..10d664c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,7 +15,4 @@ feign.client.config.default.loggerLevel = FULL threadpool.max-pool-size=${THREADPOOL_MAX_POOL_SIZE} threadpool.queue-capacity=${THREADPOOL_QUEUE_CAPACITY} threadpool.core-pool-size=${THREADPOOL_CORE_POOL_SIZE} - threadpool.thread-name-prefix=${THREADPOOL_THREAD_NAME_PREFIX} - - - \ No newline at end of file + threadpool.thread-name-prefix=${THREADPOOL_THREAD_NAME_PREFIX} \ No newline at end of file