package org.onap.aai.esr.util;
import java.util.ArrayList;
+import java.util.List;
import org.onap.aai.esr.common.SystemType;
import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.rest.FtpAddr;
public class EmsManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
- public static EsrEmsDetail emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
+ public EsrEmsDetail emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
EsrEmsDetail esrEms = new EsrEmsDetail();
- esrEms.setEmsId(ExtsysUtil.generateId());
- ArrayList<EsrSystemInfo> authInfos = new ArrayList<EsrSystemInfo>();
- authInfos = getAuthInfosFromRegisterData(emsRegisterInfo);
- esrEms.setEsrSystemInfoList(ExtsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
+ esrEms.setEmsId(extsysUtil.generateId());
+ List<EsrSystemInfo> authInfos = getAuthInfosFromRegisterData(emsRegisterInfo);
+ esrEms.setEsrSystemInfoList(extsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
return esrEms;
}
- private static ArrayList<EsrSystemInfo> getAuthInfosFromRegisterData(EmsRegisterInfo emsRegisterInfo) {
- ArrayList<EsrSystemInfo> authInfos = new ArrayList<EsrSystemInfo>();
- EsrSystemInfo resouceAuthInfo = new EsrSystemInfo();
- EsrSystemInfo performanceAuthInfo = new EsrSystemInfo();
- EsrSystemInfo alarmAuthInfo = new EsrSystemInfo();
- resouceAuthInfo = getAuthInfoFromFtpAddr(emsRegisterInfo, SystemType.EMS_RESOUCE.toString());
- performanceAuthInfo = getAuthInfoFromFtpAddr(emsRegisterInfo, SystemType.EMS_PERFORMANCE.toString());
- alarmAuthInfo = getAuthInfoFromAlarmAddr(emsRegisterInfo);
+ private List<EsrSystemInfo> getAuthInfosFromRegisterData(EmsRegisterInfo emsRegisterInfo) {
+ List<EsrSystemInfo> authInfos = new ArrayList<>();
+ EsrSystemInfo resouceAuthInfo = getAuthInfoFromFtpAddr(emsRegisterInfo, SystemType.EMS_RESOUCE.toString());
+ EsrSystemInfo performanceAuthInfo = getAuthInfoFromFtpAddr(emsRegisterInfo, SystemType.EMS_PERFORMANCE.toString());
+ EsrSystemInfo alarmAuthInfo = getAuthInfoFromAlarmAddr(emsRegisterInfo);
authInfos.add(resouceAuthInfo);
authInfos.add(performanceAuthInfo);
authInfos.add(alarmAuthInfo);
return authInfos;
}
- private static EsrSystemInfo getAuthInfoFromFtpAddr(EmsRegisterInfo emsRegisterInfo, String systemType) {
+ private EsrSystemInfo getAuthInfoFromFtpAddr(EmsRegisterInfo emsRegisterInfo, String systemType) {
EsrSystemInfo authInfo = new EsrSystemInfo();
FtpAddr ftpAddr = new FtpAddr();
if(systemType.equals(SystemType.EMS_RESOUCE.toString())) {
authInfo.setPassword(ftpAddr.getPassword());
authInfo.setRemotePath(ftpAddr.getRemotepath());
authInfo.setPassive(ftpAddr.getPassive());
- authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setSystemType(systemType);
authInfo.setSystemName(emsRegisterInfo.getName());
authInfo.setVendor(emsRegisterInfo.getVendor());
return authInfo;
}
- private static EsrSystemInfo getAuthInfoFromAlarmAddr(EmsRegisterInfo emsRegisterInfo) {
+ private EsrSystemInfo getAuthInfoFromAlarmAddr(EmsRegisterInfo emsRegisterInfo) {
EsrSystemInfo authInfo = new EsrSystemInfo();
- AlarmAddr alarmAddr = new AlarmAddr();
- alarmAddr = emsRegisterInfo.getAlarmAddr();
+ AlarmAddr alarmAddr = emsRegisterInfo.getAlarmAddr();
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setIpAddress(alarmAddr.getIp());
authInfo.setPort(alarmAddr.getPort());
authInfo.setUserName(alarmAddr.getUser());
return authInfo;
}
- public static EmsRegisterInfo EsrEms2EmsRegisterInfo(EsrEmsDetail esrEms) {
+ public EmsRegisterInfo EsrEms2EmsRegisterInfo(EsrEmsDetail esrEms) {
EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
- ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
EsrSystemInfo authInfo = new EsrSystemInfo();
- esrSystemInfo = esrEms.getEsrSystemInfoList().getEsrSystemInfo();
+ List<EsrSystemInfo> esrSystemInfo = esrEms.getEsrSystemInfoList().getEsrSystemInfo();
emsRegisterInfo.setEmsId(esrEms.getEmsId());
for(int i=0; i<esrSystemInfo.size(); i++) {
} else if(authInfo.getSystemType().equals(SystemType.EMS_PERFORMANCE.toString())) {
FtpAddr performanceAddr = new FtpAddr();
performanceAddr = getFtpAddrFromAuthInfo(authInfo);
- emsRegisterInfo.setResourceAddr(performanceAddr);
+ emsRegisterInfo.setPerformanceAddr(performanceAddr);
} else if(authInfo.getSystemType().equals(SystemType.EMS_ALARM.toString())) {
AlarmAddr alarmAddr = new AlarmAddr();
alarmAddr = getAlarmAddrFromAuthInfo(authInfo);
return emsRegisterInfo;
}
- private static FtpAddr getFtpAddrFromAuthInfo(EsrSystemInfo authInfo) {
+ private FtpAddr getFtpAddrFromAuthInfo(EsrSystemInfo authInfo) {
FtpAddr ftpAddr = new FtpAddr();
ftpAddr.setFtptype(authInfo.getType());
ftpAddr.setIp(authInfo.getIpAddress());
return ftpAddr;
}
- private static AlarmAddr getAlarmAddrFromAuthInfo(EsrSystemInfo authInfo) {
+ private AlarmAddr getAlarmAddrFromAuthInfo(EsrSystemInfo authInfo) {
AlarmAddr alarmAddr = new AlarmAddr();
alarmAddr.setIp(authInfo.getIpAddress());
alarmAddr.setPassword(authInfo.getPassword());