에러응답 처리 수정
This commit is contained in:
@@ -61,6 +61,7 @@ public class DJErpApiAdapterController implements HttpAdapterServiceKey {
|
|||||||
"/tss/{path:^(?!oauth).*$}", "/tss/{path:^(?!oauth).*$}/**",
|
"/tss/{path:^(?!oauth).*$}", "/tss/{path:^(?!oauth).*$}/**",
|
||||||
"/tsb/{path:^(?!oauth).*$}", "/tsb/{path:^(?!oauth).*$}/**",
|
"/tsb/{path:^(?!oauth).*$}", "/tsb/{path:^(?!oauth).*$}/**",
|
||||||
"/shb/{path:^(?!oauth).*$}", "/shb/{path:^(?!oauth).*$}/**",
|
"/shb/{path:^(?!oauth).*$}", "/shb/{path:^(?!oauth).*$}/**",
|
||||||
|
"/tst/{path:^(?!oauth).*$}", "/tst/{path:^(?!oauth).*$}/**",
|
||||||
})
|
})
|
||||||
public ResponseEntity<String> callApi(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
|
public ResponseEntity<String> callApi(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
package com.eactive.eai.custom.adapter.handler;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.eactive.eai.adapter.handler.TemplateAdapterErrorMsgHandler;
|
||||||
|
import com.eactive.eai.adapter.handler.TemplateCodeConvertAdapterErrorMsgHandler;
|
||||||
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
|
import com.eactive.eai.common.message.EAIMessage;
|
||||||
|
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
import com.eactive.eai.custom.message.StandardMessageCoordinatorDJB;
|
||||||
|
import com.eactive.eai.message.StandardItem;
|
||||||
|
import com.eactive.eai.message.StandardMessage;
|
||||||
|
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||||
|
import com.eactive.eai.message.service.InterfaceMapper;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class KakaopayAdapterErrorMsgHandler extends TemplateCodeConvertAdapterErrorMsgHandler {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
|
|
||||||
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object generateNonStandardErrorResponseMessage(String inboundAdapterGroupName, String inboundAdapterName,
|
||||||
|
Properties callProp, Object outboundRequestData, EAIMessage resEaiMsg) throws Exception {
|
||||||
|
|
||||||
|
Object responseMsessage = super.generateNonStandardErrorResponseMessage(inboundAdapterGroupName,
|
||||||
|
inboundAdapterName, callProp, outboundRequestData, resEaiMsg);
|
||||||
|
|
||||||
|
logger.debug("generateNonStandardErrorResponseMessage - {}", responseMsessage);
|
||||||
|
|
||||||
|
if (!(responseMsessage instanceof String)) {
|
||||||
|
return responseMsessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
String jsonStr = (String) responseMsessage;
|
||||||
|
if (StringUtils.isBlank(jsonStr)) {
|
||||||
|
return responseMsessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode rootNode = OBJECT_MAPPER.readTree(jsonStr);
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
|
||||||
|
if (modified) {
|
||||||
|
responseMsessage = OBJECT_MAPPER.writeValueAsString(rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseMsessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 표준 -> 비표준 거래 아웃바운드 어댑터에서 Exception이 발생했을 때, Outbound Process 응답 메시지 생성
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object generateOutboundErrorResponseMessage(String outboundadapterGroupName, String outboundadapterName,
|
||||||
|
Properties callProp, Object outboundRequestData, EAIMessage resEaiMsg) throws Exception {
|
||||||
|
|
||||||
|
String msgCd = "error";
|
||||||
|
String msgCtnt = "IF오류";
|
||||||
|
String msgDesc = "";
|
||||||
|
// 에러에 대한 응답메시지
|
||||||
|
if (callProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP) instanceof Map) {
|
||||||
|
Map<String, Object> map = (Map<String, Object>) callProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP);
|
||||||
|
Object responseBody = map.get(HttpAdapterServiceKey.OUTBOUND_RESPONSE_MESSAGE);
|
||||||
|
|
||||||
|
if (responseBody instanceof String) {
|
||||||
|
String jsonStr = (String) responseBody;
|
||||||
|
if (!StringUtils.isBlank(jsonStr)) {
|
||||||
|
JsonNode rootNode = OBJECT_MAPPER.readTree(jsonStr);
|
||||||
|
msgDesc = rootNode.get("error_code").textValue() + "/" + rootNode.get("error_message").textValue();
|
||||||
|
msgCd = "BFEX03216";
|
||||||
|
msgCtnt = "참가기관코드 에러입니다.";
|
||||||
|
logger.debug("오류 응답 수신 - {}", jsonStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StandardMessage standardMessage = resEaiMsg.getStandardMessage();
|
||||||
|
// msg_dvcd = EM (에러메시지)
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_DVCD, "NM");
|
||||||
|
|
||||||
|
// 출력속성코드 = 1(팝업)
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_OUTP_ATRB_CD, "");
|
||||||
|
|
||||||
|
// MSG_LIST 1건 구성
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_LIST_ROWCNT, "0");
|
||||||
|
StandardItem msgPart = standardMessage.findItem("MSG");
|
||||||
|
msgPart.getChilds().remove("MSG_LIST");
|
||||||
|
|
||||||
|
StandardMessageManager manager = StandardMessageManager.getInstance();
|
||||||
|
InterfaceMapper mapper = manager.getMapper();
|
||||||
|
|
||||||
|
// mapper 에러코드 설정
|
||||||
|
mapper.setErrorCode(standardMessage, msgCd);
|
||||||
|
mapper.setErrorMsg(standardMessage, msgCtnt);
|
||||||
|
if (StringUtils.isNotEmpty(msgDesc))
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_OUTP_MSG_DESC, msgDesc);
|
||||||
|
|
||||||
|
// 성공 처리 처럼 진행한다.
|
||||||
|
resEaiMsg.setRspErrCd(EAIMessageKeys.EAI_SUCCESS_CODE, false);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package com.eactive.eai.custom.adapter.handler;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.eactive.eai.adapter.handler.TemplateAdapterErrorMsgHandler;
|
||||||
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
|
import com.eactive.eai.common.message.EAIMessage;
|
||||||
|
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
import com.eactive.eai.custom.message.StandardMessageCoordinatorDJB;
|
||||||
|
import com.eactive.eai.message.StandardItem;
|
||||||
|
import com.eactive.eai.message.StandardMessage;
|
||||||
|
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||||
|
import com.eactive.eai.message.service.InterfaceMapper;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class NaverpayAdapterErrorMsgHandler extends TemplateAdapterErrorMsgHandler {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
|
|
||||||
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 표준 -> 비표준 거래
|
||||||
|
* 아웃바운드 어댑터에서 Exception이 발생했을 때, Outbound Process 응답 메시지 생성
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object generateOutboundErrorResponseMessage(String outboundadapterGroupName,
|
||||||
|
String outboundadapterName, Properties callProp, Object outboundRequestData, EAIMessage resEaiMsg)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
StandardMessage standardMessage = resEaiMsg.getStandardMessage();
|
||||||
|
// msg_dvcd = EM (에러메시지)
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_DVCD, "NM");
|
||||||
|
|
||||||
|
// 출력속성코드 = 1(팝업)
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_OUTP_ATRB_CD, "1");
|
||||||
|
|
||||||
|
// MSG_LIST 1건 구성
|
||||||
|
standardMessage.setData(StandardMessageCoordinatorDJB.MSG_LIST_ROWCNT, "0");
|
||||||
|
StandardItem msgPart = standardMessage.findItem("MSG");
|
||||||
|
msgPart.getChilds().remove("MSG_LIST");
|
||||||
|
|
||||||
|
StandardMessageManager manager = StandardMessageManager.getInstance();
|
||||||
|
InterfaceMapper mapper = manager.getMapper();
|
||||||
|
|
||||||
|
// mapper 에러코드 설정
|
||||||
|
mapper.setErrorCode(standardMessage, "");
|
||||||
|
mapper.setErrorMsg(standardMessage, "처리오류");
|
||||||
|
|
||||||
|
// 성공 처리 처럼 진행한다.
|
||||||
|
resEaiMsg.setRspErrCd(EAIMessageKeys.EAI_SUCCESS_CODE, false);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+17
-4
@@ -5,6 +5,9 @@ import java.util.Properties;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
import com.eactive.eai.adapter.http.HttpStatusException;
|
||||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilter;
|
import com.eactive.eai.adapter.http.dynamic.filter.HttpAdapterFilter;
|
||||||
import com.eactive.eai.adapter.http.dynamic.filter.InCryptoFilter;
|
import com.eactive.eai.adapter.http.dynamic.filter.InCryptoFilter;
|
||||||
@@ -27,6 +30,8 @@ import com.eactive.eai.common.security.keyderiv.KeyDerivationStrategy;
|
|||||||
*/
|
*/
|
||||||
public class DouzoneEncFieldInCryptoFilter implements HttpAdapterFilter {
|
public class DouzoneEncFieldInCryptoFilter implements HttpAdapterFilter {
|
||||||
|
|
||||||
|
public static final String ERROR_DEC_FAIL = "E.DECRYPT_FAIL";
|
||||||
|
public static final String ERROR_ENC_FAIL = "E.ENCRYPT_FAIL";
|
||||||
private final InCryptoFilter filter = new InCryptoFilter();
|
private final InCryptoFilter filter = new InCryptoFilter();
|
||||||
|
|
||||||
protected Properties setProp(Properties p) {
|
protected Properties setProp(Properties p) {
|
||||||
@@ -47,15 +52,23 @@ public class DouzoneEncFieldInCryptoFilter implements HttpAdapterFilter {
|
|||||||
@Override
|
@Override
|
||||||
public Object doPreFilter(String adptGrpName, String adptName, Object message, Properties prop,
|
public Object doPreFilter(String adptGrpName, String adptName, Object message, Properties prop,
|
||||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
setContext(prop);
|
try {
|
||||||
return filter.doPreFilter(adptGrpName, adptName, message, setProp(prop), request, response);
|
setContext(prop);
|
||||||
|
return filter.doPreFilter(adptGrpName, adptName, message, setProp(prop), request, response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new HttpStatusException(ERROR_DEC_FAIL, "복호화 오류", HttpStatus.INTERNAL_SERVER_ERROR.value(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object doPostFilter(String adptGrpName, String adptName, Object resultMessage, Properties prop,
|
public Object doPostFilter(String adptGrpName, String adptName, Object resultMessage, Properties prop,
|
||||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
setContext(prop);
|
try {
|
||||||
return filter.doPostFilter(adptGrpName, adptName, resultMessage, setProp(prop), request, response);
|
setContext(prop);
|
||||||
|
return filter.doPostFilter(adptGrpName, adptName, resultMessage, setProp(prop), request, response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new HttpStatusException(ERROR_ENC_FAIL, "암호화 오류", HttpStatus.INTERNAL_SERVER_ERROR.value(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ public class InterfaceMapperDJB extends DefaultInterfaceMapper {
|
|||||||
if(StringUtils.isNotBlank(standardMessage.getEaiSvcCd()))
|
if(StringUtils.isNotBlank(standardMessage.getEaiSvcCd()))
|
||||||
return standardMessage.getEaiSvcCd();
|
return standardMessage.getEaiSvcCd();
|
||||||
|
|
||||||
// String interfaceId = getInterfaceId(standardMessage);
|
String eaiInterfaceId = getInterfaceId(standardMessage);
|
||||||
String txId = getServiceId(standardMessage);
|
// String txId = getServiceId(standardMessage);
|
||||||
String sendRecvDvcd = getSendRecvDivision(standardMessage); // S | R
|
String sendRecvDvcd = getSendRecvDivision(standardMessage); // S | R
|
||||||
String inExDivision = getInExDivision(standardMessage); // 1 | 2
|
String inExDivision = getInExDivision(standardMessage); // 1 | 2
|
||||||
|
|
||||||
if(StringUtils.isEmpty(txId))
|
if(StringUtils.isEmpty(eaiInterfaceId))
|
||||||
throw new RuntimeException("not found txid");
|
throw new RuntimeException("not found if_id");
|
||||||
|
|
||||||
return API_ID_PREFIX + txId + sendRecvDvcd + StringUtils.defaultString(inExDivision);
|
return API_ID_PREFIX + StringUtils.substring(eaiInterfaceId, 2) + sendRecvDvcd + StringUtils.defaultString(inExDivision);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public class StandardMessageCoordinatorDJB extends DefaultStandardMessageCoordin
|
|||||||
public static final String MSG_OUTP_ATRB_CD = "MSG.MAIN_MSG.outp_atrb_cd";
|
public static final String MSG_OUTP_ATRB_CD = "MSG.MAIN_MSG.outp_atrb_cd";
|
||||||
public static final String MSG_OUTP_MSG_CD = "MSG.MAIN_MSG.outp_msg_cd";
|
public static final String MSG_OUTP_MSG_CD = "MSG.MAIN_MSG.outp_msg_cd";
|
||||||
public static final String MSG_OUTP_MSG_CTNT = "MSG.MAIN_MSG.outp_msg_ctnt";
|
public static final String MSG_OUTP_MSG_CTNT = "MSG.MAIN_MSG.outp_msg_ctnt";
|
||||||
|
public static final String MSG_OUTP_MSG_DESC = "MSG.MAIN_MSG.outp_msg_desc";
|
||||||
public static final String MSG_LIST_ROWCNT = "MSG.MAIN_MSG.msg_list_rowcnt";
|
public static final String MSG_LIST_ROWCNT = "MSG.MAIN_MSG.msg_list_rowcnt";
|
||||||
public static final String MSG_LIST = "MSG.MSG_LIST";
|
public static final String MSG_LIST = "MSG.MSG_LIST";
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ public class StandardMessageCoordinatorDJB extends DefaultStandardMessageCoordin
|
|||||||
// 에러코드/메시지 변환
|
// 에러코드/메시지 변환
|
||||||
String siteErrCode = StringUtils.defaultString(MessageUtil.getTobeCode(errCode));
|
String siteErrCode = StringUtils.defaultString(MessageUtil.getTobeCode(errCode));
|
||||||
String siteErrMsg = StringUtils.defaultString(MessageUtil.getTobeMessage(errCode));
|
String siteErrMsg = StringUtils.defaultString(MessageUtil.getTobeMessage(errCode));
|
||||||
String siteErrDesc = StringUtils.defaultString(MessageUtil.getTobeMessage(errCode));
|
String siteErrDesc = StringUtils.defaultString(MessageUtil.getTobeDesc(errCode));
|
||||||
|
|
||||||
// MSG 영역 활성화
|
// MSG 영역 활성화
|
||||||
StandardItem msgItem = standardMessage.findItem("MSG");
|
StandardItem msgItem = standardMessage.findItem("MSG");
|
||||||
|
|||||||
Reference in New Issue
Block a user