summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-17 05:48:03 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-17 05:48:03 +0000
commit633af62e329892feb8c7a3354a9bdb37eaef3f3d (patch)
treed4a5e082ec3b2204e9f84b80605ab8ef1539a6e9 /mso-api-handlers/mso-api-handler-infra/src/main/java
parent4b7611ffa47492aa6080fc58c0d04c23f32804b3 (diff)
parent30c6bacb158f5446915a772745f33a28d8da5ea2 (diff)
Merge "Implement Subnet Capability query functionality"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java16
2 files changed, 39 insertions, 12 deletions
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 e7b96b16a9..3f05c79dad 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
@@ -23,6 +23,11 @@ package org.onap.so.apihandlerinfra;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.UUID;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.function.Function;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -54,6 +59,7 @@ import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Allocate3gppServ
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.DeAllocate3gppService;
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService;
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability;
+import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.SubnetTypes;
import org.onap.so.constants.Status;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -70,6 +76,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.core.type.TypeReference;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
@@ -238,8 +245,8 @@ public class Onap3gppServiceInstances {
public Response getSliceSubnetCapabilities(QuerySubnetCapability request, @PathParam("version") String version)
throws ApiException {
logger.debug("Request received {}", request);
- String subnetType = null;
- return getSubnetCapabilities(subnetType, version);
+ List<SubnetTypes> subnetTypes = request.getSubnetTypes();
+ return getSubnetCapabilities(subnetTypes, version);
}
/**
@@ -577,8 +584,28 @@ public class Onap3gppServiceInstances {
}
// To be implemented for fetching Subnet capabilities
- private Response getSubnetCapabilities(String subnetType, String version) throws ApiException {
- return null;
+ private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException {
+ ObjectMapper oMapper = new ObjectMapper();
+ InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json");
+ Map<String, Object> subnetCapability = new HashMap<>();
+ try {
+ subnetCapability = oMapper.readValue(inputStream, Map.class);
+ } catch (Exception e) {
+ logger.debug("Exception while reading subnet capability value from json", e);
+ }
+ Map<String, Object> responseMap = new HashMap<>();
+ for (SubnetTypes value : subnetTypes) {
+ if (subnetCapability.containsKey(value.toString())) {
+ responseMap.put(value.toString(), subnetCapability.get(value.toString()));
+ }
+ }
+ String response = null;
+ try {
+ response = oMapper.writeValueAsString(responseMap);
+ } catch (JsonProcessingException e) {
+ logger.debug("Exception while converting subnet capability object to String {}", e);
+ }
+ return builder.buildResponse(HttpStatus.SC_OK, null, response, version);
}
/**
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
index 2e479e1ecb..c66b053609 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
@@ -22,26 +22,26 @@ package org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Model class for slice subnet capability query
*/
public class QuerySubnetCapability {
- private SubnetTypes subnetType;
+ @JsonProperty("subnetTypes")
+ private List<SubnetTypes> subnetTypes;
- public SubnetTypes getSubnetType() {
- return subnetType;
+ public List<SubnetTypes> getSubnetTypes() {
+ return subnetTypes;
}
- public void setSubnetType(SubnetTypes subnetType) {
- this.subnetType = subnetType;
+ public void setSubnetTypes(List<SubnetTypes> subnetTypes) {
+ this.subnetTypes = subnetTypes;
}
@Override
public String toString() {
- return "QuerySubnetCapability [subnetType=" + subnetType + "]";
+ return "QuerySubnetCapability [subnetType=" + subnetTypes + "]";
}
-
}
-