aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2020-05-26 11:46:44 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-05-26 11:46:44 -0400
commite4f0a5c9ecbbdb1cdebcab2706a44d869ce03c9e (patch)
tree4069657cb8f85f3026ea3cffadaa2d5f8470ca49 /bpmn/so-bpmn-tasks/src/main
parent6c1869316041e314007acb2f777ea89631c890b8 (diff)
removed net.minidev.json from codebase
removed net.minidev.json from codebase Issue-ID: SO-2957 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I03f89a1002b3cf052a304503cd206a979bfee6f8
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java55
1 files changed, 26 insertions, 29 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
index ce0f2c7417..6831a656a8 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
@@ -24,7 +24,6 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.EXT_V
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -32,14 +31,14 @@ import java.util.stream.Collectors;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.jsonpath.JsonPathUtil;
import org.onap.so.client.sdnc.SDNCClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.jayway.jsonpath.JsonPath;
-import net.minidev.json.JSONArray;
/**
* This class retrieve pre-load data from SDNC using <br/>
@@ -56,9 +55,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
private final SDNCClient sdncClient;
+ private final ObjectMapper mapper;
+
@Autowired
public SdncInputParametersProvider(final SDNCClient sdncClient) {
this.sdncClient = sdncClient;
+ this.mapper = new ObjectMapper();
}
@Override
@@ -70,21 +72,23 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
try {
LOGGER.debug("Will query sdnc for input parameters using url: {}", url);
final String jsonResponse = sdncClient.get(url);
-
- final JSONArray vnfParametersArray = JsonPath.read(jsonResponse, VNF_PARAMETERS_PATH);
- if (vnfParametersArray != null) {
- for (int index = 0; index < vnfParametersArray.size(); index++) {
- final Object vnfParametersObject = vnfParametersArray.get(index);
- if (vnfParametersObject instanceof JSONArray) {
- final JSONArray vnfParameters = (JSONArray) vnfParametersObject;
- final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParameters);
- final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
- final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
- final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
- LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
- return inputParameter;
- }
+ final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null);
+
+ try {
+
+ if (json != null) {
+ final List<VnfParameter> vnfParametersArray =
+ mapper.readValue(json, new TypeReference<List<VnfParameter>>() {});
+ final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray);
+ final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
+ final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
+ final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
+ LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
+ return inputParameter;
}
+
+ } catch (final IOException exception) {
+ LOGGER.error("Unable to parse vnf parameters : {}", json, exception);
}
} catch (final Exception exception) {
LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception);
@@ -112,19 +116,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
}
- private Map<String, String> getVnfParameterMap(final JSONArray array) {
- try {
- if (array != null) {
- final ObjectMapper mapper = new ObjectMapper();
- final VnfParameter[] readValue = mapper.readValue(array.toJSONString(), VnfParameter[].class);
- LOGGER.debug("Vnf parameters: {}", Arrays.asList(readValue));
- return Arrays.asList(readValue).stream()
- .filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
- .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
- }
- } catch (final IOException exception) {
- LOGGER.error("Unable to parse vnf parameters : {}", array, exception);
+ private Map<String, String> getVnfParameterMap(final List<VnfParameter> array) {
+ if (array != null) {
+ return array.stream().filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
+ .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
}
+
return Collections.emptyMap();
}