2 * Copyright 2017 ZTE Corporation.
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.EsrVnfmDetail;
22 import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
24 public class VnfmManagerUtil {
25 private static ExtsysUtil extsysUtil = new ExtsysUtil();
27 public EsrVnfmDetail vnfmRegisterInfo2EsrVnfm(VnfmRegisterInfo vnfmRegisterInfo) {
28 EsrVnfmDetail esrVnfm = new EsrVnfmDetail();
29 EsrSystemInfoList esrSystemInfo = new EsrSystemInfoList();
30 EsrSystemInfo authInfo = new EsrSystemInfo();
31 esrVnfm.setCertificateUrl(vnfmRegisterInfo.getCertificateUrl());
32 esrVnfm.setVimId(vnfmRegisterInfo.getVimId());
33 esrVnfm.setVnfmId(extsysUtil.generateId());
34 authInfo = getAuthInfoFromVnfmRegisterInfo(vnfmRegisterInfo);
35 esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
36 esrVnfm.setEsrSystemInfoList(esrSystemInfo);
41 * @param vnfmRegisterInfo vnfm register informantion from portal
44 private EsrSystemInfo getAuthInfoFromVnfmRegisterInfo(VnfmRegisterInfo vnfmRegisterInfo) {
45 EsrSystemInfo authInfo = new EsrSystemInfo();
46 authInfo.setEsrSystemInfoId(extsysUtil.generateId());
47 authInfo.setSystemName(vnfmRegisterInfo.getName());
48 authInfo.setType(vnfmRegisterInfo.getType());
49 authInfo.setVendor(vnfmRegisterInfo.getVendor());
50 authInfo.setVersion(vnfmRegisterInfo.getVersion());
51 authInfo.setServiceUrl(vnfmRegisterInfo.getUrl());
52 authInfo.setUserName(vnfmRegisterInfo.getUserName());
53 authInfo.setPassword(vnfmRegisterInfo.getPassword());
54 authInfo.setSystemType(SystemType.VNFM.toString());
58 public VnfmRegisterInfo esrVnfm2VnfmRegisterInfo(EsrVnfmDetail esrVnfm) {
59 VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
60 EsrSystemInfo authInfo = new EsrSystemInfo();
61 vnfmRegisterInfo.setVnfmId(esrVnfm.getVnfmId());
62 vnfmRegisterInfo.setCertificateUrl(esrVnfm.getCertificateUrl());
63 vnfmRegisterInfo.setVimId(esrVnfm.getVimId());
64 authInfo = esrVnfm.getEsrSystemInfoList().getEsrSystemInfo().get(0);
65 vnfmRegisterInfo.setName(authInfo.getSystemName());
66 vnfmRegisterInfo.setPassword(authInfo.getPassword());
67 vnfmRegisterInfo.setType(authInfo.getType());
68 vnfmRegisterInfo.setUrl(authInfo.getServiceUrl());
69 vnfmRegisterInfo.setUserName(authInfo.getUserName());
70 vnfmRegisterInfo.setVendor(authInfo.getVendor());
71 vnfmRegisterInfo.setVersion(authInfo.getVersion());
72 return vnfmRegisterInfo;