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.exception.ExtsysException;
24 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
26 public class ExternalSystemProxy {
28 private static IExternalSystem externalSystemproxy;
29 private static String transactionId = "9999";
30 private static String fromAppId = "esr-server";
31 private static String authorization = AaiCommon.getAuthenticationCredentials();
33 ClientConfig config = new ClientConfig();
35 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
38 public void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws ExtsysException {
39 ClientConfig config = new ClientConfig(new VnfmRegisterProvider());
40 IExternalSystem registerVnfmServiceproxy =
41 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
43 registerVnfmServiceproxy.registerVNFM(transactionId, fromAppId, authorization, vnfmId, esrVnfmDetail);
44 } catch (Exception e) {
45 throw new ExtsysException("PUT VNFM to A&AI failed.", e);
49 public String queryVnfmDetail(String vnfmId) throws ExtsysException {
51 return externalSystemproxy.queryVNFMDetail(transactionId, fromAppId, authorization, vnfmId);
52 } catch (Exception e) {
53 throw new ExtsysException("Query VNFM detail from A&AI failed.", e);
57 public String queryVnfmList() throws ExtsysException {
59 return externalSystemproxy.queryVNFMList(transactionId, fromAppId, authorization);
60 } catch (Exception e) {
61 throw new ExtsysException("Query VNFM list from A&AI failed.", e);
65 public void deleteVnfm(String vnfmId, String resourceVersion) throws ExtsysException {
67 externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion);
68 } catch (Exception e) {
69 throw new ExtsysException("Delete VNFM from A&AI failed.", e);
73 public void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws ExtsysException {
74 ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider());
75 IExternalSystem registerSdncServiceproxy =
76 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
78 registerSdncServiceproxy.registerThirdpartySdnc(transactionId, fromAppId, authorization, thirdpartySdncId,
80 } catch (Exception e) {
81 throw new ExtsysException("PUT thirdparty SDNC to A&AI failed.", e);
85 public String queryThirdpartySdncDetail(String thirdpartySdncId) throws ExtsysException {
87 return externalSystemproxy.queryThirdpartySdncDetail(transactionId, fromAppId, authorization,
89 } catch (Exception e) {
90 throw new ExtsysException("Query thirdparty SDNC detail from A&AI failed.", e);
94 public String querySdncList() throws ExtsysException {
96 return externalSystemproxy.queryThirdpartySdncList(transactionId, fromAppId, authorization);
97 } catch (Exception e) {
98 throw new ExtsysException("Query thirdparty SDNC list from A&AI failed.", e);
102 public void deleteThirdpartySdnc(String sdncId, String resourceVersion) throws ExtsysException {
104 externalSystemproxy.deleteThirdpartySdnc(transactionId, fromAppId, authorization, sdncId, resourceVersion);
105 } catch (Exception e) {
106 throw new ExtsysException("Delete thirdparty SDNC from A&AI failed.", e);
110 public void registerEms(String emsId, EsrEmsDetail emsDetail) throws ExtsysException {
111 ClientConfig config = new ClientConfig(new EmsRegisterProvider());
112 IExternalSystem registerEmsServiceproxy =
113 ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
115 registerEmsServiceproxy.registerEMS(transactionId, fromAppId, authorization, emsId, emsDetail);
116 } catch (Exception e) {
117 throw new ExtsysException("PUT EMS to A&AI failed.", e);
121 public String queryEmsDetail(String emsId) throws ExtsysException {
123 return externalSystemproxy.queryEMSDetail(transactionId, fromAppId, authorization, emsId);
124 } catch (Exception e) {
125 throw new ExtsysException("Query EMS detail from A&AI failed.", e);
129 public String queryEmsList() throws ExtsysException {
131 return externalSystemproxy.queryEMSList(transactionId, fromAppId, authorization);
132 } catch (Exception e) {
133 throw new ExtsysException("Query EMS list from A&AI failed.", e);
137 public void deleteEms(String emsId, String resourceVersion) throws ExtsysException {
139 externalSystemproxy.deleteEMS(transactionId, fromAppId, authorization, emsId, resourceVersion);
140 } catch (Exception e) {
141 throw new ExtsysException("Delete EMS from A&AI failed.", e);