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.externalservice.aai;
18 import org.glassfish.jersey.client.ClientConfig;
19 import org.onap.aai.esr.common.MsbConfig;
20 import org.onap.aai.esr.entity.aai.EsrEmsDetail;
21 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
22 import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
23 import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
24 import org.onap.aai.esr.exception.ExtsysException;
25 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
27 public class ExternalSystemProxy {
29 private static IExternalSystem externalSystem, externalSystemV16;
30 private static String transactionId = "9999";
31 private static String fromAppId = "esr-server";
32 private static String authorization = AaiCommon.getAuthenticationCredentials();
34 ClientConfig config = new ClientConfig();
36 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
38 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
41 public void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws ExtsysException {
42 ClientConfig config = new ClientConfig(new VnfmRegisterProvider());
43 IExternalSystem registerVnfmServiceproxy =
44 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
46 registerVnfmServiceproxy.registerVNFM(transactionId, fromAppId, authorization, vnfmId, esrVnfmDetail);
47 } catch (Exception e) {
48 throw new ExtsysException("PUT VNFM to A&AI failed.", e);
52 public String queryVnfmDetail(String vnfmId) throws ExtsysException {
54 return externalSystem.queryVNFMDetail(transactionId, fromAppId, authorization, vnfmId);
55 } catch (Exception e) {
56 throw new ExtsysException("Query VNFM detail from A&AI failed.", e);
60 public String queryVnfmList() throws ExtsysException {
62 return externalSystem.queryVNFMList(transactionId, fromAppId, authorization);
63 } catch (Exception e) {
64 throw new ExtsysException("Query VNFM list from A&AI failed.", e);
68 public void deleteVnfm(String vnfmId, String resourceVersion) throws ExtsysException {
70 externalSystem.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion);
71 } catch (Exception e) {
72 throw new ExtsysException("Delete VNFM from A&AI failed.", e);
76 public void registerNfvo(String nfvoId, EsrNfvoDetail esrNfvoDetail) throws ExtsysException {
77 ClientConfig config = new ClientConfig(new NfvoRegisterProvider());
78 IExternalSystem registerNfvoServiceproxy =
79 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
81 registerNfvoServiceproxy.registerNFVO(transactionId, fromAppId, authorization, nfvoId, esrNfvoDetail);
82 } catch (Exception e) {
83 throw new ExtsysException("PUT NFVO to A&AI failed.", e);
87 public String queryNfvoDetail(String nfvoId) throws ExtsysException {
89 return externalSystemV16.queryNFVODetail(transactionId, fromAppId, authorization, nfvoId);
90 } catch (Exception e) {
91 throw new ExtsysException("Query NFVO detail from A&AI failed.", e);
95 public String queryNfvoList() throws ExtsysException {
97 return externalSystemV16.queryNFVOList(transactionId, fromAppId, authorization);
98 } catch (Exception e) {
99 throw new ExtsysException("Query NFVO list from A&AI failed.", e);
103 public void deleteNfvo(String nfvoId, String resourceVersion) throws ExtsysException {
105 externalSystemV16.deleteNFVO(transactionId, fromAppId, authorization, nfvoId, resourceVersion);
106 } catch (Exception e) {
107 throw new ExtsysException("Delete NFVO from A&AI failed.", e);
115 public void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws ExtsysException {
116 ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider());
117 IExternalSystem registerSdncServiceproxy =
118 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
120 registerSdncServiceproxy.registerThirdpartySdnc(transactionId, fromAppId, authorization, thirdpartySdncId,
122 } catch (Exception e) {
123 throw new ExtsysException("PUT thirdparty SDNC to A&AI failed.", e);
127 public String queryThirdpartySdncDetail(String thirdpartySdncId) throws ExtsysException {
129 return externalSystem.queryThirdpartySdncDetail(transactionId, fromAppId, authorization,
131 } catch (Exception e) {
132 throw new ExtsysException("Query thirdparty SDNC detail from A&AI failed.", e);
136 public String querySdncList() throws ExtsysException {
138 return externalSystem.queryThirdpartySdncList(transactionId, fromAppId, authorization);
139 } catch (Exception e) {
140 throw new ExtsysException("Query thirdparty SDNC list from A&AI failed.", e);
144 public void deleteThirdpartySdnc(String sdncId, String resourceVersion) throws ExtsysException {
146 externalSystem.deleteThirdpartySdnc(transactionId, fromAppId, authorization, sdncId, resourceVersion);
147 } catch (Exception e) {
148 throw new ExtsysException("Delete thirdparty SDNC from A&AI failed.", e);
152 public void registerEms(String emsId, EsrEmsDetail emsDetail) throws ExtsysException {
153 ClientConfig config = new ClientConfig(new EmsRegisterProvider());
154 IExternalSystem registerEmsServiceproxy =
155 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
157 registerEmsServiceproxy.registerEMS(transactionId, fromAppId, authorization, emsId, emsDetail);
158 } catch (Exception e) {
159 throw new ExtsysException("PUT EMS to A&AI failed.", e);
163 public String queryEmsDetail(String emsId) throws ExtsysException {
165 return externalSystem.queryEMSDetail(transactionId, fromAppId, authorization, emsId);
166 } catch (Exception e) {
167 throw new ExtsysException("Query EMS detail from A&AI failed.", e);
171 public String queryEmsList() throws ExtsysException {
173 return externalSystem.queryEMSList(transactionId, fromAppId, authorization);
174 } catch (Exception e) {
175 throw new ExtsysException("Query EMS list from A&AI failed.", e);
179 public void deleteEms(String emsId, String resourceVersion) throws ExtsysException {
181 externalSystem.deleteEMS(transactionId, fromAppId, authorization, emsId, resourceVersion);
182 } catch (Exception e) {
183 throw new ExtsysException("Delete EMS from A&AI failed.", e);