2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.uebhandler;
40 import java.text.DateFormat;
41 import java.text.SimpleDateFormat;
42 import java.util.Date;
43 import java.util.concurrent.ConcurrentLinkedQueue;
45 import org.onap.portalapp.portal.ueb.EPUebMsgTypes;
46 import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
47 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
48 import org.onap.portalsdk.core.onboarding.ueb.UebMsg;
49 import org.onap.portalsdk.core.onboarding.ueb.UebMsgTypes;
51 import org.springframework.beans.factory.annotation.Autowired;
52 import org.springframework.scheduling.annotation.Async;
53 import org.springframework.stereotype.Component;
55 import com.att.eelf.configuration.Configuration;
57 //-------------------------------------------------------------------------
58 // Listens for received UEB messages and handles the messages
60 // Note: To implement a synchronous reply call getMsgId on the request
61 // and putMsgId on the reply (echoing the request MsgId).
63 //-------------------------------------------------------------------------
64 @Component("MainUebHandler")
65 public class MainUebHandler {
66 final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
67 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class);
69 private ConcurrentLinkedQueue<UebMsg> inboxQueue = null;
72 private FunctionalMenuHandler funcMenuHandler;
75 private WidgetNotificationHandler widgetNotificationHandler;
78 public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) {
80 logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "==> MainUebHandler started");
83 while ((msg = inboxQueue.poll()) != null) {
84 if ((msg.getMsgType() != null)
85 && (!msg.getMsgType().equalsIgnoreCase(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK))) {
86 // TODO: switch this back to debug
87 logger.info(EELFLoggerDelegate.errorLogger,
88 dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString());
89 logger.info(EELFLoggerDelegate.debugLogger,
90 dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString());
91 MDC.put(EPCommonSystemProperties.PARTNER_NAME, msg.getSourceTopicName());
92 MDC.put(Configuration.MDC_SERVICE_NAME, msg.getMsgType().toString());
93 switch (msg.getMsgType()) {
94 case UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU: {
95 funcMenuHandler.getFunctionalMenu(msg);
98 case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: {
99 widgetNotificationHandler.handleWidgetNotification(msg);
103 logger.info(EELFLoggerDelegate.debugLogger,
104 dateFormat.format(new Date()) + "Unknown UEB message type " + msg.toString());
111 if (Thread.interrupted()) {
112 logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting");
118 } catch (InterruptedException e) {
119 logger.error(EELFLoggerDelegate.errorLogger, "runHandler interrupted", e);
120 } catch (Exception e) {
121 logger.error(EELFLoggerDelegate.errorLogger, "runHandler failed", e);