This commit is contained in:
Rinjae
2025-09-05 17:16:26 +09:00
commit c54ef1903f
4947 changed files with 817291 additions and 0 deletions
@@ -0,0 +1,184 @@
package com.eactive.eai.rms.onl.adapter;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.log4j.Logger;
/**
* <pre>
* 1. 기능 : 시스템상의 해당명령을 수행하여 결과를 반환한다.
* 2. 처리 개요 :
* - 시스템상의 해당명령을 수행하여 결과를 반환한다.
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.2 $
* @since : rts 1.0
*/
public abstract class AgentExecCommand {
private final Logger logger = Logger.getLogger(AgentExecCommand.class);
// YUN_DEBUG : execCommand 함수에 오류가 있어서 수정함 (2008.04.14)
// 내용 : Runtime.exec() 의 결과를 1 KByte 밖에 못얻어오는 현상.
public String execCommand(String command) {
String result = "";
Runtime rt = Runtime.getRuntime();
Process ps = null;
InputStream is = null;
byte[] buff = null;
int len;
ByteArrayOutputStream baos = null;
try {
// 명령어 수행
if (logger.isDebugEnabled()) {
logger.debug("Command Exec : " + command);
}
ps = rt.exec(command);
if (!isError(ps)) {
// 명령 수행에 문제가 없었을 경우
is = ps.getInputStream();
len = 0;
buff = new byte[4096];
baos = new ByteArrayOutputStream();
while ((len = is.read(buff)) > 0) {
baos.write(buff, 0, len);
}
result = new String(baos.toByteArray());
if (logger.isDebugEnabled()) {
logger.debug("AgentExecCommand result =" + result);
}
} // end of else
} catch (Exception e) {
// 예외 상황 발생
logger.error(e.toString());
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
baos = null;
logger.error(e.toString());
}
}
if (is != null) {
try {
is.close();
} catch (IOException e) {
is = null;
logger.error(e.toString());
}
}
if (ps != null) {
ps.destroy();
}
}
return result;
}
public String execCommand_test(String command) {
StringBuffer sb = new StringBuffer();
Runtime runtime = null;
Process process = null;
try {
runtime = Runtime.getRuntime();
process = runtime.exec(command);
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
} catch (Exception e) {
logger.error( e );
}
return sb.toString();
}
/**
* <pre>
* 1. 기능 : 명령분 수행에 대한 에러 체크
* 2. 처리 개요 :
* - 명령문 수행에 대한 에러 체크
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.2 $
* @since : rts 1.0
* @param ps
* @return
*/
private boolean isError(Process ps) {
boolean result = true;
InputStream es = ps.getErrorStream();
byte[] buff = new byte[1024];
try {
// check
if(es.available() <= 0) {
if (logger.isDebugEnabled()) {
logger.debug("isError = false");
}
return false;
}
if (es.read(buff) != -1) {
// 명령 수행에 문제가 있을 경우
String s = new String(buff);
logger.error(s);
result = true;
} else {
// 명령 수행에 문제가 없을 경우
result = false;
}
} catch (IOException e) {
result = true;
logger.error(e.toString());
} finally {
if (es != null) {
try {
es.close();
} catch (IOException e) {
es = null;
logger.error(e.toString());
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("isError = " + result);
}
return result;
}
}
@@ -0,0 +1,101 @@
package com.eactive.eai.rms.onl.adapter.common.vo;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import com.eactive.eai.rms.onl.common.vo.SearchForm;
/**
* <pre>
* 1. :
* 2. ó :
* -
* 3. ǻ :
* </pre>
* @author : ڱ⼷
* @version : $Revision: 1.3 $
* @since : rts 1.0
*/
public class ErrorContentForm
extends SearchForm {
/** log level */
private String logLevel = "TOTAL";
private String componentId = "";
/** log type */
private String logType = "WCA";
private String adapterGroupNm;
private String luGroupNm;
private String luNm;
/** @return Returns the logLevel. */
public String getLogLevel() {
return logLevel;
}
/** @param logLevel The logLevel to set. */
public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
/** @return Returns the logType. */
public String getLogType() {
if (logType == null) {
return null;
} else {
return logType.trim();
}
}
/** @param logType The logType to set. */
public void setLogType(String logType) {
this.logType = logType;
}
public String getComponentId() {
return componentId;
}
public void setComponentId(String componentId) {
this.componentId = componentId;
}
/**
* @see Object#toString()
*/
public String toString() {
return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).appendSuper(super.toString()).append("logLevel",
this.logLevel).append("componentId", this.componentId).append("logType",
this.logType).toString();
}
public String getAdapterGroupNm() {
return adapterGroupNm;
}
public void setAdapterGroupNm(String adapterGroupNm) {
this.adapterGroupNm = adapterGroupNm;
}
public String getLuGroupNm() {
return luGroupNm;
}
public void setLuGroupNm(String luGroupNm) {
this.luGroupNm = luGroupNm;
}
public String getLuNm() {
return luNm;
}
public void setLuNm(String luNm) {
this.luNm = luNm;
}
}
@@ -0,0 +1,41 @@
package com.eactive.eai.rms.onl.adapter.count;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
@Controller
public class AdapterCountRetrieveController {
@Autowired
private AdapterCountRetrieveService service;
@RequestMapping(value= "/onl/adapter/retrieve/adapterCountRetrieve.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value= "/onl/adapter/retrieve/adapterCountRetrieve.json", params = "cmd=LIST")
public ResponseEntity<List<Map<String, Object>>> list(String searchAdapterGroup, String searchInstanceName) {
List<Map<String, Object>> selectList = service.selectList(searchAdapterGroup, searchInstanceName);
return ResponseEntity.ok().body(selectList);
}
}
@@ -0,0 +1,43 @@
package com.eactive.eai.rms.onl.adapter.count;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.onl.common.service.jspcall.JspCallAgentUtilService;
@Service
public class AdapterCountRetrieveService {
@Autowired
@Qualifier("OnlJspCallAgentUtilService")
private JspCallAgentUtilService jspCallAgentUtilService;
public List<Map<String, Object>> selectList(String searchAdapterGroup, String searchInstanceName) {
Map<String,String> filter = new HashMap<String,String>();
List<Map<String, Object>> response = null;
if (StringUtils.isNotBlank(searchInstanceName)) {
response = jspCallAgentUtilService.agentCallByGetMethod("adapter_count_agent.jsp", new ArrayList<String>() {{ add(searchInstanceName); }}, new HashMap<>(), filter);
} else {
response = jspCallAgentUtilService.agentCallByGetMethod("adapter_count_agent.jsp", new HashMap<>(), filter);
}
if (StringUtils.isNotBlank(searchAdapterGroup)) {
response = response.stream().filter(row -> String.valueOf(row.get("AdptrBzwkGroupName")).contains(searchAdapterGroup)).collect(Collectors.toList());
}
return response;
}
}
@@ -0,0 +1,25 @@
package com.eactive.eai.rms.onl.adapter.http.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.spring.BaseController;
@Controller
public class HttpAdapterStatusController extends BaseController {
@RequestMapping("/adapter/http/httpAdapterStatus.do")
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
return null;
}
private void findList(HttpServletRequest request, HttpServletResponse response, Map model) throws Exception {
}
}
@@ -0,0 +1,33 @@
package com.eactive.eai.rms.onl.adapter.http.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
@Controller
public class HttpErrorContentsController extends BaseController {
private static final String AGENT_PAGE = "adapter_log_agent.jsp";
@RequestMapping("/adapter/http/errorContents.do")
public ResponseEntity<Void> handleRequest(HttpServletRequest request, HttpServletResponse response) {
ErrorContentForm form = new ErrorContentForm();
// parameter 설정
form.setEaiSvrInstNm(request.getParameter("eaiSvrInstNm"));
form.setEaiSvrIp(request.getParameter("eaiSvrIp"));
form.setEaiSvrLsnPort(request.getParameter("eaiSvrLsnPort"));
form.setAgentPage(AGENT_PAGE);
form.setSearchText(request.getParameter("searchText")); // 검색안
form.setLogLevel(request.getParameter("logLevel"));
return ResponseEntity.ok().build();
}
}
@@ -0,0 +1,76 @@
package com.eactive.eai.rms.onl.adapter.http.controller;//package com.eactive.eai.rms.onl.adapter.http.controller;
//
//import java.util.Map;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.springframework.stereotype.Controller;
//import org.springframework.validation.BindException;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.servlet.ModelAndView;
//
//import com.eactive.eai.rms.common.spring.OnlineFormController;
//import com.eactive.eai.rms.onl.common.vo.BaseForm;
//
///**
// * <pre>
// * 1. :
// * 2. ó :
// * -
// * 3. ǻ :
// * </pre>
// * @author : ڱ⼷
// * @version : $Revision: 1.2 $
// * @since : rts 1.0
// */
//@Controller
//public class HttpLogInfomationController
// extends OnlineFormController {
//
// /**
// *
// */
// public HttpLogInfomationController() {
// super();
// setValidateOnBinding(false);
// setFormView("adapter.http.logInfomation");
// setCommandName("baseForm");
// setCommandClass(BaseForm.class);
// }
//
// /**
// * <pre>
// * 1. :
// * 2. ó :
// * -
// * 3. ǻ : Overriden
// * </pre>
// * @author : ڱ⼷
// * @version : $Revision: 1.2 $
// * @since : rts 1.0
// * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(
// * javax.servlet.http.HttpServletRequest,
// * javax.servlet.http.HttpServletResponse,
// * java.lang.Object, org.springframework.validation.BindException)
// * @param request
// * @param response
// * @param form
// * @param bindException
// * @return
// * @throws Exception
// */
//
// @RequestMapping("/adapter/http/logInfomation.do")
// protected ModelAndView onSubmit(HttpServletRequest request,
// HttpServletResponse response, Object form,
// BindException bindException)
// throws Exception {
//
// //BaseForm baseForm = (BaseForm) form;
// Map model = createModel(request);
//
// return new ModelAndView("adapter.http.logInfomation", "model", model);
// }
//
//}
@@ -0,0 +1,160 @@
package com.eactive.eai.rms.onl.adapter.http.httpStatus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.common.vo.SimpleResponse;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.adapter.socket.MapComparator;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.google.gson.Gson;
import edu.emory.mathcs.backport.java.util.Collections;
/**
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : 박기섭
* @version : $Revision: 1.13 $
* @since : rts 1.0
*/
@Controller
public class HttpStatusController extends BaseController {
private static final String AGENT_PAGE_STATUS = "adapter_status_agent.jsp";
private static final String AGENT_PAGE_STARTSTOP = "adapter_startstop_agent.jsp";
private EAIServerService eaiServerService;
@Autowired
protected HttpStatusController(EAIServerService eaiServerService) {
this.eaiServerService = eaiServerService;
}
@RequestMapping(value = "/onl/adapter/http/httpStatus.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd) {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@PostMapping(value = "/onl/adapter/http/httpStatus.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<HashMap<String, Object>>> selectList(
@RequestParam(name = "adapterType", defaultValue = "") List<String> adapterTypes,
String searchAdapterGroup) {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
if (serverList.isEmpty()) {
throw new BizException("서버리스트가 없습니다.");
}
List<String> urls = new ArrayList<>();
for (EAIServer serverMap : serverList) {
for (String adapterType : adapterTypes) {
String url = "http://" + serverMap.getEaisevrip() + ":" + serverMap.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STATUS + "?adapterType=" + adapterType
+ "&eaiSvrInstNm=" + serverMap.getEaisevrinstncname();
urls.add(url);
logger.debug(url);
}
}
HashMap<String, String> filter = new HashMap<>();
if (searchAdapterGroup != null && !"".equals(searchAdapterGroup)) {
filter.put("adapterGroupName", searchAdapterGroup);
}
DataSetUtil gUtil = new DataSetUtil();
gUtil.setFilter(filter);
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(urls);
// 리스트에서 데이터가 없을때 제거
list.removeIf(m -> m.get("adapterGroupSimple") == null || m.get("adapterGroupSimple") == "");
// 어댑터 업무그룹별 정렬
String[] compareParam = { "adapterGroupName", "eaiSvrInstNm" };
MapComparator comp = new MapComparator(compareParam);
Collections.sort(list, comp);
return ResponseEntity.ok(new GridResponse<>(list));
}
@PostMapping(value = "/onl/adapter/http/httpStatus.json", params = "cmd=TRANSACTION_STARTSTOP")
public ResponseEntity<SimpleResponse> transactionStartStop(HttpServletRequest request, String eaiInstanceName,
String adapterType, String control, String adapterGroupName, String adapterName) throws Exception {
EAIServer eaiServer = eaiServerService.getByEaiSevrInstncName(eaiInstanceName);
String url = "http://" + eaiServer.getEaisevrip() + ":" + eaiServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STARTSTOP;
// cmd 는 START/STOP
NameValuePair[] postParameters = new NameValuePair[] { new NameValuePair("adapterType", adapterType),
new NameValuePair("adapterGroupNm", adapterGroupName), new NameValuePair("adapterNm", adapterName),
new NameValuePair("adapterStartStop", control) };
// Agent를 호출한다.
CallAgentUtil util = new CallAgentUtil();
String message = util.getAgentDataToString(url, postParameters);
return ResponseEntity.ok(SimpleResponse.of(message));
}
@RequestMapping(value = "/onl/adapter/http/httpStatus.excel", params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, String gridData,
String header, String headerTitle, String fileName, String merge) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
Gson gson = new Gson();
@SuppressWarnings("unchecked")
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
String[] headers = gson.fromJson(header, String[].class);
String[] headerTitles = gson.fromJson(headerTitle, String[].class);
HashMap<String, Object>[] lmerge = null;
if (merge != null) {
lmerge = gson.fromJson(merge, HashMap[].class);
}
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", list);
resultMap.put("fileName", fileName);
resultMap.put("merge", lmerge);
ModelAndView modelAndView = new ModelAndView("excelView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,52 @@
package com.eactive.eai.rms.onl.adapter.http.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@Service
@Scope("prototype")
@SuppressWarnings(value = { "deprecation", "unchecked" })
public class EaiEngineHttpStatusService {
public EaiEngineHttpStatusService() {
super();
}
public List getHttpAdapterStatusList() throws Exception {
ArrayList statusArray = new ArrayList();
//TODO WLS => JBOSS
//
// MBeanHomeUtil mbeanHomeUtil = (MBeanHomeUtil) applicationContext.getBean("mbeanHomeUtil");
//
// Set runtimeSet = mbeanHomeUtil.getMBeanHome().getMBeansByType(
// "ServletRuntime");
//
// ServletStatusVO servletVo = null;
//
// for (Iterator it = runtimeSet.iterator(); it.hasNext();) {
// ServletRuntimeMBean servletRuntime = (ServletRuntimeMBean) it.next();
// String servletName = servletRuntime.getServletName();
// if (HTTP_ADAPTER_NAME.indexOf(servletName) > -1) {
// servletVo = new ServletStatusVO();
// servletVo.setServerName(servletRuntime.getObjectName()
// .getLocation());
// servletVo.setExecutionTimeAverage(servletRuntime.getExecutionTimeAverage());
// servletVo.setExecutionTimeHigh(servletRuntime.getExecutionTimeHigh());
// servletVo.setExecutionTimeLow(servletRuntime.getExecutionTimeLow());
// servletVo.setExecutionTimeTotal(servletRuntime.getExecutionTimeTotal());
// servletVo.setInvocationTotalCount(servletRuntime.getInvocationTotalCount());
// servletVo.setPoolMaxCapacity(servletRuntime.getPoolMaxCapacity());
// servletVo.setReloadTotalCount(servletRuntime.getReloadTotalCount());
// servletVo.setServletName(servletName);
// servletVo.setServletPath(servletRuntime.getServletPath());
// statusArray.add(servletVo);
// }
// }
return statusArray;
}
}
@@ -0,0 +1,100 @@
package com.eactive.eai.rms.onl.adapter.http.vo;
public class ServletStatusVO {
private String serverName = null;
private String servletName = null;
private int executionTimeAverage = 0;
private int executionTimeHigh = 0;
private int executionTimeLow = 0;
private int executionTimeTotal = 0;
private int invocationTotalCount = 0;
private int poolMaxCapacity = 0;
private int reloadTotalCount = 0;
private String servletPath = null;
public ServletStatusVO() {
super();
}
public int getExecutionTimeAverage() {
return executionTimeAverage;
}
public void setExecutionTimeAverage(int executionTimeAverage) {
this.executionTimeAverage = executionTimeAverage;
}
public int getExecutionTimeHigh() {
return executionTimeHigh;
}
public void setExecutionTimeHigh(int executionTimeHigh) {
this.executionTimeHigh = executionTimeHigh;
}
public int getExecutionTimeLow() {
return executionTimeLow;
}
public void setExecutionTimeLow(int executionTimeLow) {
this.executionTimeLow = executionTimeLow;
}
public int getExecutionTimeTotal() {
return executionTimeTotal;
}
public void setExecutionTimeTotal(int executionTimeTotal) {
this.executionTimeTotal = executionTimeTotal;
}
public int getInvocationTotalCount() {
return invocationTotalCount;
}
public void setInvocationTotalCount(int invocationTotalCount) {
this.invocationTotalCount = invocationTotalCount;
}
public int getPoolMaxCapacity() {
return poolMaxCapacity;
}
public void setPoolMaxCapacity(int poolMaxCapacity) {
this.poolMaxCapacity = poolMaxCapacity;
}
public int getReloadTotalCount() {
return reloadTotalCount;
}
public void setReloadTotalCount(int reloadTotalCount) {
this.reloadTotalCount = reloadTotalCount;
}
public String getServletName() {
return servletName;
}
public void setServletName(String servletName) {
this.servletName = servletName;
}
public String getServletPath() {
return servletPath;
}
public void setServletPath(String servletPath) {
this.servletPath = servletPath;
}
public String getServerName() {
return serverName;
}
public void setServerName(String serverName) {
this.serverName = serverName;
}
}
@@ -0,0 +1,322 @@
package com.eactive.eai.rms.onl.adapter.info;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.eactive.eai.rms.common.datasource.DataSourceType;
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
import com.eactive.eai.rms.common.util.ContainerUtil;
public class AdapterInfosManager {
private Context context;
protected final Logger logger = Logger.getLogger(getClass());
//모니터링을 위한 정보를 저장할 VO
public static HashMap<String,AdapterInfosVO> adaptersMap = null;
public AdapterInfosManager() {
this.init();
}
/** singleton 구현을 위한 자신의 instance */
private static AdapterInfosManager instance ;
public void init() {
//RMS가 기동할 때 인스턴스별로 돌면서 개별 DB의 어뎁터를 불러옴
try {
if (ContainerUtil.get() == ContainerUtil.TOMCAT) {
Context initContext = new InitialContext();
context = (Context) initContext.lookup("java:/comp/env");
}
else {
context = new InitialContext();
}
} catch (Exception e) {
//취약점소스 수정 2020.08.24
logger.error(" error", e);
}
loadAdapterInfos();
}
@Autowired
public static AdapterInfosManager getInstance() {
synchronized (AdapterInfosManager.class) {
if (instance == null) {
instance = new AdapterInfosManager();
}
return instance;
}
}
public void loadAdapterInfos() {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
adaptersMap = new HashMap<String,AdapterInfosVO>();
//int i = 0;
for(DataSourceType d : DataSourceTypeManager.getOnlineDataSourceTypes() ) {
logger.info(" Adapter 정보 구성을 위한 db 접속 ==> " + d.toString());
// Source Connection
conn = getConnection(d.getJndiName());
if(conn != null) { //취약점소스 수정 2020.08.25
stmt = conn.prepareStatement(makeSqlStatus(d.getSchema()));
}
if(stmt != null) { //취약점소스 수정 2020.08.26
rs = stmt.executeQuery();
}
while ( rs.next() ) {
if(rs != null){ //취약점소스 수정 2020.08.26
//AdapterInfosVO 처리
AdapterInfosVO avo = new AdapterInfosVO();
//HASHMAP에 있는 어뎁터인지를 먼저 확인함
avo.setAdptrBzwkGroupName(rs.getString(1));
if ( adaptersMap.containsKey(avo.getAdptrBzwkGroupName()) ) {
avo = adaptersMap.get(avo.getAdptrBzwkGroupName());
avo.ALEAISevrInstncName.add(rs.getString(3));
} else {
avo.setAdptrBzwkGroupDesc(rs.getString(2));
avo.ALEAISevrInstncName.add(rs.getString(3));
avo.setSocketType(rs.getString(4));
avo.setOsidInstiBzwkRsempName(rs.getString(5));
avo.setOsidInstiTelno(rs.getString(6));
avo.setBoundType(rs.getString(7));
//tobe 추가
avo.setPermanent(rs.getString(8));
avo.setHostName(rs.getString(9));
avo.setPortNumber(rs.getString(10));
}
adaptersMap.put(avo.getAdptrBzwkGroupName(), avo);
}
}
closeConnection(conn, stmt, rs);
}
} catch (Exception e) {
//e.printStackTrace(); //취약점소스 수정 2020.08.24
logger.error(" DB Source CONNECTION FAIL");
} finally {
closeConnection(conn, stmt, rs);
}
}
public Connection getConnection(String datasource) throws Exception {
try {
DataSource ds = null;
if(context != null){ //취약점소스 수정 2020.08.24
ds = (DataSource) context.lookup(datasource);
}
if(ds != null){ //취약점소스 수정 2020.08.24
return ds.getConnection();
}else{
return null;
}
} catch (Exception e) {
throw e;
}
}
protected void closeConnection(Connection con, Statement stmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
;
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
;
}
}
if (con != null) {
try {
if (!con.isClosed()) {
con.close();
}
} catch (SQLException e) {
;
}
}
}
public static HashMap<String, AdapterInfosVO> getAdaptersMap() {
return adaptersMap;
}
public static void setAdaptersMap(HashMap<String, AdapterInfosVO> adaptersMap) {
AdapterInfosManager.adaptersMap = adaptersMap;
}
public void updateAdapterInfo(AdapterInfosVO aptinfo) {
adaptersMap.put(aptinfo.getAdptrBzwkGroupName(), aptinfo);
}
public void removeAdapterInfo(String adptrName) {
if ( adaptersMap.containsKey(adptrName) )
adaptersMap.remove(adptrName);
}
public AdapterInfosVO getAdapterVOInfo(String adptrName) {
if ( adaptersMap.containsKey(adptrName) )
return adaptersMap.get(adptrName);
return new AdapterInfosVO();
}
public String toString() {
System.out.println("---------------- Display START -------------------");
Collection<AdapterInfosVO> coll = AdapterInfosManager.adaptersMap.values();
Iterator<AdapterInfosVO> iter = coll.iterator();
while (iter.hasNext()) {
AdapterInfosVO tempVO = iter.next();
System.out.println(tempVO.toString());
}
return new String("---------------- Display END -------------------" );
}
public String makeSqlStatus(String schemaId) {
String SqlString = new String();
SqlString =
"SELECT "
+ "\n A.ADPTRBZWKGROUPNAME, "
+ "\n A.ADPTRBZWKGROUPDESC, "
+ "\n B.EAISEVRINSTNCNAME, "
+ "\n TAB1.SOCKETTYPE AS \"SOCKETTYPE\", "
+ "\n A.OSIDINSTITELNO, "
+ "\n A.OSIDINSTIBZWKRSEMPNAME , "
+ "\n TAB2.BOUNDTYPE AS \"BOUNDTYPE\" , "
+ "\n TAB3.PERMANENT AS \"PERMANENT\", "
+ "\n TAB4.HOSTNAME AS \"HOSTNAME\" ,"
+ "\n TAB5.PORTNUMBER AS \"PORTNUMBER\" "
+ "\n FROM " + schemaId + ".TSEAIAD01 A, "
+ "\n " + schemaId + ".TSEAIAD02 B, "
+ "\n ( SELECT C.PRPTYGROUPNAME, "
+ "\n C.PRPTY2VAL AS SOCKETTYPE "
+ "\n FROM " + schemaId + ".TSEAIAD15 C "
+ "\n WHERE C.PRPTYNAME = 'socket.type' "
+ "\n ) TAB1, "
+ "\n ( SELECT C.PRPTYGROUPNAME , "
+ "\n C.PRPTY2VAL AS BOUNDTYPE "
+ "\n FROM " + schemaId + ".TSEAIAD15 C "
+ "\n WHERE C.PRPTYNAME = 'bound.usage' "
+ "\n ) TAB2, "
+ "\n ( SELECT C.PRPTYGROUPNAME , "
+ "\n C.PRPTY2VAL AS PERMANENT "
+ "\n FROM " + schemaId + ".TSEAIAD15 C "
+ "\n WHERE C.PRPTYNAME = 'permanent' "
+ "\n ) TAB3, "
+ "\n ( SELECT C.PRPTYGROUPNAME , "
+ "\n C.PRPTY2VAL AS HOSTNAME "
+ "\n FROM " + schemaId + ".TSEAIAD15 C "
+ "\n WHERE C.PRPTYNAME = 'host.name' "
+ "\n ) TAB4 , "
+ "\n ( SELECT C.PRPTYGROUPNAME , "
+ "\n C.PRPTY2VAL AS PORTNUMBER "
+ "\n FROM " + schemaId + ".TSEAIAD15 C "
+ "\n WHERE C.PRPTYNAME = 'port.number' "
+ "\n ) TAB5 "
+ "\n WHERE A.ADPTRCD = 'NET' "
+ "\n AND A.ADPTRBZWKGROUPNAME = B.ADPTRBZWKGROUPNAME "
+ "\n AND B.PRPTYGROUPNAME = TAB1.PRPTYGROUPNAME "
+ "\n AND B.PRPTYGROUPNAME = TAB2.PRPTYGROUPNAME "
+ "\n AND B.PRPTYGROUPNAME = TAB3.PRPTYGROUPNAME "
+ "\n AND B.PRPTYGROUPNAME = TAB4.PRPTYGROUPNAME "
+ "\n AND B.PRPTYGROUPNAME = TAB5.PRPTYGROUPNAME "
+ "\n ORDER BY 1, 3, 4 "
+ "\n WITH UR";
System.out.println(SqlString);
return SqlString;
}
public List<Map<String, String>> getEaiServerIpList(String name) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
try {
//int i = 0;
DataSourceType d = DataSourceTypeManager.getDataSourceType(name);
logger.debug(" Adapter 정보 구성을 위한 db 접속 ==> " + name +"=" + d);
if(d == null) {
return list;
}
// Source Connection
conn = getConnection(d.getJndiName());
if(conn != null) {//취약점소스 수정 2020.08.25
stmt = conn.prepareStatement(makeSqlInst(d.getSchema()));
}
if(stmt != null) { //취약점소스 수정 2020.08.27
rs = stmt.executeQuery();
}
if(rs != null){ //취약점소스 수정 2020.08.26
while ( rs.next() ) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("EAISVRINSTNM", rs.getString("EAISVRINSTNM"));
map.put("EAISVRIP", rs.getString("EAISVRIP"));
map.put("EAISVRLSNPORT", rs.getString("EAISVRLSNPORT"));
map.put("HOSTNAME", rs.getString("HOSTNAME"));
map.put("FAILOVERSVRNM", rs.getString("FAILOVERSVRNM"));
list.add(map);
}
}
} catch (Exception e) {
//e.printStackTrace(); //취약점소스 수정 2020.08.24
logger.error(" DB Source CONNECTION FAIL");
} finally {
closeConnection(conn, stmt, rs);
}
return list;
}
public String makeSqlInst(String schemaId) {
String SqlString = new String();
SqlString =
"\n SELECT EAISEVRINSTNCNAME AS \"EAISVRINSTNM\", EAISEVRIP AS \"EAISVRIP\" , "
+"\n SEVRLSNPORTNAME AS \"EAISVRLSNPORT\", FLOVRSEVRNAME AS \"FAILOVERSVRNM\", "
+"\n HOSTNAME AS \"HOSTNAME\" "
+"\n FROM " + schemaId + ".TSEAISY02 "
+"\n WHERE EAISEVRINSTNCNAME != 'ALL' "
+"\n AND EAISEVRIP != '*' "
+"\n ORDER BY EAISEVRIP, SEVRLSNPORTNAME ASC";
return SqlString;
}
}
@@ -0,0 +1,116 @@
package com.eactive.eai.rms.onl.adapter.info;
import java.util.ArrayList;
public class AdapterInfosVO {
public String adptrBzwkGroupName; //AD01 어댑터그룹명
public String adptrBzwkGroupDesc; //AD01 대외기관명
public ArrayList<String> ALEAISevrInstncName = new ArrayList<String>(); //AD02 EAI서버인스턴스명 AL
public String socketType; //CM03 SERVER / CLIENT
//DB에서 로드하기 위한 임시적 프로퍼티로 Monitor에서 사용할 때는 ArrayList를 호출하도록 주의한다
public String eAISevrInstncName;
public String boundType; //INBOUND, OUTBOUND
public String osidInstiBzwkRsempName; //담당자명
public String osidInstiTelno; //담당자연락처
//TOBE 추가
public String permanent; //permanent
public String hostName; //host.name
public String portNumber; //port.Number
public String toString() {
String output = this.adptrBzwkGroupName + ": [" + this.adptrBzwkGroupDesc + "," ;
for ( String temp : this.ALEAISevrInstncName ) {
output += temp + ",";
}
output += osidInstiBzwkRsempName + ", " + osidInstiTelno + ", " + socketType + "]";
return output;
}
public ArrayList<String> getALEAISevrInstncName() {
return ALEAISevrInstncName;
}
public void setALEAISevrInstncName(ArrayList<String> sevrInstncName) {
ALEAISevrInstncName = sevrInstncName;
}
public String getEAISevrInstncName() {
return eAISevrInstncName;
}
public void setEAISevrInstncName(String sevrInstncName) {
eAISevrInstncName = sevrInstncName;
}
public String getAdptrBzwkGroupName() {
return adptrBzwkGroupName;
}
public void setAdptrBzwkGroupName(String adptrBzwkGroupName) {
this.adptrBzwkGroupName = adptrBzwkGroupName;
}
public String getAdptrBzwkGroupDesc() {
return adptrBzwkGroupDesc;
}
public void setAdptrBzwkGroupDesc(String adptrBzwkGroupDesc) {
this.adptrBzwkGroupDesc = adptrBzwkGroupDesc;
}
public String getSocketType() {
return socketType;
}
public void setSocketType(String socketType) {
this.socketType = socketType;
}
public String getBoundType() {
return boundType;
}
public void setBoundType(String boundType) {
this.boundType = boundType;
}
public String getOsidInstiBzwkRsempName() {
return osidInstiBzwkRsempName;
}
public void setOsidInstiBzwkRsempName(String osidInstiBzwkRsempName) {
this.osidInstiBzwkRsempName = osidInstiBzwkRsempName;
}
public String getOsidInstiTelno() {
return osidInstiTelno;
}
public void setOsidInstiTelno(String osidInstiTelno) {
this.osidInstiTelno = osidInstiTelno;
}
public String getPermanent() {
return permanent;
}
public void setPermanent(String permanent) {
this.permanent = permanent;
}
public String getHostName() {
return hostName;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public String getPortNumber() {
return portNumber;
}
public void setPortNumber(String portNumber) {
this.portNumber = portNumber;
}
}
@@ -0,0 +1,173 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
import com.eactive.eai.rms.onl.manage.sna.lugroup.LuGroupService;
import com.google.gson.Gson;
@Controller
public class SnaConnectionListController extends BaseController{
@Autowired
@Qualifier("snaConnectionListService")
private SnaConnectionListService service;
@Autowired
@Qualifier("luGroupService")
private LuGroupService groupService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value= "/onl/adapter/sna/snaConnectionListMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaConnectionListMan.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,HttpServletResponse response) throws Exception {
HashMap paramMap = new HashMap();
List groupList = groupService.selectSnaGroupList();
List adapterList = groupService.selectSnaAdapterList();
List luGroupShortNameList = groupService.selectLuGroupShortNameList();
List luGroupList = groupService.selectLuGroupList(paramMap);
Map resultMap = new HashMap();
resultMap.put("groupRows" , groupList );
resultMap.put("adapterRows" , adapterList);
resultMap.put("luGroupShortNameRows" , luGroupShortNameList);
resultMap.put("luGroupList" , luGroupList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaConnectionListMan.json",params = "cmd=LIST_CHANGE_COMBO")
public ModelAndView initCombo2( HttpServletRequest request,
HttpServletResponse response,String adptrGstatSevrName , String adptrGroupName) throws Exception {
HashMap paramMap = new HashMap();
paramMap.put("adptrGstatSevrName", adptrGstatSevrName);
paramMap.put("adptrGroupName", adptrGroupName);
List luGroupList = groupService.selectLuGroupList(paramMap);
Map resultMap = new HashMap();
resultMap.put("luGroupList" , luGroupList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@PostMapping(value= "/onl/adapter/sna/snaConnectionListMan.json", params = "cmd=LIST")
public ModelAndView selectList(@RequestParam Map<String,Object> paramMap) {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
for (EAIServer eaiServer : serverList) {
if (eaiServer.getHostname().equals(paramMap.get("hostName"))) {
paramMap.put("eaiSvrIp", eaiServer.getEaisevrip());
}
}
// SnaStatusCmd 설정
String statusCmd = null;
statusCmd = "SnaStatus -t " + paramMap.get("adptGrpNm") + " -gA " + paramMap.get("luGrpNm") + " -host "
+ paramMap.get("eaiSvrIp");
paramMap.put("snaStatusCmd", statusCmd);
List list = service.executeSnaStatus(paramMap);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", list);
return new ModelAndView("jsonView", resultMap);
}
@RequestMapping(value = "/onl/adapter/sna/snaConnectionListMan.json", params = "cmd=TRANSACTION_CHANGE")
public ModelAndView transactionBackUp(HttpServletRequest request, @RequestParam HashMap<String, Object> paramMap) {
EAIServer eaiServer = eaiServerService
.findFirstByHostname((String) paramMap.get("hostName"))
.orElseThrow(() -> new EMSRuntimeException("HOST를 조회 할 수 없습니다."));
// SnaStatusCmd 설정
String statusCmd = null;
String type = paramMap.get("type").toString();
statusCmd = (type.startsWith("START_") ? "SnaStart -t "
: "SnaStop -t ")
+ paramMap.get("adptGrpNm") + " -g " + paramMap.get("luGrpNm")+ " ";
if (type.endsWith("_LU")) {
statusCmd += " -s " + request.getParameter("luNm") + " ";
}
statusCmd += "-host " + eaiServer.getEaisevrip();
logger.info("controller statusCmd : " + statusCmd);
paramMap.put("snaStatusCmd", statusCmd);
List list = service.executeStartStop(paramMap);
Map resultMap = new HashMap();
resultMap.put("result", list); // 전체 페이지수
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaConnectionListMan.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, String gridData, String header, String headerTitle, String fileName, String merge) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
String[] headers = gson.fromJson(header, String[].class);
String[] headerTitles = gson.fromJson(headerTitle, String[].class);
HashMap<String, Object>[] lmerge = null;
if (merge !=null){
lmerge = gson.fromJson(merge, HashMap[].class);
}
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", list);
resultMap.put("fileName", fileName);
resultMap.put("merge", lmerge);
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,452 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.onl.adapter.AgentExecCommand;
@Service("snaConnectionListService")
public class SnaConnectionListService extends AgentExecCommand{
private static final Logger logger = Logger.getLogger(SnaConnectionListService.class);
@Autowired
@Qualifier("monitoringContext")
private MonitoringContext monitoringContext;
public List executeSnaStatus(Map<String,Object> paramMap) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
""); // /fsapp/eai/SNAAdapter/bin/
/*if ((paramMap.get("snaStatusCmd").toString()).indexOf("grep") > -1) {
paramMap.put("snaStatusCmd","SnaStatus -tA | grep -E 'DOWN|그룹'");
}*/
logger.info("SnaStatus cmdPath : " + cmdPath);
// 명령어
String cmd = cmdPath + paramMap.get("snaStatusCmd");
//cmd = CharsetDecoderUtil.toKor(cmd);
logger.info("SnaStatus Command Exec : " + cmd);
String result = execCommand(cmd);
int linePoint = 0;
// 정보를 라인단위로 파싱하여
linePoint = result.indexOf("\n");
//================================================================================================================================================
//어댑터 그룹(SNAAdapter_HOST_OUT) LU 그룹명 (SNAAdapter_HOST_OUT_001) LU 그룹 상태 (정상)
//총 LU수 (175) UP LU수 (175) 사용 가능 LU수 (175) 수신 대기 LU수 (0) 송신 대기 LU수 (0) WCA 세션 수 (10)
//송신 건수 (1319) 수신 건수 (8) TIMEOUT 건수 (0) 송신 실패 건수 (0) 수신 실패 건수 (0) 큐 대기 건수 (0) 큐 대기 최대 건수 (0)
//================================================================================================================================================
// LU이름 LU모드 LU상태 LU세부상태 TRAN상태 백업LU APP_ID 세션연결수 송신건수 수신건수 타임아웃 송신실패 수신실패 세션초기화시간
//------------------------------------------------------------------------------------------------------------------------------------------------
//TEN11001 SENDONLY UP - READY 0 I81 1 309 0 0 0 0 2005.10.07 13:23:14
//TEN11002 SENDONLY UP - READY 0 I81 1 183 0 0 0 0 2005.10.07 13:23:08
//TEN11003 SENDONLY UP - READY 0 I81 1 135 0 0 0 0 2005.10.07 13:23:14
//TEN11004 SENDONLY UP - READY 0 I81 1 112 0 0 0 0 2005.10.07 13:23:08
//TEN11005 SENDONLY UP - READY 0 I81 1 102 0 0 0 0 2005.10.07 13:23:12
//================================================================================================================================================
String taskCode = ""; // 서비스 코드명
String luGroup = ""; // Lu 그룹명
while (linePoint > -1) {
Map map = new HashMap();
// 한 라인만을 읽어 온다.
String line = result.substring(0, linePoint);
result = result.substring(linePoint + 1);
// 리스트 부분만
if ((line.indexOf("======") < 0) && (line.indexOf("-----") < 0)
&& (line.indexOf("") < 0) && (line.indexOf("송신") < 0)
&& (line.indexOf("[") != 0)) {
//에러에 대한 예외처리 에러시 첫자가 '[' 로 온다.
// 업무코드(서비스코드)와 LU그룹을 얻는부분
if (line.indexOf("LU 그룹 상태") > -1) {
int point1 = line.indexOf("(");
int point2 = line.indexOf(")");
// 서비스코드
taskCode = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
luGroup = line.substring(point1 + 1, point2);
linePoint = result.indexOf("\n");
continue;
}
logger.info("line : " + line);
StringTokenizer st = new StringTokenizer(line);
int stCount = 0;
map.put("taskCode", taskCode);
map.put("luGroup", luGroup);
String sessionInitTime = "";
while (st.hasMoreTokens()) {
String t = st.nextToken();
//System.out.println(t);
switch (stCount) {
case 0:
// Lu 이름
map.put("luName", t.trim());
break;
case 1:
// Lu 모드
map.put("luMode", t.trim());
map.put("luModeToolTip", getLuModeToolTip(t.trim()));
break;
case 2:
// Lu 상태
map.put("luState", t.trim());
map.put("luStateToolTip", getLuStateToolTip(t.trim()));
// 상태에 대한 이미지 셋팅
if ((t.trim()).equals("UP")) {
map.put("startStop", "1"); //start
} else {
map.put("startStop", "0"); //stop
}
break;
case 3:
// Lu 세부 상태
map.put("luDetailState", t.trim());
map.put("luDetailStateToolTip",
getLuDetailStateToolTip(t.trim()));
break;
case 4:
// TRAN 상태
map.put("tranState", t.trim());
map.put("tranStateToolTip",
getTranStateToolTip(t.trim()));
break;
case 5:
// 백업LU
map.put("backupLu", t.trim());
break;
case 6:
// APP_ID
map.put("appId", t.trim());
break;
case 7:
// Session 연결수
map.put("sessionCnt", t.trim());
break;
case 8:
// 송신 건수
map.put("sendCnt", t.trim());
break;
case 9:
// 수신 건수
map.put("receiveCnt", t.trim());
break;
case 10:
// 타임아웃 건수
map.put("timeOut", t.trim());
break;
case 11:
// 송신 실패 건수
map.put("sendFailCnt", t.trim());
break;
case 12:
// 수신 실패 건수
map.put("receiveFailCnt", t.trim());
break;
case 13:
// Session 초기화 시간 (년 월 일)
sessionInitTime = t.trim();
break;
case 14:
// Session 초기화 시간 (시 분 초)
map.put("sessionInitTime", sessionInitTime + " " + t.trim());
break;
}
stCount++;
} // end of while
if (stCount < 13)
map.put("sessionInitTime", "");
if (map.size() >= 10) {
list.add(map);
}
}
linePoint = result.indexOf("\n");
}
return list;
} // end of refresh
/**
* <pre>
* 1. 기능 : Lu 모드에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
private String getLuModeToolTip(String code) {
String result = "";
if (code.equals("SENDONLY")) {
result = "전문 타입의 Non-Response 모드로 호스트로 데이터 송신만을 수행";
} else if (code.equals("RECVONLY")) {
result = "전문 타입의 Non-Response 모드로 호스트로부터 데이터 수신만을 수행";
} else if (code.equals("SENDRECV")) {
result = "전문 타입의 Response 모드로 호스트와 데이터 송수신 수행";
} else if (code.equals("TERMINAL")) {
result = "단말 타입의 Response 모드로 호스트와 데이터 송수신 수행";
}
return result;
}
/**
* <pre>
* 1. 기능 : Tran 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
private String getTranStateToolTip(String code) {
String result = "";
if (code.equals("NOTREADY")) {
result = "Transaction을 수행할 수 없는 상태";
} else if (code.equals("READY")) {
result = "Transaction을 수행할 수 있는 상태";
} else if (code.equals("SEND")) {
result = "호스트로부터 데이터를 송신하고 있는 상태";
} else if (code.equals("RECV")) {
result = "호스트로부터 데이터를 수신 대기하고 있는 상태";
}
return result;
}
/**
* <pre>
* 1. 기능 : Lu 세부 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
private String getLuDetailStateToolTip(String code) {
String result = "";
if (code.equals("API_ERROR")) {
result = "SNA Gateway 내부 장애가 발생한 상태";
} else if (code.equals("NOT_DEF")) {
result = "LU가 정의되지 않은 상태";
} else if (code.equals("LINK_DOWN")) {
result = "호스트와의 SNA Link가 Down된 상태";
} else if (code.equals("NET_DOWN")) {
result = "호스트와의 Network가 Down된 상태";
} else if (code.equals("DISCONN")) {
result = "호스트와의 LU 세션이 해제된 상태";
}
return result;
}
/**
* <pre>
* 1. 기능 : Lu 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
private String getLuStateToolTip(String code) {
String result = "";
if (code.equals("DOWN")) {
result = "호스트와 세션이 해제된 상태";
} else if (code.equals("TRY_INIT")) {
result = "호스트와 세션을 연결하기 위한 자원 초기화 상태";
} else if (code.equals("TRY_INITSELF")) {
result = "호스트로 INIT-SELF 데이터를 송신하는 상태";
} else if (code.equals("WAIT_BIND")) {
result = "호스트로부터 BIND 데이터를 수신 대기하는 상태";
} else if (code.equals("WAIT_SDT")) {
result = "호스트로부터 SDT 데이터를 수신 대기하는 상태";
} else if (code.equals("UP")) {
result = "호스트와 LU-LU 세션이 연결된 상태";
} else if (code.equals("TRY_TERMSELF")) {
result = "호스트로 TERM-SELF 데이터를 송신하는 상태";
} else if (code.equals("WAIT_UNBIND")) {
result = "호스트로부터 UNBIND 데이터를 수신 대기하는 상태";
} else if (code.equals("TRY_TERM")) {
result = "호스트와 세션을 해제하기 위한 자원 해제 상태";
} else if (code.equals("RECV_UNBIND")) {
result = "호스트로부터 UNBIND를 수신한 상태";
}
return result;
}
/**
* <pre>
* 1. 기능 : Sna 명령어 실행
* 2. 처리 개요 :
* - SnaStart, SnaStop 명령어 실행
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param form
* @return
*/
public List executeStartStop(HashMap<String,Object> paramMap) {
// 명령어
String cmd = paramMap.get("snaStatusCmd").toString();
logger.info("SnaStartStop Cmd : " + cmd);
return executeCmd(cmd);
} // end of refresh
/**
* <pre>
* 1. 기능 : 명령을 실행후 결과를 반환한다.
* 2. 처리 개요 :
* - 명령어를 실행후 결과를 반환한다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param cmd
* @return
*/
private List executeCmd(String cmd) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
"/fsapp/eai/SNAAdapter/bin/");
String command = cmdPath + cmd;
String result = execCommand(command);
Map map = new HashMap();
if ((result.trim()).length() > 0) {
map.put("msg", result.trim());
} else {
map.put("msg", "명령처리에 실패 하였습니다.");
}
list.add(map);
return list;
}
}
@@ -0,0 +1,27 @@
package com.eactive.eai.rms.onl.adapter.sna;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
@Controller
public class SnaLogInformationController extends BaseController{
@RequestMapping(value= "/onl/adapter/sna/snaLogInformationMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
}
@@ -0,0 +1,191 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.common.util.CharsetDecoderUtil;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.onl.adapter.socket2.vo.ErrorContentVO;
import com.eactive.eai.rms.onl.common.util.DateUtil;
@Controller
public class SnaLuLogController extends BaseController{
@Autowired
@Qualifier("monitoringContext")
private MonitoringContext monitoringContext;
@Autowired
@Qualifier("comboService")
private ComboService comboService;
@RequestMapping(value= "/onl/adapter/sna/snaLuLogMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaLuLogMan.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,HttpServletResponse response) throws Exception {
String logType = request.getParameter("logType");
List serverList = new ArrayList<HashMap<String,Object>>();
if("SNA".equals(logType)){
// serverList = comboService.selectListComboForTable("TSEAIAD13", "SNAADPTRSEVRNAME","SNAADPTRSEVRIPNAME", "", "SNAADPTRSEVRNAME");
}else{
serverList = comboService.getFromEAIServerWithoutAll();
}
List<ComboVo> loglevelList = comboService.getFromCode("SNA_SEARCH_LOGLEVEL");
Map resultMap = new HashMap();
resultMap.put("serverRows" , serverList);
resultMap.put("logLevelRows" , loglevelList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaLuLogMan.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,@RequestParam HashMap<String,Object> paramMap) throws Exception {
List list = execute(paramMap);
for (int i = 0 ; i < list.size() ; i++)
{
//ErrorContentVO vo = (ErrorContentVO) list.get(i);
//dataSet.put("sline", vo.getSline(), 500, GauceDataColumn.TB_NORMAL);
}
Map resultMap = new HashMap();
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
public List execute(HashMap<String,Object> paramMap) throws Exception {
String logLevel = (String)paramMap.get("searchLogLevel");
String logType = (String)paramMap.get("logType");
String searchText = (String)paramMap.get("searchText");
int count = 0;
//---------------------------------------------------------
// 대상 파일명
//---------------------------------------------------------
String fileName = "";
String lastLineText = null;
RandomAccessFile randomAccessFile = null;
//---------------------------------------------------------
// 버프의 내용을 라인씩 읽어 들인다.
//---------------------------------------------------------
ArrayList errorContentList = new ArrayList();
ErrorContentVO errorContent = null;
try {
//---------------------------------------------------------
// 대상 파일명
//---------------------------------------------------------
String defaultLogPath = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH,
"/fslog/eai/");
String snaWcaLogFile = monitoringContext.getStringProperty(
MonitoringContext.SNA_WCA_LOG_FILE,
"snaAdapter.log");
logger.info("defaultLogPath : "+defaultLogPath);
logger.info("snaWcaLogFile : "+snaWcaLogFile);
if (logType.equals("WCA")) {
// (Was 도메인 경로 + Was인스턴스명 + 파일경로) - 이동철
fileName = defaultLogPath
+ (String)paramMap.get("searchInstNm") + "/"
+ snaWcaLogFile;
} else {
fileName = snaWcaLogFile + "."
+ DateUtil.getDate();
}
logger.info("fileName : "+fileName);
if (logLevel.equals("TOTAL"))
logLevel = "";
File file = new File(fileName);
randomAccessFile = new RandomAccessFile(file, "r");
long currentPoint = randomAccessFile.getFilePointer();
do {
randomAccessFile.seek(currentPoint); // 마지막지점 검색
lastLineText = randomAccessFile.readLine(); // 마지막지점의 라인을 읽어온다.
currentPoint = randomAccessFile.getFilePointer();
count++;
if (lastLineText == null)
break;
// 만약 현 라인에 해당 로그 level 이 존재 하지 않거나
if (lastLineText.indexOf(logLevel) >= 0
&& lastLineText.indexOf(searchText) >= 0) {
errorContent = new ErrorContentVO();
lastLineText = CharsetDecoderUtil.toKor(lastLineText);
errorContent.setSline(count + ":" + lastLineText);
//가장 최근이 맨 상단으로 가기 위해(이동철)
errorContentList.add(0, errorContent);
} else {
// YUN_DEBUG
logger.debug("lastLineText.indexOf(logLevel) < 0 ");
}
} while (lastLineText != null);
} catch (IOException e) {
logger.error(e);
} finally {
try {
randomAccessFile.close();
} catch (Exception e) {
}
}
return errorContentList;
}
}
@@ -0,0 +1,290 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
import com.eactive.eai.rms.onl.manage.sna.lugroup.LuGroupService;
import com.google.gson.Gson;
@Controller
public class SnaProcessStatusController extends BaseController{
@Autowired
@Qualifier("snaProcessStatusService")
private SnaProcessStatusService service;
@Autowired
@Qualifier("luGroupService")
private LuGroupService groupService;
@Autowired
private EAIServerService eaiServerService;
private final String CMD_STATUS = "SnaStatus -t -host ";
private final String CMD_INIT = "SnaRestat -a -host ";
private final String CMD_START = "BackupLUStart -t -host ";
private final String CMD_STOP = "BackupLUStop -t -host ";
@Autowired
@Qualifier("comboService")
private ComboService comboService;
@RequestMapping(value= "/onl/adapter/sna/snaProcessStatusMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaProcessStatusMan.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,HttpServletResponse response) throws Exception {
// List snaHostList = comboService.selectListComboForTable("TSEAIAD13", "SNAADPTRSEVRNAME","SNAADPTRSEVRIPNAME", "", "SNAADPTRSEVRNAME");
Map resultMap = new HashMap();
// resultMap.put("snaHostRows" , snaHostList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaProcessStatusMan.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,@RequestParam HashMap<String,Object> paramMap) throws Exception {
List snaHostList = groupService.selectSnaHostList(paramMap);
// YUN_info
if( logger.isInfoEnabled()) {
logger.info("findStatusNonAgent snaHostList=" + snaHostList);
}
String[] url = new String[snaHostList.size()];
//String adptGrpNm = "";
//String luGrpNm = "";
String snaStatusCmd = "";
List<HashMap<String, Object>> resultList = new ArrayList<HashMap<String, Object>>();
try
{
logger.info("########## START findStatusNonAgent ##########");
// 호출할 Agent Page List
for (int i = 0; i < url.length ; i++)
{
logger.info("########## start for : " + i + " ###");
Map serverMap = (Map) snaHostList.get(i);
snaStatusCmd = (CMD_STATUS + (String) serverMap.get("EAISVRIP"));
//form.setSnaStatusCmd(CMD_STATUS + "172.17.50.51");
// YUN_info
if( logger.isInfoEnabled()) logger.info("YUN_info command : [" + CMD_STATUS + (String) serverMap.get("EAISVRIP") + "]");
if( logger.isInfoEnabled()) logger.info("########## init service ##########");
if( logger.isInfoEnabled()) logger.info("########## call service ##########");
List list = service.executeSnaStatus(snaStatusCmd);
// YUN_info
if( logger.isInfoEnabled()) logger.info("returned list size = " + list.size() );
String hostName = (String) serverMap.get("HOSTNAME");
//String hostName = "keaita02";
HashMap<String, Object> rsMap = new HashMap<String, Object>();
if( logger.isInfoEnabled()) logger.info("########## start result loop ##########");
// 호출 결과가 없으면 서버명만 출력한다.
// 예전 AS-IS에 process_status_data.jsp에서 처리하던 것
if (list.size() < 1)
{
if( logger.isInfoEnabled()) logger.info("########## no data ##########");
rsMap.put("hostNm",hostName);
rsMap.put("taskCode","");
rsMap.put("luGroup","");
rsMap.put("luGroupState","");
rsMap.put("numLu", "");
rsMap.put("backupLu","");
rsMap.put("upLu", "");
rsMap.put("usefulLu","");
rsMap.put("resLu", "");
rsMap.put("sendLu","");
rsMap.put("wcaSession","");
rsMap.put("sendCnt", "");
rsMap.put("resCnt","");
rsMap.put("timeOut", "");
rsMap.put("sendFailCnt","");
rsMap.put("resFailCnt","");
rsMap.put("queueWaitCnt","");
rsMap.put("queueWaitMaxCnt","");
resultList.add(rsMap);
}
else
{
if( logger.isInfoEnabled()) logger.info("########## multi rows ##########");
for (int j = 0 ; j < list.size() ; j++)
{
if( logger.isInfoEnabled()) logger.info("########## inner for + " + (j+1) + " ##########");
Map map = (Map) list.get(j);
rsMap = new HashMap<String, Object>();
rsMap.put("hostNm", hostName);
rsMap.put("taskCode", (String)map.get("taskCode"));
rsMap.put("luGroup", (String)map.get("luGroup"));
rsMap.put("luGroupState",(String)map.get("luGroupState"));
rsMap.put("numLu", (String)map.get("numLu"));
rsMap.put("backupLu", (String)map.get("backupLu"));
rsMap.put("upLu", (String)map.get("upLu"));
rsMap.put("usefulLu", (String)map.get("usefulLu"));
rsMap.put("resLu", (String)map.get("resLu"));
rsMap.put("sendLu", (String)map.get("sendLu"));
rsMap.put("wcaSession",(String)map.get("wcaSession"));
rsMap.put("sendCnt", (String)map.get("sendCnt"));
rsMap.put("resCnt", (String)map.get("resCnt"));
rsMap.put("timeOut", (String)map.get("timeOut"));
rsMap.put("sendFailCnt", (String)map.get("sendFailCnt"));
rsMap.put("resFailCnt", (String)map.get("resFailCnt"));
rsMap.put("queueWaitCnt", (String)map.get("queueWaitCnt"));
rsMap.put("queueWaitMaxCnt", (String)map.get("queueWaitMaxCnt"));
resultList.add(rsMap);
}
}
}
if( logger.isInfoEnabled()) logger.info("########## write service ##########");
}
catch (Exception e)
{
throw e;
}
Map resultMap = new HashMap();
resultMap.put("rows" , resultList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
/**
* <pre>
* 1. 기능 : 서버 초기화, 재시작, 종료를 처리한다.
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.17.4.4 $
* @since : rts 1.0
* @param request
* @param response
* @param hostInfomation
* @throws ServletException
* @throws IOException
*/
@RequestMapping(value= "/onl/adapter/sna/snaProcessStatusMan.json", params = "cmd=LIST_STAT_CHANGE")
public ModelAndView changeStatusNonAgent(HttpServletRequest request, HttpServletResponse response,@RequestParam HashMap<String,Object> paramMap) {
EAIServer eaiServer = eaiServerService
.findFirstByHostname((String) paramMap.get("hostName"))
.orElseThrow(() -> new EMSRuntimeException("HOST를 조회 할 수 없습니다."));
String msg = "";
String type = paramMap.get("snaStatusCmd").toString();
if ("INIT".equals(type))
{
paramMap.put("snaStatusCmd",CMD_INIT);
}
else if (type.startsWith("BACKUP_"))
{
paramMap.put("snaStatusCmd" ,("BACKUP_START".equals(type) ? CMD_START : CMD_STOP));
}
String result = "";
//Sna Lu 건수 초기화
String cmd = (String) paramMap.get("snaStatusCmd")+(String) eaiServer.getEaisevrip();
logger.info("cmd :"+cmd);
List list = null;
if ("INIT".equals(cmd))
{
list = service.executeInit(cmd);
}
else
{
list = service.executeBackupLu(cmd);
}
if(list != null && list.size() > 0){
for (int i = 0 ; i < list.size() ; i++)
{
Map map = (Map) list.get(i);
result += (String)map.get("msg") + "\n";
}
}
msg = result;
Map resultMap = new HashMap();
resultMap.put("result" ,msg);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaProcessStatusMan.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String,Object> paramMap) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
String jsonStr = (String)paramMap.get("gridData");
HashMap<String, Object>[] dataList = gson.fromJson(jsonStr, HashMap[].class);
String[] headers = gson.fromJson((String) paramMap.get("header"), String[].class);
String[] headerTitles = gson.fromJson((String)paramMap.get("headerTitle"), String[].class);
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", dataList);
resultMap.put("fileName", (String)paramMap.get("fileName"));
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,336 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.onl.adapter.AgentExecCommand;
@Service("snaProcessStatusService")
public class SnaProcessStatusService extends AgentExecCommand {
private static final Logger logger = Logger.getLogger(SnaProcessStatusService.class);
@Autowired
@Qualifier("monitoringContext")
private MonitoringContext monitoringContext;
public List executeSnaStatus(String snaStatusCmd) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
"/fsapp/eai/SNAAdapter/bin/");
// 명령어
String cmd = cmdPath + snaStatusCmd;
//cmd = CharsetDecoderUtil.toKor(cmd);
logger.info("SnaStatus Command Exec : " + cmd);
String result = execCommand(cmd);
// YUN_DEBUG
logger.info("executeSnaStatus() ret size=" + result.length() );
logger.info("executeSnaStatus() result =[" + result + "]" );
logger.info("SnaStatus Command Result : \n" + result);
int linePoint = 0;
// 정보를 라인단위로 파싱하여
linePoint = result.indexOf("\n");
// ================================================================================================================================================
// 어댑터 그룹(OUT_SNA_KESAPOOL_001) LU 그룹명 (OUT_SNA_KESAPOOL_001_001) LU 그룹 상태 (정상)
// 총 LU수 (28) 총 백업 LU 수 (2) UP LU수 (28) 사용 가능 LU수 (28) 수신 대기 LU수 (0) 송신 대기 LU수 (0) WCA 세션 수 (5)
// 송신 건수 (0) 수신 건수 (0) TIMEOUT 건수 (0) 송신 실패 건수 (0) 수신 실패 건수 (0) 큐 대기 건수 (0) 큐 대기 최대 건수 (0)
// ================================================================================================================================================
// 어댑터 그룹(SNAAdapter_HOST_IN) LU 그룹명 (SNAAdapter_HOST_IN_001) LU 그룹 상태 (정상)
// 총 LU수 (50) 총 백업 LU 수 (0) UP LU수 (50) 사용 가능 LU수 (50) 수신 대기 LU수 (0) 송신 대기 LU수 (0) WCA 세션 수 (5)
// 송신 건수 (0) 수신 건수 (0) TIMEOUT 건수 (0) 송신 실패 건수 (0) 수신 실패 건수 (0) 큐 대기 건수 (0) 큐 대기 최대 건수 (0)
// ================================================================================================================================================
// 어댑터 그룹(SNAAdapter_HOST_OUT) LU 그룹명 (SNAAdapter_HOST_OUT_001) LU 그룹 상태 (정상)
// 총 LU수 (175) 총 백업 LU 수 (0) UP LU수 (175) 사용 가능 LU수 (175) 수신 대기 LU수 (0) 송신 대기 LU수 (0) WCA 세션 수 (5)
// 송신 건수 (0) 수신 건수 (0) TIMEOUT 건수 (0) 송신 실패 건수 (0) 수신 실패 건수 (0) 큐 대기 건수 (0) 큐 대기 최대 건수 (0)
// ================================================================================================================================================
String taskCode = "";
String luGroup = "";
String luGroupState = "";
String numLu = "";
String backupLu = "";
String upLu = "";
String usefulLu = "";
String resLu = "";
String sendLu = "";
String wcaSession = "";
String sendCnt = "";
String resCnt = "";
String timeOut = "";
String sendFailCnt = "";
String resFailCnt = "";
String queueWaitCnt = "";
String queueWaitMaxCnt = "";
while (linePoint > -1) {
// 한 라인만을 읽어 온다.
String line = result.substring(0, linePoint);
result = result.substring(linePoint + 1);
//logger.info("Line : " + line);
// 필요한 데이터가 있는 부분만
if ((line.indexOf("======") < 0) && (line.indexOf("-----") < 0)) {
int point1 = 0;
int point2 = 0;
// 업무코드(서비스코드)와 LU그룹을 얻는부분
if (line.indexOf("LU 그룹 상태") > -1) {
point1 = line.indexOf("(");
point2 = line.indexOf(")");
// 서비스코드
taskCode = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
// LU그룹
luGroup = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//LU그룹 상태
luGroupState = line.substring(point1 + 1, point2);
//총 LU수, UP LU수, 사용 가능 LU수, 수신 대기 LU수, 송신 대기 LU수
} else if (line.indexOf("총 LU수") > -1) {
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//총 LU수
numLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//백업LU수
backupLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//UP LU수
upLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//사용가능 LU수
usefulLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//수신대기 LU수
resLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//송신대기 LU수
sendLu = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//WCA 세션 수
wcaSession = line.substring(point1 + 1, point2);
} else if (line.indexOf("송신 건수") > -1) {
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//송신 건수
sendCnt = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//수신 건수
resCnt = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//타임아웃건수
timeOut = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//송신실패건수
sendFailCnt = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//수신실패건수
resFailCnt = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//큐대기건수
queueWaitCnt = line.substring(point1 + 1, point2);
line = line.substring(point2 + 1);
point1 = line.indexOf("(");
point2 = line.indexOf(")");
//큐 대기 최대 건수
queueWaitMaxCnt = line.substring(point1 + 1, point2);
Map map = new HashMap();
map.put("taskCode", taskCode);
map.put("luGroup", luGroup);
map.put("luGroupState", luGroupState);
map.put("numLu", numLu);
map.put("backupLu", backupLu);
map.put("upLu", upLu);
map.put("usefulLu", usefulLu);
map.put("resLu", resLu);
map.put("sendLu", sendLu);
map.put("wcaSession", wcaSession);
map.put("sendCnt", sendCnt);
map.put("resCnt", resCnt);
map.put("timeOut", timeOut);
map.put("sendFailCnt", sendFailCnt);
map.put("resFailCnt", resFailCnt);
map.put("queueWaitCnt", queueWaitCnt);
map.put("queueWaitMaxCnt", queueWaitMaxCnt);
list.add(map);
}
}
linePoint = result.indexOf("\n");
}
return list;
} // end of refresh
/**
* <pre>
* 1. 기능 : Sna 명령어 실행
* 2. 처리 개요 :
* - SnaRestart 명령어 실행
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param form
* @return
*/
public List executeInit(String cmd) {
logger.debug("SnaRestat Cmd : " + cmd);
return executeCmd(cmd);
}
/**
* <pre>
* 1. 기능 : Sna 명령어 실행
* 2. 처리 개요 :
* - BackupLUStart, BackupLUStop 명령어 실행
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param form
* @return
*/
public List executeBackupLu(String cmd) {
logger.debug("SnaBackupLuStartStop Cmd : " + cmd);
return executeCmd(cmd);
}
/**
* <pre>
* 1. 기능 : 명령을 실행후 결과를 반환한다.
* 2. 처리 개요 :
* - 명령어를 실행후 결과를 반환한다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param cmd
* @return
*/
private List executeCmd(String cmd) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
"/fsapp/eai/SNAAdapter/bin/");
String command = cmdPath + cmd;
String result = execCommand(command);
Map map = new HashMap();
if ((result.trim()).length() > 0) {
map.put("msg", result.trim());
} else {
map.put("msg", "명령처리에 실패 하였습니다.");
}
list.add(map);
return list;
}
}
@@ -0,0 +1,100 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.google.gson.Gson;
@Controller
public class SnaTrackingController extends BaseController{
@Autowired
@Qualifier("snaTrackingService")
private SnaTrackingService service;
@Autowired
@Qualifier("comboService")
private ComboService comboService;
@RequestMapping(value= "/onl/adapter/sna/snaTrackingMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaTrackingMan.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,HttpServletResponse response) throws Exception {
List<ComboVo> listLogPrcssSerno = comboService.getFromCode("LOGPRCSSSERNO_TYPE");
Map resultMap = new HashMap();
resultMap.put("logPrcssSernoList", listLogPrcssSerno);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaTrackingMan.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,@RequestParam HashMap<String,Object> paramMap) throws Exception {
logger.debug("param : "+paramMap.toString());
HashMap map = service.selectList( pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
pageVo.setTotalCount((Integer)map.get("totalCount"));
Map resultMap = new HashMap();
resultMap.put("total" , pageVo.getTotal()); //전체 페이지수
resultMap.put("page" , pageVo.getPage()); //현재 페이지수
resultMap.put("records", pageVo.getTotalCount());//전체 레코드건수
resultMap.put("rows" , map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaTrackingMan.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String,Object> paramMap) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
String jsonStr = (String)paramMap.get("gridData");
HashMap<String, Object>[] dataList = gson.fromJson(jsonStr, HashMap[].class);
String[] headers = gson.fromJson((String) paramMap.get("header"), String[].class);
String[] headerTitles = gson.fromJson((String)paramMap.get("headerTitle"), String[].class);
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", dataList);
resultMap.put("fileName", (String)paramMap.get("fileName"));
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,23 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
@Repository("snaTrackingDao")
@SuppressWarnings("unchecked")
public class SnaTrackingDao extends SqlMapClientTemplateDao{
public int selectListCount(HashMap param) throws Exception {
return (Integer)template.queryForObject("SnaTracking.selectListCount", param);
}
public List selectList(HashMap param) throws Exception {
return template.queryForList("SnaTracking.selectList", param);
}
}
@@ -0,0 +1,37 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.onl.adapter.AgentExecCommand;
@Service("snaTrackingService")
public class SnaTrackingService extends AgentExecCommand{
@Autowired
@Qualifier("snaTrackingDao")
private SnaTrackingDao dao;
public HashMap selectList(int startNum,int endNum,HashMap paramMap) throws Exception{
// 전체 목록수 얻기
int totalCount = dao.selectListCount(paramMap);
paramMap.put("startNum" , startNum);// 시작 record
paramMap.put("endNum" , endNum);// 끝 record
List<HashMap<String, Object>> list = dao.selectList(paramMap);
HashMap map = new HashMap();
map.put("totalCount", totalCount);
map.put("list", list);
return map;
}
}
@@ -0,0 +1,166 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
import com.eactive.eai.rms.onl.manage.adapter.adapter.AdapterManService;
import com.eactive.eai.rms.onl.manage.sna.lugroup.LuGroupService;
import com.google.gson.Gson;
@Controller
public class SnaWcaConnectionListController extends BaseController{
@Autowired
@Qualifier("snaWcaConnectionListService")
private SnaWcaConnectionListService service;
@Autowired
@Qualifier("luGroupService")
private LuGroupService groupService;
@Autowired
private AdapterManService adapterManService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value= "/onl/adapter/sna/snaWcaConnectionListMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaConnectionListMan.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,HttpServletResponse response) throws Exception {
HashMap paramMap = new HashMap();
List groupList = groupService.selectSnaGroupList();
List adapterList = groupService.selectSnaAdapterList();
List luGroupShortNameList = groupService.selectLuGroupShortNameList();
List luGroupList = groupService.selectLuGroupList(paramMap);
Map resultMap = new HashMap();
resultMap.put("groupRows" , groupList );
resultMap.put("adapterRows" , adapterList);
resultMap.put("luGroupShortNameRows" , luGroupShortNameList);
resultMap.put("luGroupList" , luGroupList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaConnectionListMan.json",params = "cmd=LIST_CHANGE_COMBO")
public ModelAndView initCombo2( HttpServletRequest request,
HttpServletResponse response,String adptrGstatSevrName , String adptrGroupName) throws Exception {
HashMap paramMap = new HashMap();
paramMap.put("adptrGstatSevrName", adptrGstatSevrName);
paramMap.put("adptrGroupName", adptrGroupName);
List luGroupList = groupService.selectLuGroupList(paramMap);
Map resultMap = new HashMap();
resultMap.put("luGroupList" , luGroupList);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaConnectionListMan.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,@RequestParam HashMap<String,Object> paramMap) throws Exception {
EAIServer eaiServer = eaiServerService
.findFirstByHostname((String) paramMap.get("hostName"))
.orElseThrow(() -> new EMSRuntimeException("HOST를 조회 할 수 없습니다."));
// SnaStatusCmd 설정
String statusCmd = null;
statusCmd = "WcaStatus -t " + paramMap.get("adptGrpNm") + " -gA "
+ paramMap.get("luGrpNm") + " -host " + eaiServer.getEaisevrip();
paramMap.put("WcaStatusCmd", statusCmd);
List list = service.executeWcaStatus(paramMap);
if(logger.isInfoEnabled()) logger.info("cmd list size :" + list.size());
//SNA 어댑터 APP_CODE 프라퍼티 MAP 담기
List<Map<String, String>> dbMapList = adapterManService.selectAdapterPropInfo(paramMap);
HashMap<String, Object> dbMap = new HashMap<String, Object>();
for(Map<String, String> tmp : dbMapList){
dbMap.put(tmp.get("ADPTRBZWKNAME"), tmp.get("PRPTY2VAL"));
}
//메모리 DB비교 결과
for (int i=0; i<list.size();i++){
HashMap<String,Object> tmp = (HashMap<String, Object>) list.get(i);
if(tmp.get("appCode") != null){
if(tmp.get("appCode").equals(dbMap.get(tmp.get("adapterName")))){
tmp.put("compare", "true");
}else{
tmp.put("compare", "false");
}
}else{
if(dbMap.get(tmp.get("adapterName")) == null || "".equals(dbMap.get(tmp.get("adapterName")))){
tmp.put("compare", "true");
}else{
tmp.put("compare", "false");
}
}
}
if(logger.isInfoEnabled()) logger.info("메모리 DB비교 결과 list size :" + list.size());
Map resultMap = new HashMap();
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaConnectionListMan.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String,Object> paramMap) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
String jsonStr = (String)paramMap.get("gridData");
HashMap<String, Object>[] dataList = gson.fromJson(jsonStr, HashMap[].class);
String[] headers = gson.fromJson((String) paramMap.get("header"), String[].class);
String[] headerTitles = gson.fromJson((String)paramMap.get("headerTitle"), String[].class);
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", dataList);
resultMap.put("fileName", (String)paramMap.get("fileName"));
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,371 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.onl.adapter.AgentExecCommand;
@Service("snaWcaConnectionListService")
public class SnaWcaConnectionListService extends AgentExecCommand{
private static final Logger logger = Logger.getLogger(SnaWcaConnectionListService.class);
@Autowired
@Qualifier("monitoringContext")
private MonitoringContext monitoringContext;
/**
* <pre>
* 1. 기능 : SNA 정보 수집
* 2. 처리 개요 :
* - 명령어를 사용하여 정보를 수집 파싱한다.
* - 파싱한 정보를 RtsServiceSnaConnectionList 에 저장한다.
* 3. 주의사항 :
* </pre>
*
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
*/
public List executeWcaStatus(HashMap<String,Object> paramMap) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
""); // /fsapp/eai/SNAAdapter/bin/
/*if ((paramMap.get("snaStatusCmd").toString()).indexOf("grep") > -1) {
paramMap.put("snaStatusCmd","SnaStatus -tA | grep -E 'DOWN|그룹'");
}*/
logger.info("WcaStatus cmdPath : " + cmdPath);
// 명령어
String cmd = cmdPath + paramMap.get("WcaStatusCmd");
//cmd = CharsetDecoderUtil.toKor(cmd);
logger.info("WcaStatus Command Exec : " + cmd);
String result = execCommand(cmd);
int linePoint = 0;
// 정보를 라인단위로 파싱하여
linePoint = result.indexOf("\n");
// ------------------------------------------------------------------------------------------------------------------------------------------------
// WCA IP WCA ADAPTER NAME CODE REG DATETIME WCA APP CODE
// ------------------------------------------------------------------------------------------------------------------------------------------------
// 127.0.0.1 _DAO_IN_SNA_AsR{DAO_IN_SNA_AsR_i11} 2019.10.10 08:06:20 ACM,ARS,ATS,B2B,BBA,BBG,BBS,BCN,BWB,CAQ,CAV,CBF,CBG,CDB,CDC,CDG,CDF,CDH,CDM,CDS,CFF,CFH,CFK,CFS,CFZ,CGK,CGS,CRS,DAN,EBA,EBE,EBP,EFT,EGI,EIE,EIG,ELB,ESI,ESJ,ESN,FPI,GCM,GMK,HBJ,HGD,HJB,HJJ,HJK,HMY,HPJ,HSH,HSI,HSJ,HST,HTJ,HYD,ICB,IKC,IDC,IVN,IWB,JGS,JJJ,JRO,JWB,JYB,JYK,KAA,KAD,KAE,KBG,KBH,KEC,KED,KEE,KFL,KGA,KIG,KIS,KJI,KJJ,KJW,KKT,KMB,KOK,KVN,KSI,KSJ,KSN,KTN,KWB,LGC,MCI,MFB,NKS,NOV,OTP,PAE,PBS,PDM,PGS,PID,POS,PPC,SBJ,SBK,SDS,SHI,SIA,SIC,SIN,SKW,SUP,SWB,THD,TPP,TXA,UNS,UJR,WHJ,WNS,ZLO
// 127.0.0.1 _DAO_IN_SNA_AsR{DAO_IN_SNA_AsR_i11} 2019.10.10 08:06:20 ACM,ARS,ATS,B2B,BBA,BBG,BBS,BCN,BWB,CAQ,CAV,CBF,CBG,CDB,CDC,CDG,CDF,CDH,CDM,CDS,CFF,CFH,CFK,CFS,CFZ,CGK,CGS,CRS,DAN,EBA,EBE,EBP,EFT,EGI,EIE,EIG,ELB,ESI,ESJ,ESN,FPI,GCM,GMK,HBJ,HGD,HJB,HJJ,HJK,HMY,HPJ,HSH,HSI,HSJ,HST,HTJ,HYD,ICB,IKC,IDC,IVN,IWB,JGS,JJJ,JRO,JWB,JYB,JYK,KAA,KAD,KAE,KBG,KBH,KEC,KED,KEE,KFL,KGA,KIG,KIS,KJI,KJJ,KJW,KKT,KMB,KOK,KVN,KSI,KSJ,KSN,KTN,KWB,LGC,MCI,MFB,NKS,NOV,OTP,PAE,PBS,PDM,PGS,PID,POS,PPC,SBJ,SBK,SDS,SHI,SIA,SIC,SIN,SKW,SUP,SWB,THD,TPP,TXA,UNS,UJR,WHJ,WNS,ZLO
// 127.0.0.1 _DAO_IN_SNA_AsR{DAO_IN_SNA_AsR_i11} 2019.10.10 08:06:20 ACM,ARS,ATS,B2B,BBA,BBG,BBS,BCN,BWB,CAQ,CAV,CBF,CBG,CDB,CDC,CDG,CDF,CDH,CDM,CDS,CFF,CFH,CFK,CFS,CFZ,CGK,CGS,CRS,DAN,EBA,EBE,EBP,EFT,EGI,EIE,EIG,ELB,ESI,ESJ,ESN,FPI,GCM,GMK,HBJ,HGD,HJB,HJJ,HJK,HMY,HPJ,HSH,HSI,HSJ,HST,HTJ,HYD,ICB,IKC,IDC,IVN,IWB,JGS,JJJ,JRO,JWB,JYB,JYK,KAA,KAD,KAE,KBG,KBH,KEC,KED,KEE,KFL,KGA,KIG,KIS,KJI,KJJ,KJW,KKT,KMB,KOK,KVN,KSI,KSJ,KSN,KTN,KWB,LGC,MCI,MFB,NKS,NOV,OTP,PAE,PBS,PDM,PGS,PID,POS,PPC,SBJ,SBK,SDS,SHI,SIA,SIC,SIN,SKW,SUP,SWB,THD,TPP,TXA,UNS,UJR,WHJ,WNS,ZLO
// 127.0.0.1 _DAO_IN_SNA_AsR{DAO_IN_SNA_AsR_i11} 2019.10.10 08:06:20 ACM,ARS,ATS,B2B,BBA,BBG,BBS,BCN,BWB,CAQ,CAV,CBF,CBG,CDB,CDC,CDG,CDF,CDH,CDM,CDS,CFF,CFH,CFK,CFS,CFZ,CGK,CGS,CRS,DAN,EBA,EBE,EBP,EFT,EGI,EIE,EIG,ELB,ESI,ESJ,ESN,FPI,GCM,GMK,HBJ,HGD,HJB,HJJ,HJK,HMY,HPJ,HSH,HSI,HSJ,HST,HTJ,HYD,ICB,IKC,IDC,IVN,IWB,JGS,JJJ,JRO,JWB,JYB,JYK,KAA,KAD,KAE,KBG,KBH,KEC,KED,KEE,KFL,KGA,KIG,KIS,KJI,KJJ,KJW,KKT,KMB,KOK,KVN,KSI,KSJ,KSN,KTN,KWB,LGC,MCI,MFB,NKS,NOV,OTP,PAE,PBS,PDM,PGS,PID,POS,PPC,SBJ,SBK,SDS,SHI,SIA,SIC,SIN,SKW,SUP,SWB,THD,TPP,TXA,UNS,UJR,WHJ,WNS,ZLO
// 127.0.0.1 _DAO_IN_SNA_AsR{DAO_IN_SNA_AsR_i11} 2019.10.10 08:06:20 ACM,ARS,ATS,B2B,BBA,BBG,BBS,BCN,BWB,CAQ,CAV,CBF,CBG,CDB,CDC,CDG,CDF,CDH,CDM,CDS,CFF,CFH,CFK,CFS,CFZ,CGK,CGS,CRS,DAN,EBA,EBE,EBP,EFT,EGI,EIE,EIG,ELB,ESI,ESJ,ESN,FPI,GCM,GMK,HBJ,HGD,HJB,HJJ,HJK,HMY,HPJ,HSH,HSI,HSJ,HST,HTJ,HYD,ICB,IKC,IDC,IVN,IWB,JGS,JJJ,JRO,JWB,JYB,JYK,KAA,KAD,KAE,KBG,KBH,KEC,KED,KEE,KFL,KGA,KIG,KIS,KJI,KJJ,KJW,KKT,KMB,KOK,KVN,KSI,KSJ,KSN,KTN,KWB,LGC,MCI,MFB,NKS,NOV,OTP,PAE,PBS,PDM,PGS,PID,POS,PPC,SBJ,SBK,SDS,SHI,SIA,SIC,SIN,SKW,SUP,SWB,THD,TPP,TXA,UNS,UJR,WHJ,WNS,ZLO
while (linePoint > -1) {
Map map = new HashMap();
// 한 라인만을 읽어 온다.
String line = result.substring(0, linePoint);
result = result.substring(linePoint + 1);
// 리스트 부분만
if ((line.indexOf("======") < 0) && (line.indexOf("-----") < 0) && (line.indexOf("WCA") < 0)
&& (line.indexOf("[") != 0)) {
logger.info("line : " + line);
StringTokenizer st = new StringTokenizer(line);
int stCount = 0;
String regTime = "";
while (st.hasMoreTokens()) {
String t = st.nextToken();
//System.out.println(t);
switch (stCount) {
case 0:
map.put("wcaIp", t.trim());
break;
case 1:
map.put("adapterName", t.trim());
break;
case 2:
regTime = t.trim();
break;
case 3:
map.put("codeRegDate", regTime + " " + t.trim());
break;
case 4:
map.put("appCode", t.trim());
break;
}
stCount++;
} // end of while
if (map.size() >= 3) {
list.add(map);
}
}
linePoint = result.indexOf("\n");
}
return list;
} // end of refresh
/**
* <pre>
* 1. 기능 : Lu 모드에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
// private String getLuModeToolTip(String code) {
//
// String result = "";
//
// if (code.equals("SENDONLY")) {
//
// result = "전문 타입의 Non-Response 모드로 호스트로 데이터 송신만을 수행";
//
// } else if (code.equals("RECVONLY")) {
//
// result = "전문 타입의 Non-Response 모드로 호스트로부터 데이터 수신만을 수행";
//
// } else if (code.equals("SENDRECV")) {
//
// result = "전문 타입의 Response 모드로 호스트와 데이터 송수신 수행";
//
// } else if (code.equals("TERMINAL")) {
//
// result = "단말 타입의 Response 모드로 호스트와 데이터 송수신 수행";
//
// }
//
// return result;
//
// }
/**
* <pre>
* 1. 기능 : Tran 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
// private String getTranStateToolTip(String code) {
//
// String result = "";
//
// if (code.equals("NOTREADY")) {
//
// result = "Transaction을 수행할 수 없는 상태";
//
// } else if (code.equals("READY")) {
//
// result = "Transaction을 수행할 수 있는 상태";
//
// } else if (code.equals("SEND")) {
//
// result = "호스트로부터 데이터를 송신하고 있는 상태";
//
// } else if (code.equals("RECV")) {
//
// result = "호스트로부터 데이터를 수신 대기하고 있는 상태";
//
// }
//
// return result;
//
// }
/**
* <pre>
* 1. 기능 : Lu 세부 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
// private String getLuDetailStateToolTip(String code) {
//
// String result = "";
//
// if (code.equals("API_ERROR")) {
//
// result = "SNA Gateway 내부 장애가 발생한 상태";
//
// } else if (code.equals("NOT_DEF")) {
//
// result = "LU가 정의되지 않은 상태";
//
// } else if (code.equals("LINK_DOWN")) {
//
// result = "호스트와의 SNA Link가 Down된 상태";
//
// } else if (code.equals("NET_DOWN")) {
//
// result = "호스트와의 Network가 Down된 상태";
//
// } else if (code.equals("DISCONN")) {
//
// result = "호스트와의 LU 세션이 해제된 상태";
//
// }
//
// return result;
//
// }
/**
* <pre>
* 1. 기능 : Lu 상태에 대한 툴팁정보를 얻는다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.7 $
* @since : rts 1.0
* @param code
* @return
*/
// private String getLuStateToolTip(String code) {
//
// String result = "";
//
// if (code.equals("DOWN")) {
//
// result = "호스트와 세션이 해제된 상태";
//
// } else if (code.equals("TRY_INIT")) {
//
// result = "호스트와 세션을 연결하기 위한 자원 초기화 상태";
//
// } else if (code.equals("TRY_INITSELF")) {
//
// result = "호스트로 INIT-SELF 데이터를 송신하는 상태";
//
// } else if (code.equals("WAIT_BIND")) {
//
// result = "호스트로부터 BIND 데이터를 수신 대기하는 상태";
//
// } else if (code.equals("WAIT_SDT")) {
//
// result = "호스트로부터 SDT 데이터를 수신 대기하는 상태";
//
// } else if (code.equals("UP")) {
//
// result = "호스트와 LU-LU 세션이 연결된 상태";
//
// } else if (code.equals("TRY_TERMSELF")) {
//
// result = "호스트로 TERM-SELF 데이터를 송신하는 상태";
//
// } else if (code.equals("WAIT_UNBIND")) {
//
// result = "호스트로부터 UNBIND 데이터를 수신 대기하는 상태";
//
// } else if (code.equals("TRY_TERM")) {
//
// result = "호스트와 세션을 해제하기 위한 자원 해제 상태";
//
// } else if (code.equals("RECV_UNBIND")) {
//
// result = "호스트로부터 UNBIND를 수신한 상태";
//
// }
//
// return result;
//
// }
/**
* <pre>
* 1. 기능 : Sna 명령어 실행
* 2. 처리 개요 :
* - SnaStart, SnaStop 명령어 실행
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param form
* @return
*/
public List executeStartStop(HashMap<String,Object> paramMap) {
// 명령어
String cmd = paramMap.get("snaStatusCmd").toString();
logger.info("SnaStartStop Cmd : " + cmd);
return executeCmd(cmd);
} // end of refresh
/**
* <pre>
* 1. 기능 : 명령을 실행후 결과를 반환한다.
* 2. 처리 개요 :
* - 명령어를 실행후 결과를 반환한다.
* </pre>
* @author : 이동철
* @version : $Revision: 1.8 $
* @since : rts 1.0
* @param cmd
* @return
*/
private List executeCmd(String cmd) {
List list = new ArrayList();
// 명령어의 경로를 얻는다.
String cmdPath = monitoringContext.getStringProperty(
MonitoringContext.SNA_STATUS_PATH,
"/fsapp/eai/SNAAdapter/bin/");
String command = cmdPath + cmd;
String result = execCommand(command);
Map map = new HashMap();
if ((result.trim()).length() > 0) {
map.put("msg", result.trim());
} else {
map.put("msg", "명령처리에 실패 하였습니다.");
}
list.add(map);
return list;
}
}
@@ -0,0 +1,186 @@
package com.eactive.eai.rms.onl.adapter.sna;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.google.gson.Gson;
@Controller
public class SnaWcaStatusController extends BaseController{
private final String AGENT_PAGE_STATUS = "adapter_sna_status_agent.jsp";
private final String AGENT_PAGE_STARTSTOP = "adapter_startstop_agent.jsp";
private final String AGENT_PAGE_BACKUP = "adapter_sna_backup_change_agent.jsp";
private final String ADAPTER_TYPE = "SNA";
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value= "/onl/adapter/sna/snaWcaStatusMan.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaStatusMan.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,@RequestParam HashMap<String,Object> paramMap
) {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
if (serverList.isEmpty()) {
throw new BizException("서버리스트가 없습니다.");
}
List<String> urls = new ArrayList<>();
for (EAIServer serverMap : serverList)
{
String url = "http://" + serverMap.getEaisevrip() + ":"
+ serverMap.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_STATUS + "?eaiSvrInstNm="
+ serverMap.getEaisevrinstncname() + "&adapterType="
+ ADAPTER_TYPE;
urls.add(url);
logger.info(url);
}
String searchAdapterGroup = (String)paramMap.get("searchAdapterGroup");
String searchAdapter = (String)paramMap.get("searchAdapter");
HashMap<String,String> filter = new HashMap<>();
if (searchAdapterGroup !=null && !"".equals(searchAdapterGroup)){
filter.put("AdapterGroup",searchAdapterGroup);
}
if (searchAdapter !=null && !"".equals(searchAdapter)){
filter.put("Adapter",searchAdapter);
}
DataSetUtil gUtil = new DataSetUtil();
gUtil.setFilter(filter);
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(urls);
Map resultMap = new HashMap();
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaStatusMan.json", params = "cmd=TRANSACTION_STARTSTOP")
private ModelAndView transactionStartStop(HttpServletRequest request,String eaiInstanceName, String adapterGroupNm,String adapterNm, String adapterStartStop) throws Exception {
String result = null;
EAIServer selectedServer = eaiServerService
.getByEaiSevrInstncName(eaiInstanceName);
// 호출할 Agent Page
String url = "http://" + selectedServer.getEaisevrip() + ":"
+ selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_STARTSTOP
+ "?adapterType=" + ADAPTER_TYPE
+ "&adapterGroupNm=" + adapterGroupNm
+ "&adapterNm=" + adapterNm
+ "&adapterStartStop=" + adapterStartStop;
logger.info(url);
// Agent를 호출한다.
CallAgentUtil agent = new CallAgentUtil();
result = agent.getAgentDataToString(url);
Map resultMap = new HashMap();
resultMap.put("message", result); // 전체 페이지수
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaStatusMan.json", params = "cmd=TRANSACTION_BACKUP")
public ModelAndView transactionBackUp(HttpServletRequest request,String eaiInstanceName, String adapterGroupNm,String luGroupNm, String backupMode) throws Exception {
String result = null;
EAIServer selectedServer = eaiServerService
.getByEaiSevrInstncName(eaiInstanceName);
// 호출할 Agent Page
String url = "http://" + selectedServer.getEaisevrip() + ":"
+ selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_BACKUP + "?"
+ "adapterType=" + ADAPTER_TYPE
+ "&adapterGroupNm=" + adapterGroupNm
+ "&luGroupNm=" + luGroupNm
+ "&backupMode=" + backupMode;
logger.info(url);
// Agent를 호출한다.
CallAgentUtil agent = new CallAgentUtil();
result = agent.getAgentDataToString(url);
Map resultMap = new HashMap();
resultMap.put("message", result); // 전체 페이지수
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/sna/snaWcaStatusMan.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, String gridData, String header, String headerTitle, String fileName, String merge) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
String[] headers = gson.fromJson(header, String[].class);
String[] headerTitles = gson.fromJson(headerTitle, String[].class);
HashMap<String, Object>[] lmerge = null;
if (merge !=null){
lmerge = gson.fromJson(merge, HashMap[].class);
}
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", list);
resultMap.put("fileName", fileName);
resultMap.put("merge", lmerge);
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,27 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.util.Comparator;
import java.util.HashMap;
public class MapComparator implements Comparator<HashMap<String, Object>>{
private final String[] key ;
public MapComparator(String[] key){
this.key = key;
}
@Override
public int compare(HashMap<String, Object> first, HashMap<String, Object> second){
int result = 0;
for(int i=0; i< key.length;i++){
if(first.get(key[i]) == null || second.get(key[i]) == null) {
continue;
}
result = ((String) first.get(key[i])).compareTo((String) second.get(key[i]));
if(result != 0) break;
}
return result;
}
}
@@ -0,0 +1,168 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.login.SessionManager;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.common.vo.SimpleResponse;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.eactive.eai.rms.onl.manage.adapter.adapter.AdapterManService;
import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterGroupUI;
import com.google.gson.Gson;
/**
* <pre>
* 1. 기능 : Socket 상태 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.3 $
* @since : rts 1.0
*/
@Controller
public class SocketConnectionController extends BaseController {
private final String AGENT_PAGE_STATUS = "adapter_socket2_agent3.jsp";
private final String AGENT_PAGE_STARTSTOP = "adapter_socket2_close.jsp";
private ComboService comboService;
private AdapterManService adapterManService;
private EAIServerService eaiServerService;
@Autowired
protected SocketConnectionController(ComboService comboService, AdapterManService adapterManService,
EAIServerService eaiServerService) {
this.comboService = comboService;
this.adapterManService = adapterManService;
this.eaiServerService = eaiServerService;
}
@RequestMapping(value = "/onl/adapter/socket/socketConnection.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@PostMapping(value = "/onl/adapter/socket/socketConnection.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<HashMap<String, Object>>> selectList(HttpServletRequest request,
String searchEaiSevrInstncName, String searchAdptrBzwkGroupName) {
List<EAIServer> serverList = new ArrayList<>();
if (StringUtils.isEmpty(searchEaiSevrInstncName)) {
serverList.addAll(eaiServerService.selectEaiServerIpList());
} else {
serverList.add(eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName));
}
if (serverList.isEmpty()) {
throw new BizException("서버리스트가 없습니다.");
}
List<String> urlList = new ArrayList<>();
for (EAIServer serverMap : serverList) {
String url = "http://" + serverMap.getEaisevrip() + ":" + serverMap.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STATUS + "?eaiSvrInstNm="
+ serverMap.getEaisevrinstncname() + "&adapterGroupName=" + searchAdptrBzwkGroupName;
logger.debug(url);
urlList.add(url);
}
DataSetUtil gUtil = new DataSetUtil();
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(urlList);
return ResponseEntity.ok(new GridResponse<>(list));
}
@PostMapping(value = "/onl/adapter/socket/socketConnection.json", params = "cmd=TRANSACTION_STARTSTOP")
public ResponseEntity<SimpleResponse> transactionStartStop(HttpServletRequest request,
String searchEaiSevrInstncName, String adptrBzwkGroupName, String adptrBzwkName, String remoteAddress,
String localAddress, String session) throws Exception {
EAIServer eaiServer = eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName);
String url = "http://" + eaiServer.getEaisevrip() + ":" + eaiServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STARTSTOP;
// cmd 는 start/stop
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("adapterGroupName", adptrBzwkGroupName),
new NameValuePair("adapterName", adptrBzwkName), new NameValuePair("remoteAddress", remoteAddress),
new NameValuePair("localAddress", localAddress), new NameValuePair("sessionName", session) };
// Agent를 호출한다.
CallAgentUtil util = new CallAgentUtil();
String message = util.getAgentDataToString(url, postParameters);
return ResponseEntity.ok(SimpleResponse.of(message));
}
@RequestMapping(value = "/onl/adapter/socket/socketConnection.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
// 업무구분
List<ComboVo> instanceList = comboService.getFromEAIServerWithoutAll();
List<AdapterGroupUI> adapterList = adapterManService.selectSocketAdapterGroup("NET");
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("instanceList", instanceList);
resultMap.put("adapterList", adapterList);
return new ModelAndView("jsonView", resultMap);
}
@RequestMapping(value = "/onl/adapter/socket/socketConnection.excel", params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response,
@RequestParam HashMap<String, Object> paramMap) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
Gson gson = new Gson();
String jsonStr = (String) paramMap.get("gridData");
HashMap<String, Object>[] dataList = gson.fromJson(jsonStr, HashMap[].class);
String[] headers = gson.fromJson((String) paramMap.get("header"), String[].class);
String[] headerTitles = gson.fromJson((String) paramMap.get("headerTitle"), String[].class);
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", dataList);
resultMap.put("fileName", (String) paramMap.get("fileName"));
ModelAndView modelAndView = new ModelAndView("excelView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,139 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
@Controller
public class SocketErrorContentsController extends BaseController {
private final String AGENT_PAGE = "adapter_log_agent.jsp";
@Autowired
@Qualifier("monitoringContext")
private MonitoringContext monitoringContext;
@Autowired
@Qualifier("comboService")
private ComboService comboService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value = "/onl/adapter/socket/socketErrorContents.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/adapter/socket/socketErrorContents.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
// 업무구분
List<ComboVo> instanceList = comboService.getFromEAIServerWithoutAll();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("instanceList", instanceList);
return new ModelAndView("jsonView", resultMap);
}
@RequestMapping(value = "/onl/adapter/socket/socketErrorContents.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request, JsonPageVo pageVo, String searchEaiSevrInstncName,
String searchText) throws Exception {
EAIServer selectedServer = eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName);
// LOG 파일 위치 프라퍼티로
String defaultLogPath = monitoringContext.getStringProperty(MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/");
String socketErrorLogFile = monitoringContext
.getStringProperty(MonitoringContext.SOCKET_ERROR_LOG_FILE, "netAdapterError.log");
String logPath = "";
if (defaultLogPath == null || defaultLogPath.equals("")) {
logPath = "/fslog/eai/" + searchEaiSevrInstncName + socketErrorLogFile;
} else {
logPath = defaultLogPath + searchEaiSevrInstncName + "/" + socketErrorLogFile;
}
// http://192.168.68.21:30311/ONLWeb/agent/host/adapter_log_agent.jsp?fileName=/fslog/eai/EAIDS01_i01/netAdapter.log
// searchText=[찾으려는값]
// checkHead=[라인의 시작문자]
// skipLineCount=[이전페이지의 마지막 라인수]
String url = "http://" + selectedServer.getEaisevrip() + ":" + selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE + "?fileName=" + logPath + "&searchText="
+ URLEncoder.encode(searchText);
logger.info("url : " + url);
CallAgentUtil util = new CallAgentUtil();
List<HashMap<String, Object>> list = new ArrayList<>();
HashMap map = null;
String result = util.getAgentDataToString(url);
int linePoint = 0;
// 정보를 라인단위로 파싱하여
if (result != null) {
linePoint = result.indexOf("\n");
}
while (linePoint > -1) {
map = new HashMap();
// 한 라인만을 읽어 온다.
String line = null;
if (result != null) {
line = result.substring(0, linePoint);
}
if (result != null) {
result = result.substring(linePoint + 1);
}
map.put("logContent", line);
list.add(map);
linePoint = result.indexOf("\n");
}
Map resultMap = new HashMap();
resultMap.put("total", pageVo.getTotal()); // 전체 페이지수
resultMap.put("page", pageVo.getPage()); // 현재 페이지수
resultMap.put("records", pageVo.getTotalCount());// 전체 레코드건수
resultMap.put("rows", list);
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,354 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.google.gson.Gson;
/**
* <pre>
* 1. 기능 : SOCKET 로그 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* Xml을 수신하지 않고 String을 받아 처리한다.(CallAgentUtil 이용)
* 이전 로컬 WAS에서 Service단에서 Agent없이 조회하던 방식
* 방식 변경(2008/05/21) --> Agent
* Agent(2008/04까지) --> Local WAS(2008/04 이후) --> Agent(2008/05/21이후)
*
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
*/
@Controller
public class SocketLogContentsController extends BaseController {
// private final String AGENT_PAGE = "/adapter/socket/adapter_socket_log_content_agent.jsp";
private final String AGENT_PAGE = "adapter_log_agent.jsp";
@Autowired
private MonitoringContext monitoringContext;
@Autowired
private ComboService comboService;
@Autowired
private EAIServerService eaiServerService;
/*
* /adapter/socket/adapter_socket_log_content.jsp
* /adapter/socket/adapter_socket_log_content_data.jsp
* /adapter/socket/adapter_socket_log_content_agent.jsp
*/
@RequestMapping(value= "/onl/adapter/socket/socketLogContents.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value = "/onl/adapter/socket/socketLogContents.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
List<ComboVo> instanceList = comboService.getFromEAIServerWithoutAll();
List<ComboVo> loglevelList = comboService.getFromCode("SNA_SEARCH_LOGLEVEL");
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("instanceList", instanceList);
resultMap.put("logLevelRows", loglevelList);
return new ModelAndView("jsonView", resultMap);
}
@RequestMapping(value= "/onl/adapter/socket/socketLogContents.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,String searchEaiSevrInstncName , String searchLogLevel, String searchText) throws Exception {
EAIServer selectedServer = eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName);
//LOG 파일 위치 프라퍼티로
String defaultLogPath = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/");
String socketLogFile = monitoringContext.getStringProperty(
MonitoringContext.SOCKET_LOG_FILE, "netAdapter.log");
String logPath = "";
logger.info("defaultLogPath : "+defaultLogPath);
if (defaultLogPath == null || defaultLogPath.equals("")) {
logPath = "/fslog/eai/" + searchEaiSevrInstncName + socketLogFile;
} else {
logPath = defaultLogPath + searchEaiSevrInstncName + "/"
+ socketLogFile;
}
logger.info("logPath : "+logPath);
//http://192.168.68.21:30311/ONLWeb/agent/host/adapter_log_agent.jsp?logLevel=TOTAL&fileName=/fslog/eai/EAIDS01_i01/netAdapter.log
//searchText=[찾으려는값]
//checkHead=[라인의 시작문자]
//skipLineCount=[이전페이지의 마지막 라인수]
String url = "http://" + (String) selectedServer.getEaisevrip() + ":"
+ (String) selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE
+ "?logLevel=" + searchLogLevel
+ "&fileName=" + logPath
+ "&searchText=" + URLEncoder.encode(searchText)
;
logger.info("url : "+url);
CallAgentUtil util = new CallAgentUtil();
List<HashMap<String, Object>> list = new ArrayList<>();
HashMap map = null;
String result = util.getAgentDataToString(url);
int linePoint = 0;
// 정보를 라인단위로 파싱하여
if(result != null){
linePoint = result.indexOf("\n");
}
while (linePoint > -1) {
map = new HashMap();
// 한 라인만을 읽어 온다.
String line = null;
if(result != null){
line = result.substring(0, linePoint);
}
result = result.substring(linePoint + 1);
map.put("logContent", line);
list.add(map);
linePoint = result.indexOf("\n");
}
Map resultMap = new HashMap();
resultMap.put("total" , pageVo.getTotal()); //전체 페이지수
resultMap.put("page" , pageVo.getPage()); //현재 페이지수
resultMap.put("records", pageVo.getTotalCount());//전체 레코드건수
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
/**
* <pre>
* 1. 기능 : SOCKET 로그 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 : Overriden
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/onl/adapter/socket/socketLogContents.do")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//Map model = this.createModel(request);
ErrorContentForm form = new ErrorContentForm();
// parameter 설정
form.setEaiSvrInstNm(request.getParameter("eaiSvrInstNm"));
form.setEaiSvrIp(request.getParameter("eaiSvrIp"));
form.setEaiSvrLsnPort(request.getParameter("eaiSvrLsnPort"));
form.setAgentPage(AGENT_PAGE);
form.setSearchText(request.getParameter("searchText"));
form.setLogLevel(request.getParameter("logLevel"));
String cmd = request.getParameter("cmd");
// try {
// // adapter.socket2.findLogContentsAgent
// if ("SELECT_LIST".equals(cmd)) {
// getLogList(request, response, form);
// }
// } catch (BizException be) {
// //be.printStackTrace();
// logger.error("[BIZ ERROR]");
// ((HttpGauceResponse) response).addException(be);
// } catch (SysException se) {
// //se.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(se);
// } catch (Exception e) {
// //e.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(e);
// } finally {
// GauceOutputStream gos = null;
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
// if (gos != null) {
// try {
// gos.close();
// } catch (Exception e) {
// gos = null;
// }
// }
// }
return null;
}
/**
* <pre>
* 1. 기능 : 로그 리스트 조회
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 2.0
* @param request
* @param response
* @param form
* @throws ServletException
* @throws IOException
*/
private void getLogList(HttpServletRequest request,
HttpServletResponse response, ErrorContentForm form)
throws Exception {
String url = form.getWebAgentPath();
// YUN_DEBUG (2008.05.22)
// local 에서 테스트 하기 위해 default 값을 사용함
String defaultLogPath = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/");
String socketLogFile = monitoringContext.getStringProperty(
MonitoringContext.SOCKET_LOG_FILE, "netAdapter.log");
String logPath = "";
if (defaultLogPath == null || defaultLogPath.equals("")) {
logPath = "/fslog/eai/" + form.getEaiSvrInstNm() + socketLogFile;
} else {
logPath = defaultLogPath + form.getEaiSvrInstNm() + "/"
+ socketLogFile;
}
// 파라미터에 특수문자가 포함되어 있으므로 Post 방식으로 WebMethod를 실행해야 한다.
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("fileName", logPath),
new NameValuePair("logLevel", form.getLogLevel()),
new NameValuePair("searchText", form.getSearchText()) };
// debug
logger.debug("SocketLogContentsController:getLogList()");
logger.debug("url=" + url);
for (int i = 0; i < postParameters.length; i++) {
logger.debug("param:" + postParameters[i].getName() + " : ["
+ postParameters[i].getValue() + "]");
}
// GauceInputStream gis = null;
// GauceOutputStream gos = null;
//
// try {
// gis = ((HttpGauceRequest) request).getGauceInputStream();
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
// GauceDataSet dataSet = gis.read("ds_01");
//
// // Agent를 호출한다.
// CallAgentUtil util = new CallAgentUtil();
// String result = util.getAgentDataToString(url, postParameters);
// String arrResult[] = null;
// if(result != null){
// arrResult = result.split("\n");
// }
//
// // YUN_DEBUG : (2008.05.22) 로그 데이터를 역순으로 출력한다.
// if(arrResult != null){ //취약점소스 수정 2020.08.24
// for (int i = arrResult.length - 1; i >= 0; i--) {
// dataSet.put("sline", arrResult[i], 1000,
// GauceDataColumn.TB_NORMAL);
// dataSet.heap();
// }
// }
//
//
// gos.write(dataSet);
// } catch (Exception e) {
// throw e;
// }
}
@RequestMapping(value= "/onl/adapter/socket/logInfoMation.view")
private String viewLogInfoMation(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/socket/socketLogContents.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String,Object> paramMap) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
String jsonStr = (String)paramMap.get("gridData");
HashMap<String, Object>[] dataList = gson.fromJson(jsonStr, HashMap[].class);
String[] headers = gson.fromJson((String) paramMap.get("header"), String[].class);
String[] headerTitles = gson.fromJson((String)paramMap.get("headerTitle"), String[].class);
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", dataList);
resultMap.put("fileName", (String)paramMap.get("fileName"));
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,173 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.eactive.eai.rms.onl.manage.adapter.adapter.AdapterManService;
import com.google.gson.Gson;
import edu.emory.mathcs.backport.java.util.Collections;
/**
* <pre>
* 1. 기능 : Socket 상태 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.3 $
* @since : rts 1.0
*/
@Controller
public class SocketProcessController extends BaseController{
private final String AGENT_PAGE_STATUS = "adapter_socket2_agent2.jsp";
@Autowired
private AdapterManService adapterManService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value= "/onl/adapter/socket/socketProcess.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/socket/socketProcess.json",params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo( HttpServletRequest request,
HttpServletResponse response) throws Exception {
List listRealTimeGroup = adapterManService.selectListRealTimeGroup();
Map resultMap = new HashMap();
resultMap.put("realTimeGroupRows" , listRealTimeGroup);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/socket/socketProcess.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,String searchType , String searchAdapterGroup, String searchRealTimeCd
) throws Exception {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
if(serverList.isEmpty()) {
throw new BizException("서버리스트가 없습니다.");
}
List<String> urls = new ArrayList<>();
for (EAIServer serverMap : serverList)
{
String url = "http://" + serverMap.getEaisevrip() + ":"
+ serverMap.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_STATUS + "?cmd=get+connection+summary"
+ "&eaiSvrInstNm=" + serverMap.getEaisevrinstncname();
logger.debug(url);
urls.add(url);
}
HashMap<String,String> filter = new HashMap<>();
if (searchAdapterGroup !=null && !"".equals(searchAdapterGroup)){
filter.put("AdptrBzwkGroupName",searchAdapterGroup);
}
if ("ERR".equals(searchType)){
filter.put("Status", "false"); // 어댑터 상태
filter.put("Starting", "STOPPED"); // 기동상태
}
else if ("24H".equals(searchType)){
filter.put("Param8", "1"); // 24시업무여부
}
else if ("24E".equals(searchType)){
filter.put("Param8", "1"); // 24시업무여부
filter.put("Status", "false"); // 어댑터 상태
filter.put("Starting", "STOPPED"); // 기동상태
}
else if("GRP".equals(searchType))
{
filter.put("Param7", searchRealTimeCd); // 24시업무명
}
DataSetUtil gUtil = new DataSetUtil();
gUtil.setFilter(filter);
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(urls);
pageVo.setTotalCount(list.size());
//어댑터 업무그룹별 정렬
String[] compareParam = {"AdptrBzwkGroupName","EaiSevrInstncName"};
MapComparator comp = new MapComparator(compareParam);
Collections.sort(list,comp);
Map resultMap = new HashMap();
resultMap.put("total" , pageVo.getTotal()); //전체 페이지수
resultMap.put("page" , pageVo.getPage()); //현재 페이지수
resultMap.put("records", pageVo.getTotalCount());//전체 레코드건수
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@SuppressWarnings("unchecked")
@RequestMapping(value= "/onl/adapter/socket/socketProcess.excel",params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, String gridData, String header, String headerTitle, String fileName, String merge) throws Exception {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
Gson gson = new Gson();
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
String[] headers = gson.fromJson(header, String[].class);
String[] headerTitles = gson.fromJson(headerTitle, String[].class);
HashMap<String, Object>[] lmerge = null;
if (merge !=null){
lmerge = gson.fromJson(merge, HashMap[].class);
}
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", list);
resultMap.put("fileName", fileName);
resultMap.put("merge", lmerge);
ModelAndView modelAndView = new ModelAndView("excelView",resultMap);
return modelAndView;
}
}
@@ -0,0 +1,182 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import com.eactive.eai.rms.onl.manage.adapter.adapter.AdapterManService;
import com.google.gson.Gson;
import edu.emory.mathcs.backport.java.util.Collections;
/**
* <pre>
* 1. 기능 : Socket 상태 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.3 $
* @since : rts 1.0
*/
@Controller
public class SocketStatusController extends BaseController {
private final String AGENT_PAGE_STATUS = "adapter_socket2_agent1.jsp";
private final String AGENT_PAGE_STARTSTOP = "adapter_socket2_startstop.jsp";
@Autowired
private AdapterManService adapterManService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value = "/onl/adapter/socket/socketStatus.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/adapter/socket/socketStatus.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) throws Exception {
List listRealTimeGroup = adapterManService.selectListRealTimeGroup();
Map resultMap = new HashMap();
resultMap.put("realTimeGroupRows", listRealTimeGroup);
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
@PostMapping(value = "/onl/adapter/socket/socketStatus.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<HashMap<String, Object>>> selectList(HttpServletRequest request,
String searchType, String searchAdapterGroup, String searchRealTimeCd) {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
if (serverList.isEmpty()) {
throw new BizException("서버리스트가 없습니다.");
}
List<String> urls = new ArrayList<>();
for (EAIServer serverMap : serverList) {
String url = "http://" + serverMap.getEaisevrip() + ":" + serverMap.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STATUS + "?adapterType=SOC"
+ "&eaiSvrInstNm=" + serverMap.getEaisevrinstncname();
urls.add(url);
logger.debug(url);
}
HashMap<String, String> filter = new HashMap<>();
if (searchAdapterGroup != null && !"".equals(searchAdapterGroup)) {
filter.put("AdptrBzwkGroupName", searchAdapterGroup);
}
if ("ERR".equals(searchType)) {
filter.put("Status", "false"); // 어댑터 상태
filter.put("Starting", "STOPPED"); // 기동상태
} else if ("24H".equals(searchType)) {
filter.put("Param8", "1"); // 24시업무여부
} else if ("24E".equals(searchType)) {
filter.put("Param8", "1"); // 24시업무여부
filter.put("Status", "false"); // 어댑터 상태
filter.put("Starting", "STOPPED"); // 기동상태
} else if ("GRP".equals(searchType)) {
filter.put("Param7", searchRealTimeCd); // 24시업무명
}
DataSetUtil gUtil = new DataSetUtil();
gUtil.setFilter(filter);
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(urls);
// 어댑터 업무그룹별 정렬
String[] compareParam = { "AdptrBzwkGroupName", "EaiSevrInstncName", "AdptrBzwkName" };
MapComparator comp = new MapComparator(compareParam);
Collections.sort(list, comp);
return ResponseEntity.ok(new GridResponse<>(list));
}
@RequestMapping(value = "/onl/adapter/socket/socketStatus.json", params = "cmd=TRANSACTION_STARTSTOP")
public ModelAndView transactionStartStop(HttpServletRequest request, String eaiInstanceName, String control,
String adapterGroupName, String adapterName) throws Exception {
EAIServer selectedServer = eaiServerService.getByEaiSevrInstncName(eaiInstanceName);
String url = "http://" + selectedServer.getEaisevrip() + ":" + selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH + AGENT_PAGE_STARTSTOP;
// cmd 는 start/stop
NameValuePair[] postParameters = new NameValuePair[] { new NameValuePair("cmd", control),
new NameValuePair("adapterGroupName", adapterGroupName),
new NameValuePair("adapterName", adapterName) };
// Agent를 호출한다.
CallAgentUtil util = new CallAgentUtil();
String message = util.getAgentDataToString(url, postParameters);
Map resultMap = new HashMap();
resultMap.put("message", message); // 전체 페이지수
return new ModelAndView("jsonView", resultMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/onl/adapter/socket/socketStatus.excel", params = "cmd=LIST_GRID_TO_EXCEL")
public ModelAndView listGridToExcel(HttpServletRequest request, HttpServletResponse response, String gridData,
String header, String headerTitle, String fileName, String merge) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
Gson gson = new Gson();
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
String[] headers = gson.fromJson(header, String[].class);
String[] headerTitles = gson.fromJson(headerTitle, String[].class);
HashMap<String, Object>[] lmerge = null;
if (merge != null) {
lmerge = gson.fromJson(merge, HashMap[].class);
}
resultMap.put("headers", headers);
resultMap.put("headerTitles", headerTitles);
resultMap.put("datas", list);
resultMap.put("fileName", fileName);
resultMap.put("merge", lmerge);
ModelAndView modelAndView = new ModelAndView("excelView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,144 @@
package com.eactive.eai.rms.onl.adapter.socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.login.SessionManager;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.CallAgentUtil;
import com.eactive.eai.rms.onl.common.util.DataSetUtil;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
import edu.emory.mathcs.backport.java.util.Collections;
/**
* <pre>
* 1. 기능 : Socket 상태 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.3 $
* @since : rts 1.0
*/
@Controller
public class SocketTrackingController extends BaseController{
private final String AGENT_PAGE_STATUS = "adapter_socket2_trace_agent.jsp";
private final String AGENT_PAGE_STARTSTOP = "adapter_socket2_trace_level.jsp";
@Autowired
@Qualifier("comboService")
private ComboService comboService;
@Autowired
private EAIServerService eaiServerService;
@RequestMapping(value= "/onl/adapter/socket/socketTracking.view")
private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
@RequestMapping(value= "/onl/adapter/socket/socketTracking.json", params = "cmd=LIST")
private ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,String searchEaiSevrInstncName
) throws Exception {
EAIServer selectedServer = eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName);
String url = "http://" + selectedServer.getEaisevrip() + ":"
+ selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_STATUS ;
DataSetUtil gUtil = new DataSetUtil();
List<HashMap<String, Object>> list = gUtil.flushXmlToClient(url);
pageVo.setTotalCount(list.size());
//어댑터 업무그룹별 정렬
String[] compareParam = {"AdptrBzwkGroupName"};
MapComparator comp = new MapComparator(compareParam);
Collections.sort(list,comp);
Map resultMap = new HashMap();
resultMap.put("total" , pageVo.getTotal()); //전체 페이지수
resultMap.put("page" , pageVo.getPage()); //현재 페이지수
resultMap.put("records", pageVo.getTotalCount());//전체 레코드건수
resultMap.put("rows" , list);
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/adapter/socket/socketTracking.json", params = "cmd=TRANSACTION_STARTSTOP")
public ModelAndView transactionStartStop(HttpServletRequest request,
String searchEaiSevrInstncName, String adptrBzwkGroupName,
String adptrBzwkName, String level) throws Exception {
EAIServer selectedServer = eaiServerService.getByEaiSevrInstncName(searchEaiSevrInstncName);
String url = "http://" + selectedServer.getEaisevrip() + ":"
+ selectedServer.getSevrlsnportname()
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE_STARTSTOP;
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("adapterGroupName", adptrBzwkGroupName ),
new NameValuePair("adapterName" , adptrBzwkName),
new NameValuePair("level" , level)
};
// Agent를 호출한다.
CallAgentUtil util = new CallAgentUtil();
String message = util.getAgentDataToString(url, postParameters);
Map resultMap = new HashMap();
resultMap.put("message", message); // 전체 페이지수
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
@RequestMapping(value = "/onl/adapter/socket/socketTracking.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
List<ComboVo> instanceList = comboService.getFromEAIServerWithoutAll();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("instanceList", instanceList);
return new ModelAndView("jsonView", resultMap);
}
}
@@ -0,0 +1,197 @@
package com.eactive.eai.rms.onl.adapter.socket2.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
/**
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
*/
@Controller
public class SocketErrorContents2Controller extends BaseController {
private final String AGENT_PAGE = "adapter_log_agent.jsp";
@Autowired
@Qualifier("monitoringContext")
private transient MonitoringContext monitoringContext;
// adapter.socket2.errorContents
/*
* /adapter/socket/adapter_socket_error_content.jsp
* /adapter/socket/adapter_socket_error_content_data.jsp
* /adapter/socket/adapter_socket_error_content_agent.jsp
*/
/**
* <pre>
* 1. 기능 : SOCKET 에러 로그 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 : Overriden
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/adapter/socket2/socketErrorContents2.do")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// Map model = new HashMap();
ErrorContentForm form = new ErrorContentForm();
// parameter 설정
form.setEaiSvrInstNm(request.getParameter("eaiSvrInstNm"));
form.setEaiSvrIp(request.getParameter("eaiSvrIp"));
form.setEaiSvrLsnPort(request.getParameter("eaiSvrLsnPort"));
form.setAgentPage(AGENT_PAGE);
form.setSearchText(request.getParameter("searchText")); // 검색안
form.setLogLevel("TOTAL");
String cmd = request.getParameter("cmd");
// try {
// // adapter.socket2.findLogContentsAgent
// if ("SELECT_LIST".equals(cmd)) {
// getLogList(request, response, form);
// }
// } catch (BizException be) {
// //be.printStackTrace();
// logger.error("[BIZ ERROR]");
// ((HttpGauceResponse) response).addException(be);
// } catch (SysException se) {
// // se.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(se);
// } catch (Exception e) {
// //e.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(e);
// } finally {
// GauceOutputStream gos = null;
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
// if (gos != null) {
// try {
// gos.close();
// } catch (Exception e) {
// gos = null;
// }
// }
// }
return null;
}
/**
* <pre>
* 1. 기능 : 로그 리스트 조회
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 2.0
* @param request
* @param response
* @param form
* @throws ServletException
* @throws IOException
*/
private void getLogList(HttpServletRequest request,
HttpServletResponse response, ErrorContentForm form)
throws Exception {
String url = form.getWebAgentPath();
// YUN_DEBUG (2008.05.22)
// local 에서 테스트 하기 위해 default 값을 사용함
String defaultLogPath = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/");
String logPath = "";
if (defaultLogPath == null || defaultLogPath.equals("")) {
logPath = "/fslog/eai/" + form.getEaiSvrInstNm()
+ "/netAdapterError.log";
} else {
logPath = defaultLogPath
+ form.getEaiSvrInstNm()
+ "/"
+ monitoringContext.getStringProperty(
MonitoringContext.SOCKET_ERROR_LOG_FILE,
"netAdapterError.log");
}
// 파라미터에 특수문자가 포함되어 있으므로 Post 방식으로 WebMethod를 실행해야 한다.
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("fileName", logPath),
new NameValuePair("logLevel", form.getLogLevel()),
new NameValuePair("searchText", form.getSearchText()) };
// debug
logger.debug("SocketErrorContentsController:getLogList()");
logger.debug("url=" + url);
for (int i = 0; i < postParameters.length; i++) {
logger.debug("param:" + postParameters[i].getName() + " : ["
+ postParameters[i].getValue() + "]");
}
// GauceInputStream gis = null;
// GauceOutputStream gos = null;
//
// try {
// gis = ((HttpGauceRequest) request).getGauceInputStream();
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
// GauceDataSet dataSet = gis.read("ds_01");
//
// // Agent를 호출한다.
// CallAgentUtil util = new CallAgentUtil();
// String result = util.getAgentDataToString(url, postParameters);
//
// if(result != null){
// String arrResult[] = result.split("\n");
//
// // YUN_DEBUG : (2008.05.22) 로그 데이터를 역순으로 출력한다.
// for (int i = arrResult.length - 1; i >= 0; i--) {
// dataSet.put("sline", arrResult[i], 1000,
// GauceDataColumn.TB_NORMAL);
// dataSet.heap();
// }
// }
//
// gos.write(dataSet);
// } catch (Exception e) {
// throw e;
// }
}
}
@@ -0,0 +1,170 @@
package com.eactive.eai.rms.onl.adapter.socket2.controller;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
/**
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.8 $
* @since : rts 1.0
*/
@Controller
public class SocketErrorInformation2Controller extends BaseController {
private final String AGENT_PAGE = "adapter_socket2_error.jsp";
/**
* <pre>
* 1. 기능 : 어댑터 에러 팝업 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 : Overriden
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.8 $
* @since : rts 2.0
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/adapter/socket2/errorInformation2.do")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String cmd = request.getParameter("cmd");
// try {
// if ("SELECT_LIST".equals(cmd)) {
// getLogList(request, response, model);
// }
// } catch (BizException be) {
// //be.printStackTrace();
// logger.error("[BIZ ERROR]");
// ((HttpGauceResponse) response).addException(be);
// } catch (SysException se) {
// //se.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(se);
// } catch (Exception e) {
// //e.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(e);
// } finally {
// GauceOutputStream gos = null;
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
// if (gos != null) {
// try {
// gos.close();
// } catch (Exception e) {
// gos = null;
// }
// }
// }
return null;
}
/**
* <pre>
* 1. 기능 : 어댑터 에러 리스트 조회
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.8 $
* @since : rts 2.0
* @param request
* @param response
* @param form
* @throws ServletException
* @throws IOException
*/
private void getLogList(HttpServletRequest request, HttpServletResponse response, Map model) throws Exception {
List serverList = (List) model.get("serverList");
String url = null;
String eaiSvrInstNm = request.getParameter("eaiSvrInstNm");
String adapterGrpNm = request.getParameter("adapterGrpNm");
String adptNm = request.getParameter("adptNm");
if(serverList != null){ //취약점소스 수정 2020.08.27
for (int i = 0; i < serverList.size(); i++) {
Map serverMap = (Map) serverList.get(i);
if (serverMap != null && eaiSvrInstNm != null && eaiSvrInstNm.equals((String) serverMap.get("EAISVRINSTNM"))) {
url = "http://" + (String) serverMap.get("EAISVRIP") + ":"
+ (String) serverMap.get("EAISVRLSNPORT")
+ HostInfomationForm.WEB_AGENT_CONTEXT_PATH
+ AGENT_PAGE;
logger.debug(url);
}
}
}
// check url
if (url == null)
throw new BizException("인스턴스명과 동일한 URL이 없습니다.");
// 파라미터에 특수문자가 포함되어 있으므로 Post 방식으로 WebMethod를 실행해야 한다.
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("adapterGroupName", adapterGrpNm),
new NameValuePair("adapterName", adptNm) };
// GauceInputStream gis = null;
// GauceOutputStream gos = null;
//
// try {
// gis = ((HttpGauceRequest) request).getGauceInputStream();
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
// GauceDataSet dataSet = gis.read("ds_01");
//
// // Agent를 호출한다.
// CallAgentUtil util = new CallAgentUtil();
// String result = util.getAgentDataToString(url, postParameters);
// String arrResult[] = null; //취약점소스 수정 2020.08.24
// if(result != null){
// arrResult = result.split("\n");
// }
//
// if (arrResult != null) {
// for (int i = 0; i < arrResult.length; i++) {
// dataSet.put("sline", arrResult[i], 1000,
// GauceDataColumn.TB_NORMAL);
// dataSet.heap();
// }
//
// gos.write(dataSet);
// } else {
// logger.debug("ErrorInformation2Controller: result data is null");
// }
// } catch (Exception e) {
// throw e;
// }
}
}
@@ -0,0 +1,196 @@
package com.eactive.eai.rms.onl.adapter.socket2.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.NameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
/**
* <pre>
* 1. 기능 : SOCKET 로그 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* Xml을 수신하지 않고 String을 받아 처리한다.(CallAgentUtil 이용)
* 이전 로컬 WAS에서 Service단에서 Agent없이 조회하던 방식
* 방식 변경(2008/05/21) --> Agent
* Agent(2008/04까지) --> Local WAS(2008/04 이후) --> Agent(2008/05/21이후)
*
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
*/
@Controller
public class SocketLogContents2Controller extends BaseController {
// private final String AGENT_PAGE = "/adapter/socket/adapter_socket_log_content_agent.jsp";
private final String AGENT_PAGE = "adapter_log_agent.jsp";
@Autowired
@Qualifier("monitoringContext")
private transient MonitoringContext monitoringContext;
/*
* /adapter/socket/adapter_socket_log_content.jsp
* /adapter/socket/adapter_socket_log_content_data.jsp
* /adapter/socket/adapter_socket_log_content_agent.jsp
*/
/**
* <pre>
* 1. 기능 : SOCKET 로그 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 : Overriden
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 1.0
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/adapter/socket2/socketLogContents2.do")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//Map model = this.createModel(request);
ErrorContentForm form = new ErrorContentForm();
// parameter 설정
form.setEaiSvrInstNm(request.getParameter("eaiSvrInstNm"));
form.setEaiSvrIp(request.getParameter("eaiSvrIp"));
form.setEaiSvrLsnPort(request.getParameter("eaiSvrLsnPort"));
form.setAgentPage(AGENT_PAGE);
form.setSearchText(request.getParameter("searchText"));
form.setLogLevel(request.getParameter("logLevel"));
String cmd = request.getParameter("cmd");
// try {
// // adapter.socket2.findLogContentsAgent
// if ("SELECT_LIST".equals(cmd)) {
// getLogList(request, response, form);
// }
// } catch (BizException be) {
// //be.printStackTrace();
// logger.error("[BIZ ERROR]");
// ((HttpGauceResponse) response).addException(be);
// } catch (SysException se) {
// //se.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(se);
// } catch (Exception e) {
// //e.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(e);
// } finally {
// GauceOutputStream gos = null;
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
// if (gos != null) {
// try {
// gos.close();
// } catch (Exception e) {
// gos = null;
// }
// }
// }
return null;
}
/**
* <pre>
* 1. 기능 : 로그 리스트 조회
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.5 $
* @since : rts 2.0
* @param request
* @param response
* @param form
* @throws ServletException
* @throws IOException
*/
private void getLogList(HttpServletRequest request,
HttpServletResponse response, ErrorContentForm form)
throws Exception {
String url = form.getWebAgentPath();
// YUN_DEBUG (2008.05.22)
// local 에서 테스트 하기 위해 default 값을 사용함
String defaultLogPath = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/");
String socketLogFile = monitoringContext.getStringProperty(
MonitoringContext.SOCKET_LOG_FILE, "netAdapter.log");
String logPath = "";
if (defaultLogPath == null || defaultLogPath.equals("")) {
logPath = "/fslog/eai/" + form.getEaiSvrInstNm() + socketLogFile;
} else {
logPath = defaultLogPath + form.getEaiSvrInstNm() + "/"
+ socketLogFile;
}
// 파라미터에 특수문자가 포함되어 있으므로 Post 방식으로 WebMethod를 실행해야 한다.
NameValuePair[] postParameters = new NameValuePair[] {
new NameValuePair("fileName", logPath),
new NameValuePair("logLevel", form.getLogLevel()),
new NameValuePair("searchText", form.getSearchText()) };
// debug
logger.debug("SocketLogContentsController:getLogList()");
logger.debug("url=" + url);
for (int i = 0; i < postParameters.length; i++) {
logger.debug("param:" + postParameters[i].getName() + " : ["
+ postParameters[i].getValue() + "]");
}
// GauceInputStream gis = null;
// GauceOutputStream gos = null;
//
// try {
// gis = ((HttpGauceRequest) request).getGauceInputStream();
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
// GauceDataSet dataSet = gis.read("ds_01");
//
// // Agent를 호출한다.
// CallAgentUtil util = new CallAgentUtil();
// String result = util.getAgentDataToString(url, postParameters);
// String arrResult[] = null;
// if(result != null){
// arrResult= result.split("\n");
// // YUN_DEBUG : (2008.05.22) 로그 데이터를 역순으로 출력한다.
// for (int i = arrResult.length - 1; i >= 0; i--) {
// dataSet.put("sline", arrResult[i], 1000,
// GauceDataColumn.TB_NORMAL);
// dataSet.heap();
// }
// }
//
// gos.write(dataSet);
// } catch (Exception e) {
// throw e;
// }
}
}
@@ -0,0 +1,96 @@
package com.eactive.eai.rms.onl.adapter.socket2.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.spring.BaseController;
/**
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.4 $
* @since : rts 1.0
*/
@Controller
public class SocketLogInfomation2Controller extends BaseController
{
/**
* <pre>
* 1. 기능 : Socket 로그 위치 정보
* 2. 처리 개요 :
* -
* 3. 주의사항 : Overriden
* </pre>
*
* @author : vs.net
* @version : $Revision: 1.4 $
* @since : rts 1.0
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/adapter/socket2/logInfomation2.do")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception
{
String cmd = request.getParameter("cmd");
// try
// {
// if ("SELECT_DEFAULT".equals(cmd))
// {
// getDefaultValue(response);
// }
// }
// catch (BizException be)
// {
// //be.printStackTrace();
// logger.error("[BIZ ERROR]");
// ((HttpGauceResponse) response).addException(be);
// }
// catch (SysException se)
// {
// //se.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(se);
// }
// catch (Exception e)
// {
// //e.printStackTrace();
// logger.error("[SYS ERROR]");
// ((HttpGauceResponse) response).addException(e);
// }
// finally
// {
// GauceOutputStream gos = null;
// gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
// if (gos != null)
// {
// try
// {
// gos.close();
// }
// catch (Exception e)
// {
// gos = null;
// }
// }
// }
return null;
}
}
@@ -0,0 +1,128 @@
package com.eactive.eai.rms.onl.adapter.socket2.service;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
import com.eactive.eai.rms.onl.adapter.socket2.vo.ErrorContentVO;
import com.eactive.eai.rms.onl.common.util.CharsetDecoderUtil;
/**
*
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
* @author : 박기섭, 이동철
* @version : $Revision: 1.4 $
* @since : rts 1.0
*/
@Service("socket2ErrorContentService")
public class SocketErrorContentService {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(SocketErrorContentService.class);
@Autowired
@Qualifier("monitoringContext")
private transient MonitoringContext monitoringContext;
public List execute(ErrorContentForm form) {
int count = 0;
String logLevel = form.getLogLevel();
//---------------------------------------------------------
// 대상 파일명
// (Was 도메인 경로 + Was인스턴스명 + 파일경로) - 이동철
//---------------------------------------------------------
String file_name = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/")
+ form.getEaiSvrInstNm()
+ "/"
+ monitoringContext.getStringProperty(
MonitoringContext.SOCKET_ERROR_LOG_FILE,
"netAdapterError.log");
if (logLevel.equals("TOTAL"))
logLevel = "";
RandomAccessFile randomaccessfile = null;
ArrayList errorContentList = new ArrayList();
ErrorContentVO errorContent = null;
try {
File file = new File(file_name);
randomaccessfile = new RandomAccessFile(file, "r");
long currentPoint = 0L;
randomaccessfile.getFilePointer();
String currentText = null;
//---------------------------------------------------------
// 버프의 내용을 라인씩 읽어 들인다.
//---------------------------------------------------------
do {
// 마지막지점 검색
randomaccessfile.seek(currentPoint);
// 마지막지점의 라인을 읽어온다.
currentText = randomaccessfile.readLine();
if(currentText != null) {
currentText = currentText.trim();
} else {
break;
}
currentPoint = randomaccessfile.getFilePointer();
count++;
if (currentText.length() == 0) {
continue;
}
// 만약 현 라인에 해당 로그 level 이 존재 하지 않거나
//if (currentText.indexOf(logLevel) >= 0 && currentText.indexOf(form.getSearchText()) >= 0) {
errorContent = new ErrorContentVO();
// TODO SOCKET 로그 파싱부
// ---> 현재 이 로그로 파싱함
// ---> 향후 바뀔수 있음
//[2005-08-03 13:44:18 FileLogger{NET}_EAI_DSVR0101] INFO - SOCKET_B2B_IN session stopped with SOCKET_B2B_IN-SESSION-14
errorContent.setSline(count + ":"
+ CharsetDecoderUtil.toKor(currentText));
//가장 최근이 맨 상단으로 가기 위해(이동철)
//errorContentList.add(errorContent);
errorContentList.add(0, errorContent);
//}
} while (currentText != null);
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (randomaccessfile != null) {
try {
randomaccessfile.close();
} catch (IOException e) {
}
}
}
return errorContentList;
}
}
@@ -0,0 +1,128 @@
package com.eactive.eai.rms.onl.adapter.socket2.service;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.onl.adapter.common.vo.ErrorContentForm;
import com.eactive.eai.rms.onl.adapter.socket2.vo.ErrorContentVO;
import com.eactive.eai.rms.onl.common.util.CharsetDecoderUtil;
/**
*
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
* @author : 박기섭, 이동철
* @version : $Revision: 1.4 $
* @since : rts 1.0
*/
@Service("socket2LogContentService")
public class SocketLogContentService {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(SocketLogContentService.class);
@Autowired
@Qualifier("monitoringContext")
private transient MonitoringContext monitoringContext;
public List execute(ErrorContentForm form) {
int count = 0;
String logLevel = form.getLogLevel();
//---------------------------------------------------------
// 대상 파일명
// (Was 도메인 경로 + Was인스턴스명 + 파일경로) - 이동철
//---------------------------------------------------------
String file_name = monitoringContext.getStringProperty(
MonitoringContext.DEFAULT_LOG_PATH, "/fslog/eai/")
+ form.getEaiSvrInstNm()
+ "/"
+ monitoringContext.getStringProperty(
MonitoringContext.SOCKET_LOG_FILE, "netAdapter.log");
if (logLevel.equals("TOTAL"))
logLevel = "";
RandomAccessFile randomaccessfile = null;
ArrayList errorContentList = new ArrayList();
ErrorContentVO errorContent = null;
try {
File file = new File(file_name);
randomaccessfile = new RandomAccessFile(file, "r");
long currentPoint = 0L;
randomaccessfile.getFilePointer();
String currentText = null;
//---------------------------------------------------------
// 버프의 내용을 라인씩 읽어 들인다.
//---------------------------------------------------------
do {
// 마지막지점 검색
randomaccessfile.seek(currentPoint);
// 마지막지점의 라인을 읽어온다.
currentText = randomaccessfile.readLine();
if(currentText != null) { //취약점소스 수정 2020.08.27
currentText = currentText.trim();
}
currentPoint = randomaccessfile.getFilePointer();
count++;
if (currentText == null) {
break;
}
if (currentText.length() == 0 || currentText.indexOf("[") != 0) {
continue;
}
// 만약 현 라인에 해당 로그 level 이 존재 하지 않거나
if (currentText.indexOf(logLevel) >= 0
&& currentText.indexOf(form.getSearchText()) >= 0) {
errorContent = new ErrorContentVO();
// TODO SOCKET 로그 파싱부
// ---> 현재 이 로그로 파싱함
// ---> 향후 바뀔수 있음
//[2005-08-03 13:44:18 FileLogger{NET}_EAI_DSVR0101] INFO - SOCKET_B2B_IN session stopped with SOCKET_B2B_IN-SESSION-14
errorContent.setSline(count + ":"
+ CharsetDecoderUtil.toKor(currentText));
//가장 최근이 맨 상단으로 가기 위해(이동철)
//errorContentList.add(errorContent);
errorContentList.add(0, errorContent);
}
} while (currentText != null);
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (randomaccessfile != null) {
try {
randomaccessfile.close();
} catch (IOException e) {
}
}
}
return errorContentList;
}
}
@@ -0,0 +1,73 @@
package com.eactive.eai.rms.onl.adapter.socket2.vo;
import java.io.Serializable;
public class ErrorContentVO
implements Serializable {
private String stime = "";
private String sclass = "";
private String smethod = "";
private String slevel = "";
private String scode = "";
private String sline = "";
/** @return Returns the sclass. */
public String getSclass() {
return sclass;
}
/** @param class1 The sclass to set. */
public void setSclass(String class1) {
sclass = class1;
}
/** @return Returns the scode. */
public String getScode() {
return scode;
}
/** @param code The scode to set. */
public void setScode(String code) {
scode = code;
}
/** @return Returns the slevel. */
public String getSlevel() {
return slevel;
}
/** @param level The slevel to set. */
public void setSlevel(String level) {
slevel = level;
}
/** @return Returns the smethod. */
public String getSmethod() {
return smethod;
}
/** @param method The smethod to set. */
public void setSmethod(String method) {
smethod = method;
}
/** @return Returns the stime. */
public String getStime() {
return stime;
}
/** @param time The stime to set. */
public void setStime(String time) {
stime = time;
}
/** @return Returns the sline. */
public String getSline() {
return sline;
}
/** @param sline The sline to set. */
public void setSline(String sline) {
this.sline = sline;
}
}
@@ -0,0 +1,43 @@
package com.eactive.eai.rms.onl.adapter.socket2.vo;
import java.io.Serializable;
import com.eactive.eai.rms.onl.common.vo.HostInfomationForm;
/**
*
* <pre>
* 1. 기능 :
* 2. 처리 개요 :
* -
* 3. 주의사항 :
* </pre>
* @author : 이동철
* @version : $Revision: 1.1 $
* @since : rts 1.0
*/
public class SocketConnectionListForm
extends HostInfomationForm
implements Serializable {
private String adapterGrpNm = "";
private String netadminCmd = "";
public String getAdapterGrpNm() {
return adapterGrpNm;
}
public void setAdapterGrpNm(String adapterGrpNm) {
this.adapterGrpNm = adapterGrpNm;
}
public String getNetadminCmd() {
return netadminCmd;
}
public void setNetadminCmd(String netadminCmd) {
this.netadminCmd = netadminCmd;
}
}
@@ -0,0 +1,108 @@
package com.eactive.eai.rms.onl.admin.common;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.acl.user.BizService;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
import com.google.gson.Gson;
@Controller
public class BizController extends BaseAnnotationController {
@Autowired
@Qualifier("bizService")
private BizService service;
@RequestMapping(value= "/onl/admin/common/bizMan.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd ) throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())){
cmd = "";
}else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0]+cmd;
}
/**
* @param request
* @param response
* @throws Exception
*/
@RequestMapping(value= "/onl/admin/common/bizMan.json", params = "cmd=LIST")
public ModelAndView selectList(HttpServletRequest request,
JsonPageVo pageVo ,String searchBzwkDstcd) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
if (searchBzwkDstcd != null) {
map = service.selectList( pageVo.getStartNum(), pageVo.getEndNum(), searchBzwkDstcd);
}
pageVo.setTotalCount((Integer)map.get("totalCount"));
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("total" , pageVo.getTotal()); //전체 페이지수
resultMap.put("page" , pageVo.getPage()); //현재 페이지수
resultMap.put("records", pageVo.getTotalCount());//전체 레코드건수
resultMap.put("rows" , map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
@RequestMapping(value= "/onl/admin/common/bizMan.json",params = "cmd=DETAIL")
public ModelAndView selectDetail(HttpServletRequest request,
HttpServletResponse response,String bzwkDstcd) throws Exception {
HashMap<String, Object> map = service.selectDetail(bzwkDstcd);
ModelAndView modelAndView = new ModelAndView("jsonView",map);
return modelAndView;
}
@RequestMapping(value= "/onl/admin/common/bizMan.json",params = "cmd=INSERT")
public String insert(HttpServletRequest request,
HttpServletResponse response,@RequestParam HashMap<String,Object> map, String gridData ) throws Exception {
Gson gson = new Gson();
@SuppressWarnings("unchecked")
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
service.insert(map,list);
return null;
}
@RequestMapping(value= "/onl/admin/common/bizMan.json",params = "cmd=UPDATE")
public String update(HttpServletRequest request,
HttpServletResponse response,@RequestParam HashMap<String,Object> map, String gridData ) throws Exception {
Gson gson = new Gson();
@SuppressWarnings("unchecked")
HashMap<String, Object>[] list = gson.fromJson(gridData, HashMap[].class);
service.update(map,list);
return null;
}
@RequestMapping(value= "/onl/admin/common/bizMan.json",params = "cmd=DELETE")
public String delete(HttpServletRequest request,
HttpServletResponse response, String bzwkDstcd ) throws Exception {
HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("bzwkDstcd", bzwkDstcd);
service.delete(paramMap);
return null;
}
}
@@ -0,0 +1,54 @@
package com.eactive.eai.rms.onl.admin.session;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
@Controller
public class SessionHistoryController {
@Autowired
private SessionHistoryService sessionHistoryService;
@RequestMapping(value = "/onl/admin/session/sessionHistory.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/admin/session/sessionHistory.json", params = "cmd=LIST")
public ModelAndView selectList(HttpServletRequest request, JsonPageVo pageVo, @RequestParam HashMap paramMap) throws Exception {
HashMap<String, Object> map = sessionHistoryService.selectList(pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
pageVo.setTotalCount((Integer) map.get("totalCount"));
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("total", pageVo.getTotal()); // 전체 페이지수
resultMap.put("page", pageVo.getPage()); // 현재 페이지수
resultMap.put("records", pageVo.getTotalCount()); // 전체 레코드건수
resultMap.put("rows", map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,22 @@
package com.eactive.eai.rms.onl.admin.session;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
@Repository
public class SessionHistoryDao extends SqlMapClientTemplateDao {
public Integer selectListCount(HashMap paramMap) {
return (Integer) template.queryForObject("SessionHistory.selectListCount", paramMap);
}
public List<Map<String, Object>> selectList(HashMap paramMap) {
return template.queryForList("SessionHistory.selectList", paramMap);
}
}
@@ -0,0 +1,31 @@
package com.eactive.eai.rms.onl.admin.session;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SessionHistoryService {
@Autowired
private SessionHistoryDao sessionHistoryDao;
public HashMap<String, Object> selectList(int startNum, int endNum, HashMap paramMap) throws Exception {
int totalCount = sessionHistoryDao.selectListCount(paramMap);
paramMap.put("startNum", startNum);// ½ÃÀÛ record
paramMap.put("endNum", endNum);// ³¡ record
List<Map<String, Object>> list = sessionHistoryDao.selectList(paramMap);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("totalCount", totalCount);
map.put("list", list);
return map;
}
}
@@ -0,0 +1,22 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
@Repository
public class AutomaticTerminalDao extends SqlMapClientTemplateDao {
public int selectListCount(HashMap paramMap) {
return (int) template.queryForObject("AutomaticTerminalStatus.selectListCount", paramMap);
}
public List<Map<String, Object>> selectList(HashMap paramMap) {
return template.queryForList("AutomaticTerminalStatus.selectList", paramMap);
}
}
@@ -0,0 +1,54 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
@Controller
public class AutomaticTerminalStatusController {
@Autowired
private AutomaticTerminalStatusService autoTerminalService;
@RequestMapping(value = "/onl/admin/adapter/autoTerminalStatusInfo.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/admin/adapter/autoTerminalStatusInfo.json", params = "cmd=LIST")
public ModelAndView selectList(HttpServletRequest request, JsonPageVo pageVo, @RequestParam HashMap paramMap)
throws Exception {
HashMap<String, Object> map = autoTerminalService.selectList(pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
pageVo.setTotalCount((Integer) map.get("totalCount"));
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("total", pageVo.getTotal()); // 전체 페이지수
resultMap.put("page", pageVo.getPage()); // 현재 페이지수
resultMap.put("records", pageVo.getTotalCount()); // 전체 레코드건수
resultMap.put("rows", map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,33 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AutomaticTerminalStatusService {
@Autowired
private AutomaticTerminalDao autoTerminalDao;
public HashMap<String, Object> selectList(int startNum, int endNum, HashMap paramMap) throws Exception {
// 전체 목록수 얻기
int totalCount = autoTerminalDao.selectListCount(paramMap);
paramMap.put("startNum", startNum);// 시작 record
paramMap.put("endNum", endNum);// 끝 record
List<Map<String, Object>> list = autoTerminalDao.selectList(paramMap);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("totalCount", totalCount);
map.put("list", list);
return map;
}
}
@@ -0,0 +1,55 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
@Controller
public class TerminalStatusController {
@Autowired
private TerminalStatusService terminalService;
@RequestMapping(value = "/onl/admin/adapter/terminalStatusInfo.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/admin/adapter/terminalStatusInfo.json", params = "cmd=LIST")
public ModelAndView selectList(HttpServletRequest request, JsonPageVo pageVo, @RequestParam HashMap paramMap)
throws Exception {
HashMap<String, Object> map = terminalService.selectList(pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
pageVo.setTotalCount((Integer) map.get("totalCount"));
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("total", pageVo.getTotal()); // 전체 페이지수
resultMap.put("page", pageVo.getPage()); // 현재 페이지수
resultMap.put("records", pageVo.getTotalCount());// 전체 레코드건수
resultMap.put("rows", map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,21 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
@Repository
public class TerminalStatusDao extends SqlMapClientTemplateDao {
public int selectListCount(HashMap param) throws Exception {
return (Integer) template.queryForObject("TerminalStatus.selectListCount", param);
}
public List selectList(HashMap param) throws Exception {
return template.queryForList("TerminalStatus.selectList", param);
}
}
@@ -0,0 +1,33 @@
package com.eactive.eai.rms.onl.admin.terminal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TerminalStatusService {
@Autowired
private TerminalStatusDao terminalDao;
public HashMap<String, Object> selectList(int startNum, int endNum, HashMap paramMap) throws Exception {
// 전체 목록수 얻기
int totalCount = terminalDao.selectListCount(paramMap);
paramMap.put("startNum", startNum);// 시작 record
paramMap.put("endNum", endNum);// 끝 record
List<Map<String, Object>> list = terminalDao.selectList(paramMap);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("totalCount", totalCount);
map.put("list", list);
return map;
}
}
@@ -0,0 +1,58 @@
package com.eactive.eai.rms.onl.admin.websocket;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.util.CamelCaseUtil;
import com.eactive.eai.rms.common.vo.JsonPageVo;
@Controller
public class WebSocketController extends BaseAnnotationController {
@Autowired
private WebSocketService webSocketService;
@RequestMapping(value = "/onl/admin/adapter/webSocketMan.view")
public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false) String cmd)
throws Exception {
if (cmd == null || "LIST".equals(cmd.toUpperCase())) {
cmd = "";
} else {
cmd = CamelCaseUtil.converCamelCase(cmd);
}
String path = request.getServletPath();
return path.split("[.]")[0] + cmd;
}
@RequestMapping(value = "/onl/admin/adapter/webSocketMan.json", params = "cmd=LIST")
public ModelAndView selectList(HttpServletRequest request, JsonPageVo pageVo, @RequestParam HashMap paramMap)
throws Exception {
logger.debug(paramMap.toString());
HashMap<String, Object> map = webSocketService.selectList(pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
pageVo.setTotalCount((Integer) map.get("totalCount"));
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("total", pageVo.getTotal()); // 전체 페이지수
resultMap.put("page", pageVo.getPage()); // 현재 페이지수
resultMap.put("records", pageVo.getTotalCount());// 전체 레코드건수
resultMap.put("rows", map.get("list"));
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
}
}
@@ -0,0 +1,157 @@
package com.eactive.eai.rms.onl.admin.websocket;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import com.eactive.eai.common.util.HttpUtil;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
@Service
public class WebSocketService extends BaseService {
private EAIServerService eaiServerService;
@Autowired
public WebSocketService(EAIServerService eaiServerService) {
this.eaiServerService = eaiServerService;
}
public HashMap<String, Object> selectList(int startNum, int endNum, HashMap paramMap) throws Exception {
HashMap<String, Object> result = new HashMap<>();
List<HashMap<String, String>> list = new ArrayList<>();
String[] keyArray = {
"wsInstId",
"wsAdapterGroupName",
"loginUserId",
"localSocketAddress",
"remoteSocketAddress",
"socketStatus"
};
/** search parameter **/
boolean searchConditionMatched = true;
String remoteSocketAddressParam = (String) paramMap.get("remoteSocketAddress");
String loginUserId = (String) paramMap.get("loginUserId");
int totalCount = 0;
/** 해당 startNum endNum serverList가져오는 정보로 검색결과와 상관없음 **/
paramMap.put("startNum", 1);
paramMap.put("endNum", 100);
List<EAIServer> serverList = eaiServerService.findAll();
for(EAIServer m : serverList) {
String serverIp = m.getEaisevrip();
if(serverIp.contains("*")) {
continue;
}
String url = buildUrl(m, paramMap);
logger.debug("HttpCall : " + url);
String xmlString = HttpUtil.httpCall(url, "GET");
if(xmlString == null) {
continue;
}
logger.debug("XmlResponseReturn : " + xmlString);
Document doc = parseXmlStringToDocument(xmlString);
Element root = doc.getDocumentElement();
NodeList children = root.getElementsByTagName("Rows");
//<Rows>
for (int i = 0; i < children.getLength(); i++) {
NodeList rowList = ((Element)children.item(i)).getElementsByTagName("Row");
//<Row>
for (int j = 0; j < rowList.getLength(); j++) {
HashMap<String, String> rowUnit = new HashMap<>();
NodeList dataList = ((Element)rowList.item(j)).getElementsByTagName("Data");
//<Data>
for (int k = 0; k < dataList.getLength(); k++) {
Element data = (Element) dataList.item(k);
rowUnit.put(keyArray[k], data.getTextContent());
if(loginUserId != null && k == 2) {
searchConditionMatched = data.getTextContent().contains(loginUserId);
if(!searchConditionMatched) { break; }
}
if(remoteSocketAddressParam != null && k == 4) {
searchConditionMatched = data.getTextContent().contains(remoteSocketAddressParam);
if(!searchConditionMatched) { break; }
}
}//</Data>
if(searchConditionMatched) {
list.add(rowUnit);
totalCount++;
}
}//</Row>
}//</Rows>
}//server
list = paging(startNum, endNum, list);
for(HashMap m : list) {
logger.debug(m.toString());
}
result.put("totalCount", totalCount);
result.put("list", list);
return result;
}
private String buildUrl(EAIServer m, HashMap paramMap) {
String prepend = "http://";
String suppend = "/session/websocketConnections.jsp";
StringBuilder reqUrl = new StringBuilder();
reqUrl.append(prepend);
reqUrl.append((String) m.getEaisevrip());
reqUrl.append(":");
reqUrl.append((String) m.getSevrlsnportname());
reqUrl.append(suppend);
return reqUrl.toString();
}
private Document parseXmlStringToDocument(String xmlString) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(xmlString)));
return doc;
}
private List<HashMap<String, String>> paging(int startNum, int endNum, List<HashMap<String, String>> list) {
if(list.size() > endNum) {
return list.subList(startNum-1, endNum);
} else {
return list.subList(startNum-1, list.size());
}
}
}
@@ -0,0 +1,154 @@
package com.eactive.eai.rms.onl.apim.apigroup;
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.apim.apigroup.command.ReloadApiGroupCommand;
import com.eactive.eai.apim.apigroup.command.RemoveApiGroupCommand;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.util.CommonUtil;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.common.vo.SimpleResponse;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUI;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUISearch;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgManService;
import com.eactive.eai.rms.onl.common.exception.BizException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.HashMap;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;
@Controller
public class ApiGroupManController extends OnlBaseAnnotationController {
public static final Log logger = LogFactory.getLog(ApiGroupManController.class);
public final ApiGroupManService service;
private final PortalOrgManService portalOrgManService;
@Autowired
public ApiGroupManController(ApiGroupManService service, PortalOrgManService portalOrgManService) {
this.service = service;
this.portalOrgManService = portalOrgManService;
}
@GetMapping(value = "/onl/apim/apigroup/apiGroupMan.view")
public void view() {
}
@GetMapping(value = "/onl/apim/apigroup/apiGroupMan.view", params = "cmd=DETAIL")
public String viewDetail() {
return "/onl/apim/apigroup/apiGroupManDetail";
}
@GetMapping(value = "/onl/apim/apigroup/apiGroupMan.view", params = "cmd=POPUP")
public String apiSearchPopup() {
return "/onl/apim/apigroup/apiGroupManPopup";
}
@PostMapping(value= "/onl/apim/apigroup/apiGroupMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<ApiGroupUI>> selectList(ApiGroupUISearch apiGroupUISearch,
Pageable pageable) {
Pageable sortedPageable = PageRequest.of(
pageable.getPageNumber(),
pageable.getPageSize(),
Sort.by(
Sort.Order.asc("displayOrder"),
Sort.Order.asc("groupName")
)
);
Page<ApiGroupUI> page = service.selectList(apiGroupUISearch, sortedPageable);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value= "/onl/apim/apigroup/apiGroupMan.json",params = "cmd=DETAIL")
public ResponseEntity<ApiGroupUI> selectDetail(String apiGroupId) throws Exception {
ApiGroupUI apiGroupUI = service.selectDetail(apiGroupId);
if (StringUtils.isNotBlank(apiGroupUI.getDisplayOrg())) {
String orgNames = Arrays.stream(apiGroupUI.getDisplayOrg().split(","))
.map(portalOrgManService::findById)
.filter(Optional::isPresent)
.map(Optional::get)
.map(PortalOrg::getOrgName)
.collect(Collectors.joining(", "));
apiGroupUI.setDisplayOrgName(orgNames);
}
return ResponseEntity.ok(apiGroupUI);
}
@PostMapping(value= "/onl/apim/apigroup/apiGroupMan.json",params = "cmd=INSERT")
public ResponseEntity<SimpleResponse> insert(ApiGroupUI apiGroupUI) throws Exception {
try {
service.insert(apiGroupUI);
CommonCommand command = new CommonCommand(ReloadApiGroupCommand.class.getName(), apiGroupUI.getId());
HashMap<String, Object> returnMap = agentUtilService.broadcast(command);
SimpleResponse simpleResponse = SimpleResponse.of(CommonUtil.getMapString(returnMap, true));
return ResponseEntity.ok(simpleResponse);
}catch(Exception e) {
logger.error(e);
if(e instanceof BizException) {
throw e;
}
throw new BizException("오류가 발생했습니다. 확인바랍니다. error:"+e.getMessage(), e);
}
}
@PostMapping(value= "/onl/apim/apigroup/apiGroupMan.json", params = "cmd=UPDATE")
public ResponseEntity<SimpleResponse> update(ApiGroupUI apiGroupUI) throws Exception {
try {
service.update(apiGroupUI);
CommonCommand command = new CommonCommand(ReloadApiGroupCommand.class.getName(), apiGroupUI.getId());
HashMap<String, Object> returnMap = agentUtilService.broadcast(command);
SimpleResponse simpleResponse = SimpleResponse.of(CommonUtil.getMapString(returnMap, true));
return ResponseEntity.ok(simpleResponse);
}catch(Exception e) {
if(e instanceof BizException) {
throw e;
}
if(e instanceof DuplicateKeyException) {
DuplicateKeyException dupEx = (DuplicateKeyException) e;
Throwable cause = dupEx.getMostSpecificCause();
throw new BizException("중복 오류가 발생했습니다. 확인바랍니다. 오류메시지: "+cause.getMessage());
}
logger.error(e);
throw new BizException("오류가 발생했습니다. 확인바랍니다. 오류메시지: "+e.getMessage());
}
}
@PostMapping(value= "/onl/apim/apigroup/apiGroupMan.json",params = "cmd=DELETE")
public ResponseEntity<SimpleResponse> delete(ApiGroupUI apiGroupUI) throws Exception {
try {
service.delete(apiGroupUI);
CommonCommand command = new CommonCommand(RemoveApiGroupCommand.class.getName(), apiGroupUI.getId());
HashMap<String, Object> returnMap = agentUtilService.broadcast(command);
SimpleResponse simpleResponse = SimpleResponse.of(CommonUtil.getMapString(returnMap, true));
return ResponseEntity.ok(simpleResponse);
}catch(Exception e) {
if(e instanceof BizException) {
throw e;
}
throw new BizException("오류가 발생했습니다. 확인바랍니다. error:"+e.getMessage(), e);
}
}
}
@@ -0,0 +1,98 @@
package com.eactive.eai.rms.onl.apim.apigroup;
import com.eactive.eai.data.entity.onl.apim.apigroup.ApiGroup;
import com.eactive.eai.data.entity.onl.apim.apigroup.ApiGroupApi;
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
import com.eactive.eai.rms.common.base.OnlBaseService;
import com.eactive.eai.rms.data.entity.onl.apim.apigroup.ApiGroupService;
import com.eactive.eai.rms.data.entity.onl.eaimsg.EAIMessageService;
import com.eactive.eai.rms.onl.apim.apigroup.mapping.ApiGroupUIMapper;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUI;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUISearch;
import com.eactive.eai.transformer.util.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Transactional
public class ApiGroupManService extends OnlBaseService {
@Autowired
private ApiGroupService apiGroupService;
@Autowired
private EAIMessageService eaiMessageService;
@Autowired
private ApiGroupUIMapper apiGroupUIMapper;
private static final Logger logger = Logger.getLogger(ApiGroupManService.class);
public Page<ApiGroupUI> selectList(ApiGroupUISearch apiGroupUISearch, Pageable pageable) {
Page<ApiGroup> tuples = apiGroupService.selectList(apiGroupUISearch, pageable);
return tuples.map(apiGroup -> {
ApiGroupUI apiGroupUI = apiGroupUIMapper.toVo(apiGroup);
apiGroupUI.setMainIcon(null);
apiGroupUI.setContentIcon(null);
return apiGroupUI;
});
}
public ApiGroupUI selectDetail(String apiGroupId) throws Exception {
ApiGroup apiGroup = apiGroupService.getById(apiGroupId);
ApiGroupUI apiGroupUI;
if(apiGroup.getApiGroupApiList() != null && apiGroup.getApiGroupApiList().size() > 0) {
List<String> apiIds = apiGroup.getApiGroupApiList().stream()
.map(api -> api.getId().getApiId())
.collect(Collectors.toList());
List<EAIMessageEntity> eaiMessageEntities = eaiMessageService.findByEaisvcnameList(apiIds);
apiGroupUI = apiGroupUIMapper.toVo(apiGroup, eaiMessageEntities);
// displayOrder 정보를 포함하는 ApiGroupApiList 설정
Map<String, Integer> displayOrders = apiGroup.getApiGroupApiList().stream()
.collect(Collectors.toMap(
api -> api.getId().getApiId(),
ApiGroupApi::getDisplayOrder
));
// ApiGroupApiUI 리스트에 displayOrder 설정
apiGroupUI.getApiGroupApiList().forEach(apiGroupApiUI -> {
apiGroupApiUI.setDisplayOrder(displayOrders.get(apiGroupApiUI.getApiId()));
});
} else {
apiGroupUI = apiGroupUIMapper.toVo(apiGroup);
}
return apiGroupUI;
}
public void insert(ApiGroupUI apiGroupUI) {
ApiGroup apiGroup = apiGroupUIMapper.toEntity(apiGroupUI);
for (ApiGroupApi apiGroupApi : apiGroup.getApiGroupApiList()){
apiGroupApi.setApiGroup(apiGroup);
}
apiGroupService.save(apiGroup);
for (ApiGroupApi apiGroupApi : apiGroup.getApiGroupApiList()){
apiGroupApi.getId().setApiGroupId(apiGroup.getId());
}
}
public void update(ApiGroupUI apiGroupUI) {
ApiGroup apiGroup = apiGroupService.getById(apiGroupUI.getId());
apiGroupUIMapper.updateToEntity(apiGroupUI, apiGroup);
apiGroupService.save(apiGroup);
}
public void delete(ApiGroupUI apiGroupUI) {
ApiGroup apiGroup = apiGroupService.getById(apiGroupUI.getId());
apiGroupService.delete(apiGroup);
}
}
@@ -0,0 +1,26 @@
package com.eactive.eai.rms.onl.apim.apigroup.mapping;
import com.eactive.eai.data.entity.onl.apim.apigroup.ApiGroupApi;
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupApiUI;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@Mapper(config = BaseMapperConfig.class, uses = {})
public interface ApiGroupApiUIMapper extends GenericMapper<ApiGroupApiUI, ApiGroupApi> {
@Mapping(source = "id.apiGroupId", target = "apiGroupId")
@Mapping(source = "id.apiId", target = "apiId")
@Mapping(source = "displayOrder", target = "displayOrder")
ApiGroupApiUI toVo(ApiGroupApi apiGroupApi);
@InheritInverseConfiguration
ApiGroupApi toEntity(ApiGroupApiUI apiGroupApiUI);
@Mapping(source = "eaibzwkdstcd", target = "bizCode")
@Mapping(source = "eaisvcname", target = "apiId")
@Mapping(source = "eaisvcdesc", target = "apiDesc")
ApiGroupApiUI toVo(EAIMessageEntity eaiMessageEntity);
}
@@ -0,0 +1,27 @@
package com.eactive.eai.rms.onl.apim.apigroup.mapping;
import com.eactive.eai.data.entity.onl.apim.apigroup.ApiGroup;
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUI;
import org.mapstruct.*;
import java.util.List;
@Mapper(config = BaseMapperConfig.class, uses = { ApiGroupApiUIMapper.class })
public interface ApiGroupUIMapper extends GenericMapper<ApiGroupUI, ApiGroup> {
@Mapping(source = "apiGroupApiList", target = "apiGroupApiList")
ApiGroupUI toVo(ApiGroup apiGroup);
@Mapping(source = "eaiMessageEntityList", target = "apiGroupApiList")
ApiGroupUI toVo(ApiGroup apiGroup, List<EAIMessageEntity> eaiMessageEntityList);
@InheritInverseConfiguration
ApiGroup toEntity(ApiGroupUI apiGroupUI);
@InheritInverseConfiguration
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
void updateToEntity(ApiGroupUI apiGroupUI, @MappingTarget ApiGroup apiGroup);
}
@@ -0,0 +1,12 @@
package com.eactive.eai.rms.onl.apim.apigroup.ui;
import lombok.Data;
@Data
public class ApiGroupApiUI {
private String apiGroupId;
private String bizCode;
private String apiId;
private String apiDesc;
private Integer displayOrder;
}
@@ -0,0 +1,32 @@
package com.eactive.eai.rms.onl.apim.apigroup.ui;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class ApiGroupUI {
private String id;
private String groupName;
private String groupDesc;
private String contentDetail;
private String contentIcon;
private String contentSubject;
private Integer displayOrder;
private Integer menuDisplayOrder;
private String mainText;
private String displayYn;
private String displayOrg;
private String displayOrgName;
private String displayRoleCode;
private String mainIcon;
private String createdBy;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdDate;
private String lastModifiedBy;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime lastModifiedDate;
private List<ApiGroupApiUI> apiGroupApiList;
}
@@ -0,0 +1,10 @@
package com.eactive.eai.rms.onl.apim.apigroup.ui;
import lombok.Data;
@Data
public class ApiGroupUISearch {
private String searchGroupName;
private String searchGroupDesc;
private String searchDisplayYn;
}
@@ -0,0 +1,30 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.approval.entity.ApproverStatus;
import com.eactive.eai.data.converter.LocalDateTimeFormatters;
import com.eactive.eai.rms.common.acl.user.ui.UserUI;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@Data
public class PortalApprovalApproverUI {
private Long ordinal;
private UserUI user;
private ApproverStatus approverStatus;
private String approverStatusDescription;
private String approvalMessage;
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYY_MM_DD_HH_MM_SS_19)
@DateTimeFormat(pattern = "yyyyMMddHHmmssSSS")
private LocalDateTime approvedDate;
public String getApproverStatusDescription() {
return approverStatus != null ? approverStatus.getDescription() : "";
}
}
@@ -0,0 +1,18 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.approval.entity.Approver;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.common.acl.user.mapper.UserUIMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring",uses = {UserUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalApprovalApproverUIMapper extends GenericMapper<PortalApprovalApproverUI, Approver> {
@Override
@Mapping(target = "ordinal", source = "id.ordinal")
PortalApprovalApproverUI toVo(Approver approver);
}
@@ -0,0 +1,27 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.apim.portal.approval.entity.Approver;
import com.eactive.apim.portal.approval.entity.ApproverStatus;
import com.eactive.apim.portal.approval.statemachine.ApprovalAuthorizer;
import org.springframework.stereotype.Component;
@Component
public class PortalApprovalAuthorizer implements ApprovalAuthorizer {
@Override
public boolean isAuthorized(Approval approval, String approverId) {
return approval.getApprovers().stream()
.filter(this::isCurrentApprover)
.map(this::getApproverId)
.anyMatch(id -> id.equals(approverId));
}
private boolean isCurrentApprover(Approver approver) {
return ApproverStatus.CURRENT.equals(approver.getApproverStatus());
}
private String getApproverId(Approver approver) {
return approver.getUser().getId();
}
}
@@ -0,0 +1,79 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.login.SessionManager;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.data.entity.onl.apim.approval.PortalApprovalUISearch;
import com.eactive.eai.rms.onl.common.exception.BizException;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequiredArgsConstructor
public class PortalApprovalManController extends BaseAnnotationController {
private final PortalApprovalManService portalApprovalManService;
@GetMapping(value = "/onl/apim/approval/portalApprovalMan.view")
public void view() {
// view
}
@GetMapping(value = "/onl/apim/approval/portalApprovalMan.view", params = "cmd=DETAIL")
public String detailView(@RequestParam(name = "type", defaultValue = "app") String type) {
if (type.equalsIgnoreCase("app")) {
return "/onl/apim/approval/portalAppApprovalManPopup";
} else {
return "/onl/apim/approval/portalUserApprovalManPopup";
}
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<PortalApprovalUI>> selectList(@SortDefault(value = "createdDate", direction = Sort.Direction.DESC) Pageable pageable,
PortalApprovalUISearch portalApprovalUISearch) {
Page<PortalApprovalUI> page = portalApprovalManService.selectList(pageable, portalApprovalUISearch);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=DETAIL")
public ResponseEntity<PortalApprovalUI> selectDetail(String id) {
PortalApprovalUI portalApprovalUI = portalApprovalManService.selectDetail(id);
return ResponseEntity.ok(portalApprovalUI);
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=UNMASK")
public ResponseEntity<PortalApprovalUI> selectDetail(String id, String reason) {
if (StringUtils.isBlank(reason)) {
throw new BizException("마스킹 해제 사유를 입력해 주세요.");
}
PortalApprovalUI portalApprovalUI = portalApprovalManService.selectDetailUnmask(id);
return ResponseEntity.ok(portalApprovalUI);
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=APPROVE")
public ResponseEntity<Void> approve(String id) {
portalApprovalManService.approve(id, SessionManager.getLoginVo().getUserId());
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=REJECT")
public ResponseEntity<Void> reject(String id, String rejectReason) {
portalApprovalManService.reject(id, SessionManager.getLoginVo().getUserId(), rejectReason);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/portalApprovalMan.json", params = "cmd=REDEPLOY")
public ResponseEntity<Void> redeploy(String id) {
portalApprovalManService.redeploy(id);
return ResponseEntity.ok().build();
}
}
@@ -0,0 +1,298 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.apispec.service.ApiSpecInfoService;
import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.apim.portal.apprequest.repository.AppRequestRepository;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.apim.portal.approval.entity.ApprovalType;
import com.eactive.apim.portal.approval.statemachine.*;
import com.eactive.apim.portal.portaluser.entity.PortalUser;
import com.eactive.apim.portal.portaluser.repository.PortalUserRepository;
import com.eactive.eai.data.entity.onl.apim.apigroup.ApiGroup;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.apigroup.ApiGroupService;
import com.eactive.eai.rms.data.entity.onl.apim.approval.ApprovalService;
import com.eactive.eai.rms.data.entity.onl.apim.approval.PortalApprovalUISearch;
import com.eactive.eai.rms.onl.apim.apigroup.mapping.ApiGroupUIMapper;
import com.eactive.eai.rms.onl.apim.approval.app.PortalAppApprovalListener;
import com.eactive.eai.rms.onl.apim.approval.app.PortalAppApprovalUI;
import com.eactive.eai.rms.onl.apim.approval.app.PortalAppApprovalUIMapper;
import com.eactive.eai.rms.onl.apim.approval.user.PortalUserApprovalListener;
import com.eactive.eai.rms.onl.apim.approval.user.PortalUserApprovalUI;
import com.eactive.eai.rms.onl.apim.approval.user.PortalUserApprovalUIMapper;
import com.eactive.eai.rms.onl.apim.masking.MaskingUtils;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgManService;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserManService;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
import com.eactive.eai.rms.onl.transaction.apim.ApiInterfaceService;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiInterfaceUI;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@RequiredArgsConstructor
public class PortalApprovalManService extends BaseService {
private final ApprovalService approvalService;
private final ApprovalStateMachine approvalStateMachine;
private final AppRequestRepository appRequestRepository;
private final PortalAppApprovalListener portalAppApprovalListener;
private final PortalAppApprovalUIMapper portalAppApprovalUIMapper;
private final PortalUserRepository portalUserRepository;
private final PortalUserApprovalListener portalUserApprovalListener;
private final PortalUserApprovalUIMapper portalUserApprovalUIMapper;
private final PortalUserManService portalUserManService;
private final ApiGroupService apiGroupService;
private final ApiInterfaceService apiInterfaceService;
private final ApiSpecInfoService apiSpecInfoService;
private final ApiSpecUIMapper apiSpecUIMapper;
private final ApiGroupUIMapper apiGroupUIMapper;
private final PortalApprovalAuthorizer portalApprovalAuthorizer;
private final PortalOrgManService portalOrgManService;
public Page<PortalApprovalUI> selectList(Pageable pageable, PortalApprovalUISearch portalApprovalUISearch) {
Page<Approval> approval = approvalService.findAll(pageable, portalApprovalUISearch);
return approval.map(entity -> getDetailWithMaskOption(entity.getId(), true));
}
/**
* 마스킹된 상세 정보 조회
*/
public PortalApprovalUI selectDetail(String id) {
return getDetailWithMaskOption(id, true);
}
/**
* 마스킹 해제된 상세 정보 조회
*/
public PortalApprovalUI selectDetailUnmask(String id) {
return getDetailWithMaskOption(id, false);
}
private PortalApprovalUI getDetailWithMaskOption(String id, boolean isMasked) {
Approval approval = approvalService.getById(id);
if (approval.getApprovalType().equals(ApprovalType.USER)) {
PortalUserApprovalUI userApprovalUI = portalUserApprovalUIMapper.toVo(approval);
// 요청자 정보 마스킹 처리
if (userApprovalUI.getRequester() != null && isMasked) {
userApprovalUI.getRequester().setUserName(
MaskingUtils.maskName(userApprovalUI.getRequester().getUserName())
);
userApprovalUI.getRequester().setEmailAddr(
MaskingUtils.maskEmailId(userApprovalUI.getRequester().getEmailAddr())
);
userApprovalUI.getRequester().setLoginId(
MaskingUtils.maskEmailId(userApprovalUI.getRequester().getLoginId())
);
userApprovalUI.getRequester().setMobileNumber(
MaskingUtils.maskPhoneNumber(userApprovalUI.getRequester().getMobileNumber())
);
}
// 사용자 정보 처리
Optional<PortalUser> optUser = portalUserRepository.findById(approval.getTargetId());
optUser.ifPresent(user -> {
PortalUserUI userUI = isMasked ?
portalUserManService.selectDetail(user.getId()) :
portalUserManService.selectDetailUnmask(user.getId());
// IP 마스킹 상태만 재설정
if (user.getPortalOrg() != null) {
userUI.setPortalOrgUIs(null); // 기존 마스킹된 PortalOrgUI 제거
portalOrgManService.getPortalOrgUI(user.getPortalOrg().getId(), isMasked)
.ifPresent(userUI::setPortalOrgUIs);
}
userApprovalUI.setPortalUser(userUI);
});
userApprovalUI.getApprovers().forEach(approvers -> approvers.getUser().setUserName(MaskingUtils.maskName(approvers.getUser().getUserName())));
return userApprovalUI;
} else if (approval.getApprovalType().equals(ApprovalType.APP)) {
PortalAppApprovalUI appApprovalUI = portalAppApprovalUIMapper.toVo(approval);
// 요청자 정보 마스킹 처리
if (appApprovalUI.getRequester() != null && isMasked) {
appApprovalUI.getRequester().setUserName(
MaskingUtils.maskName(appApprovalUI.getRequester().getUserName())
);
appApprovalUI.getRequester().setEmailAddr(
MaskingUtils.maskEmailId(appApprovalUI.getRequester().getEmailAddr())
);
appApprovalUI.getRequester().setLoginId(
MaskingUtils.maskEmailId(appApprovalUI.getRequester().getLoginId())
);
appApprovalUI.getRequester().setMobileNumber(
MaskingUtils.maskPhoneNumber(appApprovalUI.getRequester().getMobileNumber())
);
}
Optional<AppRequest> optRequest = appRequestRepository.findById(approval.getTargetId());
if (optRequest.isPresent()) {
AppRequest appRequest = optRequest.get();
appApprovalUI.setRequestType(appRequest.getType());
String[] apiGroupList = appRequest.getApiGroupList().split(",");
for (String apiGroupId : apiGroupList) {
apiGroupService.findByIdWithApiList(apiGroupId).ifPresent(apiGroup ->
appApprovalUI.getApiServices().add(apiGroupUIMapper.toVo(apiGroup))
);
}
List<String> currentGroupNameList = new ArrayList<>();
processApiList(appRequest.getApiList(), appApprovalUI.getApis(), currentGroupNameList);
appApprovalUI.setApiGroupNameList(currentGroupNameList);
if (appRequest.getPrevApiList() != null && !appRequest.getPrevApiList().isEmpty() && !appRequest.getPrevApiList().equals("null")) {
List<String> prevGroupNameList = new ArrayList<>();
List<ApiSpecInfoUI> prevApisList = new ArrayList<>();
processApiList(appRequest.getPrevApiList(), prevApisList, prevGroupNameList);
appApprovalUI.setPrevApisList(prevApisList);
appApprovalUI.setPrevApiGroupNameList(prevGroupNameList);
} else {
appApprovalUI.setPrevApisList(null);
appApprovalUI.setPrevApiGroupNameList(null);
}
appApprovalUI.setApprovalDetail(appRequest.getReason());
appApprovalUI.setClientName(appRequest.getClientName());
appApprovalUI.getApprovers().forEach(approverList ->
approverList.getUser().setUserName(MaskingUtils.maskName(approverList.getUser().getUserName()))
);
}
return appApprovalUI;
}
return null;
}
private void processApiList(String apiListStr, List<ApiSpecInfoUI> apiList, List<String> groupNameList) {
if (apiListStr == null || apiListStr.isEmpty()) {
return;
}
String[] apiIds = apiListStr.split(",");
for (String apiId : apiIds) {
try {
ApiSpecInfoUI api = apiSpecUIMapper.map(apiSpecInfoService.findById(apiId));
apiList.add(api);
List<ApiGroup> apiGroups = apiGroupService.findByApiId(apiId);
if (!apiGroups.isEmpty()) {
StringBuilder groupNameBuilder = new StringBuilder();
apiGroups.forEach(apiGroup -> {
if (groupNameBuilder.length() > 0) {
groupNameBuilder.append(", ");
}
groupNameBuilder.append(apiGroup.getGroupName());
});
groupNameList.add(groupNameBuilder.toString());
} else {
groupNameList.add("");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
// private void setAppRequestDetails(PortalAppApprovalUI appApprovalUI, AppRequest appRequest) {
// // API 그룹 정보 설정
// String[] apiGroupList = appRequest.getApiGroupList().split(",");
// for (String apiGroupId : apiGroupList) {
// apiGroupService.findByIdWithApiList(apiGroupId).ifPresent(apiGroup ->
// appApprovalUI.getApiServices().add(apiGroupUIMapper.toVo(apiGroup))
// );
// }
//
// // API 정보 설정
// String[] apiList = appRequest.getApiList().split(",");
// for (String apiId : apiList) {
// try {
// ApiInterfaceUI api = apiInterfaceService.selectDetail(apiId);
// appApprovalUI.getApis().add(api);
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// }
// }
//
// appApprovalUI.setApprovalDetail(appRequest.getReason());
// appApprovalUI.setClientName(appRequest.getClientName());
// }
public void approve(String id, String approverId) {
Map options = new HashMap<>();
Approval approval = approvalService.findById(id).orElseThrow(() -> new IllegalArgumentException("승인 정보를 찾을 수 없습니다. ID: " + id));
if (!portalApprovalAuthorizer.isAuthorized(approval, approverId)) {
throw new IllegalArgumentException("아직 승인 차례가 아닙니다.");
}
options.put(ApprovalConstants.APPROVER, approverId);
sendEvent(id, ApprovalEvent.APPROVE, options);
}
public void reject(String id, String approverId, String rejectReason) {
Map options = new HashMap<>();
Approval approval = approvalService.findById(id).orElseThrow(() -> new IllegalArgumentException("승인 정보를 찾을 수 없습니다. ID: " + id));
if (!portalApprovalAuthorizer.isAuthorized(approval, approverId)) {
throw new IllegalArgumentException("아직 승인 차례가 아닙니다.");
}
options.put(ApprovalConstants.APPROVER, approverId);
options.put(ApprovalConstants.MESSAGE, rejectReason);
sendEvent(id, ApprovalEvent.DENY, options);
}
public void redeploy(String id) {
Map options = new HashMap<>();
Approval approval = approvalService.findById(id).orElseThrow(() -> new IllegalArgumentException("승인 정보를 찾을 수 없습니다. ID: " + id));
if (approval.getApprovalStatus() instanceof DeployFailedState) {
sendEvent(id, ApprovalEvent.REDEPLOY, options);
}
}
public void sendEvent(String id, ApprovalEvent event, Map<String, Object> options) {
approvalService.findById(id).ifPresent(approval -> {
options.put("authorizer", portalApprovalAuthorizer);
if (approval.getApprovalType().equals(ApprovalType.APP)) {
options.put("listener", portalAppApprovalListener);
}
if (approval.getApprovalType().equals(ApprovalType.USER)) {
logger.debug("Setting listener - approval ID: {}, listener type: {}",
approval.getId(),
portalUserApprovalListener.getClass().getSimpleName());
options.put("listener", portalUserApprovalListener);
}
logger.debug("Sending event - ID: {}, Event: {}", id, event);
approvalStateMachine.transition(approval, event, options);
if (approval.getApprovalStatus() instanceof DeniedState || approval.getApprovalStatus() instanceof ApprovedState) {
logger.debug("Sending END event after DENY - ID: {}", id);
approvalStateMachine.transition(approval, ApprovalEvent.END, options); // DeniedState의 handleEnd() 호출을 위한 END 이벤트
}
approvalService.save(approval);
});
}
}
@@ -0,0 +1,44 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.approval.entity.ApprovalType;
import com.eactive.apim.portal.approval.statemachine.ApprovalState;
import com.eactive.eai.data.converter.LocalDateTimeFormatters;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@Data
public class PortalApprovalUI {
private String id;
private ApprovalState approvalStatus; //승인 진행 상태 //statemachine 에 정의됨.
private ApprovalType approvalType; //승인 유형: APP, USER
private String approvalTypeDescription; //승인 유형 Description: API 사용, 법인사용자
private String targetId; //승인하는 대상 객체의 ID
private PortalUserUI requester;
private List<PortalApprovalApproverUI> approvers = new ArrayList<>();
private String approvalSubject; //제목
private String approvalDetail; //승인 요청 내용
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSSSSS_17)
@DateTimeFormat(pattern = "yyyyMMddHHmmssSSS")
private String createdDate;
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSSSSS_17)
@DateTimeFormat(pattern = "yyyyMMddHHmmssSSS")
private String approvalDate;
public String getApprovalTypeDescription() {
return approvalType != null ? approvalType.getDescription() : "";
}
}
@@ -0,0 +1,13 @@
package com.eactive.eai.rms.onl.apim.approval;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUIMapper;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", uses = {PortalUserUIMapper.class, PortalApprovalApproverUIMapper.class }, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalApprovalUIMapper extends GenericMapper<PortalApprovalUI, Approval> {
}
@@ -0,0 +1,17 @@
package com.eactive.eai.rms.onl.apim.approval;
public class RandomStringGenerator {
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
public static String generateString(int length) {
StringBuilder result = new StringBuilder(length);
int charactersLength = CHARACTERS.length();
for (int i = 0; i < length; i++) {
int randomIndex = (int) (Math.random() * charactersLength);
result.append(CHARACTERS.charAt(randomIndex));
}
return result.toString();
}
}
@@ -0,0 +1,306 @@
package com.eactive.eai.rms.onl.apim.approval.app;
import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.apim.portal.apprequest.entity.AppRequestType;
import com.eactive.apim.portal.apprequest.repository.AppRequestRepository;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.apim.portal.approval.service.ApprovalDeployException;
import com.eactive.apim.portal.approval.statemachine.listener.ApprovalListener;
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
import com.eactive.apim.portal.template.service.MessageRecipient;
import com.eactive.apim.portal.template.service.MessageSendService;
import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;
import com.eactive.eai.rms.common.datasource.DataSourceType;
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
import com.eactive.eai.rms.data.entity.onl.apim.apigroup.ApiGroupService;
import com.eactive.eai.rms.onl.apim.approval.RandomStringGenerator;
import com.eactive.eai.rms.onl.apim.approval.credential.CredentialManService;
import com.eactive.eai.rms.onl.apim.approval.credential.CredentialUI;
import com.eactive.eai.rms.onl.apim.approval.credential.CredentialUIMapper;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
import com.eactive.eai.rms.onl.common.service.AgentUtilService;
import com.eactive.eai.rms.onl.manage.authserver.client.ClientManService;
import com.eactive.eai.rms.onl.manage.authserver.client.ClientUI;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
@Service
@RequiredArgsConstructor
public class PortalAppApprovalListener implements ApprovalListener {
private static final Logger logger = LoggerFactory.getLogger(PortalAppApprovalListener.class);
private static final String PORTAL_PROPERTY_GROUP = "Portal";
@Qualifier("onlAgentUtilService")
@Autowired
private AgentUtilService agentUtilService;
private final PortalPropertyService portalPropertyService;
private final ApiGroupService apiGroupService;
private final AppRequestRepository appRequestRepository;
private final CredentialManService credentialManService;
private final CredentialUIMapper credentialUIMapper;
private final ClientManService clientManService;
private final MessageSendService messageSendService;
public static RestTemplate createRestTemplateWithTimeout(int connectTimeout) {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(connectTimeout)
.setConnectTimeout(connectTimeout)
.setSocketTimeout(connectTimeout)
.build();
HttpClient httpClient =
HttpClientBuilder.create()
.setMaxConnTotal(50)
.setMaxConnPerRoute(20)
.setDefaultRequestConfig(requestConfig)
.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
return restTemplate;
}
@Override
public void execute(Approval approval, Map<String, Object> option1) throws ApprovalDeployException {
Optional<AppRequest> optRequest = appRequestRepository.findAppRequestByApproval(approval);
AppRequest appRequest = optRequest.orElseGet(null);
if (appRequest != null) {
AppRequestType type = appRequest.getType();
String server = determineServer(type);
CredentialUI credentialUI = null;
if (appRequest.getType().equals(AppRequestType.PROD_NEW)) {
credentialUI = createAndSaveCredentialUI("prod", optRequest.get());
} else if (appRequest.getType().equals(AppRequestType.PROD_MODIFY)) {
credentialUI = modifyClientUI(optRequest.get());
} else if (appRequest.getType().equals(AppRequestType.PROD_DELETE)) {
credentialManService.delete(optRequest.get().getClientId());
credentialUI = new CredentialUI();
credentialUI.setClientid(optRequest.get().getClientId());
} else if (appRequest.getType().equals(AppRequestType.NEW)) {
credentialUI = createAndSaveCredentialUI("stg", optRequest.get());
} else if (appRequest.getType().equals(AppRequestType.MODIFY)) {
credentialUI = modifyClientUI(optRequest.get());
} else if (appRequest.getType().equals(AppRequestType.DELETE)) {
credentialManService.delete(optRequest.get().getClientId());
credentialUI = new CredentialUI();
credentialUI.setClientid(optRequest.get().getClientId());
}
syncTargetServer(server, determineAction(type), credentialUI);
sendApprovalResult(appRequest);
}
}
private void sendApprovalResult(AppRequest appRequest) {
MessageRecipient recipient = new MessageRecipient();
recipient.setPhone(appRequest.getApproval().getRequester().getMobileNumber());
recipient.setUserId(appRequest.getApproval().getRequester().getEmailAddr());
Map<String, String> params = new HashMap<>();
params.put("apiKey", appRequest.getClientName());
messageSendService.sendMessage("APP_REGISTER_APPROVED", recipient, params);
}
private String determineAction(AppRequestType type) {
if (type == AppRequestType.PROD_NEW || type == AppRequestType.NEW) {
return "insert";
} else if (type == AppRequestType.PROD_MODIFY || type == AppRequestType.MODIFY) {
return "update";
} else if (type == AppRequestType.PROD_DELETE || type == AppRequestType.DELETE) {
return "delete";
} else {
return "none";
}
}
private String determineServer(AppRequestType type) {
if (type == AppRequestType.NEW || type == AppRequestType.MODIFY || type == AppRequestType.DELETE) {
return "stg";
} else {
return "prod";
}
}
private void syncTargetServer(String server, String action, CredentialUI credentialUI) throws ApprovalDeployException {
// 프록시를 통한 스테이징 서버 호출 추가
Map<String, String> properties = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY_GROUP);
String prodUseProxy = properties.getOrDefault("deploy.prod_use_proxy", "N");
if (server.equalsIgnoreCase("prod") && prodUseProxy.equalsIgnoreCase("N")) {
if (action.equalsIgnoreCase("insert")) {
clientManService.insert(credentialUIMapper.mapClient(credentialUI));
} else if (action.equalsIgnoreCase("update")) {
clientManService.update(credentialUIMapper.mapClient(credentialUI));
} else if (action.equalsIgnoreCase("delete")) {
clientManService.delete(credentialUI.getClientid());
}
DataSourceType type = DataSourceTypeManager.getDataSourceType("APIGW");
DataSourceContextHolder.setDataSourceType(type);
CommonCommand.builder()
.name(CommonCommand.RELOAD_CLIENT_COMMAND)
.args(credentialUI.getClientid())
.build().broadcast(agentUtilService);
} else {
String apiKey = properties.get("apiKey");
String proxyUrl = properties.get("portal.url");
String timeout = properties.getOrDefault("deploy.proxy_timeout", "10000");
String proxyEndpoint = proxyUrl + "/_onl/admin/authserver/clientMan.json?serviceType=APIGW";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("X-API-KEY", apiKey);
headers.set("target_host", server);
headers.set("action", action);
HttpEntity<ClientUI> request = new HttpEntity<>(credentialUIMapper.mapClient(credentialUI), headers);
try {
ResponseEntity<String> response = createRestTemplateWithTimeout(Integer.parseInt(timeout)).exchange(
proxyEndpoint,
HttpMethod.POST,
request,
String.class
);
if (!response.getStatusCode().is2xxSuccessful()) {
logger.error("Failed to sync with {} server. Status: {}, Body: {}", server, response.getStatusCode(), response.getBody());
throw new ApprovalDeployException("API키 배포에 실패 했습니다.");
}
} catch (Exception e) {
logger.error("Failed to sync with {} server. {}", server, e.getMessage());
throw new ApprovalDeployException("API키 배포에 실패 했습니다.");
}
}
}
private CredentialUI modifyClientUI(AppRequest appRequest) {
CredentialUI existingCredential = credentialManService.selectDetail(appRequest.getClientId());
existingCredential.getApiList().clear();
Set<String> apiIds = processApiGroups(appRequest);
for (String apiId : apiIds) {
ApiSpecInfoUI apiSpecInfoUI = new ApiSpecInfoUI();
apiSpecInfoUI.setApiId(apiId);
existingCredential.getApiList().add(apiSpecInfoUI);
}
credentialManService.update(existingCredential);
return existingCredential;
}
private CredentialUI createAndSaveCredentialUI(String server, AppRequest appRequest) {
CredentialUI credentialUI = new CredentialUI();
credentialUI.setServer(server);
credentialUI.setClientid(RandomStringGenerator.generateString(32));
credentialUI.setClientsecret(RandomStringGenerator.generateString(128));
credentialUI.setClientname(appRequest.getClientName());
credentialUI.setScope("api");
credentialUI.setGranttypes("client_credentials");
credentialUI.setOrgid(appRequest.getOrg().getId());
credentialUI.setOrgname(appRequest.getOrg().getOrgName());
credentialUI.setAccesstokenvalidityseconds("86400");
Set<String> apiIds = processApiGroups(appRequest);
for (String apiId : apiIds) {
ApiSpecInfoUI apiSpecInfoUI = new ApiSpecInfoUI();
apiSpecInfoUI.setApiId(apiId);
credentialUI.getApiList().add(apiSpecInfoUI);
}
credentialManService.insert(credentialUI);
return credentialUI;
}
private Set<String> processApiGroups(AppRequest appRequest) {
// Guard clause for null request or both null lists
if (appRequest == null || (StringUtils.isBlank(appRequest.getApiGroupList()) && StringUtils.isBlank(appRequest.getApiList()))) {
return Collections.emptySet();
}
Set<String> requestApis = processApiList(appRequest.getApiList());
Set<String> serviceApis = processApiGroupList(appRequest.getApiGroupList());
// Combine serviceApis and requestApis into one set
requestApis.addAll(serviceApis);
return requestApis;
}
private Set<String> processApiGroupList(String apiGroupList) {
if (StringUtils.isBlank(apiGroupList)) {
return Collections.emptySet();
}
return Arrays.stream(apiGroupList.split(","))
.map(String::trim) // Trim leading and trailing spaces
.filter(StringUtils::isNotBlank)
.flatMap(apiGroupId ->
apiGroupService.findByIdWithApiList(apiGroupId)
.map(apiGroup -> apiGroup.getApiGroupApiList().stream()
.map(apiGroupApi -> apiGroupApi.getId().getApiId()))
.orElse(Stream.empty())
)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}
private Set<String> processApiList(String apiList) {
if (StringUtils.isBlank(apiList)) {
return Collections.emptySet();
}
return Arrays.stream(apiList.split(","))
.map(String::trim) // Trim leading and trailing spaces
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
}
@Override
@Transactional
public void rollback(Approval approval) {
logger.info("Approval {} rollback", approval.getId());
}
}
@@ -0,0 +1,29 @@
package com.eactive.eai.rms.onl.apim.approval.app;
import com.eactive.apim.portal.apprequest.entity.AppRequestType;
import com.eactive.eai.rms.onl.apim.apigroup.ui.ApiGroupUI;
import com.eactive.eai.rms.onl.apim.approval.PortalApprovalUI;
import java.util.ArrayList;
import java.util.List;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class PortalAppApprovalUI extends PortalApprovalUI {
private List<ApiGroupUI> apiServices = new ArrayList<>();
// private List<ApiInterfaceUI> apis = new ArrayList<>();
private List<ApiSpecInfoUI> apis = new ArrayList<>();
private String clientName;
private List<String> apiGroupNameList;
private List<ApiSpecInfoUI> prevApisList = new ArrayList<>();
private List<String> prevApiGroupNameList = new ArrayList<>();
private AppRequestType requestType;
}
@@ -0,0 +1,14 @@
package com.eactive.eai.rms.onl.apim.approval.app;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.approval.PortalApprovalApproverUIMapper;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUIMapper;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", uses = {PortalUserUIMapper.class, PortalApprovalApproverUIMapper.class }, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalAppApprovalUIMapper extends GenericMapper<PortalAppApprovalUI, Approval> {
}
@@ -0,0 +1,39 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
import com.eactive.apim.portal.apprequest.entity.AppRequestType;
import com.eactive.apim.portal.approval.entity.ApprovalStatus;
import com.eactive.eai.data.converter.LocalDateTimeFormatters;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUI;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
@Data
public class AppRequestUI {
private String id;
private PortalOrgUI org;
private ApprovalStatus status;
private AppRequestType type; // 신규(NEW), 변경(MODIFY)
private List<ApiSpecInfoUI> apiList = new ArrayList<>();
private String apiGroupList = ""; //comma separated api group id list
private String clientId; //for modifying existing app
private String clientName;
private String reason;
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYY_MM_DD_HH_MM_SS_19)
private LocalDateTime createdDate;
private String refClient;
}
@@ -0,0 +1,47 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUIMapper;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Mapper(componentModel = "spring", uses = {PortalOrgUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
@Component
public abstract class AppRequestUIMapper implements GenericMapper<AppRequestUI, AppRequest> {
@Autowired
ApiSpecUIMapper apiSpecUIMapper;
@InheritInverseConfiguration
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public abstract void updateToEntity(AppRequestUI appRequestUI, @MappingTarget AppRequest appRequest);
public List<ApiSpecInfoUI> mapApiList(String apiIds) {
return Arrays.stream(apiIds.split(","))
.map(String::trim)
.filter(id -> !id.isEmpty())
.map(id -> apiSpecUIMapper.getUIById(id))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
public String joinApiList(List<ApiSpecInfoUI> apiList) {
return apiList.stream()
.map(ApiSpecInfoUI::getApiId)
.filter(Objects::nonNull)
.collect(Collectors.joining(","));
}
}
@@ -0,0 +1,5 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
public class AppRequestUISearch {
}
@@ -0,0 +1,49 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.vo.GridResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
@RequiredArgsConstructor
public class PortalAppRequestManController extends OnlBaseAnnotationController {
private final PortalAppRequestManService portalAppRequestManService;
@GetMapping(value = "/onl/apim/approval/apprequest/prodAppRequestMan.view")
public void view() {
}
@GetMapping(value = "/onl/apim/approval/apprequest/prodAppRequestMan.view", params = "cmd=DETAIL")
public String detailView() {
return "/onl/apim/approval/apprequest/prodAppRequestManPopup";
}
@PostMapping(value = "/onl/apim/approval/apprequest/prodAppRequestMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<AppRequestUI>> selectList(@SortDefault(value = "createdDate", direction = Sort.Direction.DESC) Pageable pageable,
AppRequestUISearch appRequestUISearch) {
Page<AppRequestUI> page = portalAppRequestManService.selectList(pageable, appRequestUISearch);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value = "/onl/apim/approval/apprequest/prodAppRequestMan.json", params = "cmd=DETAIL")
public ResponseEntity<AppRequestUI> selectDetail(String id) {
AppRequestUI portalApprovalUI = portalAppRequestManService.selectDetail(id);
return ResponseEntity.ok(portalApprovalUI);
}
@PostMapping(value = "/onl/apim/approval/apprequest/prodAppRequestMan.json", params = "cmd=UPDATE")
public ResponseEntity<AppRequestUI> update(AppRequestUI appRequestUI) {
AppRequestUI portalApprovalUI = portalAppRequestManService.update(appRequestUI);
return ResponseEntity.ok(portalApprovalUI);
}
}
@@ -0,0 +1,39 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
import com.eactive.apim.portal.apispec.service.ApiSpecInfoService;
import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.eai.rms.common.base.BaseService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@RequiredArgsConstructor
public class PortalAppRequestManService extends BaseService {
private final ApiSpecInfoService apiSpecInfoService;
private final PortalAppRequestService portalAppRequestService;
private final AppRequestUIMapper appRequestUIMapper;
public Page<AppRequestUI> selectList(Pageable pageable, AppRequestUISearch appRequestUISearch) {
return portalAppRequestService.findAllProd(pageable, appRequestUISearch)
.map(appRequest -> appRequestUIMapper.toVo(appRequest));
}
public AppRequestUI selectDetail(String id) {
AppRequest appRequest = portalAppRequestService.getById(id);
return appRequestUIMapper.toVo(appRequest);
}
public AppRequestUI update(AppRequestUI appRequestUI) {
AppRequest appRequest = portalAppRequestService.getById(appRequestUI.getId());
appRequestUIMapper.updateToEntity(appRequestUI, appRequest);
appRequest = portalAppRequestService.save(appRequest);
return appRequestUIMapper.toVo(appRequest);
}
}
@@ -0,0 +1,27 @@
package com.eactive.eai.rms.onl.apim.approval.apprequest;
import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.apim.portal.apprequest.entity.AppRequestType;
import com.eactive.apim.portal.apprequest.entity.QAppRequest;
import com.eactive.apim.portal.apprequest.repository.AppRequestRepository;
import com.eactive.eai.rms.data.jpa.AbstractEMSDataSerivce;
import com.querydsl.core.BooleanBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class PortalAppRequestService extends AbstractEMSDataSerivce<AppRequest, String, AppRequestRepository> {
public Page<AppRequest> findAllProd(Pageable pageable, AppRequestUISearch uiSearch) {
QAppRequest qAppRequest = QAppRequest.appRequest;
BooleanBuilder predicate = new BooleanBuilder();
predicate.and(qAppRequest.type.eq(AppRequestType.PROD_NEW));
return repository.findAll(predicate, pageable);
}
}
@@ -0,0 +1,11 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.apim.portal.app.entity.Credential;
import com.eactive.eai.data.jpa.BaseRepository;
import com.eactive.eai.rms.data.EMSDataSource;
@EMSDataSource
public interface CredentialEMSRepository extends BaseRepository<Credential, String> {
}
@@ -0,0 +1,66 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.vo.GridResponse;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
@RequiredArgsConstructor
public class CredentialManController extends OnlBaseAnnotationController {
private final CredentialManService credentialManService;
@GetMapping(value = "/onl/apim/approval/credential/credentialMan.view")
public void view() {
}
@GetMapping(value = "/onl/apim/approval/credential/credentialMan.view", params = "cmd=DETAIL")
public String detailView() {
return "/onl/apim/approval/credential/credentialManDetail";
}
@PostMapping(value = "/onl/apim/approval/credential/credentialMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<CredentialUI>> selectList(@SortDefault("clientname") Pageable pageable,
CredentialSearch clientSearch) {
Page<CredentialUI> page = credentialManService.selectList(pageable, clientSearch);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value= "/onl/apim/approval/credential/credentialMan.json",params = "cmd=LIST_DETAIL_COMBO")
public ResponseEntity<Map<String, Object>> selectDetailCombo() throws Exception {
Map<String, Object> map = credentialManService.selectDetailCombo();
return ResponseEntity.ok(map);
}
@PostMapping(value = "/onl/apim/approval/credential/credentialMan.json", params = "cmd=DETAIL")
public ResponseEntity<CredentialUI> selectDetail(String clientId) {
CredentialUI clientUI = credentialManService.selectDetail(clientId);
return ResponseEntity.ok(clientUI);
}
@PostMapping(value = "/onl/apim/approval/credential/credentialMan.json", params = "cmd=INSERT")
public ResponseEntity<Void> insert(CredentialUI clientUI) {
credentialManService.insert(clientUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/credential/credentialMan.json", params = "cmd=UPDATE")
public ResponseEntity<Void> update(CredentialUI clientUI) {
credentialManService.update(clientUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/credential/credentialMan.json", params = "cmd=DELETE")
public ResponseEntity<Void> delete(String clientId) {
credentialManService.delete(clientId);
return ResponseEntity.ok().build();
}
}
@@ -0,0 +1,64 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.apim.portal.app.entity.Credential;
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.portalorg.PortalOrgService;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUI;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUIMapper;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@RequiredArgsConstructor
public class CredentialManService extends BaseService {
private final CredentialService credentialService;
private final CredentialUIMapper credentialUIMapper;
private final PortalOrgService portalOrgService;
private final PortalOrgUIMapper portalOrgUIMapper;
public Page<CredentialUI> selectList(Pageable pageable, CredentialSearch credentialSearch) {
Page<Credential> page = credentialService.findAll(pageable, credentialSearch);
return page.map(credentialUIMapper::toVo);
}
public HashMap<String, Object> selectDetailCombo() {
List<PortalOrg> portalOrgList = portalOrgService.findByOrgStatusAndApprovalStatus("ACTIVE", "COMPLETED");
List<PortalOrgUI> portalOrgUIList = portalOrgList.stream()
.map(portalOrgUIMapper::toVo)
.collect(Collectors.toList());
HashMap<String, Object> map = new HashMap<>();
map.put("portalOrgList", portalOrgUIList);
return map;
}
public CredentialUI selectDetail(String clientId) {
Credential credential = credentialService.getById(clientId);
return credentialUIMapper.toVo(credential);
}
public void insert(CredentialUI credentialUI) {
Credential credential = credentialUIMapper.toEntity(credentialUI);
credential.setAppstatus("1"); // Set default status to normal
credentialService.save(credential);
}
public void update(CredentialUI credentialUI) {
Credential credential = credentialService.getById(credentialUI.getClientid());
credentialUIMapper.updateToEntity(credentialUI, credential);
credentialService.save(credential);
}
public void delete(String clientId) {
credentialService.deleteById(clientId);
}
}
@@ -0,0 +1,14 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import lombok.Data;
@Data
public class CredentialSearch {
private String searchClientName;
private String searchClientId;
private String searchOrgId;
}
@@ -0,0 +1,32 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.apim.portal.app.entity.Credential;
import com.eactive.apim.portal.app.entity.QCredential;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.querydsl.core.types.dsl.BooleanExpression;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class CredentialService extends AbstractDataService<Credential, String, CredentialEMSRepository> {
public Page<Credential> findAll(Pageable pageable, CredentialSearch clientSearch) {
QCredential qClientEntity = QCredential.credential;
BooleanExpression predicate = qClientEntity.clientname.containsIgnoreCase(clientSearch.getSearchClientName());
if (StringUtils.isNotBlank(clientSearch.getSearchClientId())) {
predicate = predicate.and(qClientEntity.clientid.containsIgnoreCase(clientSearch.getSearchClientId()));
}
if (StringUtils.isNotBlank(clientSearch.getSearchOrgId())) {
predicate = predicate.and(qClientEntity.orgid.eq(clientSearch.getSearchOrgId()));
}
return repository.findAll(predicate, pageable);
}
}
@@ -0,0 +1,56 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
@Data
public class CredentialUI implements Serializable, com.eactive.eai.data.Data {
private static final long serialVersionUID = 1L;
private String clientid;
private String server;
private String accesstokenvalidityseconds;
private String allowedips;
private String authorities;
private String autoapprove;
private String clientname;
private String clientsecret;
private String granttypes;
private String modifiedby;
private String modifiedon;
private String redirecturi;
private String refreshtokenvalidityseconds;
private String resourceids;
private String scope;
private String securitykey;
private String orgid;
private String appstatus; //0: 차단, 1: 정상
private String orgname;
private int dailytokenlimit;
private List<ApiSpecInfoUI> apiList = new ArrayList<>();
}
@@ -0,0 +1,73 @@
package com.eactive.eai.rms.onl.apim.approval.credential;
import com.eactive.apim.portal.app.entity.Credential;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.manage.authserver.client.ClientUI;
import com.eactive.eai.rms.onl.transaction.apim.ApiInterfaceService;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiInterfaceUI;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;
import org.springframework.beans.factory.annotation.Autowired;
@Mapper(config = BaseMapperConfig.class, componentModel = "spring", uses = {ApiSpecUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class CredentialUIMapper implements GenericMapper<CredentialUI, Credential> {
@Autowired
private ApiInterfaceService apiInterfaceService;
@InheritInverseConfiguration
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
@Mapping(target = "apiList", expression = "java(apiSpecUIMapper.mapList(credentialUI.getApiList()))")
public abstract void updateToEntity(CredentialUI credentialUI, @MappingTarget Credential credential);
@Mapping(source = "clientid", target = "clientId")
@Mapping(source = "clientname", target = "clientName")
@Mapping(source = "clientsecret", target = "clientSecret")
@Mapping(source = "accesstokenvalidityseconds", target = "accessTokenValiditySeconds")
@Mapping(source = "allowedips", target = "allowedIps")
@Mapping(source = "autoapprove", target = "autoApprove")
@Mapping(source = "granttypes", target = "grantTypes")
@Mapping(source = "modifiedby", target = "modifiedBy")
@Mapping(source = "modifiedon", target = "modifiedOn", dateFormat = "yyyy-MM-dd HH:mm:ss")
@Mapping(source = "redirecturi", target = "redirectUri")
@Mapping(source = "refreshtokenvalidityseconds", target = "refreshTokenValiditySeconds")
@Mapping(source = "resourceids", target = "resourceIds")
@Mapping(source = "securitykey", target = "securityKey")
@Mapping(source = "orgid", target = "orgId")
@Mapping(source = "orgname", target = "orgName")
@Mapping(source = "appstatus", target = "appStatus")
@Mapping(source = "dailytokenlimit", target = "dailyTokenLimit")
@Mapping(target = "apiList", expression = "java(mapApiList(credential.getApiList()))")
@Mapping(source = "authorities", target = "authorities")
@Mapping(source = "scope", target = "scope")
public abstract ClientUI mapClient(CredentialUI credential);
protected List<ApiInterfaceUI> mapApiList(List<ApiSpecInfoUI> apiSpecInfoList) {
if (apiSpecInfoList == null) {
return new ArrayList<>();
}
return apiSpecInfoList.stream()
.map(apiSpecInfo -> {
ApiInterfaceUI apiInterface = null;
try {
apiInterface = apiInterfaceService.selectDetail(apiSpecInfo.getApiId());
return apiInterface;
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.toList());
}
}
@@ -0,0 +1,11 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.apim.portal.app.entity.ProdClient;
import com.eactive.eai.data.jpa.BaseRepository;
import com.eactive.eai.rms.data.EMSDataSource;
@EMSDataSource
public interface ProdClientEMSRepository extends BaseRepository<ProdClient, String> {
}
@@ -0,0 +1,67 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.vo.GridResponse;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequiredArgsConstructor
public class ProdClientManController extends OnlBaseAnnotationController {
private final ProdClientManService prodClientManService;
@GetMapping(value = "/onl/apim/approval/prodclient/clientMan.view")
public void view() {
}
@GetMapping(value = "/onl/apim/approval/prodclient/clientMan.view", params = "cmd=DETAIL")
public String detailView() {
return "/onl/apim/approval/prodclient/clientManDetail";
}
@PostMapping(value = "/onl/apim/approval/prodclient/clientMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<ProdClientUI>> selectList(@SortDefault("clientname") Pageable pageable,
ProdClientSearch clientSearch) {
Page<ProdClientUI> page = prodClientManService.selectList(pageable, clientSearch);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value= "/onl/apim/approval/prodclient/clientMan.json",params = "cmd=LIST_DETAIL_COMBO")
public ResponseEntity<Map<String, Object>> selectDetailCombo() throws Exception {
Map<String, Object> map = prodClientManService.selectDetailCombo();
return ResponseEntity.ok(map);
}
@PostMapping(value = "/onl/apim/approval/prodclient/clientMan.json", params = "cmd=DETAIL")
public ResponseEntity<ProdClientUI> selectDetail(String clientId) {
ProdClientUI clientUI = prodClientManService.selectDetail(clientId);
return ResponseEntity.ok(clientUI);
}
@PostMapping(value = "/onl/apim/approval/prodclient/clientMan.json", params = "cmd=INSERT")
public ResponseEntity<Void> insert(ProdClientUI clientUI) {
prodClientManService.insert(clientUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/prodclient/clientMan.json", params = "cmd=UPDATE")
public ResponseEntity<Void> update(ProdClientUI clientUI) {
prodClientManService.update(clientUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approval/prodclient/clientMan.json", params = "cmd=DELETE")
public ResponseEntity<Void> delete(String clientId) {
prodClientManService.delete(clientId);
return ResponseEntity.ok().build();
}
}
@@ -0,0 +1,64 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.apim.portal.app.entity.ProdClient;
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.portalorg.PortalOrgService;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUI;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUIMapper;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@RequiredArgsConstructor
public class ProdClientManService extends BaseService {
private final ProdClientService prodClientService;
private final ProdClientUIMapper prodClientUIMapper;
private final PortalOrgService portalOrgService;
private final PortalOrgUIMapper portalOrgUIMapper;
public Page<ProdClientUI> selectList(Pageable pageable, ProdClientSearch prodClientSearch) {
Page<ProdClient> page = prodClientService.findAll(pageable, prodClientSearch);
return page.map(prodClientUIMapper::toVo);
}
public HashMap<String, Object> selectDetailCombo() {
List<PortalOrg> portalOrgList = portalOrgService.findByOrgStatusAndApprovalStatus("ACTIVE", "COMPLETED");
List<PortalOrgUI> portalOrgUIList = portalOrgList.stream()
.map(portalOrgUIMapper::toVo)
.collect(Collectors.toList());
HashMap<String, Object> map = new HashMap<>();
map.put("portalOrgList", portalOrgUIList);
return map;
}
public ProdClientUI selectDetail(String clientId) {
ProdClient prodClient = prodClientService.getById(clientId);
return prodClientUIMapper.toVo(prodClient);
}
public void insert(ProdClientUI prodClientUI) {
ProdClient prodClient = prodClientUIMapper.toEntity(prodClientUI);
prodClient.setAppstatus("1"); // Set default status to normal
prodClientService.save(prodClient);
}
public void update(ProdClientUI prodClientUI) {
ProdClient prodClient = prodClientService.getById(prodClientUI.getClientid());
prodClientUIMapper.updateToEntity(prodClientUI, prodClient);
prodClientService.save(prodClient);
}
public void delete(String clientId) {
prodClientService.deleteById(clientId);
}
}
@@ -0,0 +1,14 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import lombok.Data;
@Data
public class ProdClientSearch {
private String searchClientName;
private String searchClientId;
private String searchOrgId;
}
@@ -0,0 +1,32 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.apim.portal.app.entity.ProdClient;
import com.eactive.apim.portal.app.entity.QProdClient;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.querydsl.core.types.dsl.BooleanExpression;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class ProdClientService extends AbstractDataService<ProdClient, String, ProdClientEMSRepository> {
public Page<ProdClient> findAll(Pageable pageable, ProdClientSearch clientSearch) {
QProdClient qClientEntity = QProdClient.prodClient;
BooleanExpression predicate = qClientEntity.clientname.containsIgnoreCase(clientSearch.getSearchClientName());
if (StringUtils.isNotBlank(clientSearch.getSearchClientId())) {
predicate = predicate.and(qClientEntity.clientid.containsIgnoreCase(clientSearch.getSearchClientId()));
}
if (StringUtils.isNotBlank(clientSearch.getSearchOrgId())) {
predicate = predicate.and(qClientEntity.orgid.eq(clientSearch.getSearchOrgId()));
}
return repository.findAll(predicate, pageable);
}
}
@@ -0,0 +1,54 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.eai.rms.onl.transaction.apim.ui.ApiSpecInfoUI;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
@Data
public class ProdClientUI implements Serializable, com.eactive.eai.data.Data{
private static final long serialVersionUID = 1L;
private String clientid;
private String accesstokenvalidityseconds;
private String allowedips;
private String authorities;
private String autoapprove;
private String clientname;
private String clientsecret;
private String granttypes;
private String modifiedby;
private LocalDateTime modifiedon;
private String redirecturi;
private String refreshtokenvalidityseconds;
private String resourceids;
private String scope;
private String securitykey;
private String orgid;
private String appstatus; //0: 차단, 1: 정상
private String orgname;
private int dailytokenlimit;
private List<ApiSpecInfoUI> apiList = new ArrayList<>();
}
@@ -0,0 +1,22 @@
package com.eactive.eai.rms.onl.apim.approval.prodclient;
import com.eactive.apim.portal.app.entity.ProdClient;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;
@Mapper(config = BaseMapperConfig.class, componentModel = "spring", uses = {ApiSpecUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ProdClientUIMapper implements GenericMapper<ProdClientUI, ProdClient> {
@InheritInverseConfiguration
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
@Mapping(target = "apiList", expression = "java(apiSpecUIMapper.mapList(prodClientUI.getApiList()))")
public abstract void updateToEntity(ProdClientUI prodClientUI, @MappingTarget ProdClient prodClient);
}
@@ -0,0 +1,182 @@
package com.eactive.eai.rms.onl.apim.approval.user;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.apim.portal.approval.service.ApprovalDeployException;
import com.eactive.apim.portal.approval.statemachine.listener.ApprovalListener;
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.ApprovalStatus;
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.OrgStatus;
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
import com.eactive.apim.portal.portaluser.entity.PortalUser;
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums;
import com.eactive.apim.portal.template.service.MessageRecipient;
import com.eactive.apim.portal.template.service.MessageSendService;
import com.eactive.eai.rms.data.entity.onl.apim.portalorg.PortalOrgService;
import com.eactive.eai.rms.data.entity.onl.apim.portaluser.PortalUserService;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUI;
import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgUIMapper;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
@Service
@Transactional
@RequiredArgsConstructor
public class PortalUserApprovalListener implements ApprovalListener {
private static final Logger logger = LoggerFactory.getLogger(PortalUserApprovalListener.class);
private static final String PORTAL_PROPERTY_GROUP = "Portal";
private final PortalPropertyService portalPropertyService;
private final PortalOrgService portalOrgService;
private final PortalUserService portalUserService;
private final MessageSendService messageSendService;
private final PortalOrgUIMapper portalOrgUIMapper;
public static RestTemplate createRestTemplateWithTimeout(int connectTimeout) {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(connectTimeout)
.setConnectTimeout(connectTimeout)
.setSocketTimeout(connectTimeout)
.build();
HttpClient httpClient =
HttpClientBuilder.create()
.setMaxConnTotal(50)
.setMaxConnPerRoute(20)
.setDefaultRequestConfig(requestConfig)
.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
return restTemplate;
}
@Override
public void execute(Approval approval, Map<String, Object> options) throws ApprovalDeployException {
logger.info("Approval {} ended successfully", approval.getId());
String userId = approval.getTargetId();
PortalUser portalUser = portalUserService.findByUserId(userId);
portalUser.setApprovalStatus(PortalUserEnums.ApprovalStatus.COMPLETED);
portalUserService.save(portalUser);
PortalOrg portalOrg = portalUser.getPortalOrg();
portalOrg.setApprovalStatus(ApprovalStatus.COMPLETED);
portalOrg.setOrgStatus(OrgStatus.ACTIVE);
portalOrgService.save(portalOrg);
syncStaging(portalOrgUIMapper.toVo(portalOrg));
sendApprovalResult(portalUser);
}
private void sendApprovalResult(PortalUser portalUser) {
MessageRecipient recipient = new MessageRecipient();
recipient.setPhone(portalUser.getMobileNumber());
recipient.setUserId(portalUser.getEmailAddr());
Map<String, String> params = new HashMap<>();
messageSendService.sendMessage("USER_REGISTER_APPROVED", recipient, params);
}
private void syncStaging(PortalOrgUI portalOrgUI) throws ApprovalDeployException {
// 프록시를 통한 스테이징 서버 호출 추가
Map<String, String> properties = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY_GROUP);
String apiKey = properties.get("apiKey");
String proxyUrl = properties.get("portal.url");
String timeout = properties.getOrDefault("deploy.proxy_timeout", "10000");
String proxyEndpoint = proxyUrl + "/_onl/apim/portalorg/portalOrgMan.json";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("X-API-KEY", apiKey);
headers.set("target_host", "stg");
headers.set("action", "insert");
portalOrgUI.setCompRegFile(null);
HttpEntity<PortalOrgUI> request = new HttpEntity<>(portalOrgUI, headers);
try {
ResponseEntity<String> response = createRestTemplateWithTimeout(Integer.parseInt(timeout)).exchange(
proxyEndpoint,
HttpMethod.POST,
request,
String.class
);
if (!response.getStatusCode().is2xxSuccessful()) {
logger.error("Failed to sync with staging server. Status: {}, Body: {}", response.getStatusCode(), response.getBody());
throw new ApprovalDeployException("기관 정보 배포에 실패 했습니다.");
}
} catch (Exception e) {
logger.error("Failed to sync with staging server. {}", e.getMessage());
throw new ApprovalDeployException("기관 정보 배포에 실패 했습니다.");
}
}
@Override
public void rollback(Approval approval) {
logger.debug("Rollback started for approval ID: {}, type: {}, status: {}",
approval.getId(),
approval.getApprovalType(),
approval.getApprovalStatus());
logger.info("Approval {} rollback", approval.getId());
String userId = approval.getTargetId();
LocalDateTime now = LocalDateTime.now();
String rejectedDate = now.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
PortalUser portalUser = portalUserService.findByUserId(userId);
portalUser.setUserName("반려된 사용자");
portalUser.setMobileNumber("");
portalUser.setLoginId(portalUser.getId() + "-d" + rejectedDate);
portalUser.setEmailAddr(portalUser.getId() + "-d" + rejectedDate);
portalUser.setUserStatus(PortalUserEnums.UserStatus.INACTIVE);
portalUser.setApprovalStatus(PortalUserEnums.ApprovalStatus.REJECTED);
portalUser.setPhoneNumber(null);
portalUser.setAuthCompletedYn("N");
portalUser.setLoginFailureCount(0);
portalUser.setAccountLockYn("N");
portalUserService.save(portalUser);
PortalOrg portalOrg = portalUser.getPortalOrg();
portalOrg.setOrgName("삭제된법인");
portalOrg.setApprovalStatus(ApprovalStatus.REJECTED);
portalOrg.setOrgStatus(OrgStatus.REMOVED);
portalOrg.setOrgCode(null);
portalOrg.setCompRegFile(null);
portalOrg.setCorpRegNo(null);
portalOrg.setCompRegNo(null);
portalOrg.setCeoName(null);
portalOrg.setOrgAddr(null);
portalOrg.setOrgPhoneNumber(null);
portalOrg.setScPhoneNumber(null);
portalOrg.setOrgSectors(null);
portalOrg.setOrgIndustryType(null);
portalOrg.setServiceName(null);
portalOrgService.save(portalOrg);
}
}
@@ -0,0 +1,13 @@
package com.eactive.eai.rms.onl.apim.approval.user;
import com.eactive.eai.rms.onl.apim.approval.PortalApprovalUI;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class PortalUserApprovalUI extends PortalApprovalUI {
PortalUserUI portalUser;
}
@@ -0,0 +1,14 @@
package com.eactive.eai.rms.onl.apim.approval.user;
import com.eactive.apim.portal.approval.entity.Approval;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.apim.approval.PortalApprovalApproverUIMapper;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUIMapper;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", uses = {PortalUserUIMapper.class, PortalApprovalApproverUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalUserApprovalUIMapper extends GenericMapper<PortalUserApprovalUI, Approval> {
}
@@ -0,0 +1,101 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.eactive.eai.rms.common.acl.user.UserManService;
import com.eactive.eai.rms.common.acl.user.ui.UserUI;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.vo.GridResponse;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class PortalApprovalLineManController extends BaseAnnotationController {
private final PortalApprovalLineManService portalApprovalLineManService;
private final UserManService userManService;
private final ComboService comboService;
@GetMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.view")
public void view() {
// view
}
@GetMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.view", params = "cmd=DETAIL")
public String detailNewView() {
return "/onl/apim/approvalline/portalApprovalLineManPopup";
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<PortalApprovalLineUI>> selectList(@SortDefault("createdDate") Pageable pageable) {
Page<PortalApprovalLineUI> page = portalApprovalLineManService.selectList(pageable);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=DETAIL")
public ResponseEntity<PortalApprovalLineUI> selectDetail(String id) {
PortalApprovalLineUI portalUserUI = portalApprovalLineManService.selectDetail(id);
return ResponseEntity.ok(portalUserUI);
}
public Map<String, Object> getCommonComboData() {
List<ComboVo> approvalTypeList = comboService.getFromApprovalType(); // 승인타입코드
List<ComboVo> portalOrgList = comboService.getFromPortalOrgName(); // 기관코드
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("approvalTypeRows", approvalTypeList);
resultMap.put("orgRows", portalOrgList);
return resultMap;
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=LIST_INIT_COMBO")
public ResponseEntity<Map<String, Object>> listInitCombo() {
Map<String, Object> resultMap = getCommonComboData();
return ResponseEntity.ok(resultMap);
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=INIT_COMBO")
public ResponseEntity<Map<String, Object>> initCombo() {
Map<String, Object> resultMap = getCommonComboData();
resultMap.put("usedApprovalTypes", portalApprovalLineManService.getUsedApprovalTypes());
return ResponseEntity.ok(resultMap);
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=SEARCH_USER")
public ResponseEntity<GridResponse<UserUI>> findUser (@SortDefault("userid") Pageable pageable, String username) {
Page<UserUI> page = userManService.findUserList(pageable, username);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=INSERT")
public ResponseEntity<PortalApprovalLineUI> insert(PortalApprovalLineUI portalApprovalLineUI) {
portalApprovalLineManService.insert(portalApprovalLineUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=UPDATE")
public ResponseEntity<PortalApprovalLineUI> upate(PortalApprovalLineUI portalApprovalLineUI) {
portalApprovalLineManService.update(portalApprovalLineUI);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/onl/apim/approvalline/portalApprovalLineMan.json", params = "cmd=DELETE")
public ResponseEntity<String> delete(String id) {
portalApprovalLineManService.delete(id);
return ResponseEntity.ok().build();
}
}
@@ -0,0 +1,98 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.apim.portal.approvalline.entity.PortalApprovalLine;
import com.eactive.apim.portal.approvalline.entity.PortalApprovalLineUser;
import com.eactive.apim.portal.approvalline.entity.PortalApprovalLineUserId;
import com.eactive.apim.portal.approvalline.service.PortalApprovalLineService;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.man.user.UserInfoService;
import lombok.RequiredArgsConstructor;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@RequiredArgsConstructor
public class PortalApprovalLineManService extends BaseService {
private final PortalApprovalLineService portalApprovalLineService;
private final PortalApprovalLineUIMapper portalApprovalLineUIMapper;
private final PortalApprovalLineUserUIMapper portalApprovalLineUserUIMapper;
private final UserInfoService userInfoService;
public Page<PortalApprovalLineUI> selectList(Pageable pageable) {
return portalApprovalLineService.findAll(pageable).map(portalApprovalLineUIMapper::toVo);
}
public PortalApprovalLineUI selectDetail(String id) {
PortalApprovalLine portalApprovalLine = portalApprovalLineService.getById(id);
return portalApprovalLineUIMapper.toVo(portalApprovalLine);
}
public void insert(PortalApprovalLineUI portalApprovalLineUI) {
PortalApprovalLine portalApprovalLine = new PortalApprovalLine();
portalApprovalLine.setApprovalType(portalApprovalLineUI.getApprovalType());
portalApprovalLine.setApprovalName(portalApprovalLineUI.getApprovalName());
portalApprovalLine = portalApprovalLineService.save(portalApprovalLine);
List<PortalApprovalLineUser> approvalLineUsers = createApprovalLineUsers(portalApprovalLine,
portalApprovalLineUI.getPortalApprovalLineUsers());
portalApprovalLine.setPortalApprovalLineUsers(approvalLineUsers);
portalApprovalLineService.save(portalApprovalLine);
}
private List<PortalApprovalLineUser> createApprovalLineUsers(PortalApprovalLine portalApprovalLine,
List<PortalApprovalLineUserUI> userUIList) {
return userUIList.stream().map(userUI -> {
PortalApprovalLineUser approvalLineUser = portalApprovalLineUserUIMapper.toEntity(userUI);
PortalApprovalLineUserId id = new PortalApprovalLineUserId();
id.setApprovalLineId(portalApprovalLine.getId());
id.setUserId(userUI.getUserId());
approvalLineUser.setId(id);
approvalLineUser.setUser(userInfoService.getById(userUI.getUserId()));
approvalLineUser.setApprovalLine(portalApprovalLine);
return approvalLineUser;
}).collect(Collectors.toList());
}
public void update(PortalApprovalLineUI portalApprovalLineUI) {
PortalApprovalLine portalApprovalLine = portalApprovalLineService.getById(portalApprovalLineUI.getId());
portalApprovalLine.setApprovalName(portalApprovalLineUI.getApprovalName());
portalApprovalLine.setApprovalType(portalApprovalLineUI.getApprovalType());
portalApprovalLine.getPortalApprovalLineUsers().clear();
List<PortalApprovalLineUser> portalApprovalLineUsers = createApprovalLineUsers(portalApprovalLine,
portalApprovalLineUI.getPortalApprovalLineUsers());
portalApprovalLine.getPortalApprovalLineUsers().addAll(portalApprovalLineUsers);
portalApprovalLineService.save(portalApprovalLine);
}
public void delete(String id) {
portalApprovalLineService.deleteById(id);
}
public List<String> getUsedApprovalTypes() {
return portalApprovalLineService.findAll().stream()
.map(PortalApprovalLine::getApprovalType).distinct()
.collect(Collectors.toList());
}
}
@@ -0,0 +1,40 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.format.annotation.DateTimeFormat;
import com.eactive.eai.data.converter.LocalDateTimeFormatters;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@Data
public class PortalApprovalLineUI {
private String id;
private String approvalType;
private String approvalName;
private List<PortalApprovalLineUserUI> portalApprovalLineUsers;
private String createdBy;
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSS_14)
@DateTimeFormat(pattern = "yyyyMMddHHmmss")
private LocalDateTime createdDate;
private String lastModifiedBy;
@JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSS_14)
@DateTimeFormat(pattern = "yyyyMMddHHmmss")
private LocalDateTime lastModifiedDate; // 수정일시
public void setPortalApprovalLineUsers(List<PortalApprovalLineUserUI>portalApprovalLineUsers) {
this.portalApprovalLineUsers = portalApprovalLineUsers;
}
}
@@ -0,0 +1,16 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import com.eactive.apim.portal.approvalline.entity.PortalApprovalLine;
import org.mapstruct.*;
@Mapper(componentModel = "spring", uses = { PortalApprovalLineUserUIMapper.class }, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalApprovalLineUIMapper {
PortalApprovalLineUI toVo(PortalApprovalLine entity);
PortalApprovalLine toEntity(PortalApprovalLineUI vo);
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
void updateToEntity(PortalApprovalLineUI portalApprovalLineUI, @MappingTarget PortalApprovalLine portalApprovalLine);
}
@@ -0,0 +1,15 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import lombok.Data;
@Data
public class PortalApprovalLineUserUI {
private String approvalLineId;
private String userId;
private String userName;
private Integer approvalOrder;
}
@@ -0,0 +1,26 @@
package com.eactive.eai.rms.onl.apim.approvalline;
import com.eactive.apim.portal.approvalline.entity.PortalApprovalLineUser;
import com.eactive.eai.data.mapper.GenericMapper;
import org.mapstruct.*;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PortalApprovalLineUserUIMapper extends GenericMapper<PortalApprovalLineUserUI, PortalApprovalLineUser> {
@Override
@Mapping(target = "userId", source = "id.userId")
@Mapping(target = "approvalLineId", source = "id.approvalLineId")
@Mapping(target = "userName", source = "user.username")
PortalApprovalLineUserUI toVo(PortalApprovalLineUser entity);
@Override
@InheritInverseConfiguration
@Mapping(target = "user", ignore = true)
PortalApprovalLineUser toEntity(PortalApprovalLineUserUI vo);
@InheritInverseConfiguration
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
@Mapping(target = "user", ignore = true)
void updateToEntity(PortalApprovalLineUserUI portalApprovalLineUserUI, @MappingTarget PortalApprovalLineUser portalApprovalLineUser);
}
@@ -0,0 +1,44 @@
package com.eactive.eai.rms.onl.apim.file;
import com.eactive.apim.portal.file.entity.FileDetail;
import com.eactive.apim.portal.file.service.FileService;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
@Controller
@RequestMapping("/file")
public class AdminFileDownloadController {
FileService fileService;
public AdminFileDownloadController(FileService fileService) {
this.fileService = fileService;
}
@GetMapping(value = "/download.do")
public void downloadFileAdmin(@RequestParam(value = "fileId", defaultValue = "0") String fileId,
@RequestParam(value = "fileSn", defaultValue = "-1") int fileSn,
HttpServletResponse response) throws IOException {
// Get the FileDetail object from the service layer
FileDetail fileDetail = fileService.getFileDetailByIds(fileId, fileSn);
// Set the response headers
response.setContentType("application/octet-stream");
String encodedFilename = URLEncoder.encode(fileDetail.getOriginalFileName() + "." + fileDetail.getFileExtension(), "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFilename + "\";");
response.setContentLength(fileDetail.getFileSize());
// Decode the base64-encoded file contents and write the file to the response stream
byte[] fileContents = fileService.retrieveFileContent(fileDetail);
IOUtils.write(fileContents, response.getOutputStream());
response.flushBuffer();
}
}
@@ -0,0 +1,83 @@
package com.eactive.eai.rms.onl.apim.masking;
import com.eactive.eai.rms.common.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class MaskingUtils {
/**
* 이메일 주소의 ID 부분을 마스킹 처리
* 예: eactive@gmail.com => eact***@gmail.com
*/
public static String maskEmailId(String email) {
if (email == null || email.isEmpty() || !email.contains("@")) {
return email;
}
String[] parts = email.split("@");
String id = parts[0];
String domain = parts[1];
if (id.length() <= 3) {
return "***" + "@" + domain;
}
String maskedId = id.substring(0, id.length() - 3) + "***";
return maskedId + "@" + domain;
}
/**
* 이름의 마지막 글자를 마스킹 처리
*/
public static String maskName(String name) {
if (name == null || name.isEmpty() || name.length() < 2) {
return name;
}
return name.substring(0, name.length() - 1) + "*";
}
/**
* 전화번호 마스킹 처리
* 예: 010-1234-5678 => 010-****-5678
*/
public static String maskPhoneNumber(String phoneNumber) {
if (phoneNumber == null || phoneNumber.isEmpty()) {
return phoneNumber;
}
String[] parts = phoneNumber.split("-");
if (parts.length != 3) {
return phoneNumber;
}
return parts[0] + "-****-" + parts[2];
}
/**
* IP 주소 마스킹 처리
* 예: 192.168.1.1 => 192.168.*.*
*/
public static String maskIpAddress(String ipAddresses) {
if (StringUtils.isBlank(ipAddresses)) {
return ipAddresses;
}
String[] ips = ipAddresses.split(",");
List<String> maskedIps = Arrays.stream(ips)
.map(ip -> {
String[] parts = ip.trim().split("\\.");
if (parts.length == 4) {
// 세 번째 octet을 ***로 마스킹
parts[2] = "***";
return String.join(".", parts);
}
return ip; // 유효하지 않은 IP 형식은 그대로 반환
})
.collect(Collectors.toList());
return String.join(",", maskedIps);
}
}

Some files were not shown because too many files have changed in this diff Show More