Path Variable처리, API식별방식 변경(DAO->STDMessageManager)
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -27,8 +28,8 @@ import com.eactive.eai.adapter.service.ApiAdapterService;
|
||||
import com.eactive.eai.common.TransactionContextKeys;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.common.stdmessage.STDMessageDAO;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.stdmessage.STDMessageManager;
|
||||
import com.eactive.eai.common.stdmessage.STDMsgInfoAddOnVO;
|
||||
import com.eactive.eai.common.util.DatetimeUtil;
|
||||
import com.eactive.eai.common.util.InboundErrorLogger;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
@@ -40,7 +41,6 @@ import com.eactive.eai.inbound.error.InboundErrorInfoVO;
|
||||
import org.json.simple.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.eactive.eai.data.entity.onl.stdmessage.StandardMessageInfo;
|
||||
|
||||
@RestController
|
||||
public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
@@ -65,16 +65,24 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
//** jwhong TSEAIHS04의 api full path와 비교하여 adapter를 가져온다
|
||||
String methodAndUri = servletRequest.getMethod() + "|" + apiUri;
|
||||
HttpDynamicInAdapterUri adptUri = null;
|
||||
String adapterGrpName ="";
|
||||
String apiSvcCode = "";
|
||||
String bzwkSvcKeyName = ""; // Adapter Group별 Action Class에 따라 구성이 달라짐. 예) _AGW_IN_RST_SyS:POST/account/{acc_no}
|
||||
String adapterGrpName = ""; // Adapter Group명 예) _AGW_IN_RST_SyS : API_PATH(/api/test)
|
||||
String apiSvcCode = ""; // eaiSvcCd 예) LONNCHCON00005S2
|
||||
String apiFullPathKey = ""; // 예) POST|/api/test/account/list, POST|/api/test/account/{acc_no}
|
||||
Map<String, String> pathVariables = null;
|
||||
try {
|
||||
STDMessageDAO dao = ApplicationContextProvider.getContext().getBean(STDMessageDAO.class);
|
||||
StandardMessageInfo stdInfo = dao.getSTDMsgByPath(methodAndUri);
|
||||
String serviceKey = stdInfo.getBzwksvckeyname();
|
||||
int idx = serviceKey.indexOf(":");
|
||||
adapterGrpName = (idx != -1) ? serviceKey.substring(0, idx) : serviceKey; // ':' 이전 문자열 추출
|
||||
apiSvcCode = stdInfo.getEaisvcname();
|
||||
//아래 원래 Logic
|
||||
// PathVariable(ex:/api/test/account/{acc_no}) 대응 및 DAO조회 제거.
|
||||
// /api/test/account/1234567 호출시 /api/test/account/{acc_no} API 로 식별.
|
||||
STDMessageManager manager = STDMessageManager.getInstance();
|
||||
STDMsgInfoAddOnVO stdMsgInfo = manager.getStdMsgInfoAddOn(methodAndUri);
|
||||
bzwkSvcKeyName = stdMsgInfo.getBzwksvckeyname();
|
||||
apiSvcCode = stdMsgInfo.getEaiSvcCd();
|
||||
adapterGrpName = stdMsgInfo.gAdapterGroupName();
|
||||
apiFullPathKey = stdMsgInfo.getApiFullPath();
|
||||
if (STDMessageManager.isPathVariable(apiFullPathKey)) {
|
||||
pathVariables = new AntPathMatcher().extractUriTemplateVariables(apiFullPathKey, methodAndUri);
|
||||
}
|
||||
|
||||
adptUri = findAdptUri(apiUri, HttpDynamicInAdapterManager.getInstance(), adapterGrpName);
|
||||
} catch (Exception e) {
|
||||
adptUri = null;
|
||||
@@ -121,6 +129,9 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
// jwhong, put api received time, eaiSvcCode
|
||||
transactionProp.put(INBOUND_REQUESTED_TIME, receivedTimeStr);
|
||||
transactionProp.put(API_SERVICE_CODE, apiSvcCode);
|
||||
if (pathVariables != null) {
|
||||
transactionProp.put(INBOUND_PATH_VARIABLES, pathVariables);
|
||||
}
|
||||
|
||||
try {
|
||||
String responseData = service.callApi(servletRequest, servletResponse, httpProp, adapterGroupVO, adapterVO, transactionProp);
|
||||
@@ -206,7 +217,6 @@ public class ApiAdapterController implements HttpAdapterServiceKey {
|
||||
|
||||
|
||||
//
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
HttpDynamicInAdapterUri adptUri = manager.getAdptUri(apiUri);
|
||||
if (adptUri != null) {
|
||||
|
||||
Reference in New Issue
Block a user