NON_DELIVERY_GROUP 기능 추가
This commit is contained in:
+35
-12
@@ -108,6 +108,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
public static final String AUTH_TOKEN = "AUTH_TOKEN";
|
||||
public static final String HTTP_HEADER_SETTING = "HTTP_HEADER_SETTING";
|
||||
|
||||
public static final String NON_DELIVERY_GROUP = "NON_DELIVERY_GROUP";
|
||||
|
||||
public static final String PAYLOAD_PARAM_NAME_CLIENT_ID = "client_id"; // jwhong
|
||||
|
||||
static final String DJB_ROOTLESS_ARRAY = "{ \"DJB_ROOTLESS_ARRAY\" : ";
|
||||
@@ -135,6 +137,12 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
String bizCode = "";
|
||||
String headerGroupName = prop.getProperty(HEADER_GROUP);
|
||||
String relayResponseHeaderKeys = prop.getProperty(HEADER_KEYS, "");
|
||||
|
||||
// 전송 대상에서 제외할 그룹명(콤마로 다건 지정 가능)
|
||||
String[] nonDeliveryGroups = StringUtils.split(
|
||||
StringUtils.trimToEmpty(prop.getProperty(NON_DELIVERY_GROUP)), ",");
|
||||
if (nonDeliveryGroups == null) nonDeliveryGroups = new String[0];
|
||||
|
||||
useAdapterToken = StringUtils.equalsIgnoreCase(prop.getProperty("ADAPTER_TOKEN_USE_YN", "N"), "Y");
|
||||
String authorizationHeaderName = prop.getProperty("ADAPTER_TOKEN_HEADER_NAME", "Authorization");
|
||||
|
||||
@@ -253,24 +261,39 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
}
|
||||
}
|
||||
|
||||
if(dataObject instanceof ObjectNode) {
|
||||
if (dataObject != null && StringUtils.isNotBlank(headerGroupName)) {
|
||||
httpHeader = ((ObjectNode)dataObject).get(headerGroupName);
|
||||
((ObjectNode)dataObject).remove(headerGroupName);
|
||||
if (dataObject instanceof ObjectNode) {
|
||||
ObjectNode node = (ObjectNode) dataObject;
|
||||
if (StringUtils.isNotBlank(headerGroupName)) {
|
||||
httpHeader = node.get(headerGroupName);
|
||||
node.remove(headerGroupName);
|
||||
}
|
||||
} else if(dataObject instanceof JSONObject) {
|
||||
if (dataObject != null && StringUtils.isNotBlank(headerGroupName)) {
|
||||
httpHeader = ((JSONObject)dataObject).get(headerGroupName);
|
||||
((JSONObject)dataObject).remove(headerGroupName);
|
||||
for (String nonDeliveryGroup : nonDeliveryGroups) {
|
||||
if (StringUtils.isNotBlank(nonDeliveryGroup)) node.remove(nonDeliveryGroup.trim());
|
||||
}
|
||||
} else if (dataObject instanceof JSONObject) {
|
||||
JSONObject json = (JSONObject) dataObject;
|
||||
if (StringUtils.isNotBlank(headerGroupName)) {
|
||||
httpHeader = json.get(headerGroupName);
|
||||
json.remove(headerGroupName);
|
||||
}
|
||||
for (String nonDeliveryGroup : nonDeliveryGroups) {
|
||||
if (StringUtils.isNotBlank(nonDeliveryGroup)) json.remove(nonDeliveryGroup.trim());
|
||||
}
|
||||
} else if (dataObject instanceof Document) {
|
||||
Document doc = (Document)dataObject;
|
||||
if (doc != null && StringUtils.isNotBlank(headerGroupName)) {
|
||||
Element root = doc.getRootElement();
|
||||
Element root = ((Document) dataObject).getRootElement();
|
||||
if (root != null) {
|
||||
if (StringUtils.isNotBlank(headerGroupName)) {
|
||||
Element httpHeaderElement = root.element(headerGroupName);
|
||||
root.remove(httpHeaderElement);
|
||||
if (httpHeaderElement != null) root.remove(httpHeaderElement);
|
||||
httpHeader = httpHeaderElement;
|
||||
}
|
||||
// element(null) 은 dom4j 내부에서 NPE 가 발생하므로 반드시 blank 검사 후 조회한다
|
||||
for (String nonDeliveryGroup : nonDeliveryGroups) {
|
||||
if (StringUtils.isBlank(nonDeliveryGroup)) continue;
|
||||
Element nonDeliveryGroupElement = root.element(nonDeliveryGroup.trim());
|
||||
if (nonDeliveryGroupElement != null) root.remove(nonDeliveryGroupElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("HttpClientAdapterServiceRest] dataObject2 = [" + dataObject + "]");
|
||||
|
||||
Reference in New Issue
Block a user