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