Merge "Adding Junit"
[so.git] / adapters / mso-vnf-adapter / src / main / java / org / openecomp / mso / adapters / vnf / MsoVnfAdapterImpl.java
index 95e62a0..1db4c9f 100644 (file)
 
 package org.openecomp.mso.adapters.vnf;
 
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Optional;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.ObjectMapper;
+import java.util.Scanner;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
 import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
 import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
 import org.openecomp.mso.adapters.vnf.exceptions.VnfNotFound;
@@ -55,26 +68,19 @@ import org.openecomp.mso.openstack.utils.MsoHeatUtils;
 import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
 import org.openecomp.mso.properties.MsoPropertiesFactory;
 
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 @WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
 public class MsoVnfAdapterImpl implements MsoVnfAdapter {
 
-    CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
-    protected CloudConfig cloudConfig = null;
+       CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
+       protected CloudConfig cloudConfig = null;
 
-    MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
+       MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
 
-    private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
+       private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
     private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
     private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
     private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
@@ -96,8 +102,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
      * @param msoPropFactory
      */
     public MsoVnfAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) {
-        this.msoPropertiesFactory = msoPropFactory;
-        this.cloudConfigFactory = cloudConfigFact;
+       this.msoPropertiesFactory = msoPropFactory;
+       this.cloudConfigFactory = cloudConfigFact;
     }
 
     /**
@@ -160,65 +166,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                            Holder <String> vnfId,
                            Holder <Map <String, String>> outputs,
                            Holder <VnfRollback> rollback) throws VnfException {
-        // Create a hook here to catch shortcut createVf requests:
-        if (requestType != null) {
-            if (requestType.startsWith("VFMOD")) {
-                LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType);
-                String newRequestType = requestType.substring(5);
-                String vfVolGroupHeatStackId = "";
-                String vfBaseHeatStackId = "";
-                try {
-                    if (volumeGroupHeatStackId != null) {
-                        vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|"));
-                        vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1);
-                    }
-                } catch (Exception e) {
-                    // might be ok - both are just blank
-                    LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e);
-                }
-                this.createVfModule(cloudSiteId,
-                        tenantId,
-                        vnfType,
-                        vnfVersion,
-                        vnfName,
-                        newRequestType,
-                        vfVolGroupHeatStackId,
-                        vfBaseHeatStackId,
+       // Create a hook here to catch shortcut createVf requests:
+       if (requestType != null) {
+               if (requestType.startsWith("VFMOD")) {
+                       LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType);
+                       String newRequestType = requestType.substring(5);
+                       String vfVolGroupHeatStackId = "";
+                       String vfBaseHeatStackId = "";
+                       try {
+                               if (volumeGroupHeatStackId != null) {
+                                       vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|"));
+                                       vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1);
+                               }
+                       } catch (Exception e) {
+                               // might be ok - both are just blank
+                               LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e);
+                       }
+                       this.createVfModule(cloudSiteId,
+                                       tenantId,
+                                       vnfType,
+                                       vnfVersion,
+                                       vnfName,
+                                       newRequestType,
+                                       vfVolGroupHeatStackId,
+                                       vfBaseHeatStackId,
                         null,
-                        inputs,
-                        failIfExists,
-                        backout,
-                        msoRequest,
-                        vnfId,
-                        outputs,
-                        rollback);
-                return;
-            }
-        }
-        // createVf will know if the requestType starts with "X" that it's the "old" way
-        StringBuilder newRequestTypeSb = new StringBuilder("X");
-        String vfVolGroupHeatStackId = "";
-        String vfBaseHeatStackId = "";
-        if (requestType != null) {
-            newRequestTypeSb.append(requestType);
-            }
-        this.createVfModule(cloudSiteId,
+                                       inputs,
+                                       failIfExists,
+                                       backout,
+                                       msoRequest,
+                                       vnfId,
+                                       outputs,
+                                       rollback);
+                       return;
+               }
+       }
+       // createVf will know if the requestType starts with "X" that it's the "old" way
+       StringBuilder newRequestTypeSb = new StringBuilder("X");
+       String vfVolGroupHeatStackId = "";
+       String vfBaseHeatStackId = "";
+       if (requestType != null) {
+               newRequestTypeSb.append(requestType);
+            }
+               this.createVfModule(cloudSiteId, 
                                                tenantId,
-                vnfType,
-                vnfVersion,
+                               vnfType, 
+                               vnfVersion, 
                                                vnfName,
-                newRequestTypeSb.toString(),
-                vfVolGroupHeatStackId,
-                vfBaseHeatStackId,
-                null,
-                inputs,
-                failIfExists,
-                backout,
-                msoRequest,
-                vnfId,
-                outputs,
-                rollback);
-        // End createVf shortcut
+                               newRequestTypeSb.toString(), 
+                               vfVolGroupHeatStackId, 
+                               vfBaseHeatStackId, 
+                               null,
+                               inputs, 
+                               failIfExists, 
+                               backout, 
+                               msoRequest, 
+                               vnfId, 
+                               outputs, 
+                               rollback);
+       // End createVf shortcut
         }
 
     @Override
@@ -233,10 +239,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                            MsoRequest msoRequest,
                            Holder <Map <String, String>> outputs,
                            Holder <VnfRollback> rollback) throws VnfException {
-        // As of 1707 - this method should no longer be called
-        MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
-        MsoLogger.setServiceName ("UpdateVnf");
-        LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
+       // As of 1707 - this method should no longer be called
+       MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
+       MsoLogger.setServiceName ("UpdateVnf");
+       LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
     }
 
     /**
@@ -264,7 +270,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                           Holder <VnfStatus> status,
                           Holder <Map <String, String>> outputs) throws VnfException {
         MsoLogger.setLogContext (msoRequest);
-        MsoLogger.setServiceName ("QueryVnf");
+       MsoLogger.setServiceName ("QueryVnf");
         LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
 
         // Will capture execution time for metrics
@@ -295,7 +301,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             vnfExists.value = Boolean.FALSE;
             status.value = VnfStatus.NOTFOUND;
             vnfId.value = null;
-            outputs.value = new HashMap <String, String> (); // Return as an empty map
+            outputs.value = new HashMap<>(); // Return as an empty map
 
             LOGGER.debug ("VNF " + vnfName + " not found");
         } else {
@@ -326,7 +332,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                            String vnfName,
                            MsoRequest msoRequest) throws VnfException {
         MsoLogger.setLogContext (msoRequest);
-        MsoLogger.setServiceName ("DeleteVnf");
+       MsoLogger.setServiceName ("DeleteVnf");
         LOGGER.debug ("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
         // Will capture execution time for metrics
         long startTime = System.currentTimeMillis ();
@@ -366,7 +372,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
     public void rollbackVnf (VnfRollback rollback) throws VnfException {
         long startTime = System.currentTimeMillis ();
         MsoLogger.setServiceName ("RollbackVnf");
-        // rollback may be null (e.g. if stack already existed when Create was called)
+       // rollback may be null (e.g. if stack already existed when Create was called)
         if (rollback == null) {
             LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf");
             LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null");
@@ -426,33 +432,35 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             if (value instanceof String) {
                 stringOutputs.put (key, (String) value);
             } else if (value instanceof Integer)  {
-                try {
-                    String str = "" + value;
-                    stringOutputs.put(key, str);
-                } catch (Exception e) {
-                    LOGGER.debug("Unable to add " + key + " to outputs",e);
-                }
+               try {
+                       String str = "" + value;
+                       stringOutputs.put(key, str);
+               } catch (Exception e) {
+                       LOGGER.debug("Unable to add " + key + " to outputs",e);
+               }
             } else if (value instanceof JsonNode) {
-                try {
-                    String str = this.convertNode((JsonNode) value);
-                    stringOutputs.put(key, str);
-                } catch (Exception e) {
-                    LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
-                }
+               try {
+                       //String str = this.convertNode((JsonNode) value);
+                       String str = value.toString();
+                       stringOutputs.put(key, str);
+               } catch (Exception e) {
+                       LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
+               }
             } else if (value instanceof java.util.LinkedHashMap) {
-                try {
-                    String str = JSON_MAPPER.writeValueAsString(value);
-                    stringOutputs.put(key, str);
-                } catch (Exception e) {
-                    LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
-                }
+               try {
+                                       //String str = JSON_MAPPER.writeValueAsString(value);
+                       String str = value.toString();
+                       stringOutputs.put(key, str);
+               } catch (Exception e) {
+                       LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
+               }
             } else {
-                try {
-                    String str = value.toString();
-                    stringOutputs.put(key, str);
-                } catch (Exception e) {
-                    LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e);
-                }
+               try {
+                       String str = value.toString();
+                       stringOutputs.put(key, str);
+               } catch (Exception e) {
+                       LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e);
+               }
             }
         }
         return stringOutputs;
@@ -514,7 +522,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         }
         LOGGER.debug(sb.toString());
     }
-
+    
     private void sendMapToDebug(Map<String, String> inputs) {
         int i = 0;
         StringBuilder sb = new StringBuilder("inputs:");
@@ -536,8 +544,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
             final String json = JSON_MAPPER.writeValueAsString(obj);
             return json;
-        } catch (JsonParseException jpe) {
-            LOGGER.debug("Error converting json to string " + jpe.getMessage(),jpe);
         } catch (Exception e) {
             LOGGER.debug("Error converting json to string " + e.getMessage(),e);
         }
@@ -548,7 +554,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         if (objectMap == null) {
             return null;
         }
-        Map<String, String> stringMap = new HashMap<String, String>();
+        Map<String, String> stringMap = new HashMap<>();
         for (String key : objectMap.keySet()) {
             if (!stringMap.containsKey(key)) {
                 Object obj = objectMap.get(key);
@@ -561,7 +567,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                         String str = this.convertNode((JsonNode) obj);
                         stringMap.put(key, str);
                     } catch (Exception e) {
-                        LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e);
                         //okay in this instance - only string values (fqdn) are expected to be needed
                     }
                 } else if (obj instanceof java.util.LinkedHashMap) {
@@ -570,21 +576,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                         String str = JSON_MAPPER.writeValueAsString(obj);
                         stringMap.put(key, str);
                     } catch (Exception e) {
-                        LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e);
-                    }
-                }  else if (obj instanceof Integer) {
-                    try {
-                        String str = "" + obj;
-                        stringMap.put(key, str);
-                    } catch (Exception e) {
-                        LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e);
+                                       }
+                               }  else if (obj instanceof Integer) {
+                                       try {
+                                               String str = "" + obj;
+                                               stringMap.put(key, str);
+                                       } catch (Exception e) {
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e);
                     }
                 } else {
                     try {
-                        String str = obj.toString();
+                                               String str = obj.toString();
                         stringMap.put(key, str);
                     } catch (Exception e) {
-                        LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e);
+                                               LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e);
                     }
                 }
             }
@@ -610,9 +616,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             Holder <String> vnfId,
             Holder <Map <String, String>> outputs,
             Holder <VnfRollback> rollback) throws VnfException {
-        String vfModuleName = vnfName;
-        String vfModuleType = vnfType;
-        String vfVersion = vnfVersion;
+       String vfModuleName = vnfName;
+       String vfModuleType = vnfType;
+       String vfVersion = vnfVersion;
         String mcu = modelCustomizationUuid;
         boolean useMCUuid = false;
         if (mcu != null && !mcu.isEmpty()) {
@@ -625,45 +631,45 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                 useMCUuid = true;
             }
         }
-        MsoLogger.setLogContext (msoRequest);
-        MsoLogger.setServiceName ("CreateVfModule");
-        String requestTypeString = "";
+       MsoLogger.setLogContext (msoRequest);
+       MsoLogger.setServiceName ("CreateVfModule");
+       String requestTypeString = "";
         if (requestType != null && !"".equals(requestType)) {
-            requestTypeString = requestType;
+               requestTypeString = requestType;
         }
         String nestedStackId = null;
         if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
-            if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
-                nestedStackId = volumeGroupHeatStackId;
-            }
+               if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
+                       nestedStackId = volumeGroupHeatStackId;
+               }
         }
         String nestedBaseStackId = null;
         if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
-            if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
-                nestedBaseStackId = baseVfHeatStackId;
-            }
+               if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
+                       nestedBaseStackId = baseVfHeatStackId;
+               }
         }
 
         if (inputs == null) {
-            // Create an empty set of inputs
-            inputs = new HashMap<>();
-            LOGGER.debug("inputs == null - setting to empty");
+               // Create an empty set of inputs
+               inputs = new HashMap<>();
+               LOGGER.debug("inputs == null - setting to empty");
         } else {
-            this.sendMapToDebug(inputs);
+               this.sendMapToDebug(inputs);
         }
         //This method will also handle doing things the "old" way - i.e., just orchestrate a VNF
         boolean oldWay = false;
         if (requestTypeString.startsWith("X")) {
-            oldWay = true;
-            LOGGER.debug("orchestrating a VNF - *NOT* a module!");
-            requestTypeString = requestTypeString.substring(1);
+               oldWay = true;
+               LOGGER.debug("orchestrating a VNF - *NOT* a module!");
+               requestTypeString = requestTypeString.substring(1);
         }
 
         // 1607 - let's parse out the request type we're being sent
         boolean isBaseRequest = false;
         boolean isVolumeRequest = false;
         if (requestTypeString.startsWith("VOLUME")) {
-            isVolumeRequest = true;
+               isVolumeRequest = true;
         }
 
         LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId);
@@ -704,44 +710,44 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         }
         // New with 1607 - more precise handling/messaging if the stack already exists
         if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) {
-            // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED
-            HeatStatus status = heatStack.getStatus();
-            if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) {
-                // fail - it's in progress - return meaningful error
+               // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED
+               HeatStatus status = heatStack.getStatus();
+               if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) {
+                       // fail - it's in progress - return meaningful error
                 String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually.";
                 LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
                 throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
-            }
-            if (status == HeatStatus.FAILED) {
-                // fail - it exists and is in a FAILED state
+               }
+               if (status == HeatStatus.FAILED) {
+                       // fail - it exists and is in a FAILED state
                 String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
                 LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
                 throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
-            }
-            if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) {
-                // fail - it exists and is in a FAILED state
+               }
+               if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) {
+                       // fail - it exists and is in a FAILED state
                 String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
                 LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
                 throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
-            }
-            if (status == HeatStatus.CREATED) {
-                // fail - it exists
-                if (failIfExists != null && failIfExists) {
-                    String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
-                    LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
+               }
+               if (status == HeatStatus.CREATED) {
+                       // fail - it exists
+                       if (failIfExists != null && failIfExists) {
+                               String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
+                               LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
                     LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
-                    throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
-                } else {
-                    LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ());
-                    // Populate the outputs from the existing stack.
-                    vnfId.value = heatStack.getCanonicalName ();
-                    outputs.value = copyStringOutputs (heatStack.getOutputs ());
-                    rollback.value = vfRollback; // Default rollback - no updates performed
-                }
-            }
+                               throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
+                       } else {
+                               LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ());
+                               // Populate the outputs from the existing stack.
+                               vnfId.value = heatStack.getCanonicalName ();
+                               outputs.value = copyStringOutputs (heatStack.getOutputs ());
+                               rollback.value = vfRollback; // Default rollback - no updates performed
+                       }
+               }
             LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
             return;
 
@@ -752,36 +758,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         long subStartTime2 = System.currentTimeMillis ();
         Map<String, Object> nestedVolumeOutputs = null;
         if (nestedStackId != null) {
-            try {
-                LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
-                nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
+               try {
+                       LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
+                       nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
                 LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
-            } catch (MsoException me) {
-                // Failed to query the Stack due to an openstack exception.
-                // Convert to a generic VnfException
-                me.addContext ("CreateVFModule");
-                String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+               } catch (MsoException me) {
+                   // Failed to query the Stack due to an openstack exception.
+                   // Convert to a generic VnfException
+                   me.addContext ("CreateVFModule");
+                   String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
                 LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me);
-                LOGGER.debug("ERROR trying to query nested stack= " + error);
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me);
+                       LOGGER.debug("ERROR trying to query nested stack= " + error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
-            }
-            if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
-                String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST");
+                   throw new VnfException (me);
+               }
+               if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+                   String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
-                LOGGER.debug(error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
-            } else {
-                LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*");
-                //this.sendMapToDebug(inputs);
-                nestedVolumeOutputs = nestedHeatStack.getOutputs();
-                this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
-                //TODO
-                //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
-                //this.sendMapToDebug(inputs);
-            }
+                   LOGGER.debug(error);
+                   throw new VnfException (error, MsoExceptionCategory.USERDATA);
+               } else {
+                       LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*");
+                       //this.sendMapToDebug(inputs);
+                       nestedVolumeOutputs = nestedHeatStack.getOutputs();
+                       this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
+                       //TODO
+                       //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);      
+                       //this.sendMapToDebug(inputs);
+               }
         }
 
         // handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests
@@ -789,137 +795,94 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         long subStartTime3 = System.currentTimeMillis ();
         Map<String, Object> baseStackOutputs = null;
         if (nestedBaseStackId != null) {
-            try {
-                LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
-                nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
+               try {
+                       LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
+                       nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
                 LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
-            } catch (MsoException me) {
-                // Failed to query the Stack due to an openstack exception.
-                // Convert to a generic VnfException
-                me.addContext ("CreateVFModule");
-                String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+               } catch (MsoException me) {
+                   // Failed to query the Stack due to an openstack exception.
+                   // Convert to a generic VnfException
+                   me.addContext ("CreateVFModule");
+                   String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
                 LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me);
-                LOGGER.debug("ERROR trying to query nested base stack= " + error);
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me);
+                       LOGGER.debug("ERROR trying to query nested base stack= " + error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
-            }
-            if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
-                String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST");
+                   throw new VnfException (me);
+               }
+               if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+                   String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
-                LOGGER.debug(error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
-            } else {
-                LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*");
-                //this.sendMapToDebug(inputs);
-                baseStackOutputs = nestedBaseHeatStack.getOutputs();
-                this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
-                //TODO
-                //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
-                //this.sendMapToDebug(inputs);
-            }
+                   LOGGER.debug(error);
+                   throw new VnfException (error, MsoExceptionCategory.USERDATA);
+               } else {
+                       LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*");
+                       //this.sendMapToDebug(inputs);
+                       baseStackOutputs = nestedBaseHeatStack.getOutputs();
+                       this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
+                       //TODO
+                       //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);      
+                       //this.sendMapToDebug(inputs);
+               }
         }
 
         // Ready to deploy the new VNF
 
-        CatalogDatabase db = CatalogDatabase.getInstance();
-
-        try {
+        try (CatalogDatabase db = CatalogDatabase.getInstance()) {
             // Retrieve the VF
-            VfModule vf = null;
-            VnfResource vnfResource = null;
-            VfModuleCustomization vfmc = null;
-            LOGGER.debug("version: " + vfVersion);
+               VfModule vf = null;
+               VnfResource vnfResource = null;
+               VfModuleCustomization vfmc = null;
+               LOGGER.debug("version: " + vfVersion);
             if (useMCUuid) {
-                // 1707 - db refactoring
-                vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
-                vf = vfmc != null ? vfmc.getVfModule() : null;
+                       // 1707 - db refactoring
+                       vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
+                       vf = vfmc != null ? vfmc.getVfModule() : null;
                 // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same.
-                //vf = db.getVfModuleByModelCustomizationUuid(mcu);
+                       //vf = db.getVfModuleByModelCustomizationUuid(mcu);
                 if (vf == null) {
                     LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu);
-                    String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu;
+                    String error =
+                        "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu;
                     LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
-                            "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu);
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                        "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "",
+                        MsoLogger.ErrorCode.DataError,
+                        "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu);
+                    LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+                        error);
                     throw new VnfException(error, MsoExceptionCategory.USERDATA);
                 } else {
-                    LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
-                }
-                if (vf.isBase()) {
-                    isBaseRequest = true;
-                    LOGGER.debug("This is a BASE VF request!");
-                } else {
-                    LOGGER.debug("This is *not* a BASE VF request!");
-                    if (!isVolumeRequest && nestedBaseStackId == null) {
-                        LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
-                    }
-                }
-            }
-            /*
-            else if (!oldWay) {
-                // Need to handle old and new schema methods - for a time. Try the new way first.
-                if (vfVersion != null && !vfVersion.isEmpty()) {
-                    vf = db.getVfModuleType(vfModuleType, vfVersion);
-                    if (vf == null) {
-                        LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME");
-                        vf = db.getVfModuleModelName(vfModuleType, vfVersion);
-                        if (vf == null) {
-                            LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR");
-                        }
-                    }
-                } else {
-                    vf = db.getVfModuleType(vfModuleType);
-                    if (vf == null) {
-                        LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME");
-                        vf = db.getVfModuleModelName(vfModuleType);
-                        if (vf == null) {
-                            LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR");
-                        }
-                    }
-                }
-                if (vf == null) {
-                    String error = "Create VF Module: Unable to determine specific VF Module Type: "
-                            + vfModuleType;
-                    if (vfVersion != null && !vfVersion.isEmpty()) {
-                        error += " with version = " + vfVersion;
-                    }
-                    LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
-                            "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type");
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                    throw new VnfException(error, MsoExceptionCategory.USERDATA);
+                               LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
                 }
-                LOGGER.debug("Got VF module definition from Catalog: "
-                        + vf.toString());
-
                 if (vf.isBase()) {
                     isBaseRequest = true;
                     LOGGER.debug("This is a BASE VF request!");
                 } else {
                     LOGGER.debug("This is *not* a BASE VF request!");
                     if (!isVolumeRequest && nestedBaseStackId == null) {
-                        LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
+                        LOGGER.debug(
+                            "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
                     }
                 }
-            } */
-            else { // This is to support gamma only - get info from vnf_resource table
-                if (vfVersion != null && !vfVersion.isEmpty()) {
-                    vnfResource = db.getVnfResource(vnfType, vnfVersion);
-                } else {
-                    vnfResource = db.getVnfResource(vnfType);
-                }
-                if (vnfResource == null) {
-                    String error = "Create VNF: Unknown VNF Type: " + vnfType;
-                    LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type",
-                            vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type");
+               }
+               else { // This is to support gamma only - get info from vnf_resource table
+                               if (vfVersion != null && !vfVersion.isEmpty()) {
+                                       vnfResource = db.getVnfResource(vnfType, vnfVersion);
+                               } else {
+                                       vnfResource = db.getVnfResource(vnfType);
+                               }
+                               if (vnfResource == null) {
+                                       String error = "Create VNF: Unknown VNF Type: " + vnfType;
+                                       LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type",
+                                                       vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type");
                     LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                    throw new VnfException(error, MsoExceptionCategory.USERDATA);
-                }
-                LOGGER.debug("Got VNF module definition from Catalog: "
-                        + vnfResource.toString());
-            }
-            // By here - we have either a vf or vnfResource
+                                       throw new VnfException(error, MsoExceptionCategory.USERDATA);
+                               }
+                               LOGGER.debug("Got VNF module definition from Catalog: "
+                                               + vnfResource.toString());
+                       }
+                       // By here - we have either a vf or vnfResource
 
             //1607 - Add version check
             // First - see if it's in the VnfResource record
