표준전문이 JSON MS949인 경우, 한글 깨짐 처리
This commit is contained in:
+45
-28
@@ -212,6 +212,7 @@ public class HttpAdapterServiceStandard extends HttpAdapterServiceSupport
|
|||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
byte[] responseBytes = null;
|
||||||
String responseData = "";
|
String responseData = "";
|
||||||
if (RESPONSE_TYPE_ASYNC.equals(responseType)){
|
if (RESPONSE_TYPE_ASYNC.equals(responseType)){
|
||||||
if (stopWatch.getTime() > slowTranTime){
|
if (stopWatch.getTime() > slowTranTime){
|
||||||
@@ -222,17 +223,22 @@ public class HttpAdapterServiceStandard extends HttpAdapterServiceSupport
|
|||||||
|
|
||||||
if ( result == null) {
|
if ( result == null) {
|
||||||
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName);
|
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName);
|
||||||
|
responseBytes = responseData.getBytes();
|
||||||
} else if (result instanceof byte[]) {
|
} else if (result instanceof byte[]) {
|
||||||
responseData = new String((byte[]) result, encode);
|
responseData = new String((byte[]) result, encode);
|
||||||
|
responseBytes = (byte[]) result;
|
||||||
} else if (result instanceof String) {
|
} else if (result instanceof String) {
|
||||||
responseData = (String) result;
|
responseBytes = ((String)result).getBytes();
|
||||||
if ( StringUtils.isBlank( responseData ) ) {
|
if ( StringUtils.isBlank((String)result ) ) {
|
||||||
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName, adptName);
|
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName, adptName);
|
||||||
|
responseBytes = responseData.getBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setCharacterEncoding(encode);
|
response.setCharacterEncoding(encode);
|
||||||
response.getWriter().print(responseData);
|
// response.getWriter().print(responseData);
|
||||||
|
response.getOutputStream().write(responseBytes);
|
||||||
|
|
||||||
if (traceLevel >= 3){
|
if (traceLevel >= 3){
|
||||||
HttpMemoryLogger.txlog(adptGrpName+adptName, "SEND "+"["+responseData+"]"+
|
HttpMemoryLogger.txlog(adptGrpName+adptName, "SEND "+"["+responseData+"]"+
|
||||||
((responseData == null)?"":CommonLib.getDumpMessage(responseData))
|
((responseData == null)?"":CommonLib.getDumpMessage(responseData))
|
||||||
@@ -240,45 +246,56 @@ public class HttpAdapterServiceStandard extends HttpAdapterServiceSupport
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(requestBytes != null) {
|
if(requestBytes != null) {
|
||||||
if (result instanceof byte[]) {
|
if ( result == null) {
|
||||||
|
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName);
|
||||||
|
responseBytes = responseData.getBytes();
|
||||||
|
} else if (result instanceof byte[]) {
|
||||||
responseData = new String((byte[]) result, encode);
|
responseData = new String((byte[]) result, encode);
|
||||||
|
responseBytes = (byte[]) result;
|
||||||
} else if (result instanceof String) {
|
} else if (result instanceof String) {
|
||||||
responseData = (String) result;
|
responseBytes = ((String)result).getBytes();
|
||||||
|
if ( StringUtils.isBlank((String)result ) ) {
|
||||||
|
responseData = ElinkConfig.getAsyncDummyDataForAdapterGroup(adptGrpName, adptName);
|
||||||
|
responseBytes = responseData.getBytes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("종료 >> encode = [" + encode + "]");
|
logger.info("종료 >> encode = [" + encode + "]");
|
||||||
|
|
||||||
if (addData.length() > 0){
|
if (addData.length() > 0){
|
||||||
responseData = addData + responseData;
|
responseData = addData + responseData;
|
||||||
|
responseBytes = responseData.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
Object root = JSONValue.parse(responseData);
|
// Object root = JSONValue.parse(responseData);
|
||||||
if( root instanceof JSONObject ) {
|
// if( root instanceof JSONObject ) {
|
||||||
JSONObject wrappedObject = (JSONObject) root;
|
// JSONObject wrappedObject = (JSONObject) root;
|
||||||
responseData = wrappedObject.get("DJB_ROOTLESS_ARRAY").toString();
|
// responseData = wrappedObject.get("DJB_ROOTLESS_ARRAY").toString();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}catch (Exception e) {
|
// }catch (Exception e) {
|
||||||
// ignore json이 아니기에 해줄것이 없음.
|
// // ignore json이 아니기에 해줄것이 없음.
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 300응답에서 받은 Header정보 사용하기 위해 읽어옴.
|
// 300응답에서 받은 Header정보 사용하기 위해 읽어옴.
|
||||||
Map<String, Object> responsePropertyMap = (Map<String, Object>) prop.get(OUTBOUND_PROPERTY_MAP);
|
// Map<String, Object> responsePropertyMap = (Map<String, Object>) prop.get(OUTBOUND_PROPERTY_MAP);
|
||||||
if(responsePropertyMap != null){
|
// if(responsePropertyMap != null){
|
||||||
Properties responseHeaders = (Properties)responsePropertyMap.get(OUTBOUND_RESPONSE_HEADERS);
|
// Properties responseHeaders = (Properties)responsePropertyMap.get(OUTBOUND_RESPONSE_HEADERS);
|
||||||
Map<String, String> responseHeaderMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
// Map<String, String> responseHeaderMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
// Properties 내용을 모두 복사
|
// // Properties 내용을 모두 복사
|
||||||
for (String name : responseHeaders.stringPropertyNames()) {
|
// for (String name : responseHeaders.stringPropertyNames()) {
|
||||||
responseHeaderMap.put(name, responseHeaders.getProperty(name));
|
// responseHeaderMap.put(name, responseHeaders.getProperty(name));
|
||||||
}
|
// }
|
||||||
String contentTytpe = responseHeaderMap.get("Content-Type");
|
// String contentTytpe = responseHeaderMap.get("Content-Type");
|
||||||
response.setContentType(contentTytpe); // 300응답에서 받은 Content-Type을 그대로 적용.
|
// response.setContentType(contentTytpe); // 300응답에서 받은 Content-Type을 그대로 적용.
|
||||||
}
|
// }
|
||||||
|
|
||||||
// UI와 통신시(UTF-8) 변환오류로 ENCODE 제거
|
// UI와 통신시(UTF-8) 변환오류로 ENCODE 제거
|
||||||
response.setCharacterEncoding(encode);
|
response.setCharacterEncoding(encode);
|
||||||
response.getWriter().print(responseData);
|
// response.getWriter().print(responseData);
|
||||||
|
response.getOutputStream().write(responseBytes);
|
||||||
|
|
||||||
if (logger.isDebug()){
|
if (logger.isDebug()){
|
||||||
logger.debug("HttpAdapter] SEND ("+adptGrpName+") = [" + responseData + "]");
|
logger.debug("HttpAdapter] SEND ("+adptGrpName+") = [" + responseData + "]");
|
||||||
logger.debug("HttpAdapter] SEND ("+adptGrpName+") = " +
|
logger.debug("HttpAdapter] SEND ("+adptGrpName+") = " +
|
||||||
|
|||||||
Reference in New Issue
Block a user