Removed deprecated Matcher imports
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / adapter / vnf / mapper / VnfAdapterVfModuleObjectMapper.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.adapter.vnf.mapper;
22
23 import static java.util.Arrays.asList;
24
25 import java.io.IOException;
26 import java.io.UnsupportedEncodingException;
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.Collection;
30 import java.util.Collections;
31 import java.util.HashMap;
32 import java.util.HashSet;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Optional;
36
37 import javax.annotation.PostConstruct;
38
39 import org.apache.commons.lang3.StringUtils;
40 import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
41 import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
42 import org.onap.sdnc.northbound.client.model.GenericResourceApiSubInterfaceNetworkData;
43 import org.onap.sdnc.northbound.client.model.GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData;
44 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleTopology;
45 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleassignmentsVfModuleAssignments;
46 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms;
47 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduletopologyVfModuleTopology;
48 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData;
49 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmTopologyData;
50 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataFloatingIps;
51 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataInterfaceRoutePrefixes;
52 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkInformationItems;
53 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem;
54 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps;
55 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataSriovParameters;
56 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters;
57 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmNames;
58 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmNetworks;
59 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmnamesVnfcNames;
60 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfNetworkData;
61 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfTopology;
62 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcNetworkData;
63 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcNetworkData;
64 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts;
65 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort;
66 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfResourceAssignments;
67 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones;
68 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks;
69 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnftopologyVnfTopology;
70 import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
71 import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
72 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
73 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
74 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
75 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
76 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
77 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
78 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
79 import org.onap.so.entity.MsoRequest;
80 import org.onap.so.jsonpath.JsonPathUtil;
81 import org.springframework.beans.factory.annotation.Autowired;
82 import org.springframework.stereotype.Component;
83
84 import com.fasterxml.jackson.core.JsonParseException;
85 import com.fasterxml.jackson.core.JsonProcessingException;
86 import com.fasterxml.jackson.databind.DeserializationFeature;
87 import com.fasterxml.jackson.databind.JsonMappingException;
88 import com.fasterxml.jackson.databind.ObjectMapper;
89 import com.google.common.base.Joiner;
90
91
92 @Component
93 public class VnfAdapterVfModuleObjectMapper {
94         @Autowired
95         protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils;
96         private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name");
97         
98         private ObjectMapper mapper = new ObjectMapper();
99         private static final JsonPathUtil jsonPath = JsonPathUtil.getInstance();
100         private static final String SUB_INT = "subint";
101         private static final String SUBNET_ID = "_subnet_id";
102         private static final String V6_SUBNET_ID = "_v6_subnet_id";
103         private static final String PORT = "port";
104         private static final String SUB_INT_COUNT = "_subintcount";
105         private static final String VLAN_IDS = "_vlan_ids";
106         private static final String NET_NAMES = "_net_names";
107         private static final String NET_IDS = "_net_ids";
108         private static final String IP = "_ip";
109         private static final String V6_IP = "_v6_ip";
110         private static final String FLOATING_IP = "_floating_ip";
111         private static final String FLOATING_V6_IP = "_floating_v6_ip";
112         private static final String UNDERSCORE = "_";
113         
114         @PostConstruct
115         public void init () {
116                 mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
117         }
118         
119         public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, 
120                                 VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
121                 CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
122                 
123                 createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
124                 createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
125                 createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
126                 createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
127                 createVfModuleRequest.setVnfId(genericVnf.getVnfId());
128                 createVfModuleRequest.setVnfType(genericVnf.getVnfType());              
129                 createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
130                 createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
131                 createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
132                 if (volumeGroup != null) {
133                         createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
134                         createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
135                 }
136                 VfModule baseVfModule = getBaseVfModule(genericVnf);            
137                 if (baseVfModule != null) {
138                         createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
139                         createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
140                 }
141                 createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
142                 
143                 createVfModuleRequest.setSkipAAI(true);         
144                 createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
145                 createVfModuleRequest.setFailIfExists(true);
146                 
147                 MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);               
148                 createVfModuleRequest.setMsoRequest(msoRequest);
149                 
150                 String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
151                 createVfModuleRequest.setMessageId(messageId);
152                 createVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
153                 
154                 return createVfModuleRequest;
155         }
156         
157         private MsoRequest buildMsoRequest(RequestContext requestContext,ServiceInstance serviceInstance) {
158                 MsoRequest msoRequest = new MsoRequest();
159                 msoRequest.setRequestId(requestContext.getMsoRequestId());
160                 msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
161                 return msoRequest;              
162         }
163         
164         private Map<String,String> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, 
165                                 VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
166                 
167                 
168                 GenericResourceApiVnfTopology vnfTop= mapper.readValue(sdncVnfQueryResponse, GenericResourceApiVnfTopology.class);
169                 GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
170                 GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology();
171                 GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
172                 Map<String,String> paramsMap = new HashMap<>();
173
174                 if( vfModuleTopology.getSdncGeneratedCloudResources()) {
175                         buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true);
176                         buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, null, true);
177                 }
178                 else {
179                         Map<String,String> networkRoleMap = buildNetworkRoleMap(vfModuleTopology);
180                         buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, false);
181                         buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, networkRoleMap, false);
182                 }
183                 
184                 buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule);
185                 
186                 // Parameters received from the request should overwrite any parameters received from SDNC
187                 
188                 if (requestContext.getUserParams() != null) {
189                         paramsMap.putAll(requestContext.getUserParams());
190                 }
191                 if (vfModule.getCloudParams() != null) {
192                         paramsMap.putAll(vfModule.getCloudParams());
193                 }
194                 return paramsMap;
195         }
196         
197         private void  buildMandatoryParamsMap(Map<String,String> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) {                
198                 paramsMap.put("vnf_id", genericVnf.getVnfId());
199                 paramsMap.put("vnf_name", genericVnf.getVnfName());
200                 paramsMap.put("vf_module_id", vfModule.getVfModuleId());
201                 paramsMap.put("vf_module_name", vfModule.getVfModuleName());
202                 paramsMap.put("environment_context",serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
203                 paramsMap.putIfAbsent("environment_context", "");
204                 paramsMap.put("workload_context", serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
205                 paramsMap.putIfAbsent("workload_context", "");
206                 Integer vfModuleIndex = vfModule.getModuleIndex();
207                 if (vfModuleIndex != null) {
208                         paramsMap.put("vf_module_index", vfModuleIndex.toString());
209                 }               
210         }
211         
212         private void buildParamsMapFromVnfSdncResponse(Map<String,String> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException {                                
213                 // Get VNF parameters from SDNC response
214                 GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData();
215                 buildParamsMapFromSdncParams(paramsMap, vnfParametersData);
216                 
217                 if(!skipVnfResourceAssignments) {
218                         GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments();                
219                         if (vnfResourceAssignments != null) {
220                                 // Availability Zones
221                                 buildAvailabilityZones(paramsMap, vnfResourceAssignments);
222                                 // VNF Networks
223                                 buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);                    
224                         }
225                 }
226         }
227         
228         private void buildAvailabilityZones (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {             
229                 GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones = vnfResourceAssignments.getAvailabilityZones();
230                 if (availabilityZones != null) {
231                         List<String> availabilityZonesList = availabilityZones.getAvailabilityZone();
232                         if (availabilityZonesList != null) {
233                                 for(int i = 0; i < availabilityZonesList.size(); i++) {
234                                         paramsMap.put("availability_zone_" + i, availabilityZonesList.get(i));
235                                 }
236                         }
237                 }
238         }
239         
240         private void buildVnfNetworks (Map<String,String> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) {
241                 GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks();
242                 if (vnfNetworks != null) {
243                         List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork();
244                         if (vnfNetworksList != null) {
245                                 for (int i = 0; i < vnfNetworksList.size(); i++) {
246                                         GenericResourceApiVnfNetworkData vnfNetwork = vnfNetworksList.get(i);
247                                         String networkRole = vnfNetwork.getNetworkRole();
248                                         String vnfNetworkKey = networkRoleMap.get(networkRole);
249                                         if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) {
250                                                 vnfNetworkKey = networkRole;
251                                         }               
252                                         
253                                         String vnfNetworkNeutronIdValue = vnfNetwork.getNeutronId();
254                                         paramsMap.put(vnfNetworkKey + "_net_id", vnfNetworkNeutronIdValue);
255                                         String vnfNetworkNetNameValue = vnfNetwork.getNetworkName();
256                                         paramsMap.put(vnfNetworkKey + "_net_name", vnfNetworkNetNameValue);
257                                         String vnfNetworkNetFqdnValue = vnfNetwork.getContrailNetworkFqdn();
258                                         paramsMap.put(vnfNetworkKey + "_net_fqdn", vnfNetworkNetFqdnValue);
259                                 
260                                         buildVnfNetworkSubnets(paramsMap, vnfNetwork, vnfNetworkKey);
261                                         
262                                 }
263                         }
264                 }
265         }
266         
267         private void buildVnfNetworkSubnets(Map<String,String> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) {
268                 String vnfNetworkString = convertToString(vnfNetwork);
269                 Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id");
270                 if(ipv4Ips.isPresent())
271                         addPairToMap(paramsMap, vnfNetworkKey, SUBNET_ID, ipv4Ips.get());
272                 
273                 Optional<String> ipv6Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv6' && @.dhcp-enabled == 'Y')].subnet-id");
274                 if(ipv6Ips.isPresent())
275                         addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get());
276         }       
277
278         private void buildParamsMapFromVfModuleSdncResponse(Map<String,String> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException {          
279                 // Get VF Module parameters from SDNC response
280                 GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters();
281                 buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData);
282                 
283                 if(!skipVfModuleAssignments) {          
284                         GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
285                         if (vfModuleAssignments != null) {                      
286                                 // VNF-VMS
287                                 GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
288                                 if (vms != null) {
289                                 List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
290                                         if (vmsList != null) {
291                                                 for (GenericResourceApiVmTopologyData vm : vmsList){
292                                                         String key = vm.getVmType();
293                                                         buildVfModuleVmNames(paramsMap, vm, key);                                                                               
294                                                         GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
295                                                         if (vmNetworks != null) {
296                                                                 List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
297                                                                 if (vmNetworksList != null) {
298                                                                                 for(int n = 0; n < vmNetworksList.size(); n++){
299                                                                                 GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
300                                                                                 network.getNetworkRoleTag();
301                                                                                 String networkKey = network.getNetworkRole();   
302                                                                                 // Floating IPs
303                                                                                 buildVfModuleFloatingIps(paramsMap, network, key, networkKey);                                                                  
304                                                                                 // Interface Route Prefixes
305                                                                                 buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);                                                                       
306                                                                                 // SRIOV Parameters
307                                                                                 buildVfModuleSriovParameters(paramsMap, network, networkKey);                                                                   
308                                                                                 // IPV4 and IPV6 Addresses
309                                                                                 buildVfModuleNetworkInformation(paramsMap, network, key, networkKey);
310                                                                                 
311                                                                                 buildVlanInformation(paramsMap, network, key, networkKey);
312                                                                                 
313                                                                         }
314                                                                 }
315                                                         }
316                                                         
317                                                         buildParamsMapFromVfModuleForHeatTemplate(paramsMap, vm);
318                                                 }
319                                         }                               
320                                 }               
321                         }
322                 }
323         }
324         
325         protected void buildVlanInformation(Map<String, String> paramsMap,
326                         GenericResourceApiVmNetworkData network, String key, String networkKey) {
327                 
328                 String networkString = convertToString(network);
329                 String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter";
330                 String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans";
331                 String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans";
332                 String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans";
333                 
334                 if (network.getSegmentationId() != null) {
335                         paramsMap.put(vlanFilterKey, network.getSegmentationId());
336                 }
337                 
338                 List<String> privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id");
339                 List<String> publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id");
340                 List<String> concat = new ArrayList<>(privateVlans);
341                 concat.addAll(publicVlans);
342                 Collection<String> guestVlans = new HashSet<>(concat);
343                 
344                 if (!privateVlans.isEmpty()) {
345                         paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans));
346                 }
347                 if (!publicVlans.isEmpty()) {
348                         paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans));
349                 }
350                 if (!guestVlans.isEmpty()) {
351                         paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans));
352                 }
353         }
354
355         private void buildVfModuleVmNames(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm, String key) {
356                 String values = "";
357                 GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
358                 if (vmNames != null) {
359                         List<String> valueList = vmNames.getVmName();
360                         if (valueList != null) {
361                                 for(int i = 0; i < valueList.size(); i++){
362                                         String value = valueList.get(i);                                        
363                                         if (i != valueList.size() - 1) {
364                                                 values += value + ",";
365                                         }
366                                         else {
367                                                 values += value;
368                                         }
369                                         paramsMap.put(key + "_name_" + i, value);
370                                 }
371                                 paramsMap.put(key + "_names", values);
372                         }
373                 }
374         }
375         
376         private void buildVfModuleFloatingIps(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
377                 GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps();
378                 if (floatingIps != null) {
379                         List<String> floatingIpV4List = floatingIps.getFloatingIpV4();
380                         if (floatingIpV4List != null) {
381                                 // add only one ipv4 floating ip for now
382                                 String floatingIPKey = key + UNDERSCORE + networkKey + FLOATING_IP;
383                                 String floatingIPKeyValue = floatingIpV4List.get(0);
384                                 if (floatingIPKeyValue != null && !floatingIPKeyValue.isEmpty()) {
385                                         paramsMap.put(floatingIPKey, floatingIPKeyValue);
386                                 }
387                         }
388                         // add only one ipv6 floating ip for now
389                         List<String> floatingIpV6List = floatingIps.getFloatingIpV6();
390                         if (floatingIpV6List != null) {
391                                 String floatingIPV6Key = key + UNDERSCORE + networkKey + FLOATING_V6_IP;
392                                 String floatingIPV6KeyValue = floatingIpV6List.get(0);
393                                 if (floatingIPV6KeyValue != null && !floatingIPV6KeyValue.isEmpty()) {
394                                         paramsMap.put(floatingIPV6Key, floatingIPV6KeyValue);
395                                 }
396                         }
397                 }
398         }
399         
400         private void buildVfModuleInterfaceRoutePrefixes(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
401                 GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes = network.getInterfaceRoutePrefixes();
402                 if (interfaceRoutePrefixes != null) {
403                         List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix();
404                         StringBuilder sbInterfaceRoutePrefixes = new StringBuilder();
405                         sbInterfaceRoutePrefixes.append("[");
406                         if (interfaceRoutePrefixesList != null) {
407                                 for(int a = 0; a < interfaceRoutePrefixesList.size(); a++){
408                                         String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);                                           
409                                         if (a != interfaceRoutePrefixesList.size() - 1) {
410                                                 sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",");
411                                         }
412                                         else {
413                                                 sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}");                                              
414                                         }
415                                 }                                                       
416                                 sbInterfaceRoutePrefixes.append("]");
417                                 if (interfaceRoutePrefixesList.size() > 0) {
418                                         paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes", sbInterfaceRoutePrefixes.toString());
419                                 }
420                         }
421                 }
422         }
423         
424         private void buildVfModuleSriovParameters(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) {
425                 // SRIOV Parameters
426                 GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters();
427                 if (sriovParameters != null) {
428                         GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters heatVlanFilters = sriovParameters.getHeatVlanFilters();
429                         if (heatVlanFilters != null) {
430                                 List<String> heatVlanFiltersList = heatVlanFilters.getHeatVlanFilter();
431                                 StringBuilder sriovFilterBuf = new StringBuilder();
432                                 if (heatVlanFiltersList != null) {
433                                         for(int a = 0; a < heatVlanFiltersList.size(); a++){
434                                                 String heatVlanFilterValue = heatVlanFiltersList.get(a);                                                
435                                                 if (a != heatVlanFiltersList.size() - 1) {
436                                                         sriovFilterBuf.append(heatVlanFilterValue).append(",");
437                                                 }
438                                                 else {
439                                                         sriovFilterBuf.append(heatVlanFilterValue);                                             
440                                                 }
441                                         }                                                       
442                                         if (heatVlanFiltersList.size() > 0) {
443                                                 paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString());
444                                         }
445                                 }
446                         }
447                 }
448         }
449         
450         private void buildVfModuleNetworkInformation(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
451                 
452                 GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems = network.getNetworkInformationItems();
453                 StringBuilder sbIpv4Ips = new StringBuilder();
454                 StringBuilder sbIpv6Ips = new StringBuilder();
455                 
456                 if (networkInformationItems != null) {
457                         List<GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem> networkInformationItemList = networkInformationItems.getNetworkInformationItem();
458                         if (networkInformationItemList != null) {
459                                 for(int a = 0; a < networkInformationItemList.size(); a++){
460                                         GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem ipAddress = networkInformationItemList.get(a);
461                                         if (ipAddress != null) {
462                                                 GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps ips = ipAddress.getNetworkIps();
463                                                 if (ips != null) {
464                                                         List<String> ipsList = ips.getNetworkIp();
465                                                         if (ipsList != null) {                                                  
466                                                                 String ipVersion = ipAddress.getIpVersion();
467                                                                 for (int b = 0; b < ipsList.size(); b++) {
468                                                                         String ipAddressValue = ipsList.get(b);
469                                                                         if (ipVersion.equals("ipv4")) {
470                                                                                 if (b != ipsList.size() - 1) {
471                                                                                         sbIpv4Ips.append(ipAddressValue + ",");
472                                                                                 }
473                                                                                 else {
474                                                                                         sbIpv4Ips.append(ipAddressValue);
475                                                                                 }
476                                                                                 paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue);                                             
477                                                                         }
478                                                                         else if (ipVersion.equals("ipv6")) {
479                                                                                 if (b != ipsList.size() - 1) {
480                                                                                         sbIpv6Ips.append(ipAddressValue + ",");
481                                                                                 }
482                                                                                 else {
483                                                                                         sbIpv6Ips.append(ipAddressValue);
484                                                                                 }
485                                                                                 paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b, ipAddressValue);                                                          
486                                                                         }                                                       
487                                                                 }
488                                                                 paramsMap.put(key + UNDERSCORE + networkKey + "_ips", sbIpv4Ips.toString());
489                                                                 paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());                                                         
490                                                         }
491                                                 }
492                                         }
493                                 }
494                         }
495                 }
496         }
497         
498         /*
499          * Build Mapping from GenericResourceApi SDNC for Heat Template so that AIC - PO gets accurate requests for vf module assignments.
500          * Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
501          * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
502          */     
503         private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm) {
504                 GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
505         
506                 if (vmNames != null) {
507                 
508                         List<GenericResourceApiVmtopologydataVmnamesVnfcNames> vnfcNamesList = vmNames.getVnfcNames();
509                         if (vnfcNamesList != null) {
510                                 
511                                 for(int i = 0; i < vnfcNamesList.size(); i++){
512                                         
513                                         GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames = vnfcNamesList.get(i);
514                                         parseVnfcNamesData(paramsMap, vnfcNames);
515                                 }
516                         }
517                 }
518         }
519         
520         /*
521          * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template.
522          */     
523         private void parseVnfcNamesData(Map<String,String> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) {
524                 
525                 if (vnfcNames != null) {
526                         GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks();
527                         if (vnfcNetworks != null) {
528                                 List<GenericResourceApiVnfcnetworkdataVnfcNetworkData> vnfcNetworkdataList = vnfcNetworks.getVnfcNetworkData();
529                                 
530                                 if (vnfcNetworkdataList != null) {
531                                         
532                                         for(int networkDataIdx = 0; networkDataIdx < vnfcNetworkdataList.size(); networkDataIdx++){
533                                         
534                                                 GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata = vnfcNetworkdataList.get(networkDataIdx);
535                                                 parseVnfcNetworkData(paramsMap, vnfcNetworkdata, networkDataIdx);
536                                         }
537                                 }
538                         }
539                 }
540         }
541         
542         /*
543          * Parse VnfcNetworkData to build Mapping from GenericResourceApi SDNC for Heat Template.
544          * Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
545          * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
546          */     
547         private void parseVnfcNetworkData(Map<String,String> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) {
548                 
549                 String vmTypeKey = vnfcNetworkdata.getVnfcType();
550                 GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts();
551                 if (vnfcPorts != null) {
552                         List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList = vnfcPorts.getVnfcPort();         
553                         if (vnfcPortList != null) {                                                                     
554                                 for(int portIdx = 0; portIdx < vnfcPortList.size(); portIdx++){
555                                 
556                                         GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort vnfcPort = vnfcPortList.get(portIdx);
557                                         GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces = vnfcPort.getVnicSubInterfaces();
558                                 
559                                         String vnicSubInterfacesString = convertToString(vnicSubInterfaces);
560                                         String  networkRoleKey = vnfcPort.getCommonSubInterfaceRole();  
561                                         String subInterfaceKey = createVnfcSubInterfaceKey(vmTypeKey, networkDataIdx, networkRoleKey, portIdx);
562                                         String globalSubInterfaceKey = createGlobalVnfcSubInterfaceKey(vmTypeKey, networkRoleKey, portIdx);
563                                         
564                                         buildVfModuleSubInterfacesCount(paramsMap, globalSubInterfaceKey, vnicSubInterfaces);
565                                 
566                                         buildVfModuleVlanTag(paramsMap, subInterfaceKey, vnicSubInterfacesString);
567                                 
568                                         buildVfModuleNetworkName(paramsMap, subInterfaceKey, vnicSubInterfacesString);
569                                 
570                                         buildVfModuleNetworkId(paramsMap, subInterfaceKey, vnicSubInterfacesString);
571         
572                                         buildVfModuleIpV4AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
573                                 
574                                         buildVfModuleIpV6AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
575                                 
576                                         buildVfModuleFloatingIpV4HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
577         
578                                         buildVfModuleFloatingIpV6HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
579                                 }
580                         }
581                 }
582         }
583         
584         /*
585          * Build "count" (calculating the total number of sub-interfaces) for Heat Template
586          * Building Criteria : {vm-type}_subint_{network-role}_port_{index}_subintcount
587          * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
588          * Example: fw_subint_ctrl_port_0_subintcount
589          * 
590          */
591         private void buildVfModuleSubInterfacesCount(Map<String,String> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) {
592
593                 List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList = vnicSubInterfaces.getSubInterfaceNetworkData();
594                 
595                 if ( (subInterfaceNetworkDataList != null) && !subInterfaceNetworkDataList.isEmpty() ) {
596                         addPairToMap(paramsMap, keyPrefix, SUB_INT_COUNT, String.valueOf(subInterfaceNetworkDataList.size()));
597                 }
598     }
599         
600         protected String createVnfcSubInterfaceKey(String vmTypeKey, int networkDataIdx, String networkRoleKey, int portIdx) {
601                 
602                 return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, networkDataIdx, SUB_INT, networkRoleKey, PORT, portIdx));
603         }
604         
605         protected String createGlobalVnfcSubInterfaceKey(String vmTypeKey,String networkRoleKey, int portIdx) {
606                 
607                 return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, SUB_INT, networkRoleKey, PORT, portIdx));
608         }
609
610         /*
611          * Build VLAN Tag for Heat Template
612          * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_vlan_ids
613          * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
614          * Example: fw_0_subint_ctrl_port_0_vlan_ids
615          * 
616          */
617         protected void buildVfModuleVlanTag(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
618                 
619                 List<String> vlanTagIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id");
620
621                 addPairToMap(paramsMap, keyPrefix, VLAN_IDS, vlanTagIds);
622         }
623         /*
624          * Build "network_name" for Heat Template
625          * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_names
626          * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
627          * Example: fw_0_subint_ctrl_port_0_net_names
628          * 
629          */
630         protected void buildVfModuleNetworkName(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
631                 
632                 List<String> neworkNames = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name");
633                 
634                 addPairToMap(paramsMap, keyPrefix, NET_NAMES, neworkNames);
635         }
636
637         /*
638          * Build "network_id" for Heat Template
639          * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_ids
640          * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
641          * Example: fw_0_subint_ctrl_port_0_net_ids
642          * 
643          */
644         protected void buildVfModuleNetworkId(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
645                 
646                 List<String> neworkIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id");
647                 
648                 addPairToMap(paramsMap, keyPrefix, NET_IDS, neworkIds);
649         }
650         
651         /*
652          * Build ip_address for V4 for Heat Template
653          * Building Criteria : 
654          * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index}  -- for ipV4
655          * key = vm-type, networkRoleKey = NetWork-Role
656          */
657         protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
658                 
659                 List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]");
660                 
661                 addPairToMap(paramsMap, keyPrefix, IP, ipv4Ips);
662
663                 for (int i = 0; i < ipv4Ips.size(); i++) {
664                         addPairToMap(paramsMap, keyPrefix, IP + UNDERSCORE + i, ipv4Ips.get(i));
665                 }
666
667         }
668         
669         /*
670          * Build ip_address for Heat Template
671          * Building Criteria : 
672          * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6
673          * key = vm-type, networkRoleKey = NetWork-Role
674          */
675         protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
676                 
677                 List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]");
678
679                 addPairToMap(paramsMap, keyPrefix, V6_IP, ipv6Ips);
680
681                 for (int i = 0; i < ipv6Ips.size(); i++) {
682                         addPairToMap(paramsMap, keyPrefix, V6_IP + UNDERSCORE + i, ipv6Ips.get(i));
683                 }
684     }
685         
686         /*
687          * Build floatingip_address for Heat Template
688          * Building Criteria : 
689          * {vm-type}_subint_{network-role}_port_{index}_floating_ip  -- for ipV4
690          */
691         protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
692                 
693                 List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]");
694
695                 if (!floatingV4.isEmpty()) {
696                         floatingV4 = Collections.singletonList(floatingV4.get(0));
697                 }
698                 addPairToMap(paramsMap, keyPrefix, FLOATING_IP, floatingV4);
699
700         }
701         
702         /*
703          * Build floatingip_address for Heat Template
704          * Building Criteria : 
705          * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6
706          */
707         protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,String> paramsMap, String keyPrefix, String vnicSubInterfaces) {
708                                 
709                 List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]");
710                 
711                 if (!floatingV6.isEmpty()) {
712                         floatingV6 = Collections.singletonList(floatingV6.get(0));
713                 }
714                 addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6);
715         }
716         
717         protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, String value) {
718                 
719                 addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value));
720         }
721
722         protected void addPairToMap(Map<String, String> paramsMap, String keyPrefix, String key, List<String> value) {
723                 
724                 if (!value.isEmpty()) {
725                         paramsMap.put(keyPrefix + key, Joiner.on(",").join(value));
726                 }
727         }
728         
729         private void buildParamsMapFromSdncParams(Map<String,String> paramsMap, GenericResourceApiParam parametersData) {               
730                 if (parametersData != null) {
731                         List<GenericResourceApiParamParam> paramsList = parametersData.getParam();
732                         if (paramsList != null) {
733                                 for (int i = 0; i < paramsList.size(); i++) {
734                                         GenericResourceApiParamParam param = paramsList.get(i);
735                                         String parameterName = param.getName();
736                                         if (!sdncResponseParamsToSkip.contains(parameterName)) {
737                                                 String parameterValue = param.getValue();
738                                                 paramsMap.put(parameterName, parameterValue);
739                                         }
740                                 }                               
741                         }
742                 }                                               
743         }
744         
745         private Map<String,String> buildNetworkRoleMap(GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology) throws JsonParseException, JsonMappingException, IOException {
746                 Map<String, String> networkRoleMap = new HashMap<>();           
747                 GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
748                 if (vfModuleAssignments != null) {                      
749                         GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
750                         if (vms != null) {
751                         List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
752                         if (vmsList != null) {
753                                         for (GenericResourceApiVmTopologyData vm : vmsList){                                                    
754                                                 GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
755                                                 if (vmNetworks != null) {
756                                                         List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
757                                                         if (vmNetworksList != null) {
758                                                                         for(int n = 0; n < vmNetworksList.size(); n++){
759                                                                                 GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
760                                                                                 String networkRole = network.getNetworkRole();
761                                                                                 String networkRoleValue = network.getNetworkRoleTag();
762                                                                                 if (networkRoleValue ==  null || networkRoleValue.isEmpty()) {
763                                                                                         networkRoleValue = networkRole;
764                                                                                 }
765                                                                                 networkRoleMap.put(networkRole, networkRoleValue);
766                                                                         }
767                                                                 }
768                                                         }
769                                                 }
770                                         }
771                                 }
772                         }
773                         return networkRoleMap;
774                 }
775         
776         public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext,CloudRegion cloudRegion, 
777                         ServiceInstance serviceInstance, GenericVnf genericVnf,
778                         VfModule vfModule) throws IOException {
779                 DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
780                 deleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
781                 deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
782                 deleteVfModuleRequest.setVnfId(genericVnf.getVnfId());
783                 deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
784                 if (!StringUtils.isEmpty(vfModule.getHeatStackId())){
785                         deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId
786                 } else
787                 {
788                         deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName());
789                 }
790                 
791                 deleteVfModuleRequest.setSkipAAI(true);
792                 setIdAndUrl(deleteVfModuleRequest);
793                 MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);       
794                 deleteVfModuleRequest.setMsoRequest(msoRequest);
795                 return deleteVfModuleRequest;
796         }
797         
798         protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException{
799                 String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
800                 deleteVfModuleRequest.setMessageId(messageId);          
801                 deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
802         }
803         
804         private String convertToString(Object obj) {
805                 String json;
806                 try {
807                         json = mapper.writeValueAsString(obj);
808                 } catch (JsonProcessingException e) {
809                         json = "{}";
810                 }
811                 
812                 return json;
813         }
814         
815         private VfModule getBaseVfModule(GenericVnf genericVnf) {
816                 List<VfModule> vfModules = genericVnf.getVfModules();
817                 VfModule baseVfModule = null;
818                 if (vfModules != null) {
819                         for(int i = 0; i < vfModules.size(); i++) {
820                                 if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
821                                         baseVfModule = vfModules.get(i);
822                                         break;                                  
823                                 }
824                         }
825                 }
826                 return baseVfModule;
827         }
828 }