2  * Copyright © 2016-2017 European Support Limited
 
   4  * Licensed under the Apache License, Version 2.0 (the "License");
 
   5  * you may not use this file except in compliance with the License.
 
   6  * You may obtain a copy of the License at
 
   8  *      http://www.apache.org/licenses/LICENSE-2.0
 
  10  * Unless required by applicable law or agreed to in writing, software
 
  11  * distributed under the License is distributed on an "AS IS" BASIS,
 
  12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  13  * See the License for the specific language governing permissions and
 
  14  * limitations under the License.
 
  17 package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
 
  19 import org.openecomp.config.api.Configuration;
 
  20 import org.openecomp.config.api.ConfigurationManager;
 
  21 import org.openecomp.core.utilities.CommonMethods;
 
  22 import org.openecomp.sdc.common.errors.CoreException;
 
  23 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
 
  24 import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.OrchestrationTemplateFileExtensionErrorBuilder;
 
  27 import java.util.Objects;
 
  28 import java.util.concurrent.ConcurrentHashMap;
 
  30 import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
 
  31 import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
 
  33 public class OrchestrationUploadFactory {
 
  34     private static final Map<String, ImplementationConfiguration> FILE_HANLDERS;
 
  35     private OrchestrationUploadFactory() {
 
  39         Configuration config = ConfigurationManager.lookup();
 
  40         FILE_HANLDERS = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
 
  41                 ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
 
  45     public static OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String fileSuffix) {
 
  46         String fileExtension = fileSuffix.toLowerCase();
 
  47         ImplementationConfiguration orchestrationTemplateFileHandler = FILE_HANLDERS.get(fileExtension);
 
  49         if(Objects.isNull(orchestrationTemplateFileHandler)){
 
  50             throw new CoreException(new OrchestrationTemplateFileExtensionErrorBuilder
 
  54         return  CommonMethods.newInstance(orchestrationTemplateFileHandler.getImplementationClass(),
 
  55                         OrchestrationTemplateFileHandler.class);