From 866d1a6d498482d8734b149b5bebca24927b262a Mon Sep 17 00:00:00 2001 From: cho Date: Wed, 21 Jan 2026 11:10:58 +0900 Subject: [PATCH] =?UTF-8?q?=ED=97=A4=EB=8D=94=EA=B0=92=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/filter/SimpleFrameworkFilter.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/main/java/com/eactive/eai/custom/kjb/adapter/http/client/filter/SimpleFrameworkFilter.java b/src/main/java/com/eactive/eai/custom/kjb/adapter/http/client/filter/SimpleFrameworkFilter.java index b9cf4c1..6190255 100644 --- a/src/main/java/com/eactive/eai/custom/kjb/adapter/http/client/filter/SimpleFrameworkFilter.java +++ b/src/main/java/com/eactive/eai/custom/kjb/adapter/http/client/filter/SimpleFrameworkFilter.java @@ -1,6 +1,8 @@ package com.eactive.eai.custom.kjb.adapter.http.client.filter; +import java.util.Map; import java.util.Properties; +import java.util.TreeMap; import org.apache.commons.lang3.StringUtils; @@ -16,6 +18,7 @@ public class SimpleFrameworkFilter implements HttpClientAdapterFilter, HttpAdapt public static final String TRACEID = "traceId"; public static final String GUID = "guid"; public static final String RECEIVEDTIMESTAMP = "receivedTimestamp"; + public static final String PARTNER_TRACE_ID = "partnerTraceId"; @Override public Object doPreFilter(String adptGrpName, String adptName, Properties prop, Object message, Properties tempProp) @@ -28,6 +31,9 @@ public class SimpleFrameworkFilter implements HttpClientAdapterFilter, HttpAdapt filterHeaders = new Properties(); tempProp.put("FILTERHEADER", filterHeaders); } + + Map inboundHeaderMap = getInboundHeaderProp(tempProp); + try { /* 업체정보 */ String clientId = tempProp.getProperty(HttpAdapterServiceSupport.PROPERTIES_NAME_CLIENT_ID); @@ -49,12 +55,45 @@ public class SimpleFrameworkFilter implements HttpClientAdapterFilter, HttpAdapt String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, ""); filterHeaders.put(RECEIVEDTIMESTAMP, receivedTimestamp); logger.debug("SimpleFrameworkFilter] Processing Key ["+RECEIVEDTIMESTAMP+"], value ["+receivedTimestamp+"]"); + + String partnerTraceId = inboundHeaderMap.getOrDefault(PARTNER_TRACE_ID, ""); + filterHeaders.put(PARTNER_TRACE_ID, partnerTraceId); + logger.debug("SimpleFrameworkFilter] Processing Key ["+PARTNER_TRACE_ID+"], value ["+partnerTraceId+"]"); + } catch (Exception e) { logger.error(e.getMessage()); } return message; } + + public Map getInboundHeaderProp(Properties prop) { + Properties header = new Properties(); + Map inboundHeaderMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + try { + Object headerObj = prop.get(HttpAdapterServiceKey.INBOUND_HEADER); + if (headerObj instanceof Properties) { //tomcat + header = (Properties) headerObj; + for (String name : header.stringPropertyNames()) { + inboundHeaderMap.put(name, header.getProperty(name)); + } + } else if (headerObj instanceof String) { //weblogic + String str = (String) headerObj; + str = str.substring(1, str.length() - 1); + // key=value 쌍 분리 + String[] entries = str.split(","); + for (String entry : entries) { + String[] kv = entry.split("=", 2); + if (kv.length == 2) { + inboundHeaderMap.put(kv[0].trim(), kv[1].trim()); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return inboundHeaderMap; + } @Override public Object doPostFilter(String adptGrpName, String adptName, Properties prop, Object message,