d0f61cac5a46c5a44f35b21c07d6129e19502f10
[aai/esr-server.git] / esr-mgr / src / main / java / org / onap / aai / esr / util / ThirdpartySdncManagerUtil.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.aai.esr.util;
17
18 import java.util.ArrayList;
19
20 import org.onap.aai.esr.common.SystemType;
21 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
22 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
23 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
24 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
25
26 public class ThirdpartySdncManagerUtil {
27   private static ExtsysUtil extsysUtil = new ExtsysUtil();
28   
29   public EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
30     EsrThirdpartySdncDetail esrThirdpartySdnc = new EsrThirdpartySdncDetail();
31     sdncRegisterInfo.setThirdpartySdncId(extsysUtil.generateId());
32     esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId());
33     esrThirdpartySdnc.setLocation(sdncRegisterInfo.getLocation());
34     esrThirdpartySdnc.setProductName(sdncRegisterInfo.getProductName());
35     esrThirdpartySdnc.setEsrSystemInfoList(getEsrSystemInfoList(sdncRegisterInfo));
36     return esrThirdpartySdnc;
37   }
38   
39   private EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
40     EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
41     ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
42     EsrSystemInfo authInfo = new EsrSystemInfo();
43     authInfo.setEsrSystemInfoId(extsysUtil.generateId());
44     authInfo.setVersion(sdncRegisterInfo.getVersion());
45     authInfo.setSystemName(sdncRegisterInfo.getName());
46     authInfo.setServiceUrl(sdncRegisterInfo.getUrl());
47     authInfo.setVendor(sdncRegisterInfo.getVendor());
48     authInfo.setType(sdncRegisterInfo.getType());
49     authInfo.setUserName(sdncRegisterInfo.getUserName());
50     authInfo.setPassword(sdncRegisterInfo.getPassword());
51     authInfo.setProtocol(sdncRegisterInfo.getProtocol());
52     authInfo.setSystemType(SystemType.thirdparty_SDNC.toString());
53     esrSystemInfo.add(authInfo);
54     esrSystemInfoList.setEsrSystemInfo(esrSystemInfo);
55     return esrSystemInfoList;
56   }
57
58   public ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdncDetail esrSdnc) {
59     ThirdpartySdncRegisterInfo registerSdncInfo = new ThirdpartySdncRegisterInfo();
60     EsrSystemInfo esrSystemInfo = esrSdnc.getEsrSystemInfoList().getEsrSystemInfo().get(0);
61     registerSdncInfo.setThirdpartySdncId(esrSdnc.getThirdpartySdncId());
62     registerSdncInfo.setLocation(esrSdnc.getLocation());
63     registerSdncInfo.setProductName(esrSdnc.getProductName());
64     registerSdncInfo.setName(esrSystemInfo.getSystemName());
65     registerSdncInfo.setPassword(esrSystemInfo.getPassword());
66     registerSdncInfo.setProtocol(esrSystemInfo.getProtocol());
67     registerSdncInfo.setType(esrSystemInfo.getType());
68     registerSdncInfo.setUrl(esrSystemInfo.getServiceUrl());
69     registerSdncInfo.setUserName(esrSystemInfo.getUserName());
70     registerSdncInfo.setVendor(esrSystemInfo.getVendor());
71     registerSdncInfo.setVersion(esrSystemInfo.getVersion());
72     return registerSdncInfo;
73   }
74 }