init
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
public class ActionException extends Exception
|
||||
{
|
||||
public ActionException() {
|
||||
super("ActionException is occured.");
|
||||
}
|
||||
|
||||
public ActionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
public class ActionFactory
|
||||
{
|
||||
/*
|
||||
private static HashMap actions = new HashMap();
|
||||
|
||||
private ActionFactory() {
|
||||
}
|
||||
|
||||
public static RequestAction createAction(String actionName) throws ActionException {
|
||||
RequestAction action = (RequestAction)actions.get(actionName);
|
||||
if(action == null) {
|
||||
try {
|
||||
Class cl = Class.forName(actionName);
|
||||
action = (RequestAction)cl.newInstance();
|
||||
actions.put(actionName,action);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException("Cannot create a RequestAction. - "+actionName);
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
*/
|
||||
//--------------------------------------------------------------------
|
||||
// 200703.29 : DHLEE
|
||||
// DefaultRequestAction 읠 중복사용으로 인한 DATA 공유문제
|
||||
//--------------------------------------------------------------------
|
||||
private ActionFactory() {
|
||||
}
|
||||
|
||||
public static RequestAction createAction(String actionName) throws ActionException {
|
||||
RequestAction action = null;
|
||||
try {
|
||||
Class cl = Class.forName(actionName);
|
||||
action = (RequestAction)cl.newInstance();
|
||||
} catch(Exception e) {
|
||||
throw new ActionException("Cannot create a RequestAction. - "+actionName);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹명을 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class AdapterGroupBizRequestAction extends RequestActionSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
// byte[] tmp = null;
|
||||
String key[] = null;
|
||||
/**
|
||||
* _BPM_OU_NET_AsC{KOF} 값추출시 BPM 추출
|
||||
* _BPM_OU_NET_AsC 값추출시 BPM 추출
|
||||
*/
|
||||
String adptGrpName = adapterGroupName;
|
||||
|
||||
if (adptGrpName != null && adptGrpName.length() >= 4 ){
|
||||
adptGrpName = adptGrpName.substring(1,4);
|
||||
}
|
||||
|
||||
if (logger.isDebug()) {
|
||||
if(message instanceof byte[]) {
|
||||
// tmp = (byte[])message;
|
||||
logger.debug(adapterName+"] received data >> ["+ new String((byte[])message) +"]");
|
||||
|
||||
}else if (message instanceof String) {
|
||||
// tmp = ((String)message).getBytes();
|
||||
logger.debug(adapterName+"] received data >> ["+ (String)message +"]");
|
||||
}
|
||||
else{
|
||||
logger.debug(adapterName+"] received data >> ["+ message +"]");
|
||||
// throw new ActionException(ExceptionUtil.getErrorCode(null, "RECEAIIRA001"));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message, true, true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(int i=0; i<key.length; i++ ) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "키추출방식 : (그룹명업무3자리)+추출키값";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹명을 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class AdapterGroupNameParseRequestAction extends RequestActionSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
byte[] tmp = null;
|
||||
String key[] = null;
|
||||
/**
|
||||
* _BPM_OU_NET_AsC{KOF} 값추출시 BPMKOF 추출
|
||||
* _BPM_OU_NET_AsC 값추출시 BPM 추출
|
||||
*/
|
||||
String adptGrpName = adapterGroupName;
|
||||
String chnl = "";
|
||||
String inst = "";
|
||||
|
||||
if (adptGrpName != null
|
||||
&& adptGrpName.length() >= 4
|
||||
){
|
||||
chnl = adptGrpName.substring(1,4);
|
||||
}
|
||||
if (adptGrpName != null
|
||||
&& adptGrpName.length() >= 4
|
||||
&& adptGrpName.indexOf("{") >= 0
|
||||
&& adptGrpName.indexOf("}") >= 0
|
||||
&& adptGrpName.indexOf("{") < adptGrpName.indexOf("}")
|
||||
){
|
||||
int start = adptGrpName.indexOf("{")+1;
|
||||
int end = adptGrpName.indexOf("}");
|
||||
inst = adptGrpName.substring(start,end);
|
||||
}
|
||||
if ("".equals(chnl) && "".equals(inst)){
|
||||
;
|
||||
}else{
|
||||
adptGrpName = chnl + inst;
|
||||
}
|
||||
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
tmp = (byte[])message;
|
||||
}else if (message instanceof String) {
|
||||
tmp = ((String)message).getBytes();
|
||||
}else{
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(null, "RECEAIIRA001"));
|
||||
}
|
||||
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, tmp, true, true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
|
||||
if (logger.isDebug()) logger.debug(adapterName+"] received data >> ["+ new String(tmp)+"]");
|
||||
|
||||
for(int i=0; i<key.length; i++ ) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "키추출방식 : (그룹명업무3자리+{}안의값)+추출키값";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹명을 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class AdapterGroupNameRequestAction extends RequestActionSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
byte[] tmp = null;
|
||||
String key[] = null;
|
||||
|
||||
String adptGrpName = adapterGroupName;
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
tmp = (byte[])message;
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
|
||||
}
|
||||
|
||||
for(int i=0; i<key.length; i++ ) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "키추출방식 : 어댑터그룹명+추출키값";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class AdapterRequestAction extends RequestActionSupport
|
||||
{
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
byte[] tmp = null;
|
||||
String[] key = null;
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String eaiBizCode = null;
|
||||
if(adptGrpVO != null) {
|
||||
eaiBizCode = adptGrpVO.getEaiBizCode();
|
||||
}
|
||||
else {
|
||||
eaiBizCode = getEaiBizCodeFromAdapterName(adapterGroupName);
|
||||
}
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
tmp = (byte[])message;
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
|
||||
}
|
||||
|
||||
for(int i=0; i<key.length; i++) {
|
||||
key[i] = eaiBizCode.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "키추출방식 : 어댑터업무구분코드+추출키값";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
:
|
||||
*/
|
||||
public class DefaultRequestAction extends RequestActionSupport
|
||||
{
|
||||
// -----------------------------------------------
|
||||
// 메시지키 테이블의 변경에 따른 수정사항 반영
|
||||
// -----------------------------------------------
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 EAI메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
byte[] tmp = null;
|
||||
String[] key = null;
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
tmp = (byte[])message;
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "키추출방식 : 추출키값";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public interface RequestAction
|
||||
{
|
||||
/**
|
||||
* Inbound Adapter 이름을 초기화 한다.
|
||||
*/
|
||||
public void setAdapterInfo(String adapterGroupName, String adapterName, Properties prop);
|
||||
|
||||
/**
|
||||
* input message로 부터 업무 Key 필드를 생성 반환한다.
|
||||
*/
|
||||
public String[] perform(Object message) throws ActionException;
|
||||
|
||||
public String getDescription();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyFldVO;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyManager;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyVO;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
|
||||
public class RequestActionSupport implements RequestAction
|
||||
{
|
||||
protected String adapterGroupName;
|
||||
protected String adapterName;
|
||||
protected Properties prop;
|
||||
|
||||
protected Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
|
||||
public void setAdapterInfo(String adapterGroupName,String adapterName, Properties prop)
|
||||
{
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
this.adapterName = adapterName;
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
byte[] tmp = null;
|
||||
String[] key = null;
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
tmp = (byte[])message;
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
|
||||
} else {
|
||||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Action Decription";
|
||||
}
|
||||
|
||||
public String getEaiBizCodeFromAdapterName(String adapterGroupName) {
|
||||
String eaiBizCode = null;
|
||||
|
||||
if(adapterGroupName != null && adapterGroupName.length() > 4) {
|
||||
eaiBizCode = adapterGroupName.substring(1, 4);
|
||||
}
|
||||
return eaiBizCode;
|
||||
}
|
||||
|
||||
// public static void main(String[] argv) {
|
||||
// RequestActionSupport s = new RequestActionSupport();
|
||||
// String adapterGroupName = "_ERF_IN_NET_AsS{KFTC}";
|
||||
// String eaiBizCode = s.getEaiBizCodeFromAdapterName(adapterGroupName);
|
||||
// System.out.println(adapterGroupName + "=>" + eaiBizCode);
|
||||
// }
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||
import com.eactive.eai.adapter.http.dynamic.impl.HttpAdapterServiceRest;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyFldVO;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyGroupVO;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyManager;
|
||||
import com.eactive.eai.common.messagekey.MessageKeyVO;
|
||||
import com.eactive.eai.inbound.action.ActionException;
|
||||
import com.eactive.eai.inbound.action.RequestActionSupport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class RestAdapterMethodHeaderRequestAction extends RequestActionSupport {
|
||||
public static final String STEMSG_METHOD_DELIMITER = ":";
|
||||
|
||||
public static final String STEMSG_SERVICE_HEADER_DELIMITER = "^";
|
||||
|
||||
public static final String STEMSG_HEADER_SEPARATOR = ";";
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException {
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String adptGrpName = adptGrpVO.getName();
|
||||
|
||||
String requestMethod = prop.getProperty(HttpAdapterServiceRest.PROPERTIES_NAME_HTTP_REQUEST_METHOD);
|
||||
|
||||
String keyCode = adptGrpName + "I";
|
||||
MessageKeyManager manager = MessageKeyManager.getInstance();
|
||||
MessageKeyVO msgKey = manager.getMessageKey(keyCode);
|
||||
List<MessageKeyGroupVO> alMsgGroups = msgKey.getAlMsgGroups();
|
||||
int groupSize = alMsgGroups.size();
|
||||
|
||||
Properties inboundheader = (Properties) prop.get(HttpAdapterServiceKey.INBOUND_HEADER);
|
||||
String[] keys = new String[groupSize];
|
||||
|
||||
if (logger.isInfo()) {
|
||||
logger.info("MessageKeyExtractor] CURRENT RULE [{}]", keyCode);
|
||||
}
|
||||
|
||||
String baseMessageKey = adptGrpName + STEMSG_METHOD_DELIMITER + requestMethod + STEMSG_SERVICE_HEADER_DELIMITER;
|
||||
|
||||
for (int g = 0; g < groupSize; g++) {
|
||||
MessageKeyGroupVO groupVo = msgKey.getMessageKeyGroup(g);
|
||||
int fldSize = groupVo.getMessageKeyFldLength();
|
||||
String[] keyBuffer = new String[fldSize];
|
||||
|
||||
for (int i = 0; i < fldSize; i++) {
|
||||
MessageKeyFldVO keyFld = groupVo.getMessageKeyFld(i);
|
||||
String tmpKey = inboundheader.getProperty(keyFld.getBwkColNm().toLowerCase(),"");
|
||||
keyBuffer[i] = tmpKey;
|
||||
}
|
||||
String currentKey = baseMessageKey + String.join(STEMSG_HEADER_SEPARATOR, keyBuffer);
|
||||
keys[g] = currentKey;
|
||||
if (logger.isInfo()) {
|
||||
logger.info("MessageKeyExtractor] CURRENT RULE[{}] KEY [{}]", keyCode,currentKey);
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.adapter.Keys;
|
||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||
import com.eactive.eai.adapter.http.dynamic.impl.HttpAdapterServiceRest;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
import com.eactive.eai.inbound.action.ActionException;
|
||||
import com.eactive.eai.inbound.action.RequestActionSupport;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class RestAdapterMethodUrlRequestAction extends RequestActionSupport {
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException {
|
||||
String[] key = null;
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String adptGrpName = adptGrpVO.getName();
|
||||
|
||||
if (StringUtils.equals(adptGrpVO.getType(), Keys.TYPE_HTTP_CUSTOM)
|
||||
|| StringUtils.equals(adptGrpVO.getType(), Keys.TYPE_REST)) {
|
||||
try {
|
||||
String requestMethod = prop
|
||||
.getProperty(HttpAdapterServiceRest.PROPERTIES_NAME_HTTP_REQUEST_METHOD);
|
||||
|
||||
// /api/v1/public/getUserInfo.svc
|
||||
String inboundUri = prop.getProperty(HttpAdapterServiceKey.INBOUND_EXTURI);
|
||||
String apiPath = prop.getProperty(HttpAdapterServiceKey.API_PATH);
|
||||
|
||||
// /getUserInfo.svc
|
||||
String apiUri = org.apache.commons.lang.StringUtils.removeStart(inboundUri, apiPath);
|
||||
// _TST_IN_RST_SyS|POST:getUserInfo.svc
|
||||
String apiKey = adptGrpName + ":" + requestMethod + "|" + StringUtils.removeStart(apiUri, "/");
|
||||
|
||||
return new String[] { apiKey };
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
}
|
||||
|
||||
if (message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "url", true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + new String((byte[]) message) + "]");
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "url", true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + message + "]");
|
||||
}
|
||||
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Rest Url 추출 용
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class RestDataAdapterGroupParseRequestAction extends RequestActionSupport
|
||||
{
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
String[] key = null;
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String adptGrpName = adptGrpVO.getName();
|
||||
if (adptGrpName != null && adptGrpName.length() >= 4) {
|
||||
String chnl = adptGrpName.substring(1, 4);
|
||||
if (adptGrpName.indexOf("{") >= 0 && adptGrpName.indexOf("}") >= 0
|
||||
&& adptGrpName.indexOf("{") < adptGrpName.indexOf("}")) {
|
||||
int start = adptGrpName.indexOf("{") + 1;
|
||||
int end = adptGrpName.indexOf("}");
|
||||
String inst = adptGrpName.substring(start, end);
|
||||
adptGrpName = chnl + inst;
|
||||
} else {
|
||||
adptGrpName = chnl;
|
||||
}
|
||||
}
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "data", true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug()) logger.debug(adapterName+"] received data >> ["+ new String((byte[])message)+"]");
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "data", true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug()) logger.debug(adapterName+"] received data >> ["+ message+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(int i=0; i<key.length; i++) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Rest Url 추출 용
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class RestHeaderAdapterGroupParseRequestAction extends RequestActionSupport
|
||||
{
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException
|
||||
{
|
||||
String[] key = null;
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String adptGrpName = adptGrpVO.getName();
|
||||
if (adptGrpName != null && adptGrpName.length() >= 4) {
|
||||
String chnl = adptGrpName.substring(1, 4);
|
||||
if (adptGrpName.indexOf("{") >= 0 && adptGrpName.indexOf("}") >= 0
|
||||
&& adptGrpName.indexOf("{") < adptGrpName.indexOf("}")) {
|
||||
int start = adptGrpName.indexOf("{") + 1;
|
||||
int end = adptGrpName.indexOf("}");
|
||||
String inst = adptGrpName.substring(start, end);
|
||||
adptGrpName = chnl + inst;
|
||||
} else {
|
||||
adptGrpName = chnl;
|
||||
}
|
||||
}
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "header", true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug()) logger.debug(adapterName+"] received data >> ["+ new String((byte[])message)+"]");
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "header", true);
|
||||
} catch(Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug()) logger.debug(adapterName+"] received data >> ["+ message+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(int i=0; i<key.length; i++) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Rest Url 추출 용
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class RestHeaderParseRequestAction extends RequestActionSupport {
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException {
|
||||
String[] key = null;
|
||||
|
||||
if (message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "header",
|
||||
true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + new String((byte[]) message) + "]");
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "header",
|
||||
true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + message + "]");
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.adapter.Keys;
|
||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||
import com.eactive.eai.adapter.http.dynamic.impl.HttpAdapterServiceRest;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Rest Url 추출 용
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class RestUrlAdapterGroupParseRequestAction extends RequestActionSupport {
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException {
|
||||
String[] key = null;
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
String adptGrpName = adptGrpVO.getName();
|
||||
if (adptGrpName != null && adptGrpName.length() >= 4) {
|
||||
String chnl = adptGrpName.substring(1, 4);
|
||||
//EIMS에서 지원하지 않아 주석 처리
|
||||
// if (adptGrpName.indexOf("{") >= 0 && adptGrpName.indexOf("}") >= 0
|
||||
// && adptGrpName.indexOf("{") < adptGrpName.indexOf("}")) {
|
||||
// int start = adptGrpName.indexOf("{") + 1;
|
||||
// int end = adptGrpName.indexOf("}");
|
||||
// String inst = adptGrpName.substring(start, end);
|
||||
// adptGrpName = chnl + inst;
|
||||
// } else {
|
||||
// adptGrpName = chnl;
|
||||
// }
|
||||
adptGrpName = chnl;
|
||||
}
|
||||
|
||||
if (StringUtils.equals(adptGrpVO.getType(), Keys.TYPE_HTTP_CUSTOM)
|
||||
|| StringUtils.equals(adptGrpVO.getType(), Keys.TYPE_REST)) {
|
||||
try {
|
||||
String requestMethod = prop
|
||||
.getProperty(HttpAdapterServiceRest.PROPERTIES_NAME_HTTP_REQUEST_METHOD);
|
||||
|
||||
// /api/v1/public/getUserInfo.svc
|
||||
String apiUri = prop.getProperty(HttpAdapterServiceKey.INBOUND_EXTURI);
|
||||
|
||||
// MDIKFTC:POST/api/v1/public/getUserInfo.svc
|
||||
// String apiKey = adptGrpName + ":" + requestMethod + "/" + StringUtils.removeStart(apiUri, "/");
|
||||
// MDIKFTCPOST/api/v1/public/getUserInfo.svc
|
||||
String apiKey = adptGrpName + requestMethod + "/" + StringUtils.removeStart(apiUri, "/");
|
||||
|
||||
return new String[] { apiKey };
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
}
|
||||
|
||||
if (message instanceof byte[]) {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "url", true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + new String((byte[]) message) + "]");
|
||||
} else {
|
||||
try {
|
||||
key = MessageKeyExtractor.getMessageKeyValueForRest(this.adapterGroupName, message, prop, "url", true);
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
if (logger.isDebug())
|
||||
logger.debug(adapterName + "] received data >> [" + message + "]");
|
||||
}
|
||||
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
key[i] = adptGrpName.trim() + key[i];
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.eactive.eai.inbound.action;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
|
||||
import com.eactive.eai.adapter.http.dynamic.impl.HttpAdapterServiceRest;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Rest Url 추출 용
|
||||
* 2. 처리 개요 :
|
||||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class RestUrlParseRequestAction extends RequestActionSupport {
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 표준메시지를 생성하기 위한 키값을 추출
|
||||
* 2. 처리 개요 :
|
||||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @return String 비표준메시지의 메시지키값
|
||||
* @exception
|
||||
**/
|
||||
public String[] perform(Object message) throws ActionException {
|
||||
try {
|
||||
String requestMethod = prop.getProperty(HttpAdapterServiceRest.PROPERTIES_NAME_HTTP_REQUEST_METHOD);
|
||||
|
||||
// /api/v1/public/getUserInfo.svc
|
||||
String apiUri = prop.getProperty(HttpAdapterServiceKey.INBOUND_EXTURI);
|
||||
|
||||
// POST/api/v1/public/getUserInfo.svc
|
||||
String apiKey = requestMethod + "/" + StringUtils.removeStart(apiUri, "/");
|
||||
|
||||
return new String[] { apiKey };
|
||||
} catch (Exception e) {
|
||||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.eactive.eai.inbound.error;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.eactive.eai.agent.encryption.EncryptionManager;
|
||||
import com.eactive.eai.common.dao.BaseDAO;
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.property.PropManager;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.ScpDbAgentUtil;
|
||||
import com.eactive.eai.common.util.StringUtil;
|
||||
import com.eactive.eai.data.entity.onl.inbound.error.InboundErrorInfo;
|
||||
import com.eactive.eai.inbound.error.loader.InboundErrorInfoLoader;
|
||||
import com.eactive.eai.inbound.error.mapper.InboundErrorInfoMapper;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class InboundErrorInfoDAO extends BaseDAO {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private InboundErrorInfoLoader inboundErrorInfoLoader;
|
||||
|
||||
@Autowired
|
||||
private InboundErrorInfoMapper inboundErrorInfoMapper;
|
||||
|
||||
public void addInboundErrorInfo(InboundErrorInfoVO vo) throws DAOException {
|
||||
EncryptionManager manager = EncryptionManager.getInstance();
|
||||
String bzwkDataCtnt = vo.getBwkDataTxt();
|
||||
|
||||
// 업무데이터를 암호화할 경우 길이가 늘어나는 문제가 있으므로 double check 함
|
||||
if ("Y".equalsIgnoreCase(manager.getEncryptYN())) {
|
||||
if (bzwkDataCtnt.length() > 2000) {
|
||||
bzwkDataCtnt = StringUtil.chunkString(bzwkDataCtnt, 2000);
|
||||
}
|
||||
|
||||
String encbzwkDataCtnt = null;
|
||||
try {
|
||||
encbzwkDataCtnt = ScpDbAgentUtil.ScpEncB64(
|
||||
PropManager.getInstance().getProperties(ScpDbAgentUtil.EXT_MODULE), bzwkDataCtnt, "EUC-KR");
|
||||
} catch (Exception e) {
|
||||
logger.error("addInboundErrorInfo] scpdb_agent encryption Error - " + e.getMessage());
|
||||
}
|
||||
|
||||
// double check
|
||||
if (encbzwkDataCtnt != null && encbzwkDataCtnt.length() > 4000) {
|
||||
bzwkDataCtnt = StringUtil.chunkString(bzwkDataCtnt, 500);
|
||||
try {
|
||||
encbzwkDataCtnt = ScpDbAgentUtil.ScpEncB64(
|
||||
PropManager.getInstance().getProperties(ScpDbAgentUtil.EXT_MODULE), bzwkDataCtnt, "EUC-KR");
|
||||
bzwkDataCtnt = encbzwkDataCtnt;
|
||||
} catch (Exception e) {
|
||||
logger.error("addInboundErrorInfo] scpdb_agent encryption Error - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bzwkDataCtnt = StringUtil.chunkString(bzwkDataCtnt, 4000);
|
||||
}
|
||||
|
||||
try {
|
||||
vo.setErrTm((vo.getErrTm()).substring(0, 16));
|
||||
vo.setErrTxt(StringUtil.chunkString(vo.getErrTxt(), 4000));
|
||||
|
||||
String bizKey = vo.getBzwkSvcKeyName();
|
||||
if (bizKey == null) {
|
||||
bizKey = "";
|
||||
}
|
||||
else {
|
||||
if (bizKey.length() > 40)
|
||||
bizKey = bizKey.substring(0, 40);
|
||||
}
|
||||
vo.setBzwkSvcKeyName(bizKey);
|
||||
|
||||
InboundErrorInfo entity = inboundErrorInfoMapper.toEntity(vo);
|
||||
inboundErrorInfoLoader.save(entity);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAIIEI001"), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.eactive.eai.inbound.error;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class InboundErrorInfoVO implements Serializable {
|
||||
|
||||
private String eaiSvcSno; // EAI서비스일련번호[TSEAICM04.EAISvcSerno]
|
||||
private String adptBwkGrpNm; // 어댑터업무그룹명[TSEAICM04.AdptrBzwkGroupName]
|
||||
private String errDstcd; // EAI에러구분코드[TSEAICM04.EAIErrDstcd]
|
||||
private String eaiSvcCd; // EAI서비스코드
|
||||
private String errCd; // EAI에러코드[TSEAICM04.EAIErrCd]
|
||||
private String errTxt; // EAI에러내용[TSEAICM04.EAIErrCtnt]
|
||||
private String errTm; // 에러발생시각[TSEAICM04.ErrOccurHMS]
|
||||
private String bwkDataTxt; // 업무데이터내용[TSEAICM04.BzwkDataCtnt]
|
||||
private String eaiSvrInstNm; // EAI서버인스턴스명[TSEAICM04.EAIsevrInstncName]
|
||||
private String bzwkSvcKeyName; // 업무서비스키명[TSEAICM04.BZWKSVCKEYNAME]
|
||||
|
||||
public String getAdptBwkGrpNm() {
|
||||
return adptBwkGrpNm;
|
||||
}
|
||||
|
||||
public void setAdptBwkGrpNm(String adptBwkGrpNm) {
|
||||
this.adptBwkGrpNm = adptBwkGrpNm;
|
||||
}
|
||||
|
||||
public String getBwkDataTxt() {
|
||||
return bwkDataTxt;
|
||||
}
|
||||
|
||||
public void setBwkDataTxt(String bwkDataTxt) {
|
||||
this.bwkDataTxt = bwkDataTxt;
|
||||
}
|
||||
|
||||
public String getEaiSvcSno() {
|
||||
return eaiSvcSno;
|
||||
}
|
||||
|
||||
public void setEaiSvcSno(String eaiSvcSno) {
|
||||
this.eaiSvcSno = eaiSvcSno;
|
||||
}
|
||||
|
||||
public String getEaiSvrInstNm() {
|
||||
return eaiSvrInstNm;
|
||||
}
|
||||
|
||||
public void setEaiSvrInstNm(String eaiSvrInstNm) {
|
||||
this.eaiSvrInstNm = eaiSvrInstNm;
|
||||
}
|
||||
|
||||
public String getErrCd() {
|
||||
return errCd;
|
||||
}
|
||||
|
||||
public void setErrCd(String errCd) {
|
||||
this.errCd = errCd;
|
||||
}
|
||||
|
||||
public String getErrDstcd() {
|
||||
return errDstcd;
|
||||
}
|
||||
|
||||
public void setErrDstcd(String errDstcd) {
|
||||
this.errDstcd = errDstcd;
|
||||
}
|
||||
|
||||
public String getErrTm() {
|
||||
return errTm;
|
||||
}
|
||||
|
||||
public void setErrTm(String errTm) {
|
||||
this.errTm = errTm;
|
||||
}
|
||||
|
||||
public String getErrTxt() {
|
||||
return errTxt;
|
||||
}
|
||||
|
||||
public void setErrTxt(String errTxt) {
|
||||
this.errTxt = errTxt;
|
||||
}
|
||||
|
||||
public String getEaiSvcCd() {
|
||||
return eaiSvcCd;
|
||||
}
|
||||
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getBzwkSvcKeyName() {
|
||||
return bzwkSvcKeyName;
|
||||
}
|
||||
|
||||
public void setBzwkSvcKeyName(String bzwkSvcKeyName) {
|
||||
this.bzwkSvcKeyName = bzwkSvcKeyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InboundErrorInfoVO [eaiSvcSno=" + eaiSvcSno + ", adptBwkGrpNm=" + adptBwkGrpNm + ", eaiSvcCd="
|
||||
+ eaiSvcCd + ", errCd=" + errCd + ", errTxt=" + errTxt + ", errTm=" + errTm + ", bwkDataTxt="
|
||||
+ bwkDataTxt + ", eaiSvrInstNm=" + eaiSvrInstNm + ", errDstcd=" + errDstcd + ", bzwkSvcKeyName="
|
||||
+ bzwkSvcKeyName + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.eactive.eai.inbound.error;
|
||||
|
||||
public interface InboundErrorKeys {
|
||||
// SNA DFS Message
|
||||
public static final String SNA_DFS = "SD";
|
||||
|
||||
// SNA TIME-OUT Message
|
||||
public static final String SNA_TIMEOUT = "ST";
|
||||
|
||||
// SNA Error Message
|
||||
public static final String SNA_ERROR = "SE";
|
||||
|
||||
// SNA Other Error MEssage
|
||||
public static final String SNA_OTHER = "SO";
|
||||
|
||||
// Inbound Adapter를 통한 비정상 메시지 수신
|
||||
public static final String IN_UNKNOWN = "IU";
|
||||
|
||||
// Inbound Request Dispatcher에서 EAI메시지를 생성하기전 오류발생
|
||||
public static final String IN_ERROR = "IE";
|
||||
|
||||
public static final String TAS_START = "TS";
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.eactive.eai.inbound.error.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.data.entity.onl.inbound.error.InboundErrorInfo;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface InboundErrorInfoMapper extends GenericMapper<InboundErrorInfoVO, InboundErrorInfo> {
|
||||
@Mapping(source = "eaisvcserno", target = "eaiSvcSno")
|
||||
@Mapping(source = "adptrbzwkgroupname", target = "adptBwkGrpNm")
|
||||
@Mapping(source = "eaierrdstcd", target = "errDstcd")
|
||||
@Mapping(source = "eaierrcd", target = "errCd")
|
||||
@Mapping(source = "eaierrctnt", target = "errTxt")
|
||||
@Mapping(source = "erroccurhms", target = "errTm")
|
||||
@Mapping(source = "bzwkdatactnt", target = "bwkDataTxt")
|
||||
@Mapping(source = "eaisevrinstncname", target = "eaiSvrInstNm")
|
||||
@Mapping(source = "eaisvcname", target = "eaiSvcCd")
|
||||
@Mapping(source = "bzwksvckeyname", target = "bzwkSvcKeyName")
|
||||
@Override
|
||||
InboundErrorInfoVO toVo(InboundErrorInfo entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
InboundErrorInfo toEntity(InboundErrorInfoVO vo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
public interface AdapterFilter
|
||||
{
|
||||
/**
|
||||
* Adapter 이름을 초기화 한다.
|
||||
*/
|
||||
public void setAdapterInfo(String adapterGroupName,String adapterName);
|
||||
|
||||
/**
|
||||
* 요청 데이타를 변환한다.
|
||||
*/
|
||||
public Object requestPerform(Object message) throws AdapterFilterException;
|
||||
|
||||
/**
|
||||
* 응답 데이타를 변환한다.
|
||||
*/
|
||||
public Object responsePerform(Object message) throws AdapterFilterException;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
public class AdapterFilterException extends Exception
|
||||
{
|
||||
public AdapterFilterException() {
|
||||
super("FilterException is occured.");
|
||||
}
|
||||
|
||||
public AdapterFilterException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
|
||||
public class AdapterFilterFactory
|
||||
{
|
||||
private AdapterFilterFactory() {
|
||||
}
|
||||
|
||||
public static AdapterFilter createFilter(String filterName) throws AdapterFilterException {
|
||||
AdapterFilter action = null;
|
||||
try {
|
||||
Class cl = Class.forName(filterName);
|
||||
action = (AdapterFilter)cl.newInstance();
|
||||
} catch(Exception e) {
|
||||
throw new AdapterFilterException("Cannot create a FilterAction. - "+filterName);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class AdapterFilterSupport implements AdapterFilter
|
||||
{
|
||||
protected String adapterGroupName;
|
||||
protected String adapterName;
|
||||
|
||||
protected Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
|
||||
public void setAdapterInfo(String adapterGroupName,String adapterName)
|
||||
{
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
this.adapterName = adapterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object responsePerform(Object message) throws AdapterFilterException {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
|
||||
public class InboundAsyncZipFilter extends ZipFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[] ){
|
||||
return decomp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
|
||||
public class InboundSyncZipFilter extends ZipFilter
|
||||
{
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[] ){
|
||||
return decomp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object responsePerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[]){
|
||||
return comp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
|
||||
public class OutboundAsyncZipFilter extends ZipFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[] ){
|
||||
return comp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
|
||||
public class OutboundSyncZipFilter extends ZipFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[] ){
|
||||
return comp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
@Override
|
||||
public Object responsePerform(Object message) throws AdapterFilterException {
|
||||
if (message instanceof byte[] ){
|
||||
return decomp((byte[])message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class ZIPUtil {
|
||||
|
||||
public static byte[] compress(byte[] message){
|
||||
byte[] obj = null;
|
||||
ByteArrayOutputStream os = null;
|
||||
GZIPOutputStream gos = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try{
|
||||
os = new ByteArrayOutputStream();
|
||||
gos = new GZIPOutputStream(os);
|
||||
bos = new BufferedOutputStream(gos);
|
||||
bos.write(message);
|
||||
|
||||
bos.close();
|
||||
gos.close();
|
||||
os.close();
|
||||
|
||||
obj = os.toByteArray();
|
||||
|
||||
}catch(Exception e){
|
||||
obj = message;
|
||||
}finally{
|
||||
if (bos!=null) try {bos.close();} catch (IOException e) {}
|
||||
if (gos!=null) try {gos.close();} catch (IOException e) {}
|
||||
if (os!=null) try {os.close();} catch (IOException e) {}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] decompress(byte[] message){
|
||||
byte[] obj = null;
|
||||
ByteArrayInputStream is = null;
|
||||
GZIPInputStream gis = null;
|
||||
BufferedInputStream bis = null;
|
||||
ByteArrayOutputStream os = null;
|
||||
|
||||
try{
|
||||
is = new ByteArrayInputStream(message);
|
||||
gis = new GZIPInputStream(is);
|
||||
bis = new BufferedInputStream(gis);
|
||||
os = new ByteArrayOutputStream();
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
int length;
|
||||
while((length = bis.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
os.close();
|
||||
bis.close();
|
||||
gis.close();
|
||||
is.close();
|
||||
obj = os.toByteArray();
|
||||
}catch(Exception e){
|
||||
obj = message;
|
||||
}finally {
|
||||
if (os!=null) try {os.close();} catch (IOException e) {}
|
||||
if (bis!=null) try {bis.close();} catch (IOException e) {}
|
||||
if (gis!=null) try {gis.close();} catch (IOException e) {}
|
||||
if (is!=null) try {is.close();} catch (IOException e) {}
|
||||
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception{
|
||||
// //전체
|
||||
// //byte[] message = "00001048 000DEVCHAP_0120120509140619000002002SR10 EAI 000000 000IFWFW555555IFWCD950112TSTSYNC A2 S Y 0000 0000 0000000000000000000000000000000 KORN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000N0000000000000000000000000000000000000000000000000000000000000000000000000000000000000FILLER IBS IO00000036IFW 0000100010@@".getBytes();
|
||||
// //150byte 이후만
|
||||
// byte[] message = "000IFWFW555555IFWCD950112TSTSYNC A2 S Y 0000 0000 0000000000000000000000000000000 KORN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000N0000000000000000000000000000000000000000000000000000000000000000000000000000000000000FILLER IBS IO00000036IFW 0000100010@@".getBytes();
|
||||
// byte[] com = (byte[]) ZIPUtil.compress(message);
|
||||
// System.out.println("compress="+ new String(com));
|
||||
// byte[] decom= (byte[]) ZIPUtil.decompress(com);
|
||||
// System.out.println("decompress="+new String(decom));
|
||||
//
|
||||
// ;
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.eactive.eai.inbound.filter;
|
||||
|
||||
import com.eactive.eai.common.util.CommonLib;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class ZipFilter implements AdapterFilter
|
||||
{
|
||||
private static Integer HEADER_LENGTH = 150;
|
||||
private static Integer HEADER_LL_LENGTH = 8;
|
||||
|
||||
protected String adapterGroupName;
|
||||
protected String adapterName;
|
||||
|
||||
protected Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
|
||||
public void setAdapterInfo(String adapterGroupName,String adapterName)
|
||||
{
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
this.adapterName = adapterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object requestPerform(Object message) throws AdapterFilterException {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object responsePerform(Object message) throws AdapterFilterException {
|
||||
return message;
|
||||
}
|
||||
protected byte[] comp(byte[] msg){
|
||||
byte[] result = null;
|
||||
if (msg != null && msg.length > HEADER_LENGTH ){
|
||||
byte[] header = splitHeader(msg);
|
||||
byte[] data = splitData(msg);
|
||||
byte[] comp = ZIPUtil.compress(data);
|
||||
result = concatStdmessage(header,comp);
|
||||
return result;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
protected byte[] decomp(byte[] msg){
|
||||
byte[] result = null;
|
||||
if (msg != null && msg.length > HEADER_LENGTH ){
|
||||
byte[] header = splitHeader(msg);
|
||||
byte[] data = splitData(msg);
|
||||
byte[] decomp = ZIPUtil.decompress(data);
|
||||
result = concatStdmessage(header,decomp);
|
||||
return result;
|
||||
}
|
||||
return msg;
|
||||
|
||||
}
|
||||
protected byte[] splitHeader(byte[] message){
|
||||
byte[] header = new byte[HEADER_LENGTH];
|
||||
System.arraycopy(message, 0, header, 0, HEADER_LENGTH);
|
||||
return header;
|
||||
|
||||
}
|
||||
protected byte[] splitData(byte[] message){
|
||||
byte[] data = new byte[message.length-HEADER_LENGTH];
|
||||
System.arraycopy(message, HEADER_LENGTH, data, 0, data.length);
|
||||
return data;
|
||||
}
|
||||
protected byte[] concatStdmessage(byte[] header,byte[] data){
|
||||
|
||||
int iLen = header.length+data.length;
|
||||
byte[] result = new byte[iLen];
|
||||
|
||||
/**
|
||||
* header 와 압축해제한 데이타를 합침
|
||||
*/
|
||||
System.arraycopy(header, 0, result, 0, HEADER_LENGTH);
|
||||
System.arraycopy(data, 0, result, HEADER_LENGTH, data.length);
|
||||
|
||||
|
||||
/**
|
||||
* 길이보정
|
||||
*/
|
||||
String len = CommonLib.getFormatString(iLen,HEADER_LL_LENGTH);
|
||||
System.arraycopy(len.getBytes(), 0, result,0, HEADER_LL_LENGTH);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String args[]) throws Exception {
|
||||
// test();
|
||||
//}
|
||||
|
||||
// private static void test() throws Exception {
|
||||
// ZipFilter filter = new ZipFilter();
|
||||
// byte[] message = "00001048 000DEVCHAP_0120120509140619000002002SR10 EAI 000000 000IFWFW555555IFWCD950112TSTSYNC A2 S Y 0000 0000 0000000000000000000000000000000 KORN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000N0000000000000000000000000000000000000000000000000000000000000000000000000000000000000FILLER IBS IO00000036IFW 0000100010@@".getBytes();
|
||||
// byte[] com = (byte[]) filter.responsePerform(message);
|
||||
// System.out.println("compress="+ new String(com));
|
||||
// byte[] decom= (byte[]) filter.requestPerform(com);
|
||||
// System.out.println("decompress="+new String(decom));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.adapter.AdapterPropManager;
|
||||
import com.eactive.eai.adapter.AdapterVO;
|
||||
import com.eactive.eai.adapter.Keys;
|
||||
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
|
||||
import com.eactive.eai.common.routing.GWRemoteProxyClient;
|
||||
import com.eactive.eai.common.routing.RouteKeys;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.common.server.EAIServerVO;
|
||||
import com.eactive.eai.common.util.CommonLib;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.control.HttpSender;
|
||||
import com.eactive.eai.control.SocketSender;
|
||||
|
||||
public class GWRequestProcessor extends RequestProcessorSupport {
|
||||
|
||||
static final String OUTBOUND_ADAPTER_GROUP_NAME = "OUTBOUND_ADAPTER_GROUP_NAME";
|
||||
static final String PAIR_ADAPTER = "PAIR_ADAPTER";
|
||||
static final String PAIR_ADAPTER_HEADER_PREFIX = "PA_";
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_SIFT);
|
||||
|
||||
protected Object hookup(Object message, Properties prop, long msgRcvTm) throws Exception {
|
||||
|
||||
String inboundAdapterGroupName = prop.getProperty(Processor.ADAPTER_GROUP_NAME);
|
||||
logger.debug("GWRequestProcessor] inboundAdapterGroupName: {}", inboundAdapterGroupName);
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO inboundAdptGrpVO = adapterManager.getAdapterGroupVO(inboundAdapterGroupName);
|
||||
|
||||
String inboundAdapterName = prop.getProperty(Processor.ADAPTER_NAME);
|
||||
AdapterVO inboundAdapterVO = inboundAdptGrpVO.getAdapterVO(inboundAdapterName);
|
||||
|
||||
MDC.put(Logger.DISCRIMINATOR, inboundAdapterGroupName);
|
||||
logger.info("<RECV> " + getLogMessage(message));
|
||||
logger.debug(CommonLib.getDumpMessage(message));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
|
||||
AdapterPropManager adapterPropManager = AdapterPropManager.getInstance();
|
||||
Properties inboundProp = adapterPropManager.getProperties(inboundAdapterVO.getPropGroupName());
|
||||
|
||||
String transactionId = null;
|
||||
String instanceId = EAIServerManager.getInstance().getLocalServerName();
|
||||
|
||||
//set pair adapter
|
||||
String pairAdapter = inboundProp.getProperty(PAIR_ADAPTER);
|
||||
if (StringUtils.isNotBlank(inboundAdptGrpVO.getPairAdapterYn()) && "1".equals(inboundAdptGrpVO.getPairAdapterYn())
|
||||
&& StringUtils.isNoneBlank(pairAdapter)) {
|
||||
transactionId = PAIR_ADAPTER_HEADER_PREFIX + UUID.randomUUID().toString().substring(0, 7);
|
||||
GWSessionManager.getInstance().adapterIn(transactionId, pairAdapter);
|
||||
logger.debug("GWRequestProcessor] transactionId|pairAdapter: {}, {}", transactionId, pairAdapter);
|
||||
}
|
||||
|
||||
//set use same session
|
||||
String sessionId = prop.getProperty("SESSION_ID");
|
||||
if (StringUtils.isNotBlank(sessionId)) {
|
||||
transactionId = sessionId;
|
||||
logger.debug("GWRequestProcessor] transactionId|sessionId: {}", sessionId);
|
||||
}
|
||||
|
||||
//get Outbound Adapter Group
|
||||
Object resObject = null;
|
||||
String outboundAdapterGroupName = inboundAdptGrpVO.getLinkedAdapterGroup();
|
||||
AdapterGroupVO outboundAdptGrpVO = adapterManager.getAdapterGroupVO(outboundAdapterGroupName);
|
||||
String outboundAdapterType = outboundAdptGrpVO.getType(); //HTT, HTC, NET
|
||||
|
||||
//response header
|
||||
String responseTransactionId = prop.getProperty(HttpClientAdapterServiceKey.TRANSACTION_ID);
|
||||
String responseInstanceId = prop.getProperty(HttpClientAdapterServiceKey.INSTANCE_ID);
|
||||
if (StringUtils.isNotBlank(responseTransactionId) && StringUtils.isNotBlank(responseInstanceId)) {
|
||||
if (!responseInstanceId.equals(instanceId)) {
|
||||
logger.warn("GWRequestProcessor] intanceId not matched.[{}<{}>], call Remote Proxy", outboundAdapterGroupName, responseTransactionId);
|
||||
resObject = callRemoteProxy(message, outboundAdapterGroupName, responseTransactionId, responseInstanceId);
|
||||
|
||||
return resObject;
|
||||
}
|
||||
|
||||
if (!GWSessionManager.getInstance().isExists(responseTransactionId)) {
|
||||
logger.error("GWRequestProcessor] No matched transactionId[{}], at {}", responseTransactionId, responseInstanceId);
|
||||
throw new Exception("No matched transactionId.[" + responseTransactionId + "]");
|
||||
}
|
||||
|
||||
logger.debug("GWRequestProcessor] responseTransactionId: {}", responseTransactionId);
|
||||
}
|
||||
|
||||
AdapterVO adptVO = outboundAdptGrpVO.nextAdapterVO();
|
||||
// 가용 Adapter가 없는 경우
|
||||
if (adptVO == null) {
|
||||
// throw new Exception("No adapters available.[" + outboundAdapterGroupName + "]");
|
||||
logger.warn("GWRequestProcessor] No adapters available.[{}], call Remote Proxy", outboundAdapterGroupName);
|
||||
resObject = callRemoteProxy(message, outboundAdapterGroupName);
|
||||
} else {
|
||||
Properties outboundProp = adapterPropManager.getProperties(adptVO.getPropGroupName());
|
||||
|
||||
Properties tempProp = new Properties();
|
||||
tempProp.setProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_OUT,
|
||||
StringUtils.defaultIfBlank(outboundAdptGrpVO.getMessageEncode(), Charset.defaultCharset().name()));
|
||||
|
||||
MDC.put(Logger.DISCRIMINATOR, outboundAdapterGroupName);
|
||||
logger.info("<SEND> " + getLogMessage(message));
|
||||
logger.debug(CommonLib.getDumpMessage(message));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
|
||||
try {
|
||||
if (outboundAdapterType.equals(Keys.TYPE_HTTP) || outboundAdapterType.equals(Keys.TYPE_HTTP_CUSTOM)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, outboundAdapterGroupName);
|
||||
|
||||
//set header
|
||||
if (StringUtils.isNotBlank(pairAdapter) || StringUtils.isNotBlank(sessionId)) {
|
||||
String adapterHeader = "{ \"" + HttpClientAdapterServiceKey.TRANSACTION_ID + "\", \"" + transactionId + "\" },"
|
||||
+ "{ \"" + HttpClientAdapterServiceKey.INSTANCE_ID + "\", \"" + instanceId + "\" }";
|
||||
outboundProp.put(HttpClientAdapterServiceKey.ADAPTER_HEADER, adapterHeader);
|
||||
}
|
||||
|
||||
//set pair adapter
|
||||
if (StringUtils.isNotBlank(responseTransactionId) && responseTransactionId.startsWith(PAIR_ADAPTER_HEADER_PREFIX)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, GWSessionManager.getInstance().getAdapter(responseTransactionId));
|
||||
GWSessionManager.getInstance().adapterOut(responseTransactionId);;
|
||||
} else {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
|
||||
}
|
||||
|
||||
resObject = HttpSender.callService(outboundAdapterGroupName, outboundProp, message, tempProp);
|
||||
} else if (outboundAdapterType.equals(Keys.TYPE_NET2)) {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_GROUP_NAME, outboundAdapterGroupName);
|
||||
|
||||
//set pair adapter
|
||||
if (StringUtils.isNotBlank(responseTransactionId) && responseTransactionId.startsWith(PAIR_ADAPTER_HEADER_PREFIX)) {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_NAME, GWSessionManager.getInstance().getAdapter(responseTransactionId));
|
||||
GWSessionManager.getInstance().adapterOut(responseTransactionId);;
|
||||
} else {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_NAME, adptVO.getName());
|
||||
//set session
|
||||
if (StringUtils.isNotBlank(responseTransactionId)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.TRANSACTION_ID, responseTransactionId);
|
||||
}
|
||||
}
|
||||
|
||||
resObject = SocketSender.callService(outboundAdapterGroupName, outboundProp, message, tempProp);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.warn("GW.Sender] callService " + e.getMessage(), e);
|
||||
logger.warn("call Remote Proxy");
|
||||
// resObject = e.getMessage();
|
||||
resObject = callRemoteProxy(message, outboundAdapterGroupName);
|
||||
}
|
||||
|
||||
if (resObject != null) {
|
||||
MDC.put(Logger.DISCRIMINATOR, outboundAdapterGroupName);
|
||||
logger.info("<RECV> " + getLogMessage(resObject));
|
||||
logger.debug(CommonLib.getDumpMessage(resObject));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
}
|
||||
}
|
||||
|
||||
if (resObject != null) {
|
||||
MDC.put(Logger.DISCRIMINATOR, inboundAdapterGroupName);
|
||||
logger.info("<SEND> " + getLogMessage(resObject));
|
||||
logger.debug(CommonLib.getDumpMessage(resObject));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
}
|
||||
|
||||
return resObject;
|
||||
}
|
||||
|
||||
public static Object callService(Object message, Properties callProp) throws Exception {
|
||||
String outboundAdapterGroupName = callProp.getProperty(OUTBOUND_ADAPTER_GROUP_NAME);
|
||||
String transactionId = callProp.getProperty(HttpClientAdapterServiceKey.TRANSACTION_ID);
|
||||
logger.debug("GWRequestProcessor.callService] transactionId: {}", transactionId);
|
||||
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO outboundAdptGrpVO = adapterManager.getAdapterGroupVO(outboundAdapterGroupName);
|
||||
String outboundAdapterType = outboundAdptGrpVO.getType(); //HTT, HTC, NET
|
||||
|
||||
AdapterVO adptVO = outboundAdptGrpVO.nextAdapterVO();
|
||||
// 가용 Adapter가 없는 경우
|
||||
if (adptVO == null) {
|
||||
throw new Exception("GWRequestProcessor] No adapters available.[" + outboundAdapterGroupName + "]");
|
||||
}
|
||||
|
||||
Object resObject = null;
|
||||
AdapterPropManager manager = AdapterPropManager.getInstance();
|
||||
Properties outboundProp = manager.getProperties(adptVO.getPropGroupName());
|
||||
Properties tempProp = new Properties();
|
||||
tempProp.setProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_OUT,
|
||||
StringUtils.defaultIfBlank(outboundAdptGrpVO.getMessageEncode(), Charset.defaultCharset().name()));
|
||||
|
||||
MDC.put(Logger.DISCRIMINATOR, outboundAdapterGroupName);
|
||||
logger.info("<SEND> " + getLogMessage(message));
|
||||
logger.debug(CommonLib.getDumpMessage(message));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
|
||||
if (outboundAdapterType.equals(Keys.TYPE_HTTP) || outboundAdapterType.equals(Keys.TYPE_HTTP_CUSTOM)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, outboundAdapterGroupName);
|
||||
|
||||
//set pair adapter
|
||||
if (StringUtils.isNotBlank(transactionId) && transactionId.startsWith(PAIR_ADAPTER_HEADER_PREFIX)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, GWSessionManager.getInstance().getAdapter(transactionId));
|
||||
GWSessionManager.getInstance().adapterOut(transactionId);;
|
||||
} else {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
|
||||
}
|
||||
|
||||
resObject = HttpSender.callService(outboundAdapterGroupName, outboundProp, message, tempProp);
|
||||
} else if (outboundAdapterType.equals(Keys.TYPE_NET2)) {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_GROUP_NAME, outboundAdapterGroupName);
|
||||
|
||||
//set pair adapter
|
||||
if (StringUtils.isNotBlank(transactionId) && transactionId.startsWith(PAIR_ADAPTER_HEADER_PREFIX)) {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_NAME, GWSessionManager.getInstance().getAdapter(transactionId));
|
||||
GWSessionManager.getInstance().adapterOut(transactionId);;
|
||||
} else {
|
||||
tempProp.setProperty(Keys.OUT_ADAPTER_NAME, adptVO.getName());
|
||||
//set session
|
||||
if (StringUtils.isNotBlank(transactionId)) {
|
||||
tempProp.setProperty(HttpClientAdapterServiceKey.TRANSACTION_ID, transactionId);
|
||||
}
|
||||
}
|
||||
|
||||
resObject = SocketSender.callService(outboundAdapterGroupName, outboundProp, message, tempProp);
|
||||
}
|
||||
|
||||
if (resObject != null) {
|
||||
MDC.put(Logger.DISCRIMINATOR, outboundAdapterGroupName);
|
||||
logger.info("<RECV> " + getLogMessage(resObject));
|
||||
logger.debug(CommonLib.getDumpMessage(resObject));
|
||||
MDC.remove(Logger.DISCRIMINATOR);
|
||||
}
|
||||
|
||||
return resObject;
|
||||
}
|
||||
|
||||
public static String getLogMessage(Object obj) {
|
||||
String message = null;
|
||||
int size = 0;
|
||||
if(obj instanceof byte[]) {
|
||||
message = new String((byte[]) obj);
|
||||
size = ((byte[]) obj).length;
|
||||
}
|
||||
else if(obj instanceof String) {
|
||||
message = (String) obj;
|
||||
// size = (((String) obj).getBytes()).length;
|
||||
size = ((String) obj).length();
|
||||
}
|
||||
|
||||
StringBuffer logMessage = new StringBuffer();
|
||||
logMessage.append("size[" + size + "], message[" + message + "]");
|
||||
|
||||
return logMessage.toString();
|
||||
}
|
||||
|
||||
public String getRemoteCallUrl(String instanceId) {
|
||||
EAIServerManager mgr = EAIServerManager.getInstance();
|
||||
EAIServerVO server, backupSvr = null;
|
||||
if (instanceId == null) {
|
||||
server = mgr.getEAIServer(mgr.getLocalServerName());
|
||||
backupSvr = mgr.getEAIServer(server.getFailoverSvr());
|
||||
} else {
|
||||
backupSvr = mgr.getEAIServer(instanceId);
|
||||
}
|
||||
|
||||
|
||||
StringBuffer urlBuf = new StringBuffer();
|
||||
urlBuf.append(EAIServerVO.IIOP_PROTOCOL).append("://");
|
||||
urlBuf.append(backupSvr.getAddress()).append(":");
|
||||
urlBuf.append(backupSvr.getRmiPort());
|
||||
|
||||
return urlBuf.toString();
|
||||
}
|
||||
|
||||
public Object callRemoteProxy(Object message, String outboundAdapterGroupName) {
|
||||
return callRemoteProxy(message, outboundAdapterGroupName, null, null);
|
||||
}
|
||||
|
||||
private Object callRemoteProxy(Object message, String outboundAdapterGroupName, String responseTransactionId, String responseInstanceId) {
|
||||
Properties callProp = new Properties();
|
||||
callProp.setProperty(RouteKeys.REMOTE_CALL_URL, getRemoteCallUrl(responseInstanceId));
|
||||
callProp.setProperty(OUTBOUND_ADAPTER_GROUP_NAME, outboundAdapterGroupName);
|
||||
if (responseTransactionId != null)
|
||||
callProp.setProperty(HttpClientAdapterServiceKey.TRANSACTION_ID, responseTransactionId);
|
||||
|
||||
Object resObject = null;
|
||||
|
||||
try {
|
||||
resObject = GWRemoteProxyClient.callProxyBean(message, callProp);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return resObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.mina.common.IoSession;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class GWSessionManager {
|
||||
private static final Logger logger = Logger.getLogger(Logger.LOGGER_SIFT);
|
||||
|
||||
private static volatile GWSessionManager instance;
|
||||
private final ConcurrentHashMap<String, IoSession> sessionMap;
|
||||
private final ConcurrentHashMap<String, String> adapterMap;
|
||||
|
||||
private GWSessionManager() {
|
||||
this.sessionMap = new ConcurrentHashMap<>();
|
||||
this.adapterMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public static GWSessionManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (GWSessionManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new GWSessionManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, IoSession> getSessionList() {
|
||||
return sessionMap;
|
||||
}
|
||||
|
||||
public synchronized void sessionIn(String sessionId, IoSession session) throws Exception {
|
||||
logger.info("GWSessionManager ] sessionIn - [{}, {}]", sessionId, (session != null) ? session.toString() : "null");
|
||||
if (sessionId != null && session != null) {
|
||||
sessionMap.put(sessionId, session);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sessionOut(String sessionId) {
|
||||
logger.info("GWSessionManager ] sessionOut - [{}]", sessionId);
|
||||
if (sessionId != null && sessionMap.containsKey(sessionId)) {
|
||||
sessionMap.remove(sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized IoSession getSession(String sessionId) {
|
||||
if (sessionId != null) {
|
||||
IoSession session = sessionMap.get(sessionId);
|
||||
logger.info("GWSessionManager ] getSession - [{}, {}]", sessionId, (session != null) ? session.toString() : "null");
|
||||
return session;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, String> getAdapterList() {
|
||||
return adapterMap;
|
||||
}
|
||||
|
||||
public synchronized void adapterIn(String adapterId, String adapterName) throws Exception {
|
||||
logger.info("GWSessionManager ] adapterIn - [{}, {}]", adapterId, adapterName);
|
||||
if (adapterId != null && adapterName != null) {
|
||||
adapterMap.put(adapterId, adapterName);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void adapterOut(String adapterId) {
|
||||
logger.info("GWSessionManager ] adapterOut - [{}]", adapterId);
|
||||
if (adapterId != null && adapterMap.containsKey(adapterId)) {
|
||||
adapterMap.remove(adapterId);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String getAdapter(String adapterId) {
|
||||
if (adapterId != null) {
|
||||
String adapterName = adapterMap.get(adapterId);
|
||||
logger.info("GWSessionManager ] getAdapter - [{}, {}]", adapterId, adapterName);
|
||||
return adapterName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isExists(String transactionId) {
|
||||
if (getSession(transactionId) != null || getAdapter(transactionId) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
|
||||
/**
|
||||
* request process 에서 사용하기 위한 vo
|
||||
*
|
||||
* 추후에는 전역 Context용도로 쓰일수 있음
|
||||
*
|
||||
* @author short11
|
||||
*
|
||||
*/
|
||||
public class ProcessVO
|
||||
{
|
||||
//unknow 메시지정보 시작
|
||||
private String uuid = null;//
|
||||
private String adapterGroupName = null;//
|
||||
private String adapterName = null;//
|
||||
|
||||
private String eaiSvcCd = null;//
|
||||
private boolean isTasStarted = false;//
|
||||
private long errTm = 0;//
|
||||
private String errTypeCode = null;//
|
||||
//에러정보
|
||||
private String rspErrorCode = EAIMessageKeys.EAI_DEFAULT_CODE;
|
||||
private String rspErrorMsg = null;
|
||||
|
||||
//server정보
|
||||
private String serverName = null;//
|
||||
|
||||
private String selectedKey = null;
|
||||
//unknow 메시지정보 종료
|
||||
|
||||
|
||||
//프라퍼티정보
|
||||
private String actionName = null;//
|
||||
private String stdMsgTypeCode = null;// // [K, N] 값을 가짐 : Standard, Non-Standard
|
||||
|
||||
//어댑터정보
|
||||
private String adptrMsgType = null;//
|
||||
private String inAdapterOsidInstiNo = null;//
|
||||
private String testMasterYn = null;//
|
||||
private String bidInterface = null;//
|
||||
private String inAdapterUserEmpid = null;//
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
public String getAdapterGroupName() {
|
||||
return adapterGroupName;
|
||||
}
|
||||
public void setAdapterGroupName(String adapterGroupName) {
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
}
|
||||
public String getAdapterName() {
|
||||
return adapterName;
|
||||
}
|
||||
public void setAdapterName(String adapterName) {
|
||||
this.adapterName = adapterName;
|
||||
}
|
||||
public String getEaiSvcCd() {
|
||||
return eaiSvcCd;
|
||||
}
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
public boolean isTasStarted() {
|
||||
return isTasStarted;
|
||||
}
|
||||
public void setTasStarted(boolean isTasStarted) {
|
||||
this.isTasStarted = isTasStarted;
|
||||
}
|
||||
public long getErrTm() {
|
||||
return errTm;
|
||||
}
|
||||
public void setErrTm(long errTm) {
|
||||
this.errTm = errTm;
|
||||
}
|
||||
|
||||
public String getErrTypeCode() {
|
||||
return errTypeCode;
|
||||
}
|
||||
public void setErrTypeCode(String errTypeCode) {
|
||||
this.errTypeCode = errTypeCode;
|
||||
}
|
||||
public String getActionName() {
|
||||
return actionName;
|
||||
}
|
||||
public void setActionName(String actionName) {
|
||||
this.actionName = actionName;
|
||||
}
|
||||
public String getStdMsgTypeCode() {
|
||||
return stdMsgTypeCode;
|
||||
}
|
||||
public void setStdMsgTypeCode(String stdMsgTypeCode) {
|
||||
this.stdMsgTypeCode = stdMsgTypeCode;
|
||||
}
|
||||
public String getAdptrMsgType() {
|
||||
return adptrMsgType;
|
||||
}
|
||||
public void setAdptrMsgType(String adptrMsgType) {
|
||||
this.adptrMsgType = adptrMsgType;
|
||||
}
|
||||
public String getInAdapterOsidInstiNo() {
|
||||
return inAdapterOsidInstiNo;
|
||||
}
|
||||
public void setInAdapterOsidInstiNo(String inAdapterOsidInstiNo) {
|
||||
this.inAdapterOsidInstiNo = inAdapterOsidInstiNo;
|
||||
}
|
||||
public String getRspErrorCode() {
|
||||
return rspErrorCode;
|
||||
}
|
||||
public void setRspErrorCode(String rspErrorCode) {
|
||||
this.rspErrorCode = rspErrorCode;
|
||||
}
|
||||
public String getRspErrorMsg() {
|
||||
return rspErrorMsg;
|
||||
}
|
||||
public void setRspErrorMsg(String rspErrorMsg) {
|
||||
this.rspErrorMsg = rspErrorMsg;
|
||||
}
|
||||
|
||||
public String getTestMasterYn() {
|
||||
return testMasterYn;
|
||||
}
|
||||
public void setTestMasterYn(String testMasterYn) {
|
||||
this.testMasterYn = testMasterYn;
|
||||
}
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
public String getBidInterface() {
|
||||
return bidInterface;
|
||||
}
|
||||
public void setBidInterface(String bidInterface) {
|
||||
this.bidInterface = bidInterface;
|
||||
}
|
||||
public String getSelectedKey() {
|
||||
return selectedKey;
|
||||
}
|
||||
public void setSelectedKey(String selectedKey) {
|
||||
this.selectedKey = selectedKey;
|
||||
}
|
||||
public String getInAdapterUserEmpid() {
|
||||
return inAdapterUserEmpid;
|
||||
}
|
||||
public void setInAdapterUserEmpid(String inAdapterUserEmpid) {
|
||||
this.inAdapterUserEmpid = inAdapterUserEmpid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public interface Processor
|
||||
{
|
||||
public static final String ADAPTER_GROUP_NAME = "ADAPTER_GROUP_NAME";
|
||||
public static final String ADAPTER_NAME = "ADAPTER_NAME";
|
||||
|
||||
public static final String STD_MESSAGE = "STD_MESSAGE";
|
||||
public static final String REQUEST_ACTION = "REQUEST_ACTION";
|
||||
|
||||
public static final String MESSAGE_TYPE = "MESSAGE_TYPE";
|
||||
|
||||
public static final String TAS_ADAPTER_GROUP_NAME = "TAS_ADAPTER_GROUP_NAME";
|
||||
|
||||
public Object execute(Object message, Properties prop) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.common.server.Keys;
|
||||
import com.eactive.eai.message.StandardMessageUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ProcessorFactory
|
||||
{
|
||||
private static Processor processor ;
|
||||
static{
|
||||
Class<Processor> processorClass = null;
|
||||
try {
|
||||
if (Keys.EAI_SYSTEM_TYPE_GW.equals(System.getProperty(Keys.EAI_SYSTEM_TYPE))) {
|
||||
processorClass = (Class<Processor>) Class.forName("com.eactive.eai.inbound.processor.GWRequestProcessor");
|
||||
} else if (StringUtils.isBlank(StandardMessageUtil.requestProcessorClass)) {
|
||||
processorClass = (Class<Processor>) Class.forName("com.eactive.eai.inbound.processor.RequestProcessor");
|
||||
} else {
|
||||
processorClass = (Class<Processor>) Class.forName(StandardMessageUtil.requestProcessorClass);
|
||||
}
|
||||
|
||||
processor = processorClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessorFactory() {
|
||||
}
|
||||
|
||||
public static Processor newInstance() {
|
||||
return processor;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
public class RequestProcessorException extends Exception
|
||||
{
|
||||
public RequestProcessorException() {
|
||||
super("RequestProcessorException is occured.");
|
||||
}
|
||||
|
||||
public RequestProcessorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,556 @@
|
||||
package com.eactive.eai.inbound.processor;
|
||||
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.adapter.http.HttpStatusException;
|
||||
import com.eactive.eai.adapter.http.dynamic.filter.JwtAuthException;
|
||||
import com.eactive.eai.common.exception.ExceptionHandler;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
import com.eactive.eai.common.message.MessageType;
|
||||
import com.eactive.eai.common.util.DatetimeUtil;
|
||||
import com.eactive.eai.common.util.InboundErrorLogger;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
||||
import com.eactive.eai.inbound.error.InboundErrorKeys;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.message.mapper.MessageMapper;
|
||||
import com.eactive.eai.transformer.util.IConv;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달 받은 메시지를 EAIMessage로 변환하고
|
||||
* FlowControl로 전달하는 기능을 제공한다.
|
||||
* 2. 처리 개요 :
|
||||
* - STDMessage 생성
|
||||
* - EAIMessage 생성
|
||||
* - 요청 거래로깅
|
||||
* - FlowControl 호출
|
||||
* - 응답 거래로깅
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
* :
|
||||
*/
|
||||
|
||||
public abstract class RequestProcessorSupport implements Processor
|
||||
{
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
protected static final String SERVICE_FLAG_MESSAGE = "SERVICE BLOCKED BY EAI SYSTEM";
|
||||
protected static final String STARTING_SERVICE_KEY = "ESBFW";
|
||||
|
||||
// 장애전문송신용 EAI 수신 가상어댑터 명
|
||||
protected static final String FAIL_MSG_RECEIVER = "FAIL_MSG_RECEIVER";
|
||||
|
||||
private static int rcvCount;
|
||||
private static int errCount;
|
||||
|
||||
private static boolean EAI_SERVICE_FLAG = true;
|
||||
|
||||
static Logger esbLogger = Logger.getLogger(Logger.LOGGER_ESBFW);
|
||||
protected int svrLogLevel;
|
||||
private static ThreadLocal local = new ThreadLocal(); //경과시간 동기화를 위한 ThreadLocal
|
||||
|
||||
public RequestProcessorSupport() {
|
||||
}
|
||||
|
||||
public boolean isEAIServiceFlag() {
|
||||
return EAI_SERVICE_FLAG;
|
||||
}
|
||||
|
||||
public void setEAIServiceFlag(boolean serviceFlag) {
|
||||
EAI_SERVICE_FLAG = serviceFlag;
|
||||
}
|
||||
|
||||
public static int rcvCount() {
|
||||
return rcvCount;
|
||||
}
|
||||
|
||||
public static int errCount() {
|
||||
return errCount;
|
||||
}
|
||||
|
||||
public synchronized static void resetCount() {
|
||||
rcvCount = 0;
|
||||
errCount = 0;
|
||||
}
|
||||
|
||||
private synchronized void increaseRcvCount() {
|
||||
rcvCount++;
|
||||
}
|
||||
|
||||
public synchronized void increaseErrCount() {
|
||||
errCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : RequestDispatcher에서 호출하기 위한 메소드로 내부의 hookup을 호출한다
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지수신시각설정
|
||||
* - hookup 호출
|
||||
* - 요청 거래로깅
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @param prop 호출시 전달할 Property 값(추후 확장을 위해)
|
||||
* @return Object
|
||||
* @throws JwtAuthException
|
||||
* @exception
|
||||
**/
|
||||
public Object execute(Object message, Properties prop) throws HttpStatusException
|
||||
{
|
||||
long msgRcvTm = System.currentTimeMillis();
|
||||
increaseRcvCount();
|
||||
local.set(new Long(msgRcvTm));
|
||||
|
||||
if (logger.isDebug()) logger.debug("RequestProcessor] starting - "+prop);
|
||||
Object result = null;
|
||||
String encode = "euc-kr";
|
||||
String messageType = "";
|
||||
try {
|
||||
messageType = prop.getProperty(Processor.MESSAGE_TYPE);
|
||||
encode = prop.getProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_IN);
|
||||
result = hookup(message, prop, msgRcvTm);
|
||||
return result;
|
||||
//return message;
|
||||
} catch(HttpStatusException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
increaseErrCount();
|
||||
esbLogger.error("execute error", e);
|
||||
String msg = "";
|
||||
if (StringUtils.equalsAny(messageType, MessageType.JSON, MessageType.XML)) {
|
||||
throw new HttpStatusException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
} else {
|
||||
msg = ExceptionHandler.handle(e.getMessage());
|
||||
}
|
||||
|
||||
if(message instanceof byte[]) {
|
||||
byte[] response = null;
|
||||
// if(MessageUtil.isUTF8(messageType)) {
|
||||
// encode = "utf-8";
|
||||
// }
|
||||
try {
|
||||
response = msg.getBytes(encode);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return msg.getBytes();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
else {
|
||||
return msg;
|
||||
}
|
||||
} finally {
|
||||
long msgSndTm = System.currentTimeMillis();
|
||||
if (logger.isDebug()) logger.debug("RequestProcessor] EAI 처리시각["+(msgSndTm-msgRcvTm)+" msec] - "+prop);
|
||||
if(svrLogLevel >= 1) {
|
||||
try{
|
||||
Long threadData = (Long)local.get();
|
||||
long processTm = msgSndTm - threadData.longValue();
|
||||
if (esbLogger.isInfo()) esbLogger.info("RequestProcessor] End... - 경과시간 : " + processTm + "(ms) - EAI Server Log Level is INFO");
|
||||
}catch (Exception e){
|
||||
logger.warn("execute", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 미확인 메시지에 대한 로그
|
||||
* 2. 처리 개요 :
|
||||
* - Inbound Adapter를 통해 수신된 메시지에 대한 Rule을 확인할 수 없는 경우 로그출력
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param uuid EAI서비스일련번호
|
||||
* @param adapterGroupName Inbound Adapter 그룹명
|
||||
* @param adapterName Inbound Adapter 명
|
||||
* @param errCode 에러코드
|
||||
* @param errMsg 에러내용
|
||||
* @param errTm 에러발생시각
|
||||
* @param svcInstNm EAI서버인스턴스명
|
||||
* @param message Inbound Adapter가 수신받은 메시지 Object
|
||||
* @exception
|
||||
**/
|
||||
protected void logUnknownMessage(String uuid, String adapterGroupName, String
|
||||
adapterName, String bzwkSvcKeyName, String eaiSvcCd, boolean isTasStarted,
|
||||
String errCode, String errMsg, long errTm, String svcInstNm,String errDstCd, Object message) {
|
||||
String msg = null;
|
||||
|
||||
if(errDstCd == null || errDstCd.length() ==0) {
|
||||
errDstCd = "ND";
|
||||
}
|
||||
|
||||
if(isTasStarted) {
|
||||
errDstCd = InboundErrorKeys.TAS_START;
|
||||
}
|
||||
|
||||
InboundErrorInfoVO errorInfoVO = new InboundErrorInfoVO();
|
||||
errorInfoVO.setEaiSvcSno(uuid); // EAI서비스일련번호
|
||||
errorInfoVO.setAdptBwkGrpNm(adapterGroupName); // 어댑터업무그룹명
|
||||
errorInfoVO.setEaiSvcCd(eaiSvcCd);
|
||||
errorInfoVO.setErrCd(errCode); // 에러코드
|
||||
errorInfoVO.setErrTxt(errMsg); // 에러내용
|
||||
errorInfoVO.setErrTm(DatetimeUtil.getCurrentTime(errTm)); // 에러발생시각
|
||||
errorInfoVO.setErrDstcd(errDstCd);
|
||||
errorInfoVO.setBzwkSvcKeyName(bzwkSvcKeyName);
|
||||
|
||||
if(message == null) {
|
||||
msg = "null";
|
||||
}
|
||||
else {
|
||||
if(message instanceof byte[]) {
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO srcAdapterGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
|
||||
// TAS 거래일 경우 NULL일 수 있음
|
||||
if(srcAdapterGrpVO == null) {
|
||||
msg = new String((byte[])message);
|
||||
}
|
||||
else {
|
||||
// String srcAdapterMsgType = srcAdapterGrpVO.getMessageType();
|
||||
// if( MessageUtil.isUTF8(srcAdapterMsgType) ) {
|
||||
// try {
|
||||
// msg = new String((byte[])message, UJSONMessage.encode);
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// logger.warn("msg encode error", e);
|
||||
// msg = new String((byte[])message); }
|
||||
// }
|
||||
// else {
|
||||
// msg = new String((byte[])message);
|
||||
// }
|
||||
|
||||
String charset = StringUtils.defaultIfBlank(srcAdapterGrpVO.getMessageEncode(), Charset.defaultCharset().name());
|
||||
try {
|
||||
msg = new String((byte[])message, charset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.warn("msg encode error", e);
|
||||
msg = new String((byte[])message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(message instanceof String) {
|
||||
msg = (String)message;
|
||||
}
|
||||
else {
|
||||
msg = "invaild message ["+message.getClass().getName()+"] "+message.toString();
|
||||
}
|
||||
}
|
||||
|
||||
errorInfoVO.setBwkDataTxt(msg); // 업무데이터내용
|
||||
errorInfoVO.setEaiSvrInstNm(svcInstNm); // EAI서버인스턴스명
|
||||
|
||||
InboundErrorLogger.error(errorInfoVO);
|
||||
|
||||
if (logger.isError()) {
|
||||
logger.error("======================================================================" );
|
||||
logger.error(" RequestDispatcher] GET UNKNOWN MESSAGE");
|
||||
logger.error(" ADAPTER GROUP NAME [" + adapterGroupName + "]");
|
||||
logger.error(" EAISVCNAME [" + eaiSvcCd + "]");
|
||||
logger.error(" ADAPTER NAME [" + adapterName + "]");
|
||||
logger.error("======================================================================" );
|
||||
// logger.error("<< MESSAGE DUMP >>");
|
||||
// String[] dump = CommonLib.makeDumpFormat( msg.getBytes() );
|
||||
// for(int i=0; i< dump.length; i++) {
|
||||
// logger.error(dump[i]);
|
||||
// }
|
||||
// logger.error("======================================================================" );
|
||||
}
|
||||
|
||||
}
|
||||
protected void logUnknownMessage(ProcessVO vo, Object orgMessage) {
|
||||
if(MessageType.EBC.equals(vo.getAdptrMsgType())) {
|
||||
logUnknownMessage(vo.getUuid(), vo.getAdapterGroupName(), vo.getAdapterName(), vo.getSelectedKey(), vo.getEaiSvcCd(), vo.isTasStarted(),
|
||||
vo.getRspErrorCode(), vo.getRspErrorMsg(), vo.getErrTm(), vo.getServerName(),vo.getErrTypeCode(), IConv.ebcdicToASCII((byte[])orgMessage));
|
||||
}else{
|
||||
logUnknownMessage(vo.getUuid(), vo.getAdapterGroupName(), vo.getAdapterName(), vo.getSelectedKey(), vo.getEaiSvcCd(), vo.isTasStarted(),
|
||||
vo.getRspErrorCode(), vo.getRspErrorMsg(), vo.getErrTm(), vo.getServerName(),vo.getErrTypeCode(), orgMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : ServiceFlag의 설정에 대한 경고메시지를 생성하여 리턴한다.
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지의 유형에 따라 ServieFlag 메시지를 리턴한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param inObj 요청메시지
|
||||
* @return Object
|
||||
**/
|
||||
// private Object makeServiceFlagMessage(Object inObj) {
|
||||
// Object retObject = null;
|
||||
//
|
||||
// if(inObj instanceof byte[]) {
|
||||
// retObject = SERVICE_FLAG_MESSAGE.getBytes();
|
||||
// }
|
||||
// else if(inObj instanceof byte[]) {
|
||||
// retObject = SERVICE_FLAG_MESSAGE;
|
||||
// }
|
||||
// else {
|
||||
// retObject = SERVICE_FLAG_MESSAGE;
|
||||
// }
|
||||
// return retObject;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 1. 기능 : 응답메시지 오브젝트에 따라 응답메시지를 생성하여 리턴
|
||||
* 2. 처리 개요 :
|
||||
* - Adapter메시지패턴에 따라 응답메시지를 생성하여 리턴
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param retEaiMsg 응답EAI메시지
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @param retMsgObject 응답메시지오브젝트
|
||||
* @param adptrMsgPtrnCd Adapter메시지패턴 - [S, N, C] 값을 가짐 : Standard, Non-Standard, Custom
|
||||
* @param adptrMsgType Adapter 메시지 타입 - XML, ASC, FML, EBC
|
||||
* @param uuid 거래에 대한 Unique ID - 로깅을 위한 값
|
||||
* @return Object
|
||||
**/
|
||||
|
||||
public static Object getReturnObject(EAIMessage retEaiMsg, Object message, Object retMsgObject,
|
||||
String adptrMsgPtrnCd, String adptrMsgType, String uuid, String charset) {
|
||||
|
||||
if(com.eactive.eai.adapter.Keys.IF_STANDARD.equals(adptrMsgPtrnCd)) {
|
||||
StandardMessage stdMessage = retEaiMsg.getStandardMessage();
|
||||
try {
|
||||
stdMessage.setBizData(retMsgObject, charset);
|
||||
} catch (Exception e) {
|
||||
logger.error("setBizData failed.", e);
|
||||
}
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
standardManager.getMessageCoordinator().coordinateInReturnObject(stdMessage);
|
||||
/*
|
||||
|
||||
// if(MessageType.JSON.equals(adptrMsgType)
|
||||
// || MessageType.UJSON.equals(adptrMsgType)) {
|
||||
if(MessageType.JSON.equals(adptrMsgType)) {
|
||||
return stdMessage.toJson();
|
||||
}
|
||||
// else if(MessageType.XML.equals(adptrMsgType)
|
||||
// || MessageType.UXML.equals(adptrMsgType)) {
|
||||
else if(MessageType.XML.equals(adptrMsgType)) {
|
||||
return stdMessage.toXML();
|
||||
}
|
||||
else if(MessageType.ASC.equals(adptrMsgType)) {
|
||||
return stdMessage.toFixedString(charset);
|
||||
}
|
||||
else if(MessageType.EBC.equals(adptrMsgType)) {
|
||||
logger.error("Unsupported message type - " + MessageType.EBC);
|
||||
}
|
||||
// else if(MessageUtil.isUTF8(adptrMsgType)) {
|
||||
// return stdMessage.toJson();
|
||||
// }
|
||||
else {
|
||||
return retMsgObject;
|
||||
}
|
||||
return retMsgObject;
|
||||
*/
|
||||
String obj = null;
|
||||
try {
|
||||
obj = stdMessage.getDataString(adptrMsgType, charset);
|
||||
}catch(Exception e) {
|
||||
|
||||
}
|
||||
if(obj == null) return retMsgObject;
|
||||
return obj;
|
||||
}
|
||||
else if(com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(adptrMsgPtrnCd)) {
|
||||
StandardMessage stdMessage = retEaiMsg.getStandardMessage();
|
||||
StandardMessage subMessage = retEaiMsg.getSubMessage();
|
||||
try {
|
||||
subMessage.setBizData(retMsgObject, charset);
|
||||
} catch (Exception e) {
|
||||
logger.error("setBizData failed.", e);
|
||||
}
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
standardManager.getMessageCoordinator().coordinateInReturnObject(stdMessage);
|
||||
|
||||
if(MessageType.JSON.equals(adptrMsgType)) {
|
||||
return subMessage.toJson();
|
||||
}
|
||||
else if(MessageType.XML.equals(adptrMsgType)) {
|
||||
return subMessage.toXML();
|
||||
}
|
||||
else if(MessageType.ASC.equals(adptrMsgType)) {
|
||||
return subMessage.toFixedString(charset);
|
||||
}
|
||||
else if(MessageType.EBC.equals(adptrMsgType)) {
|
||||
logger.error("Unsupported message type - " + MessageType.EBC);
|
||||
}
|
||||
else {
|
||||
return retMsgObject;
|
||||
}
|
||||
return retMsgObject;
|
||||
}
|
||||
else {
|
||||
// 비표준 XML일 경우 XML Header Tag의 존재여부를 확인하여 없는 경우 추가해야 한다.
|
||||
// if(MessageType.XML.equals(adptrMsgType) || MessageType.UXML.equals(adptrMsgType)) {
|
||||
if(MessageType.XML.equals(adptrMsgType)) {
|
||||
// String encode = MessageType.XML_ENCODE;
|
||||
// if(MessageType.UXML.equals(adptrMsgType)) {
|
||||
// encode = MessageType.UXML_ENCODE;
|
||||
// }
|
||||
if(retMsgObject == null) {
|
||||
return "";
|
||||
}
|
||||
else if(message instanceof String) {
|
||||
String xmlString = (String)retMsgObject;
|
||||
if(xmlString.indexOf("<?") == -1 && xmlString.indexOf("?>") == -1) {
|
||||
xmlString = "<?xml version=\"1.0\" encoding=\""+ charset +"\"?>"
|
||||
+ xmlString;
|
||||
}
|
||||
return xmlString;
|
||||
}
|
||||
else if(message instanceof byte[]) {
|
||||
String xmlString = null;
|
||||
try {
|
||||
xmlString = new String( (byte[])retMsgObject, charset );
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
xmlString = new String( (byte[])retMsgObject);
|
||||
}
|
||||
if(xmlString.indexOf("<?") == -1 && xmlString.indexOf("?>") == -1) {
|
||||
xmlString = "<?xml version=\"1.0\" encoding=\""+ charset +"\"?>"
|
||||
+ xmlString;
|
||||
}
|
||||
byte[] responseBytes = null;
|
||||
try {
|
||||
responseBytes = xmlString.getBytes(charset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
responseBytes = xmlString.getBytes();
|
||||
}
|
||||
return responseBytes;
|
||||
} else {
|
||||
return retMsgObject;
|
||||
}
|
||||
}else if(MessageType.JSON.equals(adptrMsgType)) {
|
||||
if(retMsgObject == null) {
|
||||
return "{}";
|
||||
}else if(retMsgObject instanceof byte[]) {
|
||||
byte[] bytesObject = (byte[])retMsgObject;
|
||||
if(bytesObject.length == 0) {
|
||||
return "{}";
|
||||
}
|
||||
}else if(retMsgObject instanceof String) {
|
||||
String stringObject = (String)retMsgObject;
|
||||
if(StringUtils.isBlank(stringObject)) {
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
|
||||
return retMsgObject;
|
||||
}else {
|
||||
return retMsgObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Object getRestrictedResponse(EAIMessage retEaiMsg, Object message,
|
||||
String adptrMsgPtrnCd, String adptrMsgType, String uuid, String charset) {
|
||||
if(com.eactive.eai.adapter.Keys.IF_STANDARD.equals(adptrMsgPtrnCd)) {
|
||||
return getRestrictedResponse(retEaiMsg, message, adptrMsgType, uuid, charset);
|
||||
}
|
||||
else {
|
||||
String eaiRestrictedRespose = "";
|
||||
if (StringUtils.equals(retEaiMsg.getRspErrCd(), EAIMessageKeys.EAI_INFLOW_BLOCKED_CODE)) {
|
||||
eaiRestrictedRespose = "It was not processed by flow control.[" + retEaiMsg.getEAISvcCd() + "]";
|
||||
} else {
|
||||
eaiRestrictedRespose = "It was not processed by transaction control.[" + retEaiMsg.getEAISvcCd() + "]";
|
||||
}
|
||||
if(MessageType.XML.equals(adptrMsgType)) {
|
||||
return MessageUtil.makeXmlErrorMessage(retEaiMsg.getRspErrCd(), retEaiMsg.getRspErrMsg(), charset);
|
||||
} else if (MessageType.JSON.equals(adptrMsgType)) {
|
||||
return MessageUtil.makeJsonErrorMessage(retEaiMsg.getRspErrCd(), retEaiMsg.getRspErrMsg());
|
||||
} else {
|
||||
try {
|
||||
return eaiRestrictedRespose.getBytes(charset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return eaiRestrictedRespose.getBytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object getRestrictedResponse(EAIMessage retEaiMsg, Object message,
|
||||
String adptrMsgType, String uuid, String charset) {
|
||||
StandardMessage stdMessage = retEaiMsg.getStandardMessage();
|
||||
//InterfaceMapper mapper = retEaiMsg.getMapper();
|
||||
// String errorMessage = ExceptionUtil.make(retEaiMsg.getRspErrCd(), new String[]{retEaiMsg.getEAISvcCd()});
|
||||
// mapper.setErrorCode(stdMessage, STDMessageKeys.ERROR_CODE_VALUE);
|
||||
// mapper.setErrorMsg(stdMessage, errorMessage);
|
||||
//mapper.setErrorCode(stdMessage, retEaiMsg.getRspErrCd());
|
||||
//mapper.setErrorMsg(stdMessage, retEaiMsg.getRspErrMsg());
|
||||
|
||||
// 표준메시지에 BizData 셋팅할 필요 없을듯(요청 BizData 리턴)
|
||||
// try {
|
||||
// stdMessage.setBizData(errorMessage, charset);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("setBizData failed.", e);
|
||||
// }
|
||||
/*
|
||||
// if(MessageType.JSON.equals(adptrMsgType)
|
||||
// || MessageType.UJSON.equals(adptrMsgType)) {
|
||||
if(MessageType.JSON.equals(adptrMsgType)) {
|
||||
return stdMessage.toJson();
|
||||
}
|
||||
// else if(MessageType.XML.equals(adptrMsgType)
|
||||
// || MessageType.UXML.equals(adptrMsgType)) {
|
||||
else if(MessageType.XML.equals(adptrMsgType)) {
|
||||
return stdMessage.toXML();
|
||||
}
|
||||
else if(MessageType.ASC.equals(adptrMsgType)) {
|
||||
return stdMessage.toFixedString(charset);
|
||||
}
|
||||
else if(MessageType.EBC.equals(adptrMsgType)) {
|
||||
logger.error("Unsupported message type - " + MessageType.EBC);
|
||||
}
|
||||
// else if(MessageUtil.isUTF8(adptrMsgType)) {
|
||||
// return stdMessage.toJson();
|
||||
// }
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
return message;
|
||||
*/
|
||||
String obj = null;
|
||||
try {
|
||||
obj = stdMessage.getDataString(adptrMsgType, charset);
|
||||
}catch(Exception e) {
|
||||
|
||||
}
|
||||
if(obj==null) return message;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Inbound Adapter를 통해 전달 받은 메시지를 EAIMessage로 변환하고
|
||||
* FlowControl로 전달하는 기능을 제공한다.
|
||||
* 2. 처리 개요 :
|
||||
* - KBMessage 생성
|
||||
* - EAIMessage 생성
|
||||
* - 요청 거래로깅
|
||||
* - FlowControl 호출
|
||||
* - 응답 거래로깅
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message Object 타입의 요청메시지
|
||||
* @param prop 호출시 전달할 Property 값(추후 확장을 위해)
|
||||
* @param msgRcvTm 메시지 수신시각
|
||||
* @return Object
|
||||
* @exception RequestProcessorException
|
||||
**/
|
||||
abstract protected Object hookup(Object message, Properties prop, long msgRcvTm) throws RequestProcessorException, Exception ;
|
||||
}
|
||||
Reference in New Issue
Block a user