ActivitySpec - Correcting logger messages
[sdc.git] / common / onap-sdc-artifact-generator-lib / onap-sdc-artifact-generator-api / src / main / java / org / onap / sdc / generator / aai / AaiModelGenerator.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.aai;
22
23 import org.onap.sdc.generator.data.GeneratorConstants;
24 import org.onap.sdc.generator.aai.model.Resource;
25 import org.onap.sdc.generator.aai.model.Service;
26 import org.onap.sdc.generator.logging.CategoryLogLevel;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.slf4j.MDC;
30
31 import java.io.StringWriter;
32
33 public interface AaiModelGenerator {
34
35   /**
36    * Gets instance.
37    *
38    * @return the instance
39    */
40   public static AaiModelGenerator getInstance() {
41     Logger log = LoggerFactory.getLogger(AaiModelGenerator.class.getName());
42     try {
43       return AaiModelGenerator.class.cast(
44           Class.forName("org.onap.sdc.generator.aai.AaiModelGeneratorImpl").newInstance());
45     } catch (Exception exception) {
46       MDC.put(GeneratorConstants.PARTNER_NAME, GeneratorConstants.GENERATOR_PARTNER_NAME);
47       MDC.put(GeneratorConstants.ERROR_CATEGORY, CategoryLogLevel.ERROR.name());
48       MDC.put(GeneratorConstants.ERROR_CODE, GeneratorConstants.GENERATOR_ERROR_CODE);
49       MDC.put(
50           GeneratorConstants.ERROR_DESCRIPTION, GeneratorConstants.GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED);
51       StringWriter sw = new StringWriter();
52       log.error(sw.toString(), exception);
53     }
54     return null;
55   }
56
57   public String generateModelFor(Service service);
58
59   public String generateModelFor(Resource resource);
60
61
62 }