diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-01 12:48:00 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-01 12:48:14 -0500 |
commit | 09940a4aacf2fb32eddc85dd49f5a17dedff9de0 (patch) | |
tree | ca2a09e6cf184da0131b2fa3cc53decf94c69f13 /bpmn/so-bpmn-tasks/src/main/java | |
parent | 244d353aeda3662d57c6629eb95ee4791b7c07f1 (diff) |
vnf spin up gr api vnf s base module fails
map object representations of json back to json strings
marshal all objects to json strings before sending
all input params converted to Map<String, Object>
Updated userParams map from HashMap<String, String> to Map<String,
Object> as HashMap<String, String> userParams was causing VNF spin up
to fail. Input json in Userparams was not accepted as a valid json
format. Updated other files that were affected by this change.
Change-Id: I0c00fc00c4c11b54ace4df7be8d5bfc80d41d130
Issue-ID: SO-1582
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
8 files changed, 152 insertions, 97 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index 701817ab58..2559087619 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -110,8 +110,8 @@ public class VnfAdapterObjectMapper { return deleteVolumeGroupRequest; } - public Map<String, String> createVolumeGroupParams(RequestContext requestContext,GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { - Map<String, String> volumeGroupParams = new HashMap<>(); + public Map<String, Object> createVolumeGroupParams(RequestContext requestContext,GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { + Map<String, Object> volumeGroupParams = new HashMap<>(); final String USER_PARAM_NAME_KEY = "name"; final String USER_PARAM_VALUE_KEY = "value"; // sdncVfModuleQueryResponse will not be available in aLaCarte case @@ -147,7 +147,7 @@ public class VnfAdapterObjectMapper { return msoRequest; } - private void buildParamsMapFromSdncParams(Map<String,String> volumeGroupParams, GenericResourceApiParam sdncParameters) { + private void buildParamsMapFromSdncParams(Map<String,Object> volumeGroupParams, GenericResourceApiParam sdncParameters) { if (sdncParameters != null) { List<GenericResourceApiParamParam> sdncParametersList = sdncParameters.getParam(); if (sdncParametersList != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 352d4ec7d1..98174d59b6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -161,7 +161,7 @@ public class VnfAdapterVfModuleObjectMapper { return msoRequest; } - private Map<String,String> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, + private Map<String,Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException { @@ -169,7 +169,7 @@ public class VnfAdapterVfModuleObjectMapper { GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class); GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology(); GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology(); - Map<String,String> paramsMap = new HashMap<>(); + Map<String,Object> paramsMap = new HashMap<>(); if( vfModuleTopology.getSdncGeneratedCloudResources()) { buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true); @@ -184,17 +184,15 @@ public class VnfAdapterVfModuleObjectMapper { buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule); // Parameters received from the request should overwrite any parameters received from SDNC + paramsMap.putAll(requestContext.getUserParams()); - if (requestContext.getUserParams() != null) { - paramsMap.putAll(requestContext.getUserParams()); - } if (vfModule.getCloudParams() != null) { paramsMap.putAll(vfModule.getCloudParams()); } return paramsMap; } - private void buildMandatoryParamsMap(Map<String,String> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) { + private void buildMandatoryParamsMap(Map<String,Object> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) { paramsMap.put("vnf_id", genericVnf.getVnfId()); paramsMap.put("vnf_name", genericVnf.getVnfName()); paramsMap.put("vf_module_id", vfModule.getVfModuleId()); @@ -209,7 +207,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildParamsMapFromVnfSdncResponse(Map<String,String> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException { + private void buildParamsMapFromVnfSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException { // Get VNF parameters from SDNC response GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData(); buildParamsMapFromSdncParams(paramsMap, vnfParametersData); @@ -225,7 +223,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildAvailabilityZones (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) { + private void buildAvailabilityZones (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) { GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones = vnfResourceAssignments.getAvailabilityZones(); if (availabilityZones != null) { List<String> availabilityZonesList = availabilityZones.getAvailabilityZone(); @@ -237,7 +235,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVnfNetworks (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) { + private void buildVnfNetworks (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) { GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks(); if (vnfNetworks != null) { List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork(); @@ -264,7 +262,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVnfNetworkSubnets(Map<String,String> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) { + private void buildVnfNetworkSubnets(Map<String,Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) { String vnfNetworkString = convertToString(vnfNetwork); Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id"); if(ipv4Ips.isPresent()) @@ -275,7 +273,7 @@ public class VnfAdapterVfModuleObjectMapper { addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get()); } - private void buildParamsMapFromVfModuleSdncResponse(Map<String,String> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException { + private void buildParamsMapFromVfModuleSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException { // Get VF Module parameters from SDNC response GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters(); buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData); @@ -322,7 +320,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - protected void buildVlanInformation(Map<String, String> paramsMap, + protected void buildVlanInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { String networkString = convertToString(network); @@ -352,7 +350,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleVmNames(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm, String key) { + private void buildVfModuleVmNames(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm, String key) { String values = ""; GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); if (vmNames != null) { @@ -373,7 +371,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleFloatingIps(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleFloatingIps(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps(); if (floatingIps != null) { List<String> floatingIpV4List = floatingIps.getFloatingIpV4(); @@ -397,7 +395,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleInterfaceRoutePrefixes(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleInterfaceRoutePrefixes(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes = network.getInterfaceRoutePrefixes(); if (interfaceRoutePrefixes != null) { List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix(); @@ -421,7 +419,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleSriovParameters(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) { + private void buildVfModuleSriovParameters(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) { // SRIOV Parameters GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters(); if (sriovParameters != null) { @@ -447,7 +445,7 @@ public class VnfAdapterVfModuleObjectMapper { } } - private void buildVfModuleNetworkInformation(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { + private void buildVfModuleNetworkInformation(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems = network.getNetworkInformationItems(); StringBuilder sbIpv4Ips = new StringBuilder(); @@ -500,7 +498,7 @@ public class VnfAdapterVfModuleObjectMapper { * Build Count of SubInterfaces, VLAN Tag, network_name, network_id, * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template */ - private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm) { + private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm) { GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); if (vmNames != null) { @@ -520,7 +518,7 @@ public class VnfAdapterVfModuleObjectMapper { /* * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template. */ - private void parseVnfcNamesData(Map<String,String> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) { + private void parseVnfcNamesData(Map<String,Object> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) { if (vnfcNames != null) { GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks(); @@ -544,7 +542,7 @@ public class VnfAdapterVfModuleObjectMapper { * Build Count of SubInterfaces, VLAN Tag, network_name, network_id, * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template */ - private void parseVnfcNetworkData(Map<String,String> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) { + private void parseVnfcNetworkData(Map<String,Object> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) { String vmTypeKey = vnfcNetworkdata.getVnfcType(); GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts(); @@ -588,7 +586,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_subint_ctrl_port_0_subintcount * */ - private void buildVfModuleSubInterfacesCount(Map<String,String> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) { + private void buildVfModuleSubInterfacesCount(Map<String,Object> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) { List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList = vnicSubInterfaces.getSubInterfaceNetworkData(); @@ -614,7 +612,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_vlan_ids * */ - protected void buildVfModuleVlanTag(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleVlanTag(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> vlanTagIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id"); @@ -627,7 +625,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_net_names * */ - protected void buildVfModuleNetworkName(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleNetworkName(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> neworkNames = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name"); @@ -641,7 +639,7 @@ public class VnfAdapterVfModuleObjectMapper { * Example: fw_0_subint_ctrl_port_0_net_ids * */ - protected void buildVfModuleNetworkId(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleNetworkId(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> neworkIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id"); @@ -654,7 +652,7 @@ public class VnfAdapterVfModuleObjectMapper { * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4 * key = vm-type, networkRoleKey = NetWork-Role */ - protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]"); @@ -672,7 +670,7 @@ public class VnfAdapterVfModuleObjectMapper { * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6 * key = vm-type, networkRoleKey = NetWork-Role */ - protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]"); @@ -688,7 +686,7 @@ public class VnfAdapterVfModuleObjectMapper { * Building Criteria : * {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4 */ - protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]"); @@ -704,7 +702,7 @@ public class VnfAdapterVfModuleObjectMapper { * Building Criteria : * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6 */ - protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) { + protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) { List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]"); @@ -714,19 +712,19 @@ public class VnfAdapterVfModuleObjectMapper { addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6); } - protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, String value) { + protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) { addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value)); } - protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, List<String> value) { + protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) { if (!value.isEmpty()) { paramsMap.put(keyPrefix + key, Joiner.on(",").join(value)); } } - private void buildParamsMapFromSdncParams(Map<String,String> paramsMap, GenericResourceApiParam parametersData) { + private void buildParamsMapFromSdncParams(Map<String,Object> paramsMap, GenericResourceApiParam parametersData) { if (parametersData != null) { List<GenericResourceApiParamParam> paramsList = parametersData.getParam(); if (paramsList != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java index 2cd0947fa8..e46c456f88 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -22,16 +22,27 @@ package org.onap.so.client.sdnc.mapper; import java.net.URI; -import org.onap.sdnc.northbound.client.model.*; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component(value = "sdncGCTopologyOperationRequestMapper") public class GCTopologyOperationRequestMapper { - private static final GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, @@ -82,5 +93,4 @@ public class GCTopologyOperationRequestMapper { } - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index 7632831111..fedbde251e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -20,18 +20,42 @@ package org.onap.so.client.sdnc.mapper; -import org.onap.sdnc.northbound.client.model.*; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import org.onap.so.client.exception.MapperException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @Component public class GeneralTopologyObjectMapper { + private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); + private ObjectMapper mapper = new ObjectMapper(); /* * Build GenericResourceApiRequestinformationRequestInformation @@ -194,4 +218,22 @@ public class GeneralTopologyObjectMapper { } return gcRequestInput; } + + + public String mapUserParamValue(Object value) { + if (value == null) { + return null; + } else { + if (value instanceof Map || value instanceof Set || value instanceof List) { + try { + return mapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + logger.error("could not map value to string", e); + throw new IllegalArgumentException(e); + } + } else { + return value.toString(); + } + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index 2b4834af42..188a228e5d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -23,15 +23,6 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.stereotype.Component; - import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; @@ -41,6 +32,15 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnum import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /** * Mapper creating SDNC request @@ -49,7 +49,8 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformatio @Component public class NetworkTopologyOperationRequestMapper { - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, ServiceInstance serviceInstance, @@ -68,11 +69,11 @@ public class NetworkTopologyOperationRequestMapper { req.setNetworkInformation(networkInformation); if (requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); networkInputParameters.addParamItem(paramItem); networkRequestInput.setNetworkInputParameters(networkInputParameters); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java index 5b23707cb9..505466b22c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -23,13 +23,6 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.stereotype.Component; - import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; @@ -38,11 +31,19 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheader import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; @Component public class ServiceTopologyOperationMapper{ - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + public GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiServiceOperationInformation reqMapper (SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { @@ -62,13 +63,13 @@ public class ServiceTopologyOperationMapper{ servOpInput.setServiceRequestInput(servReqInfo); if(requestContext.getUserParams()!=null){ - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput(); serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); serviceInputParameters.addParamItem(paramItem ); serviceRequestInput.serviceInputParameters(serviceInputParameters); servOpInput.setServiceRequestInput(serviceRequestInput ); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 8e0072b16c..f70ac8399f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -25,13 +25,25 @@ package org.onap.so.client.sdnc.mapper; import java.util.Map; import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; @@ -39,27 +51,17 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; - import com.fasterxml.jackson.databind.ObjectMapper; @Component public class VfModuleTopologyOperationRequestMapper { private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance, @@ -126,10 +128,10 @@ public class VfModuleTopologyOperationRequestMapper { GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); vfModuleInputParameters.addParamItem(paramItem); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index e860d3cc48..7de393bb2f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -26,6 +26,16 @@ import java.util.Map; import java.util.UUID; import org.apache.commons.lang.StringUtils; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,23 +46,14 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; - @Component public class VnfTopologyOperationRequestMapper { - static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper(); + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, @@ -84,10 +85,10 @@ public class VnfTopologyOperationRequestMapper { GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); if (requestContext.getUserParams() != null) { - for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { + for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); vnfInputParameters.addParamItem(paramItem); vnfRequestInput.setVnfInputParameters(vnfInputParameters); } |