Merge remote-tracking branch 'origin/jenkins_with_weblogic' into jenkins_with_weblogic

This commit is contained in:
Rinjae
2026-02-04 10:38:05 +09:00
6 changed files with 100 additions and 42 deletions
@@ -438,19 +438,36 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
resultSet = sis.readLine(arg, total, 1024);
}
param.put("recvData", new String(arg, "UTF-8"));
// ===== 인코딩 확인 로그 시작 =====
logger.info("========== 인코딩 디버깅 정보 ==========");
logger.info("request.getCharacterEncoding(): " + request.getCharacterEncoding());
logger.info("request.getContentType(): " + request.getContentType());
logger.info("Content Length: " + arg.length + " bytes");
// 다양한 인코딩으로 읽어보기
String asDefaultEncoding = new String(arg);
String asUtf8 = new String(arg, "UTF-8");
String asEucKr = new String(arg, "EUC-KR");
logger.info("Default Encoding 전체 내용:\n" + asDefaultEncoding);
logger.info("UTF-8 전체 내용:\n" + asUtf8);
logger.info("EUC-KR 전체 내용:\n" + asEucKr);
logger.info("========================================");
// ===== 인코딩 확인 로그 끝 =====
param.put("recvData", new String(arg, "EUC-KR"));
} catch(Exception e) {
logger.error("MessageSync.err - don't read the XML File - " + new String(arg), e);
logger.error("MessageSync.err - don't read the XML File - " + new String(arg, "EUC-KR"), e);
param.put("recvData", "");
}
// byte[]로부터 XML 파싱 (BOM 제거)
String xmlContent = new String(arg, "UTF-8").trim();
// byte[]로부터 XML 파싱 (BOM 제거) - EUC-KR로 읽기
String xmlContent = new String(arg, "EUC-KR").trim();
// BOM 제거 (UTF-8 BOM: EF BB BF)
if (xmlContent.startsWith("\uFEFF")) {
xmlContent = xmlContent.substring(1);
}
Document doc = builder.build(new ByteArrayInputStream(xmlContent.getBytes("UTF-8")));
Document doc = builder.build(new ByteArrayInputStream(xmlContent.getBytes("EUC-KR")));
param.put("logPrcssSeqno", UUIDGenerator.getUUID());
// xml 1.1
@@ -512,7 +529,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
if (!"EAI".equalsIgnoreCase(useSystem) && !"FEP".equalsIgnoreCase(useSystem)) {
String errorMessage = "사용 시스템(" + useSystem + ")인 전문레이아웃은 EAI, FEP로 배포 안됨.";
logger.error(errorMessage);
throw new Exception(errorMessage);
throw new UseSystemException(errorMessage);
}
if( "ASCII".equals(format.getAttributeValue("msgType")) ) {
@@ -587,9 +604,15 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
logger.error("",e.getStackTrace()[0]);
try {
if( results != null ) {
results.getChild("Result").setText("False");
if (e instanceof UseSystemException) {
results.getChild("Result").setText("True");
} else {
results.getChild("Result").setText("False");
}
results.getChild("ResultMessage").setText( e.getMessage() );
resultS = StringUtils.toXMLString(rDoc, true);
}
if( param.get("logPrcssSeqno") == null ) {
@@ -607,10 +630,11 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null;
try {
response.setContentType("application/xml; charset=EUC-KR");
sos = response.getOutputStream();
sos.write(resultS.getBytes());
sos.write(resultS.getBytes("EUC-KR"));
} catch( Exception e ) {
e.printStackTrace();
e.printStackTrace();
} finally {
if( sis != null ) sis.close();
if( sos != null ) sos.close();
@@ -644,16 +668,16 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
// 초기화
DataSourceContextHolder.setDataSourceType(DataSourceTypeManager.getDataSourceType(schema));
try {
try {
// // 요청 전문
sis = request.getInputStream();
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis));
sis = request.getInputStream();
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis, "EUC-KR"));
// JJB 향후제거 shkim 2020-05-13 연계 테스트 체크
logger.error("\n\n MMI SYNC Request : " + json.toString());
// log 기록
// log 기록
byte[] arg = new byte[request.getContentLength()];
int resultSet =0;
int total = 0;
@@ -663,10 +687,10 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
total += resultSet;
resultSet = sis.readLine(arg, total, 1024);
}
param.put("recvData", new String(arg));
param.put("recvData", new String(arg, "EUC-KR"));
} catch(Exception e) {
logger.error("MessageSync.err - don't read the JSON File - " + new String(arg), e);
logger.error("MessageSync.err - don't read the JSON File - " + new String(arg, "EUC-KR"), e);
param.put("recvData", "");
}
@@ -707,10 +731,11 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null;
try {
response.setContentType("application/json; charset=EUC-KR");
sos = response.getOutputStream();
sos.write(resultS.toString().getBytes());
sos.write(resultS.toString().getBytes("EUC-KR"));
} catch( Exception e ) {
e.printStackTrace();
e.printStackTrace();
} finally {
if( sis != null ) sis.close();
if( sos != null ) sos.close();
@@ -0,0 +1,11 @@
package com.eactive.eai.rms.onl.manage.rule.layoutsync;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
public class UseSystemException extends EMSRuntimeException {
public UseSystemException(String message) {
super(message);
}
}
@@ -10,9 +10,11 @@ import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +41,6 @@ public class DailyToMonthlyAggregationJob implements Job {
private ApiStatsDayService apiStatsDayService;
private ApiStatsMonthService apiStatsMonthService;
private DailyToMonthlyAggregationJob self;
@Autowired
public void setApiStatsDayService(ApiStatsDayService apiStatsDayService) {
@@ -51,18 +52,24 @@ public class DailyToMonthlyAggregationJob implements Job {
this.apiStatsMonthService = apiStatsMonthService;
}
@Autowired
public void setSelf(DailyToMonthlyAggregationJob self) {
this.self = self;
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final DailyToMonthlyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(DailyToMonthlyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType);
try {
YearMonth targetMonth = YearMonth.now().minusMonths(1);
self.executeManual(targetMonth);
selfJob.executeManual(targetMonth);
} catch (Exception e) {
throw new JobExecutionException(e);
} finally {
@@ -9,9 +9,11 @@ import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -38,7 +40,6 @@ public class HourlyToDailyAggregationJob implements Job {
private ApiStatsHourService apiStatsHourService;
private ApiStatsDayService apiStatsDayService;
private HourlyToDailyAggregationJob self;
@Autowired
public void setApiStatsHourService(ApiStatsHourService apiStatsHourService) {
@@ -50,18 +51,23 @@ public class HourlyToDailyAggregationJob implements Job {
this.apiStatsDayService = apiStatsDayService;
}
@Autowired
public void setSelf(HourlyToDailyAggregationJob self) {
this.self = self;
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final HourlyToDailyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(HourlyToDailyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType);
try {
LocalDate targetDate = LocalDate.now().minusDays(1);
self.executeManual(targetDate);
selfJob.executeManual(targetDate);
} catch (Exception e) {
throw new JobExecutionException(e);
} finally {
@@ -8,9 +8,11 @@ import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -37,7 +39,6 @@ public class MonthlyToYearlyAggregationJob implements Job {
private ApiStatsMonthService apiStatsMonthService;
private ApiStatsYearService apiStatsYearService;
private MonthlyToYearlyAggregationJob self;
@Autowired
public void setApiStatsMonthService(ApiStatsMonthService apiStatsMonthService) {
@@ -49,18 +50,24 @@ public class MonthlyToYearlyAggregationJob implements Job {
this.apiStatsYearService = apiStatsYearService;
}
@Autowired
public void setSelf(MonthlyToYearlyAggregationJob self) {
this.self = self;
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final MonthlyToYearlyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(MonthlyToYearlyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType);
try {
Year targetYear = Year.now().minusYears(1);
self.executeManual(targetYear);
selfJob.executeManual(targetYear);
} catch (Exception e) {
throw new JobExecutionException(e);
} finally {
@@ -9,6 +9,8 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.*;
/**
@@ -37,9 +39,9 @@ class LayoutSyncControllerTest {
String url = BASE_URL + "?cmd=Message&schema=APIGW";
// HTTP 헤더 설정
// HTTP 헤더 설정 (EUC-KR)
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
headers.setContentType(new MediaType("application", "xml", Charset.forName("EUC-KR")));
// 요청 생성
HttpEntity<String> request = new HttpEntity<>(requestXml, headers);