Merge branch 'jenkins_with_weblogic' of http://192.168.240.178:18080/eapim/eapim-admin.git into jenkins_with_weblogic
This commit is contained in:
@@ -245,4 +245,8 @@ public class AdapterGroupService extends AbstractDataService<AdapterGroup, Strin
|
||||
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public AdapterGroup saveAndFlush(AdapterGroup adapterGroup) {
|
||||
return repository.saveAndFlush(adapterGroup);
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -1,5 +1,6 @@
|
||||
package com.eactive.eai.rms.data.entity.onl.stdmessage;
|
||||
|
||||
import com.eactive.eai.data.entity.onl.adapter.AdapterGroup;
|
||||
import com.eactive.eai.data.entity.onl.message.QEAIMessageEntity;
|
||||
import com.eactive.eai.data.entity.onl.stdmessage.QStandardMessageInfo;
|
||||
import com.eactive.eai.data.entity.onl.stdmessage.StandardMessageInfo;
|
||||
@@ -113,5 +114,18 @@ public class StandardMessageInfoService
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<StandardMessageInfo> findByBzwksvckeynameStartingWith(String adapterName) {
|
||||
QStandardMessageInfo qStandardMessageInfo = QStandardMessageInfo.standardMessageInfo;
|
||||
|
||||
return getJPAQueryFactory()
|
||||
.selectFrom(qStandardMessageInfo)
|
||||
.where(qStandardMessageInfo.bzwksvckeyname.startsWith(adapterName))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
public StandardMessageInfo saveAndFlush(StandardMessageInfo stdMsgInfo) {
|
||||
return repository.saveAndFlush(stdMsgInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class AdapterController extends OnlBaseAnnotationController {
|
||||
synchronized (obj) {
|
||||
service.update(adapterGroupUI);
|
||||
|
||||
Map<String, String> resultMap = service.reloadSync(adapterGroupUI);
|
||||
Map<String, String> resultMap = service.reloadSyncStdMsgAndAdapter(adapterGroupUI.getAdptrbzwkgroupname());
|
||||
return ResponseEntity.ok(resultMap);
|
||||
}
|
||||
|
||||
|
||||
+176
-8
@@ -23,10 +23,15 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.eactive.eai.agent.command.Command;
|
||||
import com.eactive.eai.agent.command.CommonCommand;
|
||||
import com.eactive.eai.common.stdmessage.STDMessageManager;
|
||||
import com.eactive.eai.data.entity.onl.adapter.Adapter;
|
||||
import com.eactive.eai.data.entity.onl.adapter.AdapterGroup;
|
||||
import com.eactive.eai.data.entity.onl.adapter.AdapterProp;
|
||||
import com.eactive.eai.data.entity.onl.adapter.AdapterPropGroup;
|
||||
import com.eactive.eai.data.entity.onl.stdmessage.StandardMessageInfo;
|
||||
import com.eactive.eai.data.jpa.BaseRepository;
|
||||
import com.eactive.eai.rms.common.acl.monitoringCode.MonitoringCodeManService;
|
||||
import com.eactive.eai.rms.common.base.OnlBaseService;
|
||||
import com.eactive.eai.rms.common.comDomain.CommonDomainManService;
|
||||
@@ -42,6 +47,7 @@ import com.eactive.eai.rms.data.entity.onl.adapter.AdapterTypePropertyService;
|
||||
import com.eactive.eai.rms.data.entity.onl.adapter.CommonDomain;
|
||||
import com.eactive.eai.rms.data.entity.onl.code.CodeService;
|
||||
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
|
||||
import com.eactive.eai.rms.data.entity.onl.stdmessage.StandardMessageInfoService;
|
||||
import com.eactive.eai.rms.onl.common.exception.BizException;
|
||||
import com.eactive.eai.rms.onl.common.service.AdapterChangeThreadPool;
|
||||
import com.eactive.eai.rms.onl.manage.adapter.adapter.mapper.AdapterGroupUIMapper;
|
||||
@@ -52,6 +58,7 @@ import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterGroupUIMixIn;
|
||||
import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterGroupUISearch;
|
||||
import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterPropUI;
|
||||
import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterUI;
|
||||
import com.ext.eai.agent.stdmessage.ReloadSTDMessageCommand;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
@@ -106,7 +113,10 @@ public class AdapterManService extends OnlBaseService {
|
||||
|
||||
@Autowired
|
||||
private EAIServerService eaiServerService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private StandardMessageInfoService standardmessageinfoService;
|
||||
|
||||
public Page<AdapterGroupUI> selectList(Pageable pageable, AdapterGroupUISearch adapterGroupUISearch) {
|
||||
Page<AdapterGroup> page = adapterGroupService.findPage(pageable, adapterGroupUISearch);
|
||||
return page.map(adapterGroupUIMapper::toVoWithoutChildrenMapping);
|
||||
@@ -234,11 +244,133 @@ public class AdapterManService extends OnlBaseService {
|
||||
|
||||
public void update(AdapterGroupUI adapterGroupUI) {
|
||||
|
||||
AdapterGroup adapterGroup = adapterGroupService.getById(adapterGroupUI.getAdptrbzwkgroupname());
|
||||
adapterGroupUIMapper.updateEntity(adapterGroupUI, adapterGroup);
|
||||
AdapterGroup adapterGroup = adapterGroupService.getById(adapterGroupUI.getAdptrbzwkgroupname());
|
||||
|
||||
Map<String, String> oldApiPathMap = extractApiPaths(adapterGroup);
|
||||
|
||||
adapterGroupUIMapper.updateEntity(adapterGroupUI, adapterGroup);
|
||||
|
||||
// NonUniqueObjectException 대응
|
||||
adapterGroupService.saveAndFlush(adapterGroup);
|
||||
|
||||
adapterGroupService.save(adapterGroup);
|
||||
|
||||
// HS04 - API_FULL_PATH 동기화
|
||||
syncIfApiPathChanged(adapterGroup, oldApiPathMap);
|
||||
}
|
||||
|
||||
private Map<String, String> extractApiPaths(AdapterGroup adapterGroup) {
|
||||
|
||||
Map<String, String> pathMap = new HashMap<>();
|
||||
|
||||
if (adapterGroup == null || adapterGroup.getAdapters() == null) {
|
||||
return pathMap;
|
||||
}
|
||||
for (Adapter adapter : adapterGroup.getAdapters()) {
|
||||
|
||||
if (adapter.getAdapterPropGroup() == null
|
||||
|| adapter.getAdapterPropGroup().getAdapterProps() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (AdapterProp prop : adapter.getAdapterPropGroup().getAdapterProps()) {
|
||||
String propName = prop.getId().getPrptyname();
|
||||
|
||||
if ("API_PATH".equals(propName)) {
|
||||
String adapterName = adapter.getId().getAdptrbzwkgroupname();
|
||||
|
||||
String apiPathValue = prop.getPrpty2val();
|
||||
|
||||
pathMap.put(adapterName, apiPathValue);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pathMap;
|
||||
|
||||
}
|
||||
|
||||
private void syncIfApiPathChanged(AdapterGroup newGroup, Map<String, String> oldPathMap) {
|
||||
|
||||
if (newGroup.getAdapters() == null) return;
|
||||
|
||||
for (Adapter newAdapter : newGroup.getAdapters()) { // adapterData 분리
|
||||
String adapterName = newAdapter.getId().getAdptrbzwkgroupname(); // 업데이트할때 들어온 어댑터 이름
|
||||
String newPath = findApiPathValue(newAdapter);
|
||||
|
||||
String oldPath = oldPathMap.get(adapterName);
|
||||
|
||||
if (StringUtils.isNotBlank(oldPath)
|
||||
&& StringUtils.isNotBlank(newPath)
|
||||
&& !StringUtils.equals(oldPath, newPath)) {
|
||||
|
||||
updateStdMessageInfoApiFullPath(adapterName, oldPath, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String findApiPathValue(Adapter adapter) {
|
||||
if (adapter.getAdapterPropGroup() == null
|
||||
|| adapter.getAdapterPropGroup().getAdapterProps() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return adapter.getAdapterPropGroup().getAdapterProps().stream()
|
||||
.filter(prop -> prop.getId() != null && "API_PATH".equals(prop.getId().getPrptyname()))
|
||||
.findFirst()
|
||||
.map(AdapterProp::getPrpty2val)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private void updateStdMessageInfoApiFullPath(String adapterName, String oldPath, String newPath) {
|
||||
|
||||
List<StandardMessageInfo> stdMsgInfoList = standardmessageinfoService.findByBzwksvckeynameStartingWith(adapterName);
|
||||
|
||||
// 변경 사항이 있었는지 체크해서 HS04 Reload 함.
|
||||
for (StandardMessageInfo stdMsgInfo : stdMsgInfoList) {
|
||||
String fullPath = stdMsgInfo.getApifullpath();
|
||||
|
||||
// 기존 경로(oldPath)를 포함하고 있을 때만 교체
|
||||
if (StringUtils.isNotBlank(fullPath) && fullPath.contains(oldPath)) {
|
||||
|
||||
int pipeIndex = fullPath.indexOf("|");
|
||||
|
||||
if (pipeIndex != -1) {
|
||||
String methodPart = fullPath.substring(0, pipeIndex + 1);
|
||||
String uriPart = fullPath.substring(pipeIndex + 1);
|
||||
|
||||
if (uriPart.startsWith(oldPath)) {
|
||||
String newUriPart = newPath + uriPart.substring(oldPath.length());
|
||||
String updatedFullPath = methodPart + newUriPart;
|
||||
|
||||
stdMsgInfo.setApifullpath(updatedFullPath);
|
||||
|
||||
|
||||
try {
|
||||
// DB에 즉시 반영
|
||||
standardmessageinfoService.saveAndFlush(stdMsgInfo);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
log.error("StandardMessageInfo APIFULLPATH SAVE FAIL key = {}", stdMsgInfo.getBzwksvckeyname());
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// 파이프가 없는 경우 로그 생성
|
||||
log.warn("[StandardMessageInfo APIFULLPATH Sync Skip] Abnormal data format found. Adapter: {}, FullPath: {}", adapterName, fullPath);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void delete(AdapterGroupUI adapterGroupUI) {
|
||||
adapterGroupService.deleteById(adapterGroupUI.getAdptrbzwkgroupname());
|
||||
@@ -407,7 +539,43 @@ public class AdapterManService extends OnlBaseService {
|
||||
adapterGroup.setMoniuseyn(adapterGroupUI.getMoniuseyn());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> reloadSyncStdMsgAndAdapter(String adapterGroupName) throws Exception {
|
||||
|
||||
Map<String, String> result = new HashMap<>();
|
||||
|
||||
String status = "success";
|
||||
|
||||
try {
|
||||
log.debug(">>>>>>>> [Reload Start] 어댑터 그룹명 {}", adapterGroupName);
|
||||
|
||||
CommonCommand pcommand = new CommonCommand(
|
||||
"com.eactive.eai.agent.adapter.ReloadAdapterPropGroupCommand",
|
||||
adapterGroupName
|
||||
);
|
||||
agentUtilService.broadcast(pcommand);
|
||||
|
||||
CommonCommand acommand = new CommonCommand(
|
||||
"com.eactive.eai.agent.adapter.ReloadAdapterGroupCommand",
|
||||
adapterGroupName
|
||||
);
|
||||
agentUtilService.broadcast(acommand);
|
||||
|
||||
Command stdcommand = new ReloadSTDMessageCommand();
|
||||
stdcommand.setArgs("ALL");
|
||||
agentUtilService.broadcast(stdcommand);
|
||||
|
||||
log.info(">>>>>> [Reload End] 모든 리로드 명령 전송 완료");
|
||||
} catch (Exception e) {
|
||||
status = "error";
|
||||
log.error("리로드 실패", e);
|
||||
}
|
||||
|
||||
result.put("status", status);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> reloadSync(AdapterGroupUI adapterGroupUI) throws Exception {
|
||||
Map<String, Object> receive = null;
|
||||
Map<String, String> result = new HashMap<>();
|
||||
@@ -419,19 +587,19 @@ public class AdapterManService extends OnlBaseService {
|
||||
prptyGroupName);
|
||||
agentUtilService.broadcast(pcommand);
|
||||
}
|
||||
|
||||
|
||||
CommonCommand acommand = new CommonCommand("com.eactive.eai.agent.adapter.ReloadAdapterGroupCommand",
|
||||
adapterGroupUI.getAdptrbzwkgroupname());
|
||||
receive = agentUtilService.broadcast(acommand);
|
||||
|
||||
|
||||
if (receive.values().stream().anyMatch(value -> value == null || !"success".equals(value))) {
|
||||
status = "error";
|
||||
}
|
||||
|
||||
|
||||
result.put("status", status);
|
||||
result.put("message", receive.toString());
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> deleteSync(AdapterGroupUI map, List<AdapterUI> list) throws Exception {
|
||||
|
||||
+12
-4
@@ -2,6 +2,7 @@ package com.eactive.eai.rms.onl.manage.rule.layoutsync;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -212,11 +213,18 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
|
||||
try {
|
||||
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
|
||||
|
||||
// 응답 전문
|
||||
File res = new File( request.getSession().getServletContext().getRealPath("/WEB-INF/") + "/layout-messagesync-res.xml" );
|
||||
rDoc = builder.build(res);
|
||||
results = rDoc.getRootElement();
|
||||
InputStream resStream = request.getSession().getServletContext().getResourceAsStream("/WEB-INF/layout-messagesync-res.xml");
|
||||
if (resStream == null) {
|
||||
throw new Exception("layout-messagesync-res.xml 파일을 찾을 수 없습니다.");
|
||||
}
|
||||
try {
|
||||
rDoc = builder.build(resStream);
|
||||
results = rDoc.getRootElement();
|
||||
} finally {
|
||||
resStream.close();
|
||||
}
|
||||
|
||||
// 요청 전문
|
||||
sis = request.getInputStream();
|
||||
|
||||
Reference in New Issue
Block a user