Merge branch 'jenkins_with_weblogic' of ssh://git@192.168.240.178:18081/eapim/eapim-online.git into jenkins_with_weblogic
This commit is contained in:
+9
-5
@@ -82,10 +82,7 @@ public class CustomOAuth2AuthenticationEntryPoint extends OAuth2AuthenticationEn
|
|||||||
|
|
||||||
private void logTokenIssuance(boolean isSuccess, boolean isRestrictionExempt, String resultMessage, String accessToken) {
|
private void logTokenIssuance(boolean isSuccess, boolean isRestrictionExempt, String resultMessage, String accessToken) {
|
||||||
try {
|
try {
|
||||||
if (!EAIDBLogControl.isEnable()) {
|
|
||||||
logger.warn("DB logging is disabled. Skipping token issuance logging.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RequestContextData data = RequestContextData.ThreadLocalRequestContext.get();
|
RequestContextData data = RequestContextData.ThreadLocalRequestContext.get();
|
||||||
OAuth2Manager.getInstance();
|
OAuth2Manager.getInstance();
|
||||||
|
|
||||||
@@ -109,8 +106,15 @@ public class CustomOAuth2AuthenticationEntryPoint extends OAuth2AuthenticationEn
|
|||||||
log.setResultMessage(resultMessage);
|
log.setResultMessage(resultMessage);
|
||||||
log.setAccessToken(accessToken); // Add access token value to the log
|
log.setAccessToken(accessToken); // Add access token value to the log
|
||||||
|
|
||||||
logger.info("Token request[/oauth/token or /oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
if( !isSuccess ) {
|
||||||
|
logger.error("Token request[/oauth/token or /oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
||||||
clientId, data.getGrantType(), data.getScope());
|
clientId, data.getGrantType(), data.getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EAIDBLogControl.isEnable()) {
|
||||||
|
logger.warn("DB logging is disabled. Skipping token issuance logging.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
|
|||||||
+8
-5
@@ -93,10 +93,6 @@ public class CustomTokenEndpointExceptionResolver implements HandlerExceptionRes
|
|||||||
private void logTokenIssuance(boolean isSuccess, boolean isRestrictionExempt, String resultMessage,
|
private void logTokenIssuance(boolean isSuccess, boolean isRestrictionExempt, String resultMessage,
|
||||||
String accessToken) {
|
String accessToken) {
|
||||||
try {
|
try {
|
||||||
if (!EAIDBLogControl.isEnable()) {
|
|
||||||
logger.warn("DB logging is disabled. Skipping token issuance logging.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RequestContextData data = RequestContextData.ThreadLocalRequestContext.get();
|
RequestContextData data = RequestContextData.ThreadLocalRequestContext.get();
|
||||||
OAuth2Manager.getInstance();
|
OAuth2Manager.getInstance();
|
||||||
|
|
||||||
@@ -120,8 +116,15 @@ public class CustomTokenEndpointExceptionResolver implements HandlerExceptionRes
|
|||||||
log.setResultMessage(resultMessage);
|
log.setResultMessage(resultMessage);
|
||||||
log.setAccessToken(accessToken); // Add access token value to the log
|
log.setAccessToken(accessToken); // Add access token value to the log
|
||||||
|
|
||||||
logger.info("Token request[/oauth/token or /oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
if( !isSuccess ) {
|
||||||
|
logger.error("Token request[/oauth/token or /oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
||||||
clientId, data.getGrantType(), data.getScope());
|
clientId, data.getGrantType(), data.getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EAIDBLogControl.isEnable()) {
|
||||||
|
logger.warn("DB logging is disabled. Skipping token issuance logging.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package com.eactive.eai.custom.transform.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.eactive.eai.common.message.EAIMessage;
|
||||||
|
import com.eactive.eai.common.message.EAIMessageManager;
|
||||||
|
import com.eactive.eai.common.message.ServiceMessage;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
import com.eactive.eai.common.util.MessageUtil;
|
||||||
|
import com.eactive.eai.transformer.engine.TransformEngine;
|
||||||
|
import com.eactive.eai.transformer.engine.Transformer;
|
||||||
|
import com.eactive.eai.transformer.layout.Layout;
|
||||||
|
import com.eactive.eai.transformer.message.JSONMessage;
|
||||||
|
import com.eactive.eai.transformer.message.Message;
|
||||||
|
import com.eactive.eai.transformer.message.MessageFactory;
|
||||||
|
import com.eactive.eai.transformer.transform.Transform;
|
||||||
|
import com.eactive.eai.transformer.transform.TransformManager;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class PrettyPrintContoller {
|
||||||
|
public static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||||
|
|
||||||
|
private static final String FALLBACK_ERROR_JSON =
|
||||||
|
"{ \"error\": true, \"result\": \"occur error building responseMessage.\" }";
|
||||||
|
|
||||||
|
@RequestMapping(value = "/PrettyPrint", method = RequestMethod.POST, consumes = "application/json", produces = "application/json; charset=UTF-8")
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseEntity<String> tokenJson(@RequestBody PrettyPrintRequest transFormRequest, HttpServletRequest request,
|
||||||
|
HttpServletResponse response) {
|
||||||
|
|
||||||
|
PrettyPrintResponse prettyPrintResponse = new PrettyPrintResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String layoutName = getLayoutName(transFormRequest);
|
||||||
|
|
||||||
|
String result = Optional.ofNullable(MessageFactory.getFactory().getMessage(layoutName))
|
||||||
|
.map(message -> {
|
||||||
|
|
||||||
|
message.setData(transFormRequest.getBizData());
|
||||||
|
|
||||||
|
return message.toXMLString();
|
||||||
|
})
|
||||||
|
.orElseThrow(()-> new IllegalArgumentException("업무 메세지 파싱중 오류"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
prettyPrintResponse.setResult(result);
|
||||||
|
String successJson = buildResponseMessage(prettyPrintResponse);
|
||||||
|
return ResponseEntity.ok(successJson);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Pretty print 실패", e);
|
||||||
|
prettyPrintResponse.setError(true);
|
||||||
|
prettyPrintResponse.setResult("잘못된 업무데이터 전문 파싱 중 에러");
|
||||||
|
String errorJson = buildResponseMessage(prettyPrintResponse);
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String buildResponseMessage(PrettyPrintResponse prettyPrintResponse) {
|
||||||
|
try {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
return mapper.writeValueAsString(prettyPrintResponse);
|
||||||
|
}catch (Exception e) {
|
||||||
|
return FALLBACK_ERROR_JSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLayoutName(PrettyPrintRequest request) throws Exception {
|
||||||
|
|
||||||
|
EAIMessageManager eaiMessageManager = EAIMessageManager.getInstance();
|
||||||
|
|
||||||
|
EAIMessage eaiMessage = eaiMessageManager.getEAIMessage(request.getIntrefaceId());
|
||||||
|
|
||||||
|
TransformManager transformManager = TransformManager.getManager();
|
||||||
|
|
||||||
|
if (eaiMessage == null) {
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Invalid interfaceId=" + request.getIntrefaceId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ServiceMessage> serviceMessageList = eaiMessage.getSvcMsgs();
|
||||||
|
|
||||||
|
ServiceMessage serviceMessage = serviceMessageList.get(0);
|
||||||
|
|
||||||
|
String transformId;
|
||||||
|
Transform transformInfo;
|
||||||
|
Layout layout;
|
||||||
|
|
||||||
|
switch (request.getLogProcessNo()) {
|
||||||
|
case "100":
|
||||||
|
transformId = serviceMessage.getCnvMsgID();
|
||||||
|
transformInfo = transformManager.getTransform(transformId);
|
||||||
|
layout = transformInfo.getSourceLayout(0);
|
||||||
|
return layout.getName();
|
||||||
|
case "200":
|
||||||
|
transformId = serviceMessage.getCnvMsgID();
|
||||||
|
transformInfo = transformManager.getTransform(transformId);
|
||||||
|
layout = transformInfo.getTargetLayout();
|
||||||
|
return layout.getName();
|
||||||
|
case "300":
|
||||||
|
transformId = serviceMessage.getBsRspCnvMsgID();
|
||||||
|
transformInfo = transformManager.getTransform(transformId);
|
||||||
|
layout = transformInfo.getSourceLayout(0);
|
||||||
|
return layout.getName();
|
||||||
|
case "400":
|
||||||
|
transformId = serviceMessage.getBsRspCnvMsgID();
|
||||||
|
transformInfo = transformManager.getTransform(transformId);
|
||||||
|
layout = transformInfo.getTargetLayout();
|
||||||
|
return layout.getName();
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid logProcessNo: " + request.getLogProcessNo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.eactive.eai.custom.transform.api;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
|
import com.fasterxml.jackson.annotation.Nulls;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
@ToString
|
||||||
|
@Getter
|
||||||
|
public class PrettyPrintRequest implements Serializable {
|
||||||
|
private String logProcessNo;
|
||||||
|
private String intrefaceId;
|
||||||
|
private String bizData;
|
||||||
|
@JsonSetter(nulls = Nulls.SKIP)
|
||||||
|
private boolean error = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.eactive.eai.custom.transform.api;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
|
import com.fasterxml.jackson.annotation.Nulls;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
@ToString
|
||||||
|
@Setter
|
||||||
|
public class PrettyPrintResponse implements Serializable {
|
||||||
|
private String result;
|
||||||
|
@JsonSetter(nulls = Nulls.SKIP)
|
||||||
|
private boolean error = false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user