import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.openecomp.core.utilities.file.FileUtils;
 import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
 import org.openecomp.sdc.common.errors.Messages;
 import org.openecomp.sdc.logging.api.Logger;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Optional;
-import static org.openecomp.core.utilities.file.FileUtils.*;
+
+import static org.openecomp.core.utilities.file.FileUtils.getFileExtension;
+import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName;
 
 @Named
 @Service("orchestrationTemplateCandidate")
     UploadFileResponse uploadFileResponse = candidateManager
         .upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction
             .Write), fileToUpload.getObject(InputStream.class), user, getFileExtension(filename),
-            FileUtils.getNetworkPackageName(filename));
+            getNetworkPackageName(filename));
     UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto()
         .applyMapping(uploadFileResponse, UploadFileResponseDto.class);
 
 
 import java.util.concurrent.ConcurrentHashMap;
 
 import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_Impl_Key;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
 
 public class OrchestrationUploadFactory {
     private static Map<String, ImplementationConfiguration> fileHanlders;
     static {
         Configuration config = ConfigurationManager.lookup();
         fileHanlders = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
-                ORCHESTRATION_Impl_Key, ImplementationConfiguration.class));
+                ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
 
     }
 
 
 public class OrchestrationUtil {
 
     public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
-    public static final String ORCHESTRATION_Impl_Key = "orchestration_impl";
+    public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
 
 
     private static VendorSoftwareProductDao vendorSoftwareProductDao =
 
   static {
     Configuration config = ConfigurationManager.lookup();
     processImplMap = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
-        ConfigConstants.processImplKey, ImplementationConfiguration.class));
+        ConfigConstants.PROCESS_IMPL_KEY, ImplementationConfiguration.class));
 
   }
 
 
 package org.openecomp.sdc.vendorsoftwareproduct.types;
 
 public class ConfigConstants {
-  public static final String namespace = "Orchestration";
-  public static final String processImplKey =  "process_impl";
+  public static final String NAMESPACE = "Orchestration";
+  public static final String PROCESS_IMPL_KEY =  "process_impl";
 }
 
 package org.openecomp.core.impl;
 
+import org.apache.commons.collections4.MapUtils;
 import org.openecomp.sdc.logging.api.Logger;
 import org.openecomp.sdc.logging.api.LoggerFactory;
 import org.openecomp.sdc.tosca.datatypes.model.Import;
 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
 
 public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
     private static final Logger logger = LoggerFactory.getLogger(ServiceTemplate.class);
 
-    public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME = "GlobalSubstitutionServiceTemplate.yaml";
+    public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME =
+        "GlobalSubstitutionTypesServiceTemplate.yaml";
     public static final String TEMPLATE_NAME_PROPERTY = "template_name";
     public static final String DEFININTION_VERSION = "tosca_simple_yaml_1_0_0";
     public static final String HEAT_INDEX = "openecomp_heat_index";
+    private static final Map<String, ServiceTemplate> globalServiceTemplates =
+        GlobalTypesGenerator.getGlobalTypesServiceTemplate();
 
     public GlobalSubstitutionServiceTemplate() {
         super();
 
 
     public void appendNodes(Map<String, NodeType> nodes) {
-        getNode_types().putAll(nodes);
+        Optional<Map<String, NodeType>> nodeTypesToAdd =
+            removeExistingGlobalTypes(nodes);
+
+        nodeTypesToAdd.ifPresent(nodeTypes -> getNode_types().putAll(nodeTypes));
     }
 
     public void init()   {
     private void writeDefinitionSection() {
         setTosca_definitions_version(DEFININTION_VERSION);
     }
+
+    public Optional<Map<String, NodeType>> removeExistingGlobalTypes(Map<String, NodeType> nodes){
+        Map<String, NodeType> nodeTypesToAdd = new HashMap<>();
+        ServiceTemplate serviceTemplate = globalServiceTemplates.get("openecomp/nodes.yml");
+
+        if(Objects.isNull(serviceTemplate) || MapUtils.isEmpty(serviceTemplate.getNode_types())){
+            return Optional.of(nodes);
+        }
+
+        Map<String, NodeType> globalNodeTypes = serviceTemplate.getNode_types();
+        for(Map.Entry<String, NodeType> nodeTypeEntry : nodes.entrySet()){
+            if(!globalNodeTypes.containsKey(nodeTypeEntry.getKey())){
+                nodeTypesToAdd.put(nodeTypeEntry.getKey(), nodeTypeEntry.getValue());
+            }
+        }
+
+        return Optional.of(nodeTypesToAdd);
+    }
 }
 
     private void handleMetadataFile(Map<String, byte[]> csarFiles) {
         byte[] bytes = csarFiles.remove(metadataFile);
         if (bytes != null) {
-            csarFiles.put(metadataFile + ".old", bytes);
+            csarFiles.put(metadataFile + ".original", bytes);
         }
     }
 
         Collection<ServiceTemplate> globalServiceTemplates =
                 GlobalTypesGenerator.getGlobalTypesServiceTemplate().values();
         addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates);
-        serviceTemplates.put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
         toscaServiceModel.setEntryDefinitionServiceTemplate(mainStName);
         toscaServiceModel.setServiceTemplates(serviceTemplates);
-        externalFilesHandler.addFile(metadataFile + ".old", csarFiles.get(metadataFile + ".old"));
+        externalFilesHandler.addFile(metadataFile + ".original",
+            csarFiles.get(metadataFile + ".original"));
         toscaServiceModel.setArtifactFiles(externalFilesHandler);
+
+        if(MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())) {
+            serviceTemplates
+                .put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
+        }
     }
 
     private void addGlobalServiceTemplates(Collection<ServiceTemplate> globalServiceTemplates,
 
 
 
         assertNotNull(serviceTemplate.getNode_types());
-        assertEquals(7, serviceTemplate.getNode_types().size());
+        assertEquals(1, serviceTemplate.getNode_types().size());
         Set<String> keys = serviceTemplate.getNode_types().keySet();
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VDU"));
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.CP"));
         assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF.vCSCF"));
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.ImageFile"));
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.LocalStorage"));
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VNF"));
-        assertTrue(keys.contains("tosca.nodes.nfv.ext.zte.VL"));
     }