ums 연동 대응

This commit is contained in:
Rinjae
2025-10-17 19:28:09 +09:00
parent 604d7975f6
commit 423af16926
7 changed files with 159 additions and 94 deletions
+4 -1
View File
@@ -239,4 +239,7 @@ gradle-app.setting
Doc/
docs
build-gf63.sh
gradle-gf63.sh
gradle-gf63.sh
eapim-admin-kjb/
+1
View File
@@ -77,6 +77,7 @@ dependencies {
implementation project(':elink-online-emsclient')
implementation project(':elink-portal-common')
implementation project(':kjb-safedb')
implementation project(":eapim-admin-kjb")
/* Custom Libs */
implementation fileTree(dir: 'libs', include: ['*.jar'])
+10 -7
View File
@@ -7,13 +7,16 @@ include 'elink-online-common'
include 'elink-online-emsclient'
include 'elink-portal-common'
project (':elink-online-core-jpa').projectDir = new File(settingsDir, "../eapim-online/elink-online-core-jpa")
project (':elink-online-core').projectDir = new File(settingsDir, "../eapim-online/elink-online-core")
project (':elink-online-transformer').projectDir = new File(settingsDir, "../eapim-online/elink-online-transformer")
project (':elink-online-common').projectDir = new File(settingsDir, "../eapim-online/elink-online-common")
project (':elink-online-emsclient').projectDir = new File(settingsDir, "../eapim-online/elink-online-emsclient")
project (':elink-portal-common').projectDir = new File(settingsDir, "../elink-portal-common")
project(':elink-online-core-jpa').projectDir = new File(settingsDir, "../eapim-online/elink-online-core-jpa")
project(':elink-online-core').projectDir = new File(settingsDir, "../eapim-online/elink-online-core")
project(':elink-online-transformer').projectDir = new File(settingsDir, "../eapim-online/elink-online-transformer")
project(':elink-online-common').projectDir = new File(settingsDir, "../eapim-online/elink-online-common")
project(':elink-online-emsclient').projectDir = new File(settingsDir, "../eapim-online/elink-online-emsclient")
project(':elink-portal-common').projectDir = new File(settingsDir, "../elink-portal-common")
include 'kjb-safedb'
project (':kjb-safedb').projectDir = new File(settingsDir, "../kjb-safedb")
project(':kjb-safedb').projectDir = new File(settingsDir, "../kjb-safedb")
include 'eapim-admin-kjb'
project(':eapim-admin-kjb').projectDir = new File(settingsDir, "eapim-admin-kjb")
@@ -0,0 +1,19 @@
package com.eactive.eai.custom.kjb.spring;
import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
import org.springframework.security.crypto.password.PasswordEncoder;
public class KjbSafedbPasswordEncoder implements PasswordEncoder {
@Override
public String encode(CharSequence rawPassword) {
KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
return safedb.encryptPassword(rawPassword.toString());
}
@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
String encoded = safedb.encryptPassword(rawPassword.toString());
return encoded.equals(encodedPassword);
}
}
@@ -1,85 +0,0 @@
package com.eactive.eai.custom.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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.nio.file.Path;
import java.nio.file.Paths;
@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 MonitoringPropertyService monitoringPropertyService;
private final String EAI_BATCH_URL;
private final String EAI_BATCH_SEND_DIR;
private KjbUmsService(MonitoringPropertyService monitoringPropertyService) {
this.monitoringPropertyService = monitoringPropertyService;
// 파라미터 검사
this.EAI_BATCH_URL = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_URL, "");
this.EAI_BATCH_SEND_DIR = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR, "/Data/eapim/portal/sendmail");
if (EAI_BATCH_URL.isEmpty()) {
log.warn("{} 가 설정되지 않음. 실제 EAI 배치 연동 없이 동작함", PROP_EAI_BATCH_URL);
}
log.info("EAI Batch URL: {}", EAI_BATCH_URL);
log.info("EAI Batch Send Dir: {}", EAI_BATCH_SEND_DIR);
// 디렉토리 검사(쓰기 권한 포함)
Path sendDirPath = Paths.get(EAI_BATCH_SEND_DIR);
if (!sendDirPath.toFile().exists()) {
// 생성 시도
boolean created = sendDirPath.toFile().mkdirs();
if (!created) {
log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + EAI_BATCH_SEND_DIR);
}
}
if (!sendDirPath.toFile().isDirectory()) {
log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + EAI_BATCH_SEND_DIR);
}
if (!sendDirPath.toFile().canWrite()) {
log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + EAI_BATCH_SEND_DIR);
}
}
public void sendEmail(MessageRequest messageRequest) {
log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", EAI_BATCH_URL, EAI_BATCH_SEND_DIR);
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");
}
String filename = "EMAIL_" + messageRequest.getId() + ".json";
JSONObject jsonObject = new JSONObject();
jsonObject.put("to", messageRequest.getEmail());
}
}
@@ -1,6 +1,5 @@
package com.eactive.eai.rms.onl.apim.template;
import com.eactive.apim.portal.template.entity.MessageCode;
import com.eactive.apim.portal.template.entity.MessageTemplate;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.template.MessageTemplateSearch;
@@ -0,0 +1,125 @@
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)));
}
}