@@ -930,7 +893,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     //vnfResource = db.getVnfResourceById(vnfResourceId);
                     vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
                     if (vnfResource == null) {
-                        LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+                        LOGGER.debug(
+                            "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
                     }
                 }
             }
@@ -941,7 +905,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     minVersionVnf = vnfResource.getAicVersionMin();
                     maxVersionVnf = vnfResource.getAicVersionMax();
                 } catch (Exception e) {
-                    LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+                    LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
                     minVersionVnf = null;
                     maxVersionVnf = null;
                 }
@@ -974,17 +938,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                             moreThanMax = aicV.isMoreRecentThan(maxVersionVnf);
                             equalToMax = aicV.isTheSameVersion(maxVersionVnf);
                         } catch (Exception e) {
-                            LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e);
+                            LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage()
+                                + " - will default to not check", e);
                             doNotTest = true;
                         }
                         if (!doNotTest) {
                             if ((moreThanMin || equalToMin) // aic >= min
-                                    && (equalToMax || !(moreThanMax))) { //aic <= max
-                                LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version());
+                                && (equalToMax || !(moreThanMax))) { //aic <= max
+                                LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource
+                                    .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf
+                                    + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:"
+                                    + cloudSiteOpt.get().getAic_version());
                             } else {
                                 // ERROR
-                                String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
-                                LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
+                                String error =
+                                    "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource
+                                        .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:"
+                                        + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId()
+                                        + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
+                                LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
+                                    MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
                                 LOGGER.debug(error);
                                 throw new VnfException(error, MsoExceptionCategory.USERDATA);
                             }
@@ -996,7 +969,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
                 }
             } else {
-                LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
+                LOGGER.debug(
+                    "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
             }
             // End Version check 1607
 
@@ -1004,171 +978,162 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             // with VNF_RESOURCE - we use the old methods.
             //Integer heatTemplateId = null;
             //Integer heatEnvtId = null;
-
+            
             String heatTemplateArtifactUuid = null;
             String heatEnvironmentArtifactUuid = null;
 
-            if (!oldWay) {
-                if (isVolumeRequest) {
-                    heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
-                    heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
-                } else {
-                    heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
-                    heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
-                }
-            } else {
-                if (isVolumeRequest) {
-                    LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
-                    /*
-                    VnfComponent vnfComponent = null;
-                    vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME");
-                    if (vnfComponent == null) {
-                        String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME";
-                        LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry");
-                        LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                        throw new VnfException (error, MsoExceptionCategory.USERDATA);
-                    } else {
-                        heatTemplateId = vnfComponent.getHeatTemplateId();
-                        heatEnvtId = vnfComponent.getHeatEnvironmentId();
-                    }
-                    */
-                } else {
-                    heatTemplateArtifactUuid = vnfResource.getTemplateId();
-                    heatEnvironmentArtifactUuid = null;
-                }
-            }
-            // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
-            HeatTemplate heatTemplate = null;
-            if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
-                String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
-                LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
+                       if (!oldWay) {
+                               if (isVolumeRequest) {
+                                       heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
+                                       heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
+                               } else {
+                                       heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
+                                       heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
+                               }
+                       } else {
+                               if (isVolumeRequest) {
+                                       LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
+                               } else {
+                                       heatTemplateArtifactUuid = vnfResource.getTemplateId();
+                                       heatEnvironmentArtifactUuid = null;
+                               }
+                       }
+                       // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
+                       HeatTemplate heatTemplate = null;
+                       if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
+                               String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
+                               LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
-                        MsoAlarmLogger.CRITICAL, error);
-                throw new VnfException(error, MsoExceptionCategory.INTERNAL);
-            } else {
-                heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
-            }
-            if (heatTemplate == null) {
-                String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
-                LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
-                        "Heat Template ID",
-                        String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
+                               alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+                                               MsoAlarmLogger.CRITICAL, error);
+                               throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+                       } else {
+                               heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
+                       }
+                       if (heatTemplate == null) {
+                               String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
+                               LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
+                                               "Heat Template ID",
+                                               String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
-                        MsoAlarmLogger.CRITICAL, error);
-                throw new VnfException(error, MsoExceptionCategory.INTERNAL);
-            }
-            LOGGER.debug("Got HEAT Template from DB");
+                               alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+                                               MsoAlarmLogger.CRITICAL, error);
+                               throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+                       }
+                       LOGGER.debug("Got HEAT Template from DB");
 
             HeatEnvironment heatEnvironment = null;
             String heatEnvironmentString = null;
 
             if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
-                LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
+                LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
                 heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
                 if (heatEnvironment == null) {
                     String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType
-                                   + ", Environment ID="
-                                   + heatEnvironmentArtifactUuid;
-                    LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                        + ", Environment ID="
+                        + heatEnvironmentArtifactUuid;
+                    LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
+                        String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment",
+                        MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
+                    LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+                        error);
                     // Alarm on this error, configuration must be fixed
-                    alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+                    alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
 
-                    throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+                    throw new VnfException(error, MsoExceptionCategory.INTERNAL);
                 } else {
-                    LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ());
-                    heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ());
-                    LOGGER.debug ("after parsing: " + heatEnvironmentString);
+                    LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
+                    heatEnvironmentString = heatEnvironment
+                        .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
+                    LOGGER.debug("after parsing: " + heatEnvironmentString);
                 }
             } else {
-                LOGGER.debug ("no environment parameter found for this Type " + vfModuleType);
+                LOGGER.debug("no environment parameter found for this Type " + vfModuleType);
             }
 
             // 1510 - Add the files: for nested templates *if* there are any
-            LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
-                          + heatTemplate.getArtifactUuid());
-            Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid());
-            Map <String, Object> nestedTemplatesChecked = new HashMap <> ();
+            LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
+                + heatTemplate.getArtifactUuid());
+            Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
+            Map<String, Object> nestedTemplatesChecked = new HashMap<>();
             if (nestedTemplates != null) {
                 // for debugging print them out
-                LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
-                for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+                LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
+                for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
                     String providerResourceFile = entry.getKey();
                     Object value = entry.getValue();
                     String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
                     String childTemplateBody = (String) value;
-                    LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
-                    nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
+                    LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
+                    nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
                 }
             } else {
-                LOGGER.debug ("No nested templates found - nothing to do here");
+                LOGGER.debug("No nested templates found - nothing to do here");
                 nestedTemplatesChecked = null; // just to make sure
             }
 
             // 1510 - Also add the files: for any get_files associated with this vnf_resource_id
             // *if* there are any
             Map<String, HeatFiles> heatFiles = null;
-            Map<String, Object> heatFilesObjects = new HashMap<>();
+                       Map<String, Object> heatFilesObjects = new HashMap<>();
 
             // Add ability to turn on adding get_files with volume requests (by property).
             boolean addGetFilesOnVolumeReq = false;
             try {
-                String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
-                if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
-                    addGetFilesOnVolumeReq = true;
-                    LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
-                }
+               String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
+               if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
+                       addGetFilesOnVolumeReq = true;
+                       LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
+               }
             } catch (Exception e) {
-                LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
-            }
-
-            if (!isVolumeRequest || addGetFilesOnVolumeReq) {
-                if (oldWay) {
-                    LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
-                    //heatFiles = db.getHeatFiles(vnfResource.getId());
-                } else {
-                    // 1607 - now use VF_MODULE_TO_HEAT_FILES table
-                    LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
-                            + vf.getModelUUID());
-                    heatFiles = db
-                            .getHeatFilesForVfModule(vf.getModelUUID());
-                }
-                if (heatFiles != null) {
-                    // add these to stack - to be done in createStack
-                    // here, we will map them to Map<String, Object> from
-                    // Map<String, HeatFiles>
-                    // this will match the nested templates format
-                    LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
-
-                    for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
-                        String heatFileName = entry.getKey();
-                        HeatFiles value = entry.getValue();
-                        if (heatFileName.startsWith("_ERROR|")) {
-                            // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
-                            String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
-                            String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
-                            LOGGER.debug(error);
-                            LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found");
+               LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
+            }
+
+                       if (!isVolumeRequest || addGetFilesOnVolumeReq) {
+                               if (oldWay) {
+                                       LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
+                                       //heatFiles = db.getHeatFiles(vnfResource.getId());
+                               } else {
+                                       // 1607 - now use VF_MODULE_TO_HEAT_FILES table
+                                       LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+                                                       + vf.getModelUUID());
+                                       heatFiles = db
+                                                       .getHeatFilesForVfModule(vf.getModelUUID());
+                               }
+                               if (heatFiles != null) {
+                                       // add these to stack - to be done in createStack
+                                       // here, we will map them to Map<String, Object> from
+                                       // Map<String, HeatFiles>
+                                       // this will match the nested templates format
+                                       LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
+
+                                       for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
+                                               String heatFileName = entry.getKey();
+                                               HeatFiles value = entry.getValue();
+                                               if (heatFileName.startsWith("_ERROR|")) {
+                                                       // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
+                                                       String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
+                                                       String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
+                                                       LOGGER.debug(error);
+                                                       LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found");
                             LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                            // Alarm on this error, configuration must be fixed
-                            alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-                            throw new VnfException (error, MsoExceptionCategory.INTERNAL);
-                        }
-                        String heatFileBody = value.getFileBody();
-                        String heatFileNameChecked = heatFileName;
-                        LOGGER.debug(heatFileNameChecked + " -> "
-                                + heatFileBody);
-                        heatFilesObjects.put(heatFileNameChecked, heatFileBody);
-                    }
-                } else {
-                    LOGGER.debug("No heat files found -nothing to do here");
-                    heatFilesObjects = null;
-                }
-            } else {
-                    LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
-            }
+                                                       // Alarm on this error, configuration must be fixed
+                                                       alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+                                                       throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+                                               }
+                                               String heatFileBody = value.getFileBody();
+                                               String heatFileNameChecked = heatFileName;
+                                               LOGGER.debug(heatFileNameChecked + " -> "
+                                                               + heatFileBody);
+                                               heatFilesObjects.put(heatFileNameChecked, heatFileBody);
+                                       }
+                               } else {
+                                       LOGGER.debug("No heat files found -nothing to do here");
+                                       heatFilesObjects = null;
+                               }
+                       } else {
+                                       LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
+                       }
 
             // Check that required parameters have been supplied
             StringBuilder missingParams = null;
@@ -1181,63 +1146,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             // shouldn't
             boolean checkRequiredParameters = true;
             try {
-                String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
-                                                     .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null);
-                if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
+                String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
+                    .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
+                if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
                     checkRequiredParameters = false;
-                    LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
-                                  + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
+                    LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
+                        + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
                 }
             } catch (Exception e) {
                 // No problem - default is true
-                LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
+                LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
             }
             // 1604 - Add enhanced environment & parameter checking
             // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
             // Part 2: only submit to openstack the parameters in the envt that are in the heat template
             // Note this also removes any comments
             MsoHeatEnvironmentEntry mhee = null;
-            if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) {
+            if (heatEnvironmentString != null && heatEnvironmentString.contains("parameters:")) {
                 //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases");
-                LOGGER.debug("Enhanced environment checking enabled - 1604");
-                mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
+               LOGGER.debug("Enhanced environment checking enabled - 1604");
+                StringBuilder sb = new StringBuilder(heatEnvironmentString);
+                //LOGGER.debug("About to create MHEE with " + sb);
+                mhee = new MsoHeatEnvironmentEntry(sb);
                 StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
                 for (HeatTemplateParam parm : heatTemplate.getParameters()) {
-                    sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
+                       sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
                 }
                 if (!mhee.isValid()) {
-                    sb2.append("Environment says it's not valid! " + mhee.getErrorString());
+                       sb2.append("Environment says it's not valid! " + mhee.getErrorString());
                 } else {
-                    sb2.append("\nEnvironment:");
+                       sb2.append("\nEnvironment:");
                     sb2.append(mhee);
                 }
                 LOGGER.debug(sb2.toString());
             } else {
-                LOGGER.debug("NO ENVIRONMENT for this entry");
+               LOGGER.debug("NO ENVIRONMENT for this entry");
             }
             // New with 1707 - all variables converted to their native object types
             HashMap<String, Object> goldenInputs = null;
-
+            
             LOGGER.debug("Now handle the inputs....first convert");
             ArrayList<String> parameterNames = new ArrayList<>();
             HashMap<String, String> aliasToParam = new HashMap<>();
             StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n");
             int cntr = 0;
-            try {
-                for (HeatTemplateParam htp : heatTemplate.getParameters()) {
-                    sb.append("param[").append(cntr++).append("]=").append(htp.getParamName());
-                    parameterNames.add(htp.getParamName());
-                    if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
-                        aliasToParam.put(htp.getParamAlias(), htp.getParamName());
-                        sb.append(" ** (alias=" + htp.getParamAlias() + ")");
-                    }
-                    sb.append("\n");
-                }
-                LOGGER.debug(sb.toString());
+            try { 
+               for (HeatTemplateParam htp : heatTemplate.getParameters()) {
+                       sb.append("param[" + cntr++ + "]=" + htp.getParamName());
+                       parameterNames.add(htp.getParamName());
+                       if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
+                               aliasToParam.put(htp.getParamAlias(), htp.getParamName());
+                               sb.append(" ** (alias=" + htp.getParamAlias() + ")");
+                       }
+                       sb.append("\n");
+               }
+               LOGGER.debug(sb.toString());
             } catch (Exception e) {
-                LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e);
+               LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e);
             }
-            // Step 1 - convert what we got as inputs (Map<String, String>) to a
+            // Step 1 - convert what we got as inputs (Map<String, String>) to a 
             // Map<String, Object> - where the object matches the param type identified in the template
             // This will also not copy over params that aren't identified in the template
             goldenInputs = heat.convertInputMap(inputs, heatTemplate);
@@ -1249,21 +1216,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam);
             this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack");
 
-            for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
-                LOGGER.debug ("Parameter:'" + parm.getParamName ()
-                              + "', isRequired="
-                              + parm.isRequired ()
-                              + ", alias="
-                              + parm.getParamAlias ());
+            for (HeatTemplateParam parm : heatTemplate.getParameters()) {
+                LOGGER.debug("Parameter:'" + parm.getParamName()
+                    + "', isRequired="
+                    + parm.isRequired()
+                    + ", alias="
+                    + parm.getParamAlias());
 
-                if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) {
+                if (parm.isRequired() && (goldenInputs == null || !goldenInputs.containsKey(parm.getParamName()))) {
                     // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object>
-                    LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment");
+                    LOGGER.debug("**Parameter " + parm.getParamName()
+                        + " is required and not in the inputs...check environment");
                     if (mhee != null && mhee.containsParameter(parm.getParamName())) {
-                        LOGGER.debug ("Required parameter " + parm.getParamName ()
-                                      + " appears to be in environment - do not count as missing");
+                        LOGGER.debug("Required parameter " + parm.getParamName()
+                            + " appears to be in environment - do not count as missing");
                     } else {
-                        LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
+                        LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
                         if (missingParams == null) {
                             missingParams = new StringBuilder(parm.getParamName());
                         } else {
@@ -1271,36 +1239,38 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                         }
                     }
                 }
-                paramList.add (parm.getParamName ());
+                paramList.add(parm.getParamName());
             }
             if (missingParams != null) {
                 if (checkRequiredParameters) {
                     // Problem - missing one or more required parameters
                     String error = "Create VFModule: Missing Required inputs: " + missingParams;
-                    LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
-                    throw new VnfException (error, MsoExceptionCategory.USERDATA);
+                    LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "",
+                        MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
+                    LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+                        error);
+                    throw new VnfException(error, MsoExceptionCategory.USERDATA);
                 } else {
-                    LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
+                    LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
                 }
             } else {
-                LOGGER.debug ("No missing parameters found - ok to proceed");
+                LOGGER.debug("No missing parameters found - ok to proceed");
             }
-            // We can now remove the recreating of the ENV with only legit params - that check is done for us,
+            // We can now remove the recreating of the ENV with only legit params - that check is done for us, 
             // and it causes problems with json that has arrays
             String newEnvironmentString = null;
             if (mhee != null) {
-                newEnvironmentString = mhee.getRawEntry();
+                newEnvironmentString = mhee.getRawEntry().toString();
             }
-
+            
             // "Fix" the template if it has CR/LF (getting this from Oracle)
-            String template = heatTemplate.getHeatTemplate ();
-            template = template.replaceAll ("\r\n", "\n");
+            String template = heatTemplate.getHeatTemplate();
+            template = template.replaceAll("\r\n", "\n");
 
             // Have the tenant. Now deploy the stack itself
             // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
             // because we already checked for those.
-            long createStackStarttime = System.currentTimeMillis ();
+            long createStackStarttime = System.currentTimeMillis();
             try {
                 // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true,
                 // heatTemplate.getTimeoutMinutes());
@@ -1310,48 +1280,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                 if (heat != null) {
                     LOGGER.debug("heat is not null!!");
                 }
-                    heatStack = heat.createStack (cloudSiteId,
-                                              tenantId,
-                                              vfModuleName,
-                                              template,
-                        goldenInputs,
-                                              true,
-                                              heatTemplate.getTimeoutMinutes (),
-                                              newEnvironmentString,
-                                              nestedTemplatesChecked,
-                                              heatFilesObjects,
-                                              backout.booleanValue());
-                LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName);
+                heatStack = heat.createStack(cloudSiteId,
+                    tenantId,
+                    vfModuleName,
+                    template,
+                    goldenInputs,
+                    true,
+                    heatTemplate.getTimeoutMinutes(),
+                    newEnvironmentString,
+                    nestedTemplatesChecked,
+                    heatFilesObjects,
+                    backout.booleanValue());
+                LOGGER
+                    .recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+                        "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName);
             } catch (MsoException me) {
-                me.addContext ("CreateVFModule");
+                me.addContext("CreateVFModule");
                 String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
-                LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
-                LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "MsoException - createStack", me);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
+                LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
+                    MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
+                LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+                    MsoLogger.ErrorCode.DataError, "MsoException - createStack", me);
+                LOGGER
+                    .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+                        error);
+                throw new VnfException(me);
             } catch (NullPointerException npe) {
                 String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe;
-                LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
-                LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+                LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
+                    MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
+                LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+                    MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe);
+                LOGGER
+                    .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+                        error);
                 LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack");
                 //npe.addContext ("CreateVNF");
-                throw new VnfException ("NullPointerException during heat.createStack");
+                throw new VnfException("NullPointerException during heat.createStack");
             } catch (Exception e) {
-                LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName);
-                LOGGER.debug("unhandled exception at heat.createStack",e);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack");
+                LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
+                    MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack",
+                    "OpenStack", "CreateStack", vfModuleName);
+                LOGGER.debug("unhandled exception at heat.createStack", e);
+                LOGGER
+                    .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+                        "Exception while creating stack with OpenStack");
                 throw new VnfException("Exception during heat.createStack! " + e.getMessage());
             }
         } catch (Exception e) {
-            LOGGER.debug("unhandled exception in create VF",e);
+            LOGGER.debug("unhandled exception in create VF", e);
             throw new VnfException("Exception during create VF " + e.getMessage());
-
-        } finally {
-            // Make sure DB session is closed
-            db.close ();
         }
 
+        // Make sure DB session is closed
+
         // Reach this point if createStack is successful.
         // Populate remaining rollback info and response parameters.
         vfRollback.setVnfId (heatStack.getCanonicalName ());
@@ -1372,7 +1354,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                            MsoRequest msoRequest,
                            Holder <Map <String, String>> outputs) throws VnfException {
         MsoLogger.setLogContext (msoRequest);
-        MsoLogger.setServiceName ("DeleteVf");
+       MsoLogger.setServiceName ("DeleteVf");
         LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
         // Will capture execution time for metrics
         long startTime = System.currentTimeMillis ();
@@ -1442,19 +1424,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
         MsoLogger.setServiceName (serviceName);
 
-        StringBuilder sbInit = new StringBuilder();
-        sbInit.append("updateVfModule: \n");
-        sbInit.append("cloudSiteId=").append(cloudSiteId).append("\n");
-        sbInit.append("tenantId=").append(tenantId).append("\n");
-        sbInit.append("vnfType=").append(vnfType).append("\n");
-        sbInit.append("vnfVersion=").append(vnfVersion).append("\n");
-        sbInit.append("vnfName=").append(vnfName).append("\n");
-        sbInit.append("requestType=").append(requestType).append("\n");
-        sbInit.append("volumeGroupHeatStackId=").append(volumeGroupHeatStackId).append("\n");
-        sbInit.append("baseVfHeatStackId=").append(baseVfHeatStackId).append("\n");
-        sbInit.append("vfModuleStackId=").append(vfModuleStackId).append("\n");
-        sbInit.append("modelCustomizationUuid=").append(modelCustomizationUuid).append("\n");
-        LOGGER.debug(sbInit.toString());
+        String strInit = "updateVfModule: cloudSiteId=" + cloudSiteId +
+            ",tenantId=" + tenantId +
+            ",vnfType=" + vnfType +
+            ",vnfVersion=" + vnfVersion +
+            ",vnfName=" + vnfName +
+            ",requestType=" + requestType +
+            ",volumeGroupHeatStackId=" + volumeGroupHeatStackId +
+            ",baseVfHeatStackId=" + baseVfHeatStackId +
+            ",vfModuleStackId=" + vfModuleStackId +
+            ",modelCustomizationUuid=" + modelCustomizationUuid;
+        LOGGER.debug(strInit);
 
         String mcu = modelCustomizationUuid;
         boolean useMCUuid = false;
@@ -1469,39 +1449,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             }
         }
 
-        String requestTypeString = "";
+       String requestTypeString = "";
         if (requestType != null && !"".equals(requestType)) {
-            requestTypeString = requestType;
+               requestTypeString = requestType;
         }
         String nestedStackId = null;
         if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
-            if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
-                nestedStackId = volumeGroupHeatStackId;
-            }
+               if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
+                       nestedStackId = volumeGroupHeatStackId;
+               }
         }
         String nestedBaseStackId = null;
         if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
-            if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
-                nestedBaseStackId = baseVfHeatStackId;
-            }
+               if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
+                       nestedBaseStackId = baseVfHeatStackId;
+               }
         }
 
         if (inputs == null) {
-            // Create an empty set of inputs
-            inputs = new HashMap<>();
-            LOGGER.debug("inputs == null - setting to empty");
+               // Create an empty set of inputs
+               inputs = new HashMap<>();
+               LOGGER.debug("inputs == null - setting to empty");
         } else {
-            this.sendMapToDebug(inputs);
+               this.sendMapToDebug(inputs);
         }
         boolean isBaseRequest = false;
         boolean isVolumeRequest = false;
         if (requestTypeString.startsWith("VOLUME")) {
-            isVolumeRequest = true;
+               isVolumeRequest = true;
         }
         if (vfModuleName == null || "".equals(vfModuleName.trim())) {
-            if (vfModuleStackId != null) {
-                vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
-            }
+               if (vfModuleStackId != null) {
+                       vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
+               }
         }
 
         LOGGER.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId);
@@ -1562,114 +1542,114 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
         long queryStackStarttime2 = System.currentTimeMillis ();
         Map<String, Object> nestedVolumeOutputs = null;
         if (nestedStackId != null) {
-            try {
-                LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
-                nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
+               try {
+                       LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
+                       nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
                 LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
-            } catch (MsoException me) {
-                // Failed to query the Stack due to an openstack exception.
-                // Convert to a generic VnfException
-                me.addContext ("UpdateVFModule");
-                String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+               } catch (MsoException me) {
+                   // Failed to query the Stack due to an openstack exception.
+                   // Convert to a generic VnfException
+                   me.addContext ("UpdateVFModule");
+                   String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
                 LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
-                LOGGER.debug("ERROR trying to query nested stack= " + error);
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+                       LOGGER.debug("ERROR trying to query nested stack= " + error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
-            }
-            if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
-                MsoLogger.setServiceName (serviceName);
-                String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
-                LOGGER.debug(error);
+                   throw new VnfException (me);
+               }
+               if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+                       MsoLogger.setServiceName (serviceName);
+                   String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
+                   LOGGER.debug(error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
-            } else {
-                LOGGER.debug("Found nested heat stack - copying values to inputs *later*");
-                nestedVolumeOutputs = nestedHeatStack.getOutputs();
-                //this.sendMapToDebug(inputs);
-                this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
-                //TODO
-                heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
-                //this.sendMapToDebug(inputs);
-            }
+                   throw new VnfException (error, MsoExceptionCategory.USERDATA);
+               } else {
+                       LOGGER.debug("Found nested heat stack - copying values to inputs *later*");
+                       nestedVolumeOutputs = nestedHeatStack.getOutputs();
+                       //this.sendMapToDebug(inputs);
+                       this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
+                       //TODO
+                       heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
+                       //this.sendMapToDebug(inputs);
+               }
         }
         // handle a nestedBaseStackId if sent - this is the stack ID of the base.
         StackInfo nestedBaseHeatStack = null;
         Map<String, Object> baseStackOutputs = null;
         if (nestedBaseStackId != null) {
             long queryStackStarttime3 = System.currentTimeMillis ();
-            try {
-                LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
-                nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
+               try {
+                       LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
+                       nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
                 LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
-            } catch (MsoException me) {
-                // Failed to query the Stack due to an openstack exception.
-                // Convert to a generic VnfException
-                me.addContext ("UpdateVfModule");
-                String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+               } catch (MsoException me) {
+                   // Failed to query the Stack due to an openstack exception.
+                   // Convert to a generic VnfException
+                   me.addContext ("UpdateVfModule");
+                   String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
                 LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
-                LOGGER.debug("ERROR trying to query nested base stack= " + error);
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+                       LOGGER.debug("ERROR trying to query nested base stack= " + error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
-            }
-            if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
-                MsoLogger.setServiceName (serviceName);
-                String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
-                LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
+                   throw new VnfException (me);
+               }
+               if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+                       MsoLogger.setServiceName (serviceName);
+                   String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"  ;
+                   LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
                 LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
-                LOGGER.debug(error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
-            } else {
-                LOGGER.debug("Found nested base heat stack - copying values to inputs *later*");
-                baseStackOutputs = nestedBaseHeatStack.getOutputs();
-                //this.sendMapToDebug(inputs);
-                this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
-                //TODO
-                heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
-                //this.sendMapToDebug(inputs);
-            }
+                   LOGGER.debug(error);
+                   throw new VnfException (error, MsoExceptionCategory.USERDATA);
+               } else {
+                       LOGGER.debug("Found nested base heat stack - copying values to inputs *later*");
+                       baseStackOutputs = nestedBaseHeatStack.getOutputs();
+                       //this.sendMapToDebug(inputs);
+                       this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
+                       //TODO
+                       heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
+                       //this.sendMapToDebug(inputs);
+               }
         }
 
         // Ready to deploy the new VNF
 
         // Get a handle to the Catalog Database
-        CatalogDatabase db = CatalogDatabase.getInstance();
 
         // Make sure DB session is closed
-        try {
+        try (CatalogDatabase db = CatalogDatabase.getInstance()) {
             // Retrieve the VF definition
             VnfResource vnfResource = null;
-            VfModule vf = null;
-            VfModuleCustomization vfmc = null;
+               VfModule vf = null;
+               VfModuleCustomization vfmc = null;
             if (useMCUuid) {
-                //vf = db.getVfModuleByModelCustomizationUuid(mcu);
-                vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
-                vf = vfmc != null ? vfmc.getVfModule() : null;
+                       //vf = db.getVfModuleByModelCustomizationUuid(mcu);
+                       vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
+                       vf = vfmc != null ? vfmc.getVfModule() : null;
                 if (vf == null) {
                     LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu);
                 }
-            } else {
-                LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
+               } else {
+                       LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
             }
-                if (vf == null) {
+            if (vf == null) {
                 String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu;
-                LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
+                LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "",
+                    MsoLogger.ErrorCode.DataError, error);
+                LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
+                throw new VnfException(error, MsoExceptionCategory.USERDATA);
             }
-            LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ());
+            LOGGER.debug("Got VF module definition from Catalog: " + vf.toString());
             if (vf.isBase()) {
-                isBaseRequest = true;
-                LOGGER.debug("This a BASE update request");
+               isBaseRequest = true;
+               LOGGER.debug("This a BASE update request");
             } else {
                 LOGGER.debug("This is *not* a BASE VF update request");
                 if (!isVolumeRequest && nestedBaseStackId == null) {
-                    LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
+                    LOGGER.debug("This is unexpected - no nestedBaseStackId with this non-base request");
                 }
             }
-
+            
             //1607 - Add version check
             // First - see if it's in the VnfResource record
             // if we have a vf Module - then we have to query to get the VnfResource record.
@@ -1678,7 +1658,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                 //vnfResource = db.getVnfResourceById(vnfResourceId);
                 vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
                 if (vnfResource == null) {
-                    LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+                    LOGGER
+                        .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
                 }
             }
             String minVersionVnf = null;
@@ -1688,50 +1669,57 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     minVersionVnf = vnfResource.getAicVersionMin();
                     maxVersionVnf = vnfResource.getAicVersionMax();
                 } catch (Exception e) {
-                    LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+                    LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
                     minVersionVnf = null;
                     maxVersionVnf = null;
-                    }
+                }
                 if (minVersionVnf != null && "".equals(minVersionVnf)) {
                     minVersionVnf = null;
                 }
                 if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
                     maxVersionVnf = null;
-                    }
                 }
+            }
             if (minVersionVnf != null && maxVersionVnf != null) {
                 MavenLikeVersioning aicV = new MavenLikeVersioning();
                 //String aicVersion = "";
                 if (this.cloudConfig == null) {
                     this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
-            }
+                }
                 // double check
                 if (this.cloudConfig != null) {
                     Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
                     if (cloudSiteOpt.isPresent()) {
                         aicV.setVersion(cloudSiteOpt.get().getAic_version());
                         if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min
-                                && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max
-                            LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version());
+                            && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV
+                            .isMoreRecentThan(maxVersionVnf)))) { //aic <= max
+                            LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf
+                                + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId()
+                                + " with AIC_Version:" + cloudSiteOpt.get().getAic_version());
                         } else {
                             // ERROR
-                            String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
-                            LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
+                            String error =
+                                "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf
+                                    + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get()
+                                    .getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
+                            LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
+                                MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
                             LOGGER.debug(error);
                             throw new VnfException(error, MsoExceptionCategory.USERDATA);
                         }
                     } // let this error out downstream to avoid introducing uncertainty at this stage
                 } else {
-                    LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
+                                       LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
                 }
 
-            } else {
-                LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked.");
+                       } else {
+                               LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked.");
             }
-            // End Version check 1607
-
-            String heatTemplateArtifactUuid = null;
-            String heatEnvironmentArtifactUuid = null;
+                       // End Version check 1607
+            
+                       String heatTemplateArtifactUuid = null;
+                       String heatEnvironmentArtifactUuid = null;
 
             HeatTemplate heatTemplate = null;
             if (isVolumeRequest) {
@@ -1742,11 +1730,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                 heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
             }
             if (heatTemplateArtifactUuid == null) {
-                String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString;
-                LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                String error =
+                    "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType="
+                        + requestTypeString;
+                LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "",
+                    MsoLogger.ErrorCode.DataError, error);
+                LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+                    error);
                 alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
-                        MsoAlarmLogger.CRITICAL, error);
+                    MsoAlarmLogger.CRITICAL, error);
                 throw new VnfException(error, MsoExceptionCategory.INTERNAL);
             } else {
                 heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
@@ -1754,126 +1746,137 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
 
             if (heatTemplate == null) {
                 String error = "Update VNF: undefined Heat Template. VF="
-                        + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
+                    + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
                 LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
-                        "Heat Template ID",
-                        String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                    "Heat Template ID",
+                    String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
+                LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+                    error);
                 // Alarm on this error, configuration must be fixed
                 alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
-                        MsoAlarmLogger.CRITICAL, error);
+                    MsoAlarmLogger.CRITICAL, error);
 
-                throw new VnfException(error, MsoExceptionCategory.INTERNAL);
-            }
+                               throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+                       }
 
-            LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
+            LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
 
             // Add check for any Environment variable
             HeatEnvironment heatEnvironment = null;
             String heatEnvironmentString = null;
 
             if (heatEnvironmentArtifactUuid != null) {
-                LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
+                LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
                 heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
                 if (heatEnvironment == null) {
 
                     String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType
-                                   + ", Environment ID="
-                                   + heatEnvironmentArtifactUuid;
-                    LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                        + ", Environment ID="
+                        + heatEnvironmentArtifactUuid;
+                    LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
+                        String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError,
+                        error);
+                    LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+                        error);
                     // Alarm on this error, configuration must be fixed
-                    alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+                    alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
 
-                    throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+                    throw new VnfException(error, MsoExceptionCategory.INTERNAL);
                 } else {
-                    LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ());
-                    heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ());
-                    LOGGER.debug ("After parsing: " + heatEnvironmentString);
+                    LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
+                    heatEnvironmentString = heatEnvironment
+                        .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
+                    LOGGER.debug("After parsing: " + heatEnvironmentString);
                 }
             } else {
-                LOGGER.debug ("no environment parameter for this VFModuleType " + vfModuleType);
+                LOGGER.debug("no environment parameter for this VFModuleType " + vfModuleType);
             }
 
-
-            LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
-                          + heatTemplate.getArtifactUuid ());
-            Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ());
-            Map <String, Object> nestedTemplatesChecked = new HashMap <> ();
+            LOGGER.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
+                + heatTemplate.getArtifactUuid());
+            Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
+            Map<String, Object> nestedTemplatesChecked = new HashMap<>();
             if (nestedTemplates != null) {
                 // for debugging print them out
-                LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
-                for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+                LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
+                for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
                     String providerResourceFile = entry.getKey();
                     Object value = entry.getValue();
                     String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
                     String childTemplateBody = (String) value;
-                    nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
-                    LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
+                    nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
+                    LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
                 }
             } else {
-                LOGGER.debug ("No nested templates found - nothing to do here");
+                LOGGER.debug("No nested templates found - nothing to do here");
                 nestedTemplatesChecked = null;
             }
 
             // Also add the files: for any get_files associated with this VfModule
             // *if* there are any
-            LOGGER.debug ("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
-                          + vf.getModelUUID());
+            LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
+                + vf.getModelUUID());
 
-            Map <String, HeatFiles> heatFiles = null;
+            Map<String, HeatFiles> heatFiles = null;
 //            Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ());
-            Map <String, Object> heatFilesObjects = new HashMap <> ();
+            Map<String, Object> heatFilesObjects = new HashMap<>();
 
             // Add ability to turn on adding get_files with volume requests (by property).
             boolean addGetFilesOnVolumeReq = false;
             try {
-                String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
+                String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
+                    .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
                 if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
                     addGetFilesOnVolumeReq = true;
                     LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
                 }
             } catch (Exception e) {
-                LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
+                LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ
+                    + " - default to false", e);
             }
             if (!isVolumeRequest || addGetFilesOnVolumeReq) {
-                LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+                LOGGER.debug(
+                    "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
                         + vf.getModelUUID());
 
-                heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
+               heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
                 if (heatFiles != null) {
                     // add these to stack - to be done in createStack
                     // here, we will map them to Map<String, Object> from Map<String, HeatFiles>
                     // this will match the nested templates format
-                    LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:");
+                    LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
 
-                    for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) {
+                    for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
                         String heatFileName = entry.getKey();
                         HeatFiles value = entry.getValue();
                         if (heatFileName.startsWith("_ERROR|")) {
                             // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
-                            String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
-                            String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
+                            String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1);
+                            String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType
+                                + " at HEAT_FILES index=" + heatFileId;
                             LOGGER.debug(error);
-                            LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                            LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+                            LOGGER
+                                .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId,
+                                    vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
+                            LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+                                MsoLogger.ResponseCode.DataNotFound, error);
                             // Alarm on this error, configuration must be fixed
-                            alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-                            throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+                            alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+                            throw new VnfException(error, MsoExceptionCategory.INTERNAL);
                         }
-                        String heatFileBody = value.getFileBody ();
-                        LOGGER.debug (heatFileName + " -> " + heatFileBody);
-                        heatFilesObjects.put (heatFileName, heatFileBody);
+                        String heatFileBody = value.getFileBody();
+                        LOGGER.debug(heatFileName + " -> " + heatFileBody);
+                        heatFilesObjects.put(heatFileName, heatFileBody);
                     }
                 } else {
-                    LOGGER.debug ("No heat files found -nothing to do here");
+                    LOGGER.debug("No heat files found -nothing to do here");
                     heatFilesObjects = null;
                 }
             }
 
             // Check that required parameters have been supplied
             StringBuilder missingParams = null;
-            List <String> paramList = new ArrayList <> ();
+            List<String> paramList = new ArrayList<>();
 
             // New for 1510 - consult the PARAM_ALIAS field to see if we've been
             // supplied an alias. Only check if we don't find it initially.
@@ -1883,58 +1886,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
             boolean haveEnvironmentParameters = false;
             boolean checkRequiredParameters = true;
             try {
-                String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
-                                                     .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null);
-                if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
+                String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
+                    .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
+                if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
                     checkRequiredParameters = false;
-                    LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
-                                  + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
+                    LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
+                        + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
                 }
             } catch (Exception e) {
                 // No problem - default is true
-                LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
+                LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
             }
             // 1604 - Add enhanced environment & parameter checking
             // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
             // Part 2: only submit to openstack the parameters in the envt that are in the heat template
             // Note this also removes any comments
             MsoHeatEnvironmentEntry mhee = null;
-            if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) {
+            if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) {
                 LOGGER.debug("Enhanced environment checking enabled - 1604");
-                mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
+                StringBuilder sb = new StringBuilder(heatEnvironmentString);
+                //LOGGER.debug("About to create MHEE with " + sb);
+                mhee = new MsoHeatEnvironmentEntry(sb);
                 StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
                 for (HeatTemplateParam parm : heatTemplate.getParameters()) {
-                    sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
+                       sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
                 }
                 if (!mhee.isValid()) {
-                    sb2.append("Environment says it's not valid! " + mhee.getErrorString());
+                       sb2.append("Environment says it's not valid! " + mhee.getErrorString());
                 } else {
-                    sb2.append("\nEnvironment:");
+                       sb2.append("\nEnvironment:");
                     sb2.append(mhee);
                 }
                 LOGGER.debug(sb2.toString());
             } else {
-                LOGGER.debug("NO ENVIRONMENT for this entry");
+               LOGGER.debug("NO ENVIRONMENT for this entry");
             }
 
             // New for 1607 - support params of json type
             HashMap<String, JsonNode> jsonParams = new HashMap<>();
             boolean hasJson = false;
 
-            for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
-                LOGGER.debug ("Parameter:'" + parm.getParamName ()
-                              + "', isRequired="
-                              + parm.isRequired ()
-                              + ", alias="
-                              + parm.getParamAlias ());
+            for (HeatTemplateParam parm : heatTemplate.getParameters()) {
+                LOGGER.debug("Parameter:'" + parm.getParamName()
+                    + "', isRequired="
+                    + parm.isRequired()
+                    + ", alias="
+                    + parm.getParamAlias());
                 // handle json
                 String parameterType = parm.getParamType();
                 if (parameterType == null || "".equals(parameterType.trim())) {
-                    parameterType = "String";
+                       parameterType = "String";
                 }
                 JsonNode jsonNode = null;
                 if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
-                    if (inputs.containsKey(parm.getParamName()) ) {
+                    if (inputs.containsKey(parm.getParamName())) {
                         hasJson = true;
                         String jsonString = null;
                         try {
@@ -1944,12 +1949,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                             //TODO - what to do here?
                             //for now - send the error to debug, but just leave it as a String
                             String errorMessage = jpe.getMessage();
-                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
+                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe);
                             hasJson = false;
                             jsonNode = null;
                         } catch (Exception e) {
                             // or here?
-                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
+                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
                             hasJson = false;
                             jsonNode = null;
                         }
@@ -1959,56 +1964,55 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     } else if (inputs.containsKey(parm.getParamAlias())) {
                         hasJson = true;
                         String jsonString = null;
-                           try {
+                        try {
                             jsonString = inputs.get(parm.getParamAlias());
                             jsonNode = new ObjectMapper().readTree(jsonString);
                         } catch (JsonParseException jpe) {
                             //TODO - what to do here?
                             //for now - send the error to debug, but just leave it as a String
                             String errorMessage = jpe.getMessage();
-                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
+                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe);
                             hasJson = false;
                             jsonNode = null;
                         } catch (Exception e) {
                             // or here?
-                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
+                            LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
                             hasJson = false;
                             jsonNode = null;
                         }
-                           if (jsonNode != null) {
-                               // Notice here - we add it to the jsonParams hashMap with the actual name -
-                               // then manipulate the inputs so when we check for aliases below - it will not
-                               // get flagged.
-                               jsonParams.put(parm.getParamName(), jsonNode);
-                               inputs.remove(parm.getParamAlias());
-                               inputs.put(parm.getParamName(), jsonString);
-                           }
+                        if (jsonNode != null) {
+                            // Notice here - we add it to the jsonParams hashMap with the actual name -
+                            // then manipulate the inputs so when we check for aliases below - it will not
+                            // get flagged.
+                            jsonParams.put(parm.getParamName(), jsonNode);
+                            inputs.remove(parm.getParamAlias());
+                            inputs.put(parm.getParamName(), jsonString);
+                        }
                     } //TODO add a check for the parameter in the env file
                 }
 
-                if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) {
-                    if (inputs.containsKey (parm.getParamAlias ())) {
+                if (parm.isRequired() && (inputs == null || !inputs.containsKey(parm.getParamName()))) {
+                    if (inputs.containsKey(parm.getParamAlias())) {
                         // They've submitted using an alias name. Remove that from inputs, and add back using real name.
-                        String realParamName = parm.getParamName ();
-                        String alias = parm.getParamAlias ();
-                        String value = inputs.get (alias);
-                        LOGGER.debug ("*Found an Alias: paramName=" + realParamName
-                                      + ",alias="
-                                      + alias
-                                      + ",value="
-                                      + value);
-                        inputs.remove (alias);
-                        inputs.put (realParamName, value);
-                        LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName);
+                        String realParamName = parm.getParamName();
+                        String alias = parm.getParamAlias();
+                        String value = inputs.get(alias);
+                        LOGGER.debug("*Found an Alias: paramName=" + realParamName
+                            + ",alias="
+                            + alias
+                            + ",value="
+                            + value);
+                        inputs.remove(alias);
+                        inputs.put(realParamName, value);
+                        LOGGER.debug(alias + " entry removed from inputs, added back using " + realParamName);
                     }
                     // enhanced - check if it's in the Environment (note: that method
                     else if (mhee != null && mhee.containsParameter(parm.getParamName())) {
 
-                        LOGGER.debug ("Required parameter " + parm.getParamName ()
-                                      + " appears to be in environment - do not count as missing");
-                    }
-                    else {
-                        LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
+                        LOGGER.debug("Required parameter " + parm.getParamName()
+                            + " appears to be in environment - do not count as missing");
+                    } else {
+                        LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
                         if (missingParams == null) {
                             missingParams = new StringBuilder(parm.getParamName());
                         } else {
@@ -2016,103 +2020,111 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                         }
                     }
                 }
-                paramList.add (parm.getParamName ());
+                paramList.add(parm.getParamName());
             }
             if (missingParams != null) {
                 // Problem - missing one or more required parameters
                 if (checkRequiredParameters) {
-                String error = "Update VNF: Missing Required inputs: " + missingParams;
-                LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
-                    LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
-                throw new VnfException (error, MsoExceptionCategory.USERDATA);
+                    String error = "Update VNF: Missing Required inputs: " + missingParams;
+                    LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "",
+                        MsoLogger.ErrorCode.DataError, error);
+                    LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+                        error);
+                    throw new VnfException(error, MsoExceptionCategory.USERDATA);
                 } else {
-                    LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
+                    LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
                 }
             } else {
-                LOGGER.debug ("No missing parameters found - ok to proceed");
+                LOGGER.debug("No missing parameters found - ok to proceed");
             }
 
             // Just submit the envt entry as received from the database
             String newEnvironmentString = null;
             if (mhee != null) {
-                newEnvironmentString = mhee.getRawEntry();
+                newEnvironmentString = mhee.getRawEntry().toString();
             }
 
             // Remove any extraneous parameters (don't throw an error)
             if (inputs != null) {
-                List <String> extraParams = new ArrayList <> ();
-                extraParams.addAll (inputs.keySet ());
+                List<String> extraParams = new ArrayList<>();
+                extraParams.addAll(inputs.keySet());
                 // This is not a valid parameter for this template
-                extraParams.removeAll (paramList);
-                if (!extraParams.isEmpty ()) {
-                    LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params");
-                    inputs.keySet ().removeAll (extraParams);
+                extraParams.removeAll(paramList);
+                if (!extraParams.isEmpty()) {
+                    LOGGER.warn(MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "",
+                        MsoLogger.ErrorCode.DataError, "Extra params");
+                    inputs.keySet().removeAll(extraParams);
                 }
             }
             // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json
             Map<String, Object> inputsTwo = null;
             if (hasJson && jsonParams.size() > 0) {
-                inputsTwo = new HashMap<>();
-                for (Map.Entry<String, String> entry : inputs.entrySet()) {
-                    String keyParamName = entry.getKey();
-                    String value = entry.getValue();
-                    if (jsonParams.containsKey(keyParamName)) {
-                        inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
-                    } else {
-                        inputsTwo.put(keyParamName, value);
-                    }
-                }
+               inputsTwo = new HashMap<>();
+               for (Map.Entry<String, String> entry : inputs.entrySet()) {
+                       String keyParamName = entry.getKey();
+                       String value = entry.getValue();
+                       if (jsonParams.containsKey(keyParamName)) {
+                               inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
+                       } else {
+                               inputsTwo.put(keyParamName, value);
+                       }
+               }
             }
 
             // "Fix" the template if it has CR/LF (getting this from Oracle)
-            String template = heatTemplate.getHeatTemplate ();
-            template = template.replaceAll ("\r\n", "\n");
+            String template = heatTemplate.getHeatTemplate();
+            template = template.replaceAll("\r\n", "\n");
 
             // Have the tenant. Now deploy the stack itself
             // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
             // because we already checked for those.
-            long updateStackStarttime = System.currentTimeMillis ();
+            long updateStackStarttime = System.currentTimeMillis();
             try {
                 if (!hasJson) {
-                    heatStack = heatU.updateStack (cloudSiteId,
-                                               tenantId,
-                                               vfModuleName,
-                                               template,
-                                               copyStringInputs (inputs),
-                                               true,
-                                               heatTemplate.getTimeoutMinutes (),
-                                               newEnvironmentString,
-                                               //heatEnvironmentString,
-                                               nestedTemplatesChecked,
-                                               heatFilesObjects);
-                    LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
+                    heatStack = heatU.updateStack(cloudSiteId,
+                        tenantId,
+                        vfModuleName,
+                        template,
+                        copyStringInputs(inputs),
+                        true,
+                        heatTemplate.getTimeoutMinutes(),
+                        newEnvironmentString,
+                        //heatEnvironmentString,
+                        nestedTemplatesChecked,
+                        heatFilesObjects);
+                    LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+                        MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack",
+                        "UpdateStack", null);
                 } else {
-                    heatStack = heatU.updateStack (cloudSiteId,
-                                               tenantId,
-                                               vfModuleName,
-                                               template,
-                                               inputsTwo,
-                                               true,
-                                               heatTemplate.getTimeoutMinutes (),
-                                               newEnvironmentString,
-                                               //heatEnvironmentString,
-                                               nestedTemplatesChecked,
-                                               heatFilesObjects);
-                    LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
-
-                }
+                    heatStack = heatU.updateStack(cloudSiteId,
+                        tenantId,
+                        vfModuleName,
+                        template,
+                        inputsTwo,
+                        true,
+                        heatTemplate.getTimeoutMinutes(),
+                        newEnvironmentString,
+                        //heatEnvironmentString,
+                        nestedTemplatesChecked,
+                        heatFilesObjects);
+                    LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+                        MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack",
+                        "UpdateStack", null);
+               }
             } catch (MsoException me) {
-                me.addContext ("UpdateVFModule");
+                me.addContext("UpdateVFModule");
                 String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
-                LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
-                LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
-                LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-                throw new VnfException (me);
+                LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.ERROR,
+                    MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
+                LOGGER.error(MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+                    MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+                LOGGER
+                    .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+                        error);
+                throw new VnfException(me);
             }
-        } finally {
-            // Make sure DB session is closed
-            db.close ();
         }
+        // Make sure DB session is closed
 
         // Reach this point if updateStack is successful.
         // Populate remaining rollback info and response parameters.
@@ -2125,21 +2137,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
     }
 
     private String getVfModuleNameFromModuleStackId(String vfModuleStackId) {
-        // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24"
-        // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack
-        if (vfModuleStackId == null)
-            return null;
-        int index = vfModuleStackId.lastIndexOf('/');
-        if (index <= 0)
-            return null;
-        String vfModuleName = null;
-        try {
-            vfModuleName = vfModuleStackId.substring(0, index);
-        } catch (Exception e) {
-            LOGGER.debug("Exception", e);
-            vfModuleName = null;
-        }
-        return vfModuleName;
+       // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24"
+       // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack
+       if (vfModuleStackId == null)
+               return null;
+       int index = vfModuleStackId.lastIndexOf('/');
+       if (index <= 0)
+               return null;
+       String vfModuleName = null;
+       try {
+               vfModuleName = vfModuleStackId.substring(0, index);
+       } catch (Exception e) {
+               LOGGER.debug("Exception", e);
+               vfModuleName = null;
+       }
+       return vfModuleName;
     }
 
 }