fix: yml 설정 적용

EgovYmlProperties fix
     -> override 오류 fix
main
Jonguk. Lim 12 months ago
parent 575274edd7
commit 3651d681c3

@ -1,14 +1,12 @@
package egovframework.com.cmm.service; package com.xit.core.config.support;
import lombok.extern.slf4j.Slf4j; import java.io.*;
import org.yaml.snakeyaml.Yaml; import java.util.*;
import java.io.InputStream; import org.yaml.snakeyaml.*;
import java.util.ArrayList;
import java.util.HashMap; import egovframework.com.cmm.service.*;
import java.util.List; import lombok.extern.slf4j.*;
import java.util.Map;
import java.util.Objects;
@Slf4j @Slf4j
public class EgovYmlProperties { public class EgovYmlProperties {
@ -28,8 +26,8 @@ public class EgovYmlProperties {
* @return String * @return String
*/ */
public static String getProperty(String keyName) { public static String getProperty(String keyName) {
try (InputStream baseInputStream = EgovProperties.class.getClassLoader().getResourceAsStream(GLOBALS_YAML_FILE); try (InputStream baseInputStream = EgovYmlProperties.class.getClassLoader().getResourceAsStream(GLOBALS_YAML_FILE);
InputStream profileInputStream = EgovProperties.class.getClassLoader().getResourceAsStream(getProfileYamlFile())) { InputStream profileInputStream = EgovYmlProperties.class.getClassLoader().getResourceAsStream(getProfileYamlFile())) {
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
@ -39,7 +37,7 @@ public class EgovYmlProperties {
// 프로파일별 YAML 읽기 (override) // 프로파일별 YAML 읽기 (override)
if (profileInputStream != null) { if (profileInputStream != null) {
Map<String, Object> profileMap = yaml.load(profileInputStream); Map<String, Object> profileMap = yaml.load(profileInputStream);
yamlMap.putAll(profileMap); yamlMap = mergeYamlMaps(yamlMap, profileMap);
} }
return getValueFromYamlMap(yamlMap, keyName); return getValueFromYamlMap(yamlMap, keyName);
@ -76,18 +74,18 @@ public class EgovYmlProperties {
public static List<Map<String, String>> loadYamlFile() { public static List<Map<String, String>> loadYamlFile() {
List<Map<String, String>> keyList = new ArrayList<>(); List<Map<String, String>> keyList = new ArrayList<>();
try (InputStream baseInputStream = EgovProperties.class.getClassLoader().getResourceAsStream(GLOBALS_YAML_FILE); try (InputStream baseInputStream = EgovYmlProperties.class.getClassLoader().getResourceAsStream(GLOBALS_YAML_FILE);
InputStream profileInputStream = EgovProperties.class.getClassLoader().getResourceAsStream(getProfileYamlFile())) { InputStream profileInputStream = EgovYmlProperties.class.getClassLoader().getResourceAsStream(getProfileYamlFile())) {
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
// 기본 YAML 읽기 // 기본 YAML 읽기
Map<String, Object> yamlMap = baseInputStream != null ? yaml.load(baseInputStream) : new HashMap<>(); Map<String, Object> yamlMap = baseInputStream != null ? yaml.load(baseInputStream) : new HashMap<>();
// 프로파일별 YAML 읽기 (override) // 프로파일별 YAML 읽기 (override)
if (profileInputStream != null) { if (profileInputStream != null) {
Map<String, Object> profileMap = yaml.load(profileInputStream); Map<String, Object> profileMap = yaml.load(profileInputStream);
yamlMap.putAll(profileMap); yamlMap = mergeYamlMaps(yamlMap, profileMap);
} }
flattenYamlMap(yamlMap, "", keyList); flattenYamlMap(yamlMap, "", keyList);
@ -98,6 +96,33 @@ public class EgovYmlProperties {
return keyList; return keyList;
} }
/**
* YAML . , profileMap override.
* @param baseMap YAML
* @param profileMap YAML
* @return
*/
@SuppressWarnings("unchecked")
private static Map<String, Object> mergeYamlMaps(Map<String, Object> baseMap, Map<String, Object> profileMap) {
if (baseMap == null) return profileMap;
if (profileMap == null) return baseMap;
for (Map.Entry<String, Object> entry : profileMap.entrySet()) {
String key = entry.getKey();
Object profileValue = entry.getValue();
if (baseMap.containsKey(key) && baseMap.get(key) instanceof Map && profileValue instanceof Map) {
// 중첩된 Map 병합
baseMap.put(key, mergeYamlMaps((Map<String, Object>) baseMap.get(key), (Map<String, Object>) profileValue));
} else {
// 기본값 덮어쓰기
baseMap.put(key, profileValue);
}
}
return baseMap;
}
/** /**
* YAML key-value . * YAML key-value .
* @param yamlMap Map<String, Object> * @param yamlMap Map<String, Object>

@ -4,7 +4,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import com.xit.core.config.support.EgovYmlProperties;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
@ -18,13 +18,12 @@ import org.springframework.core.io.support.ResourcePatternUtils;
import egovframework.com.cmm.EgovWebUtil; import egovframework.com.cmm.EgovWebUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.util.Properties;
/** /**
* <pre>
* Class Name : EgovProperties.java * Class Name : EgovProperties.java
* Description : properties Globals * Description : properties Globals
* . * .
* @deprecated 4.3 xit-egov yaml spring.profiles.active {@link EgovYmlProperties}
* Modification Information * Modification Information
* *
* *
@ -37,9 +36,10 @@ import lombok.extern.slf4j.Slf4j;
* @since 2009. 01. 19 * @since 2009. 01. 19
* @version 1.0 * @version 1.0
* @see * @see
* * </pre>
*/ */
@Deprecated
@Slf4j @Slf4j
public class EgovProperties { public class EgovProperties {

@ -18,7 +18,7 @@ package egovframework.com.cmm.service;
public class Globals { public class Globals {
//Client정보 프로퍼티 위치 //Client정보 프로퍼티 위치
//public static final String CLIENT_CONF_PATH = EgovProperties.getPathProperty("Globals.ClientConfPath"); //public static final String CLIENT_CONF_PATH = EgovYmlProperties.getProperty("Globals.ClientConfPath");
//파일 업로드 원 파일명 //파일 업로드 원 파일명
public static final String ORIGIN_FILE_NM = "originalFileName"; public static final String ORIGIN_FILE_NM = "originalFileName";

@ -21,6 +21,8 @@ import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.xit.core.config.support.*;
import egovframework.com.cmm.EgovWebUtil; import egovframework.com.cmm.EgovWebUtil;
import egovframework.com.cmm.service.EgovFileMngService; import egovframework.com.cmm.service.EgovFileMngService;
import egovframework.com.cmm.service.EgovProperties; import egovframework.com.cmm.service.EgovProperties;
@ -65,7 +67,7 @@ public class EgovFileDownloadController {
@Resource(name="egovARIACryptoService") @Resource(name="egovARIACryptoService")
EgovCryptoService cryptoService; EgovCryptoService cryptoService;
public static final String ALGORITM_KEY = EgovProperties.getProperty("Globals.crypto.algoritm"); public static final String ALGORITM_KEY = EgovYmlProperties.getProperty("Globals.crypto.algoritm");
/** /**
* . * .

@ -31,6 +31,8 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import com.xit.core.config.support.*;
import egovframework.com.cmm.service.EgovProperties; import egovframework.com.cmm.service.EgovProperties;
import egovframework.let.utl.fcc.service.EgovFileUploadUtil; import egovframework.let.utl.fcc.service.EgovFileUploadUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -79,7 +81,7 @@ public class EgovMultipartResolver extends CommonsMultipartResolver {
// 스프링 3.0변경으로 수정한 부분 // 스프링 3.0변경으로 수정한 부분
MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>();
Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); Map<String, String[]> multipartParameters = new HashMap<String, String[]>();
String whiteListFileUploadExtensions = EgovProperties.getProperty("Globals.fileUpload.Extensions"); String whiteListFileUploadExtensions = EgovYmlProperties.getProperty("Globals.fileUpload.Extensions");
Map<String, String> mpParamContentTypes = new HashMap<String, String>(); Map<String, String> mpParamContentTypes = new HashMap<String, String>();
// Extract multipart files and multipart parameters. // Extract multipart files and multipart parameters.

@ -3,6 +3,8 @@ package egovframework.com.config;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
import com.xit.core.config.support.*;
import egovframework.com.cmm.service.EgovProperties; import egovframework.com.cmm.service.EgovProperties;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -31,7 +33,7 @@ public class EgovWebServletContextListener implements ServletContextListener {
try { try {
log.debug("===========================Start EgovServletContextLoad START ==========="); log.debug("===========================Start EgovServletContextLoad START ===========");
System.setProperty("spring.profiles.active", System.setProperty("spring.profiles.active",
EgovProperties.getProperty("Globals.DbType") + "," + EgovProperties.getProperty("Globals.Auth")); EgovYmlProperties.getProperty("Globals.DbType") + "," + EgovYmlProperties.getProperty("Globals.Auth"));
log.debug("Setting spring.profiles.active>" + System.getProperty("spring.profiles.active")); log.debug("Setting spring.profiles.active>" + System.getProperty("spring.profiles.active"));
log.debug("===========================END EgovServletContextLoad END ==========="); log.debug("===========================END EgovServletContextLoad END ===========");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

@ -7,6 +7,8 @@ import java.util.Map;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.xit.core.config.support.*;
import egovframework.com.cmm.LoginVO; import egovframework.com.cmm.LoginVO;
import egovframework.com.cmm.service.EgovProperties; import egovframework.com.cmm.service.EgovProperties;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
@ -23,7 +25,7 @@ public class EgovJwtTokenUtil implements Serializable{
//public static final long JWT_TOKEN_VALIDITY = 24 * 60 * 60; //하루 //public static final long JWT_TOKEN_VALIDITY = 24 * 60 * 60; //하루
public static final long JWT_TOKEN_VALIDITY = (long) ((1 * 60 * 60) / 60) * 60; //토큰의 유효시간 설정, 기본 60분 public static final long JWT_TOKEN_VALIDITY = (long) ((1 * 60 * 60) / 60) * 60; //토큰의 유효시간 설정, 기본 60분
public static final String SECRET_KEY = EgovProperties.getProperty("Globals.jwt.secret"); public static final String SECRET_KEY = EgovYmlProperties.getProperty("Globals.jwt.secret");
//retrieve username from jwt token //retrieve username from jwt token
public String getUserIdFromToken(String token) { public String getUserIdFromToken(String token) {

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.xit.core.config.support.*;
import egovframework.com.cmm.EgovMessageSource; import egovframework.com.cmm.EgovMessageSource;
import egovframework.com.cmm.LoginVO; import egovframework.com.cmm.LoginVO;
@ -63,11 +64,11 @@ public class SnsLoginApiController {
@Resource(name = "egovJwtTokenUtil") @Resource(name = "egovJwtTokenUtil")
private EgovJwtTokenUtil jwtTokenUtil; private EgovJwtTokenUtil jwtTokenUtil;
/** SNS */ /** SNS */
public static final String NAVER_CLIENT_ID = EgovProperties.getProperty("Sns.naver.clientId"); public static final String NAVER_CLIENT_ID = EgovYmlProperties.getProperty("Sns.naver.clientId");
public static final String NAVER_CLIENT_SECRET = EgovProperties.getProperty("Sns.naver.clientSecret"); public static final String NAVER_CLIENT_SECRET = EgovYmlProperties.getProperty("Sns.naver.clientSecret");
public static final String NAVER_CALLBACK_URL = EgovProperties.getProperty("Sns.naver.callbackUrl"); public static final String NAVER_CALLBACK_URL = EgovYmlProperties.getProperty("Sns.naver.callbackUrl");
public static final String KAKAO_CLIENT_ID = EgovProperties.getProperty("Sns.kakao.clientId"); public static final String KAKAO_CLIENT_ID = EgovYmlProperties.getProperty("Sns.kakao.clientId");
public static final String KAKAO_CALLBACK_URL = EgovProperties.getProperty("Sns.kakao.callbackUrl"); public static final String KAKAO_CALLBACK_URL = EgovYmlProperties.getProperty("Sns.kakao.callbackUrl");
/** /**
* API * API

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*; import org.springframework.web.servlet.*;
import com.xit.*; import com.xit.*;
import com.xit.core.config.support.*;
import egovframework.com.cmm.*; import egovframework.com.cmm.*;
import egovframework.com.cmm.config.*; import egovframework.com.cmm.config.*;
@ -130,9 +131,8 @@ public class EgovLoginController {
*/ */
// 2021.05.30, 정진오, 디지털원패스 처리하기 위해 로그인 화면에 인증방식 전달 // 2021.05.30, 정진오, 디지털원패스 처리하기 위해 로그인 화면에 인증방식 전달
String authType = EgovProperties.getProperty("Globals.Auth").trim(); String authType = EgovYmlProperties.getProperty("Globals.Auth").trim();
model.addAttribute("authType", authType); model.addAttribute("authType", authType);
String message = (String)request.getParameter("loginMessage"); String message = (String)request.getParameter("loginMessage");
if (message!=null) model.addAttribute("loginMessage", message); if (message!=null) model.addAttribute("loginMessage", message);

@ -20,6 +20,8 @@ import javax.servlet.http.*;
import org.springframework.web.context.request.*; import org.springframework.web.context.request.*;
import com.xit.core.config.support.*;
import egovframework.com.cmm.service.*; import egovframework.com.cmm.service.*;
public class EgovClntInfo { public class EgovClntInfo {
@ -76,8 +78,8 @@ public class EgovClntInfo {
String user_agent = request.getHeader("user-agent"); String user_agent = request.getHeader("user-agent");
String os_info = user_agent.toUpperCase().split(";")[2].split("\\)")[0]; String os_info = user_agent.toUpperCase().split(";")[2].split("\\)")[0];
//String os_conf = EgovProperties.getProperty(Globals.CLIENT_CONF_PATH, os_info.replaceAll(" ", "")); //String os_conf = EgovYmlProperties.getProperty(Globals.CLIENT_CONF_PATH, os_info.replaceAll(" ", ""));
String os_conf = EgovProperties.getProperty("Globals.CLIENT_CONF_PATH"); String os_conf = EgovYmlProperties.getProperty("Globals.CLIENT_CONF_PATH");
String osInfo = ""; String osInfo = "";
if (os_conf != null && !"".equals(os_conf)) { if (os_conf != null && !"".equals(os_conf)) {
osInfo = os_conf; osInfo = os_conf;

Loading…
Cancel
Save