Map<String, String> responseMap = fetchSubscriberAndSubscriptionServiceType();
String serviceReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType + "/service-instances";
+ log.info("serviceReqUrl {}", serviceReqUrl);
String serviceRole = "AN-NF";
try {
String serviceInstance =
JSONArray serviceInstanceList = serviceInstanceJson.getJSONArray("service-instance");
for (int i = 0; i < serviceInstanceList.length(); i++) {
JSONObject serviceObj = serviceInstanceList.getJSONObject(i);
- if (serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) {
+ if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) {
responseMap.put("sliceProfileId", serviceObj.getString("service-instance-id"));
}
}
String serviceRoleReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType
+ "/service-instances/?service-role=nssi&depth=2";
-
+ log.info("serviceRoleReqUrl {}", serviceRoleReqUrl);
String serviceInstanceForServiceRole =
restclient.sendGetRequest(serviceRoleReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
JSONObject serviceInstanceForServiceRoleJson = new JSONObject(serviceInstanceForServiceRole);
serviceInstanceForServiceRoleJson.getJSONArray("service-instance");
for (int i = 0; i < serviceInstanceListForServiceRole.length(); i++) {
JSONObject serviceObj = serviceInstanceListForServiceRole.getJSONObject(i);
- if (serviceObj.getString("workload-context").trim().equalsIgnoreCase(serviceRole)) {
+ if (serviceObj.has("workload-context") && serviceObj.getString("workload-context").trim().equalsIgnoreCase(serviceRole)) {
responseMap.put("ranNFNSSIId", serviceObj.getString("service-instance-id"));
}
}
String serviceInstaneId = null;
String serviceReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType + "/service-instances";
+ log.info("serviceReqUrl {}", serviceReqUrl);
Map<String, Integer> responseMap = new HashMap<String, Integer>();
try {
String serviceInstance =
JSONArray serviceInstanceList = serviceInstanceJson.getJSONArray("service-instance");
for (int i = 0; i < serviceInstanceList.length(); i++) {
JSONObject serviceObj = serviceInstanceList.getJSONObject(i);
- if (serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) {
+ if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) {
serviceInstaneId = serviceObj.getString("service-instance-id");
}
}
String sliceProfileReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType
+ "/service-instances/service-instance/" + serviceInstaneId + "/slice-profiles";
-
+ log.info("sliceProfileReqUrl {}", sliceProfileReqUrl);
String sliceProfile = restclient
.sendGetRequest(sliceProfileReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
JSONObject sliceProfileJson = new JSONObject(sliceProfile);
log.info("Get GlobalSubscriberId");
String subscriberReqUrl = aaiBaseUrl + "/business/customers";
+ log.info("subscriberReqUrl {}", subscriberReqUrl);
try {
String subscriberReq =
restclient.sendGetRequest(subscriberReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
log.info("Get subscriptionServiceType");
String subscriptionServiceReqUrl =
aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId + "/service-subscriptions";
-
+ log.info("subscriptionServiceReqUrl: {}", subscriptionServiceReqUrl);
String subscriptionService = restclient
.sendGetRequest(subscriptionServiceReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
JSONObject subscriptionServiceJson = new JSONObject(subscriptionService);
String serviceReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType
+ "/service-instances/service-instance/" + sliceInstanceId;
-
+ log.info("serviceReqUrl {}", serviceReqUrl);
try {
String serviceInstanceString =
restclient.sendGetRequest(serviceReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
ServiceInstance serviceInstance = objectMapper.readValue(serviceInstanceString, ServiceInstance.class);
if (serviceInstance.getServiceRole().equalsIgnoreCase("nsi")) {
serviceInstance.getRelationshipList().getRelationship().forEach(relationship -> {
- if (relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) {
+ if (Objects.nonNull(relationship.getRelatedTo()) && relationship.getRelatedTo().equalsIgnoreCase("allotted-resource")) {
relationship.getRelationshipData().forEach(data -> {
if (data.get("relationship-key").equalsIgnoreCase("service-instance.service-instance-id")) {
allotedResource.add(data.get("relationship-value"));
String serviceReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType
+ "/service-instances/service-instance/" + serviceInstanceId;
+ log.info("serviceReqUrl {}", serviceReqUrl);
String serviceInstanceString =
restclient.sendGetRequest(serviceReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
ServiceInstance serviceInstance = objectMapper.readValue(serviceInstanceString, ServiceInstance.class);
String serviceReqUrl = aaiBaseUrl + "/business/customers/customer/" + globalSubscriberId
+ "/service-subscriptions/service-subscription/" + subscriptionServiceType + "/service-instances/"
+ "service-instance/" + serviceInstanceId;
-
+ log.info("serviceReqUrl {}", serviceReqUrl);
try {
String serviceInstanceString =
restclient.sendGetRequest(serviceReqUrl, new ParameterizedTypeReference<String>() {}).getBody();
Map<String, Map<String, Object>> responseMap = new HashMap<String, Map<String, Object>>();
String reqUrl = cpsBaseUrl + "/get-nearrtric-config";
log.info("fetching current configuration of RIC from Cps: {s-NSSAI: " + snssai + "}");
+ log.info("reqUrl {}", reqUrl);
String requestBody = "{\"inputParameters\": {\"sNssai\":" + JSONObject.quote(snssai) + "}}";
+ log.info("requestBody {}", requestBody);
try {
String response = restclient
.sendPostRequest(reqUrl, requestBody, new ParameterizedTypeReference<String>() {}).getBody();
List<String> responseList = new ArrayList<>();
String reqUrl = cpsBaseUrl + "/get-gnbdufunction-by-snssai";
log.info("fetching network functions of snssai from Cps: {s-NSSAI: " + snssai + "}");
+ log.info("reqUrl {}", reqUrl);
String requestBody = "{\"inputParameters\": {\"sNssai\":" + JSONObject.quote(snssai) + "}}";
+ log.info("requestBody {}", requestBody);
try {
String response = restclient
.sendPostRequest(reqUrl, requestBody, new ParameterizedTypeReference<String>() {}).getBody();
Map<String, List<String>> responseMap = new HashMap<>();
String reqUrl = cpsBaseUrl + "/get-nrcelldu-by-snssai";
log.info("fetching RIC of s-NSSAI from Cps: {s-NSSAI: " + snssai + "}");
+ log.info("reqUrl {}", reqUrl);
String requestBody = "{\"inputParameters\": {\"sNssai\":" + JSONObject.quote(snssai) + "}}";
+ log.info("requestBody {}", requestBody);
try {
String response = restclient
.sendPostRequest(reqUrl, requestBody, new ParameterizedTypeReference<String>() {}).getBody();