|
|
|
@@ -1,10 +1,10 @@
|
|
|
|
|
package com.eactive.eai.rms.onl.loader.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@@ -1451,77 +1451,92 @@ public class LoaderController implements InterceptorSkipController {
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
@RequestMapping( params ={"cmd=interface","control=downloadfull"})
|
|
|
|
|
public ModelAndView interfaceDownLoadFully(String serviceType, String interfaceId) throws Exception {
|
|
|
|
|
public ModelAndView interfaceDownLoadFully(String serviceType, String interfaceId) {
|
|
|
|
|
DataSourceType dt = DataSourceTypeManager.getDataSourceType(serviceType);
|
|
|
|
|
DataSourceContextHolder.setDataSourceType(dt);
|
|
|
|
|
|
|
|
|
|
// 1. interface 데이터 다운로드
|
|
|
|
|
InterfaceDeployPack interfaceDeployPack = new InterfaceDeployPack();
|
|
|
|
|
String json = "";
|
|
|
|
|
try {
|
|
|
|
|
// 1. interface 데이터 다운로드
|
|
|
|
|
InterfaceDeployPack interfaceDeployPack = new InterfaceDeployPack();
|
|
|
|
|
|
|
|
|
|
EAIMessageDeploy eaiMessageDeploy = interfaceDeployService.selectDeploy(interfaceId);
|
|
|
|
|
eaiMessageDeploy.setEailastamndyms(null);
|
|
|
|
|
EAIMessageDeploy eaiMessageDeploy = interfaceDeployService.selectDeploy(interfaceId);
|
|
|
|
|
eaiMessageDeploy.setEailastamndyms(null);
|
|
|
|
|
|
|
|
|
|
interfaceDeployPack.setEaiMessageDeploy(eaiMessageDeploy);
|
|
|
|
|
interfaceDeployPack.setEaiMessageDeploy(eaiMessageDeploy);
|
|
|
|
|
|
|
|
|
|
for(StandardMessageInfoDeploy standardMessageInfoDeploy : eaiMessageDeploy.getStandardMessageInfoDeploys()){
|
|
|
|
|
standardMessageInfoDeploy.setEailastamndyms(null);
|
|
|
|
|
}
|
|
|
|
|
for(StandardMessageInfoDeploy standardMessageInfoDeploy : eaiMessageDeploy.getStandardMessageInfoDeploys()){
|
|
|
|
|
standardMessageInfoDeploy.setEailastamndyms(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (ServiceMessageDeploy serviceMessageDeploy : eaiMessageDeploy.getServiceMessages()){
|
|
|
|
|
String[] transformNames = {serviceMessageDeploy.getChngmsgidname(), serviceMessageDeploy.getBascrspnschngmsgidname()};
|
|
|
|
|
// 2. Layout 데이터 생성
|
|
|
|
|
for(String transformName: transformNames){
|
|
|
|
|
if(StringUtils.isBlank(transformName)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(TransformSourceResultUI transformSourceResultUI : transform2Service.selectTransformSourceResult(transformName)){
|
|
|
|
|
String loutName = transformSourceResultUI.getLoutName();
|
|
|
|
|
if(StringUtils.isBlank(loutName)){
|
|
|
|
|
for (ServiceMessageDeploy serviceMessageDeploy : eaiMessageDeploy.getServiceMessages()){
|
|
|
|
|
String[] transformNames = {serviceMessageDeploy.getChngmsgidname(), serviceMessageDeploy.getBascrspnschngmsgidname()};
|
|
|
|
|
// 2. Layout 데이터 생성
|
|
|
|
|
for(String transformName: transformNames){
|
|
|
|
|
if(StringUtils.isBlank(transformName)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LayoutDeploy layoutDeploy = layoutDeployService.selectDeploy(loutName);
|
|
|
|
|
layoutDeploy.setLastamndhms(null);
|
|
|
|
|
interfaceDeployPack.getLayoutDeployList().add(layoutDeploy);
|
|
|
|
|
|
|
|
|
|
for(TransformSourceResultUI transformSourceResultUI : transform2Service.selectTransformSourceResult(transformName)){
|
|
|
|
|
String loutName = transformSourceResultUI.getLoutName();
|
|
|
|
|
if(StringUtils.isBlank(loutName)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LayoutDeploy layoutDeploy = layoutDeployService.selectDeploy(loutName);
|
|
|
|
|
layoutDeploy.setLastamndhms(null);
|
|
|
|
|
interfaceDeployPack.getLayoutDeployList().add(layoutDeploy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Transform 데이터 생성
|
|
|
|
|
TransformDeploy transformDeploy = transformDeployService.selectDeploy(transformName);
|
|
|
|
|
transformDeploy.setLastamndhms(null);
|
|
|
|
|
interfaceDeployPack.getTransformDeployList().add(transformDeploy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Transform 데이터 생성
|
|
|
|
|
TransformDeploy transformDeploy = transformDeployService.selectDeploy(transformName);
|
|
|
|
|
transformDeploy.setLastamndhms(null);
|
|
|
|
|
interfaceDeployPack.getTransformDeployList().add(transformDeploy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. API 스펙 정보(ptl_api_spec_info) 추가 (감사(audit) 컬럼은 제외)
|
|
|
|
|
Optional<ApiSpecInfo> optSpecInfo = apiSpecInfoService.findById(interfaceId);
|
|
|
|
|
if (optSpecInfo.isPresent()) {
|
|
|
|
|
ApiSpecInfoUI specInfo = apiSpecUIMapper.mapToUI(optSpecInfo.get());
|
|
|
|
|
specInfo.setCreatedBy(null);
|
|
|
|
|
specInfo.setCreatedDate(null);
|
|
|
|
|
specInfo.setLastModifiedBy(null);
|
|
|
|
|
specInfo.setLastModifiedDate(null);
|
|
|
|
|
interfaceDeployPack.setSpecInfo(specInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.registerModule(new JavaTimeModule());
|
|
|
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
|
|
|
ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
|
|
|
|
|
String bizCode = eaiMessageDeploy.getEaibzwkdstcd();
|
|
|
|
|
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_DOWNLOAD_PATH);
|
|
|
|
|
String fileDir = FilenameUtils.concat(ioMapPath, bizCode);
|
|
|
|
|
String fileFullPath = FilenameUtils.concat(fileDir, interfaceId+".json");
|
|
|
|
|
|
|
|
|
|
FileWriteUtil.makeDirWithGroupPermission(fileDir);
|
|
|
|
|
File file = new File(fileFullPath);
|
|
|
|
|
json = writer.writeValueAsString(interfaceDeployPack);
|
|
|
|
|
FileUtils.writeStringToFile(file, json, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
|
|
// TSEAITR10 배포 이력 저장 (SERVICENAME=eCams, COMMAND=downloadfull, LOUTNAME=interfaceId, RECVDATA=json)
|
|
|
|
|
loaderService.insertDeploySyncLog(dt, "downloadfull", interfaceId, json);
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<>();
|
|
|
|
|
result.put("status", "success");
|
|
|
|
|
result.put("message", fileFullPath+" write done.");
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("interface downloadfull error - interfaceId=" + interfaceId, e);
|
|
|
|
|
loaderService.insertDeployFailLog(dt, "downloadfull", interfaceId, json, e.toString());
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<>();
|
|
|
|
|
result.put("status", "fail");
|
|
|
|
|
result.put("message", e.toString());
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. API 스펙 정보(ptl_api_spec_info) 추가 (감사(audit) 컬럼은 제외)
|
|
|
|
|
Optional<ApiSpecInfo> optSpecInfo = apiSpecInfoService.findById(interfaceId);
|
|
|
|
|
if (optSpecInfo.isPresent()) {
|
|
|
|
|
ApiSpecInfoUI specInfo = apiSpecUIMapper.mapToUI(optSpecInfo.get());
|
|
|
|
|
specInfo.setCreatedBy(null);
|
|
|
|
|
specInfo.setCreatedDate(null);
|
|
|
|
|
specInfo.setLastModifiedBy(null);
|
|
|
|
|
specInfo.setLastModifiedDate(null);
|
|
|
|
|
interfaceDeployPack.setSpecInfo(specInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.registerModule(new JavaTimeModule());
|
|
|
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
|
|
|
ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
|
|
|
|
|
String bizCode = eaiMessageDeploy.getEaibzwkdstcd();
|
|
|
|
|
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_DOWNLOAD_PATH);
|
|
|
|
|
String fileDir = FilenameUtils.concat(ioMapPath, bizCode);
|
|
|
|
|
String fileFullPath = FilenameUtils.concat(fileDir, interfaceId+".json");
|
|
|
|
|
|
|
|
|
|
FileWriteUtil.makeDirWithGroupPermission(fileDir);
|
|
|
|
|
File file = new File(fileFullPath);
|
|
|
|
|
writer.writeValue(file, interfaceDeployPack);
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<>();
|
|
|
|
|
String status = "success";
|
|
|
|
|
result.put("status", status);
|
|
|
|
|
result.put("message", fileFullPath+" write done.");
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -1533,57 +1548,73 @@ public class LoaderController implements InterceptorSkipController {
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping( params ={"cmd=interface","control=uploadfull"})
|
|
|
|
|
public ModelAndView interfaceLoadFully(String serviceType, String filePath) throws Exception {
|
|
|
|
|
public ModelAndView interfaceLoadFully(String serviceType, String filePath) {
|
|
|
|
|
DataSourceType dt = DataSourceTypeManager.getDataSourceType(serviceType);
|
|
|
|
|
DataSourceContextHolder.setDataSourceType(dt);
|
|
|
|
|
|
|
|
|
|
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_UPLOAD_PATH);
|
|
|
|
|
String fileFullPath ;
|
|
|
|
|
if(StringUtils.isBlank(ioMapPath)) {
|
|
|
|
|
fileFullPath = filePath;
|
|
|
|
|
} else {
|
|
|
|
|
fileFullPath = FilenameUtils.concat(ioMapPath, filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File file = new File(fileFullPath);
|
|
|
|
|
InputStream inputStream = new FileInputStream(file);
|
|
|
|
|
// ObjectMapper 생성 및 설정
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.registerModule(new JavaTimeModule());
|
|
|
|
|
InterfaceDeployPack interfaceDeployPack = objectMapper.readValue(inputStream, InterfaceDeployPack.class);
|
|
|
|
|
|
|
|
|
|
EAIMessageDeploy eaiMessageDeploy = interfaceDeployPack.getEaiMessageDeploy();
|
|
|
|
|
|
|
|
|
|
interfaceDeployService.saveDeploy(eaiMessageDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand("com.ext.eai.agent.stdmessage.ReloadSTDMessageCommand", "ALL"));
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand("com.eactive.eai.agent.eaimessage.ReloadEAIMessageCommand", eaiMessageDeploy.getEaisvcname()));
|
|
|
|
|
|
|
|
|
|
for(LayoutDeploy layoutDeploy: interfaceDeployPack.getLayoutDeployList()){
|
|
|
|
|
layoutDeployService.saveDeploy(layoutDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadLayoutCommand", layoutDeploy.getLoutname()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(TransformDeploy transformDeploy : interfaceDeployPack.getTransformDeployList()){
|
|
|
|
|
transformDeployService.saveDeploy(transformDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadTransformCommand", transformDeploy.getCnvsnname()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiSpecInfoUI specInfoUI = interfaceDeployPack.getSpecInfo();
|
|
|
|
|
if (specInfoUI != null && StringUtils.isNotBlank(specInfoUI.getApiId())) {
|
|
|
|
|
ApiSpecInfo specInfo = apiSpecUIMapper.mapToEntity(specInfoUI);
|
|
|
|
|
if (apiSpecInfoService.findById(specInfo.getApiId()).isPresent()) {
|
|
|
|
|
apiSpecInfoService.updateById(specInfo.getApiId(), specInfo);
|
|
|
|
|
String json = "";
|
|
|
|
|
String loutName = filePath;
|
|
|
|
|
try {
|
|
|
|
|
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_UPLOAD_PATH);
|
|
|
|
|
String fileFullPath ;
|
|
|
|
|
if(StringUtils.isBlank(ioMapPath)) {
|
|
|
|
|
fileFullPath = filePath;
|
|
|
|
|
} else {
|
|
|
|
|
apiSpecInfoService.create(specInfo);
|
|
|
|
|
fileFullPath = FilenameUtils.concat(ioMapPath, filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File file = new File(fileFullPath);
|
|
|
|
|
json = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
|
|
|
|
|
// ObjectMapper 생성 및 설정
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.registerModule(new JavaTimeModule());
|
|
|
|
|
InterfaceDeployPack interfaceDeployPack = objectMapper.readValue(json, InterfaceDeployPack.class);
|
|
|
|
|
|
|
|
|
|
EAIMessageDeploy eaiMessageDeploy = interfaceDeployPack.getEaiMessageDeploy();
|
|
|
|
|
loutName = eaiMessageDeploy.getEaisvcname();
|
|
|
|
|
|
|
|
|
|
interfaceDeployService.saveDeploy(eaiMessageDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand("com.ext.eai.agent.stdmessage.ReloadSTDMessageCommand", "ALL"));
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand("com.eactive.eai.agent.eaimessage.ReloadEAIMessageCommand", eaiMessageDeploy.getEaisvcname()));
|
|
|
|
|
|
|
|
|
|
for(LayoutDeploy layoutDeploy: interfaceDeployPack.getLayoutDeployList()){
|
|
|
|
|
layoutDeployService.saveDeploy(layoutDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadLayoutCommand", layoutDeploy.getLoutname()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(TransformDeploy transformDeploy : interfaceDeployPack.getTransformDeployList()){
|
|
|
|
|
transformDeployService.saveDeploy(transformDeploy);
|
|
|
|
|
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadTransformCommand", transformDeploy.getCnvsnname()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiSpecInfoUI specInfoUI = interfaceDeployPack.getSpecInfo();
|
|
|
|
|
if (specInfoUI != null && StringUtils.isNotBlank(specInfoUI.getApiId())) {
|
|
|
|
|
ApiSpecInfo specInfo = apiSpecUIMapper.mapToEntity(specInfoUI);
|
|
|
|
|
if (apiSpecInfoService.findById(specInfo.getApiId()).isPresent()) {
|
|
|
|
|
apiSpecInfoService.updateById(specInfo.getApiId(), specInfo);
|
|
|
|
|
} else {
|
|
|
|
|
apiSpecInfoService.create(specInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TSEAITR10 배포 이력 저장 (SERVICENAME=eCams, COMMAND=uploadfull, LOUTNAME=eaisvcname, RECVDATA=json)
|
|
|
|
|
loaderService.insertDeploySyncLog(dt, "uploadfull", loutName, json);
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<String,String>();
|
|
|
|
|
result.put("status", "success");
|
|
|
|
|
result.put("message", fileFullPath+" deploy done.");
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("interface uploadfull error - filePath=" + filePath, e);
|
|
|
|
|
loaderService.insertDeployFailLog(dt, "uploadfull", loutName, json, e.toString());
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<String,String>();
|
|
|
|
|
result.put("status", "fail");
|
|
|
|
|
result.put("message", e.toString());
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String,String> result = new HashMap<String,String>();
|
|
|
|
|
String status = "success";
|
|
|
|
|
result.put("status", status);
|
|
|
|
|
result.put("message", fileFullPath+" deploy done.");
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(resultView, "result", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|