From ef16b7e22800a5b200e58dd83fc406bb94dd671a Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 30 Jul 2021 11:28:23 +0200 Subject: Log some EHVD faults on INFO level because they are well known --- .../ehvd/service/EhvdCommunicationService.java | 35 +++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java b/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java index 51bae6dfd..a25a7f421 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java +++ b/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; @@ -19,6 +20,8 @@ import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.ProxyServerType; import org.springframework.beans.factory.annotation.Autowired; +import com.google.common.collect.Sets; + import at.gv.egiz.eaaf.core.api.data.PVPAttributeDefinitions; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink; @@ -53,7 +56,9 @@ public class EhvdCommunicationService implements IEhvdCommunication { private static final String ERROR_EHVD_02 = "ehvd.02"; private static final String ERROR_EHVD_03 = "ehvd.03"; private static final String ERROR_CONFIG_05 = "config.05"; - + + private static final Set SERVICE_ERRORS_LOG_INFO = Sets.newHashSet("6002"); + @Autowired IConfiguration config; @@ -98,12 +103,7 @@ public class EhvdCommunicationService implements IEhvdCommunication { return gdaResp; } catch (final SOAPFaultException e) { - // extract reason for this error - String errorMsg = e.getFault() != null - ? StringUtils.isNotEmpty(e.getFault().getFaultString()) ? e.getFault().getFaultString() : e.getMessage() - : e.getMessage(); - Logger.warn("EHVD communication failed with SOAP response: " + errorMsg, e); - throw new EhvdException(ERROR_EHVD_02, new Object[] {errorMsg}); + throw handleSoapFaultError(e); } catch (final Exception e) { Logger.error("EHVD communication failed with generic error: " + e.getMessage(), e); @@ -113,6 +113,27 @@ public class EhvdCommunicationService implements IEhvdCommunication { } + private EhvdException handleSoapFaultError(SOAPFaultException e) { + // extract reason for this error + String errorMsg = e.getFault() != null + ? StringUtils.isNotEmpty(e.getFault().getFaultString()) ? e.getFault().getFaultString() : e.getMessage() + : e.getMessage(); + + if (SERVICE_ERRORS_LOG_INFO.stream() + .filter(el -> errorMsg.contains(el)) + .findFirst() + .isPresent()) { + Logger.info("EHVD communication failed with SOAP response: " + errorMsg); + + } else { + Logger.warn("EHVD communication failed with SOAP response: " + errorMsg, e); + + } + + return new EhvdException(ERROR_EHVD_02, new Object[] {errorMsg}); + + } + private List parseGdaResponse(GdaIndexResponse ehvdResp) throws EhvdException { if (ehvdResp.getGda() != null) { final GdaDescriptor gdaInfo = ehvdResp.getGda(); -- cgit v1.2.3