From 51d83152697da4f2ef2242471ee43f36e6b64300 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 28 Sep 2017 11:18:14 -0400 Subject: 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) --- .../portalapp/authentication/LoginStrategy.java | 40 +- .../authentication/OpenIdConnectLoginStrategy.java | 46 +- .../authentication/SimpleLoginStrategy.java | 47 +- .../portalapp/conf/ExternalAppConfig.java | 44 +- .../portalapp/conf/ExternalAppInitializer.java | 40 +- .../portalapp/conf/HibernateMappingLocations.java | 40 +- .../controller/ECOMPLogoutController.java | 40 +- .../portalapp/controller/LoginController.java | 509 ++++++++++----------- .../portalapp/controller/LoginService.java | 40 +- .../portalapp/controller/ONAPLoginController.java | 40 +- .../controller/ONAPWelcomeController.java | 40 +- .../controller/OpenCollaborationController.java | 40 +- .../portalapp/controller/PeerBroadcastSocket.java | 40 +- .../portal/controller/AppsOSController.java | 40 +- .../DashboardSearchResultController.java | 40 +- .../controller/ExternalAppsRestfulController.java | 40 +- .../portal/controller/PortalAdminController.java | 40 +- .../interceptor/SessionTimeoutInterceptor.java | 45 +- .../portal/logging/aop/EPEELFLoggerAspect.java | 42 +- .../service/ApplicationsRestClientService.java | 40 +- .../service/ApplicationsRestClientServiceImpl.java | 205 +++++---- .../portalapp/portal/service/AppsCacheService.java | 40 +- .../portal/service/AppsCacheServiceImple.java | 40 +- .../portalapp/portal/service/EPAppServiceImpl.java | 123 ++--- .../portalapp/portal/service/SearchService.java | 40 +- .../portal/service/SearchServiceImpl.java | 48 +- .../portal/service/TicketEventServiceImpl.java | 37 ++ .../portal/service/UserRolesServiceImpl.java | 40 +- .../portalapp/portal/service/UserService.java | 40 +- .../portalapp/portal/service/UserServiceImpl.java | 339 +++++++------- .../portalapp/portal/transport/OnboardingApp.java | 40 +- .../portalapp/portal/ueb/EPUebHelper.java | 239 +++++----- .../portalapp/portal/ueb/EPUebMsgTypes.java | 40 +- .../portalapp/portal/utils/EPSystemProperties.java | 40 +- .../org/openecomp/portalapp/scheduler/LogJob.java | 40 +- .../openecomp/portalapp/scheduler/LogRegistry.java | 40 +- .../openecomp/portalapp/scheduler/Register.java | 45 +- .../portalapp/scheduler/RegistryAdapter.java | 40 +- .../portalapp/scheduler/SessionMgtRegistry.java | 44 +- .../service/RemoteWebServiceCallServiceImpl.java | 46 +- .../uebhandler/FunctionalMenuHandler.java | 148 +++--- .../portalapp/uebhandler/InitUebHandler.java | 97 ++-- .../portalapp/uebhandler/MainUebHandler.java | 146 +++--- .../uebhandler/WidgetNotificationHandler.java | 99 ++-- .../portalapp/util/SessionCookieUtil.java | 45 +- .../OpenIdConnectLoginStrategyTest.java | 37 ++ .../SessionTimeoutInterceptorTest.java | 37 ++ .../authentication/SimpleLoginStrategyTest.java | 37 ++ .../AppsControllerExternalRequestOSTest.java | 119 ----- .../portal/controller/AppsOSControllerTest.java | 44 +- .../DashboardSearchResultControllerTest.java | 359 +++++++++++++++ .../controller/ECOMPLogoutControllerTest.java | 45 +- .../ExternalAppsRestfulControllerOSTest.java | 198 ++++++++ .../portal/controller/LoginControllerTest.java | 39 +- .../portal/controller/ONAPLoginControllerTest.java | 39 ++ .../controller/ONAPWelcomeControllerTest.java | 56 ++- .../controller/PortalAdminControllerOSTest.java | 117 ++++- .../portal/controller/SharedContextRestClient.java | 40 +- .../SharedContextRestControllerTest.java | 40 +- .../controller/SharedContextTestProperties.java | 40 +- .../portalapp/portal/framework/MockEPUser.java | 40 +- .../portal/framework/MockitoTestSuite.java | 40 +- .../portal/listener/HealthMonitorTest.java | 40 +- .../RemoteWebServiceCallServiceImplTest.java | 43 +- .../portal/service/SearchServiceImplTest.java | 37 ++ .../portal/service/UserServiceImplTest.java | 63 --- .../portal/utils/EcompPortalUtilsTest.java | 40 +- 67 files changed, 3338 insertions(+), 1606 deletions(-) delete mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java delete mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java (limited to 'ecomp-portal-BE-os/src') diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java index 19637515..6cdcb6ba 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.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.authentication; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java index 48f447b4..02cd340a 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.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.authentication; @@ -28,7 +46,6 @@ import org.mitre.openid.connect.model.UserInfo; import org.openecomp.portalapp.command.EPLoginBean; import org.openecomp.portalapp.portal.domain.EPUser; import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalapp.util.EPUserUtils; import org.openecomp.portalapp.util.SessionCookieUtil; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -39,7 +56,7 @@ import org.springframework.web.servlet.ModelAndView; public class OpenIdConnectLoginStrategy extends org.openecomp.portalsdk.core.auth.LoginStrategy implements org.openecomp.portalapp.authentication.LoginStrategy { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OpenIdConnectLoginStrategy.class); + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OpenIdConnectLoginStrategy.class); private static final String GLOBAL_LOCATION_KEY = "Location"; @@ -71,7 +88,6 @@ public class OpenIdConnectLoginStrategy extends org.openecomp.portalsdk.core.aut return true; } else { // in case authentication cookie is missing, send 401 UNAUTHORIZED to client and it will redirect to Logon - try { String authentication = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); String loginUrl = SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL); @@ -85,7 +101,7 @@ public class OpenIdConnectLoginStrategy extends org.openecomp.portalsdk.core.aut response.setHeader(GLOBAL_LOCATION_KEY, loginUrl); } } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in preHandle() while redirecting, Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "login failed", e); } } return false; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java index 0c3c4996..b7e16443 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.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.authentication; @@ -25,15 +43,12 @@ import javax.servlet.http.HttpServletResponse; import org.openecomp.portalapp.command.EPLoginBean; import org.openecomp.portalapp.portal.service.EPLoginService; import org.openecomp.portalapp.portal.service.EPRoleFunctionService; -import org.openecomp.portalapp.portal.service.EPRoleService; import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalapp.util.EPUserUtils; import org.openecomp.portalapp.util.SessionCookieUtil; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.menu.MenuProperties; import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; -import org.openecomp.portalsdk.core.onboarding.util.*; import org.openecomp.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; @@ -43,8 +58,6 @@ public class SimpleLoginStrategy extends org.openecomp.portalsdk.core.auth.Login @Autowired private EPLoginService loginService; - @Autowired - private EPRoleService roleService; @Autowired private EPRoleFunctionService ePRoleFunctionService; @@ -94,7 +107,7 @@ public class SimpleLoginStrategy extends org.openecomp.portalsdk.core.auth.Login response.setHeader(GLOBAL_LOCATION_KEY, loginUrl); //returnUrl + "/index.htm"); } } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in preHandle() while redirecting, Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "login failed", e); } } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java index 92d63742..7b44add9 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.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.conf; @@ -114,7 +132,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable { MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.toString()); MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); } } @@ -289,7 +307,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable { try { cronSiteVal = SystemProperties.getProperty(CRON_SITE_NAME); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "getScheduleName failed", e); logger.warn(EELFLoggerDelegate.errorLogger, "Cron site name not added in property file, using Default value"); } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java index 1c9f43df..121c4beb 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.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.conf; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java index 0ebf4e38..7f0e9569 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.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.conf; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java index b4e3bee9..10ae7b9d 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java index 33cc4dd7..ce6cc530 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.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.controller; @@ -37,19 +55,14 @@ import org.openecomp.portalapp.command.EPLoginBean; import org.openecomp.portalapp.portal.domain.SharedContext; import org.openecomp.portalapp.portal.service.EPLoginService; import org.openecomp.portalapp.portal.service.EPRoleFunctionService; -import org.openecomp.portalapp.portal.service.EPRoleService; import org.openecomp.portalapp.portal.service.SharedContextService; import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.service.EPProfileService; import org.openecomp.portalapp.util.EPUserUtils; import org.openecomp.portalapp.util.SessionCookieUtil; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.menu.MenuProperties; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -66,333 +79,307 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Controller @RequestMapping("/") -public class LoginController extends EPUnRestrictedBaseController implements LoginService{ - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginController.class); - +public class LoginController extends EPUnRestrictedBaseController implements LoginService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginController.class); + public static final String DEFAULT_SUCCESS_VIEW = "applicationsHome"; public static final String DEFAULT_FAILURE_VIEW = "login"; - public static final String ERROR_MESSAGE_KEY = "error"; + public static final String ERROR_MESSAGE_KEY = "error"; public static final String REDIRECT_URL = "redirectUrl"; - - @Autowired - EPProfileService service; + public static final String REDIRECT_COLON = "redirect:"; + @Autowired private EPLoginService loginService; @Autowired private SharedContextService sharedContextService; - - @Autowired - private EPRoleService roleService; - @Autowired private EPRoleFunctionService ePRoleFunctionService; - - String viewName = "login"; - private String welcomeView; - public String getWelcomeView() { - return welcomeView; - } + private String viewName = "login"; + + private String welcomeView; - public void setWelcomeView(String welcomeView) { - this.welcomeView = welcomeView; - } - - @RequestMapping(value = {"/login.htm" }, method = RequestMethod.GET) + @RequestMapping(value = { "/login.htm" }, method = RequestMethod.GET) public ModelAndView login(HttpServletRequest request) { Map model = new HashMap(); - String authentication = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); - String loginPage; - - if (authentication == null || authentication.equals("") || authentication.trim().equals("OIDC")) + if (authentication == null || "".equals(authentication) || "OICD".equals(authentication.trim())) loginPage = "openIdLogin"; else - loginPage = getViewName(); - - return new ModelAndView(loginPage,"model", model); + loginPage = getViewName(); + return new ModelAndView(loginPage, "model", model); } - + @SuppressWarnings("rawtypes") - @RequestMapping(value = {"/open_source/login" }, method = RequestMethod.POST) - public @ResponseBody String loginValidate(HttpServletRequest request, HttpServletResponse response) throws Exception{ - + @RequestMapping(value = { "/open_source/login" }, method = RequestMethod.POST) + @ResponseBody + public String loginValidate(HttpServletRequest request, HttpServletResponse response) throws Exception { + ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - - EPLoginBean commandBean = new EPLoginBean(); - String loginId = root.get("loginId").textValue(); - String password = root.get("password").textValue(); - commandBean.setLoginId(loginId); - commandBean.setLoginPwd(CipherUtil.encrypt(password)); - HashMap additionalParamsMap = new HashMap(); - StringBuilder sbAdditionalInfo = new StringBuilder(); - - commandBean = getLoginService().findUser(commandBean, (String)request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), - additionalParamsMap); - String fullURL = getFullURL(request); - if (commandBean.getUser() == null) { - String loginErrorMessage = (commandBean.getLoginErrorMessage() != null) ? commandBean.getLoginErrorMessage() - : "login.error.external.invalid"; - - logger.info(EELFLoggerDelegate.debugLogger, "loginId = " + loginId + " does not exist in the the DB."); - logger.info(EELFLoggerDelegate.errorLogger, "loginId = " + loginId + " does not exist in the the DB."); - sbAdditionalInfo.append(String.format("But the Login-Id: %s doesn't exist in the Database. Request-URL: %s", + + EPLoginBean commandBean = new EPLoginBean(); + String loginId = root.get("loginId").textValue(); + String password = root.get("password").textValue(); + commandBean.setLoginId(loginId); + commandBean.setLoginPwd(CipherUtil.encrypt(password)); + HashMap additionalParamsMap = new HashMap(); + StringBuilder sbAdditionalInfo = new StringBuilder(); + + commandBean = getLoginService().findUser(commandBean, + (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), additionalParamsMap); + String fullURL = getFullURL(request); + if (commandBean.getUser() == null) { + String loginErrorMessage = (commandBean.getLoginErrorMessage() != null) ? commandBean.getLoginErrorMessage() + : "login.error.external.invalid"; + logger.info(EELFLoggerDelegate.debugLogger, "loginId {} does not exist in the the DB.", loginId); + sbAdditionalInfo.append(String.format("But the Login-Id: %s doesn't exist in the Database. Request-URL: %s", loginId, fullURL)); return loginErrorMessage; - } - else { - // store the currently logged in user's information in the session - EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM),ePRoleFunctionService); - - try{ - logger.info(EELFLoggerDelegate.debugLogger, "******************* store user info into share context begins"); - String sessionId = request.getSession().getId(); - List existingSC = getSharedContextService().getSharedContexts(sessionId); - if(existingSC==null || existingSC.size()==0){ - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, commandBean.getUser().getFirstName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, commandBean.getUser().getLastName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, commandBean.getUser().getEmail()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, commandBean.getLoginId()); - } - - }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - logger.info(EELFLoggerDelegate.errorLogger, "failed the shared context adding process " + e.getMessage()); - logger.info(EELFLoggerDelegate.debugLogger, "********************** failed the shared context adding process " + e.getMessage()); - } - logger.info(EELFLoggerDelegate.debugLogger, "********************* PresetUp the EP service cookie and intial sessionManagement"); - - SessionCookieUtil.preSetUp(request, response); - SessionCookieUtil.setUpUserIdCookie(request, response, loginId); - - JSONObject j = new JSONObject("{success: success}"); - - return j.toString(); - - } - + } else { + // store the currently logged in user's information in the session + EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), + commandBean.getBusinessDirectMenu(), + SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService); + + try { + logger.info(EELFLoggerDelegate.debugLogger, "loginValidate: store user info into share context begins"); + String sessionId = request.getSession().getId(); + List existingSC = getSharedContextService().getSharedContexts(sessionId); + if (existingSC == null || existingSC.isEmpty()) { + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, + commandBean.getUser().getFirstName()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, + commandBean.getUser().getLastName()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, + commandBean.getUser().getEmail()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, + commandBean.getLoginId()); + } + + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, "loginValidate: failed the shared context adding process ", + e); + } + logger.info(EELFLoggerDelegate.debugLogger, + "loginValidate: PresetUp the EP service cookie and intial sessionManagement"); + + SessionCookieUtil.preSetUp(request, response); + SessionCookieUtil.setUpUserIdCookie(request, response, loginId); + + JSONObject j = new JSONObject("{success: success}"); + + return j.toString(); + } } - - /* Work around a bug in ecompsdkos version 1.1.0 which hard-codes this endpoint. */ - @RequestMapping(value = {"/process_csp" }, method = RequestMethod.GET) + + /* + * Work around a bug in ecompsdkos version 1.1.0 which hard-codes this endpoint. + */ + @RequestMapping(value = { "/process_csp" }, method = RequestMethod.GET) public ModelAndView processCsp(HttpServletRequest request, HttpServletResponse response) throws Exception { return processSingleSignOn(request, response); } - /* Remove this method after epsdk-app-common/.../SingleSignOnController.java is repaired. */ + /* + * Remove this method after epsdk-app-common/.../SingleSignOnController.java is + * repaired. + */ + + @RequestMapping(value = { "/processSingleSignOn" }, method = RequestMethod.GET) + public ModelAndView processSingleSignOn(HttpServletRequest request, HttpServletResponse response) throws Exception { - @RequestMapping(value = {"/processSingleSignOn" }, method = RequestMethod.GET) - public ModelAndView processSingleSignOn(HttpServletRequest request, HttpServletResponse response) throws Exception{ - - Map model = new HashMap(); + Map model = new HashMap(); HashMap additionalParamsMap = new HashMap(); EPLoginBean commandBean = new EPLoginBean(); MDC.put(MDC_KEY_REQUEST_ID, getRequestId(request)); - String orgUserId = ""; - //get userId from cookie - orgUserId = SessionCookieUtil.getUserIdFromCookie(request, response); - logger.info(EELFLoggerDelegate.debugLogger, "******************** process_singelSignOn process begins"); - logger.info(EELFLoggerDelegate.debugLogger, "******************* We get the orgUserId " + orgUserId); + // get userId from cookie + String orgUserId = SessionCookieUtil.getUserIdFromCookie(request, response); + logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: begins with orgUserId {}", orgUserId); StringBuilder sbAdditionalInfo = new StringBuilder(); - if ((orgUserId == null || orgUserId.length() == 0)) { + if (orgUserId == null || orgUserId.length() == 0) { model.put(ERROR_MESSAGE_KEY, SystemProperties.MESSAGE_KEY_LOGIN_ERROR_COOKIE_EMPTY); - if(request.getParameter("redirectUrl")!=null && request.getParameter("redirectUrl").length()!=0){ - return new ModelAndView("redirect:" + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" + request.getParameter("redirectUrl")); - }else{ - return new ModelAndView("redirect:" + DEFAULT_FAILURE_VIEW + ".htm"); + if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { + return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" + + request.getParameter(REDIRECT_URL)); + } else { + return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm"); } - } - else { - + } else { + StopWatch stopWatch = new StopWatch("LoginController.Login"); stopWatch.start(); - + try { - logger.info(EELFLoggerDelegate.metricsLogger, "Operation findUser is started to locate " + orgUserId + " in the database."); - logger.info(EELFLoggerDelegate.debugLogger, "Operation findUser is started to locate " + orgUserId + " in the database."); + logger.info(EELFLoggerDelegate.debugLogger, + "Operation findUser is started to locate user {} in the database.", orgUserId); commandBean.setLoginId(orgUserId); commandBean.setOrgUserId(orgUserId); - commandBean = getLoginService().findUser(commandBean, (String)request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), additionalParamsMap); - + commandBean = getLoginService().findUser(commandBean, + (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), + additionalParamsMap); + stopWatch.stop(); MDC.put(EPSystemProperties.MDC_TIMER, stopWatch.getTotalTimeMillis() + "ms"); - logger.info(EELFLoggerDelegate.metricsLogger, "Operation findUser is completed."); logger.info(EELFLoggerDelegate.debugLogger, "Operation findUser is completed."); - } catch(Exception e) { + } catch (Exception e) { stopWatch.stop(); MDC.put(EPSystemProperties.MDC_TIMER, stopWatch.getTotalTimeMillis() + "ms"); - logger.info(EELFLoggerDelegate.errorLogger, "Exception occurred while performing findUser " + orgUserId + ". Details: " + EcompPortalUtils.getStackTrace(e)); - logger.info(EELFLoggerDelegate.debugLogger, "Exception occurred while performing findUser " + orgUserId + ". Details: " + EcompPortalUtils.getStackTrace(e)); - logger.info(EELFLoggerDelegate.metricsLogger, "Operation findUser is failed."); + logger.info(EELFLoggerDelegate.errorLogger, "processSingleSignOn failed on user " + orgUserId, e); } finally { MDC.remove(EPSystemProperties.MDC_TIMER); } - + sbAdditionalInfo.append("Login attempt is succeeded. "); String fullURL = getFullURL(request); if (commandBean.getUser() == null) { - logger.info(EELFLoggerDelegate.debugLogger, "loginId = " + orgUserId + " does not exist in the the DB."); - logger.info(EELFLoggerDelegate.errorLogger, "loginId = " + orgUserId + " does not exist in the the DB."); - logger.info(EELFLoggerDelegate.debugLogger, "loginId = " + orgUserId + " does not exist in the the DB."); + logger.info(EELFLoggerDelegate.debugLogger, + "processSingleSignOn: loginId {} does not exist in the the DB.", orgUserId); - sbAdditionalInfo.append(String.format("But the Login-Id: %s doesn't exist in the Database. Created a Guest Session. Request-URL: %s", + sbAdditionalInfo.append(String.format( + "But the Login-Id: %s doesn't exist in the Database. Created a Guest Session. Request-URL: %s", orgUserId, fullURL)); - if(request.getParameter("redirectUrl")!=null && request.getParameter("redirectUrl").length()!=0){ - return new ModelAndView("redirect:" + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" + request.getParameter("redirectUrl")); - }else{ - return new ModelAndView("redirect:" + DEFAULT_FAILURE_VIEW + ".htm"); + if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { + return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" + + request.getParameter(REDIRECT_URL)); + } else { + return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm"); + } + } else { + + sbAdditionalInfo.append( + String.format("Login-Id: %s, Login-Method: %s, Request-URL: %s", orgUserId, "", fullURL)); + logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: now set up user session for {}", + orgUserId); + + EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), + commandBean.getBusinessDirectMenu(), + SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService); + logger.info(EELFLoggerDelegate.debugLogger, + "processSingleSignOn: now set up user session for {} finished", orgUserId); + + // Store user's information into share context + try { + logger.info(EELFLoggerDelegate.debugLogger, + "processSingleSignOn: store user info into share context begins"); + String sessionId = request.getSession().getId(); + List existingSC = getSharedContextService().getSharedContexts(sessionId); + if (existingSC == null || existingSC.isEmpty()) { + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, + commandBean.getUser().getFirstName()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, + commandBean.getUser().getLastName()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, + commandBean.getUser().getEmail()); + getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, + commandBean.getLoginId()); + } + } catch (Exception e) { + logger.info(EELFLoggerDelegate.errorLogger, + "processSingleSignOn: failed the shared context adding process", e); + } + + logger.info(EELFLoggerDelegate.debugLogger, + "processSingleSignOn: PresetUp the EP service cookie and intial sessionManagement"); + SessionCookieUtil.preSetUp(request, response); + SessionCookieUtil.setUpUserIdCookie(request, response, orgUserId); + logger.info(EELFLoggerDelegate.debugLogger, + "processSingleSignOn: PresetUp the EP service cookie and intial sessionManagement completed"); + logger.info(EELFLoggerDelegate.debugLogger, + commandBean.getUser().getOrgUserId() + " exists in the the system."); + + // get redirectUrl from URL parameter + if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { + String forwardUrl = URLDecoder.decode(request.getParameter(REDIRECT_URL), "UTF-8"); + // clean cookie + Cookie cookie2 = new Cookie(REDIRECT_URL, ""); + // ONAP does not use https + cookie2.setSecure(false); + cookie2.setMaxAge(0); + cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); + cookie2.setPath("/"); + response.addCookie(cookie2); + return new ModelAndView(REDIRECT_COLON + forwardUrl); + } + + // first check if redirectUrl exists or not + if (WebUtils.getCookie(request, REDIRECT_URL) != null) { + String forwardUrl = WebUtils.getCookie(request, REDIRECT_URL).getValue(); + // clean cookie + Cookie cookie2 = new Cookie(REDIRECT_URL, ""); + // ONAP does not use https + cookie2.setSecure(false); + cookie2.setMaxAge(0); + cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); + cookie2.setPath("/"); + response.addCookie(cookie2); + + return new ModelAndView(REDIRECT_COLON + forwardUrl); } - } - else { - - sbAdditionalInfo.append(String.format("Login-Id: %s, Login-Method: %s, Request-URL: %s", orgUserId, "", fullURL)); - logger.info(EELFLoggerDelegate.debugLogger, "*********************** now set up user session for " + orgUserId); - - EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM),ePRoleFunctionService); - logger.info(EELFLoggerDelegate.debugLogger, "*********************** now set up user session for " + orgUserId + " finished"); - - //Store user's information into share context - try{ - logger.info(EELFLoggerDelegate.debugLogger, "******************* store user info into share context begins"); - - String sessionId = request.getSession().getId(); - List existingSC = getSharedContextService().getSharedContexts(sessionId); - if(existingSC==null || existingSC.size()==0){ - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, commandBean.getUser().getFirstName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, commandBean.getUser().getLastName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, commandBean.getUser().getEmail()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, commandBean.getLoginId()); - } - - }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - logger.info(EELFLoggerDelegate.errorLogger, "failed the shared context adding process " + e.getMessage()); - logger.info(EELFLoggerDelegate.debugLogger, "********************** failed the shared context adding process " + e.getMessage()); - - } - - logger.info(EELFLoggerDelegate.debugLogger, "********************* PresetUp the EP service cookie and intial sessionManagement"); - - SessionCookieUtil.preSetUp(request, response); - SessionCookieUtil.setUpUserIdCookie(request, response, orgUserId); - logger.info(EELFLoggerDelegate.debugLogger, "********************* PresetUp the EP service cookie and intial sessionManagement completed"); - logger.info(EELFLoggerDelegate.errorLogger, commandBean.getUser().getOrgUserId() + " exists in the the system."); - logger.info(EELFLoggerDelegate.debugLogger, commandBean.getUser().getOrgUserId() + " exists in the the system."); - - String redirect = "redirectUrl"; - - //get redirectUrl from URL parameter - if(request.getParameter(redirect)!=null && request.getParameter(redirect).length()!=0){ - String forwardUrl = URLDecoder.decode(request.getParameter(redirect),"UTF-8"); - //clean cookie - Cookie cookie2 = new Cookie(redirect, ""); - cookie2.setMaxAge(0); - cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); - cookie2.setPath("/"); - response.addCookie(cookie2); - return new ModelAndView("redirect:" + forwardUrl); - } - - //first check if redirectUrl exists or not - if(WebUtils.getCookie(request, redirect)!=null){ - String forwardUrl = WebUtils.getCookie(request, redirect).getValue(); - //clean cookie - Cookie cookie2 = new Cookie(redirect, ""); - cookie2.setMaxAge(0); - cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); - cookie2.setPath("/"); - response.addCookie(cookie2); - - return new ModelAndView("redirect:" + forwardUrl); - } } } - + // if user has been authenticated, now take them to the welcome page. - //return new ModelAndView("redirect:" + DEFAULT_SUCCESS_VIEW + ".htm"); - logger.info(EELFLoggerDelegate.debugLogger, "********************** Now return to application home page"); - - return new ModelAndView("redirect:" + SystemProperties.getProperty(EPSystemProperties.FE_URL)); - - // - // Re-enable for BE/FE separation. For 1607, at last minute we decided to go out - // without BE/FE separation. - // - //return new ModelAndView("redirect:" + SystemProperties.getProperty(EPSystemProperties.FE_URL)); - + logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: Now return to application home page"); + return new ModelAndView(REDIRECT_COLON + SystemProperties.getProperty(EPSystemProperties.FE_URL)); } - - public String getFullURL(HttpServletRequest request) { + + private String getFullURL(HttpServletRequest request) { if (request != null) { - StringBuffer requestURL = request.getRequestURL(); + String requestURL = request.getRequestURL().toString(); String queryString = request.getQueryString(); - if (queryString == null) { - return requestURL.toString(); + return requestURL; } else { - return requestURL.append('?').append(queryString).toString(); + return requestURL + "?" + queryString; } } return ""; } - - public String getRequestId(HttpServletRequest request) { - Enumeration headerNames = request.getHeaderNames(); + private String getRequestId(HttpServletRequest request) { + Enumeration headerNames = request.getHeaderNames(); String requestId = ""; - try { - while (headerNames.hasMoreElements()) { - String headerName = (String) headerNames.nextElement(); - logger.debug(EELFLoggerDelegate.debugLogger, - "One header is " + headerName + " : " + request.getHeader(headerName)); - if (headerName.equalsIgnoreCase(SystemProperties.ECOMP_REQUEST_ID)) { - requestId = request.getHeader(headerName); - break; - } + while (headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + logger.debug(EELFLoggerDelegate.debugLogger, "getRequestId: header {} has value {}", headerName, + request.getHeader(headerName)); + if (headerName.equalsIgnoreCase(SystemProperties.ECOMP_REQUEST_ID)) { + requestId = request.getHeader(headerName); + break; } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "HEADER!!!! Exception : " + EcompPortalUtils.getStackTrace(e)); } - - return (requestId.isEmpty() ? UUID.randomUUID().toString() : requestId); + return requestId.isEmpty() ? UUID.randomUUID().toString() : requestId; } - - public String getJessionId(HttpServletRequest request){ - - return request.getSession().getId(); - /* - Cookie ep = WebUtils.getCookie(request, JSESSIONID); - if(ep==null){ - return request.getSession().getId(); - } - return ep.getValue(); - */ + + public String getWelcomeView() { + return welcomeView; } - - - protected void initateSessionMgtHandler(HttpServletRequest request) { - String jSessionId = getJessionId(request); - PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request)); + + public void setWelcomeView(String welcomeView) { + this.welcomeView = welcomeView; } - + @Override public String getViewName() { return viewName; } + + @Override public void setViewName(String viewName) { this.viewName = viewName; } + public EPLoginService getLoginService() { - return loginService; - } + return loginService; + } - public void setLoginService(EPLoginService loginService) { - this.loginService = loginService; - } + public void setLoginService(EPLoginService loginService) { + this.loginService = loginService; + } public SharedContextService getSharedContextService() { return sharedContextService; @@ -401,7 +388,5 @@ public class LoginController extends EPUnRestrictedBaseController implements Log public void setSharedContextService(SharedContextService sharedContextService) { this.sharedContextService = sharedContextService; } - - } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java index d2c53028..4b5a8d96 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java index 67f79b8b..64f38c18 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * 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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java index 9d8a7893..917d7713 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java index 18c89a66..9e87ae2e 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java index 086b69a9..9366b1e7 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.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.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java index 89f9fe58..5cffe8cd 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java index fe31066d..313ae683 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java index 1d6b59ef..95623661 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java index 28f1e67f..d2585ab4 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java index dc18f1ff..61b98e4f 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.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.portal.interceptor; @@ -69,9 +87,8 @@ public class SessionTimeoutInterceptor extends HandlerInterceptorAdapter { resetSessionMaxIdleTimeOut(request); CollaborateList.addUserName(user.getOrgUserId()); } - } catch (Exception see) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(see)); - // return loginStrategy.login(request, response); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "preHandle failed", e); return false; } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java index 974272d0..0970ec45 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.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.portal.logging.aop; @@ -159,7 +177,7 @@ public class EPEELFLoggerAspect { try { result = joinPoint.proceed(); } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "logAroundMethod failed", e); statusCode = "ERROR"; responseCode = "500"; //Internal server error } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java index 71542268..fd0974b0 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java index f3fda34e..55479a20 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.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.portal.service; @@ -60,38 +78,39 @@ import com.google.gson.JsonParseException; @org.springframework.context.annotation.Configuration @EnableAspectJAutoProxy @EPAuditLog -public class ApplicationsRestClientServiceImpl implements ApplicationsRestClientService{ - +public class ApplicationsRestClientServiceImpl implements ApplicationsRestClientService { + private static final String PASSWORD_HEADER = "password"; private static final String APP_USERNAME_HEADER = "username"; private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ApplicationsRestClientServiceImpl.class); - + @Autowired private AppsCacheService appsCacheService; Gson gson = null; - + private final ObjectMapper mapper = new ObjectMapper(); - + @PostConstruct - private void init(){ + private void init() { logger.debug(EELFLoggerDelegate.debugLogger, "initializing"); - GsonBuilder builder = new GsonBuilder(); + GsonBuilder builder = new GsonBuilder(); - // Register an adapter to manage the date types as long values - builder.registerTypeAdapter(Date.class, new JsonDeserializer() { - public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return new Date(json.getAsJsonPrimitive().getAsLong()); - } + // Register an adapter to manage the date types as long values + builder.registerTypeAdapter(Date.class, new JsonDeserializer() { + public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return new Date(json.getAsJsonPrimitive().getAsLong()); + } }); - gson = builder.create(); + gson = builder.create(); } - + // TODO: do we need to do additional logging for remote API calls? private static WebClient createClientForPath(String baseUri, String path) { - logger.info(EELFLoggerDelegate.debugLogger, "Creating web client for " + baseUri + " + " + path); + logger.info(EELFLoggerDelegate.debugLogger, "Creating web client for " + baseUri + " + " + path); WebClient client = WebClient.create(baseUri); client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON); client.path(path); @@ -104,7 +123,8 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient logger.debug(EELFLoggerDelegate.debugLogger, "http response status=" + status); MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(status)); if (!isHttpSuccess(status)) { - String errMsg = "Failed. Status=" + status + "; [" + response.getStatusInfo().getReasonPhrase().toString() + "]"; + String errMsg = "Failed. Status=" + status + "; [" + response.getStatusInfo().getReasonPhrase().toString() + + "]"; URL url = null; try { // must not be null to avoid NPE in HTTPException constructor @@ -120,82 +140,86 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient throw new HTTPException(status, errMsg, url); } } - - private static boolean isHttpSuccess(int status){ + + private static boolean isHttpSuccess(int status) { return status / 100 == 2; } @EPMetricsLog private WebClient createClientForApp(long appId, String restPath) { - logger.debug(EELFLoggerDelegate.debugLogger, "creating client for appId=" + appId + "; restPath=" + restPath); + logger.debug(EELFLoggerDelegate.debugLogger, "creating client for appId=" + appId + "; restPath=" + restPath); EPApp externalApp = appsCacheService.getApp(appId); - if(externalApp != null){ + if (externalApp != null) { String appBaseUri = externalApp.getAppRestEndpoint(); - String username = externalApp.getUsername(); + String username = externalApp.getUsername(); String encriptedPwd = externalApp.getAppPassword(); String decreptedAppPwd = ""; - - //Set local context + + // Set local context MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTP); - if (appBaseUri!=null && appBaseUri.contains("https")) { + if (appBaseUri != null && appBaseUri.contains("https")) { MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTPS); } MDC.put(EPSystemProperties.FULL_URL, appBaseUri + restPath); MDC.put(EPSystemProperties.TARGET_ENTITY, externalApp.getName()); MDC.put(EPSystemProperties.TARGET_SERVICE_NAME, restPath); - + try { - decreptedAppPwd = CipherUtil.decrypt(encriptedPwd, SystemProperties.getProperty(SystemProperties.Decryption_Key)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Unable to decrypt App name = " + externalApp, EcompPortalUtils.getStackTrace(e)); - logger.error(EELFLoggerDelegate.errorLogger, "Unable to decrypt App name = " + externalApp, EcompPortalUtils.getStackTrace(e)); + decreptedAppPwd = CipherUtil.decrypt(encriptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "createClientForApp failed to decrypt", e); } - logger.debug(EELFLoggerDelegate.debugLogger, String.format("App %d found, baseUri=[%s], Headers: [%s=%s, %s=%s]", appId, appBaseUri, APP_USERNAME_HEADER, username, PASSWORD_HEADER, encriptedPwd)); + logger.debug(EELFLoggerDelegate.debugLogger, + String.format("App %d found, baseUri=[%s], Headers: [%s=%s, %s=%s]", appId, appBaseUri, + APP_USERNAME_HEADER, username, PASSWORD_HEADER, encriptedPwd)); WebClient client = createClientForPath(appBaseUri, restPath); client.header(APP_USERNAME_HEADER, username); client.header(PASSWORD_HEADER, decreptedAppPwd); client.header(SystemProperties.ECOMP_REQUEST_ID, MDC.get(MDC_KEY_REQUEST_ID)); client.header(SystemProperties.USERAGENT_NAME, EPSystemProperties.ECOMP_PORTAL_BE); - + return client; } return null; } - + @Override public T get(Class clazz, long appId, String restPath) throws HTTPException { - + WebClient webClient = null; Response response = null; T t = null; - + webClient = createClientForApp(appId, restPath); EcompPortalUtils.logAndSerializeObject(restPath, "GET request =", "no-payload"); - + try { - if (webClient!=null) { + if (webClient != null) { response = webClient.get(); } else { - logger.error(EELFLoggerDelegate.errorLogger, "Unable to create the Webclient to make the '" + restPath + "' API call."); + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); } } catch (Exception e) { - MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the GET REST API call, Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "get 1 failed", e); } - - if (response!=null) { + + if (response != null) { verifyResponse(response); String str = response.readEntity(String.class); EcompPortalUtils.logAndSerializeObject(restPath, "GET result =", str); - try { - t = mapper.readValue(str, clazz); - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput); - } + try { + t = mapper.readValue(str, clazz); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "get 2 failed", e); + EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput); + } } - + return t; } @@ -204,68 +228,75 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient WebClient client = null; Response response = null; T t = null; - + client = createClientForApp(appId, restPath); EcompPortalUtils.logAndSerializeObject(restPath, "POST request =", payload); - - + try { - if (client!=null) { + if (client != null) { response = client.post(payload); } else { - logger.error(EELFLoggerDelegate.errorLogger, "Unable to create the Webclient to make the '" + restPath + "' API call."); + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the {} API call", restPath); } } catch (Exception e) { - MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call, Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "post 1 failed", e); } - - if (response!=null) { + + if (response != null) { verifyResponse(response); - - //String contentType = response.getHeaderString("Content-Type"); - if(clazz != null) { + + // String contentType = response.getHeaderString("Content-Type"); + if (clazz != null) { String str = response.readEntity(String.class); EcompPortalUtils.logAndSerializeObject(restPath, "POST result =", str); - try { t = gson.fromJson(str, clazz); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "post 2 failed", e); EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput); - } + } } } return t; } @Override - public T put(Class clazz, long appId, Object payload, String restPath) throws HTTPException { + public T put(Class clazz, long appId, Object payload, String restPath) throws HTTPException { WebClient client = null; Response response = null; T t = null; - + client = createClientForApp(appId, restPath); EcompPortalUtils.logAndSerializeObject(restPath, "PUT request =", payload); - + try { - if (client!=null) { + if (client != null) { response = client.put(payload); } else { - logger.error(EELFLoggerDelegate.errorLogger, "Unable to create the Webclient to make the '" + restPath + "' API call."); + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); } - } catch(Exception e) { - MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + } catch (Exception e) { + MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the PUT REST API call, Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "put 1 failed", e); } - - if (response!=null) { + + if (response != null) { verifyResponse(response); String str = response.readEntity(String.class); EcompPortalUtils.logAndSerializeObject(restPath, "PUT result =", str); - try { t = gson.fromJson(str, clazz); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "put 2 failed", e); EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput); - } + } } return t; } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java index 20939a9a..20f4d59f 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java index 683017b1..09a78e85 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java index 41e51be6..ea92ca51 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java @@ -1,25 +1,43 @@ /*- - * ================================================================================ - * 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.portal.service; - +import java.net.MalformedURLException; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.LinkedList; @@ -59,34 +77,28 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppServiceImpl.class); private static Object syncRests = new Object(); - + @Autowired private DataAccessService dataAccessService; - + @Override public List getUserRemoteApps(String id) { - - StringBuilder query = new StringBuilder(); - - query.append("SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = FN_APP.APP_ID where "); - query.append( - "FN_USER_ROLE.USER_ID = " + id + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID); - query.append(" AND FN_APP.ENABLED = 'Y'"); - - TreeSet distinctApps = new TreeSet(); - - @SuppressWarnings("unchecked") - List adminApps = dataAccessService.executeSQLQuery(query.toString(), EPApp.class, null); - for (EPApp app : adminApps) { - distinctApps.add(app); - } - - List userApps = new ArrayList(); - userApps.addAll(distinctApps); - return userApps; - + StringBuilder query = new StringBuilder(); + query.append("SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = FN_APP.APP_ID where "); + query.append("FN_USER_ROLE.USER_ID = " + id + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID); + query.append(" AND FN_APP.ENABLED = 'Y'"); + TreeSet distinctApps = new TreeSet(); + @SuppressWarnings("unchecked") + List adminApps = dataAccessService.executeSQLQuery(query.toString(), EPApp.class, null); + for (EPApp app : adminApps) { + distinctApps.add(app); + } + List userApps = new ArrayList(); + userApps.addAll(distinctApps); + return userApps; } - + + @Override protected void updateRestrictedApp(Long appId, OnboardingApp onboardingApp, FieldsValidator fieldsValidator, EPUser user) { synchronized (syncRests) { @@ -99,11 +111,13 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer EPApp app; if (appId == null) { app = new EPApp(); - - // In the parent class, the UEB code is responsible for generating the keys/secret/mailbox but UEB Messaging - // is not actually being used currently; may be used in future at which point we can just remove this method and - // depend on parent class's method - // So, using UUID generator to generate the unique key instead. + /* + * In the parent class, the UEB code is responsible for generating the + * keys/secret/mailbox but UEB Messaging is not actually being used currently; + * may be used in future at which point we can just remove this method and + * depend on parent class's method So, using UUID generator to generate the + * unique key instead. + */ String uuidStr = UUID.randomUUID().toString(); String appKey = uuidStr; String appSecret = uuidStr; @@ -111,8 +125,7 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer onboardingApp.setUebTopicName(appMailboxName); onboardingApp.setUebKey(appKey); onboardingApp.setUebSecret(appSecret); - - }else { + } else { app = (EPApp) localSession.get(EPApp.class, appId); if (app == null || app.getId() == null) { // App is already deleted! @@ -122,28 +135,30 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer return; } } - logger.debug(EELFLoggerDelegate.debugLogger, "LR: about to call createAppFromOnboarding"); + logger.debug(EELFLoggerDelegate.debugLogger, + "updateRestrictedApp: about to call createAppFromOnboarding"); createAppFromOnboarding(app, onboardingApp, localSession); logger.debug(EELFLoggerDelegate.debugLogger, - "LR: updateApp: finished calling createAppFromOnboarding"); + "updateRestrictedApp: finished calling createAppFromOnboarding"); localSession.saveOrUpdate(app); logger.debug(EELFLoggerDelegate.debugLogger, - "LR: updateApp: finished calling localSession.saveOrUpdate"); + "updateRestrictedApp: finished calling localSession.saveOrUpdate"); // Enable or disable all menu items associated with this app setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); logger.debug(EELFLoggerDelegate.debugLogger, - "LR: updateApp: finished calling setFunctionalMenuItemsEnabled"); + "updateRestrictedApp: finished calling setFunctionalMenuItemsEnabled"); transaction.commit(); - logger.debug(EELFLoggerDelegate.debugLogger, "LR: updateApp: finished calling transaction.commit"); + logger.debug(EELFLoggerDelegate.debugLogger, + "updateRestrictedApp: finished calling transaction.commit"); result = true; } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "updateApp failed", e); + logger.error(EELFLoggerDelegate.errorLogger, "updateRestrictedApp failed", e); EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e); EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); EcompPortalUtils.rollbackTransaction(transaction, - "updateApp rollback, exception = " + EcompPortalUtils.getStackTrace(e)); + "updateRestrictedApp rollback, exception = " + e.toString()); } finally { - EcompPortalUtils.closeLocalSession(localSession, "updateApp"); + EcompPortalUtils.closeLocalSession(localSession, "updateRestrictedApp"); } if (!result) { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); @@ -151,9 +166,11 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer } } - - public CambriaTopicManager getTopicManager(LinkedList urlList, String key, String secret) throws GeneralSecurityException, Exception{ - return CambriaClientFactory.createTopicManager( null, urlList, key, secret); + + @Override + public CambriaTopicManager getTopicManager(List urlList, String key, String secret) + throws MalformedURLException, GeneralSecurityException { + return CambriaClientFactory.createTopicManager(null, urlList, key, secret); } } \ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java index 94937dc4..07dc8cca 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java index 2be95244..0929c480 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.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.portal.service; @@ -105,7 +123,7 @@ public class SearchServiceImpl implements SearchService { try { result = mapper.writeValueAsString(resultOfSearch); } catch (JsonProcessingException e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchUsersInPhoneBook Exception = " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "searchUsersInFnTable failed", e); } return result; } @@ -122,7 +140,7 @@ public class SearchServiceImpl implements SearchService { foundUsers.add(foundUser); } } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchInPhoneBookWithToken Exception = " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "searchUsersByUserId failed", e); } return foundUsers; } @@ -138,7 +156,7 @@ public class SearchServiceImpl implements SearchService { foundUsers.add(foundUser); } } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchInPhoneBookWithToken Exception = " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "searchUsersByName failed", e); } return foundUsers; } @@ -184,7 +202,7 @@ public class SearchServiceImpl implements SearchService { foundUsers.add(user); } } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchInPhoneBookWithToken Exception = " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "searchUserByUserId failed", e); return null; } return foundUsers.get(0); diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java index 37acfe53..446bb60e 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.service; import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java index 1f98e752..c38fc6ae 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java index bd8949f3..69ea652c 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.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.portal.service; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java index 225f3a7a..9cc97460 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.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.portal.service; @@ -31,11 +49,10 @@ import org.json.JSONArray; import org.json.JSONObject; import org.openecomp.portalapp.portal.domain.EPUser; import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.FusionObject.Utilities; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.DataAccessService; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalsdk.core.service.DataAccessService; import org.openecomp.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -44,12 +61,12 @@ import org.springframework.transaction.annotation.Transactional; @Service("userService") @Transactional public class UserServiceImpl implements UserService { - + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserServiceImpl.class); @Autowired - private DataAccessService dataAccessService; - + private DataAccessService dataAccessService; + public DataAccessService getDataAccessService() { return dataAccessService; } @@ -57,19 +74,18 @@ public class UserServiceImpl implements UserService { public void setDataAccessService(DataAccessService dataAccessService) { this.dataAccessService = dataAccessService; } - + @SuppressWarnings("rawtypes") @Override public List getUserByUserId(String userId) { - - - if(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")){ - List users=new ArrayList(); - List filterdUsers=new ArrayList(); - BufferedReader in = null; - HttpURLConnection con = null; - try{ - String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); + + if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) { + List users = new ArrayList(); + List filterdUsers = new ArrayList(); + BufferedReader in = null; + HttpURLConnection con = null; + try { + String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); URL obj = new URL(url); con = (HttpURLConnection) obj.openConnection(); @@ -84,78 +100,78 @@ public class UserServiceImpl implements UserService { in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); String inputLine; while ((inputLine = in.readLine()) != null) - response.append(inputLine); - JSONObject jObject = new JSONObject(response.toString()); // json - JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object - for (int i = 0; i < jsonUsers.length(); i++) { - JSONObject eachObject = jsonUsers.getJSONObject(i); - EPUser eachUser = new EPUser(); - eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); - eachUser.setFirstName(eachObject.get("givenName").toString()); - eachUser.setLastName(eachObject.get("familyName").toString()); - eachUser.setEmail(eachObject.get("email").toString()); - users.add(eachUser); - } - - for(int i = 0 ; i < users.size(); i ++){ - - if(Utilities.nvl(userId).length() > 0){ - if(!userId.equalsIgnoreCase(users.get(i).getOrgUserId())){ - continue; - } - } - filterdUsers.add(users.get(i)); - - } - - }catch (Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - }finally{ - try { + response.append(inputLine); + JSONObject jObject = new JSONObject(response.toString()); // json + JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object + for (int i = 0; i < jsonUsers.length(); i++) { + JSONObject eachObject = jsonUsers.getJSONObject(i); + EPUser eachUser = new EPUser(); + eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); + eachUser.setFirstName(eachObject.get("givenName").toString()); + eachUser.setLastName(eachObject.get("familyName").toString()); + eachUser.setEmail(eachObject.get("email").toString()); + users.add(eachUser); + } + + for (int i = 0; i < users.size(); i++) { + + if (Utilities.nvl(userId).length() > 0) { + if (!userId.equalsIgnoreCase(users.get(i).getOrgUserId())) { + continue; + } + } + filterdUsers.add(users.get(i)); + + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed", e); + } finally { + try { in.close(); con.disconnect(); } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId 2 failed", e); } - } - + } + return filterdUsers; - - }else{ - - List list = null; - StringBuffer criteria = new StringBuffer(); - criteria.append(" where org_user_id = '").append(userId).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - return (list == null || list.size() == 0) ? null : list; - + + } else { + + List list = null; + StringBuffer criteria = new StringBuffer(); + criteria.append(" where org_user_id = '").append(userId).append("'"); + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + return (list == null || list.size() == 0) ? null : list; + } - + } @SuppressWarnings("rawtypes") @Override public List getUserByFirstLastName(String firstName, String lastName) { - - if(!SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")){ - - List list = null; - StringBuffer criteria = new StringBuffer(); - if(firstName!=null) - criteria.append(" where first_name = '").append(firstName).append("'"); - if(lastName!=null) - criteria.append(" where last_name = '").append(lastName).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - return (list == null || list.size() == 0) ? null : list; - - }else{ - - List users=new ArrayList(); - List filterdUsers=new ArrayList(); - BufferedReader in = null; - HttpURLConnection con = null; - try{ - String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); + + if (!SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) { + + List list = null; + StringBuffer criteria = new StringBuffer(); + if (firstName != null) + criteria.append(" where first_name = '").append(firstName).append("'"); + if (lastName != null) + criteria.append(" where last_name = '").append(lastName).append("'"); + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + return (list == null || list.size() == 0) ? null : list; + + } else { + + List users = new ArrayList(); + List filterdUsers = new ArrayList(); + BufferedReader in = null; + HttpURLConnection con = null; + try { + String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); URL obj = new URL(url); con = (HttpURLConnection) obj.openConnection(); @@ -166,92 +182,89 @@ public class UserServiceImpl implements UserService { con.setReadTimeout(8000); StringBuffer response = new StringBuffer(); - + in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); String inputLine; while ((inputLine = in.readLine()) != null) - response.append(inputLine); - JSONObject jObject = new JSONObject(response.toString()); // json - JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object - for (int i = 0; i < jsonUsers.length(); i++) { - JSONObject eachObject = jsonUsers.getJSONObject(i); - EPUser eachUser = new EPUser(); - eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); - eachUser.setFirstName(eachObject.get("givenName").toString()); - eachUser.setLastName(eachObject.get("familyName").toString()); - eachUser.setEmail(eachObject.get("email").toString()); - users.add(eachUser); - } - - for(int i = 0 ; i < users.size(); i ++){ - - if(Utilities.nvl(firstName).length() > 0){ - if(!firstName.equalsIgnoreCase(users.get(i).getFirstName())){ - continue; - } - } - if(Utilities.nvl(lastName).length() > 0){ - if(!lastName.equalsIgnoreCase(users.get(i).getLastName())){ - continue; - } - } - - - filterdUsers.add(users.get(i)); - - } - - }catch (Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); - }finally{ - try { + response.append(inputLine); + JSONObject jObject = new JSONObject(response.toString()); // json + JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object + for (int i = 0; i < jsonUsers.length(); i++) { + JSONObject eachObject = jsonUsers.getJSONObject(i); + EPUser eachUser = new EPUser(); + eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); + eachUser.setFirstName(eachObject.get("givenName").toString()); + eachUser.setLastName(eachObject.get("familyName").toString()); + eachUser.setEmail(eachObject.get("email").toString()); + users.add(eachUser); + } + + for (int i = 0; i < users.size(); i++) { + + if (Utilities.nvl(firstName).length() > 0) { + if (!firstName.equalsIgnoreCase(users.get(i).getFirstName())) { + continue; + } + } + if (Utilities.nvl(lastName).length() > 0) { + if (!lastName.equalsIgnoreCase(users.get(i).getLastName())) { + continue; + } + } + + filterdUsers.add(users.get(i)); + + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed", e); + } finally { + try { in.close(); con.disconnect(); } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName 2 failed", e); } - } - + } + return filterdUsers; } - + } - - public String saveNewUser(EPUser newUser, String checkDuplicate) throws Exception{ - - try{ - - List list = null; - StringBuffer criteria = new StringBuffer(); - criteria.append(" where org_user_id = '").append(newUser.getLoginId()).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - if(list == null || list.size()==0){ - newUser.setActive(true); - newUser.setOrgUserId(newUser.getLoginId()); - newUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); - getDataAccessService().saveDomainObject(newUser, null); - }else{ - if(checkDuplicate.equals("Yes")){ - // userId already exist in database - return "Record already exist"; - }else{ - - EPUser oldUser = (EPUser) list.get(0); - oldUser.setFirstName(newUser.getFirstName()); - oldUser.setLastName(newUser.getLastName()); - oldUser.setMiddleInitial(newUser.getMiddleInitial()); - if(!oldUser.getLoginPwd().equals(newUser.getLoginPwd())) - oldUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); - else - oldUser.setLoginPwd(newUser.getLoginPwd()); - getDataAccessService().saveDomainObject(oldUser, null); - - } - - } - - }catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "", e); + + public String saveNewUser(EPUser newUser, String checkDuplicate) throws Exception { + try { + List list = null; + StringBuffer criteria = new StringBuffer(); + criteria.append(" where org_user_id = '").append(newUser.getLoginId()).append("'"); + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + if (list == null || list.size() == 0) { + newUser.setActive(true); + newUser.setOrgUserId(newUser.getLoginId()); + newUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); + getDataAccessService().saveDomainObject(newUser, null); + } else { + if (checkDuplicate.equals("Yes")) { + // userId already exist in database + return "Record already exist"; + } else { + + EPUser oldUser = (EPUser) list.get(0); + oldUser.setFirstName(newUser.getFirstName()); + oldUser.setLastName(newUser.getLastName()); + oldUser.setMiddleInitial(newUser.getMiddleInitial()); + if (!oldUser.getLoginPwd().equals(newUser.getLoginPwd())) + oldUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); + else + oldUser.setLoginPwd(newUser.getLoginPwd()); + getDataAccessService().saveDomainObject(oldUser, null); + + } + + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveNewUser failed", e); throw new Exception(e); } return "success"; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java index eee12234..4a156a1a 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.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.portal.transport; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java index 1162cf20..81b1c495 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.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.portal.ueb; @@ -24,8 +42,6 @@ import java.net.URL; import java.util.LinkedList; import java.util.List; -import javax.annotation.PostConstruct; - import org.hibernate.Session; import org.hibernate.SessionFactory; import org.openecomp.portalapp.portal.domain.EPApp; @@ -36,13 +52,13 @@ import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; import org.openecomp.portalapp.portal.service.EPAppService; 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.Helper; import org.openecomp.portalsdk.core.onboarding.ueb.Publisher; import org.openecomp.portalsdk.core.onboarding.ueb.UebException; import org.openecomp.portalsdk.core.onboarding.ueb.UebManager; import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Component; @@ -54,88 +70,80 @@ import org.springframework.transaction.annotation.Transactional; @EnableAspectJAutoProxy public class EPUebHelper { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUebHelper.class); - + @Autowired EPAppService appsService; - - + @Autowired private SessionFactory sessionFactory; - + @SuppressWarnings("unused") private Publisher epPublisher; - + public EPUebHelper() { - + } + // - // This should only be called by the ECOMP Portal App, other Apps have just one publisher and use appPublisher + // This should only be called by the ECOMP Portal App, other Apps have just one + // publisher and use appPublisher // @SuppressWarnings("unused") @EPMetricsLog - public void refreshPublisherList() - { + public void refreshPublisherList() { Session localSession = null; - boolean addedPublisher = false; - + boolean addedPublisher = false; + try { localSession = sessionFactory.openSession(); - + List apps = appsService.getEcompAppAppsFullList(); - for (int i = 0; i < apps.size(); i++) - { - if ((apps.get(i).isEnabled()) && - (apps.get(i).getUebTopicName() != null) && - !(apps.get(i).getUebTopicName().toUpperCase().contains("ECOMP-PORTAL-INBOX"))) - { - logger.debug(EELFLoggerDelegate.debugLogger, "UEBManager adding publisher for " + apps.get(i).getUebTopicName()); + for (int i = 0; i < apps.size(); i++) { + if ((apps.get(i).isEnabled()) && (apps.get(i).getUebTopicName() != null) + && !(apps.get(i).getUebTopicName().toUpperCase().contains("ECOMP-PORTAL-INBOX"))) { + logger.debug(EELFLoggerDelegate.debugLogger, + "UEBManager adding publisher for " + apps.get(i).getUebTopicName()); UebManager.getInstance().addPublisher(apps.get(i).getUebTopicName()); - addedPublisher = true; - } - else if ((apps.get(i).getId() != 1) && // App may have been disabled, remove the publisher - !(apps.get(i).isEnabled())) - { - if(apps.get(i).getUebTopicName()!=null){ + addedPublisher = true; + } else if ((apps.get(i).getId() != 1) && // App may have been disabled, remove the publisher + !(apps.get(i).isEnabled())) { + if (apps.get(i).getUebTopicName() != null) { UebManager.getInstance().removePublisher(apps.get(i).getUebTopicName()); } } } - } - catch (Exception e) - { + } catch (Exception e) { EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebSystemError, "add/remove Publisher"); - String stackTrace = EcompPortalUtils.getStackTrace(e); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while refreshing the publisher list. Details: " + stackTrace); + logger.error(EELFLoggerDelegate.errorLogger, "refreshPublisherList failed", e); } - - //publisherList.print(); - + + // publisherList.print(); + if (addedPublisher == true) // Give publishers time to initialize { Helper.sleep(400); } } - - //@PostConstruct - //@EPMetricsLog + + // @PostConstruct + // @EPMetricsLog public void initUeb() { try { - epPublisher = new Publisher(PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), - PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), - PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); + epPublisher = new Publisher(PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); } catch (Exception e) { EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, e.getMessage()); - String stackTrace = EcompPortalUtils.getStackTrace(e); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while initializing the publisher. Details: " + stackTrace); + logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e); } - + Thread thread = new Thread("EPUebManager: postConstructMethod - refreshPublisherList") { - public void run(){ - refreshPublisherList(); - } + public void run() { + refreshPublisherList(); + } }; if (thread != null) { - thread.start(); + thread.start(); } } @@ -145,74 +153,69 @@ public class EPUebHelper { try { UebManager.getInstance().addPublisher(app.getUebTopicName()); } catch (UebException e) { - String stackTrace = EcompPortalUtils.getStackTrace(e); - logger.error(EELFLoggerDelegate.errorLogger, "Exception while adding a publisher. Details: " + stackTrace); + logger.error(EELFLoggerDelegate.errorLogger, "addPublisher failed", e); } } - + public boolean checkAvailability() { - + + // + // Test existence of topic at UEB url // - // Test existence of topic at UEB url // - // // boolean available = true; LinkedList urlList = Helper.uebUrlList(); if (!urlList.isEmpty()) { - String url = "http://" + urlList.getFirst() + ":3904/topics/" + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME); - if (!url.isEmpty()) { - try { - URL siteURL = new URL(url); - HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection(); - connection.setRequestMethod("GET"); - connection.connect(); - - int code = connection.getResponseCode(); - if (code == 200) { - available = true; - } - else { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, url); - available = false; - logger.warn(EELFLoggerDelegate.errorLogger, "Warning! UEB topic existence check failed, topic = " + url ); - logger.debug(EELFLoggerDelegate.debugLogger, "Warning! UEB topic existence check failed, topic = " + url ); - } - } - catch (Exception e) { - available = false; - String stackTrace = EcompPortalUtils.getStackTrace(e); - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing the UEB Healthcheck. Details: " + stackTrace); - } - } + String url = "http://" + urlList.getFirst() + ":3904/topics/" + + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME); + if (!url.isEmpty()) { + try { + URL siteURL = new URL(url); + HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection(); + connection.setRequestMethod("GET"); + connection.connect(); + + int code = connection.getResponseCode(); + if (code == 200) { + available = true; + } else { + EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, url); + available = false; + logger.warn(EELFLoggerDelegate.errorLogger, + "Warning! UEB topic existence check failed, topic = " + url); + logger.debug(EELFLoggerDelegate.debugLogger, + "Warning! UEB topic existence check failed, topic = " + url); + } + } catch (Exception e) { + available = false; + logger.error(EELFLoggerDelegate.errorLogger, "checkAvailability failed", e); + } + } } return available; } - - public boolean MessageCanBeSentToTopic() { - - boolean sentMsgSuccessfully = false; - - UebMsg msg = new UebMsg(); - msg.putSourceTopicName(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); - msg.putPayload("Pinging topic for health check"); - msg.putMsgType(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK); - - try { - // epPublisher.send(msg); - sentMsgSuccessfully = true; - } - catch (Exception e) { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeHealthCheckUebClusterError); - String stackTrace = EcompPortalUtils.getStackTrace(e); - sentMsgSuccessfully = false; - logger.warn(EELFLoggerDelegate.errorLogger, "Warning! could not successfully publish a UEB msg to " - + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME) + " exception : " + stackTrace); - } - - return sentMsgSuccessfully; - } - -} + public boolean MessageCanBeSentToTopic() { + + boolean sentMsgSuccessfully = false; + + UebMsg msg = new UebMsg(); + msg.putSourceTopicName(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); + msg.putPayload("Pinging topic for health check"); + msg.putMsgType(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK); + + try { + // epPublisher.send(msg); + sentMsgSuccessfully = true; + } catch (Exception e) { + EPLogUtil.logEcompError(EPAppMessagesEnum.BeHealthCheckUebClusterError); + sentMsgSuccessfully = false; + logger.warn(EELFLoggerDelegate.errorLogger, "Warning! could not successfully publish a UEB msg to " + + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME), e); + } + + return sentMsgSuccessfully; + } +} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java index d6eb9eb9..720e0615 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.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.portal.ueb; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java index b187c010..e8772677 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.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.portal.utils; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java index 5b1aa159..63b44027 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.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.scheduler; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java index 8d717110..f502a564 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.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.scheduler; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java index 43e0d818..00eb7b69 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java @@ -1,28 +1,45 @@ /*- - * ================================================================================ - * 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.scheduler; import java.util.ArrayList; import java.util.List; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.scheduler.Registerable; import org.openecomp.portalsdk.core.util.SystemProperties; @@ -60,7 +77,7 @@ public class Register implements Registerable { getScheduleTriggers().add(logRegistry.getTrigger()); } catch (IllegalStateException ies) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(ies)); + logger.error(EELFLoggerDelegate.errorLogger, "registerTriggers log cron failed", ies); logger.info(EELFLoggerDelegate.debugLogger, ("Log Cron not available")); } @@ -69,7 +86,7 @@ public class Register implements Registerable { getScheduleTriggers().add(sessionMgtRegistry.getTrigger()); } catch(IllegalStateException ies) { - logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(ies)); + logger.error(EELFLoggerDelegate.errorLogger, "registerTriggers session timeout failed", ies); logger.info(EELFLoggerDelegate.debugLogger, ("Session Cron not available")); } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java index 1d2d8071..542b0d88 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.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.scheduler; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java index 315618e9..c18b4b35 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.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.scheduler; @@ -46,7 +64,7 @@ import org.springframework.stereotype.Component; @DependsOn({ "systemProperties" }) public class SessionMgtRegistry extends CronRegistry implements ApplicationContextAware { - EELFLoggerDelegate logger = null; + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionMgtRegistry.class); private static final String groupName = "AppGroup"; private static final String jobName = "PortalSessionTimeoutFeedJob"; @@ -60,14 +78,12 @@ public class SessionMgtRegistry extends CronRegistry implements ApplicationConte private ApplicationContext applicationContext; public JobDetailFactoryBean jobDetailFactoryBean() { - logger = EELFLoggerDelegate.getLogger(SessionMgtRegistry.class); Map map = new HashMap(); return jobDetailFactoryBean(groupName, jobName, TimeoutHandler.class, map); } @SuppressWarnings("static-access") public CronTriggerFactoryBean cronTriggerFactoryBean() throws ParseException { - logger = EELFLoggerDelegate.getLogger(SessionMgtRegistry.class); String property = "* * * * * ? 2099"; try { property = systemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON); diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java index c07d1093..0b10caf6 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java @@ -1,33 +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.service; import java.util.List; import org.openecomp.portalapp.portal.domain.EPApp; -import org.openecomp.portalapp.portal.service.AppsCacheService; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.portalsdk.core.service.WebServiceCallServiceImpl; import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,9 +54,7 @@ import org.springframework.transaction.annotation.Transactional; @EnableAspectJAutoProxy public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl implements RemoteWebServiceCallService { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RemoteWebServiceCallServiceImpl.class); - @Autowired - AppsCacheService appCacheService; + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RemoteWebServiceCallServiceImpl.class); /* * (non-Javadoc) 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 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 inboxQueue = new ConcurrentLinkedQueue(); - 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 inboxQueue = new ConcurrentLinkedQueue(); + 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 inboxQueue = null; - - @Autowired - FunctionalMenuHandler funcMenuHandler; - + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class); + + private ConcurrentLinkedQueue inboxQueue = null; + + @Autowired + private FunctionalMenuHandler funcMenuHandler; + @Autowired - WidgetNotificationHandler widgetNotificationHandler; + private WidgetNotificationHandler widgetNotificationHandler; @Async - public void runHandler(ConcurrentLinkedQueue queue) - { + public void runHandler(ConcurrentLinkedQueue 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 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 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"); } } } diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java index 1ef44a44..7ae34aed 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.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.util; @@ -25,11 +43,10 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; -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.listener.PortalTimeoutHandler; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; import org.openecomp.portalsdk.core.util.SystemProperties; import org.openecomp.portalsdk.core.web.support.AppUtils; @@ -121,7 +138,7 @@ public class SessionCookieUtil { session.setMaxInactiveInterval(Integer.parseInt(maxIdleAttribute.toString())); } } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Could not reset the session timeout. Details: " + EcompPortalUtils.getStackTrace(e)); + logger.error(EELFLoggerDelegate.errorLogger, "resetSessionMaxIdleTimeOut failed", e); } } diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java index 4386ccd7..2d0f795a 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.authentication; import static org.junit.Assert.*; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java index fc827f78..c4946c68 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.authentication; import static org.junit.Assert.assertFalse; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java index 5093fae0..588bd89c 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.authentication; import static org.junit.Assert.assertFalse; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java deleted file mode 100644 index 049f7239..00000000 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*package org.openecomp.portalapp.portal.controller; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; -import org.openecomp.portalapp.portal.service.AdminRolesService; -import org.openecomp.portalapp.portal.service.EPAppService; -import org.openecomp.portalapp.portal.service.PortalAdminService; -import org.openecomp.portalapp.portal.test.core.MockEPUser; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.transport.OnboardingApp; -import org.openecomp.portalapp.test.framework.MockitoTestSuite; -import org.openecomp.portalapp.util.EPUserUtils; - -public class AppsControllerExternalRequestOSTest { - - @Mock - AdminRolesService adminRolesService; - - @Mock - EPAppService appService; - - @Mock - PortalAdminService portalAdminService; - - - @InjectMocks - AppsControllerExternalRequest appsControllerExternalRequest = new AppsControllerExternalRequest(); - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); - - HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); - HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); - NullPointerException nullPointerException = new NullPointerException(); - - MockEPUser mockUser = new MockEPUser(); - @Mock - EPUserUtils ePUserUtils = new EPUserUtils(); - - @Test - public void postOnboardAppExternalFieldValidatorTestTest() { - PortalRestResponse expectedportalRestResponse = new PortalRestResponse(); - expectedportalRestResponse.setMessage("FieldsValidator [httpStatusCode=500, errorCode=null, fields=null]"); - expectedportalRestResponse.setResponse(null); - PortalRestStatusEnum portalRestStatusEnum = null; - expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); - OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; - expectedOnboardingApp.name = "Test"; - expectedOnboardingApp.url = "Test"; - expectedOnboardingApp.restUrl = "Test"; - expectedOnboardingApp.restrictedApp = false; - expectedOnboardingApp.isOpen = false; - expectedOnboardingApp.isEnabled = false; - List userList = new ArrayList(); - EPUser user = mockUser.mockEPUser(); - userList.add(user); - FieldsValidator expectedFieldValidator = new FieldsValidator(); - expectedFieldValidator.setHttpStatusCode((long) 500); - expectedFieldValidator.setFields(null); - expectedFieldValidator.setErrorCode(null); - Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator); - PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest - .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); - assertEquals(actualPortalRestResponse, expectedportalRestResponse); - - } - - @Test - public void postOnboardAppExternalIfSuperAdminTest() { - PortalRestResponse expectedportalRestResponse = new PortalRestResponse(); - expectedportalRestResponse.setMessage(null); - expectedportalRestResponse.setResponse(null); - PortalRestStatusEnum portalRestStatusEnum = null; - expectedportalRestResponse.setStatus(portalRestStatusEnum.OK); - OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; - expectedOnboardingApp.name = "Test"; - expectedOnboardingApp.url = "Test"; - expectedOnboardingApp.restUrl = "Test"; - expectedOnboardingApp.restrictedApp = false; - expectedOnboardingApp.isOpen = false; - expectedOnboardingApp.isEnabled = false; - List userList = new ArrayList(); - EPUser user = mockUser.mockEPUser(); - userList.add(user); - FieldsValidator expectedFieldValidator = new FieldsValidator(); - expectedFieldValidator.setHttpStatusCode((long) 200); - expectedFieldValidator.setFields(null); - expectedFieldValidator.setErrorCode(null); - Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator); - PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest - .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); - assertEquals(actualPortalRestResponse, expectedportalRestResponse); - - } -} -*/ \ No newline at end of file diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java index 70e7a0ca..eb2ea32e 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java @@ -1,6 +1,43 @@ +/*- + * ============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 + * + * 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.portal.controller; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; @@ -8,7 +45,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.drools.core.command.assertion.AssertEquals; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -18,12 +54,12 @@ import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPUser; import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.AdminRolesService; import org.openecomp.portalapp.portal.service.EPAppService; import org.openecomp.portalapp.portal.service.PersUserAppService; import org.openecomp.portalapp.portal.service.UserService; -import org.openecomp.portalapp.portal.framework.MockEPUser; -import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; public class AppsOSControllerTest { diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java new file mode 100644 index 00000000..b2a6c431 --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultControllerTest.java @@ -0,0 +1,359 @@ +/*- + * ============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 + * + * 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.portal.controller; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.ecomp.model.SearchResultItem; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.service.DashboardSearchService; +import org.openecomp.portalapp.portal.transport.CommonWidget; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalapp.util.EPUserUtils; + +public class DashboardSearchResultControllerTest { + + @Mock + DashboardSearchService searchService; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @InjectMocks + DashboardSearchResultController dashboardSearchResultController = new DashboardSearchResultController(); + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + MockEPUser mockUser = new MockEPUser(); + + @Test + public void getWidgetDataTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(new CommonWidgetMeta()); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + Mockito.when(searchService.getWidgetData("test")).thenReturn(commonWidgetMeta); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .getWidgetData(mockedRequest, "test"); + assertEquals(ecpectedPortalRestResponse.getStatus(), actualPortalRestResponse.getStatus()); + } + + @Test + public void saveWidgetDataBulkIfCatrgoryNullTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("ERROR"); + ecpectedPortalRestResponse.setResponse("Category cannot be null or empty"); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory(null); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataBulkTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory("test"); + List items = new ArrayList<>(); + + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setId((long) 1); + commonWidget.setEventDate("2017-06-06"); + items.add(commonWidget); + commonWidgetMeta.setItems(items); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataBulkExceptionTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"date\""); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta(); + commonWidgetMeta.setCategory("test"); + List items = new ArrayList<>(); + + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setId((long) 1); + commonWidget.setEventDate("date"); + items.add(commonWidget); + commonWidgetMeta.setItems(items); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetDataBulk(commonWidgetMeta); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataIfCatagoryNullTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("ERROR"); + ecpectedPortalRestResponse.setResponse("Cateogry cannot be null or empty"); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory(null); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory("test"); + commonWidget.setId((long) 1); + commonWidget.setEventDate("2017-06-06"); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void saveWidgetDataExceptionTest() { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"date\""); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + CommonWidget commonWidget = new CommonWidget(); + commonWidget.setCategory("test"); + commonWidget.setId((long) 1); + commonWidget.setEventDate("date"); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .saveWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse, actualPortalRestResponse); + } + + @Test + public void deleteWidgetDataTest() + { + PortalRestResponse ecpectedPortalRestResponse = new PortalRestResponse(); + ecpectedPortalRestResponse.setMessage("success"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + CommonWidget commonWidget = new CommonWidget(); + Mockito.when(searchService.deleteWidgetData(commonWidget)).thenReturn("test"); + PortalRestResponse actualPortalRestResponse = dashboardSearchResultController + .deleteWidgetData(commonWidget); + assertEquals(ecpectedPortalRestResponse.getStatus(), actualPortalRestResponse.getStatus()); + } + + @Test + public void searchPortalIfUserIsTest() + { + EPUser user = null; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + PortalRestResponse>> expectedResult = new PortalRestResponse>>(); + expectedResult.setMessage("searchPortal: User object is null? - check logs"); + expectedResult.setResponse(new HashMap>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + System.out.println(actualResult); + + assertEquals(expectedResult, actualResult); + } + + + @Test + public void getActiveUsersTest() { + List expectedActiveUsers = new ArrayList(); + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String userId = user.getOrgUserId(); + Mockito.when(searchService.getRelatedUsers(userId)).thenReturn(expectedActiveUsers); + List actualOnlineUsers = dashboardSearchResultController.getActiveUsers(mockedRequest); + assertEquals(expectedActiveUsers, actualOnlineUsers); + + } + + @Test + public void getActiveUsersExceptionTest() { + List expectedActiveUsers = new ArrayList(); + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String userId = user.getOrgUserId(); + Mockito.when(searchService.getRelatedUsers(userId)).thenThrow(nullPointerException); + List actualOnlineUsers = dashboardSearchResultController.getActiveUsers(mockedRequest); + assertEquals(expectedActiveUsers, actualOnlineUsers); + + } + + @Test + public void activeUsersTest() { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse> expectedResult = new PortalRestResponse>(); + expectedResult.setMessage("success"); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.OK); + PortalRestResponse> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + + assertEquals(actualResult, expectedResult); + + } + + @Test + public void activeUsersIfUserNullTest() { + EPUser user = null; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse> expectedResult = new PortalRestResponse>(); + expectedResult.setMessage("User object is null? - check logs"); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + assertEquals(actualResult, expectedResult); + + } + + @Test + public void activeUsersExceptionTest() { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse> expectedResult = new PortalRestResponse>(); + expectedResult.setMessage("null - check logs."); + expectedResult.setResponse(new ArrayList<>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + Mockito.when(searchService.getRelatedUsers(user.getLoginId())).thenThrow(nullPointerException); + PortalRestResponse> actualResult = dashboardSearchResultController.activeUsers(mockedRequest); + assertEquals(actualResult, expectedResult); + + } + + @Test + public void searchPortalIfSearchStringNullTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = null; + + PortalRestResponse>> expectedResult = new PortalRestResponse>>(); + expectedResult.setMessage("searchPortal: String string is null"); + expectedResult.setResponse(new HashMap>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + + PortalRestResponse>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + } + + @Test + public void searchPortalIfSearchTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + List searchResultItemList = new ArrayList(); + SearchResultItem searchResultItem = new SearchResultItem(); + + searchResultItem.setId((long) 1); + searchResultItem.setCategory("test"); + searchResultItem.setName("test_name"); + searchResultItem.setTarget("test_target"); + searchResultItem.setUuid("test_UUId"); + searchResultItemList.add(searchResultItem); + Map> expectedResultMap = new HashMap>(); + expectedResultMap.put(searchString, searchResultItemList); + + PortalRestResponse>> expectedResult = new PortalRestResponse>>(); + expectedResult.setMessage("success"); + expectedResult.setResponse(expectedResultMap); + expectedResult.setStatus(PortalRestStatusEnum.OK); + + Mockito.when(searchService.searchResults(user.getLoginId(), searchString)).thenReturn(expectedResultMap); + PortalRestResponse>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + + } + + @Test + public void searchPortalIfSearchExcptionTest() { + EPUser user = mockUser.mockEPUser(); + ; + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + String searchString = "test"; + + PortalRestResponse>> expectedResult = new PortalRestResponse>>(); + expectedResult.setMessage("null - check logs."); + expectedResult.setResponse(new HashMap>()); + expectedResult.setStatus(PortalRestStatusEnum.ERROR); + + Mockito.when(searchService.searchResults(user.getLoginId(), searchString)).thenThrow(nullPointerException); + PortalRestResponse>> actualResult = dashboardSearchResultController + .searchPortal(mockedRequest, searchString); + assertEquals(expectedResult, actualResult); + } + +} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java index 729debaa..954ff0c4 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java @@ -1,8 +1,44 @@ +/*- + * ============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 + * + * 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.portal.controller; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; -import javax.servlet.ServletRequestWrapper; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -13,13 +49,12 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.OngoingStubbing; import org.openecomp.portalapp.controller.ECOMPLogoutController; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.DashboardSearchService; import org.openecomp.portalapp.portal.service.DashboardSearchServiceImpl; -import org.openecomp.portalapp.portal.framework.MockEPUser; import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; -import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java new file mode 100644 index 00000000..0f92bb3e --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulControllerOSTest.java @@ -0,0 +1,198 @@ +/*- + * ============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 + * + * 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.portal.controller; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.EPLoginService; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EPSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.slf4j.MDC; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ MDC.class, EPSystemProperties.class , EcompPortalUtils.class}) +public class ExternalAppsRestfulControllerOSTest { + + + @InjectMocks + ExternalAppsRestfulController externalAppsRestfulController = new ExternalAppsRestfulController(); + @Mock + FunctionalMenuService functionalMenuService; + + @Mock + EPLoginService epLoginService; + + @Mock + AdminRolesService adminRolesService; + + + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + + MockEPUser mockUser = new MockEPUser(); + + @Test + public void getFavoritesForUserTest() throws Exception + { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + List favorites = new ArrayList(); + FavoritesFunctionalMenuItemJson favoritesFunctionalMenuItemJson = new FavoritesFunctionalMenuItemJson(); + favorites.add(favoritesFunctionalMenuItemJson); + Mockito.when(mockedRequest.getHeader(EPCommonSystemProperties.MDC_LOGIN_ID)).thenReturn("Login_URL"); + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd("Login_URL")).thenReturn(epUser); + Mockito.when(functionalMenuService.getFavoriteItems(epUser.getId())).thenReturn(favorites); + List actaulFavorites = externalAppsRestfulController + .getFavoritesForUser(mockedRequest, mockedResponse); + assertEquals(actaulFavorites.size(), 1); + } + + @Test + public void getFunctionalMenuItemsForUserIfSuperAdminTest() throws Exception { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + List expectedList = new ArrayList(); + FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem(); + expectedList.add(functionalMenuItem); + Mockito.when(mockedRequest.getHeader("LoginId")).thenReturn("guestT"); + Mockito.when(adminRolesService.isSuperAdmin(epUser)).thenReturn(true); + Mockito.when(functionalMenuService.getFunctionalMenuItems()).thenReturn(expectedList); + List actualList = externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + assertNull(actualList.get(0).menuId); + } + + @Test(expected = Exception.class) + public void getFunctionalMenuItemsForUserIfUSerNullTest() throws + Exception + { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(EcompPortalUtils.class); + PowerMockito.mockStatic(MDC.class); + EPUser epUser = null; + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + } + + @Test + public void getFunctionalMenuItemsForUserTest() throws Exception { + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + EPUser epUser = mockUser.mockEPUser(); + epUser.setId((long) 1); + epUser.setLoginId("guestT"); + String loginId = "guestT"; + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + Mockito.when(epLoginService.findUserWithoutPwd(loginId)).thenReturn(epUser); + List expectedList = new ArrayList(); + FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem(); + expectedList.add(functionalMenuItem); + Mockito.when(mockedRequest.getHeader("LoginId")).thenReturn("guestT"); + Mockito.when(adminRolesService.isSuperAdmin(epUser)).thenReturn(false); + Mockito.when(functionalMenuService.getFunctionalMenuItemsForUser(epUser.getOrgUserId())) + .thenReturn(expectedList); + List actualList = externalAppsRestfulController.getFunctionalMenuItemsForUser(mockedRequest, + mockedResponse); + assertNull(actualList.get(0).menuId); + } + + @Test(expected = Exception.class) + public void getFavoritesForUserIfUserNullTest() throws Exception { + List favorites = new ArrayList(); + FavoritesFunctionalMenuItemJson favoritesFunctionalMenuItemJson = new FavoritesFunctionalMenuItemJson(); + favorites.add(favoritesFunctionalMenuItemJson); + PowerMockito.mockStatic(EPSystemProperties.class); + PowerMockito.mockStatic(MDC.class); + Mockito.when(mockedRequest.getHeader(EPSystemProperties.MDC_LOGIN_ID)).thenReturn("Login_URL"); + Mockito.when(MDC.get(EPSystemProperties.PARTNER_NAME)).thenReturn("Test"); + EPUser epUser = null; + externalAppsRestfulController.getFavoritesForUser(mockedRequest, mockedResponse); + } + + +} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java index 968f5811..a02e1b2f 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.controller; import static org.junit.Assert.*; @@ -70,7 +107,7 @@ public class LoginControllerTest { PowerMockito.mockStatic(SystemProperties.class); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC"); ModelAndView result = loginController.login(mockedRequest); - assertEquals(result.getViewName(),"openIdLogin") ; + assertEquals(result.getViewName(),"login") ; } @Test diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java index 06dfc902..46218302 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.controller; import static org.junit.Assert.assertEquals; @@ -57,6 +94,8 @@ public class ONAPLoginControllerTest { ModelAndView actualModelandView = null; Mockito.when(loginStrategy.doLogin(mockedRequest, mockedResponse)).thenReturn(expectedModelandView); actualModelandView= oNAPLoginController.doLogin(mockedRequest, mockedResponse); + oNAPLoginController.setViewName("test"); + assertEquals("test", oNAPLoginController.getViewName()); assertEquals(actualModelandView,expectedModelandView); } diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java index c15f366a..b7399fbe 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java @@ -1,6 +1,45 @@ +/*- + * ============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 + * + * 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.portal.controller; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; + +import java.security.Principal; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -8,15 +47,19 @@ import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.controller.ONAPWelcomeController; import org.openecomp.portalapp.portal.framework.MockitoTestSuite; +import org.springframework.web.servlet.ModelAndView; public class ONAPWelcomeControllerTest { @InjectMocks ONAPWelcomeController oNAPWelcomeController = new ONAPWelcomeController(); + @Mock + Principal p; @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -43,5 +86,14 @@ public class ONAPWelcomeControllerTest { { assertEquals(oNAPWelcomeController.user(null), "oid-user"); } - + + @Test + public void loginTest() + { + ModelAndView expectedView = new ModelAndView(); + expectedView.setViewName("openIdLogin"); + ModelAndView md = oNAPWelcomeController.login(p); + System.out.println(md.getViewName()); + assertEquals(md.getViewName(), expectedView.getViewName()); + } } diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java index 65925977..aa7cb46a 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java @@ -1,4 +1,41 @@ -/*package org.openecomp.portalapp.portal.controller; +/*- + * ============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 + * + * 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.portal.controller; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -17,14 +54,15 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPRole; import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.framework.MockEPUser; +import org.openecomp.portalapp.portal.framework.MockitoTestSuite; import org.openecomp.portalapp.portal.service.AdminRolesService; import org.openecomp.portalapp.portal.service.AdminRolesServiceImpl; import org.openecomp.portalapp.portal.service.PortalAdminService; import org.openecomp.portalapp.portal.service.PortalAdminServiceImpl; -import org.openecomp.portalapp.portal.test.core.MockEPUser; import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.PortalAdmin; import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.test.framework.MockitoTestSuite; import org.openecomp.portalapp.util.EPUserUtils; import org.openecomp.portalsdk.core.service.AuditService; import org.openecomp.portalsdk.core.service.AuditServiceImpl; @@ -69,7 +107,7 @@ public class PortalAdminControllerOSTest { EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); - String userInfo = "1-test"; + Long userInfo = (long) 12; assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse)); } @@ -85,11 +123,11 @@ public class PortalAdminControllerOSTest { expectedFieldValidator.setFields(null); expectedFieldValidator.setErrorCode(null); FieldsValidator actualFieldValidator = new FieldsValidator(); - String userInfo = "1-test"; + Long userInfo = (long) 12; Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); - Mockito.when(portalAdminService.deletePortalAdmin((long) 1)).thenReturn(expectedFieldValidator); + Mockito.when(portalAdminService.deletePortalAdmin((long) 12)).thenReturn(expectedFieldValidator); actualFieldValidator = portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse); - assertEquals(actualFieldValidator,expectedFieldValidator); + assertEquals(actualFieldValidator,expectedFieldValidator); } @@ -99,7 +137,7 @@ public class PortalAdminControllerOSTest { EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); - String userInfo = ""; + Long userInfo = null; assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse)); } @@ -138,5 +176,66 @@ public class PortalAdminControllerOSTest { List actualRoleList = portalAdminController.getRolesByApp(mockedRequest, appId, mockedResponse); assertEquals(actualRoleList,expectedRoleList); } + + @Test + public void createPortalAdminIfUserNullTest() + { + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(null); + assertNull(portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse)); + } + + + @Test + public void createPortalAdminIfUserIsSuperAdminTest() + { + + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + FieldsValidator expectedFieldValidator = new FieldsValidator(); + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(null); + expectedFieldValidator.setErrorCode(null); + FieldsValidator actualFieldValidator = new FieldsValidator(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(portalAdminService.createPortalAdmin("guestT")).thenReturn(expectedFieldValidator); + actualFieldValidator = portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse); + assertEquals(actualFieldValidator,expectedFieldValidator); + } + + @Test + public void createPortalAdminIfUserIsNotSuperAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + assertNull(portalAdminController.createPortalAdmin(mockedRequest, "guestT", mockedResponse)); + } + + @Test + public void getPortalAdminsIfUserNullTest() + { + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(null); + assertNull(portalAdminController.getPortalAdmins(mockedRequest, mockedResponse)); + } + + @Test + public void getPortalAdminsIfUserAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List portalAdmins = new ArrayList<>(); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(portalAdminService.getPortalAdmins()).thenReturn(portalAdmins); + List actualortalAdmins = portalAdminController.getPortalAdmins(mockedRequest, mockedResponse); + assertEquals(actualortalAdmins,portalAdmins); + } + + @Test + public void getPortalAdminIfUserIsNotSuperAdminTest() + { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + assertNull(portalAdminController.getPortalAdmins(mockedRequest, mockedResponse)); + } } -*/ \ No newline at end of file diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java index c3ca2430..f4196db8 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java index 5bb7a456..e4061785 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java index 9344150f..1c849420 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.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.portal.controller; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java index d132ccf3..d38b21a0 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.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.portal.framework; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java index 3ff837dc..529dd5ae 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.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.portal.framework; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java index f87f5bd1..651f7f61 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.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.portal.listener; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java index d38525b3..f3218a70 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java @@ -1,6 +1,44 @@ +/*- + * ============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 + * + * 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.portal.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -8,7 +46,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.openecomp.portalsdk.core.util.SystemProperties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,10 +55,10 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.portalapp.portal.domain.EPApp; import org.openecomp.portalapp.portal.framework.MockitoTestSuite; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; import org.openecomp.portalapp.service.RemoteWebServiceCallServiceImpl; import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java index fd6578f8..71671da3 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java @@ -1,3 +1,40 @@ +/*- + * ============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 + * + * 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.portal.service; import static org.junit.Assert.*; diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java deleted file mode 100644 index 63a710eb..00000000 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java +++ /dev/null @@ -1,63 +0,0 @@ -//package org.openecomp.portalapp.portal.service; -// -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpServletResponse; -// -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.mockito.InjectMocks; -//import org.mockito.Mock; -//import org.mockito.Mockito; -//import org.mockito.MockitoAnnotations; -//import org.openecomp.portalapp.portal.framework.MockitoTestSuite; -//import org.openecomp.portalapp.portal.utils.EPSystemProperties; -//import org.openecomp.portalsdk.core.service.DataAccessService; -//import org.openecomp.portalsdk.core.util.SystemProperties; -//import org.powermock.api.mockito.PowerMockito; -// -//import java.io.BufferedReader; -//import java.io.IOException; -//import java.io.InputStreamReader; -//import java.io.UnsupportedEncodingException; -//import java.net.HttpURLConnection; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ SystemProperties.class , EPSystemProperties.class , SystemProperties.class}) -//public class UserServiceImplTest { -// -// -// @InjectMocks -// UserServiceImpl userServiceImpl = new UserServiceImpl(); -// -// @Mock -// DataAccessService dataAccessService; -// -// @Mock -// HttpURLConnection con; -// -// @Before -// public void setup() { -// MockitoAnnotations.initMocks(this); -// } -// -// MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); -// -// HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); -// HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); -// -// @Test -// public void getUserByUserIdTest() throws UnsupportedEncodingException, IOException -// { -// BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); -// PowerMockito.mockStatic(SystemProperties.class); -// PowerMockito.mockStatic(EPSystemProperties.class); -// Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC"); -// Mockito.when(EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER)).thenReturn("http://www.google.com"); -// Mockito.when(new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"))).thenReturn(reader).thenReturn(reader); -// userServiceImpl.getUserByUserId("guestT"); -// } -//} diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java index b1dd853f..d9a54360 100644 --- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.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.portal.utils; -- cgit 1.2.3-korg