- 어댑터 프라퍼티 "API_PATH" 의 값 변경시 HS04 Table의 "APIFULLPATH" 도 업데이트 되도록 기능 추가
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+156
-4
@@ -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,153 @@ 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 함.
|
||||
boolean isUpdated = false;
|
||||
|
||||
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);
|
||||
|
||||
isUpdated = true;
|
||||
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (isUpdated) {
|
||||
|
||||
try {
|
||||
|
||||
Command command = new ReloadSTDMessageCommand();
|
||||
command.setArgs("ALL");
|
||||
|
||||
agentUtilService.broadcast(command);
|
||||
|
||||
log.debug("API 경로 변경 감지 -> 전체 표준 전문 리로드 명령 전송 완료 (ALL)");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.debug("브로드캐스트 전송 실패", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void delete(AdapterGroupUI adapterGroupUI) {
|
||||
adapterGroupService.deleteById(adapterGroupUI.getAdptrbzwkgroupname());
|
||||
|
||||
Reference in New Issue
Block a user