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.onap.config.api.Configuration;
20 import org.onap.config.api.ConfigurationManager;
21 import org.openecomp.core.utilities.CommonMethods;
22 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
23 import org.openecomp.sdc.common.errors.CoreException;
24 import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
25 import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.OrchestrationTemplateFileExtensionErrorBuilder;
28 import java.util.Objects;
29 import java.util.concurrent.ConcurrentHashMap;
31 import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
32 import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
34 public class OrchestrationUploadFactory {
35 private static final Map<String, ImplementationConfiguration> FILE_HANLDERS;
36 private OrchestrationUploadFactory() {
40 Configuration config = ConfigurationManager.lookup();
41 FILE_HANLDERS = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
42 ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
46 public static OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(
47 final OnboardingTypesEnum onboardingType) {
48 final ImplementationConfiguration orchestrationTemplateFileHandler = FILE_HANLDERS.get(onboardingType.toString());
50 if(Objects.isNull(orchestrationTemplateFileHandler)){
51 throw new CoreException(new OrchestrationTemplateFileExtensionErrorBuilder
55 return CommonMethods.newInstance(orchestrationTemplateFileHandler.getImplementationClass(),
56 OrchestrationTemplateFileHandler.class);