From 02b870f95b0358e6bc16769dd18e240fe65342d5 Mon Sep 17 00:00:00 2001 From: etreschenkov Date: Fri, 7 Jul 2023 13:18:37 +0300 Subject: [PATCH] http://jira.mfd.msk:8088/browse/CLS-367 --- .../gatewayapi/service/GatewayService.java | 27 +++++++++++-------- .../builders/OutboundRequestBuilder.java | 8 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/GatewayService.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/GatewayService.java index 3b7404fd2..a5396a561 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/GatewayService.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/GatewayService.java @@ -29,6 +29,7 @@ import ru.spcex.clearing.platform.messaging.service.QueueConsumer; import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate; import ru.spcex.clearing.util.security.UserRoleVerification; import ru.spcex.platform.enumeration.ReportKeys; +import ru.spcex.platform.enumeration.ReportType; import ru.spcex.platform.enumeration.Section; import ru.spcex.platform.enumeration.Task; import ru.spcex.platform.utils.enumeration.IEnumKey; @@ -94,7 +95,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean { String url = formingInboundUrl(inboundServerSettings.getPathLOCM()); OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder() - .type(OutboundRequestType.MEMBER_ON_DEMAND) + .type(OutboundRequestType.MEMBER_ON_DEMAND.getKey()) .build(); HttpEntity request = makeDefaultRequest(outboundFondRequest); @@ -114,7 +115,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean { OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder() .section(exportedRequest.getSection()) - .type(OutboundRequestType.FILL_LIMITS) + .type(OutboundRequestType.FILL_LIMITS.getKey()) .content(content) .build(); @@ -139,12 +140,12 @@ public class GatewayService extends QueueConsumer implements InitializingBean { OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder() .section(Section.FOND.getKey()) - .type(OutboundRequestType.ON_DEMAND) + .type(OutboundRequestType.ON_DEMAND.getKey()) .build(); OutboundRequest outboundMkrRequest = OutboundRequestBuilder.builder() .section(Section.MKR.getKey()) - .type(OutboundRequestType.ON_DEMAND) + .type(OutboundRequestType.ON_DEMAND.getKey()) .build(); HttpEntity requestFond = makeDefaultRequest(outboundFondRequest); @@ -183,7 +184,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean { OutboundRequest outboundRequest = OutboundRequestBuilder.builder() .section(Section.MKR.getKey()) - .type(OutboundRequestType.ASSET_OPERATION) + .type(OutboundRequestType.ASSET_OPERATION.getKey()) .content(content).build(); String url = formingInboundUrl(inboundServerSettings.getPathLOCM()); @@ -210,8 +211,8 @@ public class GatewayService extends QueueConsumer implements InitializingBean { public void requestOnReport(BaseRequest request) { SendReportRequest reportRequest = request.getRequestPayload(); - OutboundRequestType outboundRequestType = IEnumKey.getEnumByKey(OutboundRequestType.class, reportRequest.getType()); - if (outboundRequestType == null) { + ReportType reportType = IEnumKey.getEnumByKey(ReportType.class, reportRequest.getType()); + if (reportType == null) { log.warn("Undefined type of request: {}; skip", reportRequest.getType()); return; } @@ -220,7 +221,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean { Map content = makeContentByReportRequest(reportPart); OutboundRequest outboundRequest = OutboundRequestBuilder.builder() .section(Section.FOND.getKey()) - .type(outboundRequestType) + .type(reportType.getKey()) .content(content).build(); String url = formingInboundUrl(inboundServerSettings.getPathLOCM()); @@ -236,13 +237,17 @@ public class GatewayService extends QueueConsumer implements InitializingBean { protected Map makeContentByReportRequest(ReportPart reportPart) { Map content = new HashMap<>(); Matcher matcher = REPORT_FILE_NAME_PATTERN.matcher(reportPart.getFileName()); - ReportKeys reportKeys = null; + ReportKeys reportKey = null; if (matcher.matches()) { String rowKey = matcher.group(1); - reportKeys = IEnumKey.getEnumByKeyOrUndefined(ReportKeys.class, rowKey); + reportKey = IEnumKey.getEnumByKeyOrUndefined(ReportKeys.class, rowKey); + } + if (reportKey == null) { + log.warn("Mismatched filename pattern : {}; {}", reportPart.getFileName(), REPORT_FILE_NAME_PATTERN); + return content; } String paramName = null; - switch (reportKeys) { + switch (reportKey) { case KS_BR_PFX64_INFTYPE_1 -> paramName = "inftype_1"; case KS_BR_PFX64_INFTYPE_2 -> paramName = "inftype_2"; case KS_BR_PFX64_INFTYPE_3 -> paramName = "inftype_3"; diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/builders/OutboundRequestBuilder.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/builders/OutboundRequestBuilder.java index 6d7c1f853..766a1e010 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/builders/OutboundRequestBuilder.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/builders/OutboundRequestBuilder.java @@ -1,7 +1,6 @@ package ru.spcex.clearing.gatewayapi.service.builders; import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest; -import ru.spcex.clearing.gatewayapi.enums.OutboundRequestType; import java.time.Instant; import java.util.Map; @@ -10,7 +9,7 @@ import java.util.UUID; public class OutboundRequestBuilder { private String section; - private OutboundRequestType requestType; + private String requestType; private Map content; private OutboundRequestBuilder() { @@ -25,11 +24,12 @@ public class OutboundRequestBuilder { return this; } - public OutboundRequestBuilder type(OutboundRequestType outboundRequestType) { + public OutboundRequestBuilder type(String outboundRequestType) { this.requestType = outboundRequestType; return this; } + public OutboundRequestBuilder content(Map content) { this.content = content; return this; @@ -43,7 +43,7 @@ public class OutboundRequestBuilder { outboundRequest.setSection(section); } if (requestType != null) { - outboundRequest.setType(requestType.getKey()); + outboundRequest.setType(requestType); } outboundRequest.setContent(content); return outboundRequest;