[VID-3] Setting docker image tag
[vid.git] / vid / src / main / java / org / openecomp / portalapp / uebhandler / InitUebHandler.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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.portalapp.uebhandler;
22
23 import java.util.concurrent.ConcurrentLinkedQueue;
24
25 import javax.annotation.PostConstruct;
26
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.context.annotation.Configuration;
29
30 import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum;
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiConstants;
33 import org.openecomp.portalsdk.core.onboarding.crossapi.PortalApiProperties;
34 import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
35 import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
36 import org.openecomp.vid.conf.ExternalAppConfig;
37
38 //
39 // Adding this class for the sole purpose of insuring that the MainUebHandler really 
40 // honors @Async and kicks off a thread.  For more info google @Async and read about
41 // @Async only working if called from different class.
42 /**
43  * The Class InitUebHandler.
44  */
45 //
46 @Configuration
47 public class InitUebHandler {
48
49         /** The logger. */
50         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class);
51
52         
53         /** The main ueb handler. */
54         @Autowired
55         MainUebHandler mainUebHandler;
56         
57         /**
58          * Instantiates a new inits the ueb handler.
59          */
60         public InitUebHandler() {
61         
62         }
63         
64         /**
65          * Inits the ueb.
66          */
67         @PostConstruct
68         public void initUeb()   {
69                 
70                 try {
71                         String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE);
72                         if (enableListenerThread.equalsIgnoreCase("true")) {
73                 ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>();
74                     UebManager.getInstance().initListener(inboxQueue);
75                         mainUebHandler.runHandler(inboxQueue);
76                                 logger.info(EELFLoggerDelegate.debugLogger, ("Returned from initiating mainUebHandler..."));
77                 }
78                     else {
79                                 logger.info(EELFLoggerDelegate.debugLogger, ("Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file."));
80                     }
81                 }
82                 catch (Exception e) {
83                         logger.error(EELFLoggerDelegate.debugLogger, ("Not starting UEB listening thread because property could not be read " + PortalApiConstants.UEB_LISTENERS_ENABLE),AlarmSeverityEnum.MAJOR);
84                 }
85         
86         }
87 }
88