diff options
author | 2017-09-28 11:18:14 -0400 | |
---|---|---|
committer | 2017-09-28 11:27:51 -0400 | |
commit | 51d83152697da4f2ef2242471ee43f36e6b64300 (patch) | |
tree | 0e4bae37088950b1ab724d6f237cd5437c7f8fee /ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler | |
parent | 1b29c0944a7eba1c88cfd25c94e4dd7ed0f82dc7 (diff) |
Update license; improve coverage; add docs dir
Update licenses to match approved text; add where missing.
Improve code coverage with additional tests.
Use OParent.
Drop ecomp-portal-BE-common-test entirely; tests merged to ecomp-portal-BE-common.
All code from LF repo branch master_dev_amsterdam_1_3_0
Issue: PORTAL-42, PORTAL-50, PORTAL-90, PORTAL-96
Change-Id: I09d98bbf072411d2efed6fb34f378f7cc8d049ad
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler')
4 files changed, 269 insertions, 221 deletions
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java index 0a360500..8fd70a2b 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.openecomp.portalapp.uebhandler; @@ -27,7 +45,6 @@ import org.openecomp.portalapp.portal.service.AdminRolesService; import org.openecomp.portalapp.portal.service.FunctionalMenuService; import org.openecomp.portalapp.portal.service.SearchService; import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.onboarding.ueb.UebException; import org.openecomp.portalsdk.core.onboarding.ueb.UebManager; @@ -44,83 +61,76 @@ import com.google.gson.Gson; @org.springframework.context.annotation.Configuration @EnableAspectJAutoProxy @EPAuditLog -public class FunctionalMenuHandler { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuHandler.class); - +public class FunctionalMenuHandler { + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuHandler.class); + @Autowired - AdminRolesService adminRolesService; - + private AdminRolesService adminRolesService; + @Autowired - FunctionalMenuService functionalMenuService; - + private FunctionalMenuService functionalMenuService; + @Autowired - SearchService searchSvc; - - @Autowired - DataAccessService dataAccessService; + private SearchService searchSvc; @Async - public Boolean getFunctionalMenu(UebMsg requestMsg) - { + public Boolean getFunctionalMenu(UebMsg requestMsg) { UebMsg returnMsg = new UebMsg(); - - if (requestMsg == null) - { + + if (requestMsg == null) { logger.error(EELFLoggerDelegate.errorLogger, "handleMenuRequest received null message"); return false; - } - else if (requestMsg.getSourceTopicName() == null) - { - logger.error(EELFLoggerDelegate.errorLogger, "A source topic name is required and not found in this msg:" + requestMsg.toString()); + } else if (requestMsg.getSourceTopicName() == null) { + logger.error(EELFLoggerDelegate.errorLogger, + "A source topic name is required and not found in this msg:" + requestMsg.toString()); return false; - } - else if (requestMsg.getUserId() == null) - { - logger.debug(EELFLoggerDelegate.debugLogger, "Error getting functional menu. A userId is required and not found in this msg: " + requestMsg.toString()); - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response + } else if (requestMsg.getUserId() == null) { + logger.debug(EELFLoggerDelegate.debugLogger, + "Error getting functional menu. A userId is required and not found in this msg: " + + requestMsg.toString()); + returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response returnMsg.putPayload("Error: A userId is required. Call msg.putUserId() with an userId"); - } - else - { - logger.debug(EELFLoggerDelegate.debugLogger, "Getting functional menu for user = " + requestMsg.getUserId()); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "Getting functional menu for user = " + requestMsg.getUserId()); EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId()); - + List<FunctionalMenuItem> menuItems = null; - if (user == null) - { - logger.debug(EELFLoggerDelegate.debugLogger, "Error getting functional menu. userId not found in directory or is guest: " + requestMsg.toString()); - } - else if (adminRolesService.isSuperAdmin(user)) - { - logger.debug(EELFLoggerDelegate.debugLogger, "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()"); + if (user == null) { + logger.debug(EELFLoggerDelegate.debugLogger, + "Error getting functional menu. userId not found in directory or is guest: " + + requestMsg.toString()); + } else if (adminRolesService.isSuperAdmin(user)) { + logger.debug(EELFLoggerDelegate.debugLogger, + "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()"); menuItems = functionalMenuService.getFunctionalMenuItems(); - } - else - { - logger.debug(EELFLoggerDelegate.debugLogger, "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()"); menuItems = functionalMenuService.getFunctionalMenuItemsForUser(requestMsg.getUserId()); } - - if ( menuItems != null ) - { - String functionalMenuJsonString = new Gson().toJson(menuItems); + + if (menuItems != null) { + String functionalMenuJsonString = new Gson().toJson(menuItems); logger.debug(EELFLoggerDelegate.debugLogger, "returning functional menu : " + functionalMenuJsonString); - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response - returnMsg.putPayload(functionalMenuJsonString); + returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response + returnMsg.putPayload(functionalMenuJsonString); } else { - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response + returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response returnMsg.putPayload("Error: Not found for userId = " + requestMsg.getUserId()); } } - + try { - UebManager.getInstance().publishReplyEP(returnMsg, requestMsg.getSourceTopicName()); - } catch (UebException e) { - logger.error(EELFLoggerDelegate.errorLogger, "UebException occurred while responding to the Ueb message, Details:" + EcompPortalUtils.getStackTrace(e)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while responding to the Ueb message, Details:" + EcompPortalUtils.getStackTrace(e)); - } - - return true; + UebManager.getInstance().publishReplyEP(returnMsg, requestMsg.getSourceTopicName()); + } catch (UebException e) { + logger.error(EELFLoggerDelegate.errorLogger, + "getFunctionalMenu failed to publish reply", e); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "getFunctionalMenu failed", e); + } + + return true; } } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java index 2ba27549..db60c89f 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java @@ -1,38 +1,49 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.openecomp.portalapp.uebhandler; import java.util.concurrent.ConcurrentLinkedQueue; -import javax.annotation.PostConstruct; - -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; import org.openecomp.portalsdk.core.onboarding.ueb.UebManager; import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; // // Adding this class for the sole purpose of insuring that the MainUebHandler really @@ -43,33 +54,33 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; //@EnableAspectJAutoProxy //@EPMetricsLog public class InitUebHandler { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class); - - //@Autowired - MainUebHandler mainUebHandler; - - public InitUebHandler() { - + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class); + + // @Autowired + private MainUebHandler mainUebHandler; + + public InitUebHandler() { + } - - //@PostConstruct - public void initUeb() { - + + // @PostConstruct + public void initUeb() { try { String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE); if (enableListenerThread.equalsIgnoreCase("true")) { - ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>(); - UebManager.getInstance().initListener(inboxQueue); - mainUebHandler.runHandler(inboxQueue); - logger.info(EELFLoggerDelegate.errorLogger, "Returned from initiating mainUebHandler..."); - } - else { - logger.info(EELFLoggerDelegate.errorLogger, "Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file."); - } - } - catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - logger.info(EELFLoggerDelegate.errorLogger, "Not starting UEB listening thread because property could not be read " + PortalApiConstants.UEB_LISTENERS_ENABLE + e.getMessage()); + ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>(); + UebManager.getInstance().initListener(inboxQueue); + mainUebHandler.runHandler(inboxQueue); + logger.info(EELFLoggerDelegate.errorLogger, "Returned from initiating mainUebHandler..."); + } else { + logger.info(EELFLoggerDelegate.errorLogger, + "Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file."); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e); + logger.info(EELFLoggerDelegate.errorLogger, + "Not starting UEB listening thread because property could not be read " + + PortalApiConstants.UEB_LISTENERS_ENABLE + e.getMessage()); } } } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java index 5edf04b4..9e2bfff7 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.openecomp.portalapp.uebhandler; @@ -26,7 +44,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import org.openecomp.portalapp.portal.ueb.EPUebMsgTypes; import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg; import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes; @@ -37,7 +54,6 @@ import org.springframework.stereotype.Component; import com.att.eelf.configuration.Configuration; - //------------------------------------------------------------------------- // Listens for received UEB messages and handles the messages // @@ -46,69 +62,63 @@ import com.att.eelf.configuration.Configuration; // //------------------------------------------------------------------------- @Component("MainUebHandler") -public class MainUebHandler -{ +public class MainUebHandler { final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class); - - ConcurrentLinkedQueue<UebMsg> inboxQueue = null; - - @Autowired - FunctionalMenuHandler funcMenuHandler; - + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class); + + private ConcurrentLinkedQueue<UebMsg> inboxQueue = null; + + @Autowired + private FunctionalMenuHandler funcMenuHandler; + @Autowired - WidgetNotificationHandler widgetNotificationHandler; + private WidgetNotificationHandler widgetNotificationHandler; @Async - public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) - { + public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) { inboxQueue = queue; - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "==> MainUebHandler started"); - while (true) - { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "==> MainUebHandler started"); + while (true) { UebMsg msg = null; - while ((msg = inboxQueue.poll()) != null) - { - if ((msg.getMsgType() != null) && (!msg.getMsgType().equalsIgnoreCase(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK))) - { - // TODO: switch this back to debug - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); - logger.info(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); - MDC.put(EPSystemProperties.PARTNER_NAME, msg.getSourceTopicName()); - MDC.put(Configuration.MDC_SERVICE_NAME, msg.getMsgType().toString()); - switch(msg.getMsgType()) - { - case UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU: - { - funcMenuHandler.getFunctionalMenu(msg); - break; - } - case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: - { - widgetNotificationHandler.handleWidgetNotification(msg); - break; - } - default: - { - logger.info(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "Unknown UEB message type " + msg.toString()); - break; - } - } - } - } - - if (Thread.interrupted()) - { - logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting"); - break; - } - - try { - Thread.sleep(10); + while ((msg = inboxQueue.poll()) != null) { + if ((msg.getMsgType() != null) + && (!msg.getMsgType().equalsIgnoreCase(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK))) { + // TODO: switch this back to debug + logger.info(EELFLoggerDelegate.errorLogger, + dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); + logger.info(EELFLoggerDelegate.debugLogger, + dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); + MDC.put(EPSystemProperties.PARTNER_NAME, msg.getSourceTopicName()); + MDC.put(Configuration.MDC_SERVICE_NAME, msg.getMsgType().toString()); + switch (msg.getMsgType()) { + case UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU: { + funcMenuHandler.getFunctionalMenu(msg); + break; + } + case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: { + widgetNotificationHandler.handleWidgetNotification(msg); + break; + } + default: { + logger.info(EELFLoggerDelegate.debugLogger, + dateFormat.format(new Date()) + "Unknown UEB message type " + msg.toString()); + break; + } + } + } + } + + if (Thread.interrupted()) { + logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting"); + break; + } + + try { + Thread.sleep(10); } catch (InterruptedException e) { - logger.error(EELFLoggerDelegate.errorLogger, "UebMainHandler interrupted during sleep" + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "runHandler interrupted during sleep", e); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred during sleep" + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "runHandler failed", e); } } } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java index e6f3089c..1f964437 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.openecomp.portalapp.uebhandler; @@ -29,7 +47,6 @@ import org.openecomp.portalapp.portal.domain.EPUser; import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; import org.openecomp.portalapp.portal.service.EPAppService; import org.openecomp.portalapp.portal.service.SearchService; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.onboarding.ueb.UebException; import org.openecomp.portalsdk.core.onboarding.ueb.UebManager; @@ -44,48 +61,48 @@ import org.springframework.stereotype.Component; @EnableAspectJAutoProxy @EPMetricsLog public class WidgetNotificationHandler { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetNotificationHandler.class); - + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetNotificationHandler.class); + final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - + @Autowired EPAppService appSvc; - + @Autowired SearchService searchSvc; - - public WidgetNotificationHandler() - { + public WidgetNotificationHandler() { } - + @Async - public void handleWidgetNotification(UebMsg requestMsg) - { + public void handleWidgetNotification(UebMsg requestMsg) { if (requestMsg.getUserId() != null) { - logger.debug(EELFLoggerDelegate.debugLogger, "handleWidgetNotification: getting widgets/apps for user = " + requestMsg.getUserId()); + logger.debug(EELFLoggerDelegate.debugLogger, + "handleWidgetNotification: getting widgets/apps for user = " + requestMsg.getUserId()); EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId()); if (user != null && (appSvc != null)) { logger.debug(EELFLoggerDelegate.debugLogger, "Debug mytag: " + appSvc); - List<EPApp> apps = appSvc.getUserApps(user); - for (EPApp app : apps) { - if (app.getUebTopicName() != null) { - UebMsg widgetMsg = new UebMsg(); - widgetMsg.putSourceTopicName(app.getUebTopicName()); - logger.debug(EELFLoggerDelegate.debugLogger, "app.getUebTopicName was invoked"); - widgetMsg.putPayload(requestMsg.getPayload()); - try { - logger.debug(EELFLoggerDelegate.debugLogger, "Sending widget notification from " + requestMsg.getSourceTopicName() + " to " + app.getUebTopicName()); - UebManager.getInstance().publishEP(widgetMsg, app.getUebTopicName()); - } catch (UebException e) { - logger.error(EELFLoggerDelegate.errorLogger, "handleWidgetNotification publishEP exception" + EcompPortalUtils.getStackTrace(e)); - } - } - } + List<EPApp> apps = appSvc.getUserApps(user); + for (EPApp app : apps) { + if (app.getUebTopicName() != null) { + UebMsg widgetMsg = new UebMsg(); + widgetMsg.putSourceTopicName(app.getUebTopicName()); + logger.debug(EELFLoggerDelegate.debugLogger, "app.getUebTopicName was invoked"); + widgetMsg.putPayload(requestMsg.getPayload()); + try { + logger.debug(EELFLoggerDelegate.debugLogger, "Sending widget notification from " + + requestMsg.getSourceTopicName() + " to " + app.getUebTopicName()); + UebManager.getInstance().publishEP(widgetMsg, app.getUebTopicName()); + } catch (UebException e) { + logger.error(EELFLoggerDelegate.errorLogger, "handleWidgetNotification failed", e); + } + } + } } else { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "handleWidgetNotification: user " + - requestMsg.getUserId() + " not found" + " source = " + requestMsg.getSourceTopicName() + - ". This widget notification cannot be posted to other widgets"); + logger.error(EELFLoggerDelegate.errorLogger, + dateFormat.format(new Date()) + "handleWidgetNotification: user " + requestMsg.getUserId() + + " not found" + " source = " + requestMsg.getSourceTopicName() + + ". This widget notification cannot be posted to other widgets"); } } } |