2 * Copyright 2019 Verizon. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.aai.esr.util;
18 import org.onap.aai.esr.common.SystemType;
19 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
20 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
21 import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
22 import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
24 public class NfvoManagerUtil {
25 private static ExtsysUtil extsysUtil = new ExtsysUtil();
27 public EsrNfvoDetail nfvoRegisterInfo2EsrNfvo(NfvoRegisterInfo nfvoRegisterInfo) {
28 EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
29 esrNfvo.setNfvoId(extsysUtil.generateId());
30 esrNfvo.setApiroot(nfvoRegisterInfo.getApiroot());
31 EsrSystemInfo authInfo = getAuthInfoFromNfvoRegisterInfo(nfvoRegisterInfo);
32 EsrSystemInfoList esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
33 esrNfvo.setEsrSystemInfoList(esrSystemInfo);
38 * @param nfvoRegisterInfo nfvo register informantion from portal
41 private EsrSystemInfo getAuthInfoFromNfvoRegisterInfo(NfvoRegisterInfo nfvoRegisterInfo) {
42 EsrSystemInfo authInfo = new EsrSystemInfo();
43 authInfo.setEsrSystemInfoId(extsysUtil.generateId());
44 authInfo.setSystemName(nfvoRegisterInfo.getName());
45 authInfo.setVendor(nfvoRegisterInfo.getVendor());
46 authInfo.setVersion(nfvoRegisterInfo.getVersion());
47 authInfo.setServiceUrl(nfvoRegisterInfo.getUrl());
48 authInfo.setUserName(nfvoRegisterInfo.getUserName());
49 authInfo.setPassword(nfvoRegisterInfo.getPassword());
50 authInfo.setSystemType(SystemType.NFVO.toString());
54 public NfvoRegisterInfo esrNfvo2NfvoRegisterInfo(EsrNfvoDetail esrNfvo) {
55 NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
56 nfvoRegisterInfo.setNfvoId(esrNfvo.getNfvoId());
57 nfvoRegisterInfo.setApiroot(esrNfvo.getApiroot());
58 EsrSystemInfo authInfo = esrNfvo.getEsrSystemInfoList().getEsrSystemInfo().get(0);
59 nfvoRegisterInfo.setName(authInfo.getSystemName());
60 nfvoRegisterInfo.setPassword(authInfo.getPassword());
61 nfvoRegisterInfo.setUrl(authInfo.getServiceUrl());
62 nfvoRegisterInfo.setUserName(authInfo.getUserName());
63 nfvoRegisterInfo.setVendor(authInfo.getVendor());
64 nfvoRegisterInfo.setVersion(authInfo.getVersion());
65 return nfvoRegisterInfo;