Update license files, sonar plugin and fix tests
[aai/aai-common.git] / aai-core / src / main / java / org / openecomp / aai / ingestModel / IngestModelListener.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
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.aai.ingestModel;
22
23 import java.util.ArrayList;
24
25 import javax.servlet.ServletContextEvent;
26 import javax.servlet.ServletContextListener;
27
28 import org.openecomp.aai.exceptions.AAIException;
29 import org.openecomp.aai.logging.ErrorLogHelper;
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32
33 /**
34  * The listener interface for receiving ingestModel events.
35  * The class that is interested in processing a ingestModel
36  * event implements this interface, and the object created
37  * with that class is registered with a component using the
38  * component's <code>addIngestModelListener<code> method. When
39  * the ingestModel event occurs, that object's appropriate
40  * method is invoked.
41  *
42  * @see IngestModelEvent
43  */
44 public class IngestModelListener implements ServletContextListener {
45         
46         private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(IngestModelListener.class);
47
48 /**
49  * Destroys context.
50  *
51  * @param arg0 the ServletContextEvent
52  */
53 //@Override
54         public void contextDestroyed(ServletContextEvent arg0) {
55                 IngestModelMoxyOxm m = new IngestModelMoxyOxm();
56                 m.cleanup();
57                 LOGGER.info("AAI Auth Listener contextDestroyed() complete.");
58         }
59
60 //Run this before web application is started
61         /**
62  * Initializaes the context.
63  *
64  * @param arg0 the ServletContextEvent
65  */
66 //@Override
67         public void contextInitialized(ServletContextEvent arg0)  {
68                 
69                 LOGGER.info("IngestModel starts initialization...");
70                 try { 
71                         ArrayList<String> apiVersions = new ArrayList<String>();
72                         apiVersions.add("v10");
73                         apiVersions.add("v9");
74                         apiVersions.add("v8");
75                         apiVersions.add("v7");
76                         apiVersions.add("v2");
77                         IngestModelMoxyOxm m = new IngestModelMoxyOxm();
78                         m.init(apiVersions);
79                 } catch (AAIException e) {
80                         ErrorLogHelper.logException(e);
81                 }
82         }
83 }