에러 처리 수정

main
이범준 12 months ago
parent 3a8ae4e549
commit 7746f430d2

@ -72,36 +72,25 @@ public class MessageUtil {
return contentsByteCnt;
}
public String getRcsDescription(String text) {
public String getRcsDescription(String text) throws Exception {
String result = "";
try {
JSONParser jp = new JSONParser();
Object obj = jp.parse(text);
JSONObject jsonObject = (JSONObject)obj;
result = (String)((JSONObject)((JSONObject)jsonObject.get("msg")).get("body")).get("description");
} catch (Exception e) {
throw new RuntimeException(e);
}
JSONParser jp = new JSONParser();
Object obj = jp.parse(text);
JSONObject jsonObject = (JSONObject)obj;
result = (String)((JSONObject)((JSONObject)jsonObject.get("msg")).get("body")).get("description");
return result;
}
public String getAltDescription(String text) {
public String getAltDescription(String text) throws Exception {
String result = "";
try {
JSONParser jp = new JSONParser();
Object obj = jp.parse(text);
JSONObject jsonObject = (JSONObject)obj;
result = (String)jsonObject.get("text");
} catch (Exception e) {
throw new RuntimeException(e);
}
JSONParser jp = new JSONParser();
Object obj = jp.parse(text);
JSONObject jsonObject = (JSONObject)obj;
result = (String)jsonObject.get("text");
return result;
}

@ -100,7 +100,22 @@ public class MessageServiceBean extends AbstractServiceBean implements MessageSe
&& !EgovStringUtil.null2void(messageEntity.getAltJson()).equals("")) {
//description부 구하기
String description = forJsonText.getAltDescription(messageEntity.getAltJson());
String description = "";
try {
description = forJsonText.getAltDescription(messageEntity.getAltJson());
} catch (Exception e) {
isSuccess = false;
messageEntity.setFailRsn("알림톡 JSON 파싱 오류");
failList.add(messageEntity);
continue;
}
if(description.equals("")) {
isSuccess = false;
messageEntity.setFailRsn("알림톡 JSON 파싱 오류(본문내용없음)");
failList.add(messageEntity);
continue;
}
//description부 글자수 계산하기
int altCharCount = description.length();
if(altCharCount > 1000) {
@ -116,8 +131,24 @@ public class MessageServiceBean extends AbstractServiceBean implements MessageSe
&& !EgovStringUtil.null2void(messageEntity.getRcsJson()).equals("")) {
String contentsTypeOfRCS = messageEntity.findContentsTypeOfRCS();
//description부 구하기
String description = forJsonText.getRcsDescription(messageEntity.getRcsJson());
String description = "";
try {
description = forJsonText.getRcsDescription(messageEntity.getRcsJson());
} catch (Exception e) {
isSuccess = false;
messageEntity.setFailRsn("RCS JSON 파싱 오류");
failList.add(messageEntity);
continue;
}
if(description.equals("")) {
isSuccess = false;
messageEntity.setFailRsn("RCS JSON 파싱 오류(본문내용없음)");
failList.add(messageEntity);
continue;
}
//description부 글자수 계산하기
int rcsCharCount = description.length();
if(contentsTypeOfRCS.equals("RCS") && rcsCharCount > 100) {

@ -184,6 +184,7 @@ public class MessageInterfaceController extends AbstractController {
List<MessageEntity> messageEntityList = new ArrayList<MessageEntity>();
List<Map<String,Object>> reqs = (List<Map<String,Object>>) apiSpec.get("reqs");
for(Map<String,Object> req : reqs) {
MessageEntity messageEntity = new MessageEntity();
messageEntity.setSubId(nuri2Id);
@ -224,24 +225,30 @@ public class MessageInterfaceController extends AbstractController {
altJsonComplete = kkoTemplate;
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//역슬래시문자 치환
replacedArgValue = replacedArgValue.replace("\\", "\\\\");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forJsonText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forJsonText.replaceLineChangeForNuri2Oracle(replacedArgValue);
try {
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//역슬래시문자 치환
replacedArgValue = replacedArgValue.replace("\\", "\\\\");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forJsonText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forJsonText.replaceLineChangeForNuri2Oracle(replacedArgValue);
}
altJsonComplete = altJsonComplete.replace("{{"+argName+"}}", replacedArgValue);
}
altJsonComplete = altJsonComplete.replace("{{"+argName+"}}", replacedArgValue);
} catch (Exception e) {
messageEntity.setFailRsn("알림톡 템플릿 변수 매핑 오류");
messageEntityList.add(messageEntity);
continue;
}
able_kko = true;
@ -257,29 +264,47 @@ public class MessageInterfaceController extends AbstractController {
rcsJsonComplete = rcsTemplate;
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//역슬래시문자 치환
replacedArgValue = replacedArgValue.replace("\\", "\\\\");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forJsonText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forJsonText.replaceLineChangeForNuri2Oracle(replacedArgValue);
try {
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//역슬래시문자 치환
replacedArgValue = replacedArgValue.replace("\\", "\\\\");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forJsonText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forJsonText.replaceLineChangeForNuri2Oracle(replacedArgValue);
}
rcsJsonComplete = rcsJsonComplete.replace("{{"+argName+"}}", replacedArgValue);
}
rcsJsonComplete = rcsJsonComplete.replace("{{"+argName+"}}", replacedArgValue);
} catch (Exception e) {
messageEntity.setFailRsn("RCS 템플릿 변수 매핑 오류");
messageEntityList.add(messageEntity);
continue;
}
//description부 구하기
String description = forJsonText.getRcsDescription(rcsJsonComplete);
String description = "";
try {
description = forJsonText.getRcsDescription(rcsJsonComplete);
}catch(Exception e) {
messageEntity.setFailRsn("RCS JSON 파싱 오류");
messageEntityList.add(messageEntity);
continue;
}
if(description.equals("")) {
messageEntity.setFailRsn("RCS JSON 파싱 오류(본문내용없음)");
messageEntityList.add(messageEntity);
continue;
}
//description부 글자수 계산하기
int rcsCharCount = description.length();
@ -297,24 +322,30 @@ public class MessageInterfaceController extends AbstractController {
xmsPlainComplete = xmsTemplate;
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forPlainText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forPlainText.replaceLineChangeForNuri2Oracle(replacedArgValue);
}
xmsPlainComplete = xmsPlainComplete.replace("{{"+argName+"}}", replacedArgValue);
}
try {
//변수매핑하기
for(HashMap arg : args) {
String argName = (String)arg.get("argName");
String argValue = (String)arg.get("argValue");
String replacedArgValue = "";
//탭문자 치환
replacedArgValue = argValue.replaceAll("\t", " ");
//개행문자 치환
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
replacedArgValue = forPlainText.replaceLineChangeForNuri2Maria(replacedArgValue);
} else {
replacedArgValue = forPlainText.replaceLineChangeForNuri2Oracle(replacedArgValue);
}
xmsPlainComplete = xmsPlainComplete.replace("{{"+argName+"}}", replacedArgValue);
}
} catch(Exception e) {
messageEntity.setFailRsn("xMS 템플릿 변수 매핑 오류");
messageEntityList.add(messageEntity);
continue;
}
//글자수 계산
int xmsByteCount = forPlainText.countBytes(xmsPlainComplete,2,databaseId);

Loading…
Cancel
Save