ActivitySpec - Correcting logger messages
[sdc.git] / common / onap-sdc-artifact-generator-lib / onap-sdc-artifact-generator-api / src / main / java / org / onap / sdc / generator / service / ArtifactGenerationService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.sdc.generator.service;
22
23 import org.onap.sdc.generator.data.GenerationData;
24 import org.onap.sdc.generator.data.GeneratorConstants;
25 import org.openecomp.sdc.logging.api.Logger;
26 import org.openecomp.sdc.logging.api.LoggerFactory;
27 import org.onap.sdc.generator.data.Artifact;
28 import org.onap.sdc.generator.logging.CategoryLogLevel;
29 import org.slf4j.MDC;
30
31 import java.util.List;
32 import java.util.Map;
33
34
35 /**
36  * Artifact Generation Service interface.
37  */
38 public interface ArtifactGenerationService {
39
40
41   /**
42    * Method to get artifact generation service implementation.
43    *
44    * @return Artifact generation implementation instance
45    */
46   public static ArtifactGenerationService lookup() {
47
48     Logger log = LoggerFactory.getLogger(ArtifactGenerationService.class.getName());
49     log.debug("Instantiating Artifact Generation Service");
50     try {
51       return ArtifactGenerationService.class.cast(
52           Class.forName("org.openecomp.sdc.generator.impl.ArtifactGenerationServiceImpl")
53               .newInstance());
54     } catch (Exception exception) {
55       MDC.put(GeneratorConstants.PARTNER_NAME, GeneratorConstants.GENERATOR_PARTNER_NAME);
56       MDC.put(GeneratorConstants.ERROR_CATEGORY, CategoryLogLevel.ERROR.name());
57       MDC.put(GeneratorConstants.ERROR_CODE, GeneratorConstants.GENERATOR_ERROR_CODE);
58       MDC.put(
59           GeneratorConstants.ERROR_DESCRIPTION, GeneratorConstants.GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
60       log.error(GeneratorConstants.GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED, exception);
61     }
62     log.debug(GeneratorConstants.GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
63     return null;
64   }
65
66   public GenerationData generateArtifact(List<Artifact> input, String overridingConfiguration,
67                                          Map<String, String> additionalParams);
68
69 }