X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Futil%2FThirdpartySdncManagerUtil.java;fp=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Futil%2FThirdpartySdncManagerUtil.java;h=a9075e31b35fa44d9fcaa5e17b1487ec364c9299;hb=0fc3e68fe98646d2e814b0e7597ffae7f731b586;hp=0000000000000000000000000000000000000000;hpb=bc65f229b176269aaf9fe0cee5cf5f9e42a5d455;p=aai%2Fesr-server.git diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java new file mode 100644 index 0000000..a9075e3 --- /dev/null +++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java @@ -0,0 +1,72 @@ +/** + * Copyright 2017 ZTE Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.aai.esr.util; + +import java.util.ArrayList; + +import org.onap.aai.esr.common.SystemType; +import org.onap.aai.esr.entity.aai.EsrSystemInfo; +import org.onap.aai.esr.entity.aai.EsrSystemInfoList; +import org.onap.aai.esr.entity.aai.EsrThirdpartySdnc; +import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo; + +public class ThirdpartySdncManagerUtil { + + public EsrThirdpartySdnc sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) { + EsrThirdpartySdnc esrThirdpartySdnc = new EsrThirdpartySdnc(); + sdncRegisterInfo.setThirdpartySdncId(ExtsysUtil.generateId()); + esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId()); + esrThirdpartySdnc.setLocation(sdncRegisterInfo.getLocation()); + esrThirdpartySdnc.setProductName(sdncRegisterInfo.getProductName()); + esrThirdpartySdnc.setEsrSystemInfoList(getEsrSystemInfoList(sdncRegisterInfo)); + return esrThirdpartySdnc; + } + + private EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) { + EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); + ArrayList esrSystemInfo = new ArrayList(); + EsrSystemInfo authInfo = new EsrSystemInfo(); + authInfo.setResouceVersion(sdncRegisterInfo.getVersion()); + authInfo.setSystemName(sdncRegisterInfo.getName()); + authInfo.setServiceUrl(sdncRegisterInfo.getUrl()); + authInfo.setVendor(sdncRegisterInfo.getVendor()); + authInfo.setType(sdncRegisterInfo.getType()); + authInfo.setUserName(sdncRegisterInfo.getUserName()); + authInfo.setPassword(sdncRegisterInfo.getPassword()); + authInfo.setProtocol(sdncRegisterInfo.getProtocol()); + authInfo.setSystemType(SystemType.thirdparty_SDNC.toString()); + esrSystemInfo.add(authInfo); + esrSystemInfoList.setEsrSystemInfo(esrSystemInfo); + return esrSystemInfoList; + } + + public ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdnc esrSdnc) { + ThirdpartySdncRegisterInfo registerSdncInfo = new ThirdpartySdncRegisterInfo(); + EsrSystemInfo esrSystemInfo = esrSdnc.getEsrSystemInfoList().getEsrSystemInfo().get(0); + registerSdncInfo.setThirdpartySdncId(esrSdnc.getThirdpartySdncId()); + registerSdncInfo.setLocation(esrSdnc.getLocation()); + registerSdncInfo.setProductName(esrSdnc.getProductName()); + registerSdncInfo.setName(esrSystemInfo.getSystemName()); + registerSdncInfo.setPassword(esrSystemInfo.getPassword()); + registerSdncInfo.setProtocol(esrSystemInfo.getProtocol()); + registerSdncInfo.setType(esrSystemInfo.getType()); + registerSdncInfo.setUrl(esrSystemInfo.getServiceUrl()); + registerSdncInfo.setUserName(esrSystemInfo.getUserName()); + registerSdncInfo.setVendor(esrSystemInfo.getVendor()); + registerSdncInfo.setVersion(esrSystemInfo.getVersion()); + return registerSdncInfo; + } +}