NON_DELIVERY_GROUP 기능 추가
This commit is contained in:
+37
-14
@@ -108,6 +108,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
public static final String AUTH_TOKEN = "AUTH_TOKEN";
|
public static final String AUTH_TOKEN = "AUTH_TOKEN";
|
||||||
public static final String HTTP_HEADER_SETTING = "HTTP_HEADER_SETTING";
|
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
|
public static final String PAYLOAD_PARAM_NAME_CLIENT_ID = "client_id"; // jwhong
|
||||||
|
|
||||||
static final String DJB_ROOTLESS_ARRAY = "{ \"DJB_ROOTLESS_ARRAY\" : ";
|
static final String DJB_ROOTLESS_ARRAY = "{ \"DJB_ROOTLESS_ARRAY\" : ";
|
||||||
@@ -135,6 +137,12 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
String bizCode = "";
|
String bizCode = "";
|
||||||
String headerGroupName = prop.getProperty(HEADER_GROUP);
|
String headerGroupName = prop.getProperty(HEADER_GROUP);
|
||||||
String relayResponseHeaderKeys = prop.getProperty(HEADER_KEYS, "");
|
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");
|
useAdapterToken = StringUtils.equalsIgnoreCase(prop.getProperty("ADAPTER_TOKEN_USE_YN", "N"), "Y");
|
||||||
String authorizationHeaderName = prop.getProperty("ADAPTER_TOKEN_HEADER_NAME", "Authorization");
|
String authorizationHeaderName = prop.getProperty("ADAPTER_TOKEN_HEADER_NAME", "Authorization");
|
||||||
|
|
||||||
@@ -253,23 +261,38 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dataObject instanceof ObjectNode) {
|
if (dataObject instanceof ObjectNode) {
|
||||||
if (dataObject != null && StringUtils.isNotBlank(headerGroupName)) {
|
ObjectNode node = (ObjectNode) dataObject;
|
||||||
httpHeader = ((ObjectNode)dataObject).get(headerGroupName);
|
if (StringUtils.isNotBlank(headerGroupName)) {
|
||||||
((ObjectNode)dataObject).remove(headerGroupName);
|
httpHeader = node.get(headerGroupName);
|
||||||
|
node.remove(headerGroupName);
|
||||||
}
|
}
|
||||||
} else if(dataObject instanceof JSONObject) {
|
for (String nonDeliveryGroup : nonDeliveryGroups) {
|
||||||
if (dataObject != null && StringUtils.isNotBlank(headerGroupName)) {
|
if (StringUtils.isNotBlank(nonDeliveryGroup)) node.remove(nonDeliveryGroup.trim());
|
||||||
httpHeader = ((JSONObject)dataObject).get(headerGroupName);
|
}
|
||||||
((JSONObject)dataObject).remove(headerGroupName);
|
} 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) {
|
} else if (dataObject instanceof Document) {
|
||||||
Document doc = (Document)dataObject;
|
Element root = ((Document) dataObject).getRootElement();
|
||||||
if (doc != null && StringUtils.isNotBlank(headerGroupName)) {
|
if (root != null) {
|
||||||
Element root = doc.getRootElement();
|
if (StringUtils.isNotBlank(headerGroupName)) {
|
||||||
Element httpHeaderElement = root.element(headerGroupName);
|
Element httpHeaderElement = root.element(headerGroupName);
|
||||||
root.remove(httpHeaderElement);
|
if (httpHeaderElement != null) root.remove(httpHeaderElement);
|
||||||
httpHeader = 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user