2 * Copyright 2018 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.Pnf;
21 import org.onap.aai.esr.exception.ExtsysException;
22 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
24 public class NetworkProxy {
26 private static INetwork network;
27 private static String transactionId = "9999";
28 private static String fromAppId = "esr-server";
29 private static String authorization = AaiCommon.getAuthenticationCredentials();
31 ClientConfig config = new ClientConfig();
33 ConsumerFactory.createConsumer(MsbConfig.getNetworkAddr(), config, INetwork.class);
36 public void registerPnf(String pnfName, Pnf pnf) throws ExtsysException {
37 ClientConfig config = new ClientConfig(new PnfRegisterProvider());
38 INetwork registerPnfServiceproxy =
39 ConsumerFactory.createConsumer(MsbConfig.getNetworkAddr(), config, INetwork.class);
41 registerPnfServiceproxy.registerPnfService(transactionId, fromAppId, authorization, pnfName, pnf);
42 } catch (Exception e) {
43 throw new ExtsysException("PUT PNF to A&AI failed.", e);
47 public String queryPNF(String pnfId) throws ExtsysException {
49 return network.queryPNF(transactionId, fromAppId, authorization, pnfId);
50 } catch (Exception e) {
51 throw new ExtsysException("Query PNF from A&AI failed.", e);
55 public String queryPnfList() throws ExtsysException {
57 return network.queryPNFList(transactionId, fromAppId, authorization);
58 } catch (Exception e) {
59 throw new ExtsysException("Query PNF List from A&AI failed.", e);
63 public void deletePnf(String pnfId, String resourceVersion) throws ExtsysException {
65 network.deletePNF(transactionId, fromAppId, authorization, pnfId, resourceVersion);
66 } catch (Exception e) {
67 throw new ExtsysException("Delete PNF from A&AI failed.", e);