import java.util.ArrayList;
import org.onap.aai.esr.common.SystemType;
-import org.onap.aai.esr.entity.aai.AuthInfo;
-import org.onap.aai.esr.entity.aai.EsrEms;
+import org.onap.aai.esr.entity.aai.EsrSystemInfo;
+import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.rest.AlarmAddr;
import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
import org.onap.aai.esr.entity.rest.FtpAddr;
public class EmsManagerUtil {
- public static EsrEms emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
- EsrEms esrEms = new EsrEms();
+ public EsrEmsDetail emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
+ EsrEmsDetail esrEms = new EsrEmsDetail();
esrEms.setEmsId(ExtsysUtil.generateId());
- ArrayList<AuthInfo> authInfos = new ArrayList<AuthInfo>();
+ ArrayList<EsrSystemInfo> authInfos = new ArrayList<EsrSystemInfo>();
authInfos = getAuthInfosFromRegisterData(emsRegisterInfo);
esrEms.setEsrSystemInfoList(ExtsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
return esrEms;
}
- private static ArrayList<AuthInfo> getAuthInfosFromRegisterData(EmsRegisterInfo emsRegisterInfo) {
- ArrayList<AuthInfo> authInfos = new ArrayList<AuthInfo>();
- AuthInfo resouceAuthInfo = new AuthInfo();
- AuthInfo performanceAuthInfo = new AuthInfo();
- AuthInfo alarmAuthInfo = new AuthInfo();
+ private 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);
return authInfos;
}
- private static AuthInfo getAuthInfoFromFtpAddr(EmsRegisterInfo emsRegisterInfo, String systemType) {
- AuthInfo authInfo = new AuthInfo();
+ private EsrSystemInfo getAuthInfoFromFtpAddr(EmsRegisterInfo emsRegisterInfo, String systemType) {
+ EsrSystemInfo authInfo = new EsrSystemInfo();
FtpAddr ftpAddr = new FtpAddr();
if(systemType.equals(SystemType.EMS_RESOUCE.toString())) {
ftpAddr = emsRegisterInfo.getResourceAddr();
return authInfo;
}
- private static AuthInfo getAuthInfoFromAlarmAddr(EmsRegisterInfo emsRegisterInfo) {
- AuthInfo authInfo = new AuthInfo();
+ private EsrSystemInfo getAuthInfoFromAlarmAddr(EmsRegisterInfo emsRegisterInfo) {
+ EsrSystemInfo authInfo = new EsrSystemInfo();
AlarmAddr alarmAddr = new 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(EsrEms esrEms) {
+ public EmsRegisterInfo EsrEms2EmsRegisterInfo(EsrEmsDetail esrEms) {
EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
- ArrayList<AuthInfo> authInfos = new ArrayList<AuthInfo>();
- AuthInfo authInfo = new AuthInfo();
- authInfos = esrEms.getEsrSystemInfoList().getEsrSystemInfo().getEsrSystemInfo();
+ ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
+ EsrSystemInfo authInfo = new EsrSystemInfo();
+ esrSystemInfo = esrEms.getEsrSystemInfoList().getEsrSystemInfo();
emsRegisterInfo.setEmsId(esrEms.getEmsId());
- for(int i=0; i<authInfos.size(); i++) {
- authInfo = authInfos.get(i);
+ for(int i=0; i<esrSystemInfo.size(); i++) {
+ authInfo = esrSystemInfo.get(i);
if(authInfo.getSystemType().equals(SystemType.EMS_RESOUCE.toString())){
FtpAddr resourceAddr = new FtpAddr();
resourceAddr = getFtpAddrFromAuthInfo(authInfo);
} 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(AuthInfo authInfo) {
+ private FtpAddr getFtpAddrFromAuthInfo(EsrSystemInfo authInfo) {
FtpAddr ftpAddr = new FtpAddr();
ftpAddr.setFtptype(authInfo.getType());
ftpAddr.setIp(authInfo.getIpAddress());
return ftpAddr;
}
- private static AlarmAddr getAlarmAddrFromAuthInfo(AuthInfo authInfo) {
+ private AlarmAddr getAlarmAddrFromAuthInfo(EsrSystemInfo authInfo) {
AlarmAddr alarmAddr = new AlarmAddr();
alarmAddr.setIp(authInfo.getIpAddress());
alarmAddr.setPassword(authInfo.getPassword());