- JSONObject vpnBindingInfo = getVpnBindingInfo(networkId, pnfName, ifName, status);
- String vpnBindingId = vpnBindingInfo.getJSONObject("relationship-data").getString("relationship-value");
- JSONObject connectivityInfo = getConnectivityInfo(vpnBindingId);
- String connectivityId = connectivityInfo.getJSONObject("relationship-data").getString("relationship-value");
- JSONObject serviceInstanceInfo = getServiceInstanceByConn(connectivityId);
- String serviceInstancePath = serviceInstanceInfo.getString("related-link");
- serviceInstancePath = serviceInstancePath.substring(0, serviceInstancePath.lastIndexOf('/'));
+ JsonObject vpnBindingInfo = getVpnBindingInfo(networkId, pnfName, ifName, status);
+ if (vpnBindingInfo == null) {
+ log.warn(String.format("VPN binding information is missing from AAI. " +
+ "Method: [getServiceInstance], params: [networkId - %s, pnfName - %s, " +
+ "ifName - %s, status - %s].", networkId, pnfName, ifName, status));
+ return EMPTY_JSON;
+ }
+ String vpnBindingId = extractValueFromJsonArray(vpnBindingInfo.get("relationship-data").getAsJsonArray(),
+ "vpn-binding.vpn-id");
+ JsonObject connectivityInfo = getConnectivityInfo(vpnBindingId);
+ if (connectivityInfo == null) {
+ log.warn(String.format("Connectivity information is missing from AAI. " +
+ "Method: [getServiceInstance], params: [networkId - %s, pnfName - %s, " +
+ "ifName - %s, status - %s].", networkId, pnfName, ifName, status));
+ return EMPTY_JSON;
+ }
+ String connectivityId = extractValueFromJsonArray(connectivityInfo.get("relationship-data").getAsJsonArray(),
+ "connectivity.connectivity-id");
+ JsonObject serviceInstanceInfo = getServiceInstanceByConn(connectivityId);
+ if (serviceInstanceInfo == null) {
+ log.warn(String.format("Service instance information is missing from AAI. " +
+ "Method: [getServiceInstance], params: [networkId - %s, pnfName - %s, " +
+ "ifName - %s, status - %s].", networkId, pnfName, ifName, status));
+ return EMPTY_JSON;
+ }
+ String serviceInstancePath = serviceInstanceInfo.get("related-link").getAsString();