Merge remote-tracking branch 'origin/jenkins_with_weblogic' of C:/eactive/workspaces/eapim-bundle/bundles/251111/eapim-admin_incremental_2025-08-01.bundle into jenkins_with_weblogic

This commit is contained in:
Rinjae
2025-11-11 09:58:43 +09:00
18 changed files with 291 additions and 223 deletions
@@ -37,11 +37,9 @@ public class CrossScriptingFilter implements Filter {
String uri = request.getRequestURL().toString();
String servletPath = request.getServletPath();
String baseUrl = uri.replace(servletPath, "");
boolean isValidUrl = returnUrl.startsWith(baseUrl);
// System.out.println("checkReturnUrl => "+ uri + " : "+ servletPath);
// System.out.println("checkReturnUrl => "+ baseUrl + " : "+ returnUrl);
// System.out.println("checkReturnUrl => "+ returnUrl + " : "+ isValidUrl);
return isValidUrl;
// 25.11.10 - weblogic https://host:443/ 문제 대응
baseUrl = baseUrl.replace(":443", "");
return returnUrl.startsWith(baseUrl);
}
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
@@ -52,7 +50,6 @@ public class CrossScriptingFilter implements Filter {
String returnUrl = (String)request.getParameter("returnUrl");
if(returnUrl != null) {
if(!checkReturnUrl(request, returnUrl)) {
System.out.println("CrossScriptingFilter] bad request. - " + returnUrl);
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "bad request. - "+returnUrl);
return;
}
@@ -52,7 +52,7 @@ public class JobHistoryService extends AbstractEMSDataSerivce<JobHistory, String
String rctStatus = findRecentStatus(jobName, instanceName); // 최근 Data 조회
log.info("[DHJEONG]1_rctStatus-->{}, jobName-->{}, instanceName-->{}", rctStatus, jobName, instanceName);
// log.info("[DHJEONG]1_rctStatus-->{}, jobName-->{}, instanceName-->{}", rctStatus, jobName, instanceName);
if (!status.equals(rctStatus) || !"E".equals(jobInfo.getChkStatus())) {
// 'Y' 이면 무조건 등록, 'E' 이면 ==> Status 바뀌면 등록
@@ -5,9 +5,11 @@ import com.eactive.apim.portal.file.entity.FileInfo;
import com.eactive.apim.portal.file.service.FileService;
import com.eactive.apim.portal.file.service.FileTypeContext;
import com.eactive.apim.portal.portalNotice.entity.PortalNotice;
import com.eactive.eai.common.util.ContainerUtil;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeService;
import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeUISearch;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,19 +20,28 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@Slf4j
public class PortalNoticeManService extends BaseService {
private final PortalNoticeService portalNoticeService;
private final PortalNoticeUIMapper portalNoticeUIMapper;
private final FileService fileService;
private final FileService fileService;
private String decodeString(String value) {
// return new String(value.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
if (ContainerUtil.get() == ContainerUtil.TOMCAT) {
try {
return new String(value.getBytes("euc-kr"), StandardCharsets.UTF_8);
} catch (UnsupportedEncodingException e) {
log.warn("Failed euc-kr to UTF-8", e);
return value;
}
}
return new String(value.getBytes(Charset.defaultCharset()), StandardCharsets.UTF_8);
}
@@ -102,7 +113,7 @@ public class PortalNoticeManService extends BaseService {
if (file != null && !file.isEmpty()) { // 새로운 파일이 업로드된 경우에만 처리
String decodedFileName = decodeString(portalNoticeUI.getFileName());
FileTypeContext.setFileType("notice");
FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName);
FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName, true);
if (fileInfo != null) {
portalNotice.setFileId(fileInfo.getFileId());
@@ -50,4 +50,5 @@ public class PortalUserUI {
@DateTimeFormat(pattern = "yyyyMMddHHmmss")
private LocalDateTime lastModifiedDate;
private String accountLockYn;
}
@@ -2,11 +2,16 @@ package com.eactive.eai.rms.onl.common.service;
import com.eactive.eai.rms.onl.common.service.ums.UmsDispatchService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Admin Job Configuration
* ----------------------
@@ -17,17 +22,37 @@ import org.springframework.beans.factory.annotation.Autowired;
// Cron Expression: */5 * * * * ?
@Slf4j
public class UmsDispatchJob implements Job {
private final UmsDispatchService umsDispatchService;
@Autowired
public UmsDispatchJob(UmsDispatchService umsDispatchService) {
this.umsDispatchService = umsDispatchService;
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
log.info("Starting Message Dispatch Job...");
// inst.Name 이 지정된 경우 해당 인스턴스에서만 동작
String jobInstName = context.getJobDetail().getJobDataMap().getString("execute.instances");
if (StringUtils.isNotEmpty(jobInstName)) {
log.debug("Job 실행 인스턴스 명이 지정되어 있음 - {}", jobInstName);
jobInstName = jobInstName.toLowerCase();
Set<String> propInstances = Arrays.stream(jobInstName.split(",")).map(String::trim).collect(Collectors.toSet());
String instanceName = System.getProperty("inst.Name");
if (StringUtils.isNotEmpty(instanceName)) {
log.debug("현재 인스턴스 명 : {}", instanceName);
instanceName = instanceName.trim().toLowerCase();
if (!propInstances.contains(instanceName)) {
log.debug("Job 인스턴스명과 현재 인스턴스명이 다름. 종료 처리");
return;
}
}
}
try {
umsDispatchService.processMessages();
} catch (Exception e) {
@@ -1,8 +1,12 @@
package com.eactive.eai.rms.onl.common.service.ums;
import com.eactive.apim.portal.template.entity.MessageRequest;
import edu.emory.mathcs.backport.java.util.Collections;
import com.eactive.apim.portal.template.repository.MessageRequestRepository;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import com.eactive.ext.kjb.common.KjbProperty;
import com.eactive.ext.kjb.ums.KjbEmailSendModule;
import com.eactive.ext.kjb.ums.KjbUmsService;
import com.eactive.ext.kjb.util.KjbPropertyInjector;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -15,15 +19,17 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
public class UmsDispatchService {
public static final String PROP_GORUP_ID = "Monitoring";
private final ThreadPoolExecutor executorService;
private final TransactionTemplate transactionTemplate;
@@ -36,15 +42,25 @@ public class UmsDispatchService {
@PersistenceContext(unitName = "entityManagerFactoryForEMS")
private EntityManager entityManager;
@Autowired
private UmsSender umsSender;
private final MessageRequestRepository messageRequestRepository;
private final KjbUmsService kjbUmsService;
private final KjbEmailSendModule kjbEmailSendModule;
private final KjbPropertyInjector kjbPropertyInjector;
@Autowired
private StandardMessageFactory messageFactory;
@Autowired
public UmsDispatchService(
@Qualifier("transactionManagerForEMS") PlatformTransactionManager transactionManager) {
@Qualifier("transactionManagerForEMS") PlatformTransactionManager transactionManager,
MonitoringPropertyService monitoringPropertyService,
MessageRequestRepository messageRequestRepository
) {
this.kjbPropertyInjector = new KjbPropertyInjector(monitoringPropertyService, PROP_GORUP_ID);
this.messageRequestRepository = messageRequestRepository;
// this.kjbEmailService = kjbEmailService;
// this.kjbSafedbWrapper = kjbSafedbWrapper;
// this.monitoringPropertyService = monitoringPropertyService;
this.executorService = new ThreadPoolExecutor(
CORE_POOL_SIZE,
MAX_POOL_SIZE,
@@ -56,6 +72,20 @@ public class UmsDispatchService {
this.transactionTemplate = new TransactionTemplate(transactionManager);
log.debug("UmsDispatchService initialized with thread pool - core: {}, max: {}, queue: {}",
CORE_POOL_SIZE, MAX_POOL_SIZE, QUEUE_CAPACITY);
KjbProperty prop = new KjbProperty();
// prop.setEaiBatchUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.url"));
// prop.setUmsEaiBatchSendDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.send_dir"));
// prop.setUmsEaiBatchBackupDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.backup_dir"));
// prop.setUmsEaiBatchInterfaceId(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.interface_id"));
// prop.setUmsHostUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.host_url"));
// prop.setUmsApiKey(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.api_key"));
prop = kjbPropertyInjector.inject(prop);
this.kjbUmsService = new KjbUmsService(prop);
this.kjbEmailSendModule = KjbEmailSendModule.getInstance(prop, messageRequestRepository);
}
@SuppressWarnings("unchecked")
@@ -98,6 +128,9 @@ public class UmsDispatchService {
}
} else {
log.info("No pending messages found");
// 발송 메세지가 없을 때 파일 삭제 처리 진행
}
}
@@ -110,7 +143,17 @@ public class UmsDispatchService {
try {
transactionTemplate.execute(status -> {
try {
processMessage(message);
// 광주은행에서는 사용하지 않는 메소드
// processMessage(message);
if (KjbUmsService.isAllowChannel(message)) {
kjbUmsService.send(message);
}
if (KjbEmailSendModule.isAllowChannel(message)) {
kjbEmailSendModule.sendEmail(message);
}
return null;
} catch (Exception e) {
log.error("Failed to process message: {} - Error: {}",
@@ -127,21 +170,27 @@ public class UmsDispatchService {
});
}
public void processMessage(MessageRequest message) throws IOException {
try {
String standardMessage = messageFactory.createMessage(message);
log.debug("Processing message ID: {} - Type: {}", message.getId(), message.getMessageType());
umsSender.sendMessage(standardMessage);
updateMessageStatus(message, "SENT");
log.debug("Successfully processed and sent message ID: {}", message.getId());
} catch (Exception e) {
log.error("Message processing failed for ID: {} - Error: {}",
message.getId(), e.getMessage(), e);
updateMessageStatus(message, "FAILED");
throw e;
}
}
/**
* kbank 방식으로 광주은행에서는 사용하지 않음
* @param message
* @throws IOException
*/
// @Deprecated
// public void processMessage(MessageRequest message) throws IOException {
// try {
// String standardMessage = messageFactory.createMessage(message);
// log.debug("Processing message ID: {} - Type: {}", message.getId(), message.getMessageType());
//
// umsSender.sendMessage(standardMessage);
// updateMessageStatus(message, "SENT");
// log.debug("Successfully processed and sent message ID: {}", message.getId());
// } catch (Exception e) {
// log.error("Message processing failed for ID: {} - Error: {}",
// message.getId(), e.getMessage(), e);
// updateMessageStatus(message, "FAILED");
// throw e;
// }
// }
public void updateMessageStatus(MessageRequest message, String status) {
message.setRequestStatus(status);
@@ -16,8 +16,12 @@ import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* 25.11.05 - 광주은행 미사용 클래스
*/
@Slf4j
@Component
@Deprecated
public class UmsSender {
private final MonitoringPropertyService monitoringPropertyService;
@@ -1,125 +0,0 @@
package com.eactive.ext.kjb.ums;
import com.eactive.apim.portal.template.entity.MessageRequest;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import com.eactive.ext.kjb.common.KjbProperty;
import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@Slf4j
public class KjbUmsService extends BaseService {
public static final String PROP_GORUP_ID = "Monitoring";
public static final String PROP_EAI_BATCH_URL = "kjb.ums.eai_batch.url";
public static final String PROP_EAI_BATCH_SEND_DIR = "kjb.ums.eai_batch.send_dir";
private final KjbSafedbWrapper kjbSafedbWrapper;
private final KjbProperty prop;
@Autowired
public KjbUmsService(KjbSafedbWrapper kjbSafedbWrapper,
MonitoringPropertyService monitoringPropertyService) {
this.kjbSafedbWrapper = kjbSafedbWrapper;
KjbProperty prop = new KjbProperty();
prop.setEaiBatchUrl(monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_URL, ""));
prop.setEaiBatchSendDir(monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR, "/Data/files/send"));
this.prop = prop;
}
public KjbUmsService(KjbSafedbWrapper kjbSafedbWrapper,
KjbProperty property) {
this.kjbSafedbWrapper = kjbSafedbWrapper;
this.prop = property;
init();
}
private void init() {
if (prop.getEaiBatchUrl().isEmpty()) {
log.warn("{} 가 설정되지 않음. 실제 EAI 배치 연동 없이 동작함", PROP_EAI_BATCH_URL);
}
log.info("EAI Batch URL: {}", prop.getEaiBatchUrl());
log.info("EAI Batch Send Dir: {}", prop.getEaiBatchSendDir());
// 디렉토리 검사(쓰기 권한 포함)
Path sendDirPath = Paths.get(prop.getEaiBatchSendDir());
if (!sendDirPath.toFile().exists()) {
// 생성 시도
boolean created = sendDirPath.toFile().mkdirs();
if (!created) {
log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", prop.getEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + prop.getEaiBatchSendDir());
}
}
if (!sendDirPath.toFile().isDirectory()) {
log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", prop.getEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + prop.getEaiBatchSendDir());
}
if (!sendDirPath.toFile().canWrite()) {
log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", prop.getEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + prop.getEaiBatchSendDir());
}
}
public void sendEmail(MessageRequest messageRequest) {
log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", prop.getEaiBatchUrl(), prop.getEaiBatchSendDir());
log.debug("MessageRequest ID: {}, Email: {}", messageRequest.getId(), messageRequest.getEmail());
if (StringUtils.isEmpty(messageRequest.getId())) {
log.warn("MessageRequest ID is empty");
throw new IllegalArgumentException("MessageRequest ID is required");
}
if (StringUtils.isEmpty(messageRequest.getEmail())) {
log.warn("MessageRequest Email is empty for ID: {}", messageRequest.getId());
throw new IllegalArgumentException("MessageRequest Email is required for ID: " + messageRequest.getId());
}
String filename = "EMAIL_" + messageRequest.getId() + ".json";
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("EMAIL", kjbSafedbWrapper.encryptNotRnnoString(messageRequest.getEmail()));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonString = gson.toJson(jsonObject);
byte[] jsonBytes = null;
try {
jsonBytes = jsonString.getBytes("euc-kr");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
log.debug("Generated JSON({} bytes): {}", jsonBytes.length, jsonString);
log.debug("euc-kr first 10 bytes: {}...", Arrays.toString(Arrays.copyOfRange(jsonBytes, 0, 10)));
}
}
@@ -0,0 +1,62 @@
package com.eactive.ext.kjb.util;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import com.eactive.ext.kjb.common.KjbProperty;
import com.eactive.ext.kjb.common.KjbPropertyValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
@Slf4j
public class KjbPropertyInjector {
private final MonitoringPropertyService monitoringPropertyService;
private final String groupId;
public KjbPropertyInjector(MonitoringPropertyService monitoringPropertyService, String groupId) {
this.monitoringPropertyService = monitoringPropertyService;
this.groupId = groupId;
}
public <T> T inject(T property) {
Class<?> clazz = property.getClass();
for (Field field : clazz.getDeclaredFields()) {
KjbPropertyValue anno = field.getAnnotation(KjbPropertyValue.class);
if (anno != null) {
String key = anno.key();
String rawValue = monitoringPropertyService.getPropertyValue(groupId, key, anno.defaultValue());
Object convertedValue = convertValue(field.getType(), rawValue);
field.setAccessible(true);
try {
field.set(property, convertedValue);
} catch (IllegalAccessException e) {
log.error("Failed to inject property: {} - {}", field.getName(), key, e);
throw new RuntimeException(e);
}
}
}
return property;
}
private static Object convertValue(Class<?> type, String rawValue) {
if (rawValue == null) return null;
if (StringUtils.isEmpty(rawValue)) return "";
if (type == String.class) return rawValue;
if (type == Integer.class || type == int.class) return Integer.valueOf(rawValue);
if (type == Long.class || type == long.class) return Long.valueOf(rawValue);
if (type == Double.class || type == double.class) return Double.valueOf(rawValue);
if (type == Boolean.class || type == boolean.class) return Boolean.valueOf(rawValue);
if (type == Float.class || type == float.class) return Float.valueOf(rawValue);
if (type == Short.class || type == short.class) return Short.valueOf(rawValue);
if (type == Byte.class || type == byte.class) return Byte.valueOf(rawValue);
return rawValue;
}
}