From bc0754b45540c56eeb9fc2aa2649a030136d0742 Mon Sep 17 00:00:00 2001 From: deepikasatheesh Date: Tue, 10 Nov 2020 04:27:55 -0800 Subject: Read subnetCapabilities configuration file from SO pod Issue-ID: SO-3372 Signed-off-by: deepikasatheesh Change-Id: I1055ec23b572d4f8b19ba326615248153c895227 --- .../apihandlerinfra/Onap3gppServiceInstances.java | 23 +++++++++++++++++--- .../src/main/resources/application.yaml | 4 ++++ .../src/main/resources/subnetCapability.json | 25 ---------------------- 3 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json (limited to 'mso-api-handlers/mso-api-handler-infra/src/main') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java index b1486c9686..a25a140334 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java @@ -20,6 +20,9 @@ package org.onap.so.apihandlerinfra; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; import java.sql.Timestamp; import java.util.HashMap; import java.util.UUID; @@ -72,6 +75,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; @@ -124,6 +128,9 @@ public class Onap3gppServiceInstances { @Autowired private ResponseHandler responseHandler; + @Value("${subnetCapability.config.file}") + private String subnetCapabilityConfigFile; + /** * POST Requests for 3GPP Service create Instance on a version provided * @@ -583,13 +590,23 @@ public class Onap3gppServiceInstances { } } - // To be implemented for fetching Subnet capabilities private Response getSubnetCapabilities(List subnetTypes, String version) throws ApiException { ObjectMapper oMapper = new ObjectMapper(); - InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json"); + String inputFileString = ""; Map subnetCapability = new HashMap<>(); + BufferedReader br = null; try { - subnetCapability = oMapper.readValue(inputStream, Map.class); + logger.debug("Reading SubnetCapability file"); + br = new BufferedReader(new FileReader(new File(subnetCapabilityConfigFile))); + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + inputFileString = sb.toString(); + subnetCapability = oMapper.readValue(inputFileString, Map.class); } catch (Exception e) { logger.debug("Exception while reading subnet capability value from json", e); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index b46690f2a7..6064f73e23 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -83,3 +83,7 @@ org: adapters: network: encryptionKey: aa3871669d893c7fb8abbcda31b88b4f + +subnetCapability: + config: + file: /app/subnetCapability.json diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json deleted file mode 100644 index 0d5acef64a..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "AN": { - "latency": "5", - "maxNumberofUEs": "100", - "maxThroughput": "150", - "terminalDensity": "50" - }, - "CN": { - "latency": "10", - "maxThroughput": "50", - "maxNumberofConns": "100" - }, - "TN_FH": { - "latency": "10", - "maxThroughput": "100" - }, - "TN_MH": { - "latency": "5", - "maxThroughput": "50" - }, - "TN_BH": { - "latency": "10", - "maxThroughput": "100" - } -} -- cgit 1.2.3-korg