From b54df0ddd0c6a0372327c5aa3668e5a6458fcd64 Mon Sep 17 00:00:00 2001 From: st782s Date: Thu, 4 May 2017 07:48:42 -0400 Subject: [PATCH] [PORTAL-7] Rebase This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8 Signed-off-by: st782s --- .idea/misc.xml | 19 - .idea/modules.xml | 8 - .idea/portal.iml | 9 - .idea/vcs.xml | 6 - ecomp-portal-BE-common-test/.classpath | 31 + ecomp-portal-BE-common-test/.gitignore | 4 + ecomp-portal-BE-common-test/.project | 23 + .../.settings/org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.jdt.core.prefs | 5 + ecomp-portal-BE-common-test/README.md | 28 + .../license/licenses.properties | 1 + .../license/my_license/header.txt | 11 + .../license/my_license/license.txt | 4 + ecomp-portal-BE-common-test/pom.xml | 151 + .../test/controller/AppCatalogControllerTest.java | 264 + .../controller/AppContactUsControllerTest.java | 281 + .../controller/FunctionalMenuControllerTest.java | 190 + .../controller/UserNotificationControllerTest.java | 265 + .../test/controller/UserRolesControllerTest.java | 131 + .../portalapp/portal/test/core/MockEPUser.java | 86 + .../portal/test/core/PopulateSampleTestData.java | 66 + .../portal/test/core/RemoveSampleTestData.java | 66 + .../portal/test/core/RestURLsTestSuite.java | 329 + .../ApplicationCommonContextTestSuite.java | 175 + .../portal/test/framework/MockitoTestSuite.java | 70 + .../service/FunctionalMenuServiceImplTest.java | 88 + .../src/main/resources/PopulateTestData.sql | 28 + .../src/main/resources/RemoveTestData.sql | 27 + ecomp-portal-BE-common/.gitignore | 5 + ecomp-portal-BE-common/license/licenses.properties | 1 + .../license/my_license/header.txt | 11 + .../license/my_license/license.txt | 4 + ecomp-portal-BE-common/pom.xml | 666 + .../src/main/java/jarutil/ExtractJar.java | 204 + .../openecomp/portalapp/command/EPLoginBean.java | 186 + .../portalapp/command/PostSearchBean.java | 373 + .../openecomp/portalapp/config/SwaggerConfig.java | 58 + .../portalapp/config/SwaggerMVCConfig.java | 37 + .../controller/EPFusionBaseController.java | 106 + .../controller/EPRestrictedBaseController.java | 52 + .../EPRestrictedRESTfulBaseController.java | 54 + .../controller/EPUnRestrictedBaseController.java | 42 + .../sessionmgt/SessionCommunicationController.java | 72 + .../controller/RolesApprovalSystemController.java | 143 + .../model/ExternalSystemRoleApproval.java | 41 + .../model/ExternalSystemUser.java | 74 + .../portalapp/lm/FusionLicenseManagerImpl.java | 88 + .../portalapp/lm/LicenseableClassImpl.java | 62 + .../java/org/openecomp/portalapp/model/Result.java | 37 + .../portal/controller/AppCatalogController.java | 124 + .../portal/controller/AppContactUsController.java | 224 + .../portal/controller/AppsController.java | 670 + .../controller/AppsControllerExternalRequest.java | 374 + .../portal/controller/AuditLogController.java | 106 + .../controller/BEPropertyReaderController.java | 46 + .../controller/BasicAuthAccountController.java | 141 + .../controller/BasicAuthenticationController.java | 28 + .../portal/controller/CommonWidgetController.java | 79 + .../portal/controller/ConsulClientController.java | 90 + .../portal/controller/DashboardController.java | 385 + .../DashboardSearchResultController.java | 243 + .../controller/ExternalAppsRestfulController.java | 206 + .../controller/FunctionalMenuController.java | 555 + .../portal/controller/GetAccessController.java | 73 + .../portal/controller/HealthCheckController.java | 235 + .../portal/controller/ManifestController.java | 90 + .../portal/controller/MicroserviceController.java | 141 + .../controller/MicroserviceProxyController.java | 108 + .../portal/controller/PortalAdminController.java | 200 + .../portal/controller/RoleManageController.java | 166 + .../controller/SharedContextRestController.java | 343 + .../portal/controller/TicketEventController.java | 179 + .../controller/UserNotificationController.java | 216 + .../portal/controller/UserRolesController.java | 435 + .../controller/WebAnalyticsExtAppController.java | 157 + .../controller/WidgetsCatalogController.java | 376 + .../controller/WidgetsCatalogMarkupController.java | 83 + .../portalapp/portal/domain/AdminUserApp.java | 88 + .../portal/domain/AdminUserApplications.java | 96 + .../org/openecomp/portalapp/portal/domain/App.java | 62 + .../portalapp/portal/domain/AppContactUs.java | 86 + .../portal/domain/AppIdAndNameTransportModel.java | 63 + .../portalapp/portal/domain/AppsResponse.java | 76 + .../portalapp/portal/domain/BEProperty.java | 43 + .../portal/domain/BasicAuthCredentials.java | 95 + .../openecomp/portalapp/portal/domain/EPApp.java | 292 + .../portalapp/portal/domain/EPEndpoint.java | 37 + .../portalapp/portal/domain/EPEndpointAccount.java | 46 + .../openecomp/portalapp/portal/domain/EPRole.java | 202 + .../openecomp/portalapp/portal/domain/EPUser.java | 650 + .../portalapp/portal/domain/EPUserApp.java | 119 + .../portal/domain/EPUserAppCatalogRoles.java | 92 + .../portal/domain/EPUserAppRolesRequest.java | 87 + .../portal/domain/EPUserAppRolesRequestDetail.java | 52 + .../domain/EPUserAppsManualSortPreference.java | 50 + .../portal/domain/EPUserAppsSortPreference.java | 44 + .../portal/domain/EPUserNotification.java | 57 + .../domain/EPWidgetsManualSortPreference.java | 70 + .../portalapp/portal/domain/EcompApp.java | 146 + .../portalapp/portal/domain/EcompAppRole.java | 80 + .../portalapp/portal/domain/EcompAppRoleId.java | 83 + .../portalapp/portal/domain/EcompAuditLog.java | 61 + .../portalapp/portal/domain/EpUserAppRoles.java | 63 + .../portal/domain/ExternalSystemAccess.java | 49 + .../portal/domain/FunctionalMenuItemWithAppID.java | 96 + .../portalapp/portal/domain/GetAccessResult.java | 114 + .../portalapp/portal/domain/GetAccessResultId.java | 64 + .../portalapp/portal/domain/MicroserviceData.java | 146 + .../portal/domain/MicroserviceParameter.java | 82 + .../portal/domain/PersUserAppSelection.java | 78 + .../portal/domain/PersUserWidgetSelection.java | 81 + .../openecomp/portalapp/portal/domain/RoleApp.java | 114 + .../portalapp/portal/domain/SharedContext.java | 161 + .../portalapp/portal/domain/UserIdRoleId.java | 77 + .../portalapp/portal/domain/UserRole.java | 91 + .../portalapp/portal/domain/UserRoles.java | 113 + .../openecomp/portalapp/portal/domain/Widget.java | 105 + .../portalapp/portal/domain/WidgetCatalog.java | 109 + .../portal/domain/WidgetCatalogParameter.java | 90 + .../portal/domain/WidgetParameterResult.java | 70 + .../portal/domain/WidgetServiceHeaders.java | 54 + .../portal/ecomp/model/AppCatalogItem.java | 249 + .../ecomp/model/AppCategoryFunctionsItem.java | 140 + .../portal/ecomp/model/AppContactUsItem.java | 171 + .../portal/ecomp/model/CommonWidgetsEnum.java | 36 + .../portal/ecomp/model/PortalRestResponse.java | 101 + .../portal/ecomp/model/PortalRestStatusEnum.java | 36 + .../portal/ecomp/model/SearchResultItem.java | 86 + .../exceptions/NoHealthyServiceException.java | 36 + .../interceptor/PortalResourceInterceptor.java | 335 + .../portalapp/portal/listener/HealthMonitor.java | 355 + .../portal/listener/UserContextListener.java | 51 + .../portal/listener/UserSessionListener.java | 126 + .../portalapp/portal/logging/aop/EPAuditLog.java | 31 + .../portal/logging/aop/EPEELFLoggerAdvice.java | 371 + .../portalapp/portal/logging/aop/EPMetricsLog.java | 31 + .../logging/format/ApplicationCodes.properties | 141 + .../portal/logging/format/EPAppMessagesEnum.java | 260 + .../portal/logging/format/EPErrorCodesEnum.java | 95 + .../portalapp/portal/logging/logic/EPLogUtil.java | 270 + .../portal/service/AdminRolesService.java | 56 + .../portal/service/AdminRolesServiceImpl.java | 329 + .../portal/service/AppContactUsService.java | 55 + .../portal/service/AppContactUsServiceImpl.java | 189 + .../service/ApplicationsRestClientService.java | 53 + .../service/ApplicationsRestClientServiceImpl.java | 411 + .../portalapp/portal/service/AppsCacheService.java | 42 + .../portal/service/AppsCacheServiceImple.java | 136 + .../portal/service/BasicAuthAccountService.java | 47 + .../service/BasicAuthAccountServiceImpl.java | 205 + .../BasicAuthenticationCredentialService.java | 35 + .../BasicAuthenticationCredentialServiceImpl.java | 81 + .../portal/service/ConsulHealthService.java | 32 + .../portal/service/ConsulHealthServiceImpl.java | 91 + .../portal/service/DashboardSearchService.java | 37 + .../portal/service/DashboardSearchServiceImpl.java | 100 + .../portal/service/EPAppCommonServiceImpl.java | 1368 + .../portalapp/portal/service/EPAppService.java | 213 + .../portalapp/portal/service/EPAuditService.java | 27 + .../portal/service/EPAuditServiceImpl.java | 96 + .../portalapp/portal/service/EPLdapService.java | 31 + .../portal/service/EPLdapServiceImpl.java | 288 + .../portal/service/EPLeftMenuService.java | 44 + .../portal/service/EPLeftMenuServiceImpl.java | 195 + .../portalapp/portal/service/EPLoginService.java | 70 + .../portal/service/EPLoginServiceImpl.java | 234 + .../portalapp/portal/service/EPRoleService.java | 37 + .../portal/service/EPRoleServiceImpl.java | 171 + .../portal/service/FunctionalMenuService.java | 58 + .../portal/service/FunctionalMenuServiceImpl.java | 963 + .../portalapp/portal/service/GetAccessService.java | 33 + .../portal/service/GetAccessServiceImpl.java | 61 + .../portalapp/portal/service/ManifestService.java | 33 + .../portal/service/ManifestServiceImpl.java | 62 + .../portal/service/MicroserviceProxyService.java | 59 + .../service/MicroserviceProxyServiceImpl.java | 222 + .../portal/service/MicroserviceService.java | 86 + .../portal/service/MicroserviceServiceImpl.java | 212 + .../portal/service/PersUserAppService.java | 42 + .../portal/service/PersUserAppServiceImpl.java | 141 + .../portal/service/PersUserWidgetService.java | 41 + .../portal/service/PersUserWidgetServiceImpl.java | 81 + .../portal/service/PortalAdminService.java | 31 + .../portal/service/PortalAdminServiceImpl.java | 210 + .../portalapp/portal/service/SearchService.java | 30 + .../portal/service/SearchServiceImpl.java | 175 + .../portal/service/SharedContextService.java | 98 + .../portal/service/SharedContextServiceImpl.java | 177 + .../portal/service/UserNotificationService.java | 55 + .../service/UserNotificationServiceImpl.java | 211 + .../portalapp/portal/service/UserRolesService.java | 67 + .../portalapp/portal/service/UserService.java | 34 + .../portalapp/portal/service/UserServiceImpl.java | 260 + .../portal/service/WidgetParameterService.java | 64 + .../portal/service/WidgetParameterServiceImpl.java | 92 + .../portalapp/portal/service/WidgetService.java | 36 + .../portal/service/WidgetServiceImpl.java | 276 + .../portal/transport/AllAppsWithRolesForUser.java | 40 + .../portalapp/portal/transport/Analytics.java | 66 + .../transport/AppCatalogPersonalization.java | 94 + .../portal/transport/AppNameIdIsAdmin.java | 114 + .../portal/transport/AppWithRolesForUser.java | 73 + .../portal/transport/AppsListWithAdminRole.java | 86 + .../transport/BusinessCardApplicationRole.java | 108 + .../BusinessCardApplicationRolesList.java | 86 + .../portalapp/portal/transport/CommonWidget.java | 139 + .../portal/transport/CommonWidgetMeta.java | 50 + .../portal/transport/EPAppsManualPreference.java | 114 + .../portal/transport/EPAppsSortPreference.java | 47 + .../transport/EPDeleteAppsManualSortPref.java | 51 + .../portal/transport/EPWidgetsSortPreference.java | 92 + .../portal/transport/EpNotificationItem.java | 328 + .../portal/transport/EpNotificationItemExtVO.java | 119 + .../portal/transport/EpNotificationItemVO.java | 191 + .../portal/transport/EpRoleNotificationItem.java | 90 + .../portalapp/portal/transport/EventWidget.java | 138 + .../portal/transport/EventWidgetMeta.java | 51 + .../transport/FavoritesFunctionalMenuItem.java | 45 + .../transport/FavoritesFunctionalMenuItemJson.java | 57 + .../portal/transport/FieldsValidator.java | 125 + .../portal/transport/FunctionalMenuItem.java | 100 + .../transport/FunctionalMenuItemWithRoles.java | 60 + .../portal/transport/FunctionalMenuRole.java | 115 + .../portalapp/portal/transport/LocalRole.java | 42 + .../portalapp/portal/transport/OnboardingApp.java | 99 + .../portal/transport/OnboardingWidget.java | 65 + .../portalapp/portal/transport/PortalAdmin.java | 53 + .../portal/transport/PortalAdminUserRole.java | 48 + .../portalapp/portal/transport/RemoteRole.java | 44 + .../portal/transport/RemoteUserWithRoles.java | 197 + .../portal/transport/RoleInAppForUser.java | 105 + .../portal/transport/RolesInAppForUser.java | 33 + .../portal/transport/UserApplicationRoles.java | 86 + .../portal/transport/UserWithNameSurnameTitle.java | 39 + .../transport/WidgetCatalogPersonalization.java | 57 + .../portalapp/portal/ueb/EPUebHelper.java | 217 + .../portalapp/portal/ueb/EPUebMsgTypes.java | 27 + .../portal/utils/CustomLoggingFilter.java | 54 + .../portal/utils/EPCommonSystemProperties.java | 64 + .../portalapp/portal/utils/EcompPortalUtils.java | 331 + .../portalapp/portal/utils/EcompVersion.java | 33 + .../portalapp/portal/utils/HashMapFromList.java | 99 + .../portalapp/portal/utils/ParallelExecutor.java | 83 + .../portalapp/portal/utils/PortalConstants.java | 26 + .../portalapp/service/AdminAuthExtension.java | 36 + .../portalapp/service/EPProfileService.java | 36 + .../portalapp/service/EPProfileServiceImpl.java | 77 + .../service/RemoteWebServiceCallService.java | 48 + .../service/sessionmgt/CoreTimeoutHandler.java | 166 + .../service/sessionmgt/ManageService.java | 101 + .../service/sessionmgt/SessionCommunication.java | 271 + .../service/sessionmgt/TimeoutHandler.java | 252 + .../org/openecomp/portalapp/util/EPUserUtils.java | 407 + .../portalapp/util/SessionCookieUtil.java | 129 + .../org/openecomp/portalapp/util/SystemType.java | 26 + .../core/lm/FusionLicenseManagerUtils.java | 75 + .../src/main/webapp}/META-INF/MANIFEST.MF | 0 .../src/main/webapp/WEB-INF/defs/definitions.xml | 38 + .../webapp/WEB-INF/fusion/defs/definitions.xml | 203 + .../src/main/webapp}/WEB-INF/fusion/jsp/.gitignore | 0 .../src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml | 1595 + .../main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml | 335 + .../webapp/WEB-INF/fusion/orm/Workflow.hbm.xml | 48 + .../src/main/webapp/WEB-INF/jsp/error.jsp | 20 + .../src/main/webapp/WEB-INF/jsp/index.jsp | 21 + .../src/main/webapp/WEB-INF/jsp/login.jsp | 120 + .../src/main/webapp/WEB-INF/jsp/login_external.jsp | 162 + .../static/ebz/angular_js/angular-sanitize.js | 0 .../WEB-INF}/static/ebz/angular_js/angular.js | 0 .../webapp/WEB-INF}/static/ebz/angular_js/app.js | 0 .../static/ebz/angular_js/att-abs-tpls-1.2.51.js | 0 .../static/ebz/angular_js/attHeaderSnippet.js | 0 .../WEB-INF/static/ebz/angular_js/attHeader_new.js | 1375 + .../WEB-INF}/static/ebz/angular_js/att_abs_tpls.js | 0 .../static/ebz/angular_js/checklist-model.js | 0 .../static/ebz/angular_js/checklist-model.min.js | 0 .../static/ebz/angular_js/d7100892.modernizr.js | 0 .../static/ebz/angular_js/ebiz_keepalive.js | 0 .../WEB-INF}/static/ebz/angular_js/footer.js | 0 .../WEB-INF}/static/ebz/angular_js/footer_new.js | 0 .../WEB-INF}/static/ebz/angular_js/gestures.js | 0 .../WEB-INF}/static/ebz/angular_js/ng_base.js | 0 .../static/ebz/angular_js/ui-charts-tpls.js | 0 .../WEB-INF}/static/fusion/images/login_button.gif | Bin .../webapp/WEB-INF}/static/js/jquery-1.10.2.js | 0 .../main/webapp/WEB-INF}/static/js/jquery-ui.js | 0 .../webapp/WEB-INF}/static/js/jquery.mask.min.js | 0 .../src/main/webapp/WEB-INF/web.xml | 56 + .../src/main/webapp}/images/cache/README.txt | 0 ecomp-portal-BE-common/src/main/webapp/index.jsp | 34 + .../external/angular-1.5}/angular-animate.js | 0 .../external/angular-1.5}/angular-animate.min.js | 0 .../fusion/external/angular-1.5}/angular-aria.js | 0 .../external/angular-1.5}/angular-aria.min.js | 0 .../external/angular-1.5}/angular-cookies.js | 0 .../external/angular-1.5}/angular-cookies.min.js | 0 .../fusion/external/angular-1.5}/angular-csp.css | 0 .../fusion/external/angular-1.5/angular-loader.js | 484 + .../external/angular-1.5/angular-loader.min.js | 10 + .../external/angular-1.5/angular-message-format.js | 980 + .../angular-1.5/angular-message-format.min.js | 26 + .../external/angular-1.5/angular-messages.js | 687 + .../external/angular-1.5/angular-messages.min.js | 12 + .../fusion/external/angular-1.5/angular-mocks.js | 2842 ++ .../external/angular-1.5}/angular-resource.js | 0 .../external/angular-1.5}/angular-resource.min.js | 0 .../fusion/external/angular-1.5}/angular-route.js | 0 .../external/angular-1.5}/angular-route.min.js | 0 .../external/angular-1.5}/angular-sanitize.js | 0 .../external/angular-1.5}/angular-sanitize.min.js | 0 .../external/angular-1.5/angular-scenario.js | 41849 +++++++++++++++++ .../fusion/external/angular-1.5/angular-touch.js | 729 + .../external/angular-1.5/angular-touch.min.js | 14 + .../app/fusion/external/angular-1.5}/angular.js | 0 .../fusion/external/angular-1.5}/angular.min.js | 0 .../app/fusion/external/angular-1.5/errors.json | 1 + .../app/fusion/external/angular-1.5/version.json | 1 + .../app/fusion/external/angular-1.5/version.txt | 1 + .../angular-ui/ui-bootstrap-tpls-1.1.2.min.js | 10 + .../angular-ui/ui-bootstrap-tpls-1.2.4.min.js | 10 + .../angular-ui/ui-sortable/v0.13.4/sortable.min.js | 8 + .../app/fusion/external/utils/js/browserCheck.js | 5 + .../static/ebz/angular_js/angular-sanitize.js | 647 + .../main/webapp/static/ebz/angular_js/angular.js | 22024 +++++++++ .../src/main/webapp/static/ebz/angular_js/app.js | 3 + .../webapp/static/ebz/angular_js/ebiz_keepalive.js | 8 + .../main/webapp/static/ebz/angular_js/gestures.js | 1495 + .../webapp}/static/fusion/images/ecomp-login.jpg | Bin .../src/main/webapp/static/fusion/images/ecomp.png | Bin 0 -> 107597 bytes .../webapp}/static/fusion/images/ecomp_trans.png | Bin .../src/main/webapp/static/js/jquery-1.10.2.js | 9789 ++++ .../src/main/webapp/static/js/jquery-ui.js | 16617 +++++++ .../src/main/webapp/static/js/jquery.mask.min.js | 12 + .../portal/controller/SharedContextRestClient.java | 281 + .../SharedContextRestControllerTest.java | 127 + .../controller/SharedContextTestProperties.java | 81 + .../controller/shared-context-test.properties | 28 + .../portal/listener/HealthMonitorTest.java | 36 + .../portal/utils/EcompPortalUtilsTest.java | 37 + {ecomp-portal-BE => ecomp-portal-BE-os}/.gitignore | 0 ecomp-portal-BE-os/README.md | 23 + .../distribution.xml | 0 .../sql scripts/Apps_Users_OnBoarding_Script.sql | 303 + .../EcompPortalDDLMySql_1610_Complete_OS.sql | 1499 + .../EcompPortalDMLMySql_1610_Complete_OS.sql | 225 + ecomp-portal-BE-os/license/licenses.properties | 1 + ecomp-portal-BE-os/license/my_license/header.txt | 11 + ecomp-portal-BE-os/license/my_license/license.txt | 4 + ecomp-portal-BE-os/pom.xml | 707 + .../resources/META-INF/MANIFEST.MF | 0 .../portalapp/authentication/LoginStrategy.java | 27 + .../authentication/OpenIdConnectLoginStrategy.java | 107 + .../authentication/SimpleLoginStrategy.java | 114 + .../portalapp/conf/ExternalAppConfig.java | 316 + .../portalapp/conf/ExternalAppInitializer.java | 60 + .../portalapp/conf/HibernateMappingLocations.java | 43 + .../controller/ECOMPLogoutController.java | 114 + .../portalapp/controller/LoginController.java | 397 + .../portalapp/controller/LoginService.java | 36 + .../portalapp/controller/ONAPLoginController.java | 81 + .../controller/ONAPWelcomeController.java | 84 + .../controller/OpenCollaborationController.java | 23 + .../portalapp/controller/PeerBroadcastSocket.java | 106 + .../portal/controller/AppsOSController.java | 116 + .../DashboardSearchResultController.java | 243 + .../controller/ExternalAppsRestfulController.java | 129 + .../portal/controller/PortalAdminController.java | 117 + .../interceptor/SessionTimeoutInterceptor.java | 101 + .../portal/logging/aop/EPEELFLoggerAspect.java | 204 + .../service/ApplicationsRestClientService.java | 28 + .../service/ApplicationsRestClientServiceImpl.java | 267 + .../portalapp/portal/service/AppsCacheService.java | 40 + .../portal/service/AppsCacheServiceImple.java | 104 + .../portalapp/portal/service/EPAppServiceImpl.java | 71 + .../portalapp/portal/service/SearchService.java | 40 + .../portal/service/SearchServiceImpl.java | 192 + .../portalapp/portal/service/UserRolesService.java | 58 + .../portal/service/UserRolesServiceImpl.java | 726 + .../portalapp/portal/service/UserService.java | 34 + .../portalapp/portal/service/UserServiceImpl.java | 260 + .../portalapp/portal/transport/OnboardingApp.java | 83 + .../portalapp/portal/ueb/EPUebHelper.java | 218 + .../portalapp/portal/ueb/EPUebMsgTypes.java | 27 + .../portalapp/portal/utils/EPSystemProperties.java | 42 + .../org/openecomp/portalapp/scheduler/LogJob.java | 45 + .../openecomp/portalapp/scheduler/LogRegistry.java | 57 + .../openecomp/portalapp/scheduler/Register.java | 86 + .../portalapp/scheduler/RegistryAdapter.java | 100 + .../portalapp/scheduler/SessionMgtRegistry.java | 89 + .../service/RemoteWebServiceCallServiceImpl.java | 104 + .../uebhandler/FunctionalMenuHandler.java | 126 + .../portalapp/uebhandler/InitUebHandler.java | 75 + .../portalapp/uebhandler/MainUebHandler.java | 115 + .../uebhandler/WidgetNotificationHandler.java | 93 + .../src/main/resources/cache.ccf | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/openid-connect.properties | 0 .../src/main/resources/openid-keystore.jwks | 0 .../src/main/resources/portal.properties | 0 .../src/main/webapp/META-INF/MANIFEST.MF | 3 + .../src/main/webapp}/WEB-INF/conf/cache.ccf | 0 .../main/webapp}/WEB-INF/conf/quartz.properties | 0 .../main/webapp}/WEB-INF/conf/raptor.properties | 0 .../WEB-INF/conf/raptor_app_fusion.properties | 0 .../WEB-INF/conf/raptor_db_fusion.properties | 0 .../webapp}/WEB-INF/conf/raptor_pdf.properties | 0 .../src/main/webapp}/WEB-INF/conf/sql.properties | 0 .../src/main/webapp/WEB-INF/conf/system.properties | 118 + .../src/main/webapp}/WEB-INF/defs/definitions.xml | 0 .../webapp/WEB-INF/fusion/conf/fusion.properties | 83 + .../webapp}/WEB-INF/fusion/defs/definitions.xml | 0 .../src/main/webapp}/WEB-INF/jsp/error.jsp | 0 .../src/main/webapp}/WEB-INF/jsp/index.jsp | 0 .../src/main/webapp/WEB-INF/jsp/login.jsp | 166 + .../src/main/webapp}/WEB-INF/jsp/oid-admin.jsp | 0 .../src/main/webapp}/WEB-INF/jsp/oid-home.jsp | 0 .../src/main/webapp}/WEB-INF/jsp/oid-login.jsp | 0 .../src/main/webapp}/WEB-INF/jsp/oid-user.jsp | 0 .../src/main/webapp}/WEB-INF/jsp/welcome.jsp | 0 .../src/main/webapp}/WEB-INF/oid-context.xml | 0 .../src/main/webapp}/WEB-INF/tags/copyright.tag | 0 .../src/main/webapp}/WEB-INF/tags/footer.tag | 0 .../src/main/webapp}/WEB-INF/tags/header.tag | 0 .../src/main/webapp}/WEB-INF/tags/topbar.tag | 0 .../src/main/webapp}/WEB-INF/web.xml | 0 .../src/main/webapp/images/cache/README.txt | 1 + ecomp-portal-BE-os/src/main/webapp/index.jsp | 41 + .../portal/controller/SharedContextRestClient.java | 280 + .../SharedContextRestControllerTest.java | 125 + .../controller/SharedContextTestProperties.java | 81 + .../controller/shared-context-test.properties | 28 + .../portal/listener/HealthMonitorTest.java | 36 + .../portal/utils/EcompPortalUtilsTest.java | 33 + ecomp-portal-BE/README.md | 7 - .../sql scripts/Apps_Users_OnBoarding_Script.sql | 320 - .../EcompPortalDDLMySql_1610_Complete_OS.sql | 1499 - .../EcompPortalDMLMySql_1610_Complete_OS.sql | 225 - ecomp-portal-BE/pom.xml | 631 - .../portalapp/authentication/LoginStrategy.java | 27 - .../authentication/OpenIdConnectLoginStrategy.java | 91 - .../authentication/SimpleLoginStrategy.java | 101 - .../openecomp/portalapp/command/EPLoginBean.java | 186 - .../portalapp/command/PostSearchBean.java | 373 - .../portalapp/conf/ExternalAppConfig.java | 311 - .../portalapp/conf/ExternalAppInitializer.java | 60 - .../portalapp/conf/HibernateMappingLocations.java | 38 - .../controller/ECOMPLogoutController.java | 112 - .../controller/EPFusionBaseController.java | 106 - .../controller/EPRestrictedBaseController.java | 52 - .../EPRestrictedRESTfulBaseController.java | 54 - .../controller/EPUnRestrictedBaseController.java | 42 - .../portalapp/controller/LoginController.java | 356 - .../portalapp/controller/LoginService.java | 36 - .../controller/OpenCollaborationController.java | 48 - .../portalapp/controller/PeerBroadcastSocket.java | 106 - .../controller/UserProfileController.java | 77 - .../portalapp/controller/WelcomeController.java | 89 - .../sessionmgt/SessionCommunicationController.java | 64 - .../kpidash/controller/KpiDashboardController.java | 268 - .../portalapp/kpidash/model/KpiApiStats.java | 74 - .../kpidash/model/KpiServiceSupported.java | 60 - .../portalapp/kpidash/model/KpiUserStoryStats.java | 107 - .../portalapp/kpidash/model/KpidashProperties.java | 33 - .../kpidash/service/KpiDashboardService.java | 56 - .../kpidash/service/KpiDashboardServiceImpl.java | 180 - .../java/org/openecomp/portalapp/model/Result.java | 37 - .../portal/controller/AppCatalogController.java | 124 - .../portal/controller/AppContactUsController.java | 224 - .../portal/controller/AppsController.java | 470 - .../portal/controller/DashboardController.java | 361 - .../DashboardSearchResultController.java | 243 - .../controller/ExternalAppsRestfulController.java | 128 - .../controller/FunctionalMenuController.java | 436 - .../portal/controller/GetAccessController.java | 70 - .../portal/controller/HealthCheckController.java | 234 - .../portal/controller/ManifestController.java | 93 - .../portal/controller/PortalAdminController.java | 117 - .../controller/SharedContextRestController.java | 335 - .../portal/controller/UserRolesController.java | 336 - .../portal/controller/WidgetsController.java | 134 - .../portalapp/portal/domain/AdminUserApp.java | 88 - .../portal/domain/AdminUserApplications.java | 96 - .../portalapp/portal/domain/AppContactUs.java | 86 - .../portal/domain/AppContactUsTransportModel.java | 84 - .../portal/domain/AppIdAndNameTransportModel.java | 63 - .../portalapp/portal/domain/AppsResponse.java | 76 - .../openecomp/portalapp/portal/domain/EPApp.java | 319 - .../openecomp/portalapp/portal/domain/EPRole.java | 204 - .../openecomp/portalapp/portal/domain/EPUser.java | 602 - .../portalapp/portal/domain/EPUserApp.java | 119 - .../portalapp/portal/domain/EcompApp.java | 143 - .../portalapp/portal/domain/GetAccessResult.java | 70 - .../portalapp/portal/domain/GetAccessResultId.java | 64 - .../portal/domain/PersUserAppSelection.java | 79 - .../portalapp/portal/domain/SharedContext.java | 161 - .../portalapp/portal/domain/UserIdRoleId.java | 77 - .../portalapp/portal/domain/UserRole.java | 91 - .../portalapp/portal/domain/UserRoles.java | 111 - .../openecomp/portalapp/portal/domain/Widget.java | 104 - .../portal/ecomp/model/AppCatalogItem.java | 159 - .../ecomp/model/AppCategoryFunctionsItem.java | 84 - .../portal/ecomp/model/AppContactUsItem.java | 104 - .../portal/ecomp/model/CommonWidgetsEnum.java | 36 - .../portal/ecomp/model/PortalRestResponse.java | 60 - .../portal/ecomp/model/PortalRestStatusEnum.java | 35 - .../portal/ecomp/model/SearchResultItem.java | 92 - .../interceptor/PortalResourceInterceptor.java | 95 - .../interceptor/SessionTimeoutInterceptor.java | 97 - .../portalapp/portal/listener/HealthMonitor.java | 393 - .../portal/listener/UserContextListener.java | 49 - .../portal/listener/UserSessionListener.java | 125 - .../portalapp/portal/logging/aop/EPAuditLog.java | 31 - .../portal/logging/aop/EPEELFLoggerAdvice.java | 341 - .../portal/logging/aop/EPEELFLoggerAspect.java | 204 - .../portalapp/portal/logging/aop/EPMetricsLog.java | 31 - .../logging/format/ApplicationCodes.properties | 141 - .../portal/logging/format/EPAppMessagesEnum.java | 260 - .../portal/logging/format/EPErrorCodesEnum.java | 95 - .../portalapp/portal/logging/logic/EPLogUtil.java | 76 - .../portal/service/AdminRolesService.java | 52 - .../portal/service/AdminRolesServiceImpl.java | 318 - .../portal/service/AppContactUsService.java | 55 - .../portal/service/AppContactUsServiceImpl.java | 178 - .../service/ApplicationsRestClientService.java | 28 - .../service/ApplicationsRestClientServiceImpl.java | 267 - .../portalapp/portal/service/AppsCacheService.java | 40 - .../portal/service/AppsCacheServiceImple.java | 104 - .../portal/service/DashboardSearchService.java | 38 - .../portal/service/DashboardSearchServiceImpl.java | 238 - .../portalapp/portal/service/EPAppService.java | 164 - .../portalapp/portal/service/EPAppServiceImpl.java | 1218 - .../portalapp/portal/service/EPAuditService.java | 26 - .../portal/service/EPAuditServiceImpl.java | 74 - .../portalapp/portal/service/EPLdapService.java | 31 - .../portal/service/EPLdapServiceImpl.java | 287 - .../portalapp/portal/service/EPLoginService.java | 42 - .../portal/service/EPLoginServiceImpl.java | 235 - .../portalapp/portal/service/EPRoleService.java | 32 - .../portal/service/EPRoleServiceImpl.java | 149 - .../portal/service/FunctionalMenuService.java | 50 - .../portal/service/FunctionalMenuServiceImpl.java | 862 - .../portalapp/portal/service/GetAccessService.java | 32 - .../portal/service/GetAccessServiceImpl.java | 50 - .../portalapp/portal/service/ManifestService.java | 34 - .../portal/service/ManifestServiceImpl.java | 65 - .../portal/service/PersUserAppService.java | 24 - .../portal/service/PersUserAppServiceImpl.java | 117 - .../portal/service/PortalAdminService.java | 31 - .../portal/service/PortalAdminServiceImpl.java | 179 - .../portalapp/portal/service/SearchService.java | 38 - .../portal/service/SearchServiceImpl.java | 188 - .../portal/service/SharedContextService.java | 98 - .../portal/service/SharedContextServiceImpl.java | 173 - .../portalapp/portal/service/UserRolesService.java | 58 - .../portal/service/UserRolesServiceImpl.java | 656 - .../portalapp/portal/service/UserService.java | 34 - .../portalapp/portal/service/UserServiceImpl.java | 260 - .../portalapp/portal/service/WidgetService.java | 36 - .../portal/service/WidgetServiceImpl.java | 275 - .../portal/transport/AllAppsWithRolesForUser.java | 40 - .../transport/AppCatalogPersonalization.java | 38 - .../portal/transport/AppNameIdIsAdmin.java | 31 - .../portal/transport/AppWithRolesForUser.java | 34 - .../portal/transport/AppsListWithAdminRole.java | 34 - .../portalapp/portal/transport/CommonWidget.java | 140 - .../portal/transport/CommonWidgetMeta.java | 50 - .../portalapp/portal/transport/EventWidget.java | 139 - .../portal/transport/EventWidgetMeta.java | 52 - .../transport/FavoritesFunctionalMenuItem.java | 45 - .../transport/FavoritesFunctionalMenuItemJson.java | 57 - .../portal/transport/FieldsValidator.java | 49 - .../portal/transport/FunctionalMenuItem.java | 90 - .../portal/transport/FunctionalMenuItemJson.java | 52 - .../portal/transport/FunctionalMenuRole.java | 49 - .../portalapp/portal/transport/LocalRole.java | 42 - .../portalapp/portal/transport/OnboardingApp.java | 83 - .../portal/transport/OnboardingWidget.java | 65 - .../portalapp/portal/transport/PortalAdmin.java | 53 - .../portal/transport/PortalAdminUserRole.java | 48 - .../portalapp/portal/transport/RemoteRole.java | 28 - .../portal/transport/RemoteUserWithRoles.java | 63 - .../portal/transport/RoleInAppForUser.java | 39 - .../portal/transport/RolesInAppForUser.java | 33 - .../portal/transport/UserApplicationRoles.java | 41 - .../portal/transport/UserWithNameSurnameTitle.java | 39 - .../portalapp/portal/ueb/EPUebHelper.java | 218 - .../portalapp/portal/ueb/EPUebMsgTypes.java | 27 - .../portal/utils/CustomLoggingFilter.java | 60 - .../portalapp/portal/utils/EPSystemProperties.java | 77 - .../portalapp/portal/utils/EcompPortalUtils.java | 248 - .../portalapp/portal/utils/EcompVersion.java | 33 - .../portalapp/portal/utils/HashMapFromList.java | 100 - .../portalapp/portal/utils/ParallelExecutor.java | 83 - .../org/openecomp/portalapp/scheduler/LogJob.java | 45 - .../openecomp/portalapp/scheduler/LogRegistry.java | 57 - .../openecomp/portalapp/scheduler/Register.java | 86 - .../portalapp/scheduler/RegistryAdapter.java | 100 - .../portalapp/scheduler/SessionMgtRegistry.java | 89 - .../portalapp/service/AdminAuthExtension.java | 35 - .../portalapp/service/EPProfileService.java | 36 - .../portalapp/service/EPProfileServiceImpl.java | 76 - .../service/sessionmgt/CoreTimeoutHandler.java | 166 - .../service/sessionmgt/ManageService.java | 101 - .../sessionmgt/RemoteWebServiceCallService.java | 44 - .../RemoteWebServiceCallServiceImpl.java | 83 - .../service/sessionmgt/SessionCommunication.java | 274 - .../service/sessionmgt/TimeoutHandler.java | 252 - .../uebhandler/FunctionalMenuHandler.java | 126 - .../portalapp/uebhandler/InitUebHandler.java | 75 - .../portalapp/uebhandler/MainUebHandler.java | 115 - .../uebhandler/WidgetNotificationHandler.java | 93 - .../org/openecomp/portalapp/util/EPUserUtils.java | 308 - .../portalapp/util/SessionCookieUtil.java | 129 - .../portal/controller/SharedContextRestClient.java | 262 - .../SharedContextRestControllerTest.java | 107 - .../controller/SharedContextTestProperties.java | 62 - .../controller/shared-context-test.properties | 9 - .../portal/listener/HealthMonitorTest.java | 17 - .../portal/utils/EcompPortalUtilsTest.java | 14 - .../war/WEB-INF/conf/kpidash.properties | 22 - ecomp-portal-BE/war/WEB-INF/conf/system.properties | 102 - ecomp-portal-BE/war/WEB-INF/fusion/.DS_Store | Bin 6148 -> 0 bytes .../war/WEB-INF/fusion/conf/fusion.properties | 82 - .../war/WEB-INF/fusion/jsp/collaborateList.jsp | 101 - .../war/WEB-INF/fusion/jsp/ebz/ebz_footer.jsp | 63 - .../war/WEB-INF/fusion/jsp/ebz/ebz_header.jsp | 303 - .../war/WEB-INF/fusion/jsp/ebz_template.jsp | 44 - .../fusion/jsp/ebz_template_noheader_nofooter.jsp | 35 - ecomp-portal-BE/war/WEB-INF/fusion/jsp/include.jsp | 30 - .../war/WEB-INF/fusion/jsp/jcs_admin.jsp | 149 - ecomp-portal-BE/war/WEB-INF/fusion/jsp/meta.jsp | 35 - .../war/WEB-INF/fusion/jsp/popup_modal.html | 311 - .../war/WEB-INF/fusion/jsp/popup_modal_role.html | 257 - .../fusion/jsp/popup_modal_rolefunction.html | 87 - .../war/WEB-INF/fusion/jsp/post_search.jsp | 370 - ecomp-portal-BE/war/WEB-INF/fusion/jsp/profile.jsp | 442 - .../war/WEB-INF/fusion/jsp/profile_search.jsp | 100 - ecomp-portal-BE/war/WEB-INF/fusion/jsp/role.jsp | 298 - .../war/WEB-INF/fusion/jsp/role_function_list.jsp | 225 - .../war/WEB-INF/fusion/jsp/role_list.jsp | 147 - .../war/WEB-INF/fusion/jsp/usage_list.jsp | 99 - .../WEB-INF/fusion/jsp/webrtc/collaboration.jsp | 529 - ecomp-portal-BE/war/WEB-INF/fusion/orm/EP.hbm.xml | 558 - .../war/WEB-INF/fusion/orm/Fusion.hbm.xml | 372 - .../war/WEB-INF/fusion/orm/Workflow.hbm.xml | 48 - .../war/WEB-INF/fusion/raptor/report_search.jsp | 20 - ecomp-portal-BE/war/WEB-INF/jsp/login.jsp | 152 - ecomp-portal-BE/war/index.jsp | 22 - .../war/static/ebz/attSessionTimeoutModal.css | 1562 - ecomp-portal-BE/war/static/ebz/dashboardBase.css | 5798 --- .../war/static/ebz/dashboardBase_changed.css | 5803 --- ecomp-portal-BE/war/static/ebz/ebz_header.css | 607 - ecomp-portal-BE/war/static/ebz/fn-ebz.css | 1344 - ecomp-portal-BE/war/static/ebz/footer_new.css | 310 - ecomp-portal-BE/war/static/ebz/globalFonts.css | Bin 6347 -> 0 bytes ecomp-portal-BE/war/static/ebz/header_new.css | 1781 - .../war/static/ebz/js/attHeaderSnippet.js | 210 - ecomp-portal-BE/war/static/ebz/js/footer.js | 110 - .../war/static/ebz/sandbox/att-abs-tpls.js | 20451 --------- .../war/static/ebz/sandbox/att-abs-tpls.min.js | 22 - .../war/static/ebz/sandbox/styles/base.css | 1 - .../war/static/ebz/sandbox/styles/btn.css | 1 - .../war/static/ebz/sandbox/styles/demo.css | 2 - .../war/static/ebz/sandbox/styles/dtpk.css | 9 - .../war/static/ebz/sandbox/styles/frms.css | 1 - .../ebz/sandbox/styles/ie/backgroundsize.min.htc | 12 - .../ebz/sandbox/styles/pages/iconography.css | 2 - .../war/static/ebz/sandbox/styles/sldr.css | 1 - .../war/static/ebz/sandbox/styles/style.css | 1 - .../war/static/ebz/sandbox/styles/tbs.css | 1 - .../css/att_angular_gridster/sandbox-gridster.css | 173 - .../css/att_angular_gridster/ui-gridster.css | 116 - .../war/static/fusion/css/fusion-sunny.css | 362 - .../war/static/fusion/css/jquery-ui.css | 1225 - .../fusion/css/layout/layout-default-latest.css | 224 - ecomp-portal-BE/war/static/fusion/d3/css/nv.d3.css | 656 - ecomp-portal-BE/war/static/fusion/d3/js/cie.js | 155 - .../war/static/fusion/d3/js/colorbrewer.js | 302 - ecomp-portal-BE/war/static/fusion/d3/js/core.js | 122 - .../war/static/fusion/d3/js/crossfilter.js | 1180 - .../war/static/fusion/d3/js/crossfilter.min.js | 1 - ecomp-portal-BE/war/static/fusion/d3/js/d3.geom.js | 816 - ecomp-portal-BE/war/static/fusion/d3/js/d3.js | 5 - .../war/static/fusion/d3/js/d3.layout.cloud.js | 433 - .../war/static/fusion/d3/js/d3.layout.js | 908 - ecomp-portal-BE/war/static/fusion/d3/js/d3.v2.js | 7037 --- .../war/static/fusion/d3/js/d3.v2.min.js | 4 - .../war/static/fusion/d3/js/d3.v3.min.js | 1 - ecomp-portal-BE/war/static/fusion/d3/js/fisheye.js | 86 - ecomp-portal-BE/war/static/fusion/d3/js/hive.js | 80 - ecomp-portal-BE/war/static/fusion/d3/js/horizon.js | 192 - .../war/static/fusion/d3/js/interactiveLayer.js | 251 - ecomp-portal-BE/war/static/fusion/d3/js/intro.js | 1 - .../war/static/fusion/d3/js/models/axis-min.js | 1 - .../war/static/fusion/d3/js/models/axis.js | 470 - .../war/static/fusion/d3/js/models/axis.min.js | 1 - .../static/fusion/d3/js/models/backup/bullet.js | 250 - .../fusion/d3/js/models/backup/bulletChart.js | 349 - .../war/static/fusion/d3/js/models/boilerplate.js | 104 - .../war/static/fusion/d3/js/models/bullet.js | 385 - .../war/static/fusion/d3/js/models/bulletChart.js | 343 - .../fusion/d3/js/models/cumulativeLineChart.js | 782 - .../war/static/fusion/d3/js/models/discreteBar.js | 349 - .../static/fusion/d3/js/models/discreteBarChart.js | 333 - .../war/static/fusion/d3/js/models/distribution.js | 148 - .../static/fusion/d3/js/models/historicalBar.js | 331 - .../fusion/d3/js/models/historicalBarChart.js | 419 - .../war/static/fusion/d3/js/models/indentedTree.js | 337 - .../war/static/fusion/d3/js/models/legend.js | 270 - .../war/static/fusion/d3/js/models/line.js | 284 - .../war/static/fusion/d3/js/models/lineChart.js | 465 - .../static/fusion/d3/js/models/linePlusBarChart.js | 433 - .../d3/js/models/linePlusBarWithFocusChart.js | 658 - .../static/fusion/d3/js/models/lineWithFisheye.js | 200 - .../fusion/d3/js/models/lineWithFisheyeChart.js | 297 - .../fusion/d3/js/models/lineWithFocusChart.js | 574 - .../war/static/fusion/d3/js/models/multiBar.js | 461 - .../static/fusion/d3/js/models/multiBarChart.js | 524 - .../fusion/d3/js/models/multiBarHorizontal.js | 424 - .../fusion/d3/js/models/multiBarHorizontalChart.js | 434 - .../fusion/d3/js/models/multiBarTimeSeries.js | 384 - .../fusion/d3/js/models/multiBarTimeSeriesChart.js | 405 - .../war/static/fusion/d3/js/models/multiChart.js | 452 - .../war/static/fusion/d3/js/models/ohlcBar.js | 380 - .../fusion/d3/js/models/parallelCoordinates.js | 239 - .../war/static/fusion/d3/js/models/pie.js | 400 - .../war/static/fusion/d3/js/models/pieChart.js | 292 - .../war/static/fusion/d3/js/models/scatter.js | 674 - .../war/static/fusion/d3/js/models/scatterChart.js | 628 - .../fusion/d3/js/models/scatterPlusLineChart.js | 620 - .../war/static/fusion/d3/js/models/sparkline.js | 194 - .../static/fusion/d3/js/models/sparklinePlus.js | 295 - .../war/static/fusion/d3/js/models/stackedArea.js | 368 - .../static/fusion/d3/js/models/stackedAreaChart.js | 629 - ecomp-portal-BE/war/static/fusion/d3/js/nv.d3.js | 13097 ------ .../war/static/fusion/d3/js/nv.d3.min.js | 1 - ecomp-portal-BE/war/static/fusion/d3/js/outro.js | 1 - ecomp-portal-BE/war/static/fusion/d3/js/sankey.js | 292 - ecomp-portal-BE/war/static/fusion/d3/js/tooltip.js | 490 - ecomp-portal-BE/war/static/fusion/d3/js/utils.js | 152 - .../js/att_angular_gridster/angular-gridster.js | 2244 - .../js/att_angular_gridster/ui-gridster-tpls.js | 168 - .../war/static/fusion/js/jquery.resize.js | 139 - .../war/static/fusion/js/layout/debug.js | 329 - .../war/static/fusion/js/layout/jquery-latest.js | 9555 ---- .../static/fusion/js/layout/jquery-ui-latest.js | 14879 ------ .../fusion/js/layout/jquery.layout-latest.js | 6086 --- .../war/static/fusion/sample/css/images/blank.gif | Bin 49 -> 0 bytes .../war/static/fusion/sample/css/scribble.css | 32 - .../war/static/fusion/sample/css/slider.css | 142 - .../war/static/fusion/sample/css/spacegallery.css | 18 - .../war/static/fusion/sample/html/area_chart.html | 49 - .../war/static/fusion/sample/html/bar_chart.html | 95 - .../static/fusion/sample/html/d3_gauges_demo.html | 39 - .../fusion/sample/html/data/speedometer2.csv | 16 - .../fusion/sample/html/data/speedometer3.csv | 2 - .../static/fusion/sample/html/data/worddata.csv | 22 - .../war/static/fusion/sample/html/donut_d3.html | 43 - .../static/fusion/sample/html/js/area_chart.min.js | 1 - .../war/static/fusion/sample/html/js/donut.min.js | 1 - .../war/static/fusion/sample/html/js/gauges.min.js | 1 - .../static/fusion/sample/html/js/line_chart.min.js | 1 - .../static/fusion/sample/html/js/pie_chart.min.js | 1 - .../static/fusion/sample/html/js/worddata.min.js | 1 - .../war/static/fusion/sample/html/line_chart.html | 49 - .../war/static/fusion/sample/html/pie_chart.html | 38 - .../war/static/fusion/sample/html/wordcloud.html | 37 - .../war/static/fusion/sample/js/FusionCharts.js | 361 - .../war/static/fusion/sample/js/charts.js | 132 - ecomp-portal-BE/war/static/fusion/sample/js/eye.js | 34 - .../war/static/fusion/sample/js/scribble.js | 19 - .../static/fusion/sample/js/slides.min.jquery.js | 20 - .../war/static/fusion/sample/js/spacegallery.js | 235 - .../war/static/fusion/sample/js/utils.js | 252 - .../fusion/sample/org_chart/css/bootstrap.min.css | 351 - .../static/fusion/sample/org_chart/css/custom.css | 97 - .../sample/org_chart/css/jquery.jOrgChart.css | 51 - .../fusion/sample/org_chart/css/prettify.css | 1 - .../static/fusion/sample/org_chart/example.html | 85 - .../fusion/sample/org_chart/example_vsp.html | 88 - .../fusion/sample/org_chart/jquery.jOrgChart.js | 267 - .../war/static/fusion/sample/org_chart/prettify.js | 28 - .../war/static/fusion/webrtc/getSourceId.html | 78 - .../static/fusion/webrtc/js/RTCMultiConnection.js | 6777 --- .../war/static/fusion/webrtc/js/peerBroadcast.js | 113 - ecomp-portal-BE/war/static/js/modalService.js | 144 - .../bootstrap2/css/bootstrap-responsive.css | 1109 - .../bootstrap2/css/bootstrap-responsive.min.css | 9 - .../oid-connect/bootstrap2/css/bootstrap.css | 6167 --- .../oid-connect/bootstrap2/css/bootstrap.min.css | 9 - .../static/oid-connect/bootstrap2/js/bootstrap.js | 2280 - .../oid-connect/bootstrap2/js/bootstrap.min.js | 6 - .../war/static/oid-connect/js/lib/jquery.js | 9404 ---- .../war/static/oid-connect/js/lib/jwt.js | 244 - .../war/static/oid-connect/js/lib/underscore.js | 1221 - ecomp-portal-FE-common/README.md | 20 + .../directives/auto-focus/auto-focus.directive.js | 0 .../b2b-leftnav-ext/b2b-leftnav-ext.directive.js | 68 + .../b2b-leftnav-ext/b2b-leftnav-ext.less | 4 + .../b2b-leftnav-ext/b2b-leftnav-ext.tpl.html | 62 + .../file-upload/file-upload.directive.js | 39 + .../image-upload/image-upload.directive.js | 238 + .../directives/left-menu/left-menu.directive.js | 90 + .../client/app/directives/left-menu/left-menu.less | 177 + .../app/directives/left-menu/left-menu.tpl.html | 22 + .../multiple-select/multiple-select.directive.js | 113 + .../multiple-select/multiple-select.less | 62 + .../multiple-select/multiple-select.tpl.html | 36 + .../multiple-select/multiple-select2.directive.js | 113 + .../multiple-select/multiple-select2.tpl.html | 36 + .../multiple-select/mutliple-select2.less | 62 + .../right-click-menu/right-click-menu.directive.js | 41 + .../right-click/ng-right-click-directive.js | 32 + .../directives/scroll-top/scroll-top.directive.js | 35 + .../search-users/search-users.controller.js | 92 + .../search-users/search-users.controller.spec.js | 176 + .../search-users/search-users.directive.js | 34 + .../client/app/filters/elipsis/elipsis.filter.js | 0 .../app/filters/elipsis/elipsis.filter.spec.js | 0 .../app/filters/trusted-url/trusted-url.filter.js | 0 ecomp-portal-FE-common/client/app/router.js | 238 + .../client/app/services/admins/admins.service.js | 221 + .../services/applications/applications.service.js | 591 + .../app/services/audit-log/audit-log.service.js | 92 + .../client/app/services/base64/base64.service.js | 69 + .../basic-auth-account.service.js | 124 + .../be-property-reader.service.js | 70 + .../client/app/services/catalog/catalog.service.js | 172 + .../services/confirm-box/confirm-box.service.js | 236 + .../app/services/contact-us/contact-us.service.js | 247 + .../app/services/dashboard/dashboard.service.js | 185 + .../error-messages/error-messages.service.js | 22 + .../external-request-access-service.js | 63 + .../functionalMenu/functionalMenu.service.js | 318 + .../services/global-constants/global-constants.js | 23 + .../app/services/manifest/manifest.service.js | 64 + .../client/app/services/menus/menus.service.js | 147 + .../services/microservice/microservice.service.js | 218 + .../services/notification/notification.service.js | 322 + .../portal-admins/portal-admins.service.js | 112 + .../client/app/services/role/role.service.js | 190 + .../support/getAccess/get-access.service.js | 62 + .../app/services/userbar/userbar.update.service.js | 0 .../client/app/services/users/users.service.js | 215 + .../client/app/services/utils/utils.service.js | 55 + .../widgets-catalog/widgets-catalog.service.js | 358 + .../client/app/services/widgets/widgets.service.js | 206 + .../client/app/styles/buttons.less | 54 + .../client/app/styles/ecomp-general.less | 98 + ecomp-portal-FE-common/client/app/styles/form.less | 143 + .../client/app/styles/mixins.less | 366 + .../client/app/styles/ng-dialog.less | 71 + .../client/app/styles/reset.less | 60 + .../client/app/styles/select2.less | 230 + .../client/app/styles/spinner.less | 37 + .../client/app/styles/sprites.less | 101 + .../client/app/styles/variables.less | 97 + .../account-add-details/account-add-details.html | 125 + .../account-add-details/account-add-details.js | 171 + .../account-add-details/account-add-details.less | 195 + .../account-onboarding.controller.js | 72 + .../account-onboarding/account-onboarding.less | 24 + .../account-onboarding/account-onboarding.tpl.html | 76 + .../add-admin-dialogs/new-admin.controller.js | 252 + .../add-admin-dialogs/new-admin.controller.spec.js | 134 + .../admins/add-admin-dialogs/new-admin.modal.html | 77 + .../admins/add-admin-dialogs/new-admin.modal.less | 81 + .../client/app/views/admins/admins.controller.js | 161 + .../app/views/admins/admins.controller.spec.js | 19 + .../client/app/views/admins/admins.less | 45 + .../client/app/views/admins/admins.tpl.html | 66 + .../application-details.modal.less | 106 + .../app/views/applications/applications.less | 31 + .../add-catalog-dialogs/new-catalog.modal.less | 125 + .../client/app/views/catalog/catalog.controller.js | 238 + .../client/app/views/catalog/catalog.less | 413 + .../client/app/views/catalog/catalog.tpl.html | 90 + .../catalog/catalogconfirmation.controller.js | 0 .../app/views/catalog/information-box.tpl.html | 42 + .../admin-confirmation-box.tpl.html | 31 + .../confirmation-box.controller.js | 49 + .../views/confirmation-box/confirmation-box.less | 35 + .../confirmation-box/confirmation-box.tpl.html | 28 + .../dragdrop-confirmation-box.tpl.html | 31 + .../confirmation-box/information-box.tpl.html | 27 + .../views/dashboard/dashboard-widget-manage.html | 152 + .../dashboard-widget-parameter-manage.html | 86 + .../dashboard-widget-parameters.controller.js | 81 + .../dashboard-widget-parameters.controller.less | 28 + .../views/dashboard/dashboard-widget.controller.js | 422 + .../dashboard/dashboard-widget.controller.less | 82 + .../app/views/dashboard/dashboard.controller.js | 504 + .../views/dashboard/dashboard.controller.spec.js | 78 + .../client/app/views/dashboard/dashboard.less | 901 + .../client/app/views/dashboard/dashboard.tpl.html | 179 + .../app/views/dashboard/newsticker.controller.js | 52 + .../functionalMenu-dialog/modal-details.modal.less | 97 + .../app/views/functionalMenu/functionalMenu.less | 60 + .../client/app/views/header/header.controller.js | 449 + .../app/views/header/header.controller.spec.js | 19 + .../client/app/views/header/header.less | 496 + .../client/app/views/header/header.tpl.html | 266 + .../microservice-add-details.html | 205 + .../microservice-add-details.js | 336 + .../microservice-add-details.less | 234 + .../microservice-onboarding.controller.js | 87 + .../microservice-onboarding.less | 26 + .../microservice-onboarding.tpl.html | 75 + .../notificationhistory.controller.js | 83 + .../notification-history/notificationhistory.less | 41 + .../notificationhistory.tpl.html | 100 + .../new-portal-admin.controller.js | 95 + .../new-portal-admin.controller.spec.js | 19 + .../new-portal-admin/new-portal-admin.modal.html | 36 + .../new-portal-admin/new-portal-admin.modal.less | 80 + .../views/portal-admin/portal-admin-controller.js | 110 + .../app/views/portal-admin/portal-admin.tpl.html | 64 + .../app/views/portal-admin/portal-admins.less | 42 + .../app/views/role/popup_modal_rolefunction.html | 55 + .../client/app/views/role/role-controller.js | 219 + .../views/role/role-function-list-controller.js | 160 + .../client/app/views/role/role-list-controller.js | 147 + .../client/app/views/role/role.html | 96 + .../client/app/views/role/role.less | 50 + .../app/views/role/role_childrole_popup.html | 51 + .../client/app/views/role/role_function_list.html | 107 + .../app/views/role/role_functions_popup.html | 49 + .../client/app/views/role/role_list.html | 55 + .../app/views/role/rolefunctionpopupController.js | 95 + .../app/views/role/rolepopupmodelController.js | 251 + .../client/app/views/search/search.less | 66 + .../client/app/views/sidebar/sidebar.controller.js | 63 + .../client/app/views/sidebar/sidebar.less | 37 + .../client/app/views/sidebar/sidebar.tpl.html | 20 + .../contact-us-manage.controller.js | 202 + .../contact-us-manage.controller.less | 152 + .../contact-us-manage/contact-us-manage.html | 180 + .../support/contact-us/contact-us.controller.js | 171 + .../contact-us/contact-us.controller.spec.js | 19 + .../app/views/support/contact-us/contact-us.less | 93 + .../views/support/contact-us/contact-us.tpl.html | 126 + .../support/get-access/get-access.controller.js | 123 + .../get-access/get-access.controller.spec.js | 19 + .../app/views/support/get-access/get-access.less | 55 + .../views/support/get-access/get-access.tpl.html | 102 + .../client/app/views/tabs/tabframe.html | 22 + .../client/app/views/tabs/tabs.controller.js | 314 + .../client/app/views/tabs/tabs.controller.spec.js | 81 + .../client/app/views/tabs/tabs.less | 660 + .../user.notifications.Json.details.controller.js | 36 + ...user.notifications.Json.details.modal.page.html | 48 + .../user.notifications.controller.js | 196 + ...user.notifications.json.details.modal.page.less | 48 + .../user.notifications.less | 128 + .../user.notifications.modal.controller.js | 747 + .../user.notifications.modal.less | 157 + .../user.notifications.modal.page.html | 161 + .../user.notifications.tpl.html | 117 + .../client/app/views/userbar/userbar.less | 22 + .../users/new-user-dialogs/bulk-user.ack.html | 32 + .../users/new-user-dialogs/bulk-user.confirm.html | 83 + .../users/new-user-dialogs/bulk-user.controller.js | 577 + .../users/new-user-dialogs/bulk-user.modal.html | 70 + .../users/new-user-dialogs/bulk-user.modal.less | 60 + .../users/new-user-dialogs/new-user.controller.js | 216 + .../new-user-dialogs/new-user.controller.spec.js | 255 + .../users/new-user-dialogs/new-user.modal.html | 84 + .../users/new-user-dialogs/new-user.modal.less | 112 + .../client/app/views/users/users.controller.js | 243 + .../app/views/users/users.controller.spec.js | 141 + .../client/app/views/users/users.less | 47 + .../client/app/views/users/users.tpl.html | 98 + .../widget-catalog/widget-catalog.controller.js | 350 + .../widget-catalog.controller.spec.js | 20 + .../app/views/widget-catalog/widget-catalog.less | 156 + .../views/widget-catalog/widget-catalog.tpl.html | 76 + .../widget-details.controller.js | 381 + .../widget-details.controller.spec.js | 154 + .../widget-details.modal.html | 156 + .../widget-details.modal.less | 102 + .../widget-onboarding.controller.js | 204 + .../widget-onboarding.controller.spec.js | 20 + .../views/widget-onboarding/widget-onboarding.less | 32 + .../widget-onboarding/widget-onboarding.tpl.html | 113 + .../widget-details.controller.js | 226 + .../widget-details.controller.spec.js | 154 + .../widget-details.modal.html | 152 + .../widget-details.modal.less | 75 + .../client/app/views/widgets/widgets.controller.js | 168 + .../app/views/widgets/widgets.controller.spec.js | 19 + .../client/app/views/widgets/widgets.less | 48 + .../client/app/views/widgets/widgets.tpl.html | 81 + .../b2b/css/b2b-angular/README.md | 14 + .../b2b/css/b2b-angular/b2b-angular.css | 11827 +++++ .../b2b/js/b2b-angular/README.md | 22 + .../b2b/js/b2b-angular/b2b-library.min.js | 22055 +++++++++ .../home/ecompportal/applicationsHome | 9 + ecomp-portal-FE-common/home/ecompportal/login.htm | 9 + ecomp-portal-FE-common/home/index.html | 3 + ecomp-portal-FE-common/license/licenses.properties | 1 + .../license/my_license/header.txt | 11 + .../license/my_license/license.txt | 4 + ecomp-portal-FE-common/pom.xml | 55 + {ecomp-portal-FE => ecomp-portal-FE-os}/.bowerrc | 0 ecomp-portal-FE-os/.gitignore | 11 + ecomp-portal-FE-os/Gruntfile.js | 778 + ecomp-portal-FE-os/README.md | 70 + ecomp-portal-FE-os/bower.json | 41 + .../build-ecomportal-fe.sh | 0 .../client/.htaccess | 0 .../client/.jshintrc | 0 .../client/assets/images/ecomp_logo.png | Bin .../client/assets/images}/grips.png | Bin .../client/assets/images/photo.png | Bin .../client/assets/images/spinner.gif | Bin .../angular-gridster/angular-gridster.min.js | 8 + .../b2b/css/b2b-angular/README.md | 14 + .../b2b/js/b2b-angular/README.md | 13 + .../b2b/js/b2b-angular/b2b-library.min.js | 22048 +++++++++ .../bower_components_external/bowser/bowser.js | 0 .../bower_components_external/bowser/useragents.js | 0 .../ionicons-2.0.1/.gitignore | 0 .../ionicons-2.0.1/LICENSE | 0 .../ionicons-2.0.1/css/ionicons.css | 1493 + .../ionicons-2.0.1/css/ionicons.min.css | 0 .../ionicons-2.0.1/fonts/ionicons.eot | Bin .../ionicons-2.0.1/fonts/ionicons.svg | 0 .../ionicons-2.0.1/fonts/ionicons.ttf | Bin .../ionicons-2.0.1/fonts/ionicons.woff | Bin .../ionicons-2.0.1/readme.md | 0 ecomp-portal-FE-os/client/configurations/dev.json | 93 + .../client/configurations/devServer.json | 101 + .../client/configurations/integ.json | 93 + ecomp-portal-FE-os/client/configurations/mock.json | 101 + ecomp-portal-FE-os/client/index.html | 301 + .../client/robots.txt | 0 ecomp-portal-FE-os/client/src/app.js | 122 + ecomp-portal-FE-os/client/src/app.less | 82 + .../directives/right-menu/right-menu.directive.js | 111 + .../src/directives/right-menu/right-menu.less | 182 + .../src/directives/right-menu/right-menu.tpl.html | 42 + .../search-users/search-users.controller.js | 168 + .../src/directives/search-users/search-users.less | 159 + .../directives/search-users/search-users.tpl.html | 143 + ecomp-portal-FE-os/client/src/router.js | 238 + .../services/support/session/session.service.js | 76 + .../services/userProfile/userProfile.service.js | 202 + ecomp-portal-FE-os/client/src/styles/att-abs.less | 92 + .../application-details.controller.js | 268 + .../application-details.controller.spec.js | 0 .../application-details.modal.html | 201 + .../views/applications/applications.controller.js | 123 + .../applications/applications.controller.spec.js | 19 + .../src/views/applications/applications.tpl.html | 81 + .../add-catalog-dialogs/new-catalog.controller.js | 218 + .../add-catalog-dialogs/new-catalog.modal.html | 113 + .../client/src/views/dashboard/dashboard.tpl.html | 173 + .../client/src/views/footer/footer.controller.js | 48 + .../src/views/footer/footer.controller.spec.js | 19 + .../client/src/views/footer/footer.less | 104 + .../client/src/views/footer/footer.tpl.html | 34 + .../menu-details.controller.js | 415 + .../menu-details.delete.modal.html | 37 + .../functionalMenu-dialog/menu-details.modal.html | 103 + .../functionalMenu/functionalMenu.controller.js | 372 + .../views/functionalMenu/functionalMenu.tpl.html | 46 + .../src/views/functionalMenu/jqTreeContextMenu.js | 214 + .../client/src/views/search/search.controller.js | 198 + .../src/views/search/search.controller.spec.js | 19 + .../client/src/views/search/search.tpl.html | 84 + .../views/support/contact-us/contact-us.aux.html | 25 + .../views/support/get-access/get-accessinfo.html | 24 + .../client/src/views/tabs/tabs.tpl.html | 47 + .../client/src/views/userbar/userbar.controller.js | 229 + .../client/src/views/userbar/userbar.tpl.html | 20 + .../client/utils/test-utils/test-utils.js | 0 .../e2e/main/anchoring.spec.js | 0 .../e2e/main/main.po.js | 0 .../e2e/main/main.spec.js | 0 .../karma.conf.js | 0 ecomp-portal-FE-os/license/licenses.properties | 1 + ecomp-portal-FE-os/license/my_license/header.txt | 11 + ecomp-portal-FE-os/license/my_license/license.txt | 4 + .../mock/ecomp/data/admins/account-admins.json | 140 + .../mock/ecomp/data/admins/admin-app-roles.json | 0 .../mock/ecomp/data/applications/admin-apps.json | 0 .../data/applications/applications-onboarding.json | 128 + .../ecomp/data/applications/available-apps.json | 0 .../mock/ecomp/data/applications/user-apps.json | 62 + .../mock/ecomp/data/functional-menu/app-roles.json | 0 .../mock/ecomp/data/functional-menu/dev.json | 22 + .../mock/ecomp/data/functional-menu/favorites.json | 27 + .../data/functional-menu/menu-item-details.json | 0 .../ecomp/data/functional-menu/menu-items.json | 674 + .../data/functional-menu/menu-items_small.json | 674 + .../mock/ecomp/data/ping/ping.json | 0 .../mock/ecomp/data/user-profile/user-profile.json | 0 .../ecomp/data/user-profile/user-static-info.json | 7 + .../mock/ecomp/data/users/account-users.json | 0 .../mock/ecomp/data/users/query-users-results.json | 0 .../mock/ecomp/data/users/user-apps-roles.json | 0 .../mock/ecomp/data/widgets/widgets.json | 39 + .../mock/ecomp/router.js | 0 .../mock/server.js | 0 .../package.json | 0 ecomp-portal-FE-os/pom.xml | 225 + .../protractor.conf.js | 0 .../server/.jshintrc | 0 .../server/.jshintrc-spec | 0 .../server/app.js | 0 .../server/components/errors/index.js | 0 .../server/config/environment/index.js | 0 .../server/config/express.js | 0 .../server/routes.js | 0 .../server/views/404.html | 0 ecomp-portal-FE/.gitignore | 6 - ecomp-portal-FE/Gruntfile.js | 779 - ecomp-portal-FE/README.md | 51 - ecomp-portal-FE/bower.json | 36 - ecomp-portal-FE/client/app/app.js | 120 - ecomp-portal-FE/client/app/app.less | 78 - ecomp-portal-FE/client/app/configurations.js | 5 - .../image-upload/image-upload.directive.js | 222 - .../directives/left-menu/left-menu.directive.js | 96 - .../client/app/directives/left-menu/left-menu.less | 133 - .../app/directives/left-menu/left-menu.tpl.html | 57 - .../multiple-select/multiple-select.directive.js | 111 - .../multiple-select/multiple-select.less | 81 - .../multiple-select/multiple-select.tpl.html | 38 - .../right-click-menu/right-click-menu.directive.js | 38 - .../right-click/ng-right-click-directive.js | 32 - .../directives/right-menu/right-menu.directive.js | 140 - .../app/directives/right-menu/right-menu.less | 178 - .../app/directives/right-menu/right-menu.tpl.html | 40 - .../directives/scroll-top/scroll-top.directive.js | 35 - .../search-users/search-users.controller.js | 161 - .../search-users/search-users.controller.spec.js | 176 - .../search-users/search-users.directive.js | 34 - .../app/directives/search-users/search-users.less | 154 - .../directives/search-users/search-users.tpl.html | 144 - ecomp-portal-FE/client/app/router.js | 528 - .../client/app/services/admins/admins.service.js | 176 - .../services/applications/applications.service.js | 346 - .../client/app/services/catalog/catalog.service.js | 95 - .../services/confirm-box/confirm-box.service.js | 153 - .../app/services/contact-us/contact-us.service.js | 247 - .../app/services/dashboard/dashboard.service.js | 185 - .../error-messages/error-messages.service.js | 23 - .../functionalMenu/functionalMenu.service.js | 253 - .../services/global-constants/global-constants.js | 21 - .../kpi-dashboard/kpi-dashboard.service.js | 185 - .../app/services/manifest/manifest.service.js | 64 - .../client/app/services/menus/menus.service.js | 145 - .../portal-admins/portal-admins.service.js | 107 - .../support/getAccess/get-access.service.js | 61 - .../services/support/session/session.service.js | 56 - .../services/userProfile/userProfile.service.js | 240 - .../client/app/services/users/users.service.js | 161 - .../client/app/services/utils/utils.service.js | 57 - .../client/app/services/widgets/widgets.service.js | 178 - ecomp-portal-FE/client/app/styles/att-abs.less | 86 - ecomp-portal-FE/client/app/styles/buttons.less | 72 - .../client/app/styles/ecomp-general.less | 76 - ecomp-portal-FE/client/app/styles/fonts.less | 81 - ecomp-portal-FE/client/app/styles/form.less | 189 - .../client/app/styles/kpi-dashboard.less | 111 - ecomp-portal-FE/client/app/styles/mixins.less | 296 - ecomp-portal-FE/client/app/styles/ng-dialog.less | 88 - ecomp-portal-FE/client/app/styles/reset.less | 79 - ecomp-portal-FE/client/app/styles/select2.less | 102 - ecomp-portal-FE/client/app/styles/spinner.less | 56 - ecomp-portal-FE/client/app/styles/sprites.less | 118 - ecomp-portal-FE/client/app/styles/variables.less | 86 - .../add-admin-dialogs/new-admin.controller.js | 214 - .../add-admin-dialogs/new-admin.controller.spec.js | 130 - .../admins/add-admin-dialogs/new-admin.modal.html | 66 - .../admins/add-admin-dialogs/new-admin.modal.less | 99 - .../client/app/views/admins/admins.controller.js | 151 - .../app/views/admins/admins.controller.spec.js | 19 - .../client/app/views/admins/admins.less | 47 - .../client/app/views/admins/admins.tpl.html | 82 - .../application-details.controller.js | 244 - .../application-details.modal.html | 183 - .../application-details.modal.less | 122 - .../views/applications/applications.controller.js | 111 - .../applications/applications.controller.spec.js | 19 - .../app/views/applications/applications.less | 45 - .../app/views/applications/applications.tpl.html | 100 - .../client/app/views/catalog/catalog.controller.js | 166 - .../client/app/views/catalog/catalog.less | 439 - .../client/app/views/catalog/catalog.tpl.html | 91 - .../app/views/catalog/information-box.tpl.html | 42 - .../admin-confirmation-box.tpl.html | 31 - .../confirmation-box.controller.js | 41 - .../views/confirmation-box/confirmation-box.less | 53 - .../confirmation-box/confirmation-box.tpl.html | 28 - .../dragdrop-confirmation-box.tpl.html | 31 - .../confirmation-box/information-box.tpl.html | 27 - .../views/dashboard/dashboard-widget-manage.html | 152 - .../views/dashboard/dashboard-widget.controller.js | 422 - .../dashboard/dashboard-widget.controller.less | 101 - .../app/views/dashboard/dashboard.controller.js | 312 - .../views/dashboard/dashboard.controller.spec.js | 78 - .../client/app/views/dashboard/dashboard.less | 766 - .../client/app/views/dashboard/dashboard.tpl.html | 346 - .../app/views/dashboard/newsticker.controller.js | 47 - .../client/app/views/errors/error.404.tpl.html | 31 - .../client/app/views/errors/error.controller.js | 36 - .../client/app/views/errors/error.tpl.html | 26 - .../client/app/views/footer/footer.controller.js | 49 - .../app/views/footer/footer.controller.spec.js | 19 - .../client/app/views/footer/footer.less | 53 - .../client/app/views/footer/footer.tpl.html | 36 - .../menu-details.controller.js | 384 - .../menu-details.delete.modal.html | 35 - .../functionalMenu-dialog/menu-details.modal.html | 106 - .../functionalMenu-dialog/modal-details.modal.less | 103 - .../functionalMenu/functionalMenu.controller.js | 331 - .../app/views/functionalMenu/functionalMenu.less | 70 - .../views/functionalMenu/functionalMenu.tpl.html | 48 - .../app/views/functionalMenu/jqTreeContextMenu.js | 192 - .../client/app/views/header/header.controller.js | 419 - .../app/views/header/header.controller.spec.js | 19 - .../client/app/views/header/header.less | 380 - .../client/app/views/header/header.tpl.html | 277 - .../views/header/user-edit/edit-user.controller.js | 134 - .../app/views/header/user-edit/edit-user.less | 61 - .../app/views/header/user-edit/edit-user.tpl.html | 69 - .../applications-home.controller.js | 244 - .../applications-home.controller.spec.js | 77 - .../home/applications-home/applications-home.less | 164 - .../applications-home/applications-home.tpl.html | 59 - .../home/widgets-home/widgets-home.controller.js | 284 - .../widgets-home/widgets-home.controller.spec.js | 1 - .../app/views/home/widgets-home/widgets-home.less | 137 - .../views/home/widgets-home/widgets-home.tpl.html | 123 - .../new-portal-admin.controller.js | 85 - .../new-portal-admin.controller.spec.js | 19 - .../new-portal-admin/new-portal-admin.modal.html | 32 - .../new-portal-admin/new-portal-admin.modal.less | 99 - .../views/portal-admin/portal-admin-controller.js | 127 - .../app/views/portal-admin/portal-admin.tpl.html | 73 - .../app/views/portal-admin/portal-admins.less | 56 - .../client/app/views/search/search.controller.js | 184 - .../app/views/search/search.controller.spec.js | 19 - .../client/app/views/search/search.less | 55 - .../client/app/views/search/search.tpl.html | 82 - .../client/app/views/sidebar/sidebar.controller.js | 143 - .../client/app/views/sidebar/sidebar.less | 37 - .../client/app/views/sidebar/sidebar.tpl.html | 20 - .../contact-us-manage.controller.js | 194 - .../contact-us-manage.controller.less | 159 - .../contact-us-manage/contact-us-manage.html | 136 - .../support/contact-us/contact-us.controller.js | 166 - .../contact-us/contact-us.controller.spec.js | 19 - .../app/views/support/contact-us/contact-us.less | 104 - .../views/support/contact-us/contact-us.tpl.html | 125 - .../support/get-access/get-access.controller.js | 70 - .../get-access/get-access.controller.spec.js | 19 - .../app/views/support/get-access/get-access.less | 67 - .../views/support/get-access/get-access.tpl.html | 88 - .../client/app/views/tabs/tabframe.html | 22 - .../client/app/views/tabs/tabs.controller.js | 231 - .../client/app/views/tabs/tabs.controller.spec.js | 80 - ecomp-portal-FE/client/app/views/tabs/tabs.less | 658 - .../client/app/views/tabs/tabs.tpl.html | 46 - .../client/app/views/userbar/userbar.controller.js | 262 - .../client/app/views/userbar/userbar.less | 41 - .../client/app/views/userbar/userbar.tpl.html | 20 - .../users/new-user-dialogs/new-user.controller.js | 211 - .../new-user-dialogs/new-user.controller.spec.js | 222 - .../users/new-user-dialogs/new-user.modal.html | 70 - .../users/new-user-dialogs/new-user.modal.less | 126 - .../client/app/views/users/users.controller.js | 187 - .../app/views/users/users.controller.spec.js | 19 - ecomp-portal-FE/client/app/views/users/users.less | 59 - .../client/app/views/users/users.tpl.html | 105 - .../widget-details.controller.js | 202 - .../widget-details.controller.spec.js | 19 - .../widget-details.modal.html | 132 - .../widget-details.modal.less | 94 - .../client/app/views/widgets/widgets.controller.js | 151 - .../app/views/widgets/widgets.controller.spec.js | 19 - .../client/app/views/widgets/widgets.less | 60 - .../client/app/views/widgets/widgets.tpl.html | 77 - ecomp-portal-FE/client/assets/images/cloud.png | Bin 132244 -> 0 bytes ecomp-portal-FE/client/assets/images/grips.png | Bin 951 -> 0 bytes ecomp-portal-FE/client/assets/images/sprite.png | Bin 446 -> 0 bytes .../bower_components/angular-animate/.bower.json | 20 - .../bower_components/angular-animate/README.md | 68 - .../angular-animate/angular-animate.min.js.map | 8 - .../bower_components/angular-animate/bower.json | 10 - .../bower_components/angular-animate/index.js | 2 - .../bower_components/angular-animate/package.json | 26 - .../bower_components/angular-aria/.bower.json | 20 - .../client/bower_components/angular-aria/README.md | 67 - .../angular-aria/angular-aria.min.js.map | 8 - .../bower_components/angular-aria/bower.json | 10 - .../client/bower_components/angular-aria/index.js | 2 - .../bower_components/angular-aria/package.json | 27 - .../bower_components/angular-bootstrap/.bower.json | 31 - .../bower_components/angular-bootstrap/.gitignore | 1 - .../bower_components/angular-bootstrap/.npmignore | 1 - .../bower_components/angular-bootstrap/README.md | 120 - .../bower_components/angular-bootstrap/bower.json | 19 - .../bower_components/angular-bootstrap/index.js | 2 - .../angular-bootstrap/package.json | 23 - .../angular-bootstrap/ui-bootstrap-csp.css | 115 - .../angular-bootstrap/ui-bootstrap-tpls.js | 7715 ---- .../angular-bootstrap/ui-bootstrap-tpls.min.js | 10 - .../angular-bootstrap/ui-bootstrap.js | 7351 --- .../angular-bootstrap/ui-bootstrap.min.js | 10 - .../bower_components/angular-cache/.bower.json | 45 - .../bower_components/angular-cache/CHANGELOG.md | 353 - .../client/bower_components/angular-cache/LICENSE | 20 - .../bower_components/angular-cache/README.md | 671 - .../bower_components/angular-cache/TRANSITION.md | 98 - .../bower_components/angular-cache/bower.json | 35 - .../build_examples/browserify/README.md | 1 - .../angular-cache/build_examples/browserify/app.js | 11 - .../build_examples/browserify/index.html | 11 - .../angular-cache/build_examples/r.js/README.md | 3 - .../angular-cache/build_examples/r.js/app.js | 9 - .../angular-cache/build_examples/r.js/index.html | 14 - .../angular-cache/build_examples/r.js/main.js | 22 - .../build_examples/r.js/require.config.js | 6 - .../angular-cache/build_examples/webpack/README.md | 1 - .../angular-cache/build_examples/webpack/app.js | 8 - .../build_examples/webpack/index.html | 11 - .../build_examples/webpack/webpack.config.js | 11 - .../build_examples/webpack_es6/README.md | 1 - .../build_examples/webpack_es6/app.js | 8 - .../build_examples/webpack_es6/index.html | 11 - .../build_examples/webpack_es6/webpack.config.js | 16 - .../build_examples/webpack_es6_2/README.md | 1 - .../build_examples/webpack_es6_2/app.js | 8 - .../build_examples/webpack_es6_2/index.html | 11 - .../build_examples/webpack_es6_2/webpack.config.js | 16 - .../bower_components/angular-cache/circle.yml | 6 - .../angular-cache/dist/angular-cache.js | 1111 - .../angular-cache/dist/angular-cache.js.map | 1 - .../angular-cache/dist/angular-cache.min.js | 2 - .../angular-cache/dist/angular-cache.min.map | 1 - .../angular-cache/rollup.config.js | 22 - .../angular-cache/scripts/postbuild.js | 21 - .../bower_components/angular-cookies/.bower.json | 20 - .../bower_components/angular-cookies/README.md | 68 - .../angular-cookies/angular-cookies.min.js.map | 8 - .../bower_components/angular-cookies/bower.json | 10 - .../bower_components/angular-cookies/index.js | 2 - .../bower_components/angular-cookies/package.json | 26 - .../bower_components/angular-gestures/.bower.json | 32 - .../bower_components/angular-gestures/LICENSE.md | 21 - .../bower_components/angular-gestures/README.md | 82 - .../bower_components/angular-gestures/bower.json | 23 - .../bower_components/angular-gestures/gestures.js | 158 - .../angular-gestures/gestures.min.js | 1 - .../bower_components/angular-material/.bower.json | 24 - .../bower_components/angular-material/.gitignore | 5 - .../bower_components/angular-material/CHANGELOG.md | 1543 - .../bower_components/angular-material/LICENSE | 21 - .../bower_components/angular-material/README.md | 240 - .../angular-material/angular-material-mocks.js | 77 - .../angular-material/angular-material.css | 6795 --- .../angular-material/angular-material.js | 13909 ------ .../angular-material/angular-material.min.css | 6 - .../angular-material/angular-material.min.js | 15 - .../bower_components/angular-material/bower.json | 14 - .../bottomSheet/demoBasicUsage/img/icons/copy.svg | 1 - .../bottomSheet/demoBasicUsage/img/icons/copy2.svg | 1 - .../demoBasicUsage/img/icons/facebook.svg | 1 - .../demoBasicUsage/img/icons/hangout.svg | 1 - .../bottomSheet/demoBasicUsage/img/icons/mail.svg | 1 - .../demoBasicUsage/img/icons/message.svg | 1 - .../bottomSheet/demoBasicUsage/img/icons/print.svg | 1 - .../demoBasicUsage/img/icons/share-arrow.svg | 1 - .../demoBasicUsage/img/icons/twitter.svg | 2 - .../demoBasicUsage/img/icons/upload.svg | 1 - .../demos/chips/demoBasicUsage/style.scss | 39 - .../demos/chips/demoContactChips/style.scss | 47 - .../demos/gridList/demoBasicUsage/style.scss | 75 - .../demos/gridList/demoDynamicTiles/style.scss | 78 - .../demos/gridList/demoResponsiveUsage/style.scss | 0 .../img/icons/addShoppingCart.svg | 1 - .../demoLoadSvgIconsFromUrl/img/icons/android.svg | 1 - .../demoLoadSvgIconsFromUrl/img/icons/cake.svg | 1 - .../demos/icon/demoSvgIconSets/assets/cake.svg | 1 - .../icon/demoSvgIconSets/assets/core-icons.svg | 26 - .../icon/demoSvgIconSets/assets/social-icons.svg | 26 - .../img/icons/addShoppingCart.svg | 1 - .../icon/demoSvgIconsFromURL/img/icons/android.svg | 1 - .../icon/demoSvgIconsFromURL/img/icons/cake.svg | 1 - .../icon/demoUsingTemplateCache/assets/android.svg | 1 - .../icon/demoUsingTemplateCache/assets/cake.svg | 1 - .../demoUsingTemplateCache/assets/core-icons.svg | 26 - .../demos/input/demoIcons/icons/ic_email_24px.svg | 4 - .../demos/input/demoIcons/icons/ic_person_24px.svg | 4 - .../demos/input/demoIcons/icons/ic_phone_24px.svg | 4 - .../demos/input/demoIcons/icons/ic_place_24px.svg | 4 - .../demos/input/demoIcons/style.scss | 18 - .../demos/list/demoListControls/img/100-0.jpeg | Bin 2331 -> 0 bytes .../demos/list/demoListControls/img/100-1.jpeg | Bin 2816 -> 0 bytes .../demos/list/demoListControls/img/100-2.jpeg | Bin 3389 -> 0 bytes .../demos/tabs/demoDynamicHeight/style.scss | 13 - .../demos/tabs/demoDynamicTabs/style.scss | 44 - .../demos/tabs/demoStaticTabs/style.scss | 25 - .../toolbar/demoBasicUsage/img/icons/favorite.svg | 4 - .../toolbar/demoBasicUsage/img/icons/menu.svg | 4 - .../toolbar/demoBasicUsage/img/icons/more_vert.svg | 4 - .../bower_components/angular-material/index.js | 12 - .../autocomplete/autocomplete-default-theme.css | 24 - .../modules/closure/autocomplete/autocomplete.css | 220 - .../modules/closure/autocomplete/autocomplete.js | 794 - .../closure/backdrop/backdrop-default-theme.css | 9 - .../modules/closure/backdrop/backdrop.css | 59 - .../modules/closure/backdrop/backdrop.js | 38 - .../bottomSheet/bottomSheet-default-theme.css | 16 - .../modules/closure/bottomSheet/bottomSheet.css | 170 - .../modules/closure/bottomSheet/bottomSheet.js | 267 - .../closure/button/button-default-theme.css | 94 - .../modules/closure/button/button.css | 158 - .../modules/closure/button/button.js | 135 - .../modules/closure/card/card-default-theme.css | 12 - .../angular-material/modules/closure/card/card.css | 34 - .../angular-material/modules/closure/card/card.js | 84 - .../closure/checkbox/checkbox-default-theme.css | 47 - .../modules/closure/checkbox/checkbox.css | 125 - .../modules/closure/checkbox/checkbox.js | 166 - .../modules/closure/chips/chips-default-theme.css | 24 - .../modules/closure/chips/chips.css | 131 - .../modules/closure/chips/chips.js | 949 - .../closure/content/content-default-theme.css | 9 - .../modules/closure/content/content.css | 20 - .../modules/closure/content/content.js | 84 - .../angular-material/modules/closure/core/core.css | 2590 -- .../angular-material/modules/closure/core/core.js | 3779 -- .../modules/closure/core/default-theme.js | 4 - .../closure/dialog/dialog-default-theme.css | 12 - .../modules/closure/dialog/dialog.css | 111 - .../modules/closure/dialog/dialog.js | 713 - .../closure/divider/divider-default-theme.css | 9 - .../modules/closure/divider/divider.css | 14 - .../modules/closure/divider/divider.js | 45 - .../closure/gridList/gridList-default-theme.css | 6 - .../modules/closure/gridList/gridList.css | 68 - .../modules/closure/gridList/gridList.js | 762 - .../modules/closure/icon/icon-default-theme.css | 15 - .../angular-material/modules/closure/icon/icon.css | 20 - .../angular-material/modules/closure/icon/icon.js | 787 - .../modules/closure/input/input-default-theme.css | 46 - .../modules/closure/input/input.css | 162 - .../modules/closure/input/input.js | 371 - .../modules/closure/list/list-default-theme.css | 23 - .../angular-material/modules/closure/list/list.css | 147 - .../angular-material/modules/closure/list/list.js | 273 - .../angular-material/modules/closure/menu/menu.css | 6 - .../angular-material/modules/closure/menu/menu.js | 29 - .../progressCircular-default-theme.css | 36 - .../closure/progressCircular/progressCircular.css | 1306 - .../closure/progressCircular/progressCircular.js | 109 - .../progressLinear-default-theme.css | 27 - .../closure/progressLinear/progressLinear.css | 287 - .../closure/progressLinear/progressLinear.js | 126 - .../radioButton/radioButton-default-theme.css | 47 - .../modules/closure/radioButton/radioButton.css | 90 - .../modules/closure/radioButton/radioButton.js | 312 - .../closure/select/select-default-theme.css | 42 - .../modules/closure/select/select.css | 168 - .../modules/closure/select/select.js | 1056 - .../closure/sidenav/sidenav-default-theme.css | 9 - .../modules/closure/sidenav/sidenav.css | 99 - .../modules/closure/sidenav/sidenav.js | 424 - .../closure/slider/slider-default-theme.css | 56 - .../modules/closure/slider/slider.css | 220 - .../modules/closure/slider/slider.js | 403 - .../modules/closure/sticky/sticky.css | 21 - .../modules/closure/sticky/sticky.js | 315 - .../closure/subheader/subheader-default-theme.css | 16 - .../modules/closure/subheader/subheader.css | 63 - .../modules/closure/subheader/subheader.js | 93 - .../modules/closure/swipe/swipe.js | 72 - .../closure/switch/switch-default-theme.css | 33 - .../modules/closure/switch/switch.css | 110 - .../modules/closure/switch/switch.js | 169 - .../modules/closure/tabs/tabs-arrow.svg | 7 - .../modules/closure/tabs/tabs-default-theme.css | 82 - .../angular-material/modules/closure/tabs/tabs.css | 272 - .../angular-material/modules/closure/tabs/tabs.js | 867 - .../closure/textField/textField-default-theme.css | 30 - .../modules/closure/textField/textField.css | 111 - .../modules/closure/textField/textField.js | 145 - .../modules/closure/toast/toast-default-theme.css | 18 - .../modules/closure/toast/toast.css | 119 - .../modules/closure/toast/toast.js | 265 - .../closure/toolbar/toolbar-default-theme.css | 20 - .../modules/closure/toolbar/toolbar.css | 83 - .../modules/closure/toolbar/toolbar.js | 169 - .../closure/tooltip/tooltip-default-theme.css | 11 - .../modules/closure/tooltip/tooltip.css | 72 - .../modules/closure/tooltip/tooltip.js | 267 - .../modules/closure/whiteframe/whiteframe.css | 25 - .../modules/closure/whiteframe/whiteframe.js | 15 - .../modules/css/angular-material-layout.css | 2375 - .../js/autocomplete/autocomplete-default-theme.css | 24 - .../autocomplete-default-theme.min.css | 6 - .../modules/js/autocomplete/autocomplete.css | 220 - .../modules/js/autocomplete/autocomplete.js | 794 - .../modules/js/autocomplete/autocomplete.min.css | 6 - .../modules/js/autocomplete/autocomplete.min.js | 7 - .../modules/js/autocomplete/bower.json | 8 - .../modules/js/backdrop/backdrop-default-theme.css | 9 - .../js/backdrop/backdrop-default-theme.min.css | 6 - .../modules/js/backdrop/backdrop.css | 59 - .../modules/js/backdrop/backdrop.js | 39 - .../modules/js/backdrop/backdrop.min.css | 6 - .../modules/js/backdrop/backdrop.min.js | 7 - .../modules/js/backdrop/bower.json | 7 - .../js/bottomSheet/bottomSheet-default-theme.css | 16 - .../bottomSheet/bottomSheet-default-theme.min.css | 6 - .../modules/js/bottomSheet/bottomSheet.css | 170 - .../modules/js/bottomSheet/bottomSheet.js | 267 - .../modules/js/bottomSheet/bottomSheet.min.css | 6 - .../modules/js/bottomSheet/bottomSheet.min.js | 7 - .../modules/js/bottomSheet/bower.json | 8 - .../angular-material/modules/js/button/bower.json | 7 - .../modules/js/button/button-default-theme.css | 94 - .../modules/js/button/button-default-theme.min.css | 6 - .../angular-material/modules/js/button/button.css | 158 - .../angular-material/modules/js/button/button.js | 136 - .../modules/js/button/button.min.css | 6 - .../modules/js/button/button.min.js | 7 - .../angular-material/modules/js/card/bower.json | 7 - .../modules/js/card/card-default-theme.css | 12 - .../modules/js/card/card-default-theme.min.css | 6 - .../angular-material/modules/js/card/card.css | 34 - .../angular-material/modules/js/card/card.js | 85 - .../angular-material/modules/js/card/card.min.css | 6 - .../angular-material/modules/js/card/card.min.js | 7 - .../modules/js/checkbox/bower.json | 7 - .../modules/js/checkbox/checkbox-default-theme.css | 47 - .../js/checkbox/checkbox-default-theme.min.css | 6 - .../modules/js/checkbox/checkbox.css | 125 - .../modules/js/checkbox/checkbox.js | 167 - .../modules/js/checkbox/checkbox.min.css | 6 - .../modules/js/checkbox/checkbox.min.js | 7 - .../angular-material/modules/js/chips/bower.json | 8 - .../modules/js/chips/chips-default-theme.css | 24 - .../modules/js/chips/chips-default-theme.min.css | 6 - .../angular-material/modules/js/chips/chips.css | 131 - .../angular-material/modules/js/chips/chips.js | 949 - .../modules/js/chips/chips.min.css | 6 - .../angular-material/modules/js/chips/chips.min.js | 7 - .../angular-material/modules/js/content/bower.json | 7 - .../modules/js/content/content-default-theme.css | 9 - .../js/content/content-default-theme.min.css | 6 - .../modules/js/content/content.css | 20 - .../angular-material/modules/js/content/content.js | 85 - .../modules/js/content/content.min.css | 6 - .../modules/js/content/content.min.js | 7 - .../angular-material/modules/js/core/bower.json | 8 - .../angular-material/modules/js/core/core.css | 2590 -- .../angular-material/modules/js/core/core.js | 3779 -- .../angular-material/modules/js/core/core.min.css | 6 - .../angular-material/modules/js/core/core.min.js | 10 - .../modules/js/core/default-theme.js | 4 - .../angular-material/modules/js/dialog/bower.json | 8 - .../modules/js/dialog/dialog-default-theme.css | 12 - .../modules/js/dialog/dialog-default-theme.min.css | 6 - .../angular-material/modules/js/dialog/dialog.css | 111 - .../angular-material/modules/js/dialog/dialog.js | 713 - .../modules/js/dialog/dialog.min.css | 6 - .../modules/js/dialog/dialog.min.js | 7 - .../angular-material/modules/js/divider/bower.json | 7 - .../modules/js/divider/divider-default-theme.css | 9 - .../js/divider/divider-default-theme.min.css | 6 - .../modules/js/divider/divider.css | 14 - .../angular-material/modules/js/divider/divider.js | 46 - .../modules/js/divider/divider.min.css | 6 - .../modules/js/divider/divider.min.js | 7 - .../modules/js/gridList/bower.json | 7 - .../modules/js/gridList/gridList.css | 68 - .../modules/js/gridList/gridList.js | 763 - .../modules/js/gridList/gridList.min.css | 6 - .../modules/js/gridList/gridList.min.js | 7 - .../angular-material/modules/js/icon/bower.json | 7 - .../modules/js/icon/icon-default-theme.css | 15 - .../modules/js/icon/icon-default-theme.min.css | 6 - .../angular-material/modules/js/icon/icon.css | 20 - .../angular-material/modules/js/icon/icon.js | 788 - .../angular-material/modules/js/icon/icon.min.css | 6 - .../angular-material/modules/js/icon/icon.min.js | 7 - .../angular-material/modules/js/input/bower.json | 7 - .../modules/js/input/input-default-theme.css | 46 - .../modules/js/input/input-default-theme.min.css | 6 - .../angular-material/modules/js/input/input.css | 162 - .../angular-material/modules/js/input/input.js | 372 - .../modules/js/input/input.min.css | 6 - .../angular-material/modules/js/input/input.min.js | 7 - .../angular-material/modules/js/list/bower.json | 7 - .../modules/js/list/list-default-theme.css | 23 - .../modules/js/list/list-default-theme.min.css | 6 - .../angular-material/modules/js/list/list.css | 147 - .../angular-material/modules/js/list/list.js | 274 - .../angular-material/modules/js/list/list.min.css | 6 - .../angular-material/modules/js/list/list.min.js | 7 - .../angular-material/modules/js/menu/bower.json | 5 - .../angular-material/modules/js/menu/menu.css | 6 - .../angular-material/modules/js/menu/menu.js | 27 - .../angular-material/modules/js/menu/menu.min.css | 6 - .../angular-material/modules/js/menu/menu.min.js | 7 - .../modules/js/progressCircular/bower.json | 7 - .../progressCircular-default-theme.css | 36 - .../progressCircular-default-theme.min.css | 6 - .../js/progressCircular/progressCircular.css | 1306 - .../js/progressCircular/progressCircular.js | 110 - .../js/progressCircular/progressCircular.min.css | 6 - .../js/progressCircular/progressCircular.min.js | 7 - .../modules/js/progressLinear/bower.json | 7 - .../progressLinear-default-theme.css | 27 - .../progressLinear-default-theme.min.css | 6 - .../modules/js/progressLinear/progressLinear.css | 287 - .../modules/js/progressLinear/progressLinear.js | 127 - .../js/progressLinear/progressLinear.min.css | 6 - .../js/progressLinear/progressLinear.min.js | 7 - .../modules/js/radioButton/bower.json | 7 - .../js/radioButton/radioButton-default-theme.css | 47 - .../radioButton/radioButton-default-theme.min.css | 6 - .../modules/js/radioButton/radioButton.css | 90 - .../modules/js/radioButton/radioButton.js | 313 - .../modules/js/radioButton/radioButton.min.css | 6 - .../modules/js/radioButton/radioButton.min.js | 7 - .../angular-material/modules/js/select/bower.json | 8 - .../modules/js/select/select-default-theme.css | 42 - .../modules/js/select/select-default-theme.min.css | 6 - .../angular-material/modules/js/select/select.css | 168 - .../angular-material/modules/js/select/select.js | 1056 - .../modules/js/select/select.min.css | 6 - .../modules/js/select/select.min.js | 7 - .../angular-material/modules/js/sidenav/bower.json | 8 - .../modules/js/sidenav/sidenav-default-theme.css | 9 - .../js/sidenav/sidenav-default-theme.min.css | 6 - .../modules/js/sidenav/sidenav.css | 99 - .../angular-material/modules/js/sidenav/sidenav.js | 424 - .../modules/js/sidenav/sidenav.min.css | 6 - .../modules/js/sidenav/sidenav.min.js | 7 - .../angular-material/modules/js/slider/bower.json | 7 - .../modules/js/slider/slider-default-theme.css | 56 - .../modules/js/slider/slider-default-theme.min.css | 6 - .../angular-material/modules/js/slider/slider.css | 220 - .../angular-material/modules/js/slider/slider.js | 404 - .../modules/js/slider/slider.min.css | 6 - .../modules/js/slider/slider.min.js | 7 - .../angular-material/modules/js/sticky/bower.json | 8 - .../angular-material/modules/js/sticky/sticky.css | 21 - .../angular-material/modules/js/sticky/sticky.js | 315 - .../modules/js/sticky/sticky.min.css | 6 - .../modules/js/sticky/sticky.min.js | 7 - .../modules/js/subheader/bower.json | 8 - .../js/subheader/subheader-default-theme.css | 16 - .../js/subheader/subheader-default-theme.min.css | 6 - .../modules/js/subheader/subheader.css | 63 - .../modules/js/subheader/subheader.js | 93 - .../modules/js/subheader/subheader.min.css | 6 - .../modules/js/subheader/subheader.min.js | 7 - .../angular-material/modules/js/swipe/bower.json | 7 - .../angular-material/modules/js/swipe/swipe.js | 73 - .../angular-material/modules/js/swipe/swipe.min.js | 7 - .../angular-material/modules/js/switch/bower.json | 8 - .../modules/js/switch/switch-default-theme.css | 33 - .../modules/js/switch/switch-default-theme.min.css | 6 - .../angular-material/modules/js/switch/switch.css | 110 - .../angular-material/modules/js/switch/switch.js | 169 - .../modules/js/switch/switch.min.css | 6 - .../modules/js/switch/switch.min.js | 7 - .../angular-material/modules/js/tabs/bower.json | 8 - .../modules/js/tabs/tabs-default-theme.css | 82 - .../modules/js/tabs/tabs-default-theme.min.css | 6 - .../angular-material/modules/js/tabs/tabs.css | 272 - .../angular-material/modules/js/tabs/tabs.js | 867 - .../angular-material/modules/js/tabs/tabs.min.css | 6 - .../angular-material/modules/js/tabs/tabs.min.js | 7 - .../modules/js/textField/bower.json | 7 - .../js/textField/textField-default-theme.css | 30 - .../js/textField/textField-default-theme.min.css | 6 - .../modules/js/textField/textField.css | 111 - .../modules/js/textField/textField.js | 143 - .../modules/js/textField/textField.min.css | 6 - .../modules/js/textField/textField.min.js | 7 - .../angular-material/modules/js/toast/bower.json | 8 - .../modules/js/toast/toast-default-theme.css | 18 - .../modules/js/toast/toast-default-theme.min.css | 6 - .../angular-material/modules/js/toast/toast.css | 119 - .../angular-material/modules/js/toast/toast.js | 265 - .../modules/js/toast/toast.min.css | 6 - .../angular-material/modules/js/toast/toast.min.js | 7 - .../angular-material/modules/js/toolbar/bower.json | 8 - .../modules/js/toolbar/toolbar-default-theme.css | 20 - .../js/toolbar/toolbar-default-theme.min.css | 6 - .../modules/js/toolbar/toolbar.css | 83 - .../angular-material/modules/js/toolbar/toolbar.js | 169 - .../modules/js/toolbar/toolbar.min.css | 6 - .../modules/js/toolbar/toolbar.min.js | 7 - .../angular-material/modules/js/tooltip/bower.json | 7 - .../modules/js/tooltip/tooltip-default-theme.css | 11 - .../js/tooltip/tooltip-default-theme.min.css | 6 - .../modules/js/tooltip/tooltip.css | 72 - .../angular-material/modules/js/tooltip/tooltip.js | 268 - .../modules/js/tooltip/tooltip.min.css | 6 - .../modules/js/tooltip/tooltip.min.js | 7 - .../modules/js/whiteframe/bower.json | 5 - .../modules/js/whiteframe/whiteframe.css | 25 - .../modules/js/whiteframe/whiteframe.js | 16 - .../modules/js/whiteframe/whiteframe.min.css | 6 - .../modules/js/whiteframe/whiteframe.min.js | 7 - .../bower_components/angular-material/package.json | 48 - .../bower_components/angular-messages/.bower.json | 20 - .../bower_components/angular-messages/LICENSE.md | 21 - .../bower_components/angular-messages/README.md | 68 - .../angular-messages/angular-messages.js | 739 - .../angular-messages/angular-messages.min.js | 12 - .../angular-messages/angular-messages.min.js.map | 8 - .../bower_components/angular-messages/bower.json | 10 - .../bower_components/angular-messages/index.js | 2 - .../bower_components/angular-messages/package.json | 32 - .../bower_components/angular-mocks/.bower.json | 20 - .../bower_components/angular-mocks/LICENSE.md | 21 - .../bower_components/angular-mocks/README.md | 63 - .../angular-mocks/angular-mocks.js | 3170 -- .../bower_components/angular-mocks/bower.json | 10 - .../angular-mocks/ngAnimateMock.js | 2 - .../bower_components/angular-mocks/ngMock.js | 2 - .../bower_components/angular-mocks/ngMockE2E.js | 2 - .../bower_components/angular-mocks/package.json | 34 - .../bower_components/angular-resource/.bower.json | 20 - .../bower_components/angular-resource/README.md | 68 - .../angular-resource/angular-resource.min.js.map | 8 - .../bower_components/angular-resource/bower.json | 10 - .../bower_components/angular-resource/index.js | 2 - .../bower_components/angular-resource/package.json | 26 - .../bower_components/angular-route/.bower.json | 20 - .../bower_components/angular-route/README.md | 68 - .../angular-route/angular-route.min.js.map | 8 - .../bower_components/angular-route/bower.json | 10 - .../client/bower_components/angular-route/index.js | 2 - .../bower_components/angular-route/package.json | 26 - .../bower_components/angular-sanitize/.bower.json | 20 - .../bower_components/angular-sanitize/README.md | 68 - .../angular-sanitize/angular-sanitize.min.js.map | 8 - .../bower_components/angular-sanitize/bower.json | 10 - .../bower_components/angular-sanitize/index.js | 2 - .../bower_components/angular-sanitize/package.json | 26 - .../bower_components/angular-scenario/.bower.json | 20 - .../bower_components/angular-scenario/LICENSE.md | 21 - .../bower_components/angular-scenario/README.md | 61 - .../angular-scenario/angular-scenario.js | 44994 ------------------- .../bower_components/angular-scenario/bower.json | 10 - .../jstd-scenario-adapter-config.js | 6 - .../angular-scenario/jstd-scenario-adapter.js | 185 - .../bower_components/angular-scenario/package.json | 33 - .../angular-smart-table/.bower.json | 38 - .../angular-smart-table/.gitignore | 7 - .../angular-smart-table/.travis.yml | 12 - .../angular-smart-table/ISSUE_TEMPLATE.md | 15 - .../angular-smart-table/bower.json | 29 - .../angular-smart-table/changeLog.md | 175 - .../angular-smart-table/dist/smart-table.js | 534 - .../angular-smart-table/dist/smart-table.min.js | 6 - .../dist/smart-table.min.js.map | 1 - .../angular-smart-table/gulpFile.js | 60 - .../bower_components/angular-smart-table/index.js | 2 - .../angular-smart-table/package.json | 29 - .../bower_components/angular-smart-table/readme.md | 72 - .../angular-smart-table/src/bottom.txt | 1 - .../angular-smart-table/src/smart-table.module.js | 7 - .../angular-smart-table/src/stConfig.js | 26 - .../angular-smart-table/src/stPagination.js | 80 - .../angular-smart-table/src/stPipe.js | 36 - .../angular-smart-table/src/stSearch.js | 43 - .../angular-smart-table/src/stSelectRow.js | 26 - .../angular-smart-table/src/stSort.js | 82 - .../angular-smart-table/src/stTable.js | 219 - .../angular-smart-table/src/top.txt | 2 - .../bower_components/angular-ui-router/.bower.json | 34 - .../angular-ui-router/CHANGELOG.md | 316 - .../angular-ui-router/CONTRIBUTING.md | 65 - .../bower_components/angular-ui-router/LICENSE | 21 - .../bower_components/angular-ui-router/README.md | 252 - .../bower_components/angular-ui-router/bower.json | 24 - .../angular-ui-router/release/angular-ui-router.js | 4539 -- .../release/angular-ui-router.min.js | 8 - .../angular-ui-router/src/common.js | 293 - .../angular-ui-router/src/resolve.js | 252 - .../angular-ui-router/src/state.js | 1470 - .../angular-ui-router/src/stateDirectives.js | 391 - .../angular-ui-router/src/stateFilters.js | 39 - .../angular-ui-router/src/templateFactory.js | 110 - .../angular-ui-router/src/urlMatcherFactory.js | 1081 - .../angular-ui-router/src/urlRouter.js | 431 - .../bower_components/angular-ui-router/src/view.js | 45 - .../angular-ui-router/src/viewDirective.js | 351 - .../angular-ui-router/src/viewScroll.js | 52 - .../bower_components/angular-uuid/.bower.json | 23 - .../client/bower_components/angular-uuid/LICENCE | 19 - .../bower_components/angular-uuid/bower.json | 13 - .../client/bower_components/angular-uuid/uuid.js | 21 - .../bower_components/angular-uuid/uuid.min.js | 7 - .../client/bower_components/angular/.bower.json | 18 - .../client/bower_components/angular/README.md | 64 - .../bower_components/angular/angular.min.js.gzip | Bin 54462 -> 0 bytes .../bower_components/angular/angular.min.js.map | 8 - .../client/bower_components/angular/bower.json | 9 - .../client/bower_components/angular/index.js | 2 - .../client/bower_components/angular/package.json | 25 - .../client/bower_components/es5-shim/.bower.json | 43 - .../client/bower_components/es5-shim/CHANGES | 404 - .../bower_components/es5-shim/CONTRIBUTORS.md | 27 - .../client/bower_components/es5-shim/LICENSE | 22 - .../client/bower_components/es5-shim/Makefile | 63 - .../client/bower_components/es5-shim/README.md | 190 - .../client/bower_components/es5-shim/bower.json | 33 - .../bower_components/es5-shim/component.json | 19 - .../client/bower_components/es5-shim/es5-sham.js | 563 - .../client/bower_components/es5-shim/es5-sham.map | 1 - .../bower_components/es5-shim/es5-sham.min.js | 7 - .../client/bower_components/es5-shim/es5-shim.js | 2065 - .../client/bower_components/es5-shim/es5-shim.map | 1 - .../bower_components/es5-shim/es5-shim.min.js | 7 - .../client/bower_components/es5-shim/package.json | 75 - .../client/bower_components/es5-shim/shims.json | 7 - .../client/bower_components/hammerjs/.bower.json | 27 - .../client/bower_components/hammerjs/CHANGELOG.md | 54 - .../bower_components/hammerjs/CONTRIBUTING.md | 41 - .../client/bower_components/hammerjs/LICENSE.md | 21 - .../client/bower_components/hammerjs/README.md | 51 - .../client/bower_components/hammerjs/bower.json | 16 - .../client/bower_components/hammerjs/changelog.js | 71 - .../client/bower_components/hammerjs/hammer.js | 2643 -- .../client/bower_components/hammerjs/hammer.min.js | 7 - .../bower_components/hammerjs/hammer.min.js.map | 1 - .../bower_components/hammerjs/hammer.min.map | 1 - .../client/bower_components/jqTree/.bower.json | 28 - .../client/bower_components/jqTree/.editorconfig | 12 - .../client/bower_components/jqTree/.gitignore | 2 - .../client/bower_components/jqTree/.travis.yml | 12 - .../client/bower_components/jqTree/LICENSE | 202 - .../client/bower_components/jqTree/README.md | 63 - .../client/bower_components/jqTree/_config.yml | 18 - .../bower_components/jqTree/_entries/01_general.md | 7 - .../jqTree/_entries/02_introduction.md | 9 - .../jqTree/_entries/03_features.md | 15 - .../bower_components/jqTree/_entries/04_demo.html | 34 - .../jqTree/_entries/05_requirements.md | 6 - .../jqTree/_entries/06_downloads.md | 9 - .../jqTree/_entries/07_tutorial.md | 77 - .../jqTree/_entries/08_examples.md | 8 - .../jqTree/_entries/09_usecases.md | 17 - .../jqTree/_entries/10_changelog.md | 233 - .../bower_components/jqTree/_entries/11_options.md | 6 - .../jqTree/_entries/12_autoescape.md | 6 - .../jqTree/_entries/13_autoopen.md | 28 - .../jqTree/_entries/14_buttonleft.md | 12 - .../jqTree/_entries/15_closedicon.md | 12 - .../bower_components/jqTree/_entries/16_data.md | 46 - .../jqTree/_entries/17_datafilter.md | 17 - .../jqTree/_entries/18_data-url.md | 45 - .../jqTree/_entries/19_draganddrop.md | 18 - .../jqTree/_entries/20_keyboardsupport.md | 14 - .../jqTree/_entries/21_oncanmove.md | 22 - .../jqTree/_entries/22_oncanmoveto.md | 22 - .../jqTree/_entries/23_oncanselectnode.md | 26 - .../jqTree/_entries/24_oncreateli.md | 16 - .../jqTree/_entries/25_onismovehandle.md | 17 - .../jqTree/_entries/26_onloadfailed.md | 15 - .../jqTree/_entries/27_onloading.md | 22 - .../jqTree/_entries/28_openedicon.md | 12 - .../jqTree/_entries/29_openfolderdelay.md | 13 - .../bower_components/jqTree/_entries/30_rtl.md | 18 - .../jqTree/_entries/31_savestate.md | 42 - .../jqTree/_entries/32_selectable.md | 18 - .../bower_components/jqTree/_entries/33_slide.md | 12 - .../jqTree/_entries/34_usecontextmenu.md | 14 - .../jqTree/_entries/35_functions.md | 6 - .../jqTree/_entries/36_addnodeafter.md | 20 - .../jqTree/_entries/36a_addparentnode.md | 20 - .../jqTree/_entries/37_addnodebefore.md | 8 - .../jqTree/_entries/38_appendnode.md | 50 - .../jqTree/_entries/39_closenode.md | 23 - .../bower_components/jqTree/_entries/40_destroy.md | 12 - .../jqTree/_entries/41_getnodebycallback.md | 24 - .../jqTree/_entries/42_getnodebyid.md | 21 - .../jqTree/_entries/43_getnodebyhtmlelement.md | 29 - .../jqTree/_entries/44_getselectednode.md | 10 - .../jqTree/_entries/45_getstate.md | 19 - .../bower_components/jqTree/_entries/46_gettree.md | 12 - .../jqTree/_entries/47_loaddata.md | 46 - .../jqTree/_entries/48_loaddatafromurl.md | 55 - .../jqTree/_entries/49_movedown.md | 8 - .../jqTree/_entries/50_movenode.md | 15 - .../bower_components/jqTree/_entries/51_moveup.md | 8 - .../jqTree/_entries/52_opennode.md | 44 - .../bower_components/jqTree/_entries/53_reload.md | 22 - .../jqTree/_entries/54_removenode.md | 12 - .../jqTree/_entries/55_selectnode.md | 24 - .../jqTree/_entries/56_scrolltonode.md | 13 - .../jqTree/_entries/57_setoption.md | 12 - .../jqTree/_entries/58_setstate.md | 8 - .../bower_components/jqTree/_entries/59_toggle.md | 8 - .../bower_components/jqTree/_entries/60_tojson.md | 13 - .../jqTree/_entries/61_updatenode.md | 50 - .../bower_components/jqTree/_entries/62_events.md | 6 - .../jqTree/_entries/63_tree-click.md | 37 - .../jqTree/_entries/64_tree-close.md | 15 - .../jqTree/_entries/65_tree-contextmenu.md | 21 - .../jqTree/_entries/66_tree-dblclick.md | 19 - .../jqTree/_entries/67_tree-init.md | 15 - .../jqTree/_entries/68_tree-move.md | 73 - .../jqTree/_entries/69_tree-open.md | 15 - .../jqTree/_entries/70_tree-select.md | 28 - .../jqTree/_entries/71_multiple-selection.md | 9 - .../jqTree/_entries/72_add-to-selection.md | 11 - .../jqTree/_entries/73_get-selected-nodes.md | 10 - .../jqTree/_entries/74_is-node-selected.md | 11 - .../jqTree/_entries/75_remove-from-selection.md | 11 - .../jqTree/_entries/76_node-functions.md | 13 - .../jqTree/_entries/77_children.md | 12 - .../bower_components/jqTree/_entries/78_getdata.md | 17 - .../jqTree/_entries/79_getlevel.md | 13 - .../jqTree/_entries/80_getnextnode.md | 12 - .../jqTree/_entries/81_getnextsibling.md | 10 - .../jqTree/_entries/82_getpreviousnode.md | 12 - .../jqTree/_entries/83_getprevioussibling.md | 10 - .../bower_components/jqTree/_entries/84_parent.md | 10 - .../bower_components/jqTree/_entries/insert.py | 46 - .../bower_components/jqTree/_entries/renumber.py | 38 - .../jqTree/_examples/01_load_json_data.html | 47 - .../_examples/02_load_json_data_from_server.html | 31 - .../jqTree/_examples/03_drag_and_drop.html | 44 - .../jqTree/_examples/04_save_state.html | 52 - .../jqTree/_examples/05_load_on_demand.html | 70 - .../jqTree/_examples/06_autoescape.html | 47 - .../jqTree/_examples/07_autoscroll.html | 49 - .../jqTree/_examples/08_multiple_select.html | 72 - .../jqTree/_examples/09_custom_html.html | 68 - .../jqTree/_examples/10_icon_buttons.html | 28 - .../jqTree/_examples/11_right-to-left.html | 27 - .../jqTree/_examples/12_button_on_right.html | 27 - .../bower_components/jqTree/_layouts/base.html | 49 - .../jqTree/_layouts/frontpage.html | 20 - .../bower_components/jqTree/_layouts/page.html | 7 - .../client/bower_components/jqTree/bower.json | 18 - .../client/bower_components/jqTree/coffeelint.json | 122 - .../client/bower_components/jqTree/gulpfile.coffee | 57 - .../client/bower_components/jqTree/gulpfile.js | 2 - .../client/bower_components/jqTree/index.html | 48 - .../bower_components/jqTree/jqtree-circle.png | Bin 239 -> 0 bytes .../client/bower_components/jqTree/jqtree.css | 132 - .../bower_components/jqTree/jqtree.jquery.json | 23 - .../client/bower_components/jqTree/jqtree.scss | 197 - .../client/bower_components/jqTree/karma.conf.js | 59 - .../jqTree/lib/drag_and_drop_handler.js | 489 - .../jqTree/lib/elements_renderer.js | 220 - .../bower_components/jqTree/lib/key_handler.js | 120 - .../bower_components/jqTree/lib/mouse.widget.js | 191 - .../client/bower_components/jqTree/lib/node.js | 588 - .../bower_components/jqTree/lib/node_element.js | 226 - .../jqTree/lib/save_state_handler.js | 238 - .../bower_components/jqTree/lib/scroll_handler.js | 137 - .../jqTree/lib/select_node_handler.js | 111 - .../bower_components/jqTree/lib/simple.widget.js | 125 - .../bower_components/jqTree/lib/tree.jquery.js | 1101 - .../client/bower_components/jqTree/lib/util.js | 49 - .../client/bower_components/jqTree/lib/version.js | 1 - .../client/bower_components/jqTree/package.json | 51 - .../bower_components/jqTree/phantomjs/runner.js | 193 - .../bower_components/jqTree/phantomjs/server.js | 14 - .../client/bower_components/jqTree/screenshot.png | Bin 31319 -> 0 bytes .../client/bower_components/jqTree/sitemap.txt | 13 - .../jqTree/src/drag_and_drop_handler.coffee | 491 - .../jqTree/src/elements_renderer.coffee | 237 - .../client/bower_components/jqTree/src/header.txt | 17 - .../bower_components/jqTree/src/key_handler.coffee | 107 - .../jqTree/src/mouse.widget.coffee | 184 - .../client/bower_components/jqTree/src/node.coffee | 490 - .../jqTree/src/node_element.coffee | 170 - .../jqTree/src/save_state_handler.coffee | 208 - .../jqTree/src/scroll_handler.coffee | 114 - .../jqTree/src/select_node_handler.coffee | 84 - .../jqTree/src/simple.widget.coffee | 107 - .../bower_components/jqTree/src/tree.jquery.coffee | 918 - .../client/bower_components/jqTree/src/util.coffee | 48 - .../bower_components/jqTree/src/version.coffee | 1 - .../bower_components/jqTree/src_test/karma-test.js | 17 - .../bower_components/jqTree/src_test/test.js | 5 - .../jqTree/src_test/test_jqtree.js | 1390 - .../bower_components/jqTree/src_test/test_tree.js | 726 - .../bower_components/jqTree/src_test/test_util.js | 34 - .../jqTree/src_test/utils_for_test.js | 107 - .../bower_components/jqTree/static/bower.json | 16 - .../bower_components/blanket/dist/qunit/blanket.js | 5299 --- .../bootstrap/dist/css/bootstrap-theme.min.css | 6 - .../bootstrap/dist/css/bootstrap.min.css | 6 - .../dist/fonts/glyphicons-halflings-regular.eot | Bin 20127 -> 0 bytes .../dist/fonts/glyphicons-halflings-regular.svg | 288 - .../dist/fonts/glyphicons-halflings-regular.ttf | Bin 45404 -> 0 bytes .../dist/fonts/glyphicons-halflings-regular.woff | Bin 23424 -> 0 bytes .../dist/fonts/glyphicons-halflings-regular.woff2 | Bin 18028 -> 0 bytes .../bootstrap/dist/js/bootstrap.min.js | 7 - .../fontawesome/css/font-awesome.min.css | 4 - .../fontawesome/fonts/FontAwesome.otf | Bin 134808 -> 0 bytes .../fontawesome/fonts/fontawesome-webfont.eot | Bin 165742 -> 0 bytes .../fontawesome/fonts/fontawesome-webfont.svg | 2671 -- .../fontawesome/fonts/fontawesome-webfont.ttf | Bin 165548 -> 0 bytes .../fontawesome/fonts/fontawesome-webfont.woff | Bin 98024 -> 0 bytes .../fontawesome/fonts/fontawesome-webfont.woff2 | Bin 77160 -> 0 bytes .../bower_components/jquery-1/dist/jquery.js | 11008 ----- .../bower_components/jquery-1/dist/jquery.min.js | 5 - .../bower_components/jquery-2/dist/jquery.js | 9814 ---- .../bower_components/jquery-2/dist/jquery.min.js | 4 - .../jquery-cookie/jquery.cookie.js | 117 - .../jquery-mockjax/dist/jquery.mockjax.js | 1003 - .../static/bower_components/jquery/dist/jquery.js | 10220 ----- .../bower_components/jquery/dist/jquery.min.js | 4 - .../static/bower_components/json3/lib/json3.js | 902 - .../bower_components/pygments/css/monokai.css | 65 - .../static/bower_components/qunit/qunit/qunit.css | 431 - .../static/bower_components/qunit/qunit/qunit.js | 4366 -- .../jqTree/static/documentation.css | 171 - .../jqTree/static/documentation.js | 51 - .../bower_components/jqTree/static/example.css | 60 - .../bower_components/jqTree/static/example.scss | 86 - .../bower_components/jqTree/static/example_data.js | 128 - .../jqTree/static/examples/autoescape.js | 19 - .../jqTree/static/examples/autoscroll.js | 8 - .../jqTree/static/examples/button-on-right.js | 15 - .../jqTree/static/examples/custom_html.js | 32 - .../jqTree/static/examples/drag_and_drop.js | 15 - .../jqTree/static/examples/icon_buttons.js | 14 - .../jqTree/static/examples/load_json_data.js | 21 - .../static/examples/load_json_data_from_server.js | 11 - .../jqTree/static/examples/load_on_demand.js | 20 - .../jqTree/static/examples/multiple_select.js | 27 - .../jqTree/static/examples/right-to-left.js | 13 - .../jqTree/static/examples/save_state.js | 13 - .../bower_components/jqTree/static/spinner.gif | Bin 673 -> 0 bytes .../client/bower_components/jqTree/test/test.html | 24 - .../bower_components/jqTree/test/test_build.js | 3267 -- .../jqTree/test/test_jquery_1.html | 16 - .../jqTree/test/test_jquery_2.html | 16 - .../client/bower_components/jqTree/tree.jquery.js | 3640 -- .../bower_components/jquery-mousewheel/.bower.json | 27 - .../jquery-mousewheel/ChangeLog.md | 147 - .../bower_components/jquery-mousewheel/LICENSE.txt | 37 - .../bower_components/jquery-mousewheel/README.md | 76 - .../bower_components/jquery-mousewheel/bower.json | 17 - .../jquery-mousewheel/jquery.mousewheel.js | 221 - .../jquery-mousewheel/jquery.mousewheel.min.js | 8 - .../jquery.event.drag-new/.bower.json | 13 - .../event.drag/jquery.event.drag.js | 402 - .../event.drag/jquery.event.drag.live.js | 87 - .../event.drag/test/binding.js | 64 - .../event.drag/test/handlers.js | 160 - .../event.drag/test/index.html | 28 - .../event.drag/test/interaction.js | 198 - .../jquery.event.drag-new/event.drag/test/live.js | 41 - .../event.drag/test/method.js | 64 - .../event.drag/test/properties.js | 71 - .../event.drag/test/requirements.js | 24 - .../jquery.event.drag-new/event.drag/test/touch.js | 206 - .../event.drop/jquery.event.drop.js | 302 - .../event.drop/jquery.event.drop.live.js | 93 - .../event.drop/test/binding.js | 32 - .../event.drop/test/handlers.js | 130 - .../event.drop/test/index.html | 32 - .../event.drop/test/interaction.js | 134 - .../jquery.event.drag-new/event.drop/test/live.js | 60 - .../event.drop/test/method.js | 63 - .../event.drop/test/properties.js | 62 - .../event.drop/test/requirements.js | 37 - .../event.drop/test/tolerance.js | 189 - .../jquery.event.drag-new/event.drop/test/touch.js | 140 - .../event.keyend/jquery.event.keyend.js | 20 - .../event.linger/jquery.event.linger.js | 190 - .../event.linger/test/binding.js | 45 - .../event.linger/test/handlers.js | 111 - .../event.linger/test/index.html | 24 - .../event.linger/test/interaction.js | 231 - .../event.linger/test/method.js | 43 - .../event.linger/test/requirements.js | 23 - .../event.wheel/jquery.event.wheel.js | 50 - .../jquery.event.drag-new/fire/jquery.fire.js | 171 - .../jquery.event.drag-new/fire/test/custom.js | 61 - .../jquery.event.drag-new/fire/test/form.js | 50 - .../jquery.event.drag-new/fire/test/index.html | 26 - .../jquery.event.drag-new/fire/test/key.js | 52 - .../jquery.event.drag-new/fire/test/mouse.js | 54 - .../jquery.event.drag-new/fire/test/mutation.js | 52 - .../jquery.event.drag-new/fire/test/object.js | 50 - .../fire/test/requirements.js | 26 - .../jquery.event.drag-new/fire/test/touch.js | 61 - .../jquery.event.drag-new/jquery/jquery-1.4.2.js | 6240 --- .../jquery.event.drag-new/jquery/jquery-1.4.4.js | 7179 --- .../jquery.event.drag-new/jquery/jquery-1.5b1.js | 8068 ---- .../jquery.event.drag-new/jquery/jquery-1.7.2.js | 9404 ---- .../jquery.event.drag-new/jquery/jquery.js | 9404 ---- .../jquery.event.drag-new/jquery/qunit.css | 118 - .../jquery.event.drag-new/jquery/qunit.js | 1069 - .../bower_components/jquery.newstape/.bower.json | 34 - .../bower_components/jquery.newstape/bower.json | 24 - .../jquery.newstape/dist/jquery.newstape.min.js | 1 - .../bower_components/jquery.newstape/gulpfile.js | 22 - .../jquery.newstape/jquery.newstape.js | 135 - .../bower_components/jquery.newstape/package.json | 8 - .../bower_components/jquery.newstape/readme.md | 99 - .../client/bower_components/jquery/.bower.json | 25 - .../client/bower_components/jquery/AUTHORS.txt | 278 - .../client/bower_components/jquery/LICENSE.txt | 36 - .../client/bower_components/jquery/README.md | 65 - .../client/bower_components/jquery/bower.json | 14 - .../client/bower_components/jquery/dist/jquery.js | 9814 ---- .../bower_components/jquery/dist/jquery.min.js | 4 - .../bower_components/jquery/dist/jquery.min.map | 1 - .../jquery/external/sizzle/LICENSE.txt | 36 - .../jquery/external/sizzle/dist/sizzle.js | 2143 - .../jquery/external/sizzle/dist/sizzle.min.js | 3 - .../jquery/external/sizzle/dist/sizzle.min.map | 1 - .../client/bower_components/jquery/src/.jshintrc | 29 - .../client/bower_components/jquery/src/ajax.js | 845 - .../bower_components/jquery/src/ajax/jsonp.js | 100 - .../bower_components/jquery/src/ajax/load.js | 83 - .../bower_components/jquery/src/ajax/parseJSON.js | 13 - .../bower_components/jquery/src/ajax/parseXML.js | 27 - .../bower_components/jquery/src/ajax/script.js | 68 - .../jquery/src/ajax/var/location.js | 3 - .../bower_components/jquery/src/ajax/var/nonce.js | 5 - .../bower_components/jquery/src/ajax/var/rquery.js | 3 - .../client/bower_components/jquery/src/ajax/xhr.js | 167 - .../bower_components/jquery/src/attributes.js | 11 - .../bower_components/jquery/src/attributes/attr.js | 142 - .../jquery/src/attributes/classes.js | 177 - .../bower_components/jquery/src/attributes/prop.js | 125 - .../jquery/src/attributes/support.js | 36 - .../bower_components/jquery/src/attributes/val.js | 177 - .../bower_components/jquery/src/callbacks.js | 232 - .../client/bower_components/jquery/src/core.js | 494 - .../bower_components/jquery/src/core/access.js | 65 - .../bower_components/jquery/src/core/init.js | 134 - .../bower_components/jquery/src/core/parseHTML.js | 41 - .../bower_components/jquery/src/core/ready.js | 103 - .../jquery/src/core/var/rsingleTag.js | 5 - .../client/bower_components/jquery/src/css.js | 502 - .../jquery/src/css/addGetHookIf.js | 24 - .../bower_components/jquery/src/css/adjustCSS.js | 65 - .../bower_components/jquery/src/css/curCSS.js | 60 - .../jquery/src/css/defaultDisplay.js | 72 - .../jquery/src/css/hiddenVisibleSelectors.js | 18 - .../bower_components/jquery/src/css/showHide.js | 48 - .../bower_components/jquery/src/css/support.js | 121 - .../jquery/src/css/var/cssExpand.js | 3 - .../jquery/src/css/var/getStyles.js | 15 - .../jquery/src/css/var/isHidden.js | 16 - .../bower_components/jquery/src/css/var/rmargin.js | 3 - .../jquery/src/css/var/rnumnonpx.js | 5 - .../bower_components/jquery/src/css/var/swap.js | 24 - .../client/bower_components/jquery/src/data.js | 187 - .../bower_components/jquery/src/data/Data.js | 200 - .../jquery/src/data/var/acceptData.js | 18 - .../jquery/src/data/var/dataPriv.js | 5 - .../jquery/src/data/var/dataUser.js | 5 - .../client/bower_components/jquery/src/deferred.js | 158 - .../bower_components/jquery/src/deprecated.js | 32 - .../bower_components/jquery/src/dimensions.js | 54 - .../client/bower_components/jquery/src/effects.js | 629 - .../bower_components/jquery/src/effects/Tween.js | 121 - .../jquery/src/effects/animatedSelector.js | 13 - .../client/bower_components/jquery/src/event.js | 711 - .../bower_components/jquery/src/event/ajax.js | 20 - .../bower_components/jquery/src/event/alias.js | 27 - .../bower_components/jquery/src/event/focusin.js | 53 - .../bower_components/jquery/src/event/support.js | 9 - .../bower_components/jquery/src/event/trigger.js | 183 - .../bower_components/jquery/src/exports/amd.js | 24 - .../bower_components/jquery/src/exports/global.js | 26 - .../client/bower_components/jquery/src/intro.js | 44 - .../client/bower_components/jquery/src/jquery.js | 37 - .../bower_components/jquery/src/manipulation.js | 481 - .../jquery/src/manipulation/_evalUrl.js | 20 - .../jquery/src/manipulation/buildFragment.js | 102 - .../jquery/src/manipulation/getAll.js | 21 - .../jquery/src/manipulation/setGlobalEval.js | 20 - .../jquery/src/manipulation/support.js | 33 - .../jquery/src/manipulation/var/rcheckableType.js | 3 - .../jquery/src/manipulation/var/rscriptType.js | 3 - .../jquery/src/manipulation/var/rtagName.js | 3 - .../jquery/src/manipulation/wrapMap.js | 27 - .../client/bower_components/jquery/src/offset.js | 218 - .../client/bower_components/jquery/src/outro.js | 2 - .../client/bower_components/jquery/src/queue.js | 143 - .../bower_components/jquery/src/queue/delay.js | 22 - .../bower_components/jquery/src/selector-native.js | 211 - .../bower_components/jquery/src/selector-sizzle.js | 14 - .../client/bower_components/jquery/src/selector.js | 1 - .../bower_components/jquery/src/serialize.js | 125 - .../bower_components/jquery/src/traversing.js | 175 - .../jquery/src/traversing/findFilter.js | 100 - .../jquery/src/traversing/var/dir.js | 20 - .../jquery/src/traversing/var/rneedsContext.js | 6 - .../jquery/src/traversing/var/siblings.js | 15 - .../client/bower_components/jquery/src/var/arr.js | 3 - .../bower_components/jquery/src/var/class2type.js | 5 - .../bower_components/jquery/src/var/concat.js | 5 - .../bower_components/jquery/src/var/document.js | 3 - .../jquery/src/var/documentElement.js | 5 - .../bower_components/jquery/src/var/hasOwn.js | 5 - .../bower_components/jquery/src/var/indexOf.js | 5 - .../client/bower_components/jquery/src/var/pnum.js | 3 - .../client/bower_components/jquery/src/var/push.js | 5 - .../bower_components/jquery/src/var/rcssNum.js | 7 - .../bower_components/jquery/src/var/rnotwhite.js | 3 - .../bower_components/jquery/src/var/slice.js | 5 - .../bower_components/jquery/src/var/support.js | 5 - .../bower_components/jquery/src/var/toString.js | 5 - .../client/bower_components/jquery/src/wrap.js | 79 - .../client/bower_components/json3/.bower.json | 47 - .../client/bower_components/json3/CHANGELOG.md | 44 - .../client/bower_components/json3/CONTRIBUTING.md | 3 - .../client/bower_components/json3/LICENSE | 20 - .../client/bower_components/json3/README.md | 152 - .../client/bower_components/json3/bower.json | 38 - .../client/bower_components/json3/lib/json3.js | 902 - .../client/bower_components/json3/lib/json3.min.js | 17 - .../client/bower_components/lodash/.bower.json | 14 - .../client/bower_components/lodash/.editorconfig | 12 - .../client/bower_components/lodash/.gitattributes | 1 - .../lodash/.github/CONTRIBUTING.md | 78 - .../client/bower_components/lodash/.gitignore | 9 - .../client/bower_components/lodash/.jscsrc | 97 - .../lodash/.markdown-doctest-setup.js | 48 - .../client/bower_components/lodash/.travis.yml | 86 - .../client/bower_components/lodash/LICENSE | 47 - .../client/bower_components/lodash/README.md | 46 - .../bower_components/lodash/dist/lodash.core.js | 3830 -- .../lodash/dist/lodash.core.min.js | 28 - .../bower_components/lodash/dist/lodash.fp.js | 879 - .../bower_components/lodash/dist/lodash.fp.min.js | 17 - .../client/bower_components/lodash/dist/lodash.js | 16404 ------- .../bower_components/lodash/dist/lodash.min.js | 127 - .../bower_components/lodash/dist/mapping.fp.js | 371 - .../client/bower_components/lodash/doc/README.md | 10897 ----- .../bower_components/lodash/fp/_baseConvert.js | 466 - .../bower_components/lodash/fp/_convertBrowser.js | 18 - .../client/bower_components/lodash/fp/_mapping.js | 309 - .../bower_components/lodash/fp/placeholder.js | 6 - .../bower_components/lodash/lib/common/file.js | 71 - .../bower_components/lodash/lib/common/mapping.js | 9 - .../bower_components/lodash/lib/common/minify.js | 39 - .../lodash/lib/common/uglify.options.js | 23 - .../bower_components/lodash/lib/common/util.js | 27 - .../bower_components/lodash/lib/fp/build-dist.js | 55 - .../bower_components/lodash/lib/fp/build-doc.js | 65 - .../lodash/lib/fp/build-modules.js | 120 - .../lodash/lib/fp/template/doc/wiki.jst | 227 - .../lib/fp/template/modules/_falseOptions.jst | 7 - .../lodash/lib/fp/template/modules/_util.jst | 14 - .../lodash/lib/fp/template/modules/alias.jst | 1 - .../lodash/lib/fp/template/modules/category.jst | 2 - .../lodash/lib/fp/template/modules/convert.jst | 18 - .../lodash/lib/fp/template/modules/fp.jst | 2 - .../lodash/lib/fp/template/modules/module.jst | 5 - .../lodash/lib/fp/template/modules/thru.jst | 5 - .../bower_components/lodash/lib/main/build-dist.js | 30 - .../bower_components/lodash/lib/main/build-doc.js | 55 - .../lodash/lib/main/build-modules.js | 34 - .../client/bower_components/lodash/lodash.js | 16404 ------- .../client/bower_components/lodash/package.json | 55 - .../bower_components/lodash/perf/asset/perf-ui.js | 131 - .../client/bower_components/lodash/perf/index.html | 69 - .../client/bower_components/lodash/perf/perf.js | 1977 - .../bower_components/lodash/test/asset/test-ui.js | 170 - .../bower_components/lodash/test/asset/worker.js | 15 - .../bower_components/lodash/test/backbone.html | 170 - .../client/bower_components/lodash/test/fp.html | 41 - .../client/bower_components/lodash/test/index.html | 351 - .../client/bower_components/lodash/test/remove.js | 27 - .../bower_components/lodash/test/saucelabs.js | 914 - .../client/bower_components/lodash/test/test-fp.js | 2173 - .../client/bower_components/lodash/test/test.js | 26729 ----------- .../bower_components/lodash/test/underscore.html | 484 - .../lodash/vendor/backbone/LICENSE | 22 - .../lodash/vendor/backbone/backbone.js | 1920 - .../lodash/vendor/backbone/test/collection.js | 1998 - .../lodash/vendor/backbone/test/events.js | 706 - .../lodash/vendor/backbone/test/model.js | 1418 - .../lodash/vendor/backbone/test/noconflict.js | 13 - .../lodash/vendor/backbone/test/router.js | 1062 - .../lodash/vendor/backbone/test/setup/dom-setup.js | 4 - .../vendor/backbone/test/setup/environment.js | 45 - .../lodash/vendor/backbone/test/sync.js | 239 - .../lodash/vendor/backbone/test/view.js | 495 - .../lodash/vendor/firebug-lite/license.txt | 30 - .../lodash/vendor/firebug-lite/skin/xp/blank.gif | Bin 43 -> 0 bytes .../vendor/firebug-lite/skin/xp/buttonBg.png | Bin 167 -> 0 bytes .../vendor/firebug-lite/skin/xp/buttonBgHover.png | Bin 171 -> 0 bytes .../vendor/firebug-lite/skin/xp/debugger.css | 331 - .../lodash/vendor/firebug-lite/skin/xp/detach.png | Bin 655 -> 0 bytes .../vendor/firebug-lite/skin/xp/detachHover.png | Bin 586 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/disable.gif | Bin 340 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/disable.png | Bin 543 -> 0 bytes .../vendor/firebug-lite/skin/xp/disableHover.gif | Bin 344 -> 0 bytes .../vendor/firebug-lite/skin/xp/disableHover.png | Bin 512 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/down.png | Bin 637 -> 0 bytes .../vendor/firebug-lite/skin/xp/downActive.png | Bin 543 -> 0 bytes .../vendor/firebug-lite/skin/xp/downHover.png | Bin 526 -> 0 bytes .../vendor/firebug-lite/skin/xp/errorIcon-sm.png | Bin 447 -> 0 bytes .../vendor/firebug-lite/skin/xp/errorIcon.gif | Bin 365 -> 0 bytes .../vendor/firebug-lite/skin/xp/errorIcon.png | Bin 457 -> 0 bytes .../vendor/firebug-lite/skin/xp/firebug-1.3a2.css | 817 - .../vendor/firebug-lite/skin/xp/firebug.IE6.css | 20 - .../lodash/vendor/firebug-lite/skin/xp/firebug.css | 3147 -- .../vendor/firebug-lite/skin/xp/firebug.html | 215 - .../lodash/vendor/firebug-lite/skin/xp/firebug.png | Bin 1167 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/group.gif | Bin 158 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/html.css | 272 - .../vendor/firebug-lite/skin/xp/infoIcon.gif | Bin 359 -> 0 bytes .../vendor/firebug-lite/skin/xp/infoIcon.png | Bin 524 -> 0 bytes .../vendor/firebug-lite/skin/xp/loading_16.gif | Bin 1553 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/min.png | Bin 552 -> 0 bytes .../vendor/firebug-lite/skin/xp/minHover.png | Bin 485 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/off.png | Bin 742 -> 0 bytes .../vendor/firebug-lite/skin/xp/offHover.png | Bin 680 -> 0 bytes .../firebug-lite/skin/xp/pixel_transparent.gif | Bin 43 -> 0 bytes .../vendor/firebug-lite/skin/xp/roundCorner.svg | 6 - .../lodash/vendor/firebug-lite/skin/xp/search.gif | Bin 550 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/search.png | Bin 685 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/shadow.gif | Bin 4364 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/shadow2.gif | Bin 3093 -> 0 bytes .../vendor/firebug-lite/skin/xp/shadowAlpha.png | Bin 3403 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/sprite.png | Bin 40027 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabHoverLeft.png | Bin 438 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabHoverMid.png | Bin 261 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabHoverRight.png | Bin 436 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/tabLeft.png | Bin 449 -> 0 bytes .../firebug-lite/skin/xp/tabMenuCheckbox.png | Bin 220 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabMenuPin.png | Bin 207 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabMenuRadio.png | Bin 192 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabMenuTarget.png | Bin 142 -> 0 bytes .../firebug-lite/skin/xp/tabMenuTargetHover.png | Bin 148 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/tabMid.png | Bin 262 -> 0 bytes .../vendor/firebug-lite/skin/xp/tabRight.png | Bin 448 -> 0 bytes .../firebug-lite/skin/xp/textEditorBorders.gif | Bin 117 -> 0 bytes .../firebug-lite/skin/xp/textEditorBorders.png | Bin 3144 -> 0 bytes .../firebug-lite/skin/xp/textEditorCorners.gif | Bin 1821 -> 0 bytes .../firebug-lite/skin/xp/textEditorCorners.png | Bin 3960 -> 0 bytes .../vendor/firebug-lite/skin/xp/titlebarMid.png | Bin 273 -> 0 bytes .../vendor/firebug-lite/skin/xp/toolbarMid.png | Bin 242 -> 0 bytes .../vendor/firebug-lite/skin/xp/tree_close.gif | Bin 300 -> 0 bytes .../vendor/firebug-lite/skin/xp/tree_open.gif | Bin 202 -> 0 bytes .../vendor/firebug-lite/skin/xp/twistyClosed.png | Bin 334 -> 0 bytes .../vendor/firebug-lite/skin/xp/twistyOpen.png | Bin 309 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/up.png | Bin 619 -> 0 bytes .../vendor/firebug-lite/skin/xp/upActive.png | Bin 551 -> 0 bytes .../lodash/vendor/firebug-lite/skin/xp/upHover.png | Bin 526 -> 0 bytes .../vendor/firebug-lite/skin/xp/warningIcon.gif | Bin 357 -> 0 bytes .../vendor/firebug-lite/skin/xp/warningIcon.png | Bin 516 -> 0 bytes .../vendor/firebug-lite/src/firebug-lite-debug.js | 31176 ------------- .../lodash/vendor/json-js/json2.js | 519 - .../lodash/vendor/underscore/LICENSE | 23 - .../lodash/vendor/underscore/test/arrays.js | 555 - .../lodash/vendor/underscore/test/chaining.js | 99 - .../lodash/vendor/underscore/test/collections.js | 896 - .../vendor/underscore/test/cross-document.js | 141 - .../lodash/vendor/underscore/test/functions.js | 728 - .../lodash/vendor/underscore/test/objects.js | 1102 - .../lodash/vendor/underscore/test/utility.js | 420 - .../lodash/vendor/underscore/underscore-min.js | 6 - .../lodash/vendor/underscore/underscore.js | 1620 - .../client/bower_components/ng-dialog/.bower.json | 53 - .../client/bower_components/ng-dialog/CHANGELOG.md | 106 - .../bower_components/ng-dialog/CONTRIBUTING.md | 37 - .../client/bower_components/ng-dialog/README.md | 701 - .../client/bower_components/ng-dialog/bower.json | 43 - .../ng-dialog/css/ngDialog-custom-width.css | 3 - .../ng-dialog/css/ngDialog-theme-default.css | 191 - .../ng-dialog/css/ngDialog-theme-default.min.css | 1 - .../ng-dialog/css/ngDialog-theme-plain.css | 131 - .../ng-dialog/css/ngDialog-theme-plain.min.css | 1 - .../bower_components/ng-dialog/css/ngDialog.css | 114 - .../ng-dialog/css/ngDialog.min.css | 1 - .../bower_components/ng-dialog/js/ngDialog.js | 895 - .../bower_components/ng-dialog/js/ngDialog.min.js | 2 - .../bower_components/ng-dialog/karma.conf.js | 46 - .../client/bower_components/ng-dialog/package.json | 65 - .../bower_components/ng-dialog/protractor.conf.js | 75 - .../client/bower_components/ng-dialog/server.js | 9 - .../client/bower_components/ng-dialog/yarn.lock | 3281 -- .../client/bower_components/ui-select/.bower.json | 41 - .../client/bower_components/ui-select/CHANGELOG.md | 180 - .../bower_components/ui-select/CONTRIBUTING.md | 161 - .../client/bower_components/ui-select/LICENSE | 20 - .../client/bower_components/ui-select/README.md | 57 - .../client/bower_components/ui-select/bower.json | 31 - .../bower_components/ui-select/composer.json | 29 - .../bower_components/ui-select/deploy-docs.sh | 31 - .../bower_components/ui-select/dist/select.css | 271 - .../bower_components/ui-select/dist/select.js | 2217 - .../bower_components/ui-select/dist/select.min.css | 7 - .../bower_components/ui-select/dist/select.min.js | 9 - .../bower_components/ui-select/docs/assets/app.js | 1 - .../bower_components/ui-select/docs/assets/demo.js | 461 - .../ui-select/docs/assets/docs.css | 339 - .../ui-select/docs/assets/plunkr.js | 110 - .../bower_components/ui-select/docs/index.html | 191 - .../ui-select/docs/partials/_footer.html | 2 - .../ui-select/docs/partials/_header.html | 64 - .../client/bower_components/ui-select/index.js | 2 - .../client/bower_components/ui-select/package.json | 61 - .../angular-att-gridster/angular-gridster.js | 2240 - .../angular-att-gridster/css/angular-gridster.css | 173 - .../styles/angular-gridster.css | 173 - .../angular-att-gridster/styles/ui-gridster.css | 116 - .../angular-att-gridster/ui-gridster-tpls-0.0.1.js | 86 - .../angular-att-gridster/ui-gridster-tpls.js | 164 - .../angular-att-gridster/ui-gridster.js | 131 - .../angular.att.abs-2.17.0/CHANGELOG.md | 1190 - .../angular.att.abs-2.17.0/README.md | 70 - .../angular.att.abs-2.17.0/att-abs-tpls.js | 20422 --------- .../angular.att.abs-2.17.0/att-abs-tpls.min.js | 22 - .../angular.att.abs-2.17.0/styles/base.css | 1 - .../angular.att.abs-2.17.0/styles/btn.css | 1 - .../angular.att.abs-2.17.0/styles/demo.css | 2 - .../angular.att.abs-2.17.0/styles/dtpk.css | 9 - .../angular.att.abs-2.17.0/styles/frms.css | 1 - .../styles/ie/backgroundsize.min.htc | 12 - .../angular.att.abs-2.17.0/styles/images/down.png | Bin 1059 -> 0 bytes .../angular.att.abs-2.17.0/styles/images/up.png | Bin 1064 -> 0 bytes .../styles/images/upanddown.png | Bin 1033 -> 0 bytes .../styles/pages/iconography.css | 2 - .../angular.att.abs-2.17.0/styles/sldr.css | 1 - .../angular.att.abs-2.17.0/styles/style.css | 1 - .../angular.att.abs-2.17.0/styles/tbs.css | 1 - .../ionicons-2.0.1/css/ionicons.css | 1480 - ecomp-portal-FE/client/configurations/dev.json | 65 - .../client/configurations/devServer.json | 48 - ecomp-portal-FE/client/configurations/integ.json | 65 - ecomp-portal-FE/client/configurations/mock.json | 51 - ecomp-portal-FE/client/favicon.ico | Bin 1150 -> 0 bytes ecomp-portal-FE/client/index.html | 279 - .../kpi-dashboard/controllers/AAI-controller.js | 48 - .../kpi-dashboard/controllers/APPC-controller.js | 48 - .../kpi-dashboard/controllers/ASDC-controller.js | 45 - .../controllers/Closedloop-controller.js | 48 - .../kpi-dashboard/controllers/DCAE-controller.js | 375 - .../kpi-dashboard/controllers/DMaaP-controller.js | 48 - .../kpi-dashboard/controllers/ECOMP-controller.js | 25 - .../controllers/ECOMP_Portal-controller.js | 48 - .../controllers/InfrastructurePortal-controller.js | 48 - .../kpi-dashboard/controllers/MSO-controller.js | 48 - .../kpi-dashboard/controllers/Policy-controller.js | 48 - .../kpi-dashboard/controllers/kpi-whitelist.js | 22 - .../client/kpi-dashboard/views/AAI/AAI_KPI.html | 33 - .../kpi-dashboard/views/AAI/AAI_Metrics.html | 33 - .../views/AAI/AAI_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/APPC/APPC_KPI.html | 33 - .../kpi-dashboard/views/APPC/APPC_Metrics.html | 33 - .../views/APPC/APPC_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/ASDC/ASDC_KPI.html | 33 - .../kpi-dashboard/views/ASDC/ASDC_Metrics.html | 33 - .../views/ASDC/ASDC_UserDefinedKPI.html | 33 - .../views/Closedloop/Closedloop_KPI.html | 33 - .../views/Closedloop/Closedloop_Metrics.html | 33 - .../Closedloop/Closedloop_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/DCAE/DCAE_KPI.html | 204 - .../kpi-dashboard/views/DCAE/DCAE_Metrics.html | 41 - .../views/DCAE/DCAE_UserDefinedKPI.html | 33 - .../views/DCAE_DASH/dcae_locations.csv | 10 - .../views/DCAE_DASH/dcae_locations.html | 431 - .../views/DCAE_DASH/dcae_locations1.csv | 7 - .../kpi-dashboard/views/DCAE_DASH/lib/d3.v3.min.js | 24 - .../kpi-dashboard/views/DCAE_DASH/lib/leaflet.css | 497 - .../kpi-dashboard/views/DCAE_DASH/lib/leaflet.js | 28 - .../views/DCAE_DASH/static/visjs/legend_v2.js | 85 - .../kpi-dashboard/views/DMaaP/DMaaP_KPI.html | 33 - .../kpi-dashboard/views/DMaaP/DMaaP_Metrics.html | 33 - .../views/DMaaP/DMaaP_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/ECOMP.html | 30 - .../views/ECOMP_Portal/ECOMP_Portal_KPI.html | 33 - .../views/ECOMP_Portal/ECOMP_Portal_Metrics.html | 33 - .../ECOMP_Portal/ECOMP_Portal_UserDefinedKPI.html | 33 - .../InfrastructurePortal_KPI.html | 33 - .../InfrastructurePortal_Metrics.html | 33 - .../InfrastructurePortal_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/MSO/MSO_KPI.html | 33 - .../kpi-dashboard/views/MSO/MSO_Metrics.html | 33 - .../views/MSO/MSO_UserDefinedKPI.html | 33 - .../kpi-dashboard/views/Policy/Policy_KPI.html | 33 - .../kpi-dashboard/views/Policy/Policy_Metrics.html | 33 - .../views/Policy/Policy_UserDefinedKPI.html | 33 - .../client/kpi-dashboard/views/sec-level-tabs.html | 29 - .../client/kpi-dashboard/views/top-level-tabs.html | 44 - .../client/kpi-dashboard/views/userapi-edit.html | 71 - .../client/kpi-dashboard/views/userstory-edit.html | 102 - .../mock/ecomp/data/admins/account-admins.json | 140 - .../data/applications/applications-onboarding.json | 128 - .../mock/ecomp/data/applications/user-apps.json | 62 - .../mock/ecomp/data/functional-menu/dev.json | 22 - .../mock/ecomp/data/functional-menu/favorites.json | 27 - .../ecomp/data/functional-menu/menu-items.json | 674 - .../data/functional-menu/menu-items_small.json | 674 - .../ecomp/data/user-profile/user-static-info.json | 7 - .../mock/ecomp/data/widgets/widgets.json | 39 - ecomp-portal-FE/pom.xml | 151 - pom.xml | 68 +- 2511 files changed, 236904 insertions(+), 667164 deletions(-) delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/portal.iml delete mode 100644 .idea/vcs.xml create mode 100644 ecomp-portal-BE-common-test/.classpath create mode 100644 ecomp-portal-BE-common-test/.gitignore create mode 100644 ecomp-portal-BE-common-test/.project create mode 100644 ecomp-portal-BE-common-test/.settings/org.eclipse.core.resources.prefs create mode 100644 ecomp-portal-BE-common-test/.settings/org.eclipse.jdt.core.prefs create mode 100644 ecomp-portal-BE-common-test/README.md create mode 100644 ecomp-portal-BE-common-test/license/licenses.properties create mode 100644 ecomp-portal-BE-common-test/license/my_license/header.txt create mode 100644 ecomp-portal-BE-common-test/license/my_license/license.txt create mode 100644 ecomp-portal-BE-common-test/pom.xml create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppCatalogControllerTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppContactUsControllerTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/FunctionalMenuControllerTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserNotificationControllerTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserRolesControllerTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/MockEPUser.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/PopulateSampleTestData.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RemoveSampleTestData.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RestURLsTestSuite.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/ApplicationCommonContextTestSuite.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/MockitoTestSuite.java create mode 100644 ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/service/FunctionalMenuServiceImplTest.java create mode 100644 ecomp-portal-BE-common-test/src/main/resources/PopulateTestData.sql create mode 100644 ecomp-portal-BE-common-test/src/main/resources/RemoveTestData.sql create mode 100644 ecomp-portal-BE-common/.gitignore create mode 100644 ecomp-portal-BE-common/license/licenses.properties create mode 100644 ecomp-portal-BE-common/license/my_license/header.txt create mode 100644 ecomp-portal-BE-common/license/my_license/license.txt create mode 100644 ecomp-portal-BE-common/pom.xml create mode 100644 ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/command/EPLoginBean.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/command/PostSearchBean.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerConfig.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerMVCConfig.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPFusionBaseController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedBaseController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedRESTfulBaseController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPUnRestrictedBaseController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/sessionmgt/SessionCommunicationController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/controller/RolesApprovalSystemController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemRoleApproval.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/FusionLicenseManagerImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/LicenseableClassImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/model/Result.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppCatalogController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppContactUsController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequest.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AuditLogController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BEPropertyReaderController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthAccountController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthenticationController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ConsulClientController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/FunctionalMenuController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/GetAccessController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/HealthCheckController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ManifestController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceProxyController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/RoleManageController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/SharedContextRestController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserNotificationController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserRolesController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApplications.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/App.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUs.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppIdAndNameTransportModel.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppsResponse.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BEProperty.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BasicAuthCredentials.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpoint.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpointAccount.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppCatalogRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequest.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequestDetail.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsManualSortPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsSortPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserNotification.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPWidgetsManualSortPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRoleId.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAuditLog.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EpUserAppRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/ExternalSystemAccess.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/FunctionalMenuItemWithAppID.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResult.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResultId.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceData.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceParameter.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserAppSelection.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserWidgetSelection.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/RoleApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/SharedContext.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserIdRoleId.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/Widget.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalog.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalogParameter.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetParameterResult.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetServiceHeaders.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCatalogItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCategoryFunctionsItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppContactUsItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/CommonWidgetsEnum.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestResponse.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestStatusEnum.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/SearchResultItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/exceptions/NoHealthyServiceException.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/interceptor/PortalResourceInterceptor.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/HealthMonitor.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserContextListener.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserSessionListener.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppCommonServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AllAppsWithRolesForUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/Analytics.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppCatalogPersonalization.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppNameIdIsAdmin.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppWithRolesForUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppsListWithAdminRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRolesList.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidget.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidgetMeta.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsManualPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsSortPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPDeleteAppsManualSortPref.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPWidgetsSortPreference.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemExtVO.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemVO.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpRoleNotificationItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidget.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidgetMeta.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItemJson.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FieldsValidator.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItem.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItemWithRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/LocalRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingWidget.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdmin.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdminUserRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteRole.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteUserWithRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RoleInAppForUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RolesInAppForUser.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserApplicationRoles.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserWithNameSurnameTitle.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/WidgetCatalogPersonalization.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/CustomLoggingFilter.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompVersion.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/HashMapFromList.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/ParallelExecutor.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/PortalConstants.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/AdminAuthExtension.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileServiceImpl.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/CoreTimeoutHandler.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/ManageService.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/SessionCommunication.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/TimeoutHandler.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/EPUserUtils.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SystemType.java create mode 100644 ecomp-portal-BE-common/src/main/java/org/openecomp/portalsdk/core/lm/FusionLicenseManagerUtils.java rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp}/META-INF/MANIFEST.MF (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/defs/definitions.xml create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/defs/definitions.xml rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp}/WEB-INF/fusion/jsp/.gitignore (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Workflow.hbm.xml create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/error.jsp create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/index.jsp create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login.jsp create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login_external.jsp rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/angular-sanitize.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/angular.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/app.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/att-abs-tpls-1.2.51.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/attHeaderSnippet.js (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeader_new.js rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/att_abs_tpls.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/checklist-model.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/checklist-model.min.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/d7100892.modernizr.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/ebiz_keepalive.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/footer.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/footer_new.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/gestures.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/ng_base.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/ebz/angular_js/ui-charts-tpls.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/fusion/images/login_button.gif (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/js/jquery-1.10.2.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/js/jquery-ui.js (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp/WEB-INF}/static/js/jquery.mask.min.js (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/WEB-INF/web.xml rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp}/images/cache/README.txt (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/index.jsp rename {ecomp-portal-FE/client/bower_components/angular-animate => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-animate.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-animate => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-animate.min.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-aria => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-aria.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-aria => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-aria.min.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-cookies => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-cookies.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-cookies => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-cookies.min.js (100%) rename {ecomp-portal-FE/client/bower_components/angular => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-csp.css (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-message-format.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-message-format.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-messages.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-messages.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-mocks.js rename {ecomp-portal-FE/client/bower_components/angular-resource => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-resource.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-resource => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-resource.min.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-route => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-route.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-route => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-route.min.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-sanitize => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-sanitize.js (100%) rename {ecomp-portal-FE/client/bower_components/angular-sanitize => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular-sanitize.min.js (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-scenario.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-touch.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-touch.min.js rename {ecomp-portal-FE/client/bower_components/angular => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular.js (100%) rename {ecomp-portal-FE/client/bower_components/angular => ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5}/angular.min.js (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/errors.json create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/version.json create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/version.txt create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-ui/ui-bootstrap-tpls-1.1.2.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-ui/ui-bootstrap-tpls-1.2.4.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-ui/ui-sortable/v0.13.4/sortable.min.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/utils/js/browserCheck.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/ebz/angular_js/angular-sanitize.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/ebz/angular_js/angular.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/ebz/angular_js/app.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/ebz/angular_js/ebiz_keepalive.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/ebz/angular_js/gestures.js rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp}/static/fusion/images/ecomp-login.jpg (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/fusion/images/ecomp.png rename {ecomp-portal-BE/war => ecomp-portal-BE-common/src/main/webapp}/static/fusion/images/ecomp_trans.png (100%) create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/js/jquery-1.10.2.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/js/jquery-ui.js create mode 100644 ecomp-portal-BE-common/src/main/webapp/static/js/jquery.mask.min.js create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/controller/shared-context-test.properties create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java create mode 100644 ecomp-portal-BE-common/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java rename {ecomp-portal-BE => ecomp-portal-BE-os}/.gitignore (100%) create mode 100644 ecomp-portal-BE-os/README.md rename {ecomp-portal-BE => ecomp-portal-BE-os}/distribution.xml (100%) create mode 100644 ecomp-portal-BE-os/ecomp-portal-resources/sql scripts/Apps_Users_OnBoarding_Script.sql create mode 100644 ecomp-portal-BE-os/ecomp-portal-resources/sql scripts/EcompPortalDDLMySql_1610_Complete_OS.sql create mode 100644 ecomp-portal-BE-os/ecomp-portal-resources/sql scripts/EcompPortalDMLMySql_1610_Complete_OS.sql create mode 100644 ecomp-portal-BE-os/license/licenses.properties create mode 100644 ecomp-portal-BE-os/license/my_license/header.txt create mode 100644 ecomp-portal-BE-os/license/my_license/license.txt create mode 100644 ecomp-portal-BE-os/pom.xml rename {ecomp-portal-BE => ecomp-portal-BE-os}/resources/META-INF/MANIFEST.MF (100%) create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java create mode 100644 ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java rename {ecomp-portal-BE => ecomp-portal-BE-os}/src/main/resources/cache.ccf (100%) rename {ecomp-portal-BE => ecomp-portal-BE-os}/src/main/resources/logback.xml (100%) rename {ecomp-portal-BE => ecomp-portal-BE-os}/src/main/resources/openid-connect.properties (100%) rename {ecomp-portal-BE => ecomp-portal-BE-os}/src/main/resources/openid-keystore.jwks (100%) rename {ecomp-portal-BE => ecomp-portal-BE-os}/src/main/resources/portal.properties (100%) create mode 100644 ecomp-portal-BE-os/src/main/webapp/META-INF/MANIFEST.MF rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/cache.ccf (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/quartz.properties (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/raptor.properties (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/raptor_app_fusion.properties (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/raptor_db_fusion.properties (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/raptor_pdf.properties (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/conf/sql.properties (100%) create mode 100644 ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/defs/definitions.xml (100%) create mode 100644 ecomp-portal-BE-os/src/main/webapp/WEB-INF/fusion/conf/fusion.properties rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/fusion/defs/definitions.xml (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/error.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/index.jsp (100%) create mode 100644 ecomp-portal-BE-os/src/main/webapp/WEB-INF/jsp/login.jsp rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/oid-admin.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/oid-home.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/oid-login.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/oid-user.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/jsp/welcome.jsp (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/oid-context.xml (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/tags/copyright.tag (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/tags/footer.tag (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/tags/header.tag (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/tags/topbar.tag (100%) rename {ecomp-portal-BE/war => ecomp-portal-BE-os/src/main/webapp}/WEB-INF/web.xml (100%) create mode 100644 ecomp-portal-BE-os/src/main/webapp/images/cache/README.txt create mode 100644 ecomp-portal-BE-os/src/main/webapp/index.jsp create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/shared-context-test.properties create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java create mode 100644 ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java delete mode 100644 ecomp-portal-BE/README.md delete mode 100644 ecomp-portal-BE/ecomp-portal-resources/sql scripts/Apps_Users_OnBoarding_Script.sql delete mode 100644 ecomp-portal-BE/ecomp-portal-resources/sql scripts/EcompPortalDDLMySql_1610_Complete_OS.sql delete mode 100644 ecomp-portal-BE/ecomp-portal-resources/sql scripts/EcompPortalDMLMySql_1610_Complete_OS.sql delete mode 100644 ecomp-portal-BE/pom.xml delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/command/EPLoginBean.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/command/PostSearchBean.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/EPFusionBaseController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/EPRestrictedBaseController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/EPRestrictedRESTfulBaseController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/EPUnRestrictedBaseController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/LoginController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/LoginService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/UserProfileController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/WelcomeController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/controller/sessionmgt/SessionCommunicationController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/controller/KpiDashboardController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiApiStats.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiServiceSupported.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiUserStoryStats.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpidashProperties.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/model/Result.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/AppCatalogController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/AppContactUsController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/AppsController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/DashboardController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/FunctionalMenuController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/GetAccessController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/HealthCheckController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/ManifestController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/SharedContextRestController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/UserRolesController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsController.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApp.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApplications.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUs.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUsTransportModel.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AppIdAndNameTransportModel.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/AppsResponse.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/EPApp.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/EPRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/EPUser.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/EPUserApp.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/EcompApp.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResult.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResultId.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/PersUserAppSelection.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/SharedContext.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/UserIdRoleId.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/UserRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/UserRoles.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/domain/Widget.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCatalogItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCategoryFunctionsItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppContactUsItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/CommonWidgetsEnum.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestResponse.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestStatusEnum.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ecomp/model/SearchResultItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/interceptor/PortalResourceInterceptor.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/listener/HealthMonitor.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/listener/UserContextListener.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/listener/UserSessionListener.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPAppService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPAuditService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPAuditServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPLdapService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPLdapServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPLoginService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPLoginServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPRoleService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/EPRoleServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/GetAccessService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/GetAccessServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/ManifestService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/ManifestServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/SharedContextService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/SharedContextServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/UserService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/WidgetService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/service/WidgetServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/AllAppsWithRolesForUser.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/AppCatalogPersonalization.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/AppNameIdIsAdmin.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/AppWithRolesForUser.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/AppsListWithAdminRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidget.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidgetMeta.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/EventWidget.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/EventWidgetMeta.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItemJson.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FieldsValidator.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItem.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItemJson.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/LocalRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingWidget.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdmin.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdminUserRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/RemoteRole.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/RemoteUserWithRoles.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/RoleInAppForUser.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/RolesInAppForUser.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/UserApplicationRoles.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/transport/UserWithNameSurnameTitle.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/CustomLoggingFilter.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/EcompVersion.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/HashMapFromList.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/portal/utils/ParallelExecutor.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/scheduler/Register.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/AdminAuthExtension.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/EPProfileService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/EPProfileServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/CoreTimeoutHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/ManageService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/RemoteWebServiceCallService.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/RemoteWebServiceCallServiceImpl.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/SessionCommunication.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/service/sessionmgt/TimeoutHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/util/EPUserUtils.java delete mode 100644 ecomp-portal-BE/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestClient.java delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextRestControllerTest.java delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/controller/SharedContextTestProperties.java delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/controller/shared-context-test.properties delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/listener/HealthMonitorTest.java delete mode 100644 ecomp-portal-BE/src/test/java/org/openecomp/portalapp/portal/utils/EcompPortalUtilsTest.java delete mode 100644 ecomp-portal-BE/war/WEB-INF/conf/kpidash.properties delete mode 100644 ecomp-portal-BE/war/WEB-INF/conf/system.properties delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/.DS_Store delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/conf/fusion.properties delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/collaborateList.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/ebz/ebz_footer.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/ebz/ebz_header.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/ebz_template.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/ebz_template_noheader_nofooter.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/include.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/jcs_admin.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/meta.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/popup_modal.html delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/popup_modal_role.html delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/popup_modal_rolefunction.html delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/post_search.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/profile.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/profile_search.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/role.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/role_function_list.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/role_list.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/usage_list.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/jsp/webrtc/collaboration.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/orm/EP.hbm.xml delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/orm/Fusion.hbm.xml delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/orm/Workflow.hbm.xml delete mode 100644 ecomp-portal-BE/war/WEB-INF/fusion/raptor/report_search.jsp delete mode 100644 ecomp-portal-BE/war/WEB-INF/jsp/login.jsp delete mode 100644 ecomp-portal-BE/war/index.jsp delete mode 100644 ecomp-portal-BE/war/static/ebz/attSessionTimeoutModal.css delete mode 100644 ecomp-portal-BE/war/static/ebz/dashboardBase.css delete mode 100644 ecomp-portal-BE/war/static/ebz/dashboardBase_changed.css delete mode 100644 ecomp-portal-BE/war/static/ebz/ebz_header.css delete mode 100644 ecomp-portal-BE/war/static/ebz/fn-ebz.css delete mode 100644 ecomp-portal-BE/war/static/ebz/footer_new.css delete mode 100644 ecomp-portal-BE/war/static/ebz/globalFonts.css delete mode 100644 ecomp-portal-BE/war/static/ebz/header_new.css delete mode 100644 ecomp-portal-BE/war/static/ebz/js/attHeaderSnippet.js delete mode 100644 ecomp-portal-BE/war/static/ebz/js/footer.js delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/att-abs-tpls.js delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/att-abs-tpls.min.js delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/base.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/btn.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/demo.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/dtpk.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/frms.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/ie/backgroundsize.min.htc delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/pages/iconography.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/sldr.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/style.css delete mode 100644 ecomp-portal-BE/war/static/ebz/sandbox/styles/tbs.css delete mode 100644 ecomp-portal-BE/war/static/fusion/css/att_angular_gridster/sandbox-gridster.css delete mode 100644 ecomp-portal-BE/war/static/fusion/css/att_angular_gridster/ui-gridster.css delete mode 100644 ecomp-portal-BE/war/static/fusion/css/fusion-sunny.css delete mode 100644 ecomp-portal-BE/war/static/fusion/css/jquery-ui.css delete mode 100644 ecomp-portal-BE/war/static/fusion/css/layout/layout-default-latest.css delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/css/nv.d3.css delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/cie.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/colorbrewer.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/core.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/crossfilter.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/crossfilter.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.geom.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.layout.cloud.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.layout.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.v2.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.v2.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/d3.v3.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/fisheye.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/hive.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/horizon.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/interactiveLayer.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/intro.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/axis-min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/axis.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/axis.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/backup/bullet.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/backup/bulletChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/boilerplate.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/bullet.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/bulletChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/cumulativeLineChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/discreteBar.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/discreteBarChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/distribution.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/historicalBar.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/historicalBarChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/indentedTree.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/legend.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/line.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/lineChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/linePlusBarChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/linePlusBarWithFocusChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/lineWithFisheye.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/lineWithFisheyeChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/lineWithFocusChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBar.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBarChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBarHorizontal.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBarHorizontalChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBarTimeSeries.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiBarTimeSeriesChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/multiChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/ohlcBar.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/parallelCoordinates.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/pie.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/pieChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/scatter.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/scatterChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/scatterPlusLineChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/sparkline.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/sparklinePlus.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/stackedArea.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/models/stackedAreaChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/nv.d3.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/nv.d3.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/outro.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/sankey.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/tooltip.js delete mode 100644 ecomp-portal-BE/war/static/fusion/d3/js/utils.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/att_angular_gridster/angular-gridster.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/att_angular_gridster/ui-gridster-tpls.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/jquery.resize.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/layout/debug.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/layout/jquery-latest.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/layout/jquery-ui-latest.js delete mode 100644 ecomp-portal-BE/war/static/fusion/js/layout/jquery.layout-latest.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/css/images/blank.gif delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/css/scribble.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/css/slider.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/css/spacegallery.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/area_chart.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/bar_chart.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/d3_gauges_demo.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/data/speedometer2.csv delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/data/speedometer3.csv delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/data/worddata.csv delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/donut_d3.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/area_chart.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/donut.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/gauges.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/line_chart.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/pie_chart.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/js/worddata.min.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/line_chart.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/pie_chart.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/html/wordcloud.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/FusionCharts.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/charts.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/eye.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/scribble.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/slides.min.jquery.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/spacegallery.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/js/utils.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/css/bootstrap.min.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/css/custom.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/css/jquery.jOrgChart.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/css/prettify.css delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/example.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/example_vsp.html delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/jquery.jOrgChart.js delete mode 100644 ecomp-portal-BE/war/static/fusion/sample/org_chart/prettify.js delete mode 100644 ecomp-portal-BE/war/static/fusion/webrtc/getSourceId.html delete mode 100644 ecomp-portal-BE/war/static/fusion/webrtc/js/RTCMultiConnection.js delete mode 100644 ecomp-portal-BE/war/static/fusion/webrtc/js/peerBroadcast.js delete mode 100644 ecomp-portal-BE/war/static/js/modalService.js delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/css/bootstrap-responsive.css delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/css/bootstrap-responsive.min.css delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/css/bootstrap.css delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/css/bootstrap.min.css delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/js/bootstrap.js delete mode 100644 ecomp-portal-BE/war/static/oid-connect/bootstrap2/js/bootstrap.min.js delete mode 100644 ecomp-portal-BE/war/static/oid-connect/js/lib/jquery.js delete mode 100644 ecomp-portal-BE/war/static/oid-connect/js/lib/jwt.js delete mode 100644 ecomp-portal-BE/war/static/oid-connect/js/lib/underscore.js create mode 100644 ecomp-portal-FE-common/README.md rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/directives/auto-focus/auto-focus.directive.js (100%) create mode 100644 ecomp-portal-FE-common/client/app/directives/b2b-leftnav-ext/b2b-leftnav-ext.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/b2b-leftnav-ext/b2b-leftnav-ext.less create mode 100644 ecomp-portal-FE-common/client/app/directives/b2b-leftnav-ext/b2b-leftnav-ext.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/directives/file-upload/file-upload.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/image-upload/image-upload.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/left-menu/left-menu.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/left-menu/left-menu.less create mode 100644 ecomp-portal-FE-common/client/app/directives/left-menu/left-menu.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/multiple-select.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/multiple-select.less create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/multiple-select.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/multiple-select2.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/multiple-select2.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/directives/multiple-select/mutliple-select2.less create mode 100644 ecomp-portal-FE-common/client/app/directives/right-click-menu/right-click-menu.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/right-click/ng-right-click-directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/scroll-top/scroll-top.directive.js create mode 100644 ecomp-portal-FE-common/client/app/directives/search-users/search-users.controller.js create mode 100644 ecomp-portal-FE-common/client/app/directives/search-users/search-users.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/directives/search-users/search-users.directive.js rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/filters/elipsis/elipsis.filter.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/filters/elipsis/elipsis.filter.spec.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/filters/trusted-url/trusted-url.filter.js (100%) create mode 100644 ecomp-portal-FE-common/client/app/router.js create mode 100644 ecomp-portal-FE-common/client/app/services/admins/admins.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/applications/applications.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/base64/base64.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/basic-auth-account/basic-auth-account.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/confirm-box/confirm-box.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/contact-us/contact-us.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/error-messages/error-messages.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/external-request-access-service/external-request-access-service.js create mode 100644 ecomp-portal-FE-common/client/app/services/functionalMenu/functionalMenu.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js create mode 100644 ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/menus/menus.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/notification/notification.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/portal-admins/portal-admins.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/role/role.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/support/getAccess/get-access.service.js rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/services/userbar/userbar.update.service.js (100%) create mode 100644 ecomp-portal-FE-common/client/app/services/users/users.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/utils/utils.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js create mode 100644 ecomp-portal-FE-common/client/app/styles/buttons.less create mode 100644 ecomp-portal-FE-common/client/app/styles/ecomp-general.less create mode 100644 ecomp-portal-FE-common/client/app/styles/form.less create mode 100644 ecomp-portal-FE-common/client/app/styles/mixins.less create mode 100644 ecomp-portal-FE-common/client/app/styles/ng-dialog.less create mode 100644 ecomp-portal-FE-common/client/app/styles/reset.less create mode 100644 ecomp-portal-FE-common/client/app/styles/select2.less create mode 100644 ecomp-portal-FE-common/client/app/styles/spinner.less create mode 100644 ecomp-portal-FE-common/client/app/styles/sprites.less create mode 100644 ecomp-portal-FE-common/client/app/styles/variables.less create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-add-details/account-add-details.html create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-add-details/account-add-details.js create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-add-details/account-add-details.less create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-onboarding.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-onboarding.less create mode 100644 ecomp-portal-FE-common/client/app/views/account-onboarding/account-onboarding.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/admins/admins.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/admins/admins.less create mode 100644 ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/applications/application-details-dialog/application-details.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/applications/applications.less create mode 100644 ecomp-portal-FE-common/client/app/views/catalog/add-catalog-dialogs/new-catalog.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/catalog/catalog.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/catalog/catalog.less create mode 100644 ecomp-portal-FE-common/client/app/views/catalog/catalog.tpl.html rename {ecomp-portal-FE => ecomp-portal-FE-common}/client/app/views/catalog/catalogconfirmation.controller.js (100%) create mode 100644 ecomp-portal-FE-common/client/app/views/catalog/information-box.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/admin-confirmation-box.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/confirmation-box.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/confirmation-box.less create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/confirmation-box.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/dragdrop-confirmation-box.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/confirmation-box/information-box.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-manage.html create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameters.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameters.controller.less create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget.controller.less create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard.less create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/dashboard.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/dashboard/newsticker.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/functionalMenu/functionalMenu-dialog/modal-details.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/functionalMenu/functionalMenu.less create mode 100644 ecomp-portal-FE-common/client/app/views/header/header.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/header/header.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/header/header.less create mode 100644 ecomp-portal-FE-common/client/app/views/header/header.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-add-details/microservice-add-details.html create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-add-details/microservice-add-details.js create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-add-details/microservice-add-details.less create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-onboarding.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-onboarding.less create mode 100644 ecomp-portal-FE-common/client/app/views/microservice-onboarding/microservice-onboarding.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/notification-history/notificationhistory.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/notification-history/notificationhistory.less create mode 100644 ecomp-portal-FE-common/client/app/views/notification-history/notificationhistory.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/new-portal-admin/new-portal-admin.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/new-portal-admin/new-portal-admin.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/new-portal-admin/new-portal-admin.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/new-portal-admin/new-portal-admin.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/portal-admin-controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/portal-admin.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/portal-admin/portal-admins.less create mode 100644 ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/role-controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/role/role-list-controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/role/role.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/role.less create mode 100644 ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/role_function_list.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/role_functions_popup.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/role_list.html create mode 100644 ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js create mode 100644 ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js create mode 100644 ecomp-portal-FE-common/client/app/views/search/search.less create mode 100644 ecomp-portal-FE-common/client/app/views/sidebar/sidebar.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/sidebar/sidebar.less create mode 100644 ecomp-portal-FE-common/client/app/views/sidebar/sidebar.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.controller.less create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.html create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us.less create mode 100644 ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/support/get-access/get-access.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/support/get-access/get-access.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/support/get-access/get-access.less create mode 100644 ecomp-portal-FE-common/client/app/views/support/get-access/get-access.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/tabs/tabframe.html create mode 100644 ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/tabs/tabs.less create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.Json.details.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.Json.details.modal.page.html create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.json.details.modal.page.less create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.less create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.modal.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.modal.page.html create mode 100644 ecomp-portal-FE-common/client/app/views/user-notifications-admin/user.notifications.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/userbar/userbar.less create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.ack.html create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.confirm.html create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/new-user.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/new-user.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/new-user.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/new-user.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/users/users.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/users/users.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/users/users.less create mode 100644 ecomp-portal-FE-common/client/app/views/users/users.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/widget-catalog/widget-catalog.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-catalog/widget-catalog.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-catalog/widget-catalog.less create mode 100644 ecomp-portal-FE-common/client/app/views/widget-catalog/widget-catalog.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-onboarding.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-onboarding.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-onboarding.less create mode 100644 ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-onboarding.tpl.html create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widget-details-dialog/widget-details.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widget-details-dialog/widget-details.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widget-details-dialog/widget-details.modal.html create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widget-details-dialog/widget-details.modal.less create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widgets.controller.js create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widgets.controller.spec.js create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widgets.less create mode 100644 ecomp-portal-FE-common/client/app/views/widgets/widgets.tpl.html create mode 100644 ecomp-portal-FE-common/client/bower_components_external/b2b/css/b2b-angular/README.md create mode 100644 ecomp-portal-FE-common/client/bower_components_external/b2b/css/b2b-angular/b2b-angular.css create mode 100644 ecomp-portal-FE-common/client/bower_components_external/b2b/js/b2b-angular/README.md create mode 100644 ecomp-portal-FE-common/client/bower_components_external/b2b/js/b2b-angular/b2b-library.min.js create mode 100644 ecomp-portal-FE-common/home/ecompportal/applicationsHome create mode 100644 ecomp-portal-FE-common/home/ecompportal/login.htm create mode 100644 ecomp-portal-FE-common/home/index.html create mode 100644 ecomp-portal-FE-common/license/licenses.properties create mode 100644 ecomp-portal-FE-common/license/my_license/header.txt create mode 100644 ecomp-portal-FE-common/license/my_license/license.txt create mode 100644 ecomp-portal-FE-common/pom.xml rename {ecomp-portal-FE => ecomp-portal-FE-os}/.bowerrc (100%) create mode 100644 ecomp-portal-FE-os/.gitignore create mode 100644 ecomp-portal-FE-os/Gruntfile.js create mode 100644 ecomp-portal-FE-os/README.md create mode 100644 ecomp-portal-FE-os/bower.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/build-ecomportal-fe.sh (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/.htaccess (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/.jshintrc (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/assets/images/ecomp_logo.png (100%) rename {ecomp-portal-BE/war/static/fusion/images/att_angular_gridster => ecomp-portal-FE-os/client/assets/images}/grips.png (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/assets/images/photo.png (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/assets/images/spinner.gif (100%) create mode 100644 ecomp-portal-FE-os/client/bower_components_external/angular-gridster/angular-gridster.min.js create mode 100644 ecomp-portal-FE-os/client/bower_components_external/b2b/css/b2b-angular/README.md create mode 100644 ecomp-portal-FE-os/client/bower_components_external/b2b/js/b2b-angular/README.md create mode 100644 ecomp-portal-FE-os/client/bower_components_external/b2b/js/b2b-angular/b2b-library.min.js rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/bowser/bowser.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/bowser/useragents.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/.gitignore (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/LICENSE (100%) create mode 100644 ecomp-portal-FE-os/client/bower_components_external/ionicons-2.0.1/css/ionicons.css rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/css/ionicons.min.css (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/fonts/ionicons.eot (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/fonts/ionicons.svg (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/fonts/ionicons.ttf (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/fonts/ionicons.woff (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/bower_components_external/ionicons-2.0.1/readme.md (100%) create mode 100644 ecomp-portal-FE-os/client/configurations/dev.json create mode 100644 ecomp-portal-FE-os/client/configurations/devServer.json create mode 100644 ecomp-portal-FE-os/client/configurations/integ.json create mode 100644 ecomp-portal-FE-os/client/configurations/mock.json create mode 100644 ecomp-portal-FE-os/client/index.html rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/robots.txt (100%) create mode 100644 ecomp-portal-FE-os/client/src/app.js create mode 100644 ecomp-portal-FE-os/client/src/app.less create mode 100644 ecomp-portal-FE-os/client/src/directives/right-menu/right-menu.directive.js create mode 100644 ecomp-portal-FE-os/client/src/directives/right-menu/right-menu.less create mode 100644 ecomp-portal-FE-os/client/src/directives/right-menu/right-menu.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js create mode 100644 ecomp-portal-FE-os/client/src/directives/search-users/search-users.less create mode 100644 ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/router.js create mode 100644 ecomp-portal-FE-os/client/src/services/support/session/session.service.js create mode 100644 ecomp-portal-FE-os/client/src/services/userProfile/userProfile.service.js create mode 100644 ecomp-portal-FE-os/client/src/styles/att-abs.less create mode 100644 ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.controller.js rename {ecomp-portal-FE/client/app => ecomp-portal-FE-os/client/src}/views/applications/application-details-dialog/application-details.controller.spec.js (100%) create mode 100644 ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.modal.html create mode 100644 ecomp-portal-FE-os/client/src/views/applications/applications.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/applications/applications.controller.spec.js create mode 100644 ecomp-portal-FE-os/client/src/views/applications/applications.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/catalog/add-catalog-dialogs/new-catalog.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/catalog/add-catalog-dialogs/new-catalog.modal.html create mode 100644 ecomp-portal-FE-os/client/src/views/dashboard/dashboard.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/footer/footer.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/footer/footer.controller.spec.js create mode 100644 ecomp-portal-FE-os/client/src/views/footer/footer.less create mode 100644 ecomp-portal-FE-os/client/src/views/footer/footer.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/functionalMenu-dialog/menu-details.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/functionalMenu-dialog/menu-details.delete.modal.html create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/functionalMenu.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/functionalMenu.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/functionalMenu/jqTreeContextMenu.js create mode 100644 ecomp-portal-FE-os/client/src/views/search/search.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/search/search.controller.spec.js create mode 100644 ecomp-portal-FE-os/client/src/views/search/search.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/support/contact-us/contact-us.aux.html create mode 100644 ecomp-portal-FE-os/client/src/views/support/get-access/get-accessinfo.html create mode 100644 ecomp-portal-FE-os/client/src/views/tabs/tabs.tpl.html create mode 100644 ecomp-portal-FE-os/client/src/views/userbar/userbar.controller.js create mode 100644 ecomp-portal-FE-os/client/src/views/userbar/userbar.tpl.html rename {ecomp-portal-FE => ecomp-portal-FE-os}/client/utils/test-utils/test-utils.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/e2e/main/anchoring.spec.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/e2e/main/main.po.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/e2e/main/main.spec.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/karma.conf.js (100%) create mode 100644 ecomp-portal-FE-os/license/licenses.properties create mode 100644 ecomp-portal-FE-os/license/my_license/header.txt create mode 100644 ecomp-portal-FE-os/license/my_license/license.txt create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/admins/account-admins.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/admins/admin-app-roles.json (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/applications/admin-apps.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/applications/applications-onboarding.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/applications/available-apps.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/applications/user-apps.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/functional-menu/app-roles.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/functional-menu/dev.json create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/functional-menu/favorites.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/functional-menu/menu-item-details.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/functional-menu/menu-items.json create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/functional-menu/menu-items_small.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/ping/ping.json (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/user-profile/user-profile.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/user-profile/user-static-info.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/users/account-users.json (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/users/query-users-results.json (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/data/users/user-apps-roles.json (100%) create mode 100644 ecomp-portal-FE-os/mock/ecomp/data/widgets/widgets.json rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/ecomp/router.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/mock/server.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/package.json (100%) create mode 100644 ecomp-portal-FE-os/pom.xml rename {ecomp-portal-FE => ecomp-portal-FE-os}/protractor.conf.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/.jshintrc (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/.jshintrc-spec (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/app.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/components/errors/index.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/config/environment/index.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/config/express.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/routes.js (100%) rename {ecomp-portal-FE => ecomp-portal-FE-os}/server/views/404.html (100%) delete mode 100644 ecomp-portal-FE/.gitignore delete mode 100644 ecomp-portal-FE/Gruntfile.js delete mode 100644 ecomp-portal-FE/README.md delete mode 100644 ecomp-portal-FE/bower.json delete mode 100644 ecomp-portal-FE/client/app/app.js delete mode 100644 ecomp-portal-FE/client/app/app.less delete mode 100644 ecomp-portal-FE/client/app/configurations.js delete mode 100644 ecomp-portal-FE/client/app/directives/image-upload/image-upload.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/left-menu/left-menu.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/left-menu/left-menu.less delete mode 100644 ecomp-portal-FE/client/app/directives/left-menu/left-menu.tpl.html delete mode 100644 ecomp-portal-FE/client/app/directives/multiple-select/multiple-select.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/multiple-select/multiple-select.less delete mode 100644 ecomp-portal-FE/client/app/directives/multiple-select/multiple-select.tpl.html delete mode 100644 ecomp-portal-FE/client/app/directives/right-click-menu/right-click-menu.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/right-click/ng-right-click-directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/right-menu/right-menu.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/right-menu/right-menu.less delete mode 100644 ecomp-portal-FE/client/app/directives/right-menu/right-menu.tpl.html delete mode 100644 ecomp-portal-FE/client/app/directives/scroll-top/scroll-top.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/search-users/search-users.controller.js delete mode 100644 ecomp-portal-FE/client/app/directives/search-users/search-users.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/directives/search-users/search-users.directive.js delete mode 100644 ecomp-portal-FE/client/app/directives/search-users/search-users.less delete mode 100644 ecomp-portal-FE/client/app/directives/search-users/search-users.tpl.html delete mode 100644 ecomp-portal-FE/client/app/router.js delete mode 100644 ecomp-portal-FE/client/app/services/admins/admins.service.js delete mode 100644 ecomp-portal-FE/client/app/services/applications/applications.service.js delete mode 100644 ecomp-portal-FE/client/app/services/catalog/catalog.service.js delete mode 100644 ecomp-portal-FE/client/app/services/confirm-box/confirm-box.service.js delete mode 100644 ecomp-portal-FE/client/app/services/contact-us/contact-us.service.js delete mode 100644 ecomp-portal-FE/client/app/services/dashboard/dashboard.service.js delete mode 100644 ecomp-portal-FE/client/app/services/error-messages/error-messages.service.js delete mode 100644 ecomp-portal-FE/client/app/services/functionalMenu/functionalMenu.service.js delete mode 100644 ecomp-portal-FE/client/app/services/global-constants/global-constants.js delete mode 100644 ecomp-portal-FE/client/app/services/kpi-dashboard/kpi-dashboard.service.js delete mode 100644 ecomp-portal-FE/client/app/services/manifest/manifest.service.js delete mode 100644 ecomp-portal-FE/client/app/services/menus/menus.service.js delete mode 100644 ecomp-portal-FE/client/app/services/portal-admins/portal-admins.service.js delete mode 100644 ecomp-portal-FE/client/app/services/support/getAccess/get-access.service.js delete mode 100644 ecomp-portal-FE/client/app/services/support/session/session.service.js delete mode 100644 ecomp-portal-FE/client/app/services/userProfile/userProfile.service.js delete mode 100644 ecomp-portal-FE/client/app/services/users/users.service.js delete mode 100644 ecomp-portal-FE/client/app/services/utils/utils.service.js delete mode 100644 ecomp-portal-FE/client/app/services/widgets/widgets.service.js delete mode 100644 ecomp-portal-FE/client/app/styles/att-abs.less delete mode 100644 ecomp-portal-FE/client/app/styles/buttons.less delete mode 100644 ecomp-portal-FE/client/app/styles/ecomp-general.less delete mode 100644 ecomp-portal-FE/client/app/styles/fonts.less delete mode 100644 ecomp-portal-FE/client/app/styles/form.less delete mode 100644 ecomp-portal-FE/client/app/styles/kpi-dashboard.less delete mode 100644 ecomp-portal-FE/client/app/styles/mixins.less delete mode 100644 ecomp-portal-FE/client/app/styles/ng-dialog.less delete mode 100644 ecomp-portal-FE/client/app/styles/reset.less delete mode 100644 ecomp-portal-FE/client/app/styles/select2.less delete mode 100644 ecomp-portal-FE/client/app/styles/spinner.less delete mode 100644 ecomp-portal-FE/client/app/styles/sprites.less delete mode 100644 ecomp-portal-FE/client/app/styles/variables.less delete mode 100644 ecomp-portal-FE/client/app/views/admins/add-admin-dialogs/new-admin.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/admins/add-admin-dialogs/new-admin.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/admins/add-admin-dialogs/new-admin.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/admins/admins.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/admins/admins.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/admins/admins.less delete mode 100644 ecomp-portal-FE/client/app/views/admins/admins.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/applications/application-details-dialog/application-details.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/applications/application-details-dialog/application-details.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/applications/application-details-dialog/application-details.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/applications/applications.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/applications/applications.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/applications/applications.less delete mode 100644 ecomp-portal-FE/client/app/views/applications/applications.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/catalog/catalog.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/catalog/catalog.less delete mode 100644 ecomp-portal-FE/client/app/views/catalog/catalog.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/catalog/information-box.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/admin-confirmation-box.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/confirmation-box.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/confirmation-box.less delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/confirmation-box.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/dragdrop-confirmation-box.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/confirmation-box/information-box.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard-widget-manage.html delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard-widget.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard-widget.controller.less delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard.less delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/dashboard.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/dashboard/newsticker.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/errors/error.404.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/errors/error.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/errors/error.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/footer/footer.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/footer/footer.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/footer/footer.less delete mode 100644 ecomp-portal-FE/client/app/views/footer/footer.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu-dialog/menu-details.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu-dialog/menu-details.delete.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu-dialog/menu-details.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu-dialog/modal-details.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu.less delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/functionalMenu.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/functionalMenu/jqTreeContextMenu.js delete mode 100644 ecomp-portal-FE/client/app/views/header/header.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/header/header.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/header/header.less delete mode 100644 ecomp-portal-FE/client/app/views/header/header.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/header/user-edit/edit-user.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/header/user-edit/edit-user.less delete mode 100644 ecomp-portal-FE/client/app/views/header/user-edit/edit-user.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/home/applications-home/applications-home.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/home/applications-home/applications-home.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/home/applications-home/applications-home.less delete mode 100644 ecomp-portal-FE/client/app/views/home/applications-home/applications-home.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/home/widgets-home/widgets-home.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/home/widgets-home/widgets-home.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/home/widgets-home/widgets-home.less delete mode 100644 ecomp-portal-FE/client/app/views/home/widgets-home/widgets-home.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/new-portal-admin/new-portal-admin.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/new-portal-admin/new-portal-admin.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/new-portal-admin/new-portal-admin.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/new-portal-admin/new-portal-admin.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/portal-admin-controller.js delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/portal-admin.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/portal-admin/portal-admins.less delete mode 100644 ecomp-portal-FE/client/app/views/search/search.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/search/search.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/search/search.less delete mode 100644 ecomp-portal-FE/client/app/views/search/search.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/sidebar/sidebar.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/sidebar/sidebar.less delete mode 100644 ecomp-portal-FE/client/app/views/sidebar/sidebar.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.controller.less delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us-manage/contact-us-manage.html delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us.less delete mode 100644 ecomp-portal-FE/client/app/views/support/contact-us/contact-us.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/support/get-access/get-access.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/support/get-access/get-access.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/support/get-access/get-access.less delete mode 100644 ecomp-portal-FE/client/app/views/support/get-access/get-access.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/tabs/tabframe.html delete mode 100644 ecomp-portal-FE/client/app/views/tabs/tabs.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/tabs/tabs.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/tabs/tabs.less delete mode 100644 ecomp-portal-FE/client/app/views/tabs/tabs.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/userbar/userbar.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/userbar/userbar.less delete mode 100644 ecomp-portal-FE/client/app/views/userbar/userbar.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/users/new-user-dialogs/new-user.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/users/new-user-dialogs/new-user.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/users/new-user-dialogs/new-user.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/users/new-user-dialogs/new-user.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/users/users.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/users/users.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/users/users.less delete mode 100644 ecomp-portal-FE/client/app/views/users/users.tpl.html delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widget-details-dialog/widget-details.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widget-details-dialog/widget-details.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widget-details-dialog/widget-details.modal.html delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widget-details-dialog/widget-details.modal.less delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widgets.controller.js delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widgets.controller.spec.js delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widgets.less delete mode 100644 ecomp-portal-FE/client/app/views/widgets/widgets.tpl.html delete mode 100644 ecomp-portal-FE/client/assets/images/cloud.png delete mode 100644 ecomp-portal-FE/client/assets/images/grips.png delete mode 100644 ecomp-portal-FE/client/assets/images/sprite.png delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/angular-animate.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-animate/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/angular-aria.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-aria/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/.gitignore delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/.npmignore delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/ui-bootstrap-csp.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/ui-bootstrap-tpls.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/ui-bootstrap.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-bootstrap/ui-bootstrap.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/TRANSITION.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/browserify/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/browserify/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/browserify/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/r.js/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/r.js/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/r.js/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/r.js/main.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/r.js/require.config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack/webpack.config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6/webpack.config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6_2/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6_2/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6_2/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/build_examples/webpack_es6_2/webpack.config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/circle.yml delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/dist/angular-cache.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/dist/angular-cache.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/dist/angular-cache.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/dist/angular-cache.min.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/rollup.config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cache/scripts/postbuild.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/angular-cookies.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-cookies/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/LICENSE.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/gestures.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-gestures/gestures.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/.gitignore delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/angular-material.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/angular-material.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/angular-material.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/angular-material.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy2.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/facebook.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/hangout.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/mail.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/message.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/print.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/share-arrow.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/twitter.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/upload.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/chips/demoBasicUsage/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/chips/demoContactChips/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/gridList/demoBasicUsage/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/gridList/demoDynamicTiles/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/gridList/demoResponsiveUsage/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/addShoppingCart.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/android.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/cake.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/cake.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/core-icons.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/social-icons.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/addShoppingCart.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/android.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/cake.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/android.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/cake.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/core-icons.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/input/demoIcons/icons/ic_email_24px.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/input/demoIcons/icons/ic_person_24px.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/input/demoIcons/icons/ic_phone_24px.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/input/demoIcons/icons/ic_place_24px.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/input/demoIcons/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/list/demoListControls/img/100-0.jpeg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/list/demoListControls/img/100-1.jpeg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/list/demoListControls/img/100-2.jpeg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/tabs/demoDynamicHeight/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/tabs/demoDynamicTabs/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/tabs/demoStaticTabs/style.scss delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/favorite.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/menu.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/more_vert.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/autocomplete/autocomplete-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/autocomplete/autocomplete.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/autocomplete/autocomplete.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/backdrop/backdrop-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/backdrop/backdrop.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/backdrop/backdrop.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/button/button-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/button/button.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/button/button.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/card/card-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/card/card.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/card/card.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/checkbox/checkbox-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/checkbox/checkbox.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/checkbox/checkbox.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/chips/chips-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/chips/chips.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/chips/chips.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/content/content-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/content/content.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/content/content.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/core/core.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/core/core.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/core/default-theme.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/dialog/dialog-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/dialog/dialog.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/dialog/dialog.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/divider/divider-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/divider/divider.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/divider/divider.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/gridList/gridList-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/gridList/gridList.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/gridList/gridList.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/icon/icon-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/icon/icon.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/icon/icon.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/input/input-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/input/input.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/input/input.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/list/list-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/list/list.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/list/list.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/menu/menu.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/menu/menu.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressCircular/progressCircular-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressCircular/progressCircular.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressCircular/progressCircular.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressLinear/progressLinear-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressLinear/progressLinear.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/progressLinear/progressLinear.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/radioButton/radioButton-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/radioButton/radioButton.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/radioButton/radioButton.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/select/select-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/select/select.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/select/select.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/sidenav/sidenav-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/sidenav/sidenav.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/sidenav/sidenav.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/slider/slider-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/slider/slider.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/slider/slider.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/sticky/sticky.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/sticky/sticky.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/subheader/subheader-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/subheader/subheader.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/subheader/subheader.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/swipe/swipe.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/switch/switch-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/switch/switch.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/switch/switch.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tabs/tabs-arrow.svg delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tabs/tabs-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tabs/tabs.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tabs/tabs.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/textField/textField-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/textField/textField.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/textField/textField.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toast/toast-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toast/toast.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toast/toast.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toolbar/toolbar-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toolbar/toolbar.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/toolbar/toolbar.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tooltip/tooltip-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tooltip/tooltip.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/tooltip/tooltip.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/whiteframe/whiteframe.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/closure/whiteframe/whiteframe.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/css/angular-material-layout.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/autocomplete/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/backdrop.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/backdrop/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/bottomSheet/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/button/button.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/card/card.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/checkbox/checkbox.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/chips/chips.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/content/content.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/core.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/core.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/core.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/core.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/core/default-theme.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/dialog/dialog.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/divider/divider.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/gridList/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/gridList/gridList.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/gridList/gridList.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/gridList/gridList.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/gridList/gridList.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/icon/icon.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/input/input.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/list/list.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/menu/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/menu/menu.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/menu/menu.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/menu/menu.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/menu/menu.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/radioButton/radioButton.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/select/select.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sidenav/sidenav.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/slider/slider.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sticky/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sticky/sticky.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sticky/sticky.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sticky/sticky.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/sticky/sticky.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/subheader/subheader.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/swipe/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/swipe/swipe.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/swipe/swipe.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/switch/switch.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tabs/tabs.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/textField/textField.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toast/toast.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/toolbar/toolbar.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/tooltip/tooltip.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/whiteframe/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/whiteframe/whiteframe.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/whiteframe/whiteframe.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-material/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/LICENSE.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/angular-messages.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/angular-messages.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/angular-messages.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-messages/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/LICENSE.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/angular-mocks.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/ngAnimateMock.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/ngMock.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/ngMockE2E.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-mocks/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/angular-resource.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-resource/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/angular-route.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-route/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/angular-sanitize.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-sanitize/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/LICENSE.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/angular-scenario.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/jstd-scenario-adapter-config.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/jstd-scenario-adapter.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-scenario/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/.gitignore delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/.travis.yml delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/ISSUE_TEMPLATE.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/changeLog.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/dist/smart-table.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/dist/smart-table.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/dist/smart-table.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/gulpFile.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/readme.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/bottom.txt delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/smart-table.module.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stConfig.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stPagination.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stPipe.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stSearch.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stSelectRow.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stSort.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/stTable.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-smart-table/src/top.txt delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/release/angular-ui-router.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/release/angular-ui-router.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/common.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/resolve.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/state.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/stateDirectives.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/stateFilters.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/templateFactory.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/urlMatcherFactory.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/urlRouter.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/view.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/viewDirective.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-ui-router/src/viewScroll.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-uuid/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-uuid/LICENCE delete mode 100644 ecomp-portal-FE/client/bower_components/angular-uuid/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular-uuid/uuid.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular-uuid/uuid.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/angular/angular.min.js.gzip delete mode 100644 ecomp-portal-FE/client/bower_components/angular/angular.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/angular/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/angular/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/angular/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/CHANGES delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/CONTRIBUTORS.md delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/Makefile delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/component.json delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-sham.js delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-sham.map delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-sham.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-shim.js delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-shim.map delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/es5-shim.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/es5-shim/shims.json delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/LICENSE.md delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/changelog.js delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/hammer.js delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/hammer.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/hammer.min.js.map delete mode 100644 ecomp-portal-FE/client/bower_components/hammerjs/hammer.min.map delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/.editorconfig delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/.gitignore delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/.travis.yml delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_config.yml delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/01_general.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/02_introduction.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/03_features.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/04_demo.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/05_requirements.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/06_downloads.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/07_tutorial.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/08_examples.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/09_usecases.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/10_changelog.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/11_options.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/12_autoescape.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/13_autoopen.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/14_buttonleft.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/15_closedicon.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/16_data.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/17_datafilter.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/18_data-url.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/19_draganddrop.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/20_keyboardsupport.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/21_oncanmove.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/22_oncanmoveto.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/23_oncanselectnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/24_oncreateli.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/25_onismovehandle.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/26_onloadfailed.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/27_onloading.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/28_openedicon.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/29_openfolderdelay.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/30_rtl.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/31_savestate.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/32_selectable.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/33_slide.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/34_usecontextmenu.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/35_functions.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/36_addnodeafter.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/36a_addparentnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/37_addnodebefore.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/38_appendnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/39_closenode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/40_destroy.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/41_getnodebycallback.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/42_getnodebyid.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/43_getnodebyhtmlelement.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/44_getselectednode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/45_getstate.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/46_gettree.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/47_loaddata.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/48_loaddatafromurl.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/49_movedown.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/50_movenode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/51_moveup.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/52_opennode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/53_reload.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/54_removenode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/55_selectnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/56_scrolltonode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/57_setoption.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/58_setstate.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/59_toggle.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/60_tojson.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/61_updatenode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/62_events.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/63_tree-click.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/64_tree-close.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/65_tree-contextmenu.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/66_tree-dblclick.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/67_tree-init.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/68_tree-move.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/69_tree-open.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/70_tree-select.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/71_multiple-selection.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/72_add-to-selection.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/73_get-selected-nodes.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/74_is-node-selected.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/75_remove-from-selection.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/76_node-functions.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/77_children.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/78_getdata.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/79_getlevel.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/80_getnextnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/81_getnextsibling.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/82_getpreviousnode.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/83_getprevioussibling.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/84_parent.md delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_entries/renumber.py delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/01_load_json_data.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/02_load_json_data_from_server.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/03_drag_and_drop.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/04_save_state.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/05_load_on_demand.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/06_autoescape.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/07_autoscroll.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/08_multiple_select.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/09_custom_html.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/10_icon_buttons.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/11_right-to-left.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_examples/12_button_on_right.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_layouts/base.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_layouts/frontpage.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/_layouts/page.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/coffeelint.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/gulpfile.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/gulpfile.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/jqtree-circle.png delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/jqtree.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/jqtree.jquery.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/jqtree.scss delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/karma.conf.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/drag_and_drop_handler.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/elements_renderer.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/key_handler.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/mouse.widget.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/node.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/node_element.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/save_state_handler.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/scroll_handler.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/select_node_handler.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/simple.widget.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/tree.jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/util.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/lib/version.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/phantomjs/runner.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/phantomjs/server.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/screenshot.png delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/sitemap.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/drag_and_drop_handler.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/elements_renderer.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/header.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/key_handler.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/mouse.widget.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/node.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/node_element.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/save_state_handler.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/scroll_handler.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/select_node_handler.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/simple.widget.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/tree.jquery.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/util.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src/version.coffee delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/karma-test.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/test.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/test_jqtree.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/test_tree.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/test_util.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/src_test/utils_for_test.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/blanket/dist/qunit/blanket.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/css/bootstrap.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/bootstrap/dist/js/bootstrap.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/css/font-awesome.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/FontAwesome.otf delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/fontawesome-webfont.eot delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/fontawesome-webfont.svg delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/fontawesome-webfont.ttf delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/fontawesome-webfont.woff delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/fontawesome/fonts/fontawesome-webfont.woff2 delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-1/dist/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-1/dist/jquery.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-2/dist/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-2/dist/jquery.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-cookie/jquery.cookie.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery-mockjax/dist/jquery.mockjax.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery/dist/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/jquery/dist/jquery.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/json3/lib/json3.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/pygments/css/monokai.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/qunit/qunit/qunit.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/bower_components/qunit/qunit/qunit.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/documentation.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/documentation.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/example.css delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/example.scss delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/example_data.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/autoescape.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/autoscroll.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/button-on-right.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/custom_html.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/drag_and_drop.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/icon_buttons.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/load_json_data.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/load_json_data_from_server.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/load_on_demand.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/multiple_select.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/right-to-left.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/examples/save_state.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/static/spinner.gif delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/test/test.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/test/test_build.js delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/test/test_jquery_1.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/test/test_jquery_2.html delete mode 100644 ecomp-portal-FE/client/bower_components/jqTree/tree.jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/ChangeLog.md delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/LICENSE.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/jquery.mousewheel.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery-mousewheel/jquery.mousewheel.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/jquery.event.drag.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/jquery.event.drag.live.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/binding.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/handlers.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/interaction.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/live.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/method.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/properties.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/requirements.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drag/test/touch.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.live.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/binding.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/handlers.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/interaction.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/live.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/method.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/properties.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/requirements.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/tolerance.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/touch.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.keyend/jquery.event.keyend.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/jquery.event.linger.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/binding.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/handlers.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/interaction.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/method.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.linger/test/requirements.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.wheel/jquery.event.wheel.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/jquery.fire.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/custom.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/form.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/key.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/mouse.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/mutation.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/object.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/requirements.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/fire/test/touch.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/jquery-1.4.2.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/jquery-1.4.4.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/jquery-1.5b1.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/jquery-1.7.2.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/qunit.css delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.event.drag-new/jquery/qunit.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/dist/jquery.newstape.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/gulpfile.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/jquery.newstape.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery.newstape/readme.md delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/AUTHORS.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/LICENSE.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/dist/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/dist/jquery.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/dist/jquery.min.map delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/external/sizzle/LICENSE.txt delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/external/sizzle/dist/sizzle.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/external/sizzle/dist/sizzle.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/external/sizzle/dist/sizzle.min.map delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/.jshintrc delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/jsonp.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/load.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/parseJSON.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/parseXML.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/script.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/var/location.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/var/nonce.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/var/rquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/ajax/xhr.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes/attr.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes/classes.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes/prop.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes/support.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/attributes/val.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/callbacks.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core/access.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core/init.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core/parseHTML.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core/ready.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/core/var/rsingleTag.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/addGetHookIf.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/adjustCSS.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/curCSS.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/defaultDisplay.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/hiddenVisibleSelectors.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/showHide.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/support.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/cssExpand.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/getStyles.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/isHidden.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/rmargin.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/rnumnonpx.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/css/var/swap.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/data.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/data/Data.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/data/var/acceptData.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/data/var/dataPriv.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/data/var/dataUser.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/deferred.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/deprecated.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/dimensions.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/effects.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/effects/Tween.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/effects/animatedSelector.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event/ajax.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event/alias.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event/focusin.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event/support.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/event/trigger.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/exports/amd.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/exports/global.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/intro.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/jquery.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/_evalUrl.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/buildFragment.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/getAll.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/setGlobalEval.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/support.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/var/rcheckableType.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/var/rscriptType.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/var/rtagName.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/manipulation/wrapMap.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/offset.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/outro.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/queue.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/queue/delay.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/selector-native.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/selector-sizzle.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/selector.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/serialize.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/traversing.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/traversing/findFilter.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/traversing/var/dir.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/traversing/var/rneedsContext.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/traversing/var/siblings.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/arr.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/class2type.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/concat.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/document.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/documentElement.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/hasOwn.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/indexOf.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/pnum.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/push.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/rcssNum.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/rnotwhite.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/slice.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/support.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/var/toString.js delete mode 100644 ecomp-portal-FE/client/bower_components/jquery/src/wrap.js delete mode 100644 ecomp-portal-FE/client/bower_components/json3/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/json3/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/json3/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/json3/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/json3/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/json3/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/json3/lib/json3.js delete mode 100644 ecomp-portal-FE/client/bower_components/json3/lib/json3.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.editorconfig delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.gitattributes delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.github/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.gitignore delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.jscsrc delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.markdown-doctest-setup.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/.travis.yml delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.core.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.core.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.fp.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.fp.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/lodash.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/dist/mapping.fp.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/doc/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/fp/_baseConvert.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/fp/_convertBrowser.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/fp/_mapping.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/fp/placeholder.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/common/file.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/common/mapping.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/common/minify.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/common/uglify.options.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/common/util.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/build-dist.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/build-doc.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/build-modules.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/doc/wiki.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/_falseOptions.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/_util.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/alias.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/category.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/convert.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/fp.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/module.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/fp/template/modules/thru.jst delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/main/build-dist.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/main/build-doc.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lib/main/build-modules.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/lodash.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/perf/asset/perf-ui.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/perf/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/perf/perf.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/asset/test-ui.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/asset/worker.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/backbone.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/fp.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/remove.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/saucelabs.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/test-fp.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/test.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/underscore.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/backbone.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/collection.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/events.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/model.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/noconflict.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/router.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/setup/dom-setup.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/setup/environment.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/sync.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/backbone/test/view.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/license.txt delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/blank.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/buttonBg.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/buttonBgHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/debugger.css delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/detach.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/detachHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/disable.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/disable.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/disableHover.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/disableHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/down.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/downActive.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/downHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/errorIcon-sm.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/errorIcon.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/errorIcon.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/firebug-1.3a2.css delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/firebug.IE6.css delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/firebug.css delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/firebug.html delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/firebug.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/group.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/html.css delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/infoIcon.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/infoIcon.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/loading_16.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/min.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/minHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/off.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/offHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/pixel_transparent.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/roundCorner.svg delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/search.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/search.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/shadow.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/shadow2.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/shadowAlpha.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/sprite.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabHoverLeft.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabHoverMid.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabHoverRight.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabLeft.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMenuCheckbox.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMenuPin.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMenuRadio.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMenuTarget.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMenuTargetHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabMid.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tabRight.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/textEditorBorders.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/textEditorBorders.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/textEditorCorners.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/textEditorCorners.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/titlebarMid.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/toolbarMid.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tree_close.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/tree_open.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/twistyClosed.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/twistyOpen.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/up.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/upActive.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/upHover.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/warningIcon.gif delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/skin/xp/warningIcon.png delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/firebug-lite/src/firebug-lite-debug.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/json-js/json2.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/arrays.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/chaining.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/collections.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/cross-document.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/functions.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/objects.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/test/utility.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/underscore-min.js delete mode 100644 ecomp-portal-FE/client/bower_components/lodash/vendor/underscore/underscore.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog-custom-width.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog-theme-default.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog-theme-default.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog-theme-plain.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog-theme-plain.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/css/ngDialog.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/js/ngDialog.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/js/ngDialog.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/karma.conf.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/package.json delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/protractor.conf.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/server.js delete mode 100644 ecomp-portal-FE/client/bower_components/ng-dialog/yarn.lock delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/.bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/CONTRIBUTING.md delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/LICENSE delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/README.md delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/bower.json delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/composer.json delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/deploy-docs.sh delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/dist/select.css delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/dist/select.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/dist/select.min.css delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/dist/select.min.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/assets/app.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/assets/demo.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/assets/docs.css delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/assets/plunkr.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/index.html delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/partials/_footer.html delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/docs/partials/_header.html delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/index.js delete mode 100644 ecomp-portal-FE/client/bower_components/ui-select/package.json delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/angular-gridster.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/css/angular-gridster.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/styles/angular-gridster.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/styles/ui-gridster.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/ui-gridster-tpls-0.0.1.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/ui-gridster-tpls.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular-att-gridster/ui-gridster.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/CHANGELOG.md delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/README.md delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/att-abs-tpls.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/att-abs-tpls.min.js delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/base.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/btn.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/demo.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/dtpk.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/frms.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/ie/backgroundsize.min.htc delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/images/down.png delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/images/up.png delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/images/upanddown.png delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/pages/iconography.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/sldr.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/style.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/angular.att.abs-2.17.0/styles/tbs.css delete mode 100644 ecomp-portal-FE/client/bower_components_external/ionicons-2.0.1/css/ionicons.css delete mode 100644 ecomp-portal-FE/client/configurations/dev.json delete mode 100644 ecomp-portal-FE/client/configurations/devServer.json delete mode 100644 ecomp-portal-FE/client/configurations/integ.json delete mode 100644 ecomp-portal-FE/client/configurations/mock.json delete mode 100644 ecomp-portal-FE/client/favicon.ico delete mode 100644 ecomp-portal-FE/client/index.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/AAI-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/APPC-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/ASDC-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/Closedloop-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/DCAE-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/DMaaP-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/ECOMP-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/ECOMP_Portal-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/InfrastructurePortal-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/MSO-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/Policy-controller.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/controllers/kpi-whitelist.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/AAI/AAI_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/AAI/AAI_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/AAI/AAI_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/APPC/APPC_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/APPC/APPC_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/APPC/APPC_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ASDC/ASDC_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ASDC/ASDC_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ASDC/ASDC_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Closedloop/Closedloop_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Closedloop/Closedloop_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Closedloop/Closedloop_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE/DCAE_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE/DCAE_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE/DCAE_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/dcae_locations.csv delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/dcae_locations.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/dcae_locations1.csv delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/lib/d3.v3.min.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/lib/leaflet.css delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/lib/leaflet.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DCAE_DASH/static/visjs/legend_v2.js delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DMaaP/DMaaP_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DMaaP/DMaaP_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/DMaaP/DMaaP_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ECOMP.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ECOMP_Portal/ECOMP_Portal_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ECOMP_Portal/ECOMP_Portal_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/ECOMP_Portal/ECOMP_Portal_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/InfrastructurePortal/InfrastructurePortal_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/InfrastructurePortal/InfrastructurePortal_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/InfrastructurePortal/InfrastructurePortal_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/MSO/MSO_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/MSO/MSO_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/MSO/MSO_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Policy/Policy_KPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Policy/Policy_Metrics.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/Policy/Policy_UserDefinedKPI.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/sec-level-tabs.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/top-level-tabs.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/userapi-edit.html delete mode 100644 ecomp-portal-FE/client/kpi-dashboard/views/userstory-edit.html delete mode 100644 ecomp-portal-FE/mock/ecomp/data/admins/account-admins.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/applications/applications-onboarding.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/applications/user-apps.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/functional-menu/dev.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/functional-menu/favorites.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/functional-menu/menu-items.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/functional-menu/menu-items_small.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/user-profile/user-static-info.json delete mode 100644 ecomp-portal-FE/mock/ecomp/data/widgets/widgets.json delete mode 100644 ecomp-portal-FE/pom.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 107a11b6..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e4a40b06..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/portal.iml b/.idea/portal.iml deleted file mode 100644 index d6ebd480..00000000 --- a/.idea/portal.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ecomp-portal-BE-common-test/.classpath b/ecomp-portal-BE-common-test/.classpath new file mode 100644 index 00000000..3553992a --- /dev/null +++ b/ecomp-portal-BE-common-test/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE-common-test/.gitignore b/ecomp-portal-BE-common-test/.gitignore new file mode 100644 index 00000000..95194cea --- /dev/null +++ b/ecomp-portal-BE-common-test/.gitignore @@ -0,0 +1,4 @@ +/java/ +/debug/ +/debug/logs/ +/target/ diff --git a/ecomp-portal-BE-common-test/.project b/ecomp-portal-BE-common-test/.project new file mode 100644 index 00000000..5805bbfb --- /dev/null +++ b/ecomp-portal-BE-common-test/.project @@ -0,0 +1,23 @@ + + + ecomp-portal-BE-common-test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/ecomp-portal-BE-common-test/.settings/org.eclipse.core.resources.prefs b/ecomp-portal-BE-common-test/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..cf6931b9 --- /dev/null +++ b/ecomp-portal-BE-common-test/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/ecomp-portal-BE-common-test/.settings/org.eclipse.jdt.core.prefs b/ecomp-portal-BE-common-test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..d59e09c9 --- /dev/null +++ b/ecomp-portal-BE-common-test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ecomp-portal-BE-common-test/README.md b/ecomp-portal-BE-common-test/README.md new file mode 100644 index 00000000..30308e7b --- /dev/null +++ b/ecomp-portal-BE-common-test/README.md @@ -0,0 +1,28 @@ +# ECOMP Portal Web Application Back End for AT&T Internal Use + +## Overview + +This is a Maven project with the ECOMP Portal web application back-end test files +for internal use, containing test cases for controllers, interceptors and other Java classes +for the AT&T version. This project uses the Maven war plugin to copy in ("overlay") +the contents of the ECOMP Portal web application back-end common distribution at +package time. + +Use Apache Maven to build. + +For more information please visit: + + https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home + +## Release Notes + +This file tracks all changes to AT&T-specific versions, including back-end *and* +All of the release notes in the ecomp-portal-BE-common-test area apply. + + +-US874768 Created a new project to have common junit test cases which can be run from ecomp-portal-BE-att + -Created PopulateTestData.sql and RemoveTestData.sql to populate and rollback the test data + -Created Coomon configuration files ApplicationCommonContextTestSuite and MockitoTestSuite + which can be extended from respective test classes. + -Added Test cases for AppCatalogController + diff --git a/ecomp-portal-BE-common-test/license/licenses.properties b/ecomp-portal-BE-common-test/license/licenses.properties new file mode 100644 index 00000000..4b0e28e7 --- /dev/null +++ b/ecomp-portal-BE-common-test/license/licenses.properties @@ -0,0 +1 @@ +my_license=My license diff --git a/ecomp-portal-BE-common-test/license/my_license/header.txt b/ecomp-portal-BE-common-test/license/my_license/header.txt new file mode 100644 index 00000000..c026b6b7 --- /dev/null +++ b/ecomp-portal-BE-common-test/license/my_license/header.txt @@ -0,0 +1,11 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file 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. diff --git a/ecomp-portal-BE-common-test/license/my_license/license.txt b/ecomp-portal-BE-common-test/license/my_license/license.txt new file mode 100644 index 00000000..bf326153 --- /dev/null +++ b/ecomp-portal-BE-common-test/license/my_license/license.txt @@ -0,0 +1,4 @@ +name=my_license +description= +licenseURL= +headerURL= \ No newline at end of file diff --git a/ecomp-portal-BE-common-test/pom.xml b/ecomp-portal-BE-common-test/pom.xml new file mode 100644 index 00000000..8d38f3b4 --- /dev/null +++ b/ecomp-portal-BE-common-test/pom.xml @@ -0,0 +1,151 @@ + + 4.0.0 + + org.openecomp.portal + ecomp-portal-BE-common-test + 1.1.0-SNAPSHOT + jar + + ecomp-portal-BE-common-test + http://maven.apache.org + + + UTF-8 + + **.js + + + + src/main/java + + ${project.artifactId} + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + maven-war-plugin + 2.6 + + true + false + + + true + + + ${project.version}.${build.number} + ${maven.build.timestamp} + + + + + + org.openecomp.portal + ecompportal-be-common + + + + + + + + + + src/test/java + + **/*Test*.* + + + + src/main/resources + + **/** + + + + + + + + junit + junit + 4.11 + + + org.powermock + powermock-api-mockito + 1.6.1 + + + org.powermock + powermock-core + 1.6.1 + + + org.powermock + powermock-module-junit4 + 1.6.1 + + + org.mockito + mockito-core + 1.8.5 + + + org.openecomp.portal + ecompportal-be-common + ${project.version} + jar + classes + + + + diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppCatalogControllerTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppCatalogControllerTest.java new file mode 100644 index 00000000..4e2b842d --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppCatalogControllerTest.java @@ -0,0 +1,264 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +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.controller.AppCatalogController; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.ecomp.model.AppCatalogItem; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.AdminRolesServiceImpl; +import org.openecomp.portalapp.portal.service.EPAppCommonServiceImpl; +import org.openecomp.portalapp.portal.service.EPAppService; +import org.openecomp.portalapp.portal.service.PersUserAppService; +import org.openecomp.portalapp.portal.service.PersUserAppServiceImpl; +import org.openecomp.portalapp.portal.test.core.MockEPUser; +import org.openecomp.portalapp.portal.test.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.transport.AppCatalogPersonalization; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FieldsValidator.FieldName; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.util.SystemProperties; + +public class AppCatalogControllerTest extends MockitoTestSuite { + + @Mock + AdminRolesService adminRolesService = new AdminRolesServiceImpl(); + + @Mock + EPAppService appService = new EPAppCommonServiceImpl(); + + @InjectMocks + AppCatalogController appCatalogController = new AppCatalogController(); + + PersUserAppService persUserAppService = Mockito.spy(new PersUserAppServiceImpl()); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @Mock + EPUserUtils ePUserUtils = new EPUserUtils(); + + @Mock + EPUser epuser; + + NullPointerException nullPointerException = new NullPointerException(); + + MockEPUser mockUser = new MockEPUser(); + + public AppCatalogItem mockAppCatalogItem() { + AppCatalogItem appCatalogItem = new AppCatalogItem(); + appCatalogItem.setId((long) 1); + appCatalogItem.setName("Ecomp Portal"); + appCatalogItem.setImageUrl("Test_URL"); + appCatalogItem.setDescription("Testing"); + appCatalogItem.setNotes("Test"); + appCatalogItem.setUrl("test"); + appCatalogItem.setAlternateUrl("test"); + appCatalogItem.setRestricted(false); + appCatalogItem.setOpen(false); + appCatalogItem.setAccess(true); + appCatalogItem.setSelect(true); + appCatalogItem.setPending(false); + + return appCatalogItem; + } + + @Test + public void getAppCatalogTestIfUserNotAdmin() throws IOException { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List actualAppCatalogList = null; + + List expectedAppCatalog = new ArrayList<>(); + + AppCatalogItem appCatalogItem = mockAppCatalogItem(); + expectedAppCatalog.add(appCatalogItem); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + Mockito.when(appService.getUserAppCatalog(user)).thenReturn(expectedAppCatalog); + actualAppCatalogList = appCatalogController.getAppCatalog(mockedRequest, mockedResponse); + + assertTrue(actualAppCatalogList.contains(appCatalogItem)); + + } + + @Test + public void getAppCatalogTestIfUserIsAdmin() throws IOException { + EPUser user = mockUser.mockEPUser(); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List actualAppCatalogList = null; + + List expectedAppCatalog = new ArrayList<>(); + + AppCatalogItem appCatalogItem = mockAppCatalogItem(); + + expectedAppCatalog.add(appCatalogItem); + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(appService.getAdminAppCatalog(user)).thenReturn(expectedAppCatalog); + actualAppCatalogList = appCatalogController.getAppCatalog(mockedRequest, mockedResponse); + + assertTrue(actualAppCatalogList.contains(appCatalogItem)); + + } + + @Test + public void getAppCatalogTestIfUserisNull() throws IOException { + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(null); + List actualAppCatalogList = new ArrayList<>(); + ; + actualAppCatalogList = appCatalogController.getAppCatalog(mockedRequest, mockedResponse); + assertNull(actualAppCatalogList); + + } + + @Test + public void getAppCatalogTestIfUserThrowsExceptionTest() throws IOException { + EPUser user = new EPUser(); + user.setFirstName("test"); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List actualAppCatalogList = new ArrayList<>(); + ; + + Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); + + Mockito.when(appCatalogController.getAppCatalog(mockedRequest, mockedResponse)).thenThrow(nullPointerException); + + actualAppCatalogList = appCatalogController.getAppCatalog(mockedRequest, mockedResponse); + assertNull(actualAppCatalogList); + + } + + @Test + public void putAppCatalogSelectionTestWhenAppIsNull() throws IOException { + + AppCatalogPersonalization persRequest = new AppCatalogPersonalization(); + persRequest.setAppId((long) 1); + persRequest.setPending(false); + persRequest.setSelect(false); + + EPUser user = mockUser.mockEPUser(); + + FieldsValidator expectedFieldValidator = new FieldsValidator(); + + FieldsValidator actualFieldValidator = new FieldsValidator(); + List fields = new ArrayList<>(); + ; + + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(fields); + expectedFieldValidator.setErrorCode(null); + + EPApp app = null; + + Mockito.when(appService.getApp(persRequest.getAppId())).thenReturn(app); + + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + actualFieldValidator = appCatalogController.putAppCatalogSelection(mockedRequest, persRequest, mockedResponse); + assertEquals(expectedFieldValidator, actualFieldValidator); + + } + + @Test + public void putAppCatalogSelectionTest() throws IOException { + + AppCatalogPersonalization persRequest = new AppCatalogPersonalization(); + persRequest.setAppId((long) 1); + persRequest.setPending(false); + persRequest.setSelect(false); + + EPUser user = mockUser.mockEPUser(); + + FieldsValidator expectedFieldValidator = new FieldsValidator(); + + FieldsValidator actualFieldValidator = new FieldsValidator(); + List fields = new ArrayList<>(); + ; + + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(fields); + expectedFieldValidator.setErrorCode(null); + + EPApp app = new EPApp(); + + app.setName("Test"); + app.setImageUrl("test"); + app.setDescription("test"); + app.setNotes("test"); + app.setUrl("test"); + app.setId((long) 1); + app.setAppRestEndpoint("test"); + app.setAlternateUrl("test"); + app.setName("test"); + app.setMlAppName("test"); + app.setMlAppAdminId("test"); + app.setUsername("test"); + app.setAppPassword("test"); + app.setOpen(false); + app.setEnabled(false); + app.setUebKey("test"); + app.setUebSecret("test"); + app.setUebTopicName("test"); + app.setAppType(1); + + Mockito.when(appService.getApp(persRequest.getAppId())).thenReturn(app); + + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.doNothing().when(persUserAppService).setPersUserAppValue(user, app, persRequest.getSelect(), + persRequest.getPending()); + + actualFieldValidator = appCatalogController.putAppCatalogSelection(mockedRequest, persRequest, mockedResponse); + + assertEquals(expectedFieldValidator, actualFieldValidator); + + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppContactUsControllerTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppContactUsControllerTest.java new file mode 100644 index 00000000..9b2add8e --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/AppContactUsControllerTest.java @@ -0,0 +1,281 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.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.controller.AppContactUsController; +import org.openecomp.portalapp.portal.ecomp.model.AppCategoryFunctionsItem; +import org.openecomp.portalapp.portal.ecomp.model.AppContactUsItem; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.service.AppContactUsService; +import org.openecomp.portalapp.portal.service.AppContactUsServiceImpl; +import org.openecomp.portalapp.portal.test.framework.MockitoTestSuite; +import org.openecomp.portalapp.util.EPUserUtils; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +public class AppContactUsControllerTest { + + @Mock + AppContactUsService contactUsService = new AppContactUsServiceImpl(); + + @InjectMocks + AppContactUsController appContactUsController = new AppContactUsController(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + + @Mock + EPUserUtils ePUserUtils = new EPUserUtils(); + + public List mockResponse() { + List appContactUsItemList = new ArrayList(); + AppContactUsItem appContactUsItem = new AppContactUsItem(); + appContactUsItem.setAppId((long) 1); + appContactUsItem.setAppName("Ecmop Portal"); + appContactUsItem.setDescription("Test"); + appContactUsItem.setContactName("Test"); + appContactUsItem.setContactEmail("Test@att.com"); + appContactUsItem.setUrl("Test_URL"); + appContactUsItem.setActiveYN("Y"); + appContactUsItemList.add(appContactUsItem); + + return appContactUsItemList; + + } + + public PortalRestResponse> successPortalRestResponse() { + PortalRestResponse> expectedportalRestResponse = new PortalRestResponse>(); + List appContactUsItemList = mockResponse(); + expectedportalRestResponse.setMessage("success"); + expectedportalRestResponse.setResponse(appContactUsItemList); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedportalRestResponse.setStatus(portalRestStatusEnum.OK); + return expectedportalRestResponse; + + } + + public PortalRestResponse> exceptionPortalRestResponse() { + PortalRestResponse> expectedportalRestResponse = new PortalRestResponse>(); + expectedportalRestResponse.setMessage(null); + expectedportalRestResponse.setResponse(null); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); + return expectedportalRestResponse; + + } + + @Test + public void getAppContactUsList() throws Exception { + PortalRestResponse> expectedportalRestResponse = successPortalRestResponse(); + List appContactUsItemList = mockResponse(); + PortalRestResponse> actualPortalRestResponse = new PortalRestResponse>(); + Mockito.when(contactUsService.getAppContactUs()).thenReturn(appContactUsItemList); + actualPortalRestResponse = appContactUsController.getAppContactUsList(mockedRequest); + assertEquals(actualPortalRestResponse, expectedportalRestResponse); + } + + @Test + public void getAppContactUsListCatchesExeptionTest() throws Exception { + + PortalRestResponse> expectedportalRestResponse = exceptionPortalRestResponse(); + PortalRestResponse> actualPortalRestResponse = new PortalRestResponse>(); + Mockito.when(contactUsService.getAppContactUs()).thenThrow(nullPointerException); + actualPortalRestResponse = appContactUsController.getAppContactUsList(mockedRequest); + assertEquals(actualPortalRestResponse, expectedportalRestResponse); + } + + @Test + public void getAppsAndContactsTest() throws Exception { + PortalRestResponse> expectedportalRestResponse = successPortalRestResponse(); + List appContactUsItemList = mockResponse(); + PortalRestResponse> actualPortalRestResponse = new PortalRestResponse>(); + Mockito.when(contactUsService.getAppsAndContacts()).thenReturn(appContactUsItemList); + actualPortalRestResponse = appContactUsController.getAppsAndContacts(mockedRequest); + assertEquals(actualPortalRestResponse, expectedportalRestResponse); + + } + + @Test + public void getAppsAndContactsCatchesExceptionTest() throws Exception { + PortalRestResponse> expectedportalRestResponse = exceptionPortalRestResponse(); + PortalRestResponse> actualPortalRestResponse = new PortalRestResponse>(); + Mockito.when(contactUsService.getAppsAndContacts()).thenThrow(nullPointerException); + actualPortalRestResponse = appContactUsController.getAppsAndContacts(mockedRequest); + assertEquals(actualPortalRestResponse, expectedportalRestResponse); + + } + + @Test + public void getAppCategoryFunctionsTest() throws Exception { + PortalRestResponse> actualportalRestResponse = null; + + List contents = new ArrayList(); + + AppCategoryFunctionsItem appCategoryFunctionsItem = new AppCategoryFunctionsItem(); + AppCategoryFunctionsItem appCategoryFunctionsItem1 = new AppCategoryFunctionsItem(); + + appCategoryFunctionsItem.setRowId("1"); + appCategoryFunctionsItem.setAppId("1"); + appCategoryFunctionsItem.setApplication("Ecomp-portal"); + appCategoryFunctionsItem.setCategory("test"); + appCategoryFunctionsItem.setFunctions("test"); + + appCategoryFunctionsItem1.setRowId("2"); + appCategoryFunctionsItem1.setAppId("2"); + appCategoryFunctionsItem1.setApplication("Ecomp-portal-test"); + appCategoryFunctionsItem1.setCategory("test"); + appCategoryFunctionsItem1.setFunctions("test"); + contents.add(appCategoryFunctionsItem); + contents.add(appCategoryFunctionsItem1); + + PortalRestResponse> expectedportalRestResponse = new PortalRestResponse>(); + expectedportalRestResponse.setMessage("success"); + expectedportalRestResponse.setResponse(contents); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedportalRestResponse.setStatus(portalRestStatusEnum.OK); + + Mockito.when(contactUsService.getAppCategoryFunctions()).thenReturn(contents); + actualportalRestResponse = appContactUsController.getAppCategoryFunctions(mockedRequest); + assertEquals(actualportalRestResponse, expectedportalRestResponse); + + } + + @Test + public void getAppCategoryFunctionsCatchesExceptionTest() throws Exception { + PortalRestResponse> actualportalRestResponse = null; + PortalRestResponse> expectedportalRestResponse = exceptionPortalRestResponse(); + Mockito.when(contactUsService.getAppCategoryFunctions()).thenThrow(nullPointerException); + actualportalRestResponse = appContactUsController.getAppCategoryFunctions(mockedRequest); + assertEquals(actualportalRestResponse, expectedportalRestResponse); + + } + + @Test + public void saveTest() throws Exception { + PortalRestResponse actualSaveAppContactUS = null; + + AppContactUsItem contactUs = new AppContactUsItem(); + contactUs.setAppId((long) 1); + contactUs.setAppName("Ecmop Portal"); + contactUs.setDescription("Test"); + contactUs.setContactName("Test"); + contactUs.setContactEmail("Test@att.com"); + contactUs.setUrl("Test_URL"); + contactUs.setActiveYN("Y"); + + Mockito.when(contactUsService.saveAppContactUs(contactUs)).thenReturn("SUCCESS"); + actualSaveAppContactUS = appContactUsController.save(contactUs); + assertEquals(actualSaveAppContactUS.getMessage(), "SUCCESS"); + } + + @Test + public void saveExceptionTest() throws Exception { + PortalRestResponse actualSaveAppContactUS = null; + + AppContactUsItem contactUs = new AppContactUsItem(); + contactUs.setAppId((long) 1); + contactUs.setAppName("Ecmop Portal"); + contactUs.setDescription("Test"); + contactUs.setContactName("Test"); + contactUs.setContactEmail("Test@att.com"); + contactUs.setUrl("Test_URL"); + contactUs.setActiveYN("Y"); + + Mockito.when(contactUsService.saveAppContactUs(contactUs)).thenThrow(new Exception()); + actualSaveAppContactUS = appContactUsController.save(contactUs); + assertEquals(actualSaveAppContactUS.getMessage(), "failure"); + } + + @Test + public void saveWhenAppContactUsItemNullTest() throws Exception { + PortalRestResponse actualSaveAppContactUS = null; + AppContactUsItem contactUs = null; + actualSaveAppContactUS = appContactUsController.save(contactUs); + assertEquals(actualSaveAppContactUS.getMessage(), "failure"); + + } + + @Test + public void saveAllTest() throws Exception { + + List contactUs = mockResponse(); + PortalRestResponse actualSaveAppContactUS = null; + Mockito.when(contactUsService.saveAppContactUs(contactUs)).thenReturn("SUCCESS"); + actualSaveAppContactUS = appContactUsController.save(contactUs); + assertEquals(actualSaveAppContactUS.getMessage(), "SUCCESS"); + } + + @Test + public void saveAllExceptionTest() throws Exception { + + List contactUs = mockResponse(); + PortalRestResponse actualSaveAppContactUS = null; + Mockito.when(contactUsService.saveAppContactUs(contactUs)).thenThrow(new Exception()); + actualSaveAppContactUS = appContactUsController.save(contactUs); + assertEquals(actualSaveAppContactUS.getMessage(), "failure"); + } + + @Test + public void deleteTest() throws Exception { + + PortalRestResponse actualSaveAppContactUS = null; + Long id = (long) 1; + String saveAppContactUs = "SUCCESS"; + Mockito.when(contactUsService.deleteContactUs(id)).thenReturn(saveAppContactUs); + actualSaveAppContactUS = appContactUsController.delete(id); + assertEquals(actualSaveAppContactUS.getMessage(), "SUCCESS"); + } + + @Test + public void deleteExceptionTest() throws Exception { + + PortalRestResponse actualSaveAppContactUS = null; + Long id = (long) 1; + Mockito.when(contactUsService.deleteContactUs(id)).thenThrow(new Exception()); + actualSaveAppContactUS = appContactUsController.delete(id); + assertEquals(actualSaveAppContactUS.getMessage(), "failure"); + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/FunctionalMenuControllerTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/FunctionalMenuControllerTest.java new file mode 100644 index 00000000..b9f11eeb --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/FunctionalMenuControllerTest.java @@ -0,0 +1,190 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.controller; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.validation.constraints.AssertTrue; + +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.mockito.runners.MockitoJUnitRunner; +import org.openecomp.portalapp.portal.controller.FunctionalMenuController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.AdminRolesServiceImpl; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.service.FunctionalMenuServiceImpl; +import org.openecomp.portalapp.portal.test.core.MockEPUser; +import org.openecomp.portalapp.portal.test.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRolesList; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FieldsValidator.FieldName; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; + +@RunWith(MockitoJUnitRunner.class) +public class FunctionalMenuControllerTest extends MockitoTestSuite { + + String userid = "sk434m"; + + @Mock + FunctionalMenuService functionalMenuService = new FunctionalMenuServiceImpl(); + + @InjectMocks + FunctionalMenuController functionalMenuController = new FunctionalMenuController(); + + @Mock + private DataAccessService dataAccessService; + + @Mock + AdminRolesService adminRolesService = new AdminRolesServiceImpl(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @InjectMocks + EPUserUtils ePUserUtils = new EPUserUtils(); + + @Mock + EPUser epuser; + + MockEPUser mockUser = new MockEPUser(); + + List appRoles = new ArrayList(); + List appRolesActual = new ArrayList(); + + List userAppRoleList = new ArrayList(); + + public List mockBusinessCardApplicationRole() { + List userAppRoleList = new ArrayList(); + + BusinessCardApplicationRole businessCardApplicationRole = new BusinessCardApplicationRole(); + businessCardApplicationRole.setRoleName("ADMIN"); + businessCardApplicationRole.setAppName("ASDC"); + + BusinessCardApplicationRole businessCardApplicationRole1 = new BusinessCardApplicationRole(); + businessCardApplicationRole1.setAppName("ASDC"); + businessCardApplicationRole1.setRoleName("Tester"); + + userAppRoleList.add(businessCardApplicationRole); + userAppRoleList.add(businessCardApplicationRole1); + return userAppRoleList; + } + + public List mockBusinessCardApplicationRolesList() { + List appRolesActual = new ArrayList(); + + BusinessCardApplicationRolesList businessCardApplicationRolesList = new BusinessCardApplicationRolesList(); + businessCardApplicationRolesList.setAppName("ASDC"); + + List roleNames = new ArrayList(); + roleNames.add("ADMIN"); + roleNames.add("Tester"); + businessCardApplicationRolesList.setRoleNames(roleNames); + + appRolesActual.add(businessCardApplicationRolesList); + return appRolesActual; + } + + @Test + public void getAppListTestIfAppAlredyExistsBusinessCardApplicationRolesList() throws IOException { + + userAppRoleList = mockBusinessCardApplicationRole(); + appRolesActual = mockBusinessCardApplicationRolesList(); + + Mockito.when(functionalMenuService.getUserAppRolesList(userid)).thenReturn(userAppRoleList); + + appRoles = functionalMenuController.getAppList(mockedRequest, userid); + + assertEquals(appRolesActual.size(), appRoles.size()); + assertEquals(appRolesActual.get(0).getAppName(), appRoles.get(0).getAppName()); + assertEquals(appRolesActual.get(0).getRoleNames(), appRoles.get(0).getRoleNames()); + + } + + @Test + public void getAppListTestIfAppDoesnotExistsInBusinessCardApplicationRolesList() throws IOException { + + userAppRoleList = mockBusinessCardApplicationRole(); + BusinessCardApplicationRole businessCardApplicationRole = new BusinessCardApplicationRole(); + businessCardApplicationRole.setAppName("CCD"); + businessCardApplicationRole.setRoleName("ADMIN"); + userAppRoleList.add(businessCardApplicationRole); + appRolesActual = mockBusinessCardApplicationRolesList(); + BusinessCardApplicationRolesList businessCardApplicationRolesList = new BusinessCardApplicationRolesList(); + businessCardApplicationRolesList.setAppName("CCD"); + List roleNames1 = new ArrayList(); + roleNames1.add("ADMIN"); + businessCardApplicationRolesList.setRoleNames(roleNames1); + appRolesActual.add(businessCardApplicationRolesList); + Mockito.when(functionalMenuService.getUserAppRolesList(userid)).thenReturn(userAppRoleList); + appRoles = functionalMenuController.getAppList(mockedRequest, userid); + assertEquals(appRolesActual.size(), appRoles.size()); + assertEquals(appRolesActual.get(0).getAppName(), appRoles.get(0).getAppName()); + assertEquals(appRolesActual.get(0).getRoleNames(), appRoles.get(0).getRoleNames()); + assertEquals(appRolesActual.get(1).getAppName(), appRoles.get(1).getAppName()); + assertEquals(appRolesActual.get(1).getRoleNames(), appRoles.get(1).getRoleNames()); + + } + + @Test + public void regenerateAncestorTableTest() { + EPUser user = mockUser.mockEPUser(); + + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + FieldsValidator acutualFieldValidator = null; + FieldsValidator expectedFieldValidator = new FieldsValidator(); + List fields = new ArrayList<>(); + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(fields); + expectedFieldValidator.setErrorCode(null); + Mockito.when(!adminRolesService.isSuperAdmin(user)).thenReturn(true); + Mockito.when(functionalMenuService.regenerateAncestorTable()).thenReturn(expectedFieldValidator); + acutualFieldValidator = functionalMenuController.regenerateAncestorTable(mockedRequest, mockedResponse); + assertTrue(acutualFieldValidator.equals(expectedFieldValidator)); + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserNotificationControllerTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserNotificationControllerTest.java new file mode 100644 index 00000000..628f52a1 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserNotificationControllerTest.java @@ -0,0 +1,265 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.controller; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +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.controller.UserNotificationController; +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.FunctionalMenuService; +import org.openecomp.portalapp.portal.service.FunctionalMenuServiceImpl; +import org.openecomp.portalapp.portal.service.UserNotificationService; +import org.openecomp.portalapp.portal.service.UserNotificationServiceImpl; +import org.openecomp.portalapp.portal.test.core.MockEPUser; +import org.openecomp.portalapp.portal.test.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.EpNotificationItemVO; +import org.openecomp.portalapp.portal.transport.FunctionalMenuRole; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(UserUtils.class) +public class UserNotificationControllerTest { + + @Mock + FunctionalMenuService functionalMenuService = new FunctionalMenuServiceImpl(); + + @Mock + UserNotificationService userNotificationService = new UserNotificationServiceImpl(); + + @InjectMocks + UserNotificationController userNotificationController = new UserNotificationController(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockEPUser mockUser = new MockEPUser(); + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + + @Test + public void getMenuIdRoleIdTest() { + List expectedMenuRoleList = new ArrayList(); + FunctionalMenuRole functionalMenuRole = new FunctionalMenuRole(); + functionalMenuRole.setId(new Integer(99999999)); + functionalMenuRole.setMenuId((long) 137); + functionalMenuRole.setAppId(new Integer(456)); + functionalMenuRole.setRoleId(new Integer(6214)); + expectedMenuRoleList.add(functionalMenuRole); + List actualFunctionalMenuRoleList = null; + Mockito.when(functionalMenuService.getFunctionalMenuRole()).thenReturn(expectedMenuRoleList); + actualFunctionalMenuRoleList = userNotificationController.getMenuIdRoleId(mockedRequest, mockedResponse); + assertTrue(actualFunctionalMenuRoleList.equals(expectedMenuRoleList)); + + } + + @Test + public void getNotificationsTest() { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List expectedEpNotificationList = new ArrayList(); + EpNotificationItem epNotificationItem = new EpNotificationItem(); + epNotificationItem.setNotificationId((long) 200); + expectedEpNotificationList.add(epNotificationItem); + PortalRestResponse> expectedportalRestResponse = new PortalRestResponse>(); + expectedportalRestResponse.setMessage("success"); + expectedportalRestResponse.setResponse(expectedEpNotificationList); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedportalRestResponse.setStatus(portalRestStatusEnum.OK); + PortalRestResponse> actualPortalRestResponse = null; + Mockito.when(userNotificationService.getNotifications(user.getId())).thenReturn(expectedEpNotificationList); + actualPortalRestResponse = userNotificationController.getNotifications(mockedRequest, mockedResponse); + assertTrue(expectedportalRestResponse.equals(actualPortalRestResponse)); + + } + + @Test + public void getNotificationsCatchesExceptionTest() { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + List expectedEpNotificationList = null; + PortalRestResponse> expectedportalRestResponse = new PortalRestResponse>(); + expectedportalRestResponse.setMessage(null); + expectedportalRestResponse.setResponse(expectedEpNotificationList); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); + PortalRestResponse> actualPortalRestResponse = null; + Mockito.when(userNotificationService.getNotifications(user.getId())).thenThrow(new NullPointerException()); + actualPortalRestResponse = userNotificationController.getNotifications(mockedRequest, mockedResponse); + assertTrue(expectedportalRestResponse.equals(actualPortalRestResponse)); + + } + + @Test + public void getAdminNotificationsTest() { + List actualEpNotificationsList = new ArrayList(); + List expectedEpNotificationsList = new ArrayList(); + EpNotificationItemVO epNotificationItemVO = new EpNotificationItemVO(); + epNotificationItemVO.setId((long) 1); + expectedEpNotificationsList.add(epNotificationItemVO); + Mockito.when(userNotificationService.getAdminNotificationVOS()).thenReturn(expectedEpNotificationsList); + actualEpNotificationsList = userNotificationController.getAdminNotifications(mockedRequest, mockedResponse); + assertTrue(actualEpNotificationsList.equals(expectedEpNotificationsList)); + } + + @Test + public void saveTestWhenNotificationIsNull() throws Exception { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + + PortalRestResponse actualPortalRestResponse = new PortalRestResponse(); + PortalRestResponse expectedPortalRestResponse = new PortalRestResponse(); + expectedPortalRestResponse.setMessage("FAILURE"); + expectedPortalRestResponse.setResponse("Notification Header cannot be null or empty"); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedPortalRestResponse.setStatus(portalRestStatusEnum.ERROR); + + EpNotificationItem notificationItem = null; + actualPortalRestResponse = userNotificationController.save(mockedRequest, mockedResponse, notificationItem); + assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse)); + } + + @Test + public void saveTestWhenEndTimeIsGreater() throws Exception { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse actualPortalRestResponse = new PortalRestResponse(); + PortalRestResponse expectedPortalRestResponse = new PortalRestResponse(); + expectedPortalRestResponse.setMessage("FAILURE"); + expectedPortalRestResponse.setResponse("End Time should be greater than start time"); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedPortalRestResponse.setStatus(portalRestStatusEnum.ERROR); + EpNotificationItem notificationItem = new EpNotificationItem(); + notificationItem.setNotificationId((long) 1); + notificationItem.setMsgHeader("Test"); + Date currentDate = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(currentDate); + c.add(Calendar.DATE, 1); + Date currentDatePlusOne = c.getTime(); + notificationItem.setStartTime(currentDatePlusOne); + notificationItem.setEndTime(currentDate); + + actualPortalRestResponse = userNotificationController.save(mockedRequest, mockedResponse, notificationItem); + assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse)); + + } + + @Test + public void saveTestWhenNoRoleIDExists() throws Exception { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse actualPortalRestResponse = new PortalRestResponse(); + PortalRestResponse expectedPortalRestResponse = new PortalRestResponse(); + expectedPortalRestResponse.setMessage("FAILURE"); + expectedPortalRestResponse.setResponse("No Roles Ids Exist for the selected Roles"); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedPortalRestResponse.setStatus(portalRestStatusEnum.ERROR); + EpNotificationItem notificationItem = new EpNotificationItem(); + notificationItem.setNotificationId((long) 1); + notificationItem.setMsgHeader("Test"); + notificationItem.setIsForAllRoles("N"); + Date currentDate = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(currentDate); + c.add(Calendar.DATE, 1); + Date currentDatePlusOne = c.getTime(); + notificationItem.setStartTime(currentDate); + notificationItem.setEndTime(currentDatePlusOne); + List roleList = new ArrayList(); + notificationItem.setRoleIds(roleList); + actualPortalRestResponse = userNotificationController.save(mockedRequest, mockedResponse, notificationItem); + assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse)); + } + + @Test + public void saveTest() throws Exception { + EPUser user = mockUser.mockEPUser(); + HttpSession session = mockedRequest.getSession(); + session.setAttribute("user", user); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + PortalRestResponse actualPortalRestResponse = new PortalRestResponse(); + PortalRestResponse expectedPortalRestResponse = new PortalRestResponse(); + expectedPortalRestResponse.setMessage("SUCCESS"); + expectedPortalRestResponse.setResponse(""); + PortalRestStatusEnum portalRestStatusEnum = null; + expectedPortalRestResponse.setStatus(portalRestStatusEnum.OK); + EpNotificationItem notificationItem = new EpNotificationItem(); + notificationItem.setNotificationId((long) 1); + notificationItem.setMsgHeader("Test"); + notificationItem.setIsForAllRoles("Y"); + Date currentDate = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(currentDate); + c.add(Calendar.DATE, 1); + Date currentDatePlusOne = c.getTime(); + notificationItem.setStartTime(currentDate); + notificationItem.setEndTime(currentDatePlusOne); + List roleList = new ArrayList(); + Long role1 = (long) 1; + roleList.add(role1); + notificationItem.setRoleIds(roleList); + HttpServletRequest request = mockitoTestSuite.getMockedRequest(); + PowerMockito.mockStatic(UserUtils.class); + Mockito.when(UserUtils.getUserIdAsLong(request)).thenReturn((long) 1); + Mockito.when(userNotificationService.saveNotification(notificationItem)).thenReturn("Test"); + actualPortalRestResponse = userNotificationController.save(mockedRequest, mockedResponse, notificationItem); + assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse)); + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserRolesControllerTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserRolesControllerTest.java new file mode 100644 index 00000000..093ca585 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/controller/UserRolesControllerTest.java @@ -0,0 +1,131 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.controller; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +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.controller.UserRolesController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.service.UserRolesService; +import org.openecomp.portalapp.portal.test.core.MockEPUser; +import org.openecomp.portalapp.portal.test.framework.MockitoTestSuite; +import org.openecomp.portalapp.portal.transport.AppWithRolesForUser; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FieldsValidator.FieldName; +import org.openecomp.portalapp.portal.transport.RoleInAppForUser; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; + +public class UserRolesControllerTest extends MockitoTestSuite { + + String userid = "sk434m"; + + @Mock + UserRolesService userRolesService; + + @Mock + FieldsValidator fieldsValidator; + + @InjectMocks + UserRolesController userRolesController = new UserRolesController(); + + @Mock + private DataAccessService dataAccessService; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @Mock + EPUserUtils ePUserUtils = new EPUserUtils(); + + @Mock + EPUser epuser; + + MockEPUser mockUser = new MockEPUser(); + + @Test + public void putAppWithUserRoleRequestTest() { + + FieldsValidator actualFieldsValidator = null; + + AppWithRolesForUser appWithRolesForUser = new AppWithRolesForUser(); + List listofRoles = new ArrayList(); + + appWithRolesForUser.setOrgUserId("guest"); + appWithRolesForUser.setAppId((long) 550); + appWithRolesForUser.setAppName("D2 Services Analytics Dashboard"); + appWithRolesForUser.setAppRoles(listofRoles); + + RoleInAppForUser roleInAppForUser = new RoleInAppForUser(); + roleInAppForUser.setIsApplied(false); + roleInAppForUser.setRoleId((long) 1); + roleInAppForUser.setRoleName("System Administrator"); + + RoleInAppForUser roleInAppForUser1 = new RoleInAppForUser(); + roleInAppForUser1.setIsApplied(true); + roleInAppForUser1.setRoleId((long) 16); + roleInAppForUser1.setRoleName("Standard User"); + + listofRoles.add(roleInAppForUser); + listofRoles.add(roleInAppForUser1); + EPUser user = mockUser.mockEPUser(); + FieldsValidator expectedFieldValidator = new FieldsValidator(); + List fields = new ArrayList<>(); + + expectedFieldValidator.setHttpStatusCode((long) 200); + expectedFieldValidator.setFields(fields); + expectedFieldValidator.setErrorCode(null); + HttpSession session = mockedRequest.getSession(); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); + Mockito.when(userRolesService.putUserAppRolesRequest(appWithRolesForUser, user)) + .thenReturn(expectedFieldValidator); + + actualFieldsValidator = userRolesController.putAppWithUserRoleRequest(mockedRequest, appWithRolesForUser, + mockedResponse); + assertEquals(expectedFieldValidator.getHttpStatusCode(), actualFieldsValidator.getHttpStatusCode()); + assertEquals(expectedFieldValidator.getErrorCode(), actualFieldsValidator.getErrorCode()); + assertEquals(expectedFieldValidator.getFields(), actualFieldsValidator.getFields()); + + } +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/MockEPUser.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/MockEPUser.java new file mode 100644 index 00000000..aa3c00d2 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/MockEPUser.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.core; + +import java.util.Date; + +import org.openecomp.portalapp.portal.domain.EPUser; + +public class MockEPUser { + + public EPUser mockEPUser() { + + EPUser ePUser = new EPUser(); + ePUser.setOrgId(null); + ePUser.setManagerId(null); + ePUser.setFirstName("test"); + ePUser.setLastName("test"); + ePUser.setMiddleInitial(null); + ePUser.setPhone(null); + ePUser.setFax(null); + ePUser.setCellular(null); + ePUser.setEmail(null); + ePUser.setAddressId(null); + ePUser.setAlertMethodCd(null); + ePUser.setHrid(null); + ePUser.setOrgUserId("guest"); + ePUser.setOrgCode(null); + ePUser.setAddress1(null); + ePUser.setAddress2(null); + ePUser.setCity(null); + ePUser.setState(null); + ePUser.setZipCode(null); + ePUser.setCountry(null); + ePUser.setOrgManagerUserId(null); + ePUser.setLocationClli(null); + ePUser.setBusinessCountryCode(null); + ePUser.setBusinessCountryName(null); + ePUser.setBusinessUnit(null); + ePUser.setBusinessUnitName(null); + ePUser.setDepartment(null); + ePUser.setDepartmentName(null); + ePUser.setCompanyCode(null); + ePUser.setCompany(null); + ePUser.setZipCodeSuffix(null); + ePUser.setJobTitle(null); + ePUser.setCommandChain(null); + ePUser.setSiloStatus(null); + ePUser.setCostCenter(null); + ePUser.setFinancialLocCode(null); + + ePUser.setLoginId(null); + ePUser.setLoginPwd(null); + Date date = new Date(); + ePUser.setLastLoginDate(date); + ePUser.setActive(true); + ePUser.setInternal(false); + ePUser.setSelectedProfileId(null); + ePUser.setTimeZoneId(null); + ePUser.setOnline(true); + ePUser.setChatId(null); + ePUser.setUserApps(null); + ePUser.setPseudoRoles(null); + + ePUser.setId((long) 99999999); + + return ePUser; + + } +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/PopulateSampleTestData.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/PopulateSampleTestData.java new file mode 100644 index 00000000..b04d200e --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/PopulateSampleTestData.java @@ -0,0 +1,66 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.core; + +import java.sql.Connection; +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.portalapp.portal.test.framework.ApplicationCommonContextTestSuite; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.DataSourceUtils; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; + +public class PopulateSampleTestData extends ApplicationCommonContextTestSuite { + + @Autowired + DataSource dataSource; + + @Before + public void populateTestData() throws SQLException { + + String sql = "PopulateTestData.sql"; + createConnection(sql); + } + + public void createConnection(String sql) { + Connection connection = null; + ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); + populator.addScript(new ClassPathResource(sql)); + try { + connection = DataSourceUtils.getConnection(dataSource); + populator.populate(connection); + } finally { + if (connection != null) { + DataSourceUtils.releaseConnection(connection, dataSource); + } + } + } + + @Test + public void populateTest() { + assert (true); + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RemoveSampleTestData.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RemoveSampleTestData.java new file mode 100644 index 00000000..db9663fd --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RemoveSampleTestData.java @@ -0,0 +1,66 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.core; + +import java.sql.Connection; +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.portalapp.portal.test.framework.ApplicationCommonContextTestSuite; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.DataSourceUtils; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; + +public class RemoveSampleTestData extends ApplicationCommonContextTestSuite { + @Autowired + DataSource dataSource; + + public static int count = 0; + + @After + public void removeTestData() throws SQLException { + String sql = "RemoveTestData.sql"; + createConnection(sql); + } + + public void createConnection(String sql) { + Connection connection = null; + ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); + populator.addScript(new ClassPathResource(sql)); + try { + connection = DataSourceUtils.getConnection(dataSource); + populator.populate(connection); + } finally { + if (connection != null) { + DataSourceUtils.releaseConnection(connection, dataSource); + } + } + } + + @Test + public void removeTest() { + assert (true); + } +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RestURLsTestSuite.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RestURLsTestSuite.java new file mode 100644 index 00000000..f90b27e5 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/core/RestURLsTestSuite.java @@ -0,0 +1,329 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.core; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayList; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.test.core.MockEPUser; +import org.openecomp.portalapp.portal.test.framework.ApplicationCommonContextTestSuite; +import org.openecomp.portalapp.portal.transport.AppNameIdIsAdmin; +import org.openecomp.portalapp.portal.transport.AppsListWithAdminRole; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * + * @author sk434m Use RestURLsTestSuite to test Rest API URL's + */ +public class RestURLsTestSuite extends ApplicationCommonContextTestSuite { + + public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(), + MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); + + String url = null; + + MockEPUser mockUser = new MockEPUser(); + + public byte[] convertObjectToJsonBytes(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsBytes(object); + } + + public void requestBuilder(String url) throws Exception { + EPUser user = mockUser.mockEPUser(); + + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url); + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertData(ra); + } + + public void assertData(ResultActions ra) { + Assert.assertEquals("application/json", ra.andReturn().getResponse().getContentType()); + Assert.assertEquals(200, ra.andReturn().getResponse().getStatus()); + + } + + @Test + public void getMenuItemsTest() throws Exception { + + url = "/portalApi/functionalMenu"; + requestBuilder(url); + } + + @Test + public void getMenuItemsForNotificationsTest() throws Exception { + url = "/portalApi/functionalMenuForNotificationTree"; + requestBuilder(url); + } + + @Test + public void getUserAppsTestnew() throws Exception { + + url = "/portalApi/userApps"; + requestBuilder(url); + } + + @Test + public void getPersUserAppsTest() throws Exception { + + url = "/portalApi/persUserApps"; + requestBuilder(url); + } + + @Test + public void getAppCatalogTest() throws Exception { + + url = "/portalApi/appCatalog"; + requestBuilder(url); + } + + @Test + public void getAppListNewTest() throws Exception { + ResultActions ra = getMockMvc() + .perform(MockMvcRequestBuilders.get("/portalApi/userApplicationRoles").param("userId", "guest")); + assertData(ra); + } + + @Test + public void getAvailableAppListTest() throws Exception { + url = "/portalApi/availableApps"; + requestBuilder(url); + } + + @Test + public void getAllAppsTest() throws Exception { + url = "/portalApi/allAvailableApps"; + requestBuilder(url); + } + + @Test + public void getUserProfileTest() throws Exception { + url = "/portalApi/userProfile"; + requestBuilder(url); + } + + @Test + public void getRolesByAppTest() throws Exception { + EPUser user = mockUser.mockEPUser(); + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/adminAppsRoles/550"); + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertData(ra); + } + + @Test + public void getAppsWithAdminRoleStateForUserTest() throws Exception { + url = "/portalApi/adminAppsRoles?user=guest"; + requestBuilder(url); + + } + + @Test + public void getUsersFromAppEndpointTest() throws Exception { + url = "/portalApi/app/550/users"; + requestBuilder(url); + } + + @Test + public void getOnboardingAppsTest() throws Exception { + url = "/portalApi/onboardingApps"; + requestBuilder(url); + } + + @Test + public void getMenuItemsForAuthUserTest() throws Exception { + url = "/portalApi/functionalMenuForAuthUser"; + requestBuilder(url); + } + + @Test + public void getMenuItemsForEditingTest() throws Exception { + url = "/portalApi/functionalMenuForEditing"; + requestBuilder(url); + } + + @Test + public void getAppRolesTest() throws Exception { + url = "/portalApi/appRoles/455"; + requestBuilder(url); + } + + @Test + public void regenerateAncestorTableTest() throws Exception { + + EPUser user = mockUser.mockEPUser(); + + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders + .get("/portalApi/regenerateFunctionalMenuAncestors"); + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertEquals("application/json;charset=UTF-8", ra.andReturn().getResponse().getContentType()); + Assert.assertEquals(200, ra.andReturn().getResponse().getStatus()); + + } + + @Test + public void getAppListTest() throws Exception { + url = "/portalApi/getAppList"; + requestBuilder(url); + } + + @Test + public void getFavoritesForUserTest() throws Exception { + url = "/portalApi/getFavoriteItems"; + requestBuilder(url); + } + + @Test + public void getManifestTest() throws Exception { + url = "/portalApi/manifest"; + requestBuilder(url); + } + + @Test + public void getActiveUsersTest() throws Exception { + url = "/portalApi/dashboard/activeUsers"; + requestBuilder(url); + } + + @Test + public void searchPortalTest() throws Exception { + EPUser user = mockUser.mockEPUser(); + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/search") + .param("searchString", "guest"); + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertData(ra); + } + + @Test + public void getWidgetDataTest() throws Exception { + EPUser user = mockUser.mockEPUser(); + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/portalApi/dashboard/widgetData") + .param("resourceType", "guest"); + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertData(ra); + } + + @Test + public void getAppsAndContactsTest() throws Exception { + url = "/portalApi/contactus/allapps"; + requestBuilder(url); + } + + @Test + public void getPortalDetailsTest() throws Exception { + url = "/portalApi/contactus/feedback"; + requestBuilder(url); + } + + @Test + public void getAppCategoryFunctionsTest() throws Exception { + url = "/portalApi/contactus/functions"; + requestBuilder(url); + } + + @Test + public void getOnlineUserUpdateRateTest() throws Exception { + url = "/portalApi/dashboard/onlineUserUpdateRate"; + requestBuilder(url); + } + + @Test + public void getMenuIdRoleIdTest() throws Exception { + url = "/portalApi/getFunctionalMenuRole"; + requestBuilder(url); + } + + @Test + public void getNotificationsTest() throws Exception { + url = "/portalApi/getNotifications"; + requestBuilder(url); + } + + @Test + public void getAdminNotificationsTest() throws Exception { + url = "/portalApi/getAdminNotifications"; + requestBuilder(url); + } + + @Test + public void getNotificationAppRolesTest() throws Exception { + url = "/portalApi/getNotificationAppRoles"; + requestBuilder(url); + } + + @Test + public void getNotificationUpdateRateTest() throws Exception { + url = "/portalApi/notificationUpdateRate"; + requestBuilder(url); + } + + @Test + public void notificationReadTest() throws Exception { + url = "/portalApi/notificationRead?notificationId=262"; + requestBuilder(url); + } + + @Test + public void testGetRolesTest() throws Exception { + url = "/portalApi/notificationRole/248/roles"; + requestBuilder(url); + } + + @Test + public void putAppsWithAdminRoleStateForUserTest() throws Exception { + + AppsListWithAdminRole appsListWithAdminRole = new AppsListWithAdminRole(); + appsListWithAdminRole.setOrgUserId("guest"); + ArrayList appsRoles = new ArrayList(); + AppNameIdIsAdmin appNameIdIsAdmin = new AppNameIdIsAdmin(); + appNameIdIsAdmin.setId((long) 455); + appNameIdIsAdmin.setAppName("CCD"); + appNameIdIsAdmin.setIsAdmin(true); + appNameIdIsAdmin.setRestrictedApp(false); + appsRoles.add(appNameIdIsAdmin); + appsListWithAdminRole.setAppsRoles(appsRoles); + EPUser user = mockUser.mockEPUser(); + MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.put("/portalApi/adminAppsRoles") + .contentType(APPLICATION_JSON_UTF8).content(convertObjectToJsonBytes(appsListWithAdminRole)); + + requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + ResultActions ra = getMockMvc().perform(requestBuilder); + assertData(ra); + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/ApplicationCommonContextTestSuite.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/ApplicationCommonContextTestSuite.java new file mode 100644 index 00000000..8030dcad --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/ApplicationCommonContextTestSuite.java @@ -0,0 +1,175 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.framework; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openecomp.portalsdk.core.conf.AppConfig; +//import org.openecomp.portalapp.conf.ExternalAppConfig; +//import org.openecomp.portalapp.conf.HibernateMappingLocations; +import org.openecomp.portalsdk.core.conf.HibernateConfiguration; +import org.openecomp.portalsdk.core.conf.HibernateMappingLocatable; +import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager; +import org.openecomp.portalsdk.core.util.CacheManager; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.transaction.TransactionConfiguration; +import org.springframework.test.context.web.AnnotationConfigWebContextLoader; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; + +/** + * + * In order to write a unit test, 1. inherit this class 2. place the "war" + * folder on your test class's classpath 3. run the test with the following VM + * argument; This is important because when starting the application from + * Container, the System Properties file (SystemProperties.java) can have the + * direct path but, when running from the Mock Junit container, the path should + * be prefixed with "classpath" to enable the mock container to search for the + * file in the classpath -Dcontainer.classpath="classpath:" + */ + +@SuppressWarnings("deprecation") +@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration +@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class }) +@ActiveProfiles(value = "test") +public class ApplicationCommonContextTestSuite { + + @Autowired + public WebApplicationContext wac; + + private MockMvc mockMvc; + + @Before + public void setup() { + if (mockMvc == null) { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + + } + } + + public Object getBean(String name) { + return this.wac.getBean(name); + } + + public MockMvc getMockMvc() { + return mockMvc; + } + + public void setMockMvc(MockMvc mockMvc) { + this.mockMvc = mockMvc; + } + + public WebApplicationContext getWebApplicationContext() { + return wac; + } + +} + +@Configuration +@ComponentScan(basePackages = "org.openecomp", excludeFilters = { + // the following source configurations should not be scanned; instead of + // using Exclusion filter, we can use the @Profile annotation to exclude + // them + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalsdk.core.controller.LogoutController*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalsdk.core.controller.SDKLoginController*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalapp.conf.ExternalAppConfig*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.*.*InitUebHandler*") }) +@Profile("test") +class MockAppConfig extends AppConfig { + + @Bean + HibernateMappingLocatable locatable() { + return new MockHibernateMappingLocations(); + } + + @Bean + HibernateConfiguration hibConfiguration() { + return new HibernateConfiguration(); + } + + @Bean + public SystemProperties systemProperties() { + return new MockSystemProperties(); + } + + @Bean + public AbstractCacheManager cacheManager() { + return new CacheManager() { + + public void configure() throws IOException { + + } + }; + } + + public String[] tileDefinitions() { + return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml", + "classpath:/WEB-INF/defs/definitions.xml" }; + } + + public void addInterceptors(InterceptorRegistry registry) { + // registry.addInterceptor(new + // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout()); + // registry.addInterceptor(resourceInterceptor()); + } + + public static class MockSystemProperties extends SystemProperties { + + public MockSystemProperties() { + } + + } + +} + +@Profile("test") +class MockHibernateMappingLocations implements HibernateMappingLocatable { + + public Resource[] getMappingLocations() { + return new Resource[] { new ClassPathResource("WEB-INF/fusion/orm/Fusion.hbm.xml"), + new ClassPathResource("WEB-INF/fusion/orm/EP.hbm.xml"), + new ClassPathResource("WEB-INF/fusion/orm/Workflow.hbm.xml") }; + + } + + public String[] getPackagesToScan() { + return new String[] { "org.openecomp", "src" }; + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/MockitoTestSuite.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/MockitoTestSuite.java new file mode 100644 index 00000000..614e2ac3 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/framework/MockitoTestSuite.java @@ -0,0 +1,70 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.framework; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class MockitoTestSuite { + + + public MockHttpServletRequestWrapper mockedRequest = new MockHttpServletRequestWrapper( + Mockito.mock(HttpServletRequest.class)); + public HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class); + + public MockHttpServletRequestWrapper getMockedRequest() { + return mockedRequest; + } + + public HttpServletResponse getMockedResponse() { + return mockedResponse; + } + + public class MockHttpServletRequestWrapper extends HttpServletRequestWrapper { + + HttpSession session = Mockito.mock(HttpSession.class); + + public MockHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + + } + + @Override + public HttpSession getSession() { + + return session; + } + + @Override + public HttpSession getSession(boolean create) { + + return session; + } + + } + +} diff --git a/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/service/FunctionalMenuServiceImplTest.java b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/service/FunctionalMenuServiceImplTest.java new file mode 100644 index 00000000..7aa2029c --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/java/org/openecomp/portalapp/portal/test/service/FunctionalMenuServiceImplTest.java @@ -0,0 +1,88 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.test.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.test.framework.ApplicationCommonContextTestSuite; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole; +import org.openecomp.portalapp.portal.transport.FunctionalMenuRole; +import org.springframework.beans.factory.annotation.Autowired; + + + + +public class FunctionalMenuServiceImplTest extends ApplicationCommonContextTestSuite{ + + + @Autowired + FunctionalMenuService functionalMenuService; + + + + @Test + public void getAppListTestService() throws Exception { + + String userId ="guest"; + List userAppRolesActualResult = null; + + List userAppRolesExpectedResult = new ArrayList(); + BusinessCardApplicationRole businessCardApplicationRole= new BusinessCardApplicationRole(); + businessCardApplicationRole.setAppName("ECOMP Portal"); + businessCardApplicationRole.setRoleName("System Administrator"); + userAppRolesExpectedResult.add(businessCardApplicationRole); + Map params = new HashMap(); + params.put("userId", userId); + userAppRolesActualResult =functionalMenuService.getUserAppRolesList(userId); + assertTrue(userAppRolesActualResult.contains(businessCardApplicationRole)); + + + } + + + @Test + public void getFunctionalMenuRoleTest() throws Exception { + + FunctionalMenuRole expectedFunctionalMenuRole = new FunctionalMenuRole(); + + expectedFunctionalMenuRole.setId(new Integer(99999999)) ; + expectedFunctionalMenuRole.setMenuId((long) 137); + expectedFunctionalMenuRole.setAppId(new Integer(456)); + expectedFunctionalMenuRole.setRoleId(new Integer(6214)); + List actualFunctionalMenuRoleList = null; + actualFunctionalMenuRoleList = functionalMenuService.getFunctionalMenuRole(); + assertEquals(expectedFunctionalMenuRole.getAppId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getAppId()); + assertEquals(expectedFunctionalMenuRole.getMenuId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getMenuId()); + assertEquals(expectedFunctionalMenuRole.getId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getId()); + assertEquals(expectedFunctionalMenuRole.getRoleId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getRoleId()); + + } + +} + + diff --git a/ecomp-portal-BE-common-test/src/main/resources/PopulateTestData.sql b/ecomp-portal-BE-common-test/src/main/resources/PopulateTestData.sql new file mode 100644 index 00000000..6972ec95 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/resources/PopulateTestData.sql @@ -0,0 +1,28 @@ +--- +-- ================================================================================ +-- 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. +-- 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. +-- ================================================================================ +--- +insert into fn_user values(99999999,null,null,'test',null,'test',null,null,null,null,null,null,null,'guest',null,null,null,null,true,null,null,null,null,false,null,null,null, +null,null,null,null,null,null,null,null,null,null,null,null,null,null,null); +insert into fn_user_role values(99999999,1, null,1); +insert into fn_user_role values(99999999,16, null,1); +insert into fn_user_role values(99999999,999, null,1); +insert into fn_user_role values(99999999,1010, null,1); +insert into fn_menu_functional values(99999999,3,'Network Analytics',5,'http://vm-d2novasdn3.client.research.att.com:8080/d2novasdn-1/welcome.htm','Y',null); +insert into fn_menu_functional_roles values(99999999, 137,456, 6214); +insert into fn_menu_favorites values(3, 141); diff --git a/ecomp-portal-BE-common-test/src/main/resources/RemoveTestData.sql b/ecomp-portal-BE-common-test/src/main/resources/RemoveTestData.sql new file mode 100644 index 00000000..158508f7 --- /dev/null +++ b/ecomp-portal-BE-common-test/src/main/resources/RemoveTestData.sql @@ -0,0 +1,27 @@ +--- +-- ================================================================================ +-- 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. +-- 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. +-- ================================================================================ +--- +delete from fn_user_role where user_id ='99999999'; +delete from ep_user_notification where user_id='99999999'; +delete from fn_audit_log where user_id='99999999'; +delete from fn_user where user_id='99999999'; +delete from fn_menu_functional_roles where id='99999999'; +delete from fn_menu_functional_ancestors where menu_id=99999999; +delete from fn_menu_functional where menu_id='99999999'; +delete from fn_menu_favorites where user_id=3 and menu_id=141; diff --git a/ecomp-portal-BE-common/.gitignore b/ecomp-portal-BE-common/.gitignore new file mode 100644 index 00000000..0580e087 --- /dev/null +++ b/ecomp-portal-BE-common/.gitignore @@ -0,0 +1,5 @@ +/catalina.base_IS_UNDEFINED/ +/target/ +.classpath +.project +.settings/ diff --git a/ecomp-portal-BE-common/license/licenses.properties b/ecomp-portal-BE-common/license/licenses.properties new file mode 100644 index 00000000..4b0e28e7 --- /dev/null +++ b/ecomp-portal-BE-common/license/licenses.properties @@ -0,0 +1 @@ +my_license=My license diff --git a/ecomp-portal-BE-common/license/my_license/header.txt b/ecomp-portal-BE-common/license/my_license/header.txt new file mode 100644 index 00000000..c026b6b7 --- /dev/null +++ b/ecomp-portal-BE-common/license/my_license/header.txt @@ -0,0 +1,11 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file 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. diff --git a/ecomp-portal-BE-common/license/my_license/license.txt b/ecomp-portal-BE-common/license/my_license/license.txt new file mode 100644 index 00000000..bf326153 --- /dev/null +++ b/ecomp-portal-BE-common/license/my_license/license.txt @@ -0,0 +1,4 @@ +name=my_license +description= +licenseURL= +headerURL= \ No newline at end of file diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml new file mode 100644 index 00000000..9fb41d31 --- /dev/null +++ b/ecomp-portal-BE-common/pom.xml @@ -0,0 +1,666 @@ + + 4.0.0 + org.openecomp.portal + ecompportal-be-common + war + + 1.1.0-SNAPSHOT + + + 4.2.0.RELEASE + 4.3.11.Final + 1.0.0 + 2.7.4 + 1.1.0-SNAPSHOT + UTF-8 + + true + https://nexus.onap.org + /content/repositories/snapshots/ + /content/repositories/releases/ + /content/repositories/staging/ + + + + + + ecomp-releases + OpenECOMP - Release Repository + ${nexusproxy}/${releaseNexusPath} + + + + ecomp-snapshots + OpenECOMP - Snapshot Repository + ${nexusproxy}/${snapshotNexusPath} + + + + ecomp-staging + OpenECOMP - Staging Repository + ${nexusproxy}/${stagingNexusPath} + + + + + + + doclint-java8-disable + + [1.8,) + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + -Xdoclint:none + + + + + + + + + + + ${project.artifactId} + + + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + attach-javadocs + + jar + + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.0 + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + + true + + WEB-INF/lib/*.jar + + + + + + + + + + src/test/java + + **/*Test*.* + + + + + + + src/main/resources + + **/* + + + + + src/main/java + + **/*.xml + **/*.properties + + + + + + + + + com.att.eelf + eelf-core + ${eelf.version} + + + com.google.code.gson + gson + 2.5 + + + + + org.springframework + spring-core + ${springframework.version} + + + org.springframework + spring-web + ${springframework.version} + + + org.springframework + spring-webmvc + ${springframework.version} + + + org.springframework + spring-tx + ${springframework.version} + + + org.springframework + spring-context-support + ${springframework.version} + + + org.springframework + spring-orm + ${springframework.version} + + + org.springframework + spring-test + ${springframework.version} + + + org.springframework.boot + spring-boot-starter + 1.3.0.RELEASE + + + org.slf4j + log4j-over-slf4j + + + ch.qos.logback + logback-classic + + + + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.hibernate + hibernate-validator + 5.1.3.Final + + + + + dom4j + dom4j + 1.6.1 + + + jaxme + jaxme-api + + + jaxen + jaxen + + + msv + xsdlib + + + msv + relaxngDatatype + + + pull-parser + pull-parser + + + xpp3 + xpp3 + + + stax + stax-api + + + + + + + javax.servlet + javax.servlet-api + 3.1.0 + + + javax.servlet.jsp + javax.servlet.jsp-api + 2.3.1 + + + javax.servlet + jstl + 1.2 + + + + + + + org.apache.tiles + tiles-core + 3.0.5 + + + org.apache.tiles + tiles-jsp + 3.0.5 + + + org.apache.cxf + cxf-rt-rs-client + 3.0.0-milestone1 + + + + + com.fasterxml.jackson.core + jackson-annotations + ${fasterxml.version} + + + com.fasterxml.jackson.core + jackson-core + ${fasterxml.version} + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.version} + + + + postgresql + postgresql + 9.1-901-1.jdbc4 + + + + + org.mariadb.jdbc + mariadb-java-client + 1.5.8 + + + + + org.elasticsearch + elasticsearch + 2.2.0 + + + io.searchbox + jest + 2.0.0 + + + + org.apache.jcs + jcs + 1.3 + + + * + * + + + + + + + org.apache.tomcat + tomcat-websocket + 8.0.28 + provided + + + + concurrent + concurrent + 1.3.2 + + + * + * + + + + + + + commons-lang + commons-lang + 2.6 + + + jfree + jfreechart + 1.0.13 + + + + org.apache.poi + poi + 3.5-FINAL + + + commons-logging + commons-logging + + + log4j + log4j + + + + + org.apache.poi + poi-ooxml + 3.5-FINAL + + + commons-logging + commons-logging + + + log4j + log4j + + + + + org.apache.poi + poi-scratchpad + 3.5-FINAL + + + commons-logging + commons-logging + + + log4j + log4j + + + + + org.apache.poi + poi-contrib + 3.5-FINAL + + + commons-logging + commons-logging + + + log4j + log4j + + + + + + + com.lowagie + itext + 2.0.8 + + + + org.quartz-scheduler + quartz + 2.2.1 + + + + c3p0 + c3p0 + + + + + + org.bouncycastle + bcprov-jdk16 + 1.45 + + + + commons-codec + commons-codec + 1.9 + + + + com.att.nsa + cambriaClient + 0.0.1 + + + commons-logging + commons-logging + + + log4j + log4j + + + log4j + apache-log4j-extras + + + org.slf4j + slf4j-log4j12 + + + + + + org.openecomp.ecompsdkos + epsdk-fw + ${epsdk.version} + + + commons-logging + commons-logging + + + log4j + log4j + + + log4j + apache-log4j-extras + + + org.slf4j + slf4j-log4j12 + + + + + org.openecomp.ecompsdkos + epsdk-core + ${epsdk.version} + + + mysql + mysql-connector-java + + + + + org.openecomp.ecompsdkos + epsdk-app-common + ${epsdk.version} + + + org.openecomp.ecompsdkos + epsdk-workflow + ${epsdk.version} + + + + + + org.openecomp.ecompsdkos + epsdk-analytics + ${epsdk.version} + + + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + + + junit + junit + 4.11 + test + + + + commons-beanutils + commons-beanutils + 1.9.2 + + + + com.ecwid.consul + consul-api + 1.2.1 + + + + com.orbitz.consul + consul-client + 0.13.8 + + + + commons-fileupload + commons-fileupload + 1.3 + + + + io.springfox + springfox-swagger2 + 2.5.0 + + + + io.springfox + springfox-swagger-ui + 2.5.0 + + + + + + + diff --git a/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java b/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java new file mode 100644 index 00000000..76d4b181 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java @@ -0,0 +1,204 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package jarutil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.net.URL; +import java.util.ArrayList; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; + +public class ExtractJar { + + /** + * @param args + */ + + public static int bufferSize = 8192; + public static String JARFILE = "raptor_upgrade.jar"; + + public static void main(String[] args) throws Exception { + if(args.length > 0 && args[0]!=null && args[0].length()>0) + extractFilesFromJar(args[0]); + else { + System.out.println("Current Directory is taken as webapp path"); + String currentDir = new File(".").getAbsolutePath(); + extractFilesFromJar(currentDir); + } + } + + public static void readJar(File jarFile) throws Exception{ + JarInputStream in = new JarInputStream(new FileInputStream(jarFile)); + ArrayList entries = new ArrayList( ); + JarEntry je; + while((je=in.getNextJarEntry( ))!=null){ + if( je.isDirectory() == false ) { + if(je.getName().startsWith("att/raptor/config/")) { + //while((je=in.getNextJarEntry( ))!=null) { + System.out.println(je.getName() + " " + je.getTime()); + //} + + } + } + } + in.close( ); + } + + public static void extractFilesFromJar(String directory) throws IOException{ + //JarFile jar = new JarFile(jarFile); + Class clazz = ExtractJar.class; + String classContainer = clazz.getProtectionDomain().getCodeSource().getLocation().toString(); + //System.out.println("classContainer ---------> " + classContainer); + URL jarUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); + + JarInputStream entryStream = new JarInputStream(jarUrl.openStream()); + JarEntry entry; + while(true) { + entry = entryStream.getNextJarEntry(); + if(entry == null) + break; + if(entry.getName().indexOf("jarutil") < 0) { + System.out.println(entry.getName()); + File file=new File(directory,entry.getName()); + if(entry.isDirectory()) { + if (!file.exists()) + file.mkdirs(); + } else { + // make directory (some jars don't list dirs) + File dir = new File(file.getParent()); + if (!dir.exists()) + dir.mkdirs(); + if(file.exists()) file.delete(); + // Make file + FileOutputStream fout = new FileOutputStream(file); + copy(entryStream,fout); + fout.close(); + + // touch the file. + if (entry.getTime()>=0) + file.setLastModified(entry.getTime()); + } + + } + entryStream.closeEntry(); + } + entryStream.close(); + System.out.println("************************************************"); + System.out.println("* *"); + System.out.println("* *"); + System.out.println("* RAPTOR SETUP COMPLETE. *"); + System.out.println("* *"); + System.out.println("* Thank you for upgrading. *"); + System.out.println("* *"); + System.out.println("************************************************"); + } + + + public static void copy(InputStream in, OutputStream out, long byteCount) + throws IOException { + byte buffer[] = new byte[bufferSize]; + int len=bufferSize; + if (byteCount>=0) { + while (byteCount>0) { + if (byteCount=0) { + while (byteCount>0) { + if (byteCount menu; + private Set businessDirectMenu; + + /** + * getLoginId + * + * @return String + */ + public String getLoginId() { + return loginId; + } + + /** + * getLoginPwd + * + * @return String + */ + public String getLoginPwd() { + return loginPwd; + } + + /** + * getMenu + * + * @return Set + */ + public Set getMenu() { + return menu; + } + + /** + * getUser + * + * @return User + */ + public EPUser getUser() { + return user; + } + + /** + * getHrid + * + * @return String + */ + public String getHrid() { + return hrid; + } + + /** + * getSiteAccess + * + * @return String + */ + public String getSiteAccess() { + return siteAccess; + } + + /** + * getBusinessDirectMenu + * + * @return Set + */ + public Set getBusinessDirectMenu() { + return businessDirectMenu; + } + + /** + * getLoginErrorMessage + * + * @return String + */ + public String getLoginErrorMessage() { + return loginErrorMessage; + } + + public String getOrgUserId() { + return orgUserId; + } + + /** + * setLoginId + * + * @param loginId String + */ + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + /** + * setLoginPwd + * + * @param loginPwd String + */ + public void setLoginPwd(String loginPwd) { + this.loginPwd = loginPwd; + } + + public void setMenu(Set menu) { + this.menu = menu; + } + + /** + * setUser + * + * @param user User + */ + public void setUser(EPUser user) { + this.user = user; + } + + /** + * setHrid + * + * @param hrid String + */ + public void setHrid(String hrid) { + this.hrid = hrid; + } + + /** + * setSiteAccess + * + * @param siteAccess String + */ + public void setSiteAccess(String siteAccess) { + this.siteAccess = siteAccess; + } + + /** + * setBusinessDirectMenu + * + * @param businessDirectMenu Set + */ + public void setBusinessDirectMenu(Set businessDirectMenu) { + this.businessDirectMenu = businessDirectMenu; + } + + /** + * setLoginErrorMessage + * + * @param loginErrorMessage String + */ + public void setLoginErrorMessage(String loginErrorMessage) { + this.loginErrorMessage = loginErrorMessage; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/command/PostSearchBean.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/command/PostSearchBean.java new file mode 100644 index 00000000..9861554a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/command/PostSearchBean.java @@ -0,0 +1,373 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.command; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalsdk.core.command.support.SearchBase; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize +public class PostSearchBean extends SearchBase { + + private EPUser user = null; + private EPUser userOrig = null; + private String[] selected; + private String[] postHrid; + private String[] postOrgUserId; + private String[] postFirstName; + private String[] postLastName; + private String[] postOrgCode; + private String[] postPhone; + private String[] postEmail; + private String[] postAddress1; + private String[] postAddress2; + private String[] postCity; + private String[] postState; + private String[] postZipCode; + private String[] postLocationClli; + private String[] postBusinessCountryCode; + private String[] postBusinessCountryName; + private String[] postDepartment; + private String[] postDepartmentName; + private String[] postBusinessUnit; + private String[] postBusinessUnitName; + private String[] postJobTitle; + private String[] postOrgManagerUserId; + private String[] postCommandChain; + private String[] postCompanyCode; + private String[] postCompany; + private String[] postCostCenter; + private String[] postSiloStatus; + private String[] postFinancialLocCode; + + + public PostSearchBean() { + this(null); + } // PostSearchBean + + public PostSearchBean(List items) { + super(items); + + user = new EPUser(); + userOrig = new EPUser(); + + setSortBy1(""); + setSortBy1Orig(""); + + //setSortByList(...); + } // PostSearchBean + + + public String getFirstName() { return user.getFirstName(); } + public String getLastName() { return user.getLastName(); } + public String getHrid() { return user.getHrid(); } + public String getOrgUserId() { return user.getOrgUserId(); } + public String getOrgCode() { return user.getOrgCode(); } + public String getEmail() { return user.getEmail(); } + public String getOrgManagerUserId() { return user.getOrgManagerUserId(); } + + public String getFirstNameOrig() { return user.getFirstName(); } + public String getLastNameOrig() { return user.getLastName(); } + public String getHridOrig() { return user.getHrid(); } + public String getOrgUserIdOrig() { return user.getOrgUserId(); } + public String getOrgCodeOrig() { return user.getOrgCode(); } + public String getEmailOrig() { return user.getEmail(); } + public String getOrgManagerUserIdOrig() { return user.getOrgManagerUserId(); } + + + public EPUser getUser() { return user; } + + public String[] getPostEmail() { + return postEmail; + } + + public String[] getPostFirstName() { + return postFirstName; + } + + public String[] getPostHrid() { + return postHrid; + } + + public String[] getPostLastName() { + return postLastName; + } + + public String[] getPostOrgCode() { + return postOrgCode; + } + + public String[] getPostPhone() { + return postPhone; + } + + public String[] getPostOrgUserId() { + return postOrgUserId; + } + + public String[] getSelected() { + return selected; + } + + public String[] getPostAddress1() { + return postAddress1; + } + + public String[] getPostBusinessCountryCode() { + return postBusinessCountryCode; + } + + public String[] getPostCity() { + return postCity; + } + + public String[] getPostCommandChain() { + return postCommandChain; + } + + public String[] getPostCompany() { + return postCompany; + } + + public String[] getPostCompanyCode() { + return postCompanyCode; + } + + public String[] getPostDepartment() { + return postDepartment; + } + + public String[] getPostDepartmentName() { + return postDepartmentName; + } + + public String[] getPostBusinessCountryName() { + return postBusinessCountryName; + } + + public String[] getPostJobTitle() { + return postJobTitle; + } + + public String[] getPostLocationClli() { + return postLocationClli; + } + + public String[] getPostManagerUserId() { + return postOrgManagerUserId; + } + + public String[] getPostState() { + return postState; + } + + public String[] getPostZipCode() { + return postZipCode; + } + + public void setFirstName(String value) { user.setFirstName(value); } + public void setLastName(String value) { user.setLastName(value); } + public void setHrid(String value) { user.setHrid(value); } + public void setOrgUserId(String value) { user.setOrgUserId(value); } + public void setOrgCode(String value) { user.setOrgCode(value); } + public void setEmail(String value) { user.setEmail(value); } + public void setOrgManagerUserId(String value) { user.setOrgManagerUserId(value); } + + public void setFirstNameOrig(String value) { userOrig.setFirstName(value); } + public void setLastNameOrig(String value) { userOrig.setLastName(value); } + public void setHridOrig(String value) { userOrig.setHrid(value); } + public void setOrgUserIdOrig(String value) { userOrig.setOrgUserId(value); } + public void setOrgCodeOrig(String value) { userOrig.setOrgCode(value); } + public void setEmailOrig(String value) { userOrig.setEmail(value); } + public void setOrgManagerUserIdOrig(String value) { userOrig.setOrgManagerUserId(value); } + + public void setUser(EPUser value) { this.user = value; } + + public void setPostEmail(String[] postEmail) { + this.postEmail = postEmail; + } + + public void setPostFirstName(String[] postFirstName) { + this.postFirstName = postFirstName; + } + + public void setPostHrid(String[] postHrid) { + this.postHrid = postHrid; + } + + public void setPostLastName(String[] postLastName) { + this.postLastName = postLastName; + } + + public void setPostOrgCode(String[] postOrgCode) { + this.postOrgCode = postOrgCode; + } + + public void setPostPhone(String[] postPhone) { + this.postPhone = postPhone; + } + + public void setPostUserId(String[] postOrgUserId) { + this.postOrgUserId = postOrgUserId; + } + + public void setSelected(String[] selected) { + this.selected = selected; + } + + public void setPostAddress1(String[] postAddress1) { + this.postAddress1 = postAddress1; + } + + public void setPostBusinessCountryCode(String[] postBusinessCountryCode) { + this.postBusinessCountryCode = postBusinessCountryCode; + } + + public void setPostCity(String[] postCity) { + this.postCity = postCity; + } + + public void setPostCommandChain(String[] postCommandChain) { + this.postCommandChain = postCommandChain; + } + + public void setPostCompany(String[] postCompany) { + this.postCompany = postCompany; + } + + public void setPostCompanyCode(String[] postCompanyCode) { + this.postCompanyCode = postCompanyCode; + } + + public void setPostDepartment(String[] postDepartment) { + this.postDepartment = postDepartment; + } + + public void setPostDepartmentName(String[] postDepartmentName) { + this.postDepartmentName = postDepartmentName; + } + + public void setPostBusinessCountryName(String[] postBusinessCountryName) { + this.postBusinessCountryName = postBusinessCountryName; + } + + public void setPostJobTitle(String[] postJobTitle) { + this.postJobTitle = postJobTitle; + } + + public void setPostLocationClli(String[] postLocationClli) { + this.postLocationClli = postLocationClli; + } + + public void setPostManagerUserId(String[] postOrgManagerUserId) { + this.postOrgManagerUserId = postOrgManagerUserId; + } + + public void setPostState(String[] postState) { + this.postState = postState; + } + + public void setPostZipCode(String[] postZipCode) { + this.postZipCode = postZipCode; + } + + public String[] getPostAddress2() { + return postAddress2; + } + + public void setPostAddress2(String[] postAddress2) { + this.postAddress2 = postAddress2; + } + + public EPUser getUserOrig() { + return userOrig; + } + + public void setUserOrig(EPUser userOrig) { + this.userOrig = userOrig; + } + + public String[] getPostBusinessUnit() { + return postBusinessUnit; + } + + public void setPostBusinessUnit(String[] postBusinessUnit) { + this.postBusinessUnit = postBusinessUnit; + } + + public String[] getPostBusinessUnitName() { + return postBusinessUnitName; + } + + public void setPostBusinessUnitName(String[] postBusinessUnitName) { + this.postBusinessUnitName = postBusinessUnitName; + } + + public String[] getPostCostCenter() { + return postCostCenter; + } + + public void setPostCostCenter(String[] postCostCenter) { + this.postCostCenter = postCostCenter; + } + + public String[] getPostSiloStatus() { + return postSiloStatus; + } + + public void setPostSiloStatus(String[] postSiloStatus) { + this.postSiloStatus = postSiloStatus; + } + + public String[] getPostFinancialLocCode() { + return postFinancialLocCode; + } + + public void setPostFinancialLocCode(String[] postFinancialLocCode) { + this.postFinancialLocCode = postFinancialLocCode; + } + + public void resetSearch() { + super.resetSearch(); + setUser(new EPUser()); + } // resetSearch + + + public boolean isCriteriaUpdated() { + if(user==null&&userOrig==null) + return false; + else if(user==null||userOrig==null) + return true; + else + return (! ( + Utilities.nvl(user.getFirstName()).equals(Utilities.nvl(userOrig.getFirstName()))&& + Utilities.nvl(user.getLastName()).equals(Utilities.nvl(userOrig.getLastName()))&& + //Utilities.nvl(user.getHrid()).equals(Utilities.nvl(userOrig.getHrid()))&& + Utilities.nvl(user.getOrgUserId()).equals(Utilities.nvl(userOrig.getOrgUserId()))&& + Utilities.nvl(user.getOrgCode()).equals(Utilities.nvl(userOrig.getOrgCode()))&& + Utilities.nvl(user.getEmail()).equals(Utilities.nvl(userOrig.getEmail()))&& + Utilities.nvl(user.getOrgManagerUserId()).equals(Utilities.nvl(userOrig.getOrgManagerUserId()))&& + true)); + } // isCriteriaUpdated + +} // PostSearchBean diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerConfig.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerConfig.java new file mode 100644 index 00000000..7082fe78 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerConfig.java @@ -0,0 +1,58 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + @Bean + public Docket api(){ + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.regex("/auxapi/.*")) + .build() + .apiInfo(apiInfo()); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("ECOMP Portal API Documentation") + .description("ECOMP Portal API Documentation") + .version("1.2.6") + .termsOfServiceUrl("http://terms-of-services.url") + .license("LICENSE") + .licenseUrl("http://url-to-license.com") + .build(); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerMVCConfig.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerMVCConfig.java new file mode 100644 index 00000000..7e2d4540 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/config/SwaggerMVCConfig.java @@ -0,0 +1,37 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableWebMvc +public class SwaggerMVCConfig extends WebMvcConfigurerAdapter { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPFusionBaseController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPFusionBaseController.java new file mode 100644 index 00000000..986f6387 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPFusionBaseController.java @@ -0,0 +1,106 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.controller; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.controller.FusionBaseController; +import org.openecomp.portalsdk.core.domain.MenuData; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Controller +public abstract class EPFusionBaseController extends FusionBaseController { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPFusionBaseController.class); + + + + @Override + public boolean isAccessible() { + return true; + } + + public boolean isRESTfulCall() { + return true; + } + + @ModelAttribute("menu") + public Map messages(HttpServletRequest request) { + HttpSession session = null; + Map model = new HashMap(); + session = request.getSession(); + EPUser user = EPUserUtils.getUserSession(request); + if (session != null && user != null) { + @SuppressWarnings("unchecked") + Set menuResult = (Set) session + .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); + try { + model = setMenu(menuResult); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + } + + return model; + } + + public Map setMenu(Set menuResult) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + List> childItemList = new ArrayList>(); + ; + List parentList = new ArrayList(); + ; + Map model = new HashMap(); + for (MenuData menu : menuResult) { + MenuData parentData = new MenuData(); + parentData.setLabel(menu.getLabel()); + parentData.setAction(menu.getAction()); + parentData.setImageSrc(menu.getImageSrc()); + parentList.add(parentData); + List tempList = new ArrayList(); + for (Object o : menu.getChildMenus()) { + MenuData m = (MenuData) o; + MenuData data = new MenuData(); + data.setLabel(m.getLabel()); + data.setAction(m.getAction()); + data.setImageSrc(m.getImageSrc()); + tempList.add(data); + } + childItemList.add(tempList); + } + model.put("childItemList", childItemList != null ? mapper.writeValueAsString(childItemList) : ""); + model.put("parentList", parentList != null ? mapper.writeValueAsString(parentList) : ""); + return model; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedBaseController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedBaseController.java new file mode 100644 index 00000000..b3bef781 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedBaseController.java @@ -0,0 +1,52 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.controller; + +public class EPRestrictedBaseController extends EPFusionBaseController{ + + protected String viewName; + private String exceptionView; + + @Override + public boolean isAccessible() { + return false; + } + + @Override + public boolean isRESTfulCall(){ + return false; + } + + protected String getViewName() { + return viewName; + } + + protected void setViewName(String viewName) { + this.viewName = viewName; + } + + public String getExceptionView() { + return (exceptionView == null) ? "runtime_error_handler" : exceptionView; + } + + public void setExceptionView(String exceptionView) { + this.exceptionView = exceptionView; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedRESTfulBaseController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedRESTfulBaseController.java new file mode 100644 index 00000000..7b1be46c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPRestrictedRESTfulBaseController.java @@ -0,0 +1,54 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.controller; + +public class EPRestrictedRESTfulBaseController extends EPFusionBaseController{ + + protected String viewName; + private String exceptionView; + + @Override + public boolean isAccessible() { + return false; + } + + @Override + public boolean isRESTfulCall(){ + return true; + } + + protected String getViewName() { + return viewName; + } + + protected void setViewName(String viewName) { + this.viewName = viewName; + } + + public String getExceptionView() { + return (exceptionView == null) ? "runtime_error_handler" : exceptionView; + } + + public void setExceptionView(String exceptionView) { + this.exceptionView = exceptionView; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPUnRestrictedBaseController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPUnRestrictedBaseController.java new file mode 100644 index 00000000..f16c1b94 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/EPUnRestrictedBaseController.java @@ -0,0 +1,42 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.controller; + +public class EPUnRestrictedBaseController extends EPFusionBaseController{ + protected String viewName; + + @Override + public boolean isAccessible() { + return true; + } + + @Override + public boolean isRESTfulCall(){ + return false; + } + + protected String getViewName() { + return viewName; + } + + protected void setViewName(String viewName) { + this.viewName = viewName; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/sessionmgt/SessionCommunicationController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/sessionmgt/SessionCommunicationController.java new file mode 100644 index 00000000..eda094b5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/controller/sessionmgt/SessionCommunicationController.java @@ -0,0 +1,72 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.controller.sessionmgt; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedRESTfulBaseController; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalapp.service.sessionmgt.ManageService; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + + +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class SessionCommunicationController extends EPRestrictedRESTfulBaseController { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionCommunicationController.class); + + @Autowired + private ManageService manageService; + + protected boolean isAuxRESTfulCall(){ + return true; + } + + @ApiOperation(value = "Gets session slot-check interval, a duration in milliseconds.", + response = Integer.class) + @RequestMapping(value={"/getSessionSlotCheckInterval"}, method = RequestMethod.GET, produces = "application/json") + public Integer getSessionSlotCheckInterval(HttpServletRequest request, HttpServletResponse response) throws Exception { + return manageService.fetchSessionSlotCheckInterval(); + } + + @ApiOperation(value = "Extends session timeout values for all on-boarded applications.", + response = Boolean.class) + @RequestMapping(value={"/extendSessionTimeOuts"}, method = RequestMethod.POST) + public Boolean extendSessionTimeOuts(HttpServletRequest request, HttpServletResponse response, @RequestParam String sessionMap) throws Exception { + manageService.extendSessionTimeOuts(sessionMap); + + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/controller/RolesApprovalSystemController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/controller/RolesApprovalSystemController.java new file mode 100644 index 00000000..e0fa523a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/controller/RolesApprovalSystemController.java @@ -0,0 +1,143 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.externalsystemapproval.controller; + +import java.util.ArrayList; + +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.externalsystemapproval.model.ExternalSystemRoleApproval; +import org.openecomp.portalapp.externalsystemapproval.model.ExternalSystemUser; +import org.openecomp.portalapp.portal.controller.BasicAuthenticationController; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.UserRolesService; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class RolesApprovalSystemController implements BasicAuthenticationController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RolesApprovalSystemController.class); + + @Autowired + private UserRolesService userRolesService; + + /** + * Creates an application user with the specified roles. + * + * @param request + * @param extSysUser + * @return PortalRestResponse with appropriate status value and message + */ + @ApiOperation(value = "Creates an application user with the specified roles.", response = PortalRestResponse.class) + @RequestMapping(value = { "/userProfile" }, method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse postUserProfile(HttpServletRequest request, + @RequestBody ExternalSystemUser extSysUser) { + try { + validateExtSystemUser(extSysUser, true); + String response = userRolesService.setAppWithUserRoleStateForUser(extSysUser); + return new PortalRestResponse(PortalRestStatusEnum.OK, "Saved Successfully", response); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "postUserProfile failed", e); + return new PortalRestResponse(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + /** + * Updates an application user to have only the specified roles. + * + * @param request + * @param extSysUser + * @return PortalRestResponse with appropriate status value and message + */ + @ApiOperation(value = "Updates an application user to have only the specified roles.", response = PortalRestResponse.class) + @RequestMapping(value = { "/userProfile" }, method = RequestMethod.PUT, produces = "application/json") + public PortalRestResponse putUserProfile(HttpServletRequest request, + @RequestBody ExternalSystemUser extSysUser) { + try { + validateExtSystemUser(extSysUser, true); + String response = userRolesService.setAppWithUserRoleStateForUser(extSysUser); + return new PortalRestResponse(PortalRestStatusEnum.OK, "Updated Successfully", response); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserProfile failed", e); + return new PortalRestResponse(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + /** + * Deletes an application user by removing all assigned roles. + * + * @param request + * @param extSysUser + * This object must have zero roles. + * @return PortalRestResponse with appropriate status value and message + */ + @ApiOperation(value = "Processes a request to delete one or more application roles for one specified user who has roles.", response = PortalRestResponse.class) + @RequestMapping(value = { "/userProfile" }, method = RequestMethod.DELETE, produces = "application/json") + public PortalRestResponse deleteUserProfile(HttpServletRequest request, + @RequestBody ExternalSystemUser extSysUser) { + try { + validateExtSystemUser(extSysUser, false); + // Ignore any roles that might be mistakenly present in the request + extSysUser.setRoles(new ArrayList()); + String result = userRolesService.setAppWithUserRoleStateForUser(extSysUser); + return new PortalRestResponse(PortalRestStatusEnum.OK, "Deleted Successfully", result); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteUserProfile failed", e); + return new PortalRestResponse(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + /** + * Checks for presence of required fields. + * + * @param extSysUser + * @param rolesRequired + * If true, checks whether roles are present + * @throws Exception + * If any field is missing. + */ + private void validateExtSystemUser(ExternalSystemUser extSysUser, boolean rolesRequired) throws Exception { + if (extSysUser.getLoginId() == null) + throw new Exception("Request has no login ID"); + if (extSysUser.getApplicationName() == null) + throw new Exception("Request has no application name"); + if (extSysUser.getMyloginrequestId() == null) + throw new Exception("Request has no request ID"); + if (rolesRequired && (extSysUser.getRoles() == null || extSysUser.getRoles().size() == 0)) + throw new Exception("Request has no roles"); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemRoleApproval.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemRoleApproval.java new file mode 100644 index 00000000..f958d2b5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemRoleApproval.java @@ -0,0 +1,41 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.externalsystemapproval.model; + +import java.io.Serializable; + + +public class ExternalSystemRoleApproval implements Serializable{ + + + private static final long serialVersionUID = 6048830318039958615L; + + private String roleName ; + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemUser.java new file mode 100644 index 00000000..f3ccd14a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/externalsystemapproval/model/ExternalSystemUser.java @@ -0,0 +1,74 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.externalsystemapproval.model; + + +import java.util.ArrayList; +import java.util.List; + +public class ExternalSystemUser { + + private String loginId; + + private String applicationName; + + private String myloginrequestId; + + private List roles; + + public ExternalSystemUser() { + roles = new ArrayList(); + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getMyloginrequestId() { + return myloginrequestId; + } + + public void setMyloginrequestId(String myloginrequestId) { + this.myloginrequestId = myloginrequestId; + } + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/FusionLicenseManagerImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/FusionLicenseManagerImpl.java new file mode 100644 index 00000000..e932995f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/FusionLicenseManagerImpl.java @@ -0,0 +1,88 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.lm; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; + +import org.openecomp.portalsdk.core.lm.FusionLicenseManager; +import org.springframework.stereotype.Component; + +/* + * Please note that this class is not being used; its a dummy stub to have a qualifying bean for the interface. + */ + +@Component +public class FusionLicenseManagerImpl implements FusionLicenseManager { + + @Override + public void initKeyStoreParam() { + + } + + @Override + public void initCipherParam() { + + } + + @Override + public void initLicenseParam() { + + } + + @Override + public void doInitWork() { + + } + + @Override + public int installLicense() { + return 0; + } + + @Override + public synchronized int verifyLicense(ServletContext context) { + return 0; + } + + @Override + public void generateLicense(Map clientInfoMap, List ipAddressList) throws Exception { + + } + + @Override + public String nvl(String s) { + return null; + } + + @Override + public Date getExpiredDate() { + return null; + } + + @Override + public void setExpiredDate(Date expiredDate) { + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/LicenseableClassImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/LicenseableClassImpl.java new file mode 100644 index 00000000..91fe7870 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/lm/LicenseableClassImpl.java @@ -0,0 +1,62 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.lm; + +import java.io.FileNotFoundException; +import java.io.InputStream; + +import org.openecomp.portalsdk.core.lm.LicenseableClass; + +/* + * Please note that this class is not being used; its a dummy stub to have a qualifying bean for the interface. + */ + +public class LicenseableClassImpl implements LicenseableClass { + + public String getApplicationName() { + return ""; + } + + public InputStream getPublicKeystoreAsInputStream() throws FileNotFoundException { + return null; + } + + public String getAlias() { + return ""; + } + + public String getKeyPasswd() { + return ""; + } + + public String getPublicKeystorePassword() { + return ""; + } + + public String getCipherParamPassword() { + return ""; + } + + @SuppressWarnings("rawtypes") + public Class getClassToLicense() { + return this.getClass(); + } +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/model/Result.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/model/Result.java new file mode 100644 index 00000000..21c9c450 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/model/Result.java @@ -0,0 +1,37 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.model; + +public class Result { + private String result; + + public Result(String result) { + this.result = result; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppCatalogController.java new file mode 100644 index 00000000..a799f496 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppCatalogController.java @@ -0,0 +1,124 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +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.transport.AppCatalogPersonalization; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.portal.ecomp.model.AppCatalogItem; +import org.openecomp.portalapp.util.EPUserUtils; + +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class AppCatalogController extends EPRestrictedBaseController { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppCatalogController.class); + + @Autowired + AdminRolesService adminRolesService; + @Autowired + EPAppService appService; + @Autowired + PersUserAppService persUserAppService; + + /** + * RESTful service method to fetch all enabled applications, with details + * about which are accessible to the current user, selected by the current + * user. + * + * @return List of items suitable for display + */ + @RequestMapping(value = { "/portalApi/appCatalog" }, method = RequestMethod.GET, produces = "application/json") + public List getAppCatalog(HttpServletRequest request, HttpServletResponse response) + throws IOException { + EPUser user = EPUserUtils.getUserSession(request); + List appCatalog = null; + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getAppCatalog"); + } else { + if (adminRolesService.isSuperAdmin(user)) + appCatalog = appService.getAdminAppCatalog(user); + else + appCatalog = appService.getUserAppCatalog(user); + EcompPortalUtils.logAndSerializeObject(logger,"/portalApi/getAppCatalog", "GET result =", appCatalog); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Failed in getAppCatalog", e); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + } + return appCatalog; + } + + /** + * RESTful service to accept a user's action made on the application + * catalog. + * + * @param request + * @param selectRequest + * JSON with data including application ID + * @param response + * @return FieldsValidator + * @throws IOException + */ + @RequestMapping(value = { "/portalApi/appCatalog" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putAppCatalogSelection(HttpServletRequest request, + @RequestBody AppCatalogPersonalization persRequest, HttpServletResponse response) throws IOException { + FieldsValidator result = new FieldsValidator(); + EPApp app = appService.getApp(persRequest.getAppId()); + EPUser user = EPUserUtils.getUserSession(request); + try { + if (app == null || user == null) { + EcompPortalUtils.setBadPermissions(user, response, "putAppCatalogSelection"); + } else { + persUserAppService.setPersUserAppValue(user, app, persRequest.getSelect(), persRequest.getPending()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Failed in putAppCatalogSelection", e); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + } + result.httpStatusCode = new Long(HttpServletResponse.SC_OK); + return result; + } + +} \ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppContactUsController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppContactUsController.java new file mode 100644 index 00000000..9b476e05 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppContactUsController.java @@ -0,0 +1,224 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.json.JSONObject; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.ecomp.model.AppCategoryFunctionsItem; +import org.openecomp.portalapp.portal.ecomp.model.AppContactUsItem; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.AppContactUsService; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/portalApi/contactus") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class AppContactUsController extends EPRestrictedBaseController { + + static final String FAILURE = "failure"; + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppContactUsController.class); + + @Autowired + private AppContactUsService contactUsService; + + /** + * Answers a JSON object with three items from the system.properties file: + * user self-help ticket URL, email for feedback, and Portal info link. + * + * @param request + * @return + */ + @RequestMapping(value = "/feedback", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse getPortalDetails(HttpServletRequest request) { + PortalRestResponse portalRestResponse = null; + try { + final String ticketUrl = SystemProperties.getProperty(EPCommonSystemProperties.USH_TICKET_URL); + final String portalInfoUrl = SystemProperties.getProperty(EPCommonSystemProperties.PORTAL_INFO_URL); + final String feedbackEmail = SystemProperties.getProperty(EPCommonSystemProperties.FEEDBACK_EMAIL_ADDRESS); + HashMap map = new HashMap(); + map.put(EPCommonSystemProperties.USH_TICKET_URL, ticketUrl); + map.put(EPCommonSystemProperties.PORTAL_INFO_URL, portalInfoUrl); + map.put(EPCommonSystemProperties.FEEDBACK_EMAIL_ADDRESS, feedbackEmail); + JSONObject j = new JSONObject(map); + String contactUsPortalResponse = j.toString(); + portalRestResponse = new PortalRestResponse(PortalRestStatusEnum.OK, "success", + contactUsPortalResponse); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, FAILURE, e.getMessage()); + } + return portalRestResponse; + } + + /** + * Answers the contents of the contact-us table, extended with the + * application name. + * + * @param request + * @return + */ + @RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getAppContactUsList(HttpServletRequest request) { + PortalRestResponse> portalRestResponse = null; + try { + List contents = contactUsService.getAppContactUs(); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.OK, "success", + contents); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppContactUsList failed", e); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.ERROR, + e.getMessage(), null); + } + return portalRestResponse; + } + + /** + * Answers a list of objects, one per application, extended with available + * data on how to contact that app's organization (possibly none). + * + * @param request + * @return + */ + @RequestMapping(value = "/allapps", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getAppsAndContacts(HttpServletRequest request) { + PortalRestResponse> portalRestResponse = null; + try { + List contents = contactUsService.getAppsAndContacts(); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.OK, "success", + contents); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAllAppsAndContacts failed", e); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.ERROR, + e.getMessage(), null); + } + return portalRestResponse; + } + + /** + * Sorts by category name. + */ + private Comparator appCategoryFunctionsItemComparator = new Comparator() { + @Override + public int compare(AppCategoryFunctionsItem o1, AppCategoryFunctionsItem o2) { + return o1.getCategory().compareTo(o2.getCategory()); + } + }; + + /** + * Answers a list of objects with category-application-function details. Not + * all applications participate in the functional menu. + * + * @param request + * @return + */ + @RequestMapping(value = "/functions", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getAppCategoryFunctions(HttpServletRequest request) { + PortalRestResponse> portalRestResponse = null; + try { + List contents = contactUsService.getAppCategoryFunctions(); + // logger.debug(EELFLoggerDelegate.debugLogger, + // "getAppCategoryFunctions: result list size is " + + // contents.size()); + Collections.sort(contents, appCategoryFunctionsItemComparator); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.OK, + "success", contents); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppCategoryFunctions failed", e); + // TODO build JSON error + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.ERROR, + e.getMessage(), null); + } + return portalRestResponse; + } + + /** + * Accepts a new application's contact us details. + * + * @param contactUs + * @return + */ + @RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse save(@RequestBody AppContactUsItem contactUs) { + + if (contactUs == null || contactUs.getAppName() == null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, FAILURE, + "AppName cannot be null or empty"); + + String saveAppContactUs = FAILURE; + try { + saveAppContactUs = contactUsService.saveAppContactUs(contactUs); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.OK, saveAppContactUs, e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.ERROR, saveAppContactUs, ""); + } + + @RequestMapping(value = "/saveAll", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse save(@RequestBody List contactUsList) { + + String saveAppContactUs = FAILURE; + try { + saveAppContactUs = contactUsService.saveAppContactUs(contactUsList); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.OK, saveAppContactUs, e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.ERROR, saveAppContactUs, ""); + } + + /** + * Deletes the specified application's contact-us details entry from the + * table. + * + * @param id + * @return + */ + @RequestMapping(value = "/delete/{appid}", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse delete(@PathVariable("appid") Long id) { + + String saveAppContactUs = FAILURE; + try { + saveAppContactUs = contactUsService.deleteContactUs(id); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.OK, saveAppContactUs, e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.ERROR, saveAppContactUs, ""); + } + +} \ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsController.java new file mode 100644 index 00000000..7a05d676 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsController.java @@ -0,0 +1,670 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.AdminUserApplications; +import org.openecomp.portalapp.portal.domain.AppIdAndNameTransportModel; +import org.openecomp.portalapp.portal.domain.AppsResponse; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompApp; +import org.openecomp.portalapp.portal.domain.UserRoles; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.EPAppService; +import org.openecomp.portalapp.portal.service.EPLeftMenuService; +import org.openecomp.portalapp.portal.transport.EPAppsManualPreference; +import org.openecomp.portalapp.portal.transport.EPAppsSortPreference; +import org.openecomp.portalapp.portal.transport.EPDeleteAppsManualSortPref; +import org.openecomp.portalapp.portal.transport.EPWidgetsSortPreference; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.LocalRole; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.AppUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@EnableAspectJAutoProxy +@EPAuditLog +public class AppsController extends EPRestrictedBaseController { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsController.class); + + @Autowired + private AdminRolesService adminRolesService; + + @Autowired + private EPAppService appService; + + @Autowired + private EPLeftMenuService leftMenuService; + + /** + * RESTful service method to fetch all Applications available to current + * user + * + * @return + */ + @RequestMapping(value = { "/portalApi/userApps" }, method = RequestMethod.GET, produces = "application/json") + public List getUserApps(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List ecompApps = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + ecompApps = appService.transformAppsToEcompApps(appService.getUserApps(user)); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userApps", "GET result =", ecompApps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserApps failed", e); + } + + return ecompApps; + } + + /** + * RESTful service method to fetch all applications accessible to the + * current user, with personalizations. + * + * @return + */ + @RequestMapping(value = { "/portalApi/persUserApps" }, method = RequestMethod.GET, produces = "application/json") + public List getPersUserApps(HttpServletRequest request, HttpServletResponse response) throws IOException { + EPUser user = EPUserUtils.getUserSession(request); + List ecompApps = null; + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getPersUserApps"); + } else { + List apps = null; + if (adminRolesService.isSuperAdmin(user)) + apps = appService.getPersAdminApps(user); + else + apps = appService.getPersUserApps(user); + ecompApps = appService.transformAppsToEcompApps(apps); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userPersApps", "GET result =", ecompApps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getPersUserApps failed", e); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + } + return ecompApps; + } + + /** + * RESTful service method to fetch applications for which the current user + * is an Administrator + * + * @return + */ + @RequestMapping(value = { "/portalApi/adminApps" }, method = RequestMethod.GET, produces = "application/json") + public List getAdminApps(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List adminApps = null; + + try { + if (!adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getAdminApps"); + } else { + adminApps = appService.getAdminApps(user); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminApps", "GET result =", adminApps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAdminApps failed", e); + } + + return adminApps; + } + + /** + * RESTful service method to fetch Applications for user who is super admin + * and/or app admin. + * + * @return + */ + @RequestMapping(value = { + "/portalApi/appsForSuperAdminAndAccountAdmin" }, method = RequestMethod.GET, produces = "application/json") + public List getAppsForSuperAdminAndAccountAdmin(HttpServletRequest request, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List adminApps = null; + + try { + if (!adminRolesService.isSuperAdmin(user) && !adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getAdminApps"); + } else { + adminApps = appService.getAppsForSuperAdminAndAccountAdmin(user); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/appsForSuperAdminAndAccountAdmin", + "GET result =", adminApps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsForSuperAdminAndAccountAdmin failed", e); + } + + return adminApps; + } + + /** + * RESTful service method to fetch left menu items from the user's session. + * + * @return JSON with left menu + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @RequestMapping(value = { "/portalApi/leftmenuItems" }, method = RequestMethod.GET, produces = "application/json") + public String getLeftMenuItems(HttpServletRequest request, HttpServletResponse response) { + String menuList = null; + Set menuSet = (Set) AppUtils.getSession(request) + .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); + + Set roleFunctionSet = (Set) AppUtils.getSession(request) + .getAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME)); + + EPUser user = EPUserUtils.getUserSession(request); + + try { + menuList = leftMenuService.getLeftMenuItems(user, menuSet, roleFunctionSet); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/leftmenuItems", "GET result =", menuList); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getLeftMenuItems failed", e); + } + return menuList; + } + + @RequestMapping(value = { + "/portalApi/userAppsOrderBySortPref" }, method = RequestMethod.GET, produces = "application/json") + public List getUserAppsOrderBySortPref(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List ecompApps = null; + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserAppsOrderBySortPref"); + } else { + String usrSortPref = request.getParameter("mparams"); + if (usrSortPref.equals("")) { + usrSortPref = "N"; + } + switch (usrSortPref) { + case "N": + ecompApps = appService.transformAppsToEcompApps(appService.getAppsOrderByName(user)); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppsOrderBySortPref", "GET result =", + ecompApps); + break; + case "L": + ecompApps = appService.transformAppsToEcompApps(appService.getAppsOrderByLastUsed(user)); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppsOrderBySortPref", "GET result =", + ecompApps); + break; + case "F": + ecompApps = appService.transformAppsToEcompApps(appService.getAppsOrderByMostUsed(user)); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppsOrderBySortPref", "GET result =", + ecompApps); + break; + case "M": + ecompApps = appService.transformAppsToEcompApps(appService.getAppsOrderByManual(user)); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppsOrderBySortPref", "GET result =", + ecompApps); + break; + default: + logger.error(EELFLoggerDelegate.errorLogger, + "getUserAppsOrderBySortPref failed: no match for " + usrSortPref); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserAppsOrderBySortPref failed", e); + } + return ecompApps; + } + + /* + * This method sends the user apps manual sort preference Data to service + * + * @request: HTTP servlet request + * + * @response: HTTP servlet response + */ + @RequestMapping(value = { + "/portalApi/saveUserAppsSortingManual" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putUserAppsSortingManual(HttpServletRequest request, + @RequestBody List epAppsManualPref, HttpServletResponse response) + throws IOException { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = appService.saveAppsSortManual(epAppsManualPref, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserAppsSortingManual failed", e); + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/saveUserAppsSortingManual", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + @RequestMapping(value = { + "/portalApi/saveUserWidgetsSortManual" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putUserWidgetsSortManual(HttpServletRequest request, + @RequestBody List saveManualWidgetSData, HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = appService.saveWidgetsSortManual(saveManualWidgetSData, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserWidgetsSortManual failed", e); + } + // return fieldsValidator; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/putUserWidgetsSortManual", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + @RequestMapping(value = { + "/portalApi/updateWidgetsSortPref" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putUserWidgetsSortPref(HttpServletRequest request, + @RequestBody List delManualWidgetData, HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = appService.deleteUserWidgetSortPref(delManualWidgetData, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserWidgetsSortPref failed", e); + + } + // return fieldsValidator; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/putUserWidgetsSortPref", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + /* + * This method is being called to delete the user app manual sort preference + * record + * + * @request: HTTP servlet request + * + * @response: HTTP servlet response + */ + @RequestMapping(value = { + "/portalApi/UpdateUserAppsSortManual" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator deleteUserAppSortManual(HttpServletRequest request, + @RequestBody EPDeleteAppsManualSortPref delManualAppData, HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = appService.deleteUserAppSortManual(delManualAppData, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteUserAppSortManual failed", e); + + } + // return fieldsValidator; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/deleteUserAppSortManual", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + @RequestMapping(value = { + "/portalApi/saveUserAppsSortingPreference" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putUserAppsSortingPreference(HttpServletRequest request, + @RequestBody EPAppsSortPreference userAppsValue, HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = appService.saveAppsSortPreference(userAppsValue, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserAppsSortingPreference failed", e); + + } + + // return fieldsValidator; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/putUserAppsSortingPreference", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + @RequestMapping(value = { + "/portalApi/userAppsSortTypePreference" }, method = RequestMethod.GET, produces = "application/String") + public String getUserAppsSortTypePreference(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + String userSortPreference = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "userAppsSortTypePreference"); + } else { + userSortPreference = appService.getUserAppsSortTypePreference(user); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppsSortTypePreference", "GET result =", + userSortPreference); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserAppsSortTypePreference failed", e); + } + + return userSortPreference; + } + + /** + * RESTful service method to fetch Application Administrators to Super + * Administrator user. Attention: Users which have Super Administrator roles + * only are not included! + * + * @return + */ + @RequestMapping(value = { "/portalApi/accountAdmins" }, method = RequestMethod.GET, produces = "application/json") + public List getAppsAdministrators(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List admins = null; + try { + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getAppsAdministrators"); + } else { + admins = appService.getAppsAdmins(); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/accountAdmins", "GET result =", admins); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsAdministrators failed", e); + } + + return admins; + } + + @RequestMapping(value = { "/portalApi/availableApps" }, method = RequestMethod.GET, produces = "application/json") + public List getApps(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List apps = null; + try { + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getApps"); + } else { + apps = appService.getAllApps(false); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/availableApps", "GET result =", apps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getApps failed", e); + } + + return apps; + } + + /** + * Gets all apps, both active and inactive; i.e., all on-boarded apps, + * regardless of enabled status. + * + * @param request + * @param response + * @return List of applications + */ + // This API returns + @RequestMapping(value = { + "/portalApi/allAvailableApps" }, method = RequestMethod.GET, produces = "application/json") + public List getAllApps(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List apps = null; + try { + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getApps"); + } else { + apps = appService.getAllApps(true); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/availableApps", "GET result =", apps); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAllApps failed", e); + } + + return apps; + } + + /** + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/appsFullList" }, method = RequestMethod.GET, produces = "application/json") + public List getAppsFullList(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List ecompApps = null; + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getAppsFullList"); + } else { + ecompApps = appService.getEcompAppAppsFullList(); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/appsFullList", "GET result =", ecompApps); + } + return ecompApps; + } + + /** + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/userProfile" }, method = RequestMethod.GET, produces = "application/json") + public UserRoles getUserProfile(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + UserRoles userAndRoles = null; + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserProfile"); + } else { + userAndRoles = appService.getUserProfileNormalized(user); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserProfile failed", e); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userProfile", "getUserProfile result =", + userAndRoles); + return userAndRoles; + } + + /** + * + * @param request + * @param appId + * @return + */ + @RequestMapping(value = { "/portalApi/appRoles/{appId}" }, method = { + RequestMethod.GET }, produces = "application/json") + public List getAppRoles(HttpServletRequest request, @PathVariable("appId") Long appId) { + List roleList = null; + try { + roleList = appService.getAppRoles(appId); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/appRoles/" + appId, "GET result =", roleList); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppRoles failed", e); + } + + return roleList; + } + + /** + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.GET, produces = "application/json") + public List getOnboardingApps(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List onboardingApps = null; + try { + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getOnboardingApps"); + } else { + onboardingApps = appService.getOnboardingApps(); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/onboardingApps", "GET result =", + "onboardingApps of size " + onboardingApps.size()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getOnboardingApps failed", e); + } + + return onboardingApps; + } + + /** + * + * @param request + * @param modifiedOnboardingApp + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.PUT, produces = "application/json") + public FieldsValidator putOnboardingApp(HttpServletRequest request, + @RequestBody OnboardingApp modifiedOnboardingApp, HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "putOnboardingApp"); + } else { + modifiedOnboardingApp.normalize(); + fieldsValidator = appService.modifyOnboardingApp(modifiedOnboardingApp, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putOnboardingApps failed", e); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/onboardingApps", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + /** + * + * @param request + * @param newOnboardingApp + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.POST, produces = "application/json") + public FieldsValidator postOnboardingApp(HttpServletRequest request, @RequestBody OnboardingApp newOnboardingApp, + HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "postOnboardingApps"); + } else { + newOnboardingApp.normalize(); + fieldsValidator = appService.addOnboardingApp(newOnboardingApp, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "postOnboardingApp failed", e); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/onboardingApps", "POST result =", + response.getStatus()); + return fieldsValidator; + } + + /** + * REST endpoint to process a request to delete an on-boarded application. + * + * @param request + * @param appId + * @param response + * @return + */ + @RequestMapping(value = { "/portalApi/onboardingApps/{appId}" }, method = { + RequestMethod.DELETE }, produces = "application/json") + public FieldsValidator deleteOnboardingApp(HttpServletRequest request, @PathVariable("appId") Long appId, + HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "deleteOnboardingApps"); + } else { + fieldsValidator = appService.deleteOnboardingApp(user, appId); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteOnboardingApp failed", e); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/onboardingApps" + appId, "DELETE result =", + response.getStatus()); + return fieldsValidator; + } + + /** + * Gets the application thumbnail image; sets status 404 if none exists. + * + * @param request + * HttpServletRequest + * @param appId + * Application ID + * @return Bytes with the app thumbnail image; null if not available. + */ + @RequestMapping(value = { "/portalApi/appThumbnail/{appId}" }, method = { RequestMethod.GET }) + public HttpEntity getAppThumbnail(HttpServletRequest request, @PathVariable("appId") Long appId, + HttpServletResponse response) { + EPApp app = appService.getApp(appId); + if (app == null || app.getImageUrl() == null || app.getThumbnail() == null || app.getThumbnail().length == 0) { + logger.debug(EELFLoggerDelegate.debugLogger, + "getAppThumbnail: no app and/or no thumbnail for app " + appId); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + return null; + } + String url = app.getImageUrl(); + int indexOfDot = url.lastIndexOf('.'); + String urlSuffix = indexOfDot > 0 ? url.substring(indexOfDot + 1).toLowerCase() : "UNK"; + // Default to JPG if no usable suffix. + MediaType mediaType = MediaType.IMAGE_JPEG; + if ("png".equals(urlSuffix)) + mediaType = MediaType.IMAGE_PNG; + else if ("gif".equals(urlSuffix)) + mediaType = MediaType.IMAGE_GIF; + HttpHeaders header = new HttpHeaders(); + header.setContentType(mediaType); + header.setContentLength(app.getThumbnail().length); + return new HttpEntity(app.getThumbnail(), header); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequest.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequest.java new file mode 100644 index 00000000..fa49d5b2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequest.java @@ -0,0 +1,374 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.portal.domain.EPApp; +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.logging.aop.EPAuditLog; +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.service.UserService; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + +/** + * Processes requests from external systems (i.e., not the front-end web UI). + * First use case is ECOMP Controller, which has to create an admin and onboard + * itself upon launch of a fresh Portal. + * + * Listens on the "auxapi" path prefix. Provides alternate implementations of + * methods in several existing controllers because an EPUser object is not + * available in the session for these requests. + * + * Checks credentials sent via HTTP Basic Authentication. The Portal's basic + * HTTP authentication system requires that the user names and endpoints are + * registered together. + */ +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class AppsControllerExternalRequest implements BasicAuthenticationController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsControllerExternalRequest.class); + + private static final String ONBOARD_APP = "/onboardApp"; + + // Where is this used? + public boolean isAuxRESTfulCall() { + return true; + } + + /** + * For testing whether a user is a superadmin. + */ + @Autowired + private AdminRolesService adminRolesService; + + /** + * For onboarding or updating an app + */ + @Autowired + private EPAppService appService; + + /** + * For promoting a user to Portal admin + */ + @Autowired + private PortalAdminService portalAdminService; + + /** + * For creating a new user + */ + @Autowired + private UserService userService; + + /** + * Creates a new user as a Portal administrator. + * + *
+	 { 
+		"loginId" : "abc123",
+		"loginPwd": "",
+		"email":"ecomp@controller" 
+	 }
+	 * 
+ * + * @param request + * HttpServletRequest + * @param epUser + * User details; the email and orgUserId fields are mandatory + * @param response + * HttpServletResponse + * @return PortalRestResponse with success or failure + */ + @ApiOperation(value = "Creates a new user as a Portal administrator.", response = PortalRestResponse.class) + @RequestMapping(value = "/portalAdmin", method = RequestMethod.POST, produces = "application/json") + @ResponseBody + public PortalRestResponse postPortalAdmin(HttpServletRequest request, HttpServletResponse response, + @RequestBody EPUser epUser) { + EcompPortalUtils.logAndSerializeObject(logger, "postPortalAdmin", "request", epUser); + PortalRestResponse portalResponse = new PortalRestResponse<>(); + + // Check mandatory fields. + if (epUser.getEmail() == null || epUser.getEmail().trim().length() == 0 // + || epUser.getLoginId() == null || epUser.getLoginId().trim().length() == 0 // + || epUser.getLoginPwd() == null) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("Missing required field: email, loginId, or loginPwd"); + return portalResponse; + } + + try { + // Check for existing user; create if not found. + List userList = userService.getUserByUserId(epUser.getOrgUserId()); + if (userList == null || userList.size() == 0) { + // Create user with first, last names etc.; do check for + // duplicates. + String userCreateResult = userService.saveNewUser(epUser, "Yes"); + if (!"success".equals(userCreateResult)) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(userCreateResult); + return portalResponse; + } + } + + // Check for Portal admin status; promote if not. + if (adminRolesService.isSuperAdmin(epUser)) { + portalResponse.setStatus(PortalRestStatusEnum.OK); + } else { + FieldsValidator fv = portalAdminService.createPortalAdmin(epUser.getOrgUserId()); + if (fv.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + portalResponse.setStatus(PortalRestStatusEnum.OK); + } else { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(fv.toString()); + } + } + } catch (Exception ex) { + // Uncaught exceptions yield 404 and an empty error page + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(ex.toString()); + } + + EcompPortalUtils.logAndSerializeObject(logger, "postPortalAdmin", "response", portalResponse); + return portalResponse; + } + + /** + * Gets the specified application that is on-boarded in Portal. + * + * @param request + * HttpServletRequest + * @param appId + * Application ID to get + * @param response + * httpServletResponse + * @return OnboardingApp objects + */ + @ApiOperation(value = "Gets the specified application that is on-boarded in Portal.", response = OnboardingApp.class) + @RequestMapping(value = { ONBOARD_APP + "/{appId}" }, method = RequestMethod.GET, produces = "application/json") + @ResponseBody + public OnboardingApp getOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, + @PathVariable("appId") Long appId) { + EPApp epApp = appService.getApp(appId); + OnboardingApp obApp = new OnboardingApp(); + appService.createOnboardingFromApp(epApp, obApp); + EcompPortalUtils.logAndSerializeObject(logger, "getOnboardAppExternal", "response", obApp); + return obApp; + } + + /** + * Adds a new application to Portal. The My Logins App Owner in the request + * must be the organization user ID of a person who is a Portal + * administrator. + * + *
+	 * { 
+		"myLoginsAppOwner" : "abc123",
+		"name": "dashboard",
+		"url": "http://k8s/something",
+		"restUrl" : "http://aic.att.com",
+		"restrictedApp" : true,
+		"isOpen" : true,
+		"isEnabled": false
+		}
+	 * 
+ * + * @param request + * HttpServletRequest + * @param response + * httpServletResponse + * @param newOnboardApp + * Message with details about the app to add + * @return PortalRestResponse + */ + @ApiOperation(value = "Adds a new application to Portal.", response = PortalRestResponse.class) + @RequestMapping(value = { ONBOARD_APP }, method = RequestMethod.POST, produces = "application/json") + @ResponseBody + public PortalRestResponse postOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, + @RequestBody OnboardingApp newOnboardApp) { + EcompPortalUtils.logAndSerializeObject(logger, "postOnboardAppExternal", "request", newOnboardApp); + PortalRestResponse portalResponse = new PortalRestResponse<>(); + + // Validate fields + if (newOnboardApp.id != null) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("Unexpected field: id"); + return portalResponse; + } + if (newOnboardApp.name == null || newOnboardApp.name.trim().length() == 0 // + || newOnboardApp.url == null || newOnboardApp.url.trim().length() == 0 // + || newOnboardApp.restUrl == null || newOnboardApp.restUrl.trim().length() == 0 + || newOnboardApp.myLoginsAppOwner == null || newOnboardApp.myLoginsAppOwner.trim().length() == 0 + || newOnboardApp.restrictedApp == null // + || newOnboardApp.isOpen == null // + || newOnboardApp.isEnabled == null) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage( + "Missing required field: name, url, restUrl, restrictedApp, isOpen, isEnabled, myLoginsAppOwner"); + return portalResponse; + } + + try { + List userList = userService.getUserByUserId(newOnboardApp.myLoginsAppOwner); + if (userList == null || userList.size() != 1) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("Failed to find user: " + newOnboardApp.myLoginsAppOwner); + return portalResponse; + } + + EPUser epUser = userList.get(0); + // Check for Portal admin status + if (! adminRolesService.isSuperAdmin(epUser)) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("User lacks Portal admin role: " + epUser.getLoginId()); + return portalResponse; + } + + newOnboardApp.normalize(); + FieldsValidator fv = appService.addOnboardingApp(newOnboardApp, epUser); + if (fv.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + portalResponse.setStatus(PortalRestStatusEnum.OK); + } else { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(fv.toString()); + } + } catch (Exception ex) { + // Uncaught exceptions yield 404 and an empty error page + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(ex.toString()); + } + EcompPortalUtils.logAndSerializeObject(logger, "postOnboardAppExternal", "response", portalResponse); + return portalResponse; + } + + /** + * Updates information about an on-boarded application in Portal. The My + * Logins App Owner in the request must be the organization user ID of a + * person who is a Portal administrator. + *
+	   { 
+		"id" : 123,
+		"myLoginsAppOwner" : "abc123",
+		"name": "dashboard",
+		"url": "http://k8s/something",
+		"restUrl" : "http://aic.att.com",
+		"restrictedApp" : true,
+		"isOpen" : true,
+		"isEnabled": false
+		}
+		
+ * @param request + * HttpServletRequest + * @param response + * httpServletResponse + * @param appId + * application id + * @param oldOnboardApp + * Message with details about the app to add + * @return PortalRestResponse + */ + @ApiOperation(value = "Updates information about an on-boarded application in Portal.", response = PortalRestResponse.class) + @RequestMapping(value = { ONBOARD_APP + "/{appId}" }, method = RequestMethod.PUT, produces = "application/json") + @ResponseBody + public PortalRestResponse putOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, + @PathVariable("appId") Long appId, @RequestBody OnboardingApp oldOnboardApp) { + EcompPortalUtils.logAndSerializeObject(logger, "putOnboardAppExternal", "request", oldOnboardApp); + PortalRestResponse portalResponse = new PortalRestResponse<>(); + // Validate fields. + if (oldOnboardApp.id == null || !appId.equals(oldOnboardApp.id)) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("Unexpected value for field: id"); + return portalResponse; + } + if (oldOnboardApp.name == null || oldOnboardApp.name.trim().length() == 0 // + || oldOnboardApp.url == null || oldOnboardApp.url.trim().length() == 0 // + || oldOnboardApp.restUrl == null || oldOnboardApp.restUrl.trim().length() == 0 + || oldOnboardApp.myLoginsAppOwner == null || oldOnboardApp.myLoginsAppOwner.trim().length() == 0 + || oldOnboardApp.restrictedApp == null // + || oldOnboardApp.isOpen == null // + || oldOnboardApp.isEnabled == null) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage( + "Missing required field: name, url, restUrl, restrictedApp, isOpen, isEnabled, myLoginsAppOwner"); + return portalResponse; + } + + try { + List userList = userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner); + if (userList == null || userList.size() != 1) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("Failed to find user: " + oldOnboardApp.myLoginsAppOwner); + return portalResponse; + } + + EPUser epUser = userList.get(0); + // Check for Portal admin status + if (! adminRolesService.isSuperAdmin(epUser)) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage("User lacks Portal admin role: " + epUser.getLoginId()); + return portalResponse; + } + + oldOnboardApp.normalize(); + FieldsValidator fv = appService.modifyOnboardingApp(oldOnboardApp, epUser); + if (fv.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + portalResponse.setStatus(PortalRestStatusEnum.OK); + } else { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(fv.toString()); + } + } catch (Exception ex) { + // Uncaught exceptions yield 404 and an empty error page + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(ex.toString()); + } + EcompPortalUtils.logAndSerializeObject(logger, "putOnboardAppExternal", "response", portalResponse); + return portalResponse; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AuditLogController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AuditLogController.java new file mode 100644 index 00000000..705c9008 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/AuditLogController.java @@ -0,0 +1,106 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.domain.AuditLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.AuditService; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.util.EPUserUtils; + +@RestController +@RequestMapping("/portalApi/auditLog") +public class AuditLogController extends EPRestrictedBaseController { + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardController.class); + + @Autowired + private AuditService auditService; + + /** + * Store audit log of the specified access type. + * + * @param request + * @param affectedAppId + * @param type + * @param comment + */ + @RequestMapping(value = "/store", method = RequestMethod.GET, produces = "application/json") + public void auditLog(HttpServletRequest request, @RequestParam String affectedAppId, @RequestParam String type, + @RequestParam String comment) { + logger.debug(EELFLoggerDelegate.debugLogger, "auditLog: appId {}, type {], comment {}", + affectedAppId, type, comment); + String cd_type = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + /* Check type of Activity CD */ + if (type.equals("app")) { + cd_type = AuditLog.CD_ACTIVITY_APP_ACCESS; + } else if (type.equals("tab")) { + cd_type = AuditLog.CD_ACTIVITY_TAB_ACCESS; + } else if (type.equals("functional")) { + cd_type = AuditLog.CD_ACTIVITY_FUNCTIONAL_ACCESS; + } else if (type.equals("leftMenu")) { + cd_type = AuditLog.CD_ACTIVITY_LEFT_MENU_ACCESS; + } else { + logger.error(EELFLoggerDelegate.errorLogger, "Storing auditLog failed! Activity CD type is not correct."); + } + /* Store the audit log only if it contains valid Activity CD */ + if (cd_type != null) { + AuditLog auditLog = new AuditLog(); + auditLog.setActivityCode(cd_type); + /* + * Check affectedAppId and comment and see if these two values are + * valid + */ + if (comment != null && !comment.equals("") && !comment.equals("undefined")) + auditLog.setComments(comment); + if (affectedAppId != null && !affectedAppId.equals("") && !affectedAppId.equals("undefined")) + auditLog.setAffectedRecordId(affectedAppId); + long userId = EPUserUtils.getUserId(request); + auditLog.setUserId(userId); + auditService.logActivity(auditLog, null); + + // Log file + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage("AuditLogController.auditLog", + cd_type, user.getOrgUserId(), affectedAppId, comment)); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "auditLog failed", e); + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BEPropertyReaderController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BEPropertyReaderController.java new file mode 100644 index 00000000..a7b3f1a1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BEPropertyReaderController.java @@ -0,0 +1,46 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.controller.FusionBaseController; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.BEProperty; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; + +@RestController +@RequestMapping("/portalApi/properties") +public class BEPropertyReaderController extends FusionBaseController{ + @RequestMapping(value = "/readProperty", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse readProperty(HttpServletRequest request, @RequestParam String key) { + try { + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", new BEProperty(key, SystemProperties.getProperty(key))); + } catch (Exception e) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthAccountController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthAccountController.java new file mode 100644 index 00000000..f23054bd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthAccountController.java @@ -0,0 +1,141 @@ +package org.openecomp.portalapp.portal.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPEndpoint; +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.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.BasicAuthAccountService; +import org.openecomp.portalapp.util.EPUserUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@SuppressWarnings("unchecked") +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class BasicAuthAccountController extends EPRestrictedBaseController{ + + @Autowired + private BasicAuthAccountService basicAuthAccountService; + + @Autowired + private AdminRolesService adminRolesService; + + /** + * Saves Basic Authentication account for external systems + * @param BasicAuthCredentials + * @return Id of the newly created account + */ + + @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.POST) + public PortalRestResponse createBasicAuthAccount(HttpServletRequest request, HttpServletResponse response, + @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { + + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)){ + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "Authorization Required", "Admin Only Operation! "); + } + + if(newBasicAuthAccount == null){ + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "newBasicAuthAccount cannot be null or empty"); + } + long accountId = basicAuthAccountService.saveBasicAuthAccount(newBasicAuthAccount); + + List endpointIdList = new ArrayList<>(); + try { + for(EPEndpoint ep: newBasicAuthAccount.getEndpoints()){ + endpointIdList.add(basicAuthAccountService.saveEndpoints(ep)); + } + for(Long endpointId: endpointIdList){ + basicAuthAccountService.saveEndpointAccount(accountId, endpointId); + } + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + /** + * Returns list of all BasicAuthCredentials in the system + * @return List + */ + + @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.GET) + public PortalRestResponse> getBasicAuthAccount(HttpServletRequest request, HttpServletResponse response) + throws Exception { + + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)){ + return new PortalRestResponse>(PortalRestStatusEnum.ERROR, "UnAuthorized! Admin Only Operation", new ArrayList<>()); + } + + return new PortalRestResponse>(PortalRestStatusEnum.OK, "Success", basicAuthAccountService.getAccountData()); + } + + /** + * Updates an existing BasicAuthCredentials account + */ + + @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.PUT) + public PortalRestResponse updateAccount(HttpServletRequest request, HttpServletResponse response, + @PathVariable("accountId") long accountId, @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { + + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)){ + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "Authorization Required", "Admin Only Operation! "); + } + + if (newBasicAuthAccount == null) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "BasicAuthCredentials cannot be null or empty"); + } + try { + basicAuthAccountService.updateBasicAuthAccount(accountId, newBasicAuthAccount); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + /** + * deletes an existing BasicAuthCredentials account + */ + + @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.DELETE) + public PortalRestResponse deleteAccount(HttpServletRequest request, HttpServletResponse response, + @PathVariable("accountId") long accountId) throws Exception { + + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)){ + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "Authorization Required", "Admin Only Operation! "); + } + + + try { + basicAuthAccountService.deleteEndpointAccout(accountId); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthenticationController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthenticationController.java new file mode 100644 index 00000000..d9bdf3dc --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/BasicAuthenticationController.java @@ -0,0 +1,28 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +/** + * Marker interface to indicate that requests to this controller present HTTP + * Basic Authentication credentials. + */ +public interface BasicAuthenticationController { + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java new file mode 100644 index 00000000..68e32a16 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java @@ -0,0 +1,79 @@ +/* + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import javax.servlet.http.HttpServletRequest; +import org.openecomp.portalapp.portal.controller.DashboardController.WidgetCategory; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.service.DashboardSearchService; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class CommonWidgetController implements BasicAuthenticationController{ + + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CommonWidgetController.class); + @Autowired + private DashboardSearchService searchService; + + /** + * Validates the resource type parameter. + * + * @param resourceType + * @return True if known in the enum WidgetCategory, else false. + */ + private boolean isValidResourceType(String resourceType) { + if (resourceType == null) + return false; + for (WidgetCategory wc : WidgetCategory.values()) + if (wc.name().equals(resourceType)) + return true; + return false; + } + + /** + * Gets all widgets of the specified resource type. + * + * @param request + * @param resourceType + * Request parameter. + * @return Rest response wrapped around a CommonWidgetMeta object. + */ + @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse getWidgetData(HttpServletRequest request, + @RequestParam String resourceType) { + if (!isValidResourceType(resourceType)){ + logger.debug(EELFLoggerDelegate.debugLogger, "Unexpected resource type {}", resourceType); + return new PortalRestResponse(PortalRestStatusEnum.ERROR, + "Unexpected resource type " + resourceType, null); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.getWidgetData(resourceType)); + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ConsulClientController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ConsulClientController.java new file mode 100644 index 00000000..8db94849 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ConsulClientController.java @@ -0,0 +1,90 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.service.ConsulHealthService; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import com.orbitz.consul.ConsulException; +import com.orbitz.consul.model.health.ServiceHealth; + +import io.searchbox.client.config.exception.NoServerConfiguredException; + +@RestController +@RequestMapping("/portalApi/consul") +public class ConsulClientController extends EPRestrictedBaseController { + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ConsulClientController.class); + + @Autowired + private ConsulHealthService consulHealthService; + //Get location of a healthy node running our service + @RequestMapping(value = { "/service/{service}" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse getServiceLocation(HttpServletRequest request, HttpServletResponse response, @PathVariable("service") String service) { + + try{ + return new PortalRestResponse(PortalRestStatusEnum.OK, "Success!", consulHealthService.getServiceLocation(service)); + } + catch(NoServerConfiguredException e){ + logger.error(logger.errorLogger, "No healthy service exception!"); + return new PortalRestResponse(PortalRestStatusEnum.WARN, "Warning!", "No healthy service exception!"); + } + catch(ConsulException e){ + logger.error(logger.errorLogger, "Couldn't connect ot consul - Is consul running?"); + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "Error!", "Couldn't connect ot consul - Is consul running?"); + } + } + + @RequestMapping(value = { "/service/healthy/{service}" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getAllHealthyNodes(HttpServletRequest request, HttpServletResponse response, @PathVariable("service") String service) { + try{ + return new PortalRestResponse>(PortalRestStatusEnum.OK, "Success!", consulHealthService.getAllHealthyNodes(service)); + } + catch(ConsulException e){ + logger.error(logger.errorLogger, "Couldn't connect to consul - shouldn't break anything."); + return new PortalRestResponse>(PortalRestStatusEnum.ERROR,"Error!", new ArrayList<>()); + } + } + + @RequestMapping(value = { "/service/all/{service}" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getAllNodes(HttpServletRequest request, HttpServletResponse response, @PathVariable("service") String service) { + try{ + return new PortalRestResponse>(PortalRestStatusEnum.OK, "Success!", consulHealthService.getAllNodes(service)); + } + catch(ConsulException e){ + logger.error(logger.errorLogger, "Couldn't connect to consul - shouldn't break anything."); + return new PortalRestResponse>(PortalRestStatusEnum.ERROR,"Error!", new ArrayList<>()); + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardController.java new file mode 100644 index 00000000..290a5ffc --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardController.java @@ -0,0 +1,385 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompAuditLog; +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.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +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.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.domain.AuditLog; +import org.openecomp.portalsdk.core.domain.support.CollaborateList; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.AuditService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Controller supplies data to Angular services on the dashboard page. + */ +@Configuration +@RestController +@RequestMapping("/portalApi/dashboard") +public class DashboardController extends EPRestrictedBaseController { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardController.class); + + @Autowired + private DashboardSearchService searchService; + @Autowired + private AuditService auditService; + + public enum WidgetCategory { + EVENTS, NEWS, IMPORTANTRESOURCES; + } + + /** + * Validates the resource type parameter. + * + * @param resourceType + * @return True if known in the enum WidgetCategory, else false. + */ + private boolean isValidResourceType(String resourceType) { + if (resourceType == null) + return false; + for (WidgetCategory wc : WidgetCategory.values()) + if (wc.name().equals(resourceType)) + return true; + return false; + } + + /** + * Gets all widgets of the specified resource type. + * In iteration 41 (when widget will utilized service onboarding), this method can be removed, instead we will use CommonWidgetController.java (basic auth based) + * + * @param request + * @param resourceType + * Request parameter. + * @return Rest response wrapped around a CommonWidgetMeta object. + */ + @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse getWidgetData(HttpServletRequest request, + @RequestParam String resourceType) { + if (!isValidResourceType(resourceType)) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, + "Unexpected resource type " + resourceType, null); + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.getWidgetData(resourceType)); + } + + + /** + * Saves a batch of events, news or resources. + * + * @param commonWidgetMeta + * read from POST body. + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) { + logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); + if (commonWidgetMeta.getCategory() == null || commonWidgetMeta.getCategory().trim().equals("")) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "ERROR", + "Category cannot be null or empty"); + if (!isValidResourceType(commonWidgetMeta.getCategory())) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, + "Unexpected resource type " + commonWidgetMeta.getCategory(), null); + // validate dates + for (CommonWidget cw : commonWidgetMeta.getItems()) { + String err = validateCommonWidget(cw); + if (err != null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, err, null); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.saveWidgetDataBulk(commonWidgetMeta)); + } + + /** + * Saves one: event, news or resource + * + * @param commonWidget + * read from POST body + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse saveWidgetData(@RequestBody CommonWidget commonWidget) { + logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); + if (commonWidget.getCategory() == null || commonWidget.getCategory().trim().equals("")) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "ERROR", + "Category cannot be null or empty"); + String err = validateCommonWidget(commonWidget); + if (err != null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, err, null); + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.saveWidgetData(commonWidget)); + } + + /** + * Used by the validate function + */ + private final SimpleDateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Validates the content of a common widget. + * + * @param cw + * @return null on success; an error message if validation fails. + * @throws Exception + */ + private String validateCommonWidget(CommonWidget cw) { + if (!isValidResourceType(cw.getCategory())) + return "Invalid category: " + cw.getCategory(); + if (cw.getTitle() == null || cw.getTitle().trim().length() == 0) + return "Title is missing"; + if (cw.getHref() == null || cw.getHref().trim().length() == 0) + return "HREF is missing"; + if (!cw.getHref().toLowerCase().startsWith("http")) + return "HREF does not start with http"; + if (cw.getSortOrder() == null) + return "Sort order is null"; + if (WidgetCategory.EVENTS.name().equals(cw.getCategory())) { + if (cw.getEventDate() == null || cw.getEventDate().trim().length() == 0) + return "Date is missing"; + try { + yearMonthDayFormat.setLenient(false); + Date date = yearMonthDayFormat.parse(cw.getEventDate()); + if (date == null) + return "Failed to parse date " + cw.getEventDate(); + } catch (ParseException ex) { + return ex.toString(); + } + } + return null; + } + + /** + * Deletes one: event, news or resource + * + * @param commonWidget + * read from POST body + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse deleteWidgetData(@RequestBody CommonWidget commonWidget) { + logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget); + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.deleteWidgetData(commonWidget)); + } + + /** + * Searches all portal for the input string. + * + * @param request + * @param searchString + * @return Rest response wrapped around a Map of String to List of Search + * Result Item. + */ + @EPAuditLog + @RequestMapping(value = "/search", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse>> searchPortal(HttpServletRequest request, + @RequestParam String searchString) { + + if (searchString != null) + searchString = searchString.trim(); + EPUser user = EPUserUtils.getUserSession(request); + try { + if (user == null) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, + "searchPortal: User object is null? - check logs", + new HashMap>()); + } else if (searchString == null || searchString.length() == 0) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "searchPortal: String string is null", + new HashMap>()); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "searchPortal: user {}, search string '{}'", + user.getLoginId(), searchString); + Map> results = searchService.searchResults(user.getLoginId(), + searchString); + /*Audit log the search*/ + AuditLog auditLog = new AuditLog(); + auditLog.setUserId(user.getId()); + auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_SEARCH); + auditLog.setComments(searchString); + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + auditService.logActivity(auditLog, null); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + EcompPortalUtils.calculateDateTimeDifferenceForLog(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP)); + logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage("DashboardController.PortalRestResponse", + EcompAuditLog.CD_ACTIVITY_SEARCH, user.getOrgUserId(), null, searchString)); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + MDC.remove(SystemProperties.MDC_TIMER); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "searchPortal failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", + new HashMap>()); + } + } + + /** + * Gets all active users. + * + * TODO: should only the superuser be allowed to use this API? + * + * @param request + * @return Rest response wrapped around a list of String + */ + @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json") + public List getActiveUsers(HttpServletRequest request) { + List activeUsers = null; + List onlineUsers = new ArrayList<>(); + try { + EPUser user = EPUserUtils.getUserSession(request); + String userId = user.getOrgUserId(); + + activeUsers = searchService.getRelatedUsers(userId); + HashSet usersSet = CollaborateList.getInstance().getAllUserName(); + for (String users : activeUsers) { + if (usersSet.contains(users)) { + onlineUsers.add(users); + } + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getActiveUsers failed", e); + } + return onlineUsers; + } + + /** + * Gets the refresh interval and duration of a cycle of continuous refreshing for the online users side panel, both in milliseconds. + * + * @param request + * @return Rest response wrapped around a number that is the number of milliseconds. + */ + @RequestMapping(value = "/onlineUserUpdateRate", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getOnlineUserUpdateRate(HttpServletRequest request) { + try { + String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.ONLINE_USER_UPDATE_RATE); + String updateDuration = SystemProperties.getProperty(EPCommonSystemProperties.ONLINE_USER_UPDATE_DURATION); + Integer rateInMiliSec = Integer.valueOf(updateRate)*1000; + Integer durationInMiliSec = Integer.valueOf(updateDuration)*1000; + Map results = new HashMap(); + results.put("onlineUserUpdateRate", String.valueOf(rateInMiliSec)); + results.put("onlineUserUpdateDuration", String.valueOf(durationInMiliSec)); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getOnlineUserUpdateRate failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + /** + * Gets the window width threshold for collapsing right menu from system.properties. + * + * @param request + * @return Rest response wrapped around a number that is the window width threshold to collapse right menu. + */ + @RequestMapping(value = "/windowWidthThresholdRightMenu", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getWindowWidthThresholdForRightMenu(HttpServletRequest request) { + try { + String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_RIGHT_MENU); + Integer windowWidth = Integer.valueOf(windowWidthString); + Map results = new HashMap(); + results.put("windowWidth", String.valueOf(windowWidth)); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getWindowWidthThresholdForRightMenu failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + + /** + * Gets the window width threshold for collapsing left menu from system.properties. + * + * @param request + * @return Rest response wrapped around a number that is the window width threshold to collapse the left menu. + */ + @RequestMapping(value = "/windowWidthThresholdLeftMenu", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getWindowWidthThresholdForLeftMenu(HttpServletRequest request) { + try { + String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_LEFT_MENU); + Integer windowWidth = Integer.valueOf(windowWidthString); + Map results = new HashMap(); + results.put("windowWidth", String.valueOf(windowWidth)); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getWindowWidthThresholdForLeftMenu failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + /** + * Gets only those users that are 'related' to the currently logged-in user. + * + * @param request + * @return Rest response wrapped around a List of String + */ + @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> activeUsers(HttpServletRequest request) { + EPUser user = EPUserUtils.getUserSession(request); + try { + if (user == null) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "User object is null? - check logs", + new ArrayList<>()); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "activeUsers: searching for user {}", user.getLoginId()); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", + searchService.getRelatedUsers(user.getLoginId())); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "activeUsers failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", + new ArrayList<>()); + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java new file mode 100644 index 00000000..fe31066d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java @@ -0,0 +1,243 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +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.service.DashboardSearchService; +import org.openecomp.portalapp.portal.transport.CommonWidget; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.domain.support.CollaborateList; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/portalApi/search") +public class DashboardSearchResultController extends EPRestrictedBaseController { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardSearchResultController.class); + + @Autowired + private DashboardSearchService searchService; + + /** + * Gets all widgets by type: NEW or RESOURCE + * + * @param request + * @param resourceType + * Request parameter. + * @return Rest response wrapped around a CommonWidgetMeta object. + */ + @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse getWidgetData(HttpServletRequest request, + @RequestParam String resourceType) { + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.getWidgetData(resourceType)); + } + + /** + * Saves all: news and resources + * + * @param commonWidgetMeta + * read from POST body. + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) { + logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); + if (commonWidgetMeta.getCategory() == null || commonWidgetMeta.getCategory().trim().equals("")) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "ERROR", + "Category cannot be null or empty"); + // validate dates + for (CommonWidget cw : commonWidgetMeta.getItems()) { + String err = validateCommonWidget(cw); + if (err != null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, err, null); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.saveWidgetDataBulk(commonWidgetMeta)); + } + + /** + * Saves one: news or resource + * + * @param commonWidget + * read from POST body + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse saveWidgetData(@RequestBody CommonWidget commonWidget) { + logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); + if (commonWidget.getCategory() == null || commonWidget.getCategory().trim().equals("")) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "ERROR", + "Cateogry cannot be null or empty"); + String err = validateCommonWidget(commonWidget); + if (err != null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, err, null); + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.saveWidgetData(commonWidget)); + } + + /** + * Used by the validate function + */ + private final SimpleDateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Validates the content of a common widget. + * + * @param cw + * @return null on success; an error message if validation fails. + * @throws Exception + */ + private String validateCommonWidget(CommonWidget cw) { + try { + if (cw.getEventDate() != null && cw.getEventDate().trim().length() > 0) + yearMonthDayFormat.parse(cw.getEventDate()); + } catch (ParseException ex) { + return ex.toString(); + } + return null; + } + + /** + * Deletes one: news or resource + * + * @param commonWidget + * read from POST body + * @return Rest response wrapped around a String; e.g., "success" or "ERROR" + */ + @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse deleteWidgetData(@RequestBody CommonWidget commonWidget) { + logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget); + return new PortalRestResponse(PortalRestStatusEnum.OK, "success", + searchService.deleteWidgetData(commonWidget)); + } + + /** + * Searches all portal for the input string. + * + * @param request + * @param searchString + * @return Rest response wrapped around a Map of String to List of Search + * Result Item. + */ + @RequestMapping(value = "/allPortal", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse>> searchPortal(HttpServletRequest request, + @RequestParam String searchString) { + + EPUser user = EPUserUtils.getUserSession(request); + try { + if (user == null) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, + "searchPortal: User object is null? - check logs", + new HashMap>()); + } else if (searchString == null || searchString.trim().length() == 0) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "searchPortal: String string is null", + new HashMap>()); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "searchPortal: user {}, search string '{}'", + user.getLoginId(), searchString); + Map> results = searchService.searchResults(user.getLoginId(), + searchString); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "searchPortal failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", + new HashMap>()); + } + } + + /** + * Gets all active users. + * + * TODO: should only the superuser be allowed to use this API? + * + * @param request + * @return Rest response wrapped around a list of String + */ + @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json") + public List getActiveUsers(HttpServletRequest request) { + List activeUsers = null; + List onlineUsers = new ArrayList<>(); + try { + EPUser user = EPUserUtils.getUserSession(request); + String userId = user.getOrgUserId(); + + activeUsers = searchService.getRelatedUsers(userId); + HashSet usersSet = CollaborateList.getInstance().getAllUserName(); + for (String users : activeUsers) { + if (usersSet.contains(users)) { + onlineUsers.add(users); + } + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getActiveUsers failed", e); + } + return onlineUsers; + } + + /** + * Gets only those users that are 'related' to the currently logged-in user. + * + * @param request + * @return Rest response wrapped around a List of String + */ + @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> activeUsers(HttpServletRequest request) { + EPUser user = EPUserUtils.getUserSession(request); + try { + if (user == null) { + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "User object is null? - check logs", + new ArrayList<>()); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "activeUsers: searching for user {}", user.getLoginId()); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", + searchService.getRelatedUsers(user.getLoginId())); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "activeUsers failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", + new ArrayList<>()); + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java new file mode 100644 index 00000000..41da3357 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java @@ -0,0 +1,206 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedRESTfulBaseController; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.EPLoginService; +import org.openecomp.portalapp.portal.service.EPRoleService; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.service.UserNotificationService; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.crossapi.PortalAPIResponse; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppsRestfulController.class); + + @Autowired + private FunctionalMenuService functionalMenuService; + + @Autowired + private EPLoginService epLoginService; + + @Autowired + private AdminRolesService adminRolesService; + + @Autowired + private UserNotificationService userNotificationService; + + @Autowired + private EPRoleService epRoleService; + + @ApiOperation(value = "Creates a Portal user notification for roles identified in the content from an external application.", response = PortalAPIResponse.class) + @RequestMapping(value = { "/publishNotification" }, method = RequestMethod.POST, produces = "application/json") + @ResponseBody + public PortalAPIResponse publishNotification(HttpServletRequest request, + @RequestBody EpNotificationItem notificationItem) throws Exception { + String appKey = request.getHeader("uebkey"); + EPApp app = findEpApp(appKey); + List postRoleIds = new ArrayList(); + for (Long roleId : notificationItem.getRoleIds()) { + EPRole role = epRoleService.getRole(app.getId(), roleId); + if (role != null) + postRoleIds.add(role.getId()); + } + + // --- recreate the user notification object with the POrtal Role Ids + EpNotificationItem postItem = new EpNotificationItem(); + postItem.setRoleIds(postRoleIds); + postItem.setIsForAllRoles("N"); + postItem.setIsForOnlineUsers("N"); + postItem.setActiveYn("Y"); + postItem.setPriority(notificationItem.getPriority()); + postItem.setMsgHeader(notificationItem.getMsgHeader()); + postItem.setMsgDescription(notificationItem.getMsgDescription()); + postItem.setStartTime(notificationItem.getStartTime()); + postItem.setEndTime(notificationItem.getEndTime()); + postItem.setCreatedDate(Calendar.getInstance().getTime()); + // default creator to 1 for now + postItem.setCreatorId(PortalConstants.DEFAULT_NOTIFICATION_CREATOR); + // ---- + + try { + userNotificationService.saveNotification(postItem); + } catch (Exception e) { + return new PortalAPIResponse(false, e.getMessage()); + } + + PortalAPIResponse response = new PortalAPIResponse(true, "success"); + return response; + } + + private EPApp findEpApp(String uebKey) { + List list = null; + StringBuffer criteria = new StringBuffer(); + criteria.append(" where ueb_key = '" + uebKey + "'"); + list = getDataAccessService().getList(EPApp.class, criteria.toString(), null, null); + return (list == null || list.size() == 0) ? null : (EPApp) list.get(0); + } + + @ApiOperation(value = "Gets favorite items within the functional menu for the current user.", response = FavoritesFunctionalMenuItemJson.class, responseContainer="List") + @RequestMapping(value = { "/getFavorites" }, method = RequestMethod.GET, produces = "application/json") + public List getFavoritesForUser(HttpServletRequest request, + HttpServletResponse response) throws Exception { + String loginId = ""; + String userAgent = ""; + List favorites = null; + + loginId = request.getHeader(EPCommonSystemProperties.MDC_LOGIN_ID); + userAgent = MDC.get(EPCommonSystemProperties.PARTNER_NAME); + + EPUser epUser = epLoginService.findUserWithoutPwd(loginId); + logger.info(EELFLoggerDelegate.errorLogger, + "getFavorites request was received from " + userAgent + " for the user " + loginId + "."); + if (epUser == null || epUser.getId() == null) { + logger.error(EELFLoggerDelegate.errorLogger, + "No User record found for the LoginId '" + loginId + "' in the database."); + throw new Exception("Received null for Login-Id."); + } else { + favorites = functionalMenuService.getFavoriteItems(epUser.getId()); + FieldsValidator fieldsValidator = new FieldsValidator(); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + + EcompPortalUtils.logAndSerializeObject(logger, "/getFavorites", "result = ", favorites); + } + + return favorites; + } + + @ApiOperation(value = "Gets functional menu items appropriate for the current user.", response = FunctionalMenuItem.class, responseContainer="List") + @RequestMapping(value = { + "/functionalMenuItemsForUser" }, method = RequestMethod.GET, produces = "application/json") + public List getFunctionalMenuItemsForUser(HttpServletRequest request, + HttpServletResponse response) throws Exception { + String loginId = ""; + String userAgent = ""; + List fnMenuItems = null; + + loginId = request.getHeader("LoginId"); + userAgent = MDC.get(EPCommonSystemProperties.PARTNER_NAME); + + EPUser epUser = epLoginService.findUserWithoutPwd(loginId); + logger.info(EELFLoggerDelegate.errorLogger, "getFunctionalMenuItemsForUser request was received from " + + userAgent + " for the user " + loginId + "."); + if (epUser == null || epUser.getId() == null) { + logger.error(EELFLoggerDelegate.errorLogger, + "No User record found for the LoginId '" + loginId + "' in the database."); + throw new Exception("Received null for Login-Id."); + } else if (adminRolesService.isSuperAdmin(epUser)) { + logger.debug(EELFLoggerDelegate.debugLogger, + "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()"); + fnMenuItems = functionalMenuService.getFunctionalMenuItems(); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()"); + fnMenuItems = functionalMenuService.getFunctionalMenuItemsForUser(epUser.getOrgUserId()); + } + + FieldsValidator fieldsValidator = new FieldsValidator(); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + + EcompPortalUtils.logAndSerializeObject(logger, "/functionalMenuItemsForUser", "result = ", fnMenuItems); + + return fnMenuItems; + } + + @ExceptionHandler(Exception.class) + protected void handleBadRequests(Exception e, HttpServletResponse response) throws IOException { + logger.warn(EELFLoggerDelegate.errorLogger, "Handling bad request", e); + response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/FunctionalMenuController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/FunctionalMenuController.java new file mode 100644 index 00000000..de71766d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/FunctionalMenuController.java @@ -0,0 +1,555 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.cxf.transport.http.HTTPException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.UserProfileService; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.SharedContext; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.EPAuditService; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.service.SearchService; +import org.openecomp.portalapp.portal.service.SharedContextService; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRolesList; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItemWithRoles; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; + +/** + * Supports menus at the top of the Portal app landing page. + */ +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class FunctionalMenuController extends EPRestrictedBaseController { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuController.class); + + @Autowired + AdminRolesService adminRolesService; + @Autowired + FunctionalMenuService functionalMenuService; + @Autowired + SharedContextService sharedContextService; + @Autowired + UserProfileService service; + @Autowired + SearchService searchService; + @Autowired + EPAuditService epAuditService; + + /** + * RESTful service method to fetch all the FunctionalMenuItems. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { "/portalApi/functionalMenu" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItems(HttpServletRequest request, HttpServletResponse response) { + // TODO: should only the superuser be allowed to use this API? + List menuItems = null; + try { + menuItems = functionalMenuService.getFunctionalMenuItems(); + functionalMenuService.assignHelpURLs(menuItems); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenu", "result =", menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenu. Details: " + EcompPortalUtils.getStackTrace(e)); + } + return menuItems; + } + + /** + * RESTful service method to fetch all the FunctionalMenuItems, both active + * and inactive, for the EditFunctionalMenu feature. Can only be accessed by + * the portal admin. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { + "/portalApi/functionalMenuForEditing" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItemsForEditing(HttpServletRequest request, HttpServletResponse response) { + // TODO: should only the superuser be allowed to use this API? + EPUser user = EPUserUtils.getUserSession(request); + List menuItems = null; + try { + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getFunctionalMenuItemDetails"); + } else { + menuItems = functionalMenuService.getFunctionalMenuItems(true); + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuForEditing", "result =", menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenuForEditing. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + return menuItems; + } + + /** + * RESTful service method to fetch all the FunctionalMenuItems, active + *, for the Functional menu in notification Tree feature. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { + "/portalApi/functionalMenuForNotificationTree" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItemsForNotifications(HttpServletRequest request, HttpServletResponse response) { + // TODO: should only the superuser be allowed to use this API? + EPUser user = EPUserUtils.getUserSession(request); + List menuItems = null; + try { + menuItems = functionalMenuService.getFunctionalMenuItemsForNotificationTree(true); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuForNotificationTree", "result =", menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenuForNotifications. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + return menuItems; + } + + /** + * RESTful service method to fetch all FunctionalMenuItems associated with + * an application. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { + "/portalApi/functionalMenuForApp/{appId}" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItemsForApp(HttpServletRequest request, @PathVariable("appId") Integer appId) + throws HTTPException { + // TODO: should only the superuser be allowed to use this API? + List menuItems = null; + try { + menuItems = functionalMenuService.getFunctionalMenuItemsForApp(appId); + functionalMenuService.assignHelpURLs(menuItems); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuForApp/" + appId, "result =", menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenuForApp. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + return menuItems; + } + + /** + * RESTful service method to fetch all FunctionalMenuItems associated with + * the applications and roles that a user has access to. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { + "/portalApi/functionalMenuForUser/{orgUserId}" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItemsForUser(HttpServletRequest request, + @PathVariable("orgUserId") String orgUserId) throws HTTPException { + // TODO: should only the superuser be allowed to use this API? + List menuItems = null; + try { + menuItems = functionalMenuService.getFunctionalMenuItemsForUser(orgUserId); + functionalMenuService.assignHelpURLs(menuItems); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuForUser/" + orgUserId, "result =", menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenuForUser. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + + return menuItems; + } + + /** + * RESTful service method to fetch all FunctionalMenuItems associated with + * the applications and roles that the authenticated user has access to. + * + * @return List of FunctionalMenuItem objects + */ + @RequestMapping(value = { + "/portalApi/functionalMenuForAuthUser" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuItemsForAuthUser(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List menuItems = null; + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getMenuItemsForAuthUser"); + } else if (adminRolesService.isSuperAdmin(user)) { + menuItems = functionalMenuService.getFunctionalMenuItems(); + } else { + // calculate the menu items + String orgUserId = user.getOrgUserId(); + menuItems = functionalMenuService.getFunctionalMenuItemsForUser(orgUserId); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuForUser/" + orgUserId, "result =", + menuItems); + } + functionalMenuService.assignHelpURLs(menuItems); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling getMenuItemsForAuthUser. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + return menuItems; + } + + /** + * RESTful service method to fetch the details for a functional menu item. + * Requirement: you must be the Ecomp portal super admin user. + * + * @return FunctionalMenuItem object + */ + @RequestMapping(value = { + "/portalApi/functionalMenuItemDetails/{menuId}" }, method = RequestMethod.GET, produces = "application/json") + public FunctionalMenuItem getFunctionalMenuItemDetails(HttpServletRequest request, + @PathVariable("menuId") Integer menuId, HttpServletResponse response) throws HTTPException { + // TODO: return FunctionalMenuItemJson + // TODO: modify FunctionalMenuItem to not include the transient fields + FunctionalMenuItem menuItem = null; + try { + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getFunctionalMenuItemDetails"); + } else { + menuItem = functionalMenuService.getFunctionalMenuItemDetails(menuId); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuItemDetails/" + menuId, "result =", + menuItem); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while calling functionalMenuItemDetails. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + + return menuItem; + } + + /** + * RESTful service method to create a new menu item. + * + * Requirement: you must be the Ecomp portal super admin user. + */ + @RequestMapping(value = { "/portalApi/functionalMenuItem" }, method = RequestMethod.POST) + public FieldsValidator createFunctionalMenuItem(HttpServletRequest request, + @RequestBody FunctionalMenuItemWithRoles menuItemJson, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + if (!adminRolesService.isSuperAdmin(user)) { + logger.debug(EELFLoggerDelegate.debugLogger, + "FunctionalMenuController.createFunctionalMenuItem bad permissions"); + EcompPortalUtils.setBadPermissions(user, response, "createFunctionalMenuItem"); + } else { + fieldsValidator = functionalMenuService.createFunctionalMenuItem(menuItemJson); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuItem", "POST result =", + response.getStatus()); + } + + return fieldsValidator; + } + + /** + * RESTful service method to update an existing menu item + * + * Requirement: you must be the Ecomp portal super admin user. + * + * @return FieldsValidator + */ + @RequestMapping(value = { "/portalApi/functionalMenuItem" }, method = RequestMethod.PUT) + public FieldsValidator editFunctionalMenuItem(HttpServletRequest request, + @RequestBody FunctionalMenuItemWithRoles menuItemJson, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "editFunctionalMenuItem"); + } else { + fieldsValidator = functionalMenuService.editFunctionalMenuItem(menuItemJson); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuItem", "PUT result =", + response.getStatus()); + } + + return fieldsValidator; + } + + /** + * RESTful service method to delete a menu item + * + * @return FieldsValidator + */ + @RequestMapping(value = { "/portalApi/functionalMenuItem/{menuId}" }, method = RequestMethod.DELETE) + public FieldsValidator deleteFunctionalMenuItem(HttpServletRequest request, @PathVariable("menuId") Long menuId, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "deleteFunctionalMenuItem"); + } else { + fieldsValidator = functionalMenuService.deleteFunctionalMenuItem(menuId); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuItem", "DELETE result =", + response.getStatus()); + } + + return fieldsValidator; + } + + /** + * RESTful service to regenerate table + * + * @param request + * @param response + * + * @return FieldsValidator + */ + @RequestMapping(value = { "/portalApi/regenerateFunctionalMenuAncestors" }, method = RequestMethod.GET) + public FieldsValidator regenerateAncestorTable(HttpServletRequest request, HttpServletResponse response) { + // TODO: should only the superuser be allowed to use this API? + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "deleteFunctionalMenuItem"); + } else { + fieldsValidator = functionalMenuService.regenerateAncestorTable(); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/regenerateAncestorTable", "GET result =", + response.getStatus()); + } + + return fieldsValidator; + } + + /** + * RESful service to set a favorite item. + * + * @return FieldsValidator + */ + @RequestMapping(value = { "/portalApi/setFavoriteItem" }, method = RequestMethod.POST) + public FieldsValidator addFavoriteItem(HttpServletRequest request, + @RequestBody FavoritesFunctionalMenuItem menuItemJson, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + menuItemJson.userId = user.getId(); + fieldsValidator = functionalMenuService.setFavoriteItem(menuItemJson); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/setFavoriteItem", "Post result =", response.getStatus()); + + return fieldsValidator; + } + + /** + * RESTful service to get favorites for the current user as identified in + * the session + * + * @return List of FavoritesFunctionalMenuItemJson + */ + @RequestMapping(value = { + "/portalApi/getFavoriteItems" }, method = RequestMethod.GET, produces = "application/json") + public List getFavoritesForUser(HttpServletRequest request, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List favorites = functionalMenuService.getFavoriteItems(user.getId()); + FieldsValidator fieldsValidator = new FieldsValidator(); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/getFavoriteItems", "GET result =", response.getStatus()); + return favorites; + } + + /** + * RESTful service to delete a favorite menu item for the current user as + * identified in the session. + * + * @return FieldsValidator + */ + @RequestMapping(value = { "/portalApi/removeFavoriteItem/{menuId}" }, method = RequestMethod.DELETE) + public FieldsValidator deleteFavoriteItem(HttpServletRequest request, @PathVariable("menuId") Long menuId, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + Long userId = user.getId(); + fieldsValidator = functionalMenuService.removeFavoriteItem(userId, menuId); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + EcompPortalUtils.logAndSerializeObject(logger, "/deleteFavoriteItem", "DELETE result =", response.getStatus()); + + return fieldsValidator; + } + + /** + * RESTful service to get user information: user's first and last names, ATT + * UID, email and last-login. (Actually has nothing to do with the real + * functional menu.) First attempts to get the information from the Tomcat + * session (i.e., the CSP cookie); if that fails, calls the shared context + * service to read the information from the database. Gives back what it + * found, any of which may be null, as a JSON collection. + * + * @return JSON collection of key-value pairs shown below. + */ + @RequestMapping(value = { + "/portalApi/functionalMenuStaticInfo" }, method = RequestMethod.GET, produces = "application/json") + public String getFunctionalMenuStaticInfo(HttpServletRequest request, HttpServletResponse response) { + + // Get user details from session + logger.debug(EELFLoggerDelegate.debugLogger, "getFunctionalMenuStaticInfo: getting user info"); + String fnMenuStaticResponse = null; + try { + String orgUserIdStr = null, firstNameStr = null, lastNameStr = null, emailStr = null, lastLogin = null; + EPUser user = EPUserUtils.getUserSession(request); + firstNameStr = user.getFirstName(); + lastNameStr = user.getLastName(); + orgUserIdStr = user.getOrgUserId(); + emailStr = user.getEmail(); + if (emailStr == null || emailStr.equals("")) { + EPUser userResult = searchService.searchUserByUserId(orgUserIdStr); + emailStr = userResult.getEmail(); + } + SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ssZ"); + Date lastLoginDate = user.getLastLoginDate(); + if (lastLoginDate == null) { + // should never happen + logger.error(EELFLoggerDelegate.errorLogger, "getFunctionalMenuStaticInfo: no last login in session"); + lastLogin = "no last login available"; + } + else { + lastLogin = sdf.format(lastLoginDate); + } + + // If any item is missing from session, try the Shared Context + // service. + SharedContext orgUserIdSC = null, firstNameSC = null, lastNameSC = null, emailSC = null; + String sessionId = request.getSession().getId(); + if (firstNameStr == null) + firstNameSC = sharedContextService.getSharedContext(sessionId, EPCommonSystemProperties.USER_FIRST_NAME); + if (lastNameStr == null) + lastNameSC = sharedContextService.getSharedContext(sessionId, EPCommonSystemProperties.USER_LAST_NAME); + if (emailStr == null) + emailSC = sharedContextService.getSharedContext(sessionId, EPCommonSystemProperties.USER_EMAIL); + if (orgUserIdStr == null) + orgUserIdSC = sharedContextService.getSharedContext(sessionId, EPCommonSystemProperties.USER_ORG_USERID); + + // Build the response + Map map = new HashMap(); + map.put("firstName", + firstNameStr != null ? firstNameStr : (firstNameSC != null ? firstNameSC.getCvalue() : null)); + map.put("lastName", + lastNameStr != null ? lastNameStr : (lastNameSC != null ? lastNameSC.getCvalue() : null)); + map.put("email", emailStr != null ? emailStr : (emailSC != null ? emailSC.getCvalue() : null)); + map.put("userId", orgUserIdStr != null ? orgUserIdStr : (orgUserIdSC != null ? orgUserIdSC.getCvalue() : null)); + map.put("last_login", lastLogin); + JSONObject j = new JSONObject(map); + fnMenuStaticResponse = j.toString(); + // Be chatty in the log + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/functionalMenuStaticInfo", "GET result =", + fnMenuStaticResponse); + } catch (Exception e) { + // Should never happen. + logger.error(EELFLoggerDelegate.errorLogger, "getFunctionalMenuStaticInfo failed", e); + // Return a real error? + // fnMenuStaticResponse = "{ \"status\": \"error\", \"message\": \"" + // + e.toString() + "\" }"; + // But the angular controller expects null on error. + } + return fnMenuStaticResponse; + } + + private Comparator getUserAppRolesComparator = new Comparator() { + public int compare(BusinessCardApplicationRole o1, BusinessCardApplicationRole o2) { + return o1.getAppName().compareTo(o2.getAppName()); + } + }; + + @RequestMapping(value = { + "/portalApi/userApplicationRoles" }, method = RequestMethod.GET, produces = "application/json") + public List getAppList(HttpServletRequest request,@RequestParam("userId") String userId) throws IOException { + + + List AppRoles = null; + try { + List userAppRoleList = functionalMenuService.getUserAppRolesList(userId); + + Collections.sort(userAppRoleList, getUserAppRolesComparator); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userApplicationRoles", "result =", userAppRoleList); + + AppRoles = new ArrayList(); + for(BusinessCardApplicationRole userAppRole: userAppRoleList) + { + boolean found = false; + List roles = null; + + for(BusinessCardApplicationRolesList app :AppRoles) + { + if(app.getAppName().equals(userAppRole.getAppName())) + { + roles= app.getRoleNames(); + roles.add(userAppRole.getRoleName()); + app.setRoleNames(roles); + found = true; + break; + } + } + + if(!found) + { + roles = new ArrayList(); + roles.add(userAppRole.getRoleName()); + AppRoles.add(new BusinessCardApplicationRolesList(userAppRole.getAppName(), roles)); + } + + Collections.sort(roles); + } + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error(EELFLoggerDelegate.errorLogger, "getAppList failed", e); + } + + return AppRoles; + + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/GetAccessController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/GetAccessController.java new file mode 100644 index 00000000..7856dc43 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/GetAccessController.java @@ -0,0 +1,73 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.controller.EPUnRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.GetAccessResult; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.GetAccessService; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; + +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class GetAccessController extends EPUnRestrictedBaseController { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(GetAccessController.class); + + @Autowired + GetAccessService getAccessService; + + /** + * Sorts the list by ECOMP function name. + */ + private Comparator getAccessComparator = new Comparator() { + public int compare(GetAccessResult o1, GetAccessResult o2) { + return o1.getAppName().compareTo(o2.getAppName()); + } + }; + + @RequestMapping(value = { "/portalApi/getAppList" }, method = RequestMethod.GET, produces = "application/json") + public List getAppList(HttpServletRequest request) throws IOException { + List appsList = null; + EPUser user = EPUserUtils.getUserSession(request); + appsList = getAccessService.getAppAccessList(user); + Collections.sort(appsList, getAccessComparator); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/getAppList", "result =", appsList); + return appsList; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/HealthCheckController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/HealthCheckController.java new file mode 100644 index 00000000..84731af4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/HealthCheckController.java @@ -0,0 +1,235 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.MDC; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.controller.EPUnRestrictedBaseController; +import org.openecomp.portalapp.portal.listener.HealthMonitor; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import com.google.gson.Gson; + +/* + * This controller checks the health status and returns JSON response. + * It does not require authentication or session. + */ +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class HealthCheckController extends EPUnRestrictedBaseController { + + private class HealthStatus { + public int statusCode; + @SuppressWarnings("unused") + public String body; + + public HealthStatus(int code, String body) { + this.statusCode = code; + this.body = body; + } + } + + private class HealthStatusInfo { + HealthStatusInfo(String healthCheckComponent) { + this.healthCheckComponent = healthCheckComponent; + this.healthCheckStatus = statusUp; // Default value + this.version = ""; + this.description = statusOk; // Default value + this.hostName = ""; + this.ipAddress = ""; + this.dbClusterStatus = ""; + this.dbPermissions = ""; + } + + @SuppressWarnings("unused") + public String healthCheckComponent; + @SuppressWarnings("unused") + public String healthCheckStatus; + @SuppressWarnings("unused") + public String version; + @SuppressWarnings("unused") + public String description; + @SuppressWarnings("unused") + public String hostName; + @SuppressWarnings("unused") + public String ipAddress; + @SuppressWarnings("unused") + public String dbClusterStatus; + @SuppressWarnings("unused") + public String dbPermissions; + } + + private final String statusUp = "UP"; + private final String statusDown = "DOWN"; + private final String statusOk = "OK"; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HealthCheckController.class); + + @RequestMapping(value = { "/portalApi/healthCheck" }, method = RequestMethod.GET, produces = "application/json") + public HealthStatus healthCheck(HttpServletRequest request, HttpServletResponse response) { + HealthStatus healthStatus = new HealthStatus(500, ""); + + // Return the status as 500 if it suspended due to manual fail over + if (HealthMonitor.isSuspended) { + healthStatus.body = "Suspended"; + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + return healthStatus; + } + + try { + boolean overallStatus = true; + + List statusCollection = new ArrayList(); + + HealthStatusInfo beInfo = new HealthStatusInfo("BE"); + beInfo.hostName = EcompPortalUtils.getMyHostName(); + beInfo.ipAddress = EcompPortalUtils.getMyIpAdddress(); + if (!HealthMonitor.isBackEndUp()) { + overallStatus = false; + beInfo.healthCheckStatus = statusDown; + beInfo.description = "Check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHealthCheckError); + } + statusCollection.add(beInfo); + + HealthStatusInfo feInfo = new HealthStatusInfo("FE"); + if (!HealthMonitor.isFrontEndUp()) { + overallStatus = false; + feInfo.healthCheckStatus = statusDown; + feInfo.description = "Check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.FeHealthCheckError); + } + statusCollection.add(feInfo); + + HealthStatusInfo dbInfo = new HealthStatusInfo("DB"); + if (!HealthMonitor.isDatabaseUp()) { + overallStatus = false; + dbInfo.healthCheckStatus = statusDown; + dbInfo.description = "Check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError); + } + + if (!HealthMonitor.isClusterStatusOk()) { + dbInfo.dbClusterStatus = "Problem, check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError); + } + else { + dbInfo.dbClusterStatus = statusOk; + } + + if (!HealthMonitor.isDatabasePermissionsOk()) { + dbInfo.dbPermissions = "Problem, check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError); + } + else { + dbInfo.dbPermissions = statusOk; + } + statusCollection.add(dbInfo); + + HealthStatusInfo uebInfo = new HealthStatusInfo("UEB"); + if (!HealthMonitor.isUebUp()) { + //As per test case review meeting, UEB is considered as critical as DB. Hence commenting + //overallStatus = false; + uebInfo.healthCheckStatus = statusDown; + uebInfo.description = "Check the logs for more details"; + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebConnectionError); + } + statusCollection.add(uebInfo); + + String json = ""; + try { + json = new Gson().toJson(statusCollection); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput); + } + logger.info(EELFLoggerDelegate.debugLogger, json); + + if (overallStatus) { + healthStatus = new HealthStatus(200, json); + } else { + healthStatus = new HealthStatus(500, json); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(healthStatus.statusCode)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing the healthcheck. Details: " + + EcompPortalUtils.getStackTrace(e)); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheck", "GET result =", response.getStatus()); + + return healthStatus; + } + + @RequestMapping(value = { + "/portalApi/healthCheckSuspend" }, method = RequestMethod.GET, produces = "application/json") + public HealthStatus healthCheckSuspend(HttpServletRequest request, HttpServletResponse response) { + HealthStatus healthStatus = new HealthStatus(500, "Suspended for manual failover mechanism"); + + HealthMonitor.isSuspended = true; + healthStatus.statusCode = 200; + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckSuspend", "GET result =", + response.getStatus()); + + return healthStatus; + } + + @RequestMapping(value = { + "/portalApi/healthCheckResume" }, method = RequestMethod.GET, produces = "application/json") + public HealthStatus healthCheckResume(HttpServletRequest request, HttpServletResponse response) { + HealthStatus healthStatus = new HealthStatus(500, "Resumed from manual failover mechanism"); + + HealthMonitor.isSuspended = false; + healthStatus.statusCode = 200; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckResume", "GET result =", + response.getStatus()); + return healthStatus; + } + + + + @RequestMapping(value = { + "/portalApi/ping" }, method = RequestMethod.GET, produces = "application/json") + public HealthStatus ping(HttpServletRequest request, HttpServletResponse response) { + HealthStatus healthStatus = new HealthStatus(200, "OK"); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/ping", "GET result =", + response.getStatus()); + + return healthStatus; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ManifestController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ManifestController.java new file mode 100644 index 00000000..7b4d51f5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/ManifestController.java @@ -0,0 +1,90 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.HashMap; +import java.util.Map; +import java.util.jar.Attributes; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.controller.RestrictedBaseController; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.ManifestService; + +/** + * This controller responds to a request for the web application manifest, + * returning a JSON with the information that was created at build time. + * + * Manifest entries have names with hyphens, which means Javascript code can't + * simply use the shorthand object.key; instead use object['key']. + */ +@RestController +@Configuration("manifestPortalController") +@EnableAspectJAutoProxy +@RequestMapping("/") +@EPAuditLog +public class ManifestController extends RestrictedBaseController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestController.class); + + @Autowired + ManifestService manifestService; + + /** + * Gets the webapp manifest contents as a JSON object. + * + * @param request + * @return A map of key-value pairs. On success: + * + *
+	 * { "manifest" : { "key1": "value1", "key2": "value2" } }
+	 *         
+ * + * On failure: + * + *
+	 * { "error": "message" }
+	 *         
+ */ + @RequestMapping(value = { "/portalApi/manifest" }, method = RequestMethod.GET, produces = "application/json") + @ResponseBody + public Map getManifest(HttpServletRequest request) { + Map response = new HashMap(); + try { + Attributes attributes = manifestService.getWebappManifest(); + response.put("manifest", attributes); + } catch (Exception ex) { + logger.error(EELFLoggerDelegate.errorLogger, "getManifest: failed to read manifest", ex); + response.put("error", "failed to get manifest: " + ex.toString()); + } + return response; + } + +} \ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java new file mode 100644 index 00000000..82d70ecd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java @@ -0,0 +1,141 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.WidgetCatalog; +import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.ConsulHealthService; +import org.openecomp.portalapp.portal.service.MicroserviceService; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; + +@SuppressWarnings("unchecked") +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class MicroserviceController extends EPRestrictedBaseController { + + private static final String HTTPS = "https://"; + + String whatService = "widgets-service"; + RestTemplate template = new RestTemplate(); + + @Autowired + private ConsulHealthService consulHealthService; + + @Autowired + private MicroserviceService microserviceService; + + @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.POST) + public PortalRestResponse createMicroservice(HttpServletRequest request, HttpServletResponse response, + @RequestBody MicroserviceData newServiceData) throws Exception { + if (newServiceData == null) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "MicroserviceData cannot be null or empty"); + } + long serviceId = microserviceService.saveMicroservice(newServiceData); + + try { + microserviceService.saveServiceParameters(serviceId, newServiceData.getParameterList()); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.GET) + public List getMicroservice(HttpServletRequest request, HttpServletResponse response) + throws Exception { + List list = microserviceService.getMicroserviceData(); + return list; + } + + @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.PUT) + public PortalRestResponse updateMicroservice(HttpServletRequest request, HttpServletResponse response, + @PathVariable("serviceId") long serviceId, @RequestBody MicroserviceData newServiceData) throws Exception { + + if (newServiceData == null) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "MicroserviceData cannot be null or empty"); + } + try { + microserviceService.updateMicroservice(serviceId, newServiceData); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.DELETE) + public PortalRestResponse deleteMicroservice(HttpServletRequest request, HttpServletResponse response, + @PathVariable("serviceId") long serviceId) throws Exception { + try { + ParameterizedTypeReference> typeRef = new ParameterizedTypeReference>() { + }; + // If this service is assoicated with widgets, cannnot be deleted + ResponseEntity> ans = (ResponseEntity>) template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/service/" + serviceId, + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef); + List widgets = ans.getBody(); + if(widgets.size() == 0) + microserviceService.deleteMicroservice(serviceId); + else{ + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < widgets.size(); i++){ + sb.append("'" + widgets.get(i).getName() + "' "); + if(i < (widgets.size()-1)){ + sb.append(","); + } + } + return new PortalRestResponse(PortalRestStatusEnum.WARN, "SOME WIDGETS ASSOICATE WITH THIS SERVICE", sb.toString()); + } + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceProxyController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceProxyController.java new file mode 100644 index 00000000..6724d4c6 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceProxyController.java @@ -0,0 +1,108 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPUnRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.WidgetParameterResult; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.MicroserviceProxyService; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.HttpClientErrorException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings("unchecked") +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class MicroserviceProxyController extends EPUnRestrictedBaseController { + + @Autowired + private MicroserviceProxyService microserviceProxyService; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MicroserviceProxyController.class); + + @RequestMapping(value = { "/portalApi/microservice/proxy/{serviceId}" }, method = { + RequestMethod.GET }, produces = "application/json") + public String getMicroserviceProxy(HttpServletRequest request, HttpServletResponse response, + @PathVariable("serviceId") long serviceId) throws Exception { + EPUser user = EPUserUtils.getUserSession(request); + String answer = ""; + try{ + answer = microserviceProxyService.proxyToDestination(serviceId, user, request); + }catch(HttpClientErrorException e){ + //Check whether the error message is valid JSON format + boolean valid = true; + ObjectMapper objectMapper = new ObjectMapper(); + try{ + objectMapper.readTree(e.getResponseBodyAsString()); + } catch(JsonProcessingException exception){ + valid = false; + } + if(valid) + return e.getResponseBodyAsString(); + else + return "{\"error\":\""+ e.getResponseBodyAsString() +"\"}"; + } + return answer; + } + + @RequestMapping(value = { "/portalApi/microservice/proxy/parameter/{widgetId}" }, method = { + RequestMethod.GET }, produces = "application/json") + public String getMicroserviceProxyByWidgetId(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws Exception { + EPUser user = EPUserUtils.getUserSession(request); + String answer = ""; + try{ + answer = microserviceProxyService.proxyToDestinationByWidgetId(widgetId, user, request); + }catch(HttpClientErrorException e){ + //Check whether the error message is valid JSON format + boolean valid = true; + ObjectMapper objectMapper = new ObjectMapper(); + try{ + objectMapper.readTree(e.getResponseBodyAsString()); + } catch(JsonProcessingException exception){ + valid = false; + } + if(valid) + return e.getResponseBodyAsString(); + else + return "{\"error\":\""+ e.getResponseBodyAsString() +"\"}"; + } + return answer; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java new file mode 100644 index 00000000..2499ec66 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java @@ -0,0 +1,200 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.domain.AuditLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.AuditService; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.PortalAdminService; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.PortalAdmin; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; + +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class PortalAdminController extends EPRestrictedBaseController { + @Autowired + PortalAdminService portalAdminService; + @Autowired + AdminRolesService adminRolesService; + @Autowired + AuditService auditService; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PortalAdminController.class); + + @RequestMapping(value = { "/portalApi/portalAdmins" }, method = RequestMethod.GET, produces = "application/json") + public List getPortalAdmins(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List portalAdmins = null; + if (user == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.getPortalAdmins, null user"); + EcompPortalUtils.setBadPermissions(user, response, "getPortalAdmins"); + } else if (!adminRolesService.isSuperAdmin(user)) { + logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.getPortalAdmins, bad permissions"); + EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); + } else { + // return the list of portal admins + portalAdmins = portalAdminService.getPortalAdmins(); + logger.debug(EELFLoggerDelegate.debugLogger, "portalAdmins: called getPortalAdmins()"); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/getPortalAdmins", "result =", portalAdmins); + } + + return portalAdmins; + } + + /** + * RESTful service method to create a new portal admin. Requirement: you + * must be the Ecomp portal super admin user. + */ + + @RequestMapping(value = { "/portalApi/portalAdmin" }, method = RequestMethod.POST) + public FieldsValidator createPortalAdmin(HttpServletRequest request, @RequestBody String sbcid, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + FieldsValidator fieldsValidator = null; + if (user == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.createPortalAdmin, null user"); + EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); + } else if (!adminRolesService.isSuperAdmin(user)) { + logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.createPortalAdmin bad permissions"); + EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); + } else { + fieldsValidator = portalAdminService.createPortalAdmin(sbcid); + int statusCode = fieldsValidator.httpStatusCode.intValue(); + response.setStatus(statusCode); + if (statusCode == 200) { + AuditLog auditLog = new AuditLog(); + auditLog.setUserId(user.getId()); + auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_ADD_PORTAL_ADMIN); + auditLog.setAffectedRecordId(sbcid); + auditService.logActivity(auditLog, null); + + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + logger.info(EELFLoggerDelegate.auditLogger, + EPLogUtil.formatAuditLogMessage("PortalAdminController.createPortalAdmin", + EcompAuditLog.CD_ACTIVITY_ADD_PORTAL_ADMIN, user.getOrgUserId(), sbcid, + "A new Portal Admin has been added")); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + } + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalAdmin", "POST result =", response.getStatus()); + + return fieldsValidator; + } + + @RequestMapping(value = { "/portalApi/portalAdmin/{userInfo}" }, method = RequestMethod.DELETE) + public FieldsValidator deletePortalAdmin(HttpServletRequest request, @PathVariable("userInfo") String userInfo, + HttpServletResponse response) { + int userIdIdx = userInfo.indexOf("-"); + Long userId = null; + String sbcid = null; + FieldsValidator fieldsValidator = null; + try{ + if(userIdIdx==-1){ + logger.error(EELFLoggerDelegate.errorLogger,"deletePortalAdmin missing userId"); + return fieldsValidator; + }else{ + String userIdStr = userInfo.substring(0, userIdIdx); + userId = Long.valueOf(userIdStr); + sbcid = userInfo.substring(userIdIdx+1, userInfo.length()); + } + }catch(Exception e){ + logger.error(EELFLoggerDelegate.errorLogger,"deletePortalAdmin error while parsing the userInfo",e); + } + EPUser user = EPUserUtils.getUserSession(request); + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "deletePortalAdmin"); + } else { + fieldsValidator = portalAdminService.deletePortalAdmin(userId); + int statusCode = fieldsValidator.httpStatusCode.intValue(); + response.setStatus(statusCode); + if (statusCode == 200) { + AuditLog auditLog = new AuditLog(); + auditLog.setUserId(user.getId()); + auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_DELETE_PORTAL_ADMIN); + auditLog.setAffectedRecordId(sbcid); + auditService.logActivity(auditLog, null); + + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + logger.info(EELFLoggerDelegate.auditLogger, + EPLogUtil.formatAuditLogMessage("PortalAdminController.deletePortalAdmin", + EcompAuditLog.CD_ACTIVITY_DELETE_PORTAL_ADMIN, user.getOrgUserId(), sbcid, + "A Portal Admin has been deleted")); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + } + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalAdmin", "DELETE result =", response.getStatus()); + + return fieldsValidator; + } + + @RequestMapping(value = { + "/portalApi/adminAppsRoles/{appId}" }, method = RequestMethod.GET, produces = "application/json") + public List getRolesByApp(HttpServletRequest request, @PathVariable("appId") Long appId, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List rolesByApp = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + rolesByApp = adminRolesService.getRolesByApp(user, appId); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while performing getRolesByApp operation, Details: " + + EcompPortalUtils.getStackTrace(e)); + } + + return rolesByApp; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/RoleManageController.java new file mode 100644 index 00000000..d567269f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/RoleManageController.java @@ -0,0 +1,166 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.controller.core.RoleController; +import org.openecomp.portalapp.controller.core.RoleFunctionListController; +import org.openecomp.portalapp.controller.core.RoleListController; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * Proxies REST calls to role-management functions that arrive on paths + * /portalApi/* over to controller methods provided by the SDK-Core library. + * Those controller methods are mounted on paths not exposed by the Portal FE. + */ +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class RoleManageController extends EPRestrictedBaseController { + + @Autowired + private RoleController roleController; + + @Autowired + private RoleListController roleListController; + + @Autowired + private RoleFunctionListController roleFunctionListController; + + /** + * Calls an SDK-Core library method that gets the available roles and writes + * them to the request object. Portal specifies a Hibernate mappings from + * the Role class to the fn_role_v view, which ensures that only Portal + * (app_id is null) roles are fetched. + * + * Any method declared void (no return value) or returning null causes the + * audit log aspect method to declare failure. TODO: should return a JSON + * string. + * + * @param request + * @param response + */ + @RequestMapping(value = { "/portalApi/get_roles" }, method = RequestMethod.GET) + public void getRoles(HttpServletRequest request, HttpServletResponse response) { + getRoleListController().getRoles(request, response); + } + + @RequestMapping(value = { "/portalApi/role_list/toggleRole" }, method = RequestMethod.POST) + public PortalRestResponse toggleRole(HttpServletRequest request, HttpServletResponse response) { + PortalRestResponse portalRestResponse = null; + try{ + getRoleListController().toggleRole(request, response); + portalRestResponse = new PortalRestResponse(PortalRestStatusEnum.OK, "success", null); + }catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "failure", e.getMessage()); + } + return portalRestResponse; + } + + @RequestMapping(value = { "/portalApi/role_list/removeRole" }, method = RequestMethod.POST) + public ModelAndView removeRole(HttpServletRequest request, HttpServletResponse response) throws Exception { + return getRoleListController().removeRole(request, response); + } + + @RequestMapping(value = { "/portalApi/role/saveRole" }, method = RequestMethod.POST) + public ModelAndView saveRole(HttpServletRequest request, HttpServletResponse response) throws Exception { + return getRoleController().saveRole(request, response); + } + + @RequestMapping(value = { "/portalApi/role/removeRoleFunction" }, method = RequestMethod.POST) + public ModelAndView removeRoleRoleFunction(HttpServletRequest request, HttpServletResponse response) + throws Exception { + return getRoleController().removeRoleFunction(request, response); + } + + @RequestMapping(value = { "/portalApi/role/addRoleFunction" }, method = RequestMethod.POST) + public ModelAndView addRoleRoRoleFunction(HttpServletRequest request, HttpServletResponse response) + throws Exception { + return getRoleController().addRoleFunction(request, response); + } + + @RequestMapping(value = { "/portalApi/role/removeChildRole" }, method = RequestMethod.POST) + public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { + return getRoleController().removeChildRole(request, response); + } + + @RequestMapping(value = { "/portalApi/role/addChildRole" }, method = RequestMethod.POST) + public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { + return getRoleController().addChildRole(request, response); + } + + @RequestMapping(value = { "/portalApi/get_role" }, method = RequestMethod.GET) + public void getRole(HttpServletRequest request, HttpServletResponse response) { + getRoleController().getRole(request, response); + } + + @RequestMapping(value = { "/portalApi/get_role_functions" }, method = RequestMethod.GET) + public void getRoleFunctionList(HttpServletRequest request, HttpServletResponse response) { + getRoleFunctionListController().getRoleFunctionList(request, response); + } + + @RequestMapping(value = { "/portalApi/role_function_list/saveRoleFunction" }, method = RequestMethod.POST) + public void saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @RequestBody String roleFunc) throws Exception { + getRoleFunctionListController().saveRoleFunction(request, response, roleFunc); + } + + @RequestMapping(value = { "/portalApi/role_function_list/removeRoleFunction" }, method = RequestMethod.POST) + public void removeRoleFunction(HttpServletRequest request, HttpServletResponse response, @RequestBody String roleFunc) throws Exception { + getRoleFunctionListController().removeRoleFunction(request, response, roleFunc); + } + + public RoleListController getRoleListController() { + return roleListController; + } + + public void setRoleListController(RoleListController roleListController) { + this.roleListController = roleListController; + } + + public RoleController getRoleController() { + return roleController; + } + + public void setRoleController(RoleController roleController) { + this.roleController = roleController; + } + + public RoleFunctionListController getRoleFunctionListController() { + return roleFunctionListController; + } + + public void setRoleFunctionListController(RoleFunctionListController roleFunctionListController) { + this.roleFunctionListController = roleFunctionListController; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/SharedContextRestController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/SharedContextRestController.java new file mode 100644 index 00000000..a59a4579 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/SharedContextRestController.java @@ -0,0 +1,343 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.IOException; +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.openecomp.portalapp.controller.EPRestrictedRESTfulBaseController; +import org.openecomp.portalapp.portal.domain.SharedContext; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.SharedContextService; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.swagger.annotations.ApiOperation; + +/** + * The shared-context feature allows onboarded applications to share data among + * themselves easily for a given session. It basically implements a Java map: + * put or get a key-value pair within a map identified by a session ID. + * + * This REST endpoint listens on the Portal app server and answers requests made + * by back-end application servers. Reads and writes values to the database + * using a Hibernate service to ensure all servers in a high-availability + * cluster see the same data. + */ +@Configuration +@RestController +@RequestMapping(PortalConstants.REST_AUX_API + "/context") +@EnableAspectJAutoProxy +@EPAuditLog +public class SharedContextRestController extends EPRestrictedRESTfulBaseController { + + /** + * Model for a one-element JSON object returned by many methods. + */ + class SharedContextJsonResponse { + String response; + } + + /** + * Access to the database + */ + @Autowired + private SharedContextService contextService; + + /** + * Logger for debug etc. + */ + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SharedContextRestController.class); + + /** + * Reusable JSON (de)serializer + */ + private final ObjectMapper mapper = new ObjectMapper(); + + /** + * Gets a value for the specified context and key (RESTful service method). + * + * @param ctxtId + * ID that identifies the context, usually the ECOMP Portal + * session key. + * @param ckey + * Key for the key-value pair to fetch + * @return JSON with shared context object; response=null if not found. + */ + @ApiOperation(value = "Gets a value for the specified context and key.", response = SharedContext.class) + @RequestMapping(value = { "/get" }, method = RequestMethod.GET, produces = "application/json") + public String getContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) + throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "getContext for ID " + context_id + ", key " + ckey); + if (context_id == null || ckey == null) + throw new Exception("Received null for context_id and/or ckey"); + + SharedContext context = contextService.getSharedContext(context_id, ckey); + String jsonResponse = ""; + if (context == null) + jsonResponse = convertResponseToJSON(context); + else + jsonResponse = mapper.writeValueAsString(context); + + return jsonResponse; + } + + /** + * Gets user information for the specified context (RESTful service method). + * + * @param ctxtId + * ID that identifies the context, usually the ECOMP Portal + * session key. + * + * @return List of shared-context objects as JSON; should have user's first + * name, last name and email address; null if none found + */ + @ApiOperation(value = "Gets user information for the specified context.", response = SharedContext.class, responseContainer = "List") + @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET, produces = "application/json") + public String getUserContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "getUserContext for ID " + context_id); + if (context_id == null) + throw new Exception("Received null for context_id"); + + List listSharedContext = new ArrayList(); + SharedContext firstNameContext = contextService.getSharedContext(context_id, + EPCommonSystemProperties.USER_FIRST_NAME); + SharedContext lastNameContext = contextService.getSharedContext(context_id, + EPCommonSystemProperties.USER_LAST_NAME); + SharedContext emailContext = contextService.getSharedContext(context_id, EPCommonSystemProperties.USER_EMAIL); + SharedContext attuidContext = contextService.getSharedContext(context_id, + EPCommonSystemProperties.USER_ORG_USERID); + if (firstNameContext != null) + listSharedContext.add(firstNameContext); + if (lastNameContext != null) + listSharedContext.add(lastNameContext); + if (emailContext != null) + listSharedContext.add(emailContext); + if (attuidContext != null) + listSharedContext.add(attuidContext); + String jsonResponse = convertResponseToJSON(listSharedContext); + return jsonResponse; + } + + /** + * Tests for presence of the specified key in the specified context (RESTful + * service method). + * + * @param context_id + * ID that identifies the context, usually the ECOMP Portal + * session key. + * @param ckey + * Key for the key-value pair to test + * @return JSON with result indicating whether the context and key were + * found. + */ + @ApiOperation(value = "Tests for presence of the specified key in the specified context.", response = SharedContextJsonResponse.class) + @RequestMapping(value = { "/check" }, method = RequestMethod.GET, produces = "application/json") + public String checkContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) + throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "checkContext for " + context_id + ", key " + ckey); + if (context_id == null || ckey == null) + throw new Exception("Received null for contextId and/or key"); + + String response = null; + SharedContext context = contextService.getSharedContext(context_id, ckey); + if (context != null) + response = "exists"; + + String jsonResponse = convertResponseToJSON(response); + return jsonResponse; + } + + /** + * Removes the specified key in the specified context (RESTful service + * method). + * + * @param context_id + * ID that identifies the context, usually the ECOMP Portal + * session key. + * @param ckey + * Key for the key-value pair to remove + * @return JSON with result indicating whether the context and key were + * found. + */ + @ApiOperation(value = "Removes the specified key in the specified context.", response = SharedContextJsonResponse.class) + @RequestMapping(value = { "/remove" }, method = RequestMethod.GET, produces = "application/json") + public String removeContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) + throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "removeContext for " + context_id + ", key " + ckey); + if (context_id == null || ckey == null) + throw new Exception("Received null for contextId and/or key"); + + SharedContext context = contextService.getSharedContext(context_id, ckey); + String response = null; + if (context != null) { + contextService.deleteSharedContext(context); + response = "removed"; + } + + String jsonResponse = convertResponseToJSON(response); + return jsonResponse; + } + + /** + * Clears all key-value pairs in the specified context (RESTful service + * method). + * + * @param context_id + * ID that identifies the context, usually the ECOMP Portal + * session key. + * @return JSON with result indicating the number of key-value pairs + * removed. + */ + @ApiOperation(value = "Clears all key-value pairs in the specified context.", response = SharedContextJsonResponse.class) + @RequestMapping(value = { "/clear" }, method = RequestMethod.GET, produces = "application/json") + public String clearContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "clearContext for " + context_id); + if (context_id == null) + throw new Exception("clearContext: Received null for contextId"); + + int count = contextService.deleteSharedContexts(context_id); + String jsonResponse = convertResponseToJSON(Integer.toString(count)); + return jsonResponse; + } + + /** + * Sets a context value for the specified context and key (RESTful service + * method). Creates the context if no context with the specified ID-key pair + * exists, overwrites the value if it exists already. + * + * @param userJson + * JSON block with these tag-value pairs: + *
    + *
  • context_id: ID that identifies the context + *
  • ckey: Key for the key-value pair to store + *
  • cvalue: Value to store + *
+ * @return JSON with result indicating whether the value was added (key not + * previously known) or replaced (key previously known). + */ + @ApiOperation(value = "Sets a context value for the specified context and key. Creates the context if no context with the specified ID-key pair exists, overwrites the value if it exists already.", response = SharedContextJsonResponse.class) + @RequestMapping(value = { "/set" }, method = RequestMethod.POST, produces = "application/json") + public String setContext(HttpServletRequest request, @RequestBody String userJson) throws Exception { + + @SuppressWarnings("unchecked") + Map userData = mapper.readValue(userJson, Map.class); + // Use column names as JSON tags + final String contextId = (String) userData.get("context_id"); + final String key = (String) userData.get("ckey"); + final String value = (String) userData.get("cvalue"); + if (contextId == null || key == null) + throw new Exception("setContext: received null for contextId and/or key"); + + logger.debug(EELFLoggerDelegate.debugLogger, "setContext: ID " + contextId + ", key " + key + "->" + value); + String response = null; + SharedContext existing = contextService.getSharedContext(contextId, key); + if (existing == null) { + contextService.addSharedContext(contextId, key, value); + } else { + existing.setCvalue(value); + contextService.saveSharedContext(existing); + } + response = existing == null ? "added" : "replaced"; + String jsonResponse = convertResponseToJSON(response); + return jsonResponse; + } + + /** + * Creates a two-element JSON object tagged "response". + * + * @param responseBody + * @return JSON object as String + * @throws JsonProcessingException + */ + private String convertResponseToJSON(String responseBody) throws JsonProcessingException { + Map responseMap = new HashMap(); + responseMap.put("response", responseBody); + String response = mapper.writeValueAsString(responseMap); + return response; + } + + /** + * Converts a list of SharedContext objects to a JSON array. + * + * @param contextList + * @return JSON array as String + * @throws JsonProcessingException + */ + private String convertResponseToJSON(List contextList) throws JsonProcessingException { + String jsonArray = mapper.writeValueAsString(contextList); + return jsonArray; + } + + /** + * Creates a JSON object with the content of the shared context; null is ok. + * + * @param responseBody + * @return tag "response" with collection of context object's fields + * @throws JsonProcessingException + */ + private String convertResponseToJSON(SharedContext context) throws JsonProcessingException { + Map responseMap = new HashMap(); + responseMap.put("response", context); + String responseBody = mapper.writeValueAsString(responseMap); + return responseBody; + } + + /** + * Handles any exception thrown by a method in this controller. + * + * @param e + * Exception + * @param response + * HttpServletResponse + * @throws IOException + */ + @ExceptionHandler(Exception.class) + protected void handleBadRequests(Exception e, HttpServletResponse response) throws IOException { + logger.error(EELFLoggerDelegate.errorLogger, "handleBadRequest caught exception", e); + response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java new file mode 100644 index 00000000..0dd344d7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/TicketEventController.java @@ -0,0 +1,179 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.UserNotificationService; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.EpRoleNotificationItem; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.swagger.annotations.ApiOperation; + +/** + * Receives messages from the Collaboration Bus (C-BUS) notification and event + * brokering tool. Creates notifications for ECOMP Portal users. + */ +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class TicketEventController implements BasicAuthenticationController { + + @Autowired + private UserNotificationService userNotificationService; + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TicketEventController.class); + + public boolean isAuxRESTfulCall() { + return true; + } + + private final ObjectMapper mapper = new ObjectMapper(); + + @ApiOperation(value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class) + @RequestMapping(value = { "/ticketevent" }, method = RequestMethod.POST) + public PortalRestResponse handleRequest(HttpServletRequest request, HttpServletResponse response, + @RequestBody String ticketEventJson) throws Exception { + + logger.debug(EELFLoggerDelegate.debugLogger, "Ticket Event notification" + ticketEventJson); + PortalRestResponse portalResponse = new PortalRestResponse<>(); + try { + JsonNode ticketEventNotif = mapper.readTree(ticketEventJson); + + // Reject request if required fields are missing. + String error = validateTicketEventMessage(ticketEventNotif); + if (error != null) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + portalResponse.setMessage(error); + response.setStatus(400); + return portalResponse; + } + + EpNotificationItem epItem = new EpNotificationItem(); + epItem.setCreatedDate(new Date()); + epItem.setIsForOnlineUsers("Y"); + epItem.setIsForAllRoles("N"); + epItem.setActiveYn("Y"); + //JsonNode application = ticketEventNotif.get("application"); + JsonNode event = ticketEventNotif.get("event"); + JsonNode header = event.get("header"); + JsonNode body = event.get("body"); + epItem.setMsgDescription(body.toString()); + Long eventDate = body.get("eventDate").asLong(); + + String assetID = body.get("assetID").asText(); + epItem.setMsgHeader(assetID); + String eventSource = header.get("eventSource").asText(); + epItem.setMsgSource(eventSource); + epItem.setStartTime(new Date(eventDate)); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(epItem.getStartTime()); + int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); + calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth + 30); + epItem.setEndTime(calendar.getTime()); + String severityString= (body.get("severity").toString()).substring(1, 2); + Long severity=Long.parseLong(severityString); + epItem.setPriority(severity); + epItem.setCreatorId(null); + Set roles = new HashSet<>(); + JsonNode SubscriberInfo = ticketEventNotif.get("SubscriberInfo"); + JsonNode userList = SubscriberInfo.get("UserList"); + String UserIds[] = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "") + .split(","); + List users = userNotificationService.getUsersByOrgIds(Arrays.asList(UserIds)); + for (String userId : UserIds) { + EpRoleNotificationItem roleNotifItem = new EpRoleNotificationItem(); + for (EPUser user : users) { + if (user.getOrgUserId().equals(userId)) { + roleNotifItem.setRecvUserId(user.getId().intValue()); + roles.add(roleNotifItem); + break; + } + } + + } + epItem.setRoles(roles); + userNotificationService.saveNotification(epItem); + + portalResponse.setStatus(PortalRestStatusEnum.OK); + portalResponse.setMessage("processEventNotification: notification created"); + portalResponse.setResponse("NotificationId is :" + epItem.notificationId); + } catch (Exception ex) { + portalResponse.setStatus(PortalRestStatusEnum.ERROR); + response.setStatus(400); + portalResponse.setMessage(ex.toString()); + } + return portalResponse; + } + + /** + * Validates that mandatory fields are present. + * + * @param ticketEventNotif + * @return Error message if a problem is found; null if all is well. + */ + private String validateTicketEventMessage(JsonNode ticketEventNotif) { + JsonNode application = ticketEventNotif.get("application"); + JsonNode event = ticketEventNotif.get("event"); + JsonNode header = event.get("header"); + JsonNode body = event.get("body"); + JsonNode SubscriberInfo = ticketEventNotif.get("SubscriberInfo"); + if (application == null) + return "application is mandatory"; + if (body == null) + return "body is mandatory"; + if (body.get("assetID") == null) + return "Asset Id is mandatory"; + if (body.get("eventDate") == null) + return "Event Date is mandatory"; + if (header.get("eventSource") == null) + return "Message Source is mandatory"; + if (SubscriberInfo.get("UserList") == null) + return "At least one user Id is mandatory"; + return null; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserNotificationController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserNotificationController.java new file mode 100644 index 00000000..777fb91d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserNotificationController.java @@ -0,0 +1,216 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompAppRole; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.FunctionalMenuService; +import org.openecomp.portalapp.portal.service.UserNotificationService; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.EpNotificationItemVO; +import org.openecomp.portalapp.portal.transport.EpRoleNotificationItem; +import org.openecomp.portalapp.portal.transport.FunctionalMenuRole; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.util.EPUserUtils; + +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class UserNotificationController extends EPRestrictedBaseController { + + @Autowired + FunctionalMenuService functionalMenuService; + + @Autowired + UserNotificationService userNotificationService; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserNotificationController.class); + + @RequestMapping(value = { + "/portalApi/getFunctionalMenuRole" }, method = RequestMethod.GET, produces = "application/json") + public List getMenuIdRoleId(HttpServletRequest request, HttpServletResponse response) { + // EPUser user = EPUserUtils.getUserSession(request); + List menuRoleList = null; + menuRoleList = functionalMenuService.getFunctionalMenuRole(); + return menuRoleList; + } + + @RequestMapping(value = { + "/portalApi/getNotifications" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getNotifications(HttpServletRequest request, + HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + PortalRestResponse> portalRestResponse = null; + try { + List notificationList = userNotificationService.getNotifications(user.getId()); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.OK, "success", + notificationList); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAllAppsAndContacts failed", e); + portalRestResponse = new PortalRestResponse>(PortalRestStatusEnum.ERROR, + e.getMessage(), null); + } + return portalRestResponse; + } + + @RequestMapping(value = { + "/portalApi/getAdminNotifications" }, method = RequestMethod.GET, produces = "application/json") + public List getAdminNotifications(HttpServletRequest request, HttpServletResponse response) { + List adminNotificationList = null; + adminNotificationList = userNotificationService.getAdminNotificationVOS(); + return adminNotificationList; + } + + @RequestMapping(value = "/portalApi/saveNotification", method = RequestMethod.POST, produces = "application/json") + public PortalRestResponse save(HttpServletRequest request, HttpServletResponse response, + @RequestBody EpNotificationItem notificationItem) { + + if (notificationItem == null || notificationItem.getMsgHeader() == null) + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "Notification Header cannot be null or empty"); + if (notificationItem.getEndTime().compareTo(notificationItem.getStartTime()) < 0) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "End Time should be greater than start time"); + } + + if ((notificationItem.getIsForAllRoles() == "N") && notificationItem.getRoleIds().isEmpty()) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", + "No Roles Ids Exist for the selected Roles"); + } + + Long creatorId = UserUtils.getUserIdAsLong(request); + notificationItem.setCreatorId(creatorId); + + // Front-end date picker does not accept a time value, so all + // values are the start of the chosen day in the local time zone. + // Move the end time value to the very end of the chosen day. + // Avoid Calendar.getDefault() which uses the server's locale. + Long endTime = notificationItem.getEndTime().getTime(); + endTime += (23 * 3600 + 59 * 60 + 59) * 1000; + notificationItem.getEndTime().setTime(endTime); + + try { + userNotificationService.saveNotification(notificationItem); + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + @RequestMapping(value = { + "/portalApi/notificationUpdateRate" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> getNotificationUpdateRate(HttpServletRequest request) { + try { + String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.NOTIFICATION_UPDATE_RATE); + String updateDuration = SystemProperties.getProperty(EPCommonSystemProperties.NOTIFICATION_UPDATE_DURATION); + Integer rateInMiliSec = Integer.valueOf(updateRate) * 1000; + Integer durationInMiliSec = Integer.valueOf(updateDuration) * 1000; + Map results = new HashMap(); + results.put("updateRate", String.valueOf(rateInMiliSec)); + results.put("updateDuration", String.valueOf(durationInMiliSec)); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getNotificationUpdateRate failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + @RequestMapping(value = { + "/portalApi/notificationRead" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse> notificationRead( + @RequestParam("notificationId") String notificationID, HttpServletRequest request) { + try { + userNotificationService.setNotificationRead(Long.parseLong(notificationID), UserUtils.getUserId(request)); + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", null); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "notificationRead failed", e); + return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null); + } + } + + @RequestMapping(value = { + "/portalApi/getNotificationHistory" }, method = RequestMethod.GET, produces = "application/json") + public List getNotificationHistory(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List notificationList = null; + notificationList = userNotificationService.getNotificationHistoryVO(user.getId()); + return notificationList; + } + + @RequestMapping(value = { "/portalApi/notificationRole/{notificationId}/roles" }, method = { + RequestMethod.GET }, produces = "application/json") + public List testGetRoles(HttpServletRequest request, @PathVariable("notificationId") Long notificationId) { + List NotifRoles = userNotificationService.getNotificationRoles(notificationId); + ArrayList rolesList = new ArrayList(); + for (EpRoleNotificationItem notifRole : NotifRoles) { + rolesList.add(notifRole.roleId); + } + return rolesList; + } + + @RequestMapping(value = { "/portalApi/getNotificationAppRoles" }, method = { + RequestMethod.GET }, produces = "application/json") + public List getNotificationAppRoles(HttpServletRequest request, HttpServletResponse response) { + List epAppRoleList = null; + try { + epAppRoleList = userNotificationService.getAppRoleList(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while performing UserNofiticationController.getNotificationAppRoles. Details: ", + e); + } + return epAppRoleList; + } + + @RequestMapping(value = { + "/portalApi/getMessageRecipients" }, method = RequestMethod.GET, produces = "application/json") + public List getMessageRecipients(@RequestParam("notificationId") Long notificationID) { + // EPUser user = EPUserUtils.getUserSession(request); + List messageUserRecipients = null; + messageUserRecipients = userNotificationService.getMessageRecipients(notificationID); + return messageUserRecipients; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserRolesController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserRolesController.java new file mode 100644 index 00000000..719b7d45 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/UserRolesController.java @@ -0,0 +1,435 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.cxf.transport.http.HTTPException; +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserAppCatalogRoles; +import org.openecomp.portalapp.portal.domain.EcompAuditLog; +import org.openecomp.portalapp.portal.domain.ExternalSystemAccess; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.AdminRolesService; +import org.openecomp.portalapp.portal.service.ApplicationsRestClientService; +import org.openecomp.portalapp.portal.service.SearchService; +import org.openecomp.portalapp.portal.service.UserRolesService; +import org.openecomp.portalapp.portal.transport.AppNameIdIsAdmin; +import org.openecomp.portalapp.portal.transport.AppWithRolesForUser; +import org.openecomp.portalapp.portal.transport.AppsListWithAdminRole; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.RoleInAppForUser; +import org.openecomp.portalapp.portal.transport.UserApplicationRoles; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.domain.AuditLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.restful.domain.EcompRole; +import org.openecomp.portalsdk.core.service.AuditService; +import org.openecomp.portalsdk.core.service.RoleService; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class UserRolesController extends EPRestrictedBaseController { + + @Autowired + SearchService searchService; + @Autowired + AdminRolesService adminRolesService; + @Autowired + UserRolesService userRolesService; + @Autowired + ApplicationsRestClientService applicationsRestClientService; + @Autowired + RoleService roleService; + @Autowired + AuditService auditService; + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserRolesController.class); + + static final String FAILURE = "failure"; + + /** + * RESTful service method to fetch users in the WebPhone external service + * + * @return array of found users as json + */ + @RequestMapping(value = { "/portalApi/queryUsers" }, method = RequestMethod.GET, produces = "application/json") + public String getPhoneBookSearchResult(HttpServletRequest request, @RequestParam("search") String searchString, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + String searchResult = null; + if (!adminRolesService.isSuperAdmin(user) && !adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getPhoneBookSearchResult"); + } else { + searchString = searchString.trim(); + if (searchString.length() > 2) { + searchResult = searchService.searchUsersInPhoneBook(searchString); + } else { + logger.info(EELFLoggerDelegate.errorLogger, "getPhoneBookSearchResult - too short search string: " + searchString); + } + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/queryUsers", "result =", searchResult); + + return searchResult; + } + + /** + * RESTful service method to fetch applications where user is admin + * + * @return for GET: array of all applications with boolean isAdmin=true/false for each application + */ + @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { RequestMethod.GET }, produces = "application/json") + public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, + HttpServletResponse response) { + + EPUser user = EPUserUtils.getUserSession(request); + AppsListWithAdminRole result = null; + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getAppsWithAdminRoleStateForUser"); + } else { + if (EcompPortalUtils.legitimateUserId(orgUserId)) { + result = adminRolesService.getAppsWithAdminRoleStateForUser(orgUserId); + } else { + logger.info(EELFLoggerDelegate.errorLogger, "getAppsWithAdminRoleStateForUser - parms error, no Organization User ID"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + } + } + + StringBuilder adminAppRoles = new StringBuilder(); + if(result != null && result.appsRoles.size() >= 1) { + adminAppRoles.append("User '" + result.orgUserId + "' has admin role to the apps = {"); + for(AppNameIdIsAdmin adminAppRole : result.appsRoles) { + if (adminAppRole.isAdmin) { + adminAppRoles.append(adminAppRole.appName + ", "); + } + } + adminAppRoles.append("}."); + } else { + adminAppRoles.append("User '" + result.orgUserId + "' has no Apps with Admin Role."); + } + logger.info(EELFLoggerDelegate.errorLogger, adminAppRoles.toString()); + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "get result =", result); + + return result; + } + + @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { RequestMethod.PUT }, produces = "application/json") + public FieldsValidator putAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestBody AppsListWithAdminRole newAppsListWithAdminRoles, + HttpServletResponse response) { + + //newAppsListWithAdminRoles.appsRoles + FieldsValidator fieldsValidator = new FieldsValidator(); + StringBuilder newAppRoles = new StringBuilder(); + if(newAppsListWithAdminRoles != null && newAppsListWithAdminRoles.appsRoles.size() >= 1) { + newAppRoles.append("User '" + newAppsListWithAdminRoles.orgUserId + "' has admin role to the apps = { "); + for(AppNameIdIsAdmin adminAppRole : newAppsListWithAdminRoles.appsRoles) { + if (adminAppRole.isAdmin) { + newAppRoles.append(adminAppRole.appName + " ,"); + } + } + newAppRoles.deleteCharAt(newAppRoles.length()-1); + newAppRoles.append("}."); + } else { + newAppRoles.append("User '" + newAppsListWithAdminRoles.orgUserId + "' has no Apps with Admin Role."); + } + logger.info(EELFLoggerDelegate.errorLogger, newAppRoles.toString()); + + EPUser user = EPUserUtils.getUserSession(request); + boolean changesApplied = false; + + if (!adminRolesService.isSuperAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "putAppsWithAdminRoleStateForUser"); + } else { + changesApplied = adminRolesService.setAppsWithAdminRoleStateForUser(newAppsListWithAdminRoles); + AuditLog auditLog = new AuditLog(); + auditLog.setUserId(user.getId()); + auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN); + auditLog.setAffectedRecordId(newAppsListWithAdminRoles.orgUserId); + auditLog.setComments(newAppRoles.toString()); + auditService.logActivity(auditLog, null); + + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage("UserRolesController.putAppsWithAdminRoleStateForUser", + EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN, user.getOrgUserId(), newAppsListWithAdminRoles.orgUserId, newAppRoles.toString())); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "put result =", changesApplied); + + return fieldsValidator; + } + + @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { RequestMethod.GET }, produces = "application/json") + public List getAppRolesForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, @RequestParam("app") Long appid, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List result = null; + String feErrorString = ""; + if (!adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "getAppRolesForUser"); + feErrorString = EcompPortalUtils.getFEErrorString(true, response.getStatus()); + } else { + if (EcompPortalUtils.legitimateUserId(orgUserId)) { + result = userRolesService.getAppRolesForUser(appid, orgUserId); + int responseCode = EcompPortalUtils.getExternalAppResponseCode(); + if (responseCode != 0 && responseCode != 200) { + // external error + response.setStatus(responseCode); + feErrorString = EcompPortalUtils.getFEErrorString(false, responseCode); + } else if (result == null) { + // If the result is null, there was an internal ecomp error in the service call. + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + feErrorString = EcompPortalUtils.getFEErrorString(true, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } else { + logger.info(EELFLoggerDelegate.errorLogger, "getAppRolesForUser - no Organization User ID"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + feErrorString = EcompPortalUtils.getFEErrorString(true, HttpServletResponse.SC_BAD_REQUEST); + } + } + + StringBuilder sbUserApps = new StringBuilder(); + if (result!=null && result.size()>=1) { + sbUserApps.append("User '" + orgUserId + "' has Roles={"); + for(RoleInAppForUser appRole : result) { + if (appRole.isApplied) { + sbUserApps.append(appRole.roleName + ", "); + } + } + sbUserApps.append("} assigned to the appId '" + appid + "'."); + } else { + //Not sure creating an empty object will make any difference + //but would like to give it a shot for defect #DE221057 + if (result==null) { + result = new ArrayList(); + } + sbUserApps.append("User '" + orgUserId + "' and appid " + appid + " has no roles"); + } + logger.info(EELFLoggerDelegate.errorLogger, sbUserApps.toString()); + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppRoles", "get result =", result); + if (feErrorString != "") { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: FEErrorString to header: "+feErrorString); + + response.addHeader("FEErrorString", feErrorString); + response.addHeader("Access-Control-Expose-Headers", "FEErrorString"); + } + return result; + } + + @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { RequestMethod.PUT }, produces = "application/json") + public FieldsValidator putAppWithUserRoleStateForUser(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, + HttpServletResponse response) { + FieldsValidator fieldsValidator = new FieldsValidator(); + StringBuilder sbUserApps = new StringBuilder(); + if (newAppRolesForUser!=null) { + sbUserApps.append("User '" + newAppRolesForUser.orgUserId); + if (newAppRolesForUser.appRoles!=null && newAppRolesForUser.appRoles.size()>=1) { + sbUserApps.append("' has roles = { "); + for(RoleInAppForUser appRole : newAppRolesForUser.appRoles) { + if (appRole.isApplied) { + sbUserApps.append(appRole.roleName + " ,"); + } + } + sbUserApps.deleteCharAt(sbUserApps.length()-1); + sbUserApps.append("} assigned for the app " + newAppRolesForUser.appId); + } else { + sbUserApps.append("' has no roles assigned for app " + newAppRolesForUser.appId); + } + } + logger.info(EELFLoggerDelegate.applicationLogger, "putAppWithUserRoleStateForUser: {}", sbUserApps.toString()); + + EPUser user = EPUserUtils.getUserSession(request); + boolean changesApplied = false; + if (!adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, "putAppWithUserRoleStateForUser"); + } else { + changesApplied = userRolesService.setAppWithUserRoleStateForUser(user, newAppRolesForUser); + if (changesApplied){ + logger.info(EELFLoggerDelegate.applicationLogger, "putAppWithUserRoleStateForUser: succeeded for app {}, user {}", + newAppRolesForUser.appId, newAppRolesForUser.orgUserId); + AuditLog auditLog = new AuditLog(); + auditLog.setUserId(user.getId()); + auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_UPDATE_USER); + auditLog.setAffectedRecordId(newAppRolesForUser.orgUserId); + auditLog.setComments(sbUserApps.toString()); + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + auditService.logActivity(auditLog, null); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage("UserRolesController.putAppWithUserRoleStateForUser", + EcompAuditLog.CD_ACTIVITY_UPDATE_USER, user.getOrgUserId(), newAppRolesForUser.orgUserId, sbUserApps.toString())); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + } else { + logger.error(EELFLoggerDelegate.errorLogger, "putAppWithUserRoleStateForUser: failed for app {}, user {}", + newAppRolesForUser.appId, newAppRolesForUser.orgUserId); + } + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userAppRoles", "put result =", changesApplied); + return fieldsValidator; + } + + @RequestMapping(value = { "/portalApi/updateRemoteUserProfile" }, method = { RequestMethod.GET }, produces = "application/json") + public PortalRestResponse updateRemoteUserProfile(HttpServletRequest request,HttpServletResponse response) { + + String updateRemoteUserFlag = FAILURE; + try { + //saveNewUser = userService.saveNewUser(newUser); + String orgUserId = request.getParameter("loginId"); + Long appId = Long.parseLong(request.getParameter("appId")); + userRolesService.updateRemoteUserProfile(orgUserId, appId); + + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.OK, updateRemoteUserFlag, e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.ERROR, updateRemoteUserFlag, ""); + + } + + @RequestMapping(value = { "/portalApi/app/{appId}/users" }, method = { RequestMethod.GET }, produces = "application/json") + public List getUsersFromAppEndpoint(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { + try { + logger.debug(EELFLoggerDelegate.debugLogger, "/portalApi/app/{}/users was invoked", appId); + List appUsers = userRolesService.getUsersFromAppEndpoint(appId); + return appUsers; + } catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing UserRolesController.getUsersFromAppEndpoint. Details: " + EcompPortalUtils.getStackTrace(e)); + return new ArrayList(); + } + } + + @RequestMapping(value = { "/portalApi/app/{appId}/roles" }, method = { RequestMethod.GET }, produces = "application/json") + public List testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { + EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, appId, "/roles"); + List rolesList = Arrays.asList(appRoles); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/app/{appId}/roles", "response for appId=" + appId, rolesList); + + return rolesList; + } + + @RequestMapping(value = { "/portalApi/admin/import/app/{appId}/roles" }, method = { RequestMethod.GET }, produces = "application/json") + public List importRolesFromRemoteApplication(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { + List rolesList = userRolesService.importRolesFromRemoteApplication(appId); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/admin/import/app/{appId}/roles", "response for appId=" + appId, rolesList); + + return rolesList; + } + + @RequestMapping(value = { "/portalApi/app/{appId}/user/{orgUserId}/roles" }, method = { RequestMethod.GET }, produces = "application/json") + public EcompRole testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId, @PathVariable("orgUserId") String orgUserId) throws Exception { + if (!EcompPortalUtils.legitimateUserId(orgUserId)) { + String msg = "Error /user//roles not legitimate orgUserId = " + orgUserId; + logger.error(EELFLoggerDelegate.errorLogger, msg); + throw new Exception(msg); + } + EcompRole[] roles = applicationsRestClientService.get(EcompRole[].class, appId, String.format("/user/%s/roles", orgUserId)); + if (roles.length != 1) { + String msg = "Error /user//roles returned array. expected size 1 recieved size = " + roles.length; + logger.error(EELFLoggerDelegate.errorLogger, msg); + throw new Exception(msg); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/app/{appId}/user/{orgUserId}/roles", "response for appId='" + appId + "' and orgUserId='" + orgUserId + "'", roles[0]); + return roles[0]; + } + + @RequestMapping(value = { "/portalApi/saveUserAppRoles" }, method = { RequestMethod.PUT }, produces = "application/json") + public FieldsValidator putAppWithUserRoleRequest(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, + HttpServletResponse response) { + FieldsValidator fieldsValidator = null; + try { + + EPUser user = EPUserUtils.getUserSession(request); + fieldsValidator = userRolesService.putUserAppRolesRequest(newAppRolesForUser, user); + response.setStatus(fieldsValidator.httpStatusCode.intValue()); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putAppWithUserRoleRequest failed", e); + + } + // return fieldsValidator; + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/saveUserAppRoles", "PUT result =", + response.getStatus()); + return fieldsValidator; + } + + @RequestMapping(value = { "/portalApi/appCatalogRoles" }, method = { + RequestMethod.GET }, produces = "application/json") + public List getUserAppCatalogRoles(HttpServletRequest request, + @RequestParam("appName") String appName) { + EPUser user = EPUserUtils.getUserSession(request); + List userAppRoleList = null; + try { + userAppRoleList = userRolesService.getUserAppCatalogRoles(user, appName); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "putUserWidgetsSortPref failed", e); + + } + Collections.sort(userAppRoleList, getUserAppCatalogRolesComparator); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/userApplicationRoles", "result =", userAppRoleList); + + return userAppRoleList; + + } + private Comparator getUserAppCatalogRolesComparator = new Comparator() { + public int compare(EPUserAppCatalogRoles o1, EPUserAppCatalogRoles o2) { + return o1.getRolename().compareTo(o2.getRolename()); + } + }; + + @RequestMapping(value = "/portalApi/externalRequestAccessSystem", method = RequestMethod.GET, produces = "application/json") + public ExternalSystemAccess readExternalRequestAccess(HttpServletRequest request) { + ExternalSystemAccess result = null; + try { + result = userRolesService.getExternalRequestAccess(); + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/externalRequestAccessSystem", "GET result =", result); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger,"readExternalRequestAccess failed: " + e.getMessage()); + } + return result; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java new file mode 100644 index 00000000..f1d77a3f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java @@ -0,0 +1,157 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.openecomp.portalapp.controller.EPRestrictedRESTfulBaseController; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EcompAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.AppsCacheService; +import org.openecomp.portalapp.portal.transport.Analytics; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.crossapi.PortalAPIResponse; +import org.openecomp.portalsdk.core.service.AuditService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping(PortalConstants.REST_AUX_API) +@Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseController{ + + private static final String APP_KEY = "uebkey"; + + @Autowired + AuditService auditService; + + @Autowired + AppsCacheService appCacheService; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebAnalyticsExtAppController.class); + + protected boolean isAuxRESTfulCall() { + return true; + } + + /* + * Answers requests from partner applications for a file that is expected to + * contain javascript to support web analytics. + * + * @param request + * @return + * @throws Exception + */ + @ApiOperation(value = "Gets javascript with functions that support gathering and reporting web analytics.", response = String.class) + @RequestMapping(value = { "/analytics" }, method = RequestMethod.GET, produces = "application/javascript") + public String getAnalyticsScript(HttpServletRequest request) throws Exception { + String responseText = ""; + final String fileName = "analytics.txt"; + InputStream analyticsFileStream = null; + try { + analyticsFileStream = this.getClass().getClassLoader().getResourceAsStream(fileName); + responseText = IOUtils.toString(analyticsFileStream, StandardCharsets.UTF_8.name()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Error reading contents of the file " + fileName, e); + } finally { + if (analyticsFileStream != null) + analyticsFileStream.close(); + } + + String feURLContext = SystemProperties.getProperty("frontend_url"); + String feURL = feURLContext.substring(0, feURLContext.lastIndexOf('/')); + + responseText = responseText.replace("PORTAL_ENV_URL", feURL); + return responseText; + } + + /** + * Accepts data from partner applications with web analytics data. + * + * @param request + * @param analyticsMap + * @param response + * @return + * @throws Exception + */ + @RequestMapping(value = { "/storeAnalytics" }, method = RequestMethod.POST, produces = "application/json") + @ResponseBody + @ApiOperation(value = "Accepts data from partner applications with web analytics data.", response = PortalAPIResponse.class) + public PortalAPIResponse storeAnalyticsScript(HttpServletRequest request, @RequestBody Analytics analyticsMap) throws Exception { + try{ + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC()); + String appName = ""; + try { + + String appKeyValue = request.getHeader(APP_KEY); + if(appKeyValue == null || appKeyValue.equals("")) { + logger.error(EELFLoggerDelegate.errorLogger, " App Key unavailable; Proceeding with null app name"); + } else { + EPApp appRecord = appCacheService.getAppForAnalytics(appKeyValue); + if(appRecord == null){ + logger.error(EELFLoggerDelegate.errorLogger, " App could not be found for the key "+ appKeyValue); + } + else appName = appRecord.getName(); + + } + + } catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, " Error retrieving Application to capture app name for analytics; Proceeding with empty app name"); + } + + + + logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatStoreAnalyticsAuditLogMessage(analyticsMap.getUserId(),appName, "WebAnalyticsExtAppController.postWebAnalyticsData", + EcompAuditLog.CD_ACTIVITY_STORE_ANALYTICS, analyticsMap.getAction(),analyticsMap.getPage(),analyticsMap.getFunction(),analyticsMap.getType())); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + + PortalAPIResponse response = new PortalAPIResponse(true, "success"); + return response; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "storeAnalytics failed", e); + PortalAPIResponse response = new PortalAPIResponse(true, "error"); + return response; + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java new file mode 100644 index 00000000..f69a6484 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java @@ -0,0 +1,376 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.MicroserviceParameter; +import org.openecomp.portalapp.portal.domain.WidgetCatalog; +import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter; +import org.openecomp.portalapp.portal.domain.WidgetParameterResult; +import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.ConsulHealthService; +import org.openecomp.portalapp.portal.service.MicroserviceService; +import org.openecomp.portalapp.portal.service.WidgetParameterService; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +@SuppressWarnings("unchecked") +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class WidgetsCatalogController extends EPRestrictedBaseController { + + private static final String HTTPS = "https://"; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogController.class); + RestTemplate template = new RestTemplate(); + String whatService = "widgets-service"; + + @Autowired + private ConsulHealthService consulHealthService; + + @Autowired + private MicroserviceService microserviceService; + + @Autowired + private WidgetParameterService widgetParameterService; + + @Bean + public CommonsMultipartResolver multipartResolver() { + return new CommonsMultipartResolver(); + } + + static { + // for localhost testing only + javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() { + + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + if (hostname.equals("localhost")) { + return true; + } + return false; + } + }); + } + + @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{loginName}" }, method = RequestMethod.GET) + public List getUserWidgetCatalog(HttpServletRequest request, HttpServletResponse response, + @PathVariable("loginName") String loginName) throws RestClientException, Exception { + List widgets = new ArrayList<>(); + try { + ResponseEntity ans = template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/" + loginName, + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), ArrayList.class); + widgets = ans.getBody(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserWidgetCatalog failed", e); + // returning null because null help check on the UI if there was a + // communication problem with Microservice. + return null; + } + return widgets; + } + + @RequestMapping(value = { "/portalApi/microservices/widgetCatalog" }, method = RequestMethod.GET) + public List getWidgetCatalog(HttpServletRequest request, HttpServletResponse response) + throws RestClientException, Exception { + List widgets = new ArrayList<>(); + try { + ResponseEntity ans = template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog", + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), ArrayList.class); + widgets = ans.getBody(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getWidgetCatalog failed", e); + // returning null because null help check on the UI if there was a + // communication problem with Microservice. + return null; + } + return widgets; + } + + @RequestMapping(value = { + "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.PUT, produces = "application/json") + public void updateWidgetCatalog(HttpServletRequest request, HttpServletResponse response, + @RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId) + throws RestClientException, Exception { + template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/" + widgetId, + HttpMethod.PUT, new HttpEntity(newWidgetCatalog, WidgetServiceHeaders.getInstance()), String.class); + } + + @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.DELETE) + public void deleteOnboardingWidget(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/" + widgetId, + HttpMethod.DELETE, new HttpEntity(WidgetServiceHeaders.getInstance()), String.class); + } + + @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.POST) + public String updateWidgetCatalogWithFiles(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + MultipartHttpServletRequest mRequest; + MultiValueMap multipartRequest = new LinkedMultiValueMap<>(); + String fileName; + String tmp_folder = "/tmp/"; + String respond = null; + FileOutputStream fo = null; + try { + mRequest = (MultipartHttpServletRequest) request; + MultipartFile mFile = mRequest.getFile("file"); + fileName = mFile.getOriginalFilename(); + fo = new FileOutputStream(tmp_folder + fileName); + fo.write(mFile.getBytes()); + + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.MULTIPART_FORM_DATA); + multipartRequest.add("file", new FileSystemResource(tmp_folder + fileName)); + multipartRequest.add("widget", request.getParameter("newWidget")); + respond = template.postForObject( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/" + widgetId, + new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); + File f = new File(tmp_folder + fileName); + f.delete(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateWidgetCatalogWithFiles failed", e); + } finally { + try { + if (fo != null) + fo.close(); + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateWidgetCatalogWithFiles failed 2", e); + } + } + return respond; + } + + @RequestMapping(value = { "/portalApi/microservices/widgetCatalog" }, method = RequestMethod.POST) + public String createWidgetCatalog(HttpServletRequest request, HttpServletResponse response) + throws RestClientException, Exception { + MultipartHttpServletRequest mRequest; + MultiValueMap multipartRequest = new LinkedMultiValueMap<>(); + String fileName; + String tmp_folder = "/tmp/"; + String respond = null; + FileOutputStream fo = null; + try { + mRequest = (MultipartHttpServletRequest) request; + MultipartFile mFile = mRequest.getFile("file"); + fileName = mFile.getOriginalFilename(); + fo = new FileOutputStream(tmp_folder + fileName); + fo.write(mFile.getBytes()); + + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.MULTIPART_FORM_DATA); + multipartRequest.add("file", new FileSystemResource(tmp_folder + fileName)); + multipartRequest.add("widget", request.getParameter("newWidget")); + + respond = template.postForObject( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog", + new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); + File f = new File(tmp_folder + fileName); + f.delete(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "createWidgetCatalog failed", e); + } finally { + try { + if (fo != null) + fo.close(); + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "createWidgetCatalog failed 2", e); + } + } + return respond; + } + + @RequestMapping(value = "/portalApi/microservices/{widgetId}/framework.js", method = RequestMethod.GET) + public String getWidgetFramework(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + return template.getForObject(HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/" + widgetId + "/framework.js", String.class, + WidgetServiceHeaders.getInstance()); + } + + @RequestMapping(value = "/portalApi/microservices/{widgetId}/controller.js", method = RequestMethod.GET) + public String getWidgetController(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + return template.getForObject(HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/" + widgetId + "/controller.js", String.class, + WidgetServiceHeaders.getInstance()); + } + + @RequestMapping(value = "/portalApi/microservices/{widgetId}/style.css", method = RequestMethod.GET) + public String getWidgetCSS(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + return template.getForObject(HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/" + widgetId + "/styles.css", String.class, + WidgetServiceHeaders.getInstance()); + } + + @RequestMapping(value = { "/portalApi/microservices/parameters/{widgetId}" }, method = RequestMethod.GET) + public PortalRestResponse> getWidgetParameterResult(HttpServletRequest request, + HttpServletResponse response, @PathVariable("widgetId") long widgetId) throws Exception { + EPUser user = EPUserUtils.getUserSession(request); + + List list = new ArrayList<>(); + Long serviceId = template.exchange( + HTTPS + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/parameters/" + widgetId, + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class).getBody(); + if (serviceId == null) { + // return ok/sucess and no service parameter for this widget + return new PortalRestResponse>(PortalRestStatusEnum.WARN, + "No service parameters for this widget", list); + } else { + List defaultParam = microserviceService.getParametersById(serviceId); + for (MicroserviceParameter param : defaultParam) { + WidgetParameterResult user_result = new WidgetParameterResult(); + user_result.setParam_id(param.getId()); + user_result.setDefault_value(param.getPara_value()); + user_result.setParam_key(param.getPara_key()); + WidgetCatalogParameter userValue = widgetParameterService.getUserParamById(widgetId, user.getId(), + param.getId()); + if (userValue == null) + user_result.setUser_value(param.getPara_value()); + else { + user_result.setUser_value(userValue.getUser_value()); + } + list.add(user_result); + } + } + return new PortalRestResponse>(PortalRestStatusEnum.OK, "SUCCESS", list); + } + + @RequestMapping(value = { "/portalApi/microservices/services/{paramId}" }, method = RequestMethod.GET) + public List getUserParameterById(HttpServletRequest request, HttpServletResponse response, + @PathVariable("paramId") long paramId) throws Exception { + List list = widgetParameterService.getUserParameterById(paramId); + return list; + } + + @RequestMapping(value = { "/portalApi/microservices/services/{paramId}" }, method = RequestMethod.DELETE) + public void deleteUserParameterById(HttpServletRequest request, HttpServletResponse response, + @PathVariable("paramId") long paramId) throws Exception { + widgetParameterService.deleteUserParameterById(paramId); + } + + @RequestMapping(value = { "/portalApi/microservices/download/{widgetId}" }, method = RequestMethod.GET) + public void doDownload(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + + ServletContext context = request.getServletContext(); + byte[] byteFile = template.exchange(HTTPS + consulHealthService.getServiceLocation(whatService) + "/widget/microservices/download/" + widgetId, + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), byte[].class).getBody(); + String fileLocation = widgetId + ".zip"; + FileOutputStream stream = new FileOutputStream(fileLocation); + stream.write(byteFile); + stream.close(); + + File downloadFile = new File(fileLocation); + FileInputStream inputStream = new FileInputStream(downloadFile); + String mimeType = context.getMimeType(downloadFile.getPath()); + if (mimeType == null) { + mimeType = "application/octet-stream"; + } + + response.setContentType(mimeType); + response.setContentLength((int) downloadFile.length()); + String headerKey = "Content-Disposition"; + String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); + downloadFile.delete(); + response.setHeader(headerKey, headerValue); + + OutputStream outStream = response.getOutputStream(); + byte[] buffer = new byte[32 * 1024]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outStream.write(buffer, 0, bytesRead); + } + + inputStream.close(); + outStream.close(); + } + + @RequestMapping(value = { "/portalApi/microservices/parameters" }, method = RequestMethod.POST) + public PortalRestResponse saveWidgetParameter(HttpServletRequest request, HttpServletResponse response, + @RequestBody WidgetCatalogParameter widgetParameters) throws Exception { + EPUser user = EPUserUtils.getUserSession(request); + widgetParameters.setUserId(user.getId()); + try { + WidgetCatalogParameter oldParam = widgetParameterService.getUserParamById(widgetParameters.getWidgetId(), + widgetParameters.getUserId(), widgetParameters.getParamId()); + if (oldParam != null) { + widgetParameters.setId(oldParam.getId()); + } + widgetParameterService.saveUserParameter(widgetParameters); + + } catch (Exception e) { + return new PortalRestResponse(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java new file mode 100644 index 00000000..78499ef8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java @@ -0,0 +1,83 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.controller; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.controller.EPUnRestrictedBaseController; +import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.service.ConsulHealthService; + +@SuppressWarnings("unchecked") +@RestController +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogMarkupController.class); + RestTemplate template = new RestTemplate(); + String whatService = "widgets-service"; + + + @Autowired + private ConsulHealthService consulHealthService; + + @Bean + public CommonsMultipartResolver multipartResolver() { + return new CommonsMultipartResolver(); + } + + static { + //for localhost testing only + javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier( + new javax.net.ssl.HostnameVerifier(){ + + public boolean verify(String hostname, + javax.net.ssl.SSLSession sslSession) { + if (hostname.equals("localhost")) { + return true; + } + return false; + } + }); + } + + + @RequestMapping(value = "/portalApi/microservices/markup/{widgetId}", method = RequestMethod.GET) + public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + return template.getForObject("https://" + consulHealthService.getServiceLocation(whatService) + "/widget/microservices/markup/" + widgetId, String.class, + WidgetServiceHeaders.getInstance()); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApp.java new file mode 100644 index 00000000..ecf0b684 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApp.java @@ -0,0 +1,88 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class AdminUserApp implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @Column(name="USER_ID") + private Long user_Id; + + @Column(name="FIRST_NAME") + private String firstName; + + @Column(name="LAST_NAME") + private String lastName; + + @Column(name="ORG_USER_ID") + private String orgUserId; + + @Id + @Column(name="APP_ID") + private Long appId; + + @Column(name="APP_NAME") + private String appName; + + public Long getAppId() { + return appId; + } + public void setAppId(Long appId) { + this.appId = appId; + } + public Long getUser_Id() { + return user_Id; + } + public void setUserId(Long user_Id) { + this.user_Id = user_Id; + } + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public String getOrgUserId() { + return orgUserId; + } + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApplications.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApplications.java new file mode 100644 index 00000000..c90be671 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AdminUserApplications.java @@ -0,0 +1,96 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.ArrayList; +import java.util.List; + +public class AdminUserApplications { + private List apps = new ArrayList(); + + private Long user_Id; + private String firstName; + private String lastName; + private String orgUserId; + + public AdminUserApplications(AdminUserApp app) { + setUser_Id(app.getUser_Id()); + setOrgUserId(app.getOrgUserId()); + setFirstName(app.getFirstName()); + setLastName(app.getLastName()); + + addApp(app.getAppId(), app.getAppName()); + } + public Long getUser_Id() { + return user_Id; + } + public void setUser_Id(Long user_Id) { + this.user_Id = user_Id; + } + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public String getOrgUserId() { + return orgUserId; + } + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + public List getApps() { + return apps; + } + public void setApps(List apps) { + this.apps = apps; + } + public void addApp(Long otherAppId, String otherAppName) { + apps.add(new Application(otherAppId, otherAppName)); + } + + public class Application { + private Long appId; + private String appName; + + public Application(Long otherAppId, String otherAppName) { + setAppId(otherAppId); + setAppName(otherAppName); + } + public Long getAppId() { + return appId; + } + public void setAppId(Long appId) { + this.appId = appId; + } + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/App.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/App.java new file mode 100644 index 00000000..21068513 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/App.java @@ -0,0 +1,62 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +//@Entity +//@Table(name = "FN_APP") +public class App implements Serializable{ + + private static final long serialVersionUID = 1L; + + //@Id + //@Column(name = "APP_ID") + //@GeneratedValue(strategy=GenerationType.AUTO) + private Long appId; + + //@Column(name = "APP_Name") + private String appName; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUs.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUs.java new file mode 100644 index 00000000..d399c825 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppContactUs.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * Models rows in the fn_app_contact_us table added for 1610.1. + */ +public class AppContactUs extends DomainVo { + + private static final long serialVersionUID = -2742197830465055134L; + + private EPApp app; + private String description; + private String contactEmail; + private String contactName; + private String url; + private String activeYN; + + public EPApp getApp() { + return app; + } + + public void setApp(EPApp app) { + this.app = app; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContactEmail() { + return contactEmail; + } + + public void setContactEmail(String contactEmail) { + this.contactEmail = contactEmail; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getActiveYN() { + return activeYN; + } + + public void setActiveYN(String activeYN) { + this.activeYN = activeYN; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppIdAndNameTransportModel.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppIdAndNameTransportModel.java new file mode 100644 index 00000000..1440973e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppIdAndNameTransportModel.java @@ -0,0 +1,63 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class AppIdAndNameTransportModel implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @Column(name="APP_ID") + private Long id; + + @Column(name="APP_NAME") + private String name; + + @Column(name="APP_TYPE") + private Integer appType; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean isRestrictedApp() { + return (this.appType == 2 ? true : false); + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppsResponse.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppsResponse.java new file mode 100644 index 00000000..4935a22c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/AppsResponse.java @@ -0,0 +1,76 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +public class AppsResponse { + + public AppsResponse(Long id, String name, Boolean restrictedApp, Boolean enabled) { + this.index = id; + this.title = this.value = name; + this.restrictedApp = restrictedApp; + this.enabled = enabled; + } + + public Long getIndex() { + return index; + } + + public void setIndex(Long index) { + this.index = index; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // Hide the implementation of restricted and normal app from the front end. + // The json sent and received will include restrictedApp but not appType. + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + private Long index; + private String title; + private String value; + public Boolean restrictedApp; + public Boolean enabled; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BEProperty.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BEProperty.java new file mode 100644 index 00000000..e877641b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BEProperty.java @@ -0,0 +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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +public class BEProperty { + private String key; + private String value; + + public BEProperty(String key, String value){ + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BasicAuthCredentials.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BasicAuthCredentials.java new file mode 100644 index 00000000..359945ce --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/BasicAuthCredentials.java @@ -0,0 +1,95 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.List; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class BasicAuthCredentials extends DomainVo { + + private static final long serialVersionUID = 1L; + + public BasicAuthCredentials() { + + } + + private Long id; + private String applicationName; + private String username; + private String password; + private String isActive; + private List endpoints; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getIsActive() { + return isActive; + } + + public void setIsActive(String isActive) { + this.isActive = isActive; + } + + public List getEndpoints() { + return endpoints; + } + + public void setEndpoints(List endpoints) { + this.endpoints = endpoints; + } + + @Override + public String toString() { + return "BasicAuthCredentials [id=" + id + ", applicationName=" + applicationName + ", username=" + username + + ", password=" + password + ", isActive=" + isActive + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPApp.java new file mode 100644 index 00000000..1ba9e2d7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPApp.java @@ -0,0 +1,292 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import javax.persistence.Lob; + +import org.apache.commons.lang.StringUtils; +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * Model for all columns in the fn_app table. + */ +public class EPApp extends DomainVo { + + private static final long serialVersionUID = 1L; + + private String name; + private String imageUrl; + private String description; + private String notes; + private String url; + private String alternateUrl; + private String appRestEndpoint; + private String mlAppName; + private String mlAppAdminId; + private Long motsId; + private String username; + private String appPassword; + @Lob + private byte[] thumbnail; + private Boolean open; + private Boolean enabled; + private String uebTopicName; + private String uebKey; + private String uebSecret; + private Integer appType; + + private AppContactUs contactUs; + + public EPApp() { + // Attention!!! + // We set here all default values. We also place protection + // into setters for fields with default values. + // If we don't use such protection we are able to place null + // to these fields and save such fields into DB even if DB has + // default values for these fields. + this.name = ""; + this.mlAppName = ""; + this.mlAppAdminId = ""; + this.username = ""; + this.appPassword = ""; + this.open = new Boolean(false); + this.enabled = new Boolean(true); + this.uebTopicName = ""; + this.uebKey = ""; + this.uebSecret = ""; + this.appType = 1; + } + + public String getName() { + return name; + } + + public void setName(String name) { + if (StringUtils.isEmpty(name)) { + name = ""; + } + this.name = name; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public byte[] getThumbnail() { + return this.thumbnail; + } + + public void setThumbnail(byte[] thumbnail) { + this.thumbnail = thumbnail; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAlternateUrl() { + return alternateUrl; + } + + public void setAlternateUrl(String alternateUrl) { + this.alternateUrl = alternateUrl; + } + + public String getAppRestEndpoint() { + return appRestEndpoint; + } + + public void setAppRestEndpoint(String appRestEndpoint) { + this.appRestEndpoint = appRestEndpoint; + } + + public String getMlAppName() { + return mlAppName; + } + + public void setMlAppName(String mlAppName) { + if (StringUtils.isEmpty(mlAppName)) { + mlAppName = ""; + } + this.mlAppName = mlAppName; + } + + public String getMlAppAdminId() { + return mlAppAdminId; + } + + public void setMlAppAdminId(String mlAppAdminId) { + if (StringUtils.isEmpty(mlAppAdminId)) { + mlAppAdminId = ""; + } + this.mlAppAdminId = mlAppAdminId; + } + + public Long getMotsId() { + return motsId; + } + + public void setMotsId(Long motsId) { + this.motsId = motsId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getAppPassword() { + return appPassword; + } + + public void setAppPassword(String appPassword) { + if (StringUtils.isEmpty(appPassword)) { + appPassword = ""; + } + this.appPassword = appPassword; + } + + public Boolean getOpen() { + return open; + } + + public void setOpen(Boolean open) { + if (open == null) { + open = new Boolean(false); + } + this.open = open; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + if (enabled == null) { + enabled = new Boolean(true); + } + this.enabled = enabled; + } + + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + if (appType == null) { + appType = new Integer(1); + } + this.appType = appType; + } + + public void setRestrictedApp(Boolean restrictedApp) { + Integer result = 1; + if (restrictedApp) { + result = 2; + } + this.appType = result; + } + + public Boolean isRestrictedApp() { + return (this.appType == 2 ? true : false); + } + + public int compareTo(Object obj) { + Long c1 = getId(); + Long c2 = ((EPApp) obj).getId(); + + return c1.compareTo(c2); + } + + public String getUebTopicName() { + return this.uebTopicName; + } + + public void setUebTopicName(String topicName) { + if (StringUtils.isEmpty(topicName)) { + this.uebTopicName = ""; + } + this.uebTopicName = topicName; + } + + public String getUebKey() { + return this.uebKey; + } + + public void setUebKey(String uebKey) { + if (StringUtils.isEmpty(uebKey)) { + this.uebKey = ""; + } + this.uebKey = uebKey; + } + + public String getUebSecret() { + return this.uebSecret; + } + + public void setUebSecret(String uebSecret) { + if (StringUtils.isEmpty(uebSecret)) { + this.uebSecret = ""; + } + this.uebSecret = uebSecret; + } + + public AppContactUs getContactUs() { + return contactUs; + } + + public void setContactUs(AppContactUs contactUs) { + this.contactUs = contactUs; + } + + @Override + public String toString() { + String str = "[" + getId() + ":" + getName() + "]"; + return str; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpoint.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpoint.java new file mode 100644 index 00000000..85e390e6 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpoint.java @@ -0,0 +1,37 @@ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPEndpoint extends DomainVo { + + private static final long serialVersionUID = 1L; + + public EPEndpoint() { + + } + + private Long id; + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "EPEndpoint [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpointAccount.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpointAccount.java new file mode 100644 index 00000000..3d7dbd1f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPEndpointAccount.java @@ -0,0 +1,46 @@ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPEndpointAccount extends DomainVo { + + private static final long serialVersionUID = 1L; + + public EPEndpointAccount() { + + } + + private Long id; + private Long ep_id; + private Long account_id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getEp_id() { + return ep_id; + } + + public void setEp_id(Long ep_id) { + this.ep_id = ep_id; + } + + public Long getAccount_id() { + return account_id; + } + + public void setAccount_id(Long account_id) { + this.account_id = account_id; + } + + @Override + public String toString() { + return "EPEndpointAccount [id=" + id + ", ep_id=" + ep_id + ", account_id=" + account_id + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPRole.java new file mode 100644 index 00000000..ea70982a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPRole.java @@ -0,0 +1,202 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.openecomp.portalsdk.core.domain.RoleFunction; +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class EPRole extends DomainVo { + + private static final long serialVersionUID = 1L; + private String name; + private boolean active; + private Integer priority; + + // ECOMP will identify the specific remote application role id by appID;appRoleId among all the application roles it persists. + private Long appId; // used by ECOMP only + private Long appRoleId; // used by ECOMP only + + private SortedSet roleFunctions = new TreeSet(); + + private SortedSet childRoles = new TreeSet(); + + @JsonIgnore + private SortedSet parentRoles = new TreeSet(); + + public EPRole() {} + + public String getName() { + return name; + } + + public boolean getActive() { + return active; + } + + public SortedSet getRoleFunctions() { + return roleFunctions; + } + + public Integer getPriority() { + return priority; + } + + public SortedSet getChildRoles() { + return childRoles; + } + + public SortedSet getParentRoles() { + return parentRoles; + } + + public void setName(String name) { + this.name = name; + } + + public void setActive(boolean active) { + this.active = active; + } + + public void setRoleFunctions(SortedSet roleFunctions) { + this.roleFunctions = roleFunctions; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public void setChildRoles(SortedSet childRoles) { + this.childRoles = childRoles; + } + + public void setParentRoles(SortedSet parentRoles) { + this.parentRoles = parentRoles; + } + + public void addRoleFunction(RoleFunction roleFunction) { + this.roleFunctions.add(roleFunction); + } + + public void addChildRole(EPRole role) { + this.childRoles.add(role); + } + + public void addParentRole(EPRole role) { + this.parentRoles.add(role); + } + + public String getEditUrl() { + return "/role.htm?role_id=" + getId(); + } + + public String getToggleActiveImage() { + return "/static/fusion/images/" + (getActive() ? "active.png" : "inactive.png" ); + } + + public String getToggleActiveAltText() { + return getActive() ? "Click to Deactivate Role" : "Click to Activate Role"; + } + + public void removeChildRole(Long roleId) { + Iterator i = this.childRoles.iterator(); + + while (i.hasNext()) { + EPRole childRole = (EPRole)i.next(); + if (childRole.getId().equals(roleId)) { + this.childRoles.remove(childRole); + break; + } + } + } + + public void removeParentRole(Long roleId) { + Iterator i = this.parentRoles.iterator(); + + while (i.hasNext()) { + EPRole parentRole = (EPRole)i.next(); + if (parentRole.getId().equals(roleId)) { + this.parentRoles.remove(parentRole); + break; + } + } + } + + public void removeRoleFunction(String roleFunctionCd) { + Iterator i = this.roleFunctions.iterator(); + + while (i.hasNext()) { + RoleFunction roleFunction = (RoleFunction)i.next(); + if (roleFunction.getCode().equals(roleFunctionCd)) { + this.roleFunctions.remove(roleFunction); + break; + } + } + } + + public int compareTo(Object obj){ + EPRole other = (EPRole)obj; + + if(this.appId == null) + if(other.getAppId() == null) + return compareByName(other); //equal + else + return -1; + else // this.appId != null + if(other.getAppId() == null) + return 1; // appId != null, but others is null + else{ + int appIdCompareResult = appId.compareTo(other.getAppId()); + return appIdCompareResult == 0? compareByName(other) : appIdCompareResult; + } + } + + private int compareByName(EPRole other) { + String c1 = getName(); + String c2 = other.getName(); + + return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2); + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public Long getAppRoleId() { + return appRoleId; + } + + public void setAppRoleId(Long appRoleId) { + this.appRoleId = appRoleId; + } + + @Override + public String toString() { + return "[Id = " + id + ", name = " + name + "]"; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUser.java new file mode 100644 index 00000000..3a52ffc3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUser.java @@ -0,0 +1,650 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.Date; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.openecomp.portalapp.portal.utils.PortalConstants; +import org.openecomp.portalsdk.core.domain.User; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class EPUser extends User { + + private Long orgId; + private Long managerId; + private String firstName; + private String middleInitial; + private String lastName; + private String phone; + private String fax; + private String cellular; + private String email; + private Long addressId; + private String alertMethodCd; + private String hrid; + private String orgUserId; + private String orgCode; + private String address1; + private String address2; + private String city; + private String state; + private String zipCode; + private String country; + private String orgManagerUserId; + private String locationClli; + private String businessCountryCode; + private String businessCountryName; + private String businessUnit; + private String businessUnitName; + private String department; + private String departmentName; + private String companyCode; + private String company; + private String zipCodeSuffix; + private String jobTitle; + private String commandChain; + private String siloStatus; + private String costCenter; + private String financialLocCode; + + + + private String loginId; + private String loginPwd; + private Date lastLoginDate; + private boolean active; + private boolean internal; + private Long selectedProfileId; + private Long timeZoneId; + private boolean online; + private String chatId; + + private static final long serialVersionUID = 1L; + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class); + private static final String ECOMP_PORTAL_NAME = "ECOMP"; + private boolean isGuest = false; + + private SortedSet userApps = new TreeSet(); + private SortedSet pseudoRoles = new TreeSet(); + + public EPUser() {} + + public Long getAddressId() { + return addressId; + } + + public String getAlertMethodCd() { + return alertMethodCd; + } + + public String getCellular() { + return cellular; + } + + public String getEmail() { + return email; + } + + public String getFax() { + return fax; + } + + public String getFirstName() { + return firstName; + } + + public String getHrid() { + return hrid; + } + + public Date getLastLoginDate() { + return lastLoginDate; + } + + public String getLastName() { + return lastName; + } + + @JsonIgnore + public String getFullName() { + return getFirstName() + " " + getLastName(); + } + + public String getLoginId() { + return loginId; + } + + public String getLoginPwd() { + return loginPwd; + } + + public Long getManagerId() { + return managerId; + } + + public String getMiddleInitial() { + return middleInitial; + } + + public String getOrgCode() { + return orgCode; + } + + public Long getOrgId() { + return orgId; + } + + public String getPhone() { + return phone; + } + + public String getOrgUserId() { + return orgUserId; + } + + public boolean getActive() { + return active; + } + + public boolean getInternal() { + return internal; + } + + public String getAddress1() { + return address1; + } + + public String getAddress2() { + return address2; + } + + public String getCity() { + return city; + } + + public String getCountry() { + return country; + } + + public String getState() { + return state; + } + + public String getZipCode() { + return zipCode; + } + + public String getBusinessCountryCode() { + return businessCountryCode; + } + + public String getCommandChain() { + return commandChain; + } + + public String getCompany() { + return company; + } + + public String getCompanyCode() { + return companyCode; + } + + public String getDepartment() { + return department; + } + + public String getJobTitle() { + return jobTitle; + } + + public String getLocationClli() { + return locationClli; + } + + public String getOrgManagerUserId() { + return orgManagerUserId; + } + + public String getZipCodeSuffix() { + return zipCodeSuffix; + } + + public String getBusinessCountryName() { + return businessCountryName; + } + + public Long getSelectedProfileId() { + return selectedProfileId; + } + + public void setAddressId(Long addressId) { + this.addressId = addressId; + } + + public void setAlertMethodCd(String alertMethodCd) { + this.alertMethodCd = alertMethodCd; + } + + public void setCellular(String cellular) { + this.cellular = cellular; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setFax(String fax) { + this.fax = fax; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public void setHrid(String hrid) { + this.hrid = hrid; + } + + public void setLastLoginDate(Date lastLoginDate) { + this.lastLoginDate = lastLoginDate; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public void setLoginPwd(String loginPwd) { + this.loginPwd = loginPwd; + } + + public void setManagerId(Long managerId) { + this.managerId = managerId; + } + + public void setMiddleInitial(String middleInitial) { + this.middleInitial = middleInitial; + } + + public void setOrgCode(String orgCode) { + this.orgCode = orgCode; + } + + public void setOrgId(Long orgId) { + this.orgId = orgId; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + + public void setActive(boolean active) { + this.active = active; + } + + public void setInternal(boolean internal) { + this.internal = internal; + } + + public void setAddress1(String address1) { + this.address1 = address1; + } + + public void setAddress2(String address2) { + this.address2 = address2; + } + + public void setCity(String city) { + this.city = city; + } + + public void setCountry(String country) { + this.country = country; + } + + public void setState(String state) { + this.state = state; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + public void setBusinessCountryCode(String businessCountryCode) { + this.businessCountryCode = businessCountryCode; + } + + public void setCommandChain(String commandChain) { + this.commandChain = commandChain; + } + + public void setCompany(String company) { + this.company = company; + } + + public void setCompanyCode(String companyCode) { + this.companyCode = companyCode; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setJobTitle(String jobTitle) { + this.jobTitle = jobTitle; + } + + public void setLocationClli(String locationClli) { + this.locationClli = locationClli; + } + + public void setOrgManagerUserId(String orgManagerUserId) { + this.orgManagerUserId = orgManagerUserId; + } + + public void setZipCodeSuffix(String zipCodeSuffix) { + this.zipCodeSuffix = zipCodeSuffix; + } + + public void setBusinessCountryName(String businessCountryName) { + this.businessCountryName = businessCountryName; + } + + public SortedSet getPseudoRoles() { + return pseudoRoles; + } + + public void setPseudoRoles(SortedSet pseudoRoles) { + this.pseudoRoles = pseudoRoles; + } + + public void setSelectedProfileId(Long selectedProfileId) { + this.selectedProfileId = selectedProfileId; + } + + public Long getTimeZoneId() { + return timeZoneId; + } + + public void setTimeZoneId(Long timeZoneId) { + this.timeZoneId = timeZoneId; + } + + public String getBusinessUnit() { + return businessUnit; + } + + public void setBusinessUnit(String businessUnit) { + this.businessUnit = businessUnit; + } + + public String getSiloStatus() { + return siloStatus; + } + + public void setSiloStatus(String siloStatus) { + this.siloStatus = siloStatus; + } + + public String getCostCenter() { + return costCenter; + } + + public void setCostCenter(String costCenter) { + this.costCenter = costCenter; + } + + public String getFinancialLocCode() { + return financialLocCode; + } + + public void setFinancialLocCode(String financialLocCode) { + this.financialLocCode = financialLocCode; + } + + public String getBusinessUnitName() { + return businessUnitName; + } + + public void setBusinessUnitName(String businessUnitName) { + this.businessUnitName = businessUnitName; + } + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public int compareTo(Object obj){ + EPUser user = (EPUser)obj; + + String c1 = getLastName() + getFirstName() + getMiddleInitial(); + String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial(); + + return c1.compareTo(c2); + } + + public boolean isOnline() { + return online; + } + + public void setOnline(boolean online) { + this.online = online; + } + + public String getChatId() { + return chatId; + } + + public void setChatId(String chatId) { + this.chatId = chatId; + } + + + public void setPseudoEPRoles(SortedSet pseudoRoles) { + this.pseudoRoles = pseudoRoles; + } + + public SortedSet getEPUserApps() { + return userApps; + } + + public void setEPUserApps(SortedSet userApps) { + this.userApps = userApps; + } + + public void addUserApp(EPUserApp userApp) { + userApps.add(userApp); + } + + public void addAppRoles(EPApp app, SortedSet roles) { + if (roles != null) { + // add all + SortedSet userApps = new TreeSet(); + // this.userApps.removeAll(this.userApps); + Iterator itr = roles.iterator(); + while (itr.hasNext()) { + EPRole role = (EPRole) itr.next(); + EPUserApp userApp = new EPUserApp(); + userApp.setUserId(this.id); + userApp.setApp(app); + userApp.setRole(role); + userApps.add(userApp); + } + setEPUserApps(userApps); + } else { + // remove all + setEPUserApps(null); + } + + } + + public SortedSet getAppEPRoles(EPApp app) { + + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName()); + + SortedSet roles = new TreeSet(); + SortedSet userAppRoles = getEPUserApps(); + + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = ", userAppRoles.size()); + + Iterator userAppRolesIterator = userAppRoles.iterator(); + EPUserApp userAppRole = null; + // getting default app + while (userAppRolesIterator.hasNext()) { + EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next(); + if (tempUserApp.getApp().getId().equals(app.getId())) { + + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName()); + + userAppRole = tempUserApp; + + EPRole role = userAppRole.getRole(); + if(role.getActive()){ + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName()); + roles.add((EPRole) role); + } + else{ + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName()); + } + } + } + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = ", roles.size()); + + return roles; + } + + + /** + * Attention! Not for use in ECOMP + */ + public SortedSet getAppRoles(EPApp app) { + SortedSet roles = new TreeSet(); + SortedSet apps = getEPUserApps(); + Iterator appsItr = apps.iterator(); + EPUserApp userApp = null; + // getting default app + while (appsItr.hasNext()) { + EPUserApp tempUserApp = (EPUserApp) appsItr.next(); + if (tempUserApp.getApp().getId().equals(app.getId())) { + userApp = tempUserApp; + roles.add((EPRole) userApp.getRole()); + } + } + return roles; + } + + + + /** + * Attention! Not for use in ECOMP + */ + public SortedSet getEPRoles() { + EPApp app = new EPApp(); + app.setId(new Long(PortalConstants.PORTAL_APP_ID)); + app.setName(ECOMP_PORTAL_NAME); + return getAppEPRoles(app); + } + + /** + * Attention! Not for use in ECOMP + */ + public void setEPRoles(SortedSet roles) { + EPApp app = new EPApp(); + app.setId(new Long(PortalConstants.PORTAL_APP_ID)); + app.setName(ECOMP_PORTAL_NAME); + addAppRoles(app, roles); + } + + /** + * Attention! Not for use in ECOMP + */ + public void removeEPRole(Long roleId) { + SortedSet apps = getEPUserApps(); + Iterator appsItr = apps.iterator(); + // getting default app + while (appsItr.hasNext()) { + EPUserApp tempUserApp = (EPUserApp) appsItr.next(); + if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) { + appsItr.remove(); + } + } + } + + /** + * Attention! Not for use in ECOMP + */ + public void addEPRole(EPRole role) { + if (role != null) { + SortedSet roles = getEPRoles(); + if (roles == null) { + roles = new TreeSet(); + } + roles.add(role); + setEPRoles(roles); + } + } + + public boolean isGuest() { + return isGuest; + } + + public void setGuest(boolean isGuest) { + this.isGuest = isGuest; + } + + @Override + public String toString() { + return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial=" + + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular=" + + cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd + + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1 + + ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode + + ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli + + ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName + + ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department=" + + department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company=" + + company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain=" + + commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode=" + + financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate=" + + lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId=" + + selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId + + ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]"; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserApp.java new file mode 100644 index 00000000..9ed62d8b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserApp.java @@ -0,0 +1,119 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + + +@SuppressWarnings("rawtypes") +public class EPUserApp implements java.io.Serializable, Comparable { + + private static final long serialVersionUID = 1L; + + private Long userId; + private EPApp app; + private EPRole role; + private Short priority; + + public EPUserApp() { + } + + public Long getAppId() { + return this.getApp().getId(); + } + + public Long getRoleId() { + return (role == null) ? null : role.getId(); + } + + public Long getAppRoleId() { + return (role.getAppRoleId() == null) ? null : role.getAppRoleId(); + } + + @Override + public String toString() { + String str = "[u: "+getUserId()+"; a: "+getAppId()+", r: "+getRoleId()+"; appRoleId: "+getAppRoleId()+"]"; + return str; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long id) { + this.userId = id; + } + + public EPApp getApp() { + return app; + } + + public void setApp(EPApp app) { + this.app = app; + } + + public EPRole getRole() { + return role; + } + + public void setRole(EPRole role) { + this.role = role; + } + + public Short getPriority() { + return this.priority; + } + + public void setPriority(Short priority) { + this.priority = priority; + } + + public boolean equals(Object other) { + if ((this == other)) + return true; + if ((other == null)) + return false; + if (!(other instanceof EPUserApp)) + return false; + EPUserApp castOther = (EPUserApp) other; + + return (this.getUserId().equals(castOther.getUserId())) + && (this.getApp().getId().equals(castOther.getApp().getId())) + && (this.getRole().getId().equals(castOther.getRole().getId())) + && ((this.priority==null && castOther.getPriority()==null) || this.getPriority().equals(castOther.getPriority())); + } + + public int hashCode() { + int result = 17; + + result = 37 * result + (int) (this.getUserId()==null ? 0 : this.getUserId().intValue()); + result = 37 * result + (int) (this.getApp().getId()==null ? 0 : this.getApp().getId().intValue()); + result = 37 * result + (int) (this.getRole().getId()==null ? 0 : this.getRole().getId().intValue()); + result = 37 * result + (int) (this.priority==null ? 0 : this.priority); + return result; + } + + public int compareTo(Object other){ + EPUserApp castOther = (EPUserApp) other; + + Long c1 = (this.getUserId()==null ? 0 : this.getUserId()) + (this.getApp()==null||this.getApp().getId()==null ? 0 : this.getApp().getId()) + (this.getRole()==null||this.getRole().getId()==null ? 0 : this.getRole().getId()) + (this.priority==null ? 0 : this.priority); + Long c2 = (castOther.getUserId()==null ? 0 : castOther.getUserId()) + (castOther.getApp()==null||castOther.getApp().getId()==null ? 0 : castOther.getApp().getId()) + (castOther.getRole()==null||castOther.getRole().getId()==null ? 0 : castOther.getRole().getId()) + (castOther.priority==null ? 0 : castOther.priority); + + return c1.compareTo(c2); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppCatalogRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppCatalogRoles.java new file mode 100644 index 00000000..89411ea5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppCatalogRoles.java @@ -0,0 +1,92 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@Entity +@JsonInclude +public class EPUserAppCatalogRoles extends DomainVo { + + private static final long serialVersionUID = -5259869298825093816L; + + + @Id + @Column(name="requested_role_id") + public Long requestedRoleId; + + + @Id + @Column(name="role_name") + public String rolename; + + @Id + @Column(name="request_status") + public String requestStatus; + + @Id + @Column(name="app_id") + public Long appId; + + public Long getRequestedRoleId() { + return requestedRoleId; + } + + public void setRequestedRoleId(Long requestedRoleId) { + this.requestedRoleId = requestedRoleId; + } + + public String getRolename() { + return rolename; + } + + public void setRolename(String rolename) { + this.rolename = rolename; + } + + public String getRequestStatus() { + return requestStatus; + } + + public void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String toString() { + return "EPUserAppCatalogRoles [requestedRoleId=" + requestedRoleId + ", rolename=" + rolename + + ", requestStatus=" + requestStatus + ", appId=" + appId + "]"; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequest.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequest.java new file mode 100644 index 00000000..1d73945e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequest.java @@ -0,0 +1,87 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + + +import java.util.Date; +import java.util.Set; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + + +public class EPUserAppRolesRequest extends DomainVo { + + private static final long serialVersionUID = -7225288307806389019L; + private Long userId; + private Long appId; + private Date createdDate; + private Date updatedDate; + private String requestStatus; + + private Set epRequestIdDetail; + + public final Long getUserId() { + return userId; + } + + public final void setUserId(Long userId) { + this.userId = userId; + } + + public final Long getAppId() { + return appId; + } + + public final void setAppId(Long appId) { + this.appId = appId; + } + + public final Date getCreatedDate() { + return createdDate; + } + + public final void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public final Date getUpdatedDate() { + return updatedDate; + } + + public final void setUpdatedDate(Date updatedDate) { + this.updatedDate = updatedDate; + } + + public final String getRequestStatus() { + return requestStatus; + } + + public final void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public final Set getEpRequestIdDetail() { + return epRequestIdDetail; + } + + public final void setEpRequestIdDetail(Set epMyLoginsDetail) { + this.epRequestIdDetail = epMyLoginsDetail; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequestDetail.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequestDetail.java new file mode 100644 index 00000000..d7989bcd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppRolesRequestDetail.java @@ -0,0 +1,52 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPUserAppRolesRequestDetail extends DomainVo{ + + private static final long serialVersionUID = -4908856671135348157L; + + private Long reqRoleId; + private String reqType; + private EPUserAppRolesRequest epRequestIdData; + + public final EPUserAppRolesRequest getEpRequestIdData() { + return epRequestIdData; + } + public final void setEpRequestIdData(EPUserAppRolesRequest epRequestIdData) { + this.epRequestIdData = epRequestIdData; + } + public final Long getReqRoleId() { + return reqRoleId; + } + public final void setReqRoleId(Long reqRoleId) { + this.reqRoleId = reqRoleId; + } + public final String getReqType() { + return reqType; + } + public final void setReqType(String reqType) { + this.reqType = reqType; + } + +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsManualSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsManualSortPreference.java new file mode 100644 index 00000000..30d69bab --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsManualSortPreference.java @@ -0,0 +1,50 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPUserAppsManualSortPreference extends DomainVo { + + private static final long serialVersionUID = -6270136291139278216L; + private int userId; + private Long appId; + private int appManualSortOrder; + + public int getUserId() { + return userId; + } + public void setUserId(int userId) { + this.userId = userId; + } + public Long getAppId() { + return appId; + } + public void setAppId(Long appId) { + this.appId = appId; + } + public int getAppManualSortOrder() { + return appManualSortOrder; + } + public void setAppManualSortOrder(int appManualSortOrder) { + this.appManualSortOrder = appManualSortOrder; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsSortPreference.java new file mode 100644 index 00000000..1cab30ff --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserAppsSortPreference.java @@ -0,0 +1,44 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPUserAppsSortPreference extends DomainVo{ + + private static final long serialVersionUID = -5267000174894006433L; + + private int userId; + private String sortPref; + + public int getUserId() { + return userId; + } + public void setUserId(final int userId) { + this.userId = userId; + } + public String getSortPref() { + return sortPref; + } + public void setSortPref(final String sortPref) { + this.sortPref = sortPref; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserNotification.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserNotification.java new file mode 100644 index 00000000..c82db4de --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPUserNotification.java @@ -0,0 +1,57 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.Date; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + + +public class EPUserNotification extends DomainVo { + private Long userId; + private Long notificationId; + private String viewed; + private Date updateTime; + + public Long getUserId() { + return userId; + } + public void setUserId(Long userId) { + this.userId = userId; + } + public Long getNotificationId() { + return notificationId; + } + public void setNotificationId(Long notificationId) { + this.notificationId = notificationId; + } + public String getViewed() { + return viewed; + } + public void setViewed(String viewed) { + this.viewed = viewed; + } + public Date getUpdateTime() { + return updateTime; + } + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPWidgetsManualSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPWidgetsManualSortPreference.java new file mode 100644 index 00000000..4a3b784b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EPWidgetsManualSortPreference.java @@ -0,0 +1,70 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class EPWidgetsManualSortPreference extends DomainVo{ + + private static final long serialVersionUID = 4607102334801223570L; + private int userId; + private Long widgetId; + private int widgetRow; + private int widgetCol; + private int widgetWidth; + private int widgetHeight; + + public int getUserId() { + return userId; + } + public void setUserId(int userId) { + this.userId = userId; + } + public Long getWidgetId() { + return widgetId; + } + public void setWidgetId(Long widgetId) { + this.widgetId = widgetId; + } + public int getWidgetRow() { + return widgetRow; + } + public void setWidgetRow(int widgetRow) { + this.widgetRow = widgetRow; + } + public int getWidgetCol() { + return widgetCol; + } + public void setWidgetCol(int widgetCol) { + this.widgetCol = widgetCol; + } + public int getWidgetWidth() { + return widgetWidth; + } + public void setWidgetWidth(int widgetWidth) { + this.widgetWidth = widgetWidth; + } + public int getWidgetHeight() { + return widgetHeight; + } + public void setWidgetHeight(int widgetHeight) { + this.widgetHeight = widgetHeight; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompApp.java new file mode 100644 index 00000000..1cf89fbd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompApp.java @@ -0,0 +1,146 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +/** + * Model for a subset of the columns in the fn_app table. + */ +public class EcompApp { + + protected Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + private String imageUrl; + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + private String notes; + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + private String alternateUrl; + + public String getAlternateUrl() { + return alternateUrl; + } + + public void setAlternateUrl(String alternateUrl) { + this.alternateUrl = alternateUrl; + } + + private String uebTopicName; + + public String getUebTopicName() { + return uebTopicName; + } + + public void setUebTopicName(String topicName) { + this.uebTopicName = topicName; + } + + private String uebKey; + + public String getUebKey() { + return uebKey; + } + + public void setUebKey(String uebKey) { + this.uebKey = uebKey; + } + + private String uebSecret; + + public String getUebSecret() { + return uebSecret; + } + + public void setUebSecret(String secret) { + this.uebSecret = secret; + } + + private Boolean enabled; + + public Boolean isEnabled() { + return enabled; + } + + public void setEnabled(Boolean enable) { + this.enabled = enable; + } + + private Boolean restrictedApp; + + public Boolean isRestrictedApp() { + return restrictedApp; + } + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRole.java new file mode 100644 index 00000000..78cf4162 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRole.java @@ -0,0 +1,80 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; + +@Entity +@IdClass(EcompAppRoleId.class) +public class EcompAppRole { + + @Id + @Column(name="app_id") + private Long appId; + + @Id + @Column(name="app_name") + private String appName; + + @Id + @Column(name="role_id") + private Integer roleId; + + @Id + @Column(name="role_name") + private String roleName; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRoleId.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRoleId.java new file mode 100644 index 00000000..d89c0736 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAppRoleId.java @@ -0,0 +1,83 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Id; + +public class EcompAppRoleId implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name="app_id") + private Long appId; + + @Id + @Column(name="app_name") + private String appName; + + @Id + @Column(name="role_id") + private Integer roleId; + + @Id + @Column(name="role_name") + private String roleName; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAuditLog.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAuditLog.java new file mode 100644 index 00000000..4d4ec277 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EcompAuditLog.java @@ -0,0 +1,61 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.Date; + +import org.openecomp.portalsdk.core.domain.AuditLog; + +public class EcompAuditLog extends AuditLog { + + private static final long serialVersionUID = 7970458389782626231L; + + // values of activity_cd column in table fu_lu_activity + // as loaded by DML sql script + public static final String CD_ACTIVITY_ADD_CHILD_ROLE = "add_child_role"; + public static final String CD_ACTIVITY_ADD_ROLE = "add_role"; + public static final String CD_ACTIVITY_ADD_ROLE_FUNCTION = "add_role_function"; + public static final String CD_ACTIVITY_ADD_USER_ROLE = "add_user_role"; + public static final String CD_ACTIVITY_APP_ACCESS = "app_access"; + public static final String CD_ACTIVITY_FUNCTIONAL_ACCESS = "functional_access"; + public static final String CD_ACTIVITY_GUEST_LOGIN = "guest_login"; + public static final String CD_ACTIVITY_LOGIN = "login"; + public static final String CD_ACTIVITY_LOGOUT = "logout"; + public static final String CD_ACTIVITY_MOBILE_LOGIN = "mobile_login"; + public static final String CD_ACTIVITY_MOBILE_LOGOUT = "mobile_logout"; + public static final String CD_ACTIVITY_REMOVE_CHILD_ROLE = "remove_child_role"; + public static final String CD_ACTIVITY_REMOVE_ROLE = "remove_role"; + public static final String CD_ACTIVITY_REMOVE_ROLE_FUNCTION = "remove_role_function"; + public static final String CD_ACTIVITY_REMOVE_USER_ROLE = "remove_user_role"; + public static final String CD_ACTIVITY_TAB_ACCESS = "tab_access"; + public static final String CD_ACTIVITY_SEARCH = "search"; + public static final String CD_ACTIVITY_ADD_PORTAL_ADMIN = "apa "; + public static final String CD_ACTIVITY_DELETE_PORTAL_ADMIN = "dpa"; + public static final String CD_ACTIVITY_UPDATE_USER = "uu "; + public static final String CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN = "uaa "; + public static final String CD_ACTIVITY_STORE_ANALYTICS = "store_analytics"; + + /** + * Creates a new object with the created field set to the current date-time. + */ + public EcompAuditLog() { + setCreated(new Date()); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EpUserAppRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EpUserAppRoles.java new file mode 100644 index 00000000..1bfb1841 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/EpUserAppRoles.java @@ -0,0 +1,63 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EpUserAppRoles extends DomainVo { + + private static final long serialVersionUID = -1484592641766545668L; + + @Id + @Column(name ="role_id") + public Long roleId; + + @Id + @Column(name ="app_id") + public Long appId; + + public Long getRoleId() { + return roleId; + } + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + public Long getAppId() { + return appId; + } + public void setAppId(Long appId) { + this.appId = appId; + } + + @Override + public String toString() { + return "EpUserAppRoles [roleId=" + roleId + ", appId=" + appId + "]"; + } +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/ExternalSystemAccess.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/ExternalSystemAccess.java new file mode 100644 index 00000000..a0395bf8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/ExternalSystemAccess.java @@ -0,0 +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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +public class ExternalSystemAccess { + + private String key; + private Boolean accessValue; + + public ExternalSystemAccess(String key, Boolean accessValue){ + this.key = key; + this.accessValue = accessValue; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + public Boolean getAccessValue() { + return accessValue; + } + + public void setAccessValue(Boolean accessValue) { + this.accessValue = accessValue; + } + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/FunctionalMenuItemWithAppID.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/FunctionalMenuItemWithAppID.java new file mode 100644 index 00000000..ac2bc6c4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/FunctionalMenuItemWithAppID.java @@ -0,0 +1,96 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Transient; +/*** + * + * This class is almost identical to org.openecomp.portalapp.portal.transport.FunctionalMenuItem + * The only difference is the appId field. In FunctionMenuItem, we used @Transient as an attribute, and we are using @Column in this class. + * In some sql queries, we need to have appId, but it's not a field in fn_menu_functional table. + * + * @author robertlo + * + */ +@Entity +public class FunctionalMenuItemWithAppID{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "MENU_ID") + public Long menuId; + + @Column(name = "COLUMN_NUM") + public Integer column; + + @Column(name = "TEXT") + public String text; + + @Column(name = "PARENT_MENU_ID") + public Integer parentMenuId; + + @Column(name = "URL") + public String url; + + @Column(name="ACTIVE_YN") + public String active_yn; + + @Column(name="APP_ID") + public Integer appid; + + @Transient + public List roles; + + @Transient + public Boolean restrictedApp; + + public void normalize() { + if (this.column == null) + this.column = new Integer(1); + this.text = (this.text == null) ? "" : this.text.trim(); + if (this.parentMenuId == null) + this.parentMenuId = new Integer(-1); + this.url = (this.url == null) ? "" : this.url.trim(); + } + + @Override + public String toString() { + return "FunctionalMenuItem [menuId=" + menuId + ", column=" + column + ", text=" + text + ", parentMenuId=" + + parentMenuId + ", url=" + url + ", active_yn=" + active_yn + ", appid=" + appid + ", roles=" + roles + + ", restrictedApp=" + restrictedApp + "]"; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResult.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResult.java new file mode 100644 index 00000000..4669426a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResult.java @@ -0,0 +1,114 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@Entity +@JsonInclude +public class GetAccessResult implements Serializable{ + + + private static final long serialVersionUID = 5239527705869613411L; + + @Id + @Column(name="row_id") + private String rowId; + + @Column(name="role_id") + private Long roleId; + + @Column(name="ecomp_function",nullable=true) + private String ecompFunction; + + @Column(name="app_name") + private String appName; + + @Column(name="app_mots_id",nullable=true) + private Integer appMotsId; + + @Column(name="role_name") + private String roleName; + + @Column(name="role_actv",nullable=true) + private String roleActive; + + + @Column(name="request_type",nullable=true) + private String reqType; + + + + public final String getRowId() { + return rowId; + } + public final void setRowId(String rowId) { + this.rowId = rowId; + } + public final Long getRoleId() { + return roleId; + } + public final void setRoleId(Long roleId) { + this.roleId = roleId; + } + public String getEcompFunction() { + return ecompFunction; + } + public void setEcompFunction(String ecompFunction) { + this.ecompFunction = ecompFunction; + } + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } + public Integer getAppMotsId() { + return appMotsId; + } + public void setAppMotsId(Integer appMotsId) { + this.appMotsId = appMotsId; + } + public String getRoleName() { + return roleName; + } + public void setRoleName(String roleName) { + this.roleName = roleName; + } + public final String getRoleActive() { + return roleActive; + } + public final void setRoleActive(String roleActive) { + this.roleActive = roleActive; + } + public final String getReqType() { + return reqType; + } + public final void setReqType(String reqType) { + this.reqType = reqType; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResultId.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResultId.java new file mode 100644 index 00000000..0830bfd8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/GetAccessResultId.java @@ -0,0 +1,64 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Id; + +public class GetAccessResultId implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name="ecomp_function") + private String ecompFunction; + + @Id + @Column(name="app_name") + private String appName; + + @Id + @Column(name="role_name") + private String roleName; + + public String getEcompFunction() { + return ecompFunction; + } + public void setEcompFunction(String ecompFunction) { + this.ecompFunction = ecompFunction; + } + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } + public String getRoleName() { + return roleName; + } + public void setRoleName(String roleName) { + this.roleName = roleName; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceData.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceData.java new file mode 100644 index 00000000..91366ce8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceData.java @@ -0,0 +1,146 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class MicroserviceData extends DomainVo { + + private static final long serialVersionUID = 1L; + + public MicroserviceData() { + + } + + private Long id; + + private String name; + + private String active; + + private String desc; + + private long appId; + + private String url; + + private String securityType; + + private String username; + + private String password; + + private List parameterList; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public long getAppId() { + return appId; + } + + public void setAppId(long appId) { + this.appId = appId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getSecurityType() { + return securityType; + } + + public void setSecurityType(String securityType) { + this.securityType = securityType; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getParameterList() { + return parameterList; + } + + public void setParameterList(List parameterList) { + this.parameterList = parameterList; + } + + @Override + public String toString() { + return "MicroserviceData [id=" + id + ", name=" + name + ", desc=" + desc + ", appId=" + appId + ", url=" + url + + ", securityType=" + securityType + ", username=" + username + ", password=" + password + + ", parameterList=" + parameterList + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceParameter.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceParameter.java new file mode 100644 index 00000000..74a29370 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/MicroserviceParameter.java @@ -0,0 +1,82 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class MicroserviceParameter extends DomainVo { + + private static final long serialVersionUID = 1L; + + public MicroserviceParameter() { + + } + + private Long id; + + private long serviceId; + + private String para_key; + + private String para_value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public long getServiceId() { + return serviceId; + } + + public void setServiceId(long serviceId) { + this.serviceId = serviceId; + } + + public String getPara_key() { + return para_key; + } + + public void setPara_key(String para_key) { + this.para_key = para_key; + } + + public String getPara_value() { + return para_value; + } + + public void setPara_value(String para_value) { + this.para_value = para_value; + } + + @Override + public String toString() { + return "MicroserviceParameter [id=" + id + ", serviceId=" + serviceId + ", para_key=" + para_key + + ", para_value=" + para_value + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserAppSelection.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserAppSelection.java new file mode 100644 index 00000000..68875bf5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserAppSelection.java @@ -0,0 +1,78 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * Models a row in the table with personalization of user app selections. + */ +public class PersUserAppSelection extends DomainVo { + + private static final long serialVersionUID = 1545308654500121206L; + + private Long userId; + + private Long appId; + + private String statusCode; + + public PersUserAppSelection() {} + + /** + * Convenience constructor + * + * @param id + * @param userId + * @param appId + * @param statusCode + */ + public PersUserAppSelection(final Long id, final Long userId, final Long appId, final String statusCode) { + super.id = id; + this.userId = userId; + this.appId = appId; + this.statusCode = statusCode; + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserWidgetSelection.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserWidgetSelection.java new file mode 100644 index 00000000..4993b462 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/PersUserWidgetSelection.java @@ -0,0 +1,81 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * Models a row in the table with personalization of user widget selections. + */ +public class PersUserWidgetSelection extends DomainVo { + + /** + * + */ + private static final long serialVersionUID = -6547880514779039200L; + + private Long userId; + + private Long widgetId; + + private String statusCode; + + public PersUserWidgetSelection() {} + + /** + * Convenience constructor + * + * @param id + * @param userId + * @param widgetId + * @param statusCode + */ + public PersUserWidgetSelection(final Long id, final Long userId, final Long widgetId, final String statusCode) { + super.id = id; + this.userId = userId; + this.widgetId = widgetId; + this.statusCode = statusCode; + } + + public Long getWidgetId() { + return widgetId; + } + + public void setWidgetId(Long widgetId) { + this.widgetId = widgetId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/RoleApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/RoleApp.java new file mode 100644 index 00000000..ade24dcb --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/RoleApp.java @@ -0,0 +1,114 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +//@Entity +//@Table(name = "FN_ROLE") +public class RoleApp implements Serializable{ + private static final long serialVersionUID = 1L; + + //@Id + //@Column(name = "ROLE_ID") + //@GeneratedValue(strategy=GenerationType.AUTO) + private Long roleId; + + + //@Column(name = "ROLE_Name") + private String roleName; + + //@ManyToOne(fetch = FetchType.EAGER) + //@JoinColumn(name="APP_ID") + private App app; + + //@JsonIgnore + //@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, mappedBy="widgetRoles") + private Set widgets; + + /*@PreRemove + private void removeGroupsFromUsers() { + for (WidgetCatalog w : widgets) { + w.getWidgetRoles().remove(this); + } + }*/ + + /*@ManyToOne + @JoinColumn(name = "WIDGET_ID", nullable = false) + WidgetCatalog widgetCatalog;*/ + + //@JsonIgnore + //@ManyToMany(mappedBy = "widgetRoles") + //@ManyToMany(fetch = FetchType.EAGER, mappedBy = "widgetRoles") + //private Set widgets = new HashSet(); + + public Long getRoleId() { + return roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public App getApp() { + return app; + } + + public void setApp(App app) { + this.app = app; + } + + + + public Set getWidgets() { + return widgets; + } + + public void setWidgets(Set widgets) { + this.widgets = widgets; + } + + @Override + public String toString() { + return "Role [roleId=" + roleId + ", roleName=" + roleName + ", app=" + app + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/SharedContext.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/SharedContext.java new file mode 100644 index 00000000..f966c964 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/SharedContext.java @@ -0,0 +1,161 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * A shared context is a key-value pair in a session. All shared-context objects + * should be dropped when a session is destroyed. Because there's always a + * chance of missing that event, this object notes its creation time so that it + * can be expired after a suitable time interval. + */ +@Entity +@Table(name = "fn_shared_context") +public class SharedContext extends DomainVo { + + // generated + private static final long serialVersionUID = 7287469622586677888L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private Date create_time; + private String context_id; + private String ckey; + private String cvalue; + + /** + * Mandatory no-argument constructor + */ + public SharedContext() { + } + + /** + * Convenience constructor. The database ID and creation timestamp are + * populated when the object is added to the database. + */ + public SharedContext(final String contextId, final String key, final String value) { + this.context_id = contextId; + this.ckey = key; + this.cvalue = value; + } + + /** + * Gets the database row ID. + * + * @return Database row ID + */ + public Long getId() { + return id; + } + + /** + * Sets the database row ID. + * + * @param id + */ + public void setId(final Long id) { + this.id = id; + } + + /** + * Gets the creation time + * + * @return Creation time as a Date + */ + public Date getCreate_time() { + return create_time; + } + + /** + * Sets the creation time + * + * @param create_time + */ + public void setCreate_time(final Date create_time) { + this.create_time = create_time; + } + + /** + * Gets the context ID + * + * @return Context ID + */ + public String getContext_id() { + return context_id; + } + + /** + * Sets the context ID + * + * @param context_id + */ + public void setContext_id(final String context_id) { + this.context_id = context_id; + } + + /** + * Gets the key of the key-value pair. Called ckey because "key" is a + * reserved word in Mysql. + * + * @return The key + */ + public String getCkey() { + return ckey; + } + + /** + * Sets the key of the key-value pair. + * + * @param ckey + */ + public void setCkey(final String ckey) { + this.ckey = ckey; + } + + /** + * Gets the value of the key-value pair. Called cvalue because "value" is a + * reserved word in Mysql. + * + * @return + */ + public String getCvalue() { + return cvalue; + } + + /** + * Sets the value of the key-value pair. + * + * @param cvalue + */ + public void setCvalue(final String cvalue) { + this.cvalue = cvalue; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserIdRoleId.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserIdRoleId.java new file mode 100644 index 00000000..4d2041dd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserIdRoleId.java @@ -0,0 +1,77 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class UserIdRoleId implements Serializable{ + + private static final long serialVersionUID = 1L; + + @Id + @Column(name="USER_ID") + private String user_Id; + + @Column(name="ROLE_ID") + private String roleId; + + @Column(name="ORG_USER_ID") + private String orgUserId; + + @Column(name="APP_ID") + private String appId; + + public String getUser_Id() { + return user_Id; + } + + public void setUser_Id(String id) { + this.user_Id = id; + } + + public String getRoleId() { + return roleId; + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRole.java new file mode 100644 index 00000000..0e13cc01 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRole.java @@ -0,0 +1,91 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class UserRole implements Serializable{ + private static final long serialVersionUID = 1L; + + + @Id + @Column(name="USER_ID") + private Long user_Id; + + @Id + @Column(name="ROLE_ID") + private Long roleId; + + @Column(name="ORG_USER_ID") + private String orgUserId; + + + @Column(name="FIRST_NAME") + private String firstName; + + @Column(name="LAST_NAME") + private String lastName; + + + @Column(name="ROLE_NAME") + private String roleName; + + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public String getOrgUserId() { + return orgUserId; + } + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + public String getRoleName() { + return roleName; + } + public void setRoleName(String roleName) { + this.roleName = roleName; + } + public Long getUser_Id() { + return user_Id; + } + public void setUser_Id(Long user_Id) { + this.user_Id = user_Id; + } + public Long getRoleId() { + return roleId; + } + public void setRoleId(Long roleId) { + this.roleId = roleId; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRoles.java new file mode 100644 index 00000000..1483f34a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/UserRoles.java @@ -0,0 +1,113 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; + +public class UserRoles implements Serializable { + private static final long serialVersionUID = 1L; + + /* + private static final HashMap rolesDictionary; + // remove hard coded roles + static { + rolesDictionary = new HashMap(); + rolesDictionary.put(Long.valueOf(SystemProperties.getProperty(SystemProperties.SYS_ADMIN_ROLE_ID)).longValue(), "superAdmin"); + rolesDictionary.put(Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ACCOUNT_ADMIN_ROLE_ID)).longValue(), "admin"); + } + */ + + public UserRoles(UserRole user) { + setOrgUserId(user.getOrgUserId()); + setFirstName(user.getFirstName()); + setLastName(user.getLastName()); + setGuestSession(user.getUser_Id()==-1 ? true : false); + + addRole(user.getRoleName()); + } + + public void addRole(String roleName) { + //String normalizedRole = normalizeRole(roleId); + if (!getRoles().contains(roleName)) { + this.roles.add(roleName); + } + } + + /* + public static String normalizeRole(Long role) { + String roleTranslated = rolesDictionary.get(role); + return roleTranslated == null ? "user" : roleTranslated; + } + */ + + private String orgUserId; + private String firstName; + private String lastName; + private boolean guestSession; + + // TODO: Make into set + private List roles = new ArrayList(); + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public void setGuestSession(boolean guestSession) { + this.guestSession = guestSession; + } + + public boolean getGuestSession() { + return this.guestSession; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/Widget.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/Widget.java new file mode 100644 index 00000000..c2ef3c00 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/Widget.java @@ -0,0 +1,105 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.apache.commons.lang.StringUtils; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class Widget extends DomainVo { + + private static final long serialVersionUID = 1L; + + private String name; + + private Integer width; + + private Integer height; + + private String url; + + private Long appId; + + public Widget() { + // Attention!!! + // We set here all default values. We also place protection + // into setters for fields with default values. + // If we don't use such protection we are able to place null + // to these fields and save such fields into DB even if DB has + // default values for these fields. + this.name = ""; + this.width = new Integer(0); + this.height = new Integer(0); + this.url = ""; + } + + public String getName() { + return name; + } + + public void setName(String name) { + if (StringUtils.isEmpty(name)) { + name = ""; + } + this.name = name; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + if (width == null) { + width = new Integer(0); + } + this.width = width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + if (height == null) { + height = new Integer(0); + } + this.height = height; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + if (StringUtils.isEmpty(url)) { + url = ""; + } + this.url = url; + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalog.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalog.java new file mode 100644 index 00000000..605a41d2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalog.java @@ -0,0 +1,109 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.io.Serializable; +import java.util.Set; + +public class WidgetCatalog implements Serializable{ + + private static final long serialVersionUID = 1L; + + private long id; + + private String name; + + private String desc; + + private String fileLocation; + + private String allowAllUser; + + private Long serviceId; + + private String sortOrder; + + private String statusCode; + + private Set widgetRoles; + + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + public Long getServiceId() { + return serviceId; + } + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; + } + public String getDesc() { + return desc; + } + public void setDesc(String desc) { + this.desc = desc; + } + public String getFileLocation() { + return fileLocation; + } + public void setFileLocation(String fileLocation) { + this.fileLocation = fileLocation; + } + + public String getAllowAllUser() { + return allowAllUser; + } + public void setAllowAllUser(String allowAllUser) { + this.allowAllUser = allowAllUser; + } + public Set getWidgetRoles() { + return widgetRoles; + } + public void setWidgetRoles(Set widgetRoles) { + this.widgetRoles = widgetRoles; + } + + public String getSortOrder() { + return sortOrder; + } + public void setSortOrder(String sortOrder) { + this.sortOrder = sortOrder; + } + public String getStatusCode() { + return statusCode; + } + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + @Override + public String toString() { + return "WidgetCatalog [id=" + id + ", name=" + name + ", desc=" + desc + ", fileLocation=" + fileLocation + + ", allowAllUser=" + allowAllUser + "]"; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalogParameter.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalogParameter.java new file mode 100644 index 00000000..c72780aa --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetCatalogParameter.java @@ -0,0 +1,90 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +public class WidgetCatalogParameter extends DomainVo{ + + private static final long serialVersionUID = 1L; + + public WidgetCatalogParameter() { + + } + private Long id; + + private Long widgetId; + + private Long userId; + + private Long paramId; + + private String user_value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWidgetId() { + return widgetId; + } + + public void setWidgetId(Long widgetId) { + this.widgetId = widgetId; + } + + public String getUser_value() { + return user_value; + } + + public void setUser_value(String user_value) { + this.user_value = user_value; + } + + public Long getParamId() { + return paramId; + } + + public void setParamId(Long paramId) { + this.paramId = paramId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + @Override + public String toString() { + return "WidgetCatalogParameter [id=" + id + ", widgetId=" + widgetId + ", userId=" + userId + ", paramId=" + + paramId + ", user_value=" + user_value + "]"; + } + + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetParameterResult.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetParameterResult.java new file mode 100644 index 00000000..884ec141 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetParameterResult.java @@ -0,0 +1,70 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +public class WidgetParameterResult { + + private Long param_id; + + private String param_key; + + private String user_value; + + private String default_value; + + public Long getParam_id() { + return param_id; + } + + public void setParam_id(Long param_id) { + this.param_id = param_id; + } + + public String getParam_key() { + return param_key; + } + + public void setParam_key(String param_key) { + this.param_key = param_key; + } + + public String getUser_value() { + return user_value; + } + + public void setUser_value(String user_value) { + this.user_value = user_value; + } + + public String getDefault_value() { + return default_value; + } + + public void setDefault_value(String default_value) { + this.default_value = default_value; + } + + @Override + public String toString() { + return "WidgetParameterResult [param_id=" + param_id + ", param_key=" + param_key + ", user_value=" + user_value + + ", default_value=" + default_value + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetServiceHeaders.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetServiceHeaders.java new file mode 100644 index 00000000..9200adda --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/domain/WidgetServiceHeaders.java @@ -0,0 +1,54 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.domain; + +import java.nio.charset.Charset; + +import org.apache.commons.codec.binary.Base64; +import org.springframework.http.HttpHeaders; + +import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +public class WidgetServiceHeaders { + + private static HttpHeaders widgetHeaders; + + private WidgetServiceHeaders(){} + + public static HttpHeaders getInstance() throws Exception{ + if(null == widgetHeaders){ + return new HttpHeaders(){{ + + String username = EcompPortalUtils.getPropertyOrDefault("microservices.widget.username", "widget_user"); + String password = CipherUtil.decrypt(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")); + String auth = username + ":" + password; + byte[] encodedAuth = Base64.encodeBase64( + auth.getBytes(Charset.forName("US-ASCII")) ); + String authHeader = "Basic " + new String( encodedAuth ); + set( "Authorization", authHeader ); + } + }; + } + else + return widgetHeaders; + + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCatalogItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCatalogItem.java new file mode 100644 index 00000000..ec20b4f3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCatalogItem.java @@ -0,0 +1,249 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * This model of an application catalog entry has some EPApp fields plus + * additional fields to indicate access(ible) and select(ed) statuses. + */ +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppCatalogItem extends DomainVo { + + private static final long serialVersionUID = 6619663784935017846L; + + @Id + private Long id; + private String name; + private String imageUrl; + private String description; + private String notes; + private String url; + private String alternateUrl; + private Boolean restricted; + private Boolean open; + private Boolean access; + private Boolean select; + private Boolean pending; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAlternateUrl() { + return alternateUrl; + } + + public void setAlternateUrl(String alternateUrl) { + this.alternateUrl = alternateUrl; + } + + public Boolean getRestricted() { + return restricted; + } + + public void setRestricted(Boolean restricted) { + this.restricted = restricted; + } + + public Boolean getOpen() { + return open; + } + + public void setOpen(Boolean open) { + this.open = open; + } + + public Boolean getAccess() { + return access; + } + + public void setAccess(Boolean access) { + this.access = access; + } + + public Boolean getSelect() { + return select; + } + + public void setSelect(Boolean select) { + this.select = select; + } + + public Boolean getPending() { + return pending; + } + + public void setPending(Boolean pending) { + this.pending = pending; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + @Override + public String toString() { + return "AppCatalogItem [id=" + id + ", name=" + name + ", access=" + access + ", select=" + select + + ", pending=" + pending + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((access == null) ? 0 : access.hashCode()); + result = prime * result + ((alternateUrl == null) ? 0 : alternateUrl.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((notes == null) ? 0 : notes.hashCode()); + result = prime * result + ((open == null) ? 0 : open.hashCode()); + result = prime * result + ((pending == null) ? 0 : pending.hashCode()); + result = prime * result + ((restricted == null) ? 0 : restricted.hashCode()); + result = prime * result + ((select == null) ? 0 : select.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppCatalogItem other = (AppCatalogItem) obj; + if (access == null) { + if (other.access != null) + return false; + } else if (!access.equals(other.access)) + return false; + if (alternateUrl == null) { + if (other.alternateUrl != null) + return false; + } else if (!alternateUrl.equals(other.alternateUrl)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (imageUrl == null) { + if (other.imageUrl != null) + return false; + } else if (!imageUrl.equals(other.imageUrl)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (notes == null) { + if (other.notes != null) + return false; + } else if (!notes.equals(other.notes)) + return false; + if (open == null) { + if (other.open != null) + return false; + } else if (!open.equals(other.open)) + return false; + if (pending == null) { + if (other.pending != null) + return false; + } else if (!pending.equals(other.pending)) + return false; + if (restricted == null) { + if (other.restricted != null) + return false; + } else if (!restricted.equals(other.restricted)) + return false; + if (select == null) { + if (other.select != null) + return false; + } else if (!select.equals(other.select)) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCategoryFunctionsItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCategoryFunctionsItem.java new file mode 100644 index 00000000..b1601431 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppCategoryFunctionsItem.java @@ -0,0 +1,140 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Carries row information for the functional table on the Contact Us page. + */ +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppCategoryFunctionsItem extends DomainVo { + + private static final long serialVersionUID = -1573834082471206458L; + + @Id + private String rowId; + private String appId; + private String application; + private String category; + private String functions; + + public String getRowId() { + return rowId; + } + + public void setRowId(String rowId) { + this.rowId = rowId; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getApplication() { + return application; + } + + public void setApplication(String appName) { + this.application = appName; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getFunctions() { + return functions; + } + + public void setFunctions(String functions) { + this.functions = functions; + } + + @Override + public String toString() { + return "AppCategoryFunctionsItem [rowId=" + rowId + ", appId=" + appId + ", application=" + application + + ", category=" + category + ", functions=" + functions + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appId == null) ? 0 : appId.hashCode()); + result = prime * result + ((application == null) ? 0 : application.hashCode()); + result = prime * result + ((category == null) ? 0 : category.hashCode()); + result = prime * result + ((functions == null) ? 0 : functions.hashCode()); + result = prime * result + ((rowId == null) ? 0 : rowId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppCategoryFunctionsItem other = (AppCategoryFunctionsItem) obj; + if (appId == null) { + if (other.appId != null) + return false; + } else if (!appId.equals(other.appId)) + return false; + if (application == null) { + if (other.application != null) + return false; + } else if (!application.equals(other.application)) + return false; + if (category == null) { + if (other.category != null) + return false; + } else if (!category.equals(other.category)) + return false; + if (functions == null) { + if (other.functions != null) + return false; + } else if (!functions.equals(other.functions)) + return false; + if (rowId == null) { + if (other.rowId != null) + return false; + } else if (!rowId.equals(other.rowId)) + return false; + return true; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppContactUsItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppContactUsItem.java new file mode 100644 index 00000000..5dc7bf57 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/AppContactUsItem.java @@ -0,0 +1,171 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * An easily serializable version of row information from the fn_app_contact_us + * table; specifically this has an app ID instead of an EPApp object. + */ +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppContactUsItem extends DomainVo { + + private static final long serialVersionUID = 6964210807573346262L; + + @Id + private Long appId; + private String appName; + private String description; + private String contactName; + private String contactEmail; + private String url; + private String activeYN; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getContactEmail() { + return contactEmail; + } + + public void setContactEmail(String contactEmail) { + this.contactEmail = contactEmail; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getActiveYN() { + return activeYN; + } + + public void setActiveYN(String activeYN) { + this.activeYN = activeYN; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activeYN == null) ? 0 : activeYN.hashCode()); + result = prime * result + ((appId == null) ? 0 : appId.hashCode()); + result = prime * result + ((appName == null) ? 0 : appName.hashCode()); + result = prime * result + ((contactEmail == null) ? 0 : contactEmail.hashCode()); + result = prime * result + ((contactName == null) ? 0 : contactName.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppContactUsItem other = (AppContactUsItem) obj; + if (activeYN == null) { + if (other.activeYN != null) + return false; + } else if (!activeYN.equals(other.activeYN)) + return false; + if (appId == null) { + if (other.appId != null) + return false; + } else if (!appId.equals(other.appId)) + return false; + if (appName == null) { + if (other.appName != null) + return false; + } else if (!appName.equals(other.appName)) + return false; + if (contactEmail == null) { + if (other.contactEmail != null) + return false; + } else if (!contactEmail.equals(other.contactEmail)) + return false; + if (contactName == null) { + if (other.contactName != null) + return false; + } else if (!contactName.equals(other.contactName)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + return true; + } + + @Override + public String toString() { + return "AppContactUsItem [appId=" + appId + ", appName=" + appName + ", description=" + description + + ", contactName=" + contactName + ", contactEmail=" + contactEmail + ", url=" + url + ", activeYN=" + + activeYN + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/CommonWidgetsEnum.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/CommonWidgetsEnum.java new file mode 100644 index 00000000..994108dd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/CommonWidgetsEnum.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +public enum CommonWidgetsEnum{ + NEWS("news"), + EVENTS("events"), + RESOURCES("resources"); + + private String value; + private CommonWidgetsEnum(String value){ + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestResponse.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestResponse.java new file mode 100644 index 00000000..3572d6a6 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestResponse.java @@ -0,0 +1,101 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +public class PortalRestResponse { + + private PortalRestStatusEnum status; + private String message; + + private T response; + + public PortalRestResponse(){}; + + public PortalRestResponse(PortalRestStatusEnum status, String message, T response){ + this.status = status; + this.message = message; + this.response = response; + } + + public PortalRestStatusEnum getStatus() { + return status; + } + + public void setStatus(PortalRestStatusEnum status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getResponse() { + return response; + } + + public void setResponse(T response) { + this.response = response; + } + + @Override + public String toString() { + return "PortalRestResponse [status=" + status + ", message=" + message + ", response=" + response + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((message == null) ? 0 : message.hashCode()); + result = prime * result + ((response == null) ? 0 : response.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PortalRestResponse other = (PortalRestResponse) obj; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + if (response == null) { + if (other.response != null) + return false; + } else if (!response.equals(other.response)) + return false; + if (status != other.status) + return false; + return true; + }; + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestStatusEnum.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestStatusEnum.java new file mode 100644 index 00000000..b4dc63ab --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/PortalRestStatusEnum.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +public enum PortalRestStatusEnum{ + OK("ok"), + WARN("WARNING"), + ERROR("error"); + + private String value; + private PortalRestStatusEnum(String value){ + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/SearchResultItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/SearchResultItem.java new file mode 100644 index 00000000..c6538470 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ecomp/model/SearchResultItem.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ecomp.model; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SearchResultItem extends DomainVo{ + + @Id + private String rowId; + + @JsonProperty("category") + private String category; + + @JsonProperty("name") + private String name; + + @JsonProperty("target") + private String target; + + @JsonProperty("uuid") + private String uuid; + + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + public String getRowId() { + return rowId; + } + public void setRowId(String rowId) { + this.rowId = rowId; + } + public String getCategory() { + return category; + } + public void setCategory(String category) { + this.category = category; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + public String getTarget() { + return target; + } + public void setTarget(String target) { + this.target = target; + } + @Override + public String toString() { + return "SearchResultItem [rowId=" + rowId + ", category=" + category + ", name=" + name + ", target=" + target + + ", uuid=" + uuid + "]"; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/exceptions/NoHealthyServiceException.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/exceptions/NoHealthyServiceException.java new file mode 100644 index 00000000..ce0366c8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/exceptions/NoHealthyServiceException.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.exceptions; + +import com.ecwid.consul.ConsulException; + +public class NoHealthyServiceException extends ConsulException{ + + private static final long serialVersionUID = -7089437673127729813L; + + public NoHealthyServiceException(String message){ + super(message); + } + + @Override + public String toString() { + return "NoHealthyServiceException [] " + this.getMessage(); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/interceptor/PortalResourceInterceptor.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/interceptor/PortalResourceInterceptor.java new file mode 100644 index 00000000..9a2fc4de --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/interceptor/PortalResourceInterceptor.java @@ -0,0 +1,335 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================*/ +package org.openecomp.portalapp.portal.interceptor; + +import java.net.URL; +import java.nio.charset.Charset; +import java.util.Base64; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.sessionmgt.SessionCommunicationController; +import org.openecomp.portalapp.portal.controller.BasicAuthenticationController; +import org.openecomp.portalapp.portal.controller.ExternalAppsRestfulController; +import org.openecomp.portalapp.portal.controller.SharedContextRestController; +import org.openecomp.portalapp.portal.controller.WebAnalyticsExtAppController; +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPEndpoint; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPEELFLoggerAdvice; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.BasicAuthenticationCredentialService; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.service.RemoteWebServiceCallService; +import org.openecomp.portalapp.service.sessionmgt.ManageService; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.controller.FusionBaseController; +import org.openecomp.portalsdk.core.exception.UrlAccessRestrictedException; +import org.openecomp.portalsdk.core.interceptor.ResourceInterceptor; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +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.util.SystemProperties.SecurityEventTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.method.HandlerMethod; + +public class PortalResourceInterceptor extends ResourceInterceptor { + private static final String APP_KEY = "uebkey"; + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PortalResourceInterceptor.class); + + @Autowired + private RemoteWebServiceCallService remoteWebServiceCallService; + + @Autowired + private ManageService manageService; + + @Autowired + private EPEELFLoggerAdvice epAdvice; + + @Autowired + private BasicAuthenticationCredentialService basicAuthService; + + @SuppressWarnings("unchecked") + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + + if (handler instanceof HandlerMethod) { + HandlerMethod method = (HandlerMethod) handler; + + /** + * These classes provide REST endpoints used by other application + * servers, NOT by an end user's browser. + */ + if (method.getBean() instanceof FusionBaseController) { + FusionBaseController controller = (FusionBaseController) method.getBean(); + if (!controller.isAccessible()) { + + // authorize portalApi requests by user role + String requestURI = request.getRequestURI(); + if (requestURI != null) { + String[] uriArray = requestURI.split("/portalApi/"); + if (uriArray.length > 1) { + String portalApiPath = uriArray[1]; + + Set roleFunctions = (Set) request.getSession() + .getAttribute(SystemProperties + .getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME)); + Set allRoleFunctions = (Set) request.getSession() + .getAttribute(EPUserUtils.ALL_ROLE_FUNCTIONS); + // Defend against code error to avoid throwing NPE + if (roleFunctions == null || allRoleFunctions == null) { + logger.error(EELFLoggerDelegate.errorLogger, + "preHandle: failed to get role functions attribute(s) from session!!"); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInitializationError); + return false; + } + // check to see if roleFunctions of the user is in + // the + // list of all role functions + // if not, ignore to prevent restricting every + // trivial + // call; otherwise, if it is, then check for the + // access + if (matchRoleFunctions(portalApiPath, allRoleFunctions) + && !matchRoleFunctions(portalApiPath, roleFunctions)) { + EPUser user = (EPUser) request.getSession().getAttribute( + SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); + logger.error(EELFLoggerDelegate.errorLogger, + "preHandle: User {} not authorized for path {} ", user.getOrgUserId(), + portalApiPath); + EcompPortalUtils.setBadPermissions(user, response, portalApiPath); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiAuthenticationError); + return false; + } // failed to match + + } // is portalApi + + } // requestURI + } // instance check + } // not accessible + else if (method.getBean() instanceof BasicAuthenticationController) { + return checkBasicAuth(request, response); + } + Object controllerObj = method.getBean(); + if (controllerObj instanceof SessionCommunicationController + || controllerObj instanceof SharedContextRestController + || controllerObj instanceof ExternalAppsRestfulController) { + // check user authentication for RESTful calls + String secretKey = null; + try { + epAdvice.loadServletRequestBasedDefaults(request, SecurityEventTypeEnum.INCOMING_REST_MESSAGE); + if (!remoteWebServiceCallService.verifyRESTCredential(secretKey, request.getHeader(APP_KEY), + request.getHeader("username"), request.getHeader("password"))) { + throw new UrlAccessRestrictedException(); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "preHandle: failed to authenticate RESTful service", + e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiAuthenticationError, e); + throw new UrlAccessRestrictedException(); + } + } + + if (controllerObj instanceof WebAnalyticsExtAppController) { + if (!remoteWebServiceCallService.verifyAppKeyCredential(request.getHeader(APP_KEY))) { + logger.error(EELFLoggerDelegate.errorLogger, + "preHandle: failed to verify app key for web analytics call"); + throw new UrlAccessRestrictedException(); + } + } + } + + handleSessionUpdates(request); + return true; + } + + /** + * Sets the status code and sends a response. Factors code out of many + * methods. + * + * @param response + * HttpServletResponse + * @param statusCode + * HTTP status code like 404 + * @param message + * Message to send in a JSON error object + */ + private void sendErrorResponse(HttpServletResponse response, final int statusCode, final String message) + throws Exception { + response.setStatus(statusCode); + response.setContentType("application/json"); + response.getWriter().write("{\"error\":\"" + message + "\"}"); + response.getWriter().flush(); + } + + /** + * Gets HTTP basic authentication information from the request and checks + * whether those credentials are authorized for the request path. + * + * @param request + * HttpServletRequest + * @param response + * HttpServletResponse + * @return True if the request is authorized, else false + * @throws Exception + */ + private boolean checkBasicAuth(HttpServletRequest request, HttpServletResponse response) throws Exception { + + String uri = request.getRequestURI().toString(); + uri = uri.substring(uri.indexOf("/", 1)); + + final String authHeader = request.getHeader("Authorization"); + if (authHeader == null) { + final String msg = "no authorization found"; + logger.debug(EELFLoggerDelegate.debugLogger, "checkBasicAuth: {}", msg); + sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, msg); + return false; + } + + String[] accountNamePassword = getUserNamePassword(authHeader); + if (accountNamePassword == null || accountNamePassword.length != 2) { + final String msg = "failed to get username and password from auth header"; + logger.debug(EELFLoggerDelegate.debugLogger, "checkBasicAuth: {}", msg); + sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, msg); + return false; + } + + BasicAuthCredentials creds; + try { + creds = basicAuthService.getBasicAuthCredentialByAppName(accountNamePassword[0]); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "checkBasicAuth failed to get credentials", e); + final String msg = "Failed while getting basic authentication credential: " + e.toString(); + sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); + throw e; + } + + boolean isAllowedEp = false; + for(EPEndpoint ep: creds.getEndpoints()){ + if(ep.getName().equals(uri)){ + isAllowedEp = true; + break; + } + } + if(!isAllowedEp){ + response.setStatus(401); + response.setContentType("application/json"); + response.getWriter().write("{\"error\":\"Unauthorized: Endpoint access denied\"}"); + response.getWriter().flush(); + response.getWriter().close(); + return false; + } + + if (creds == null) { + final String msg = "failed to find match for credentials"; + logger.debug(EELFLoggerDelegate.debugLogger, "checkBasicAuth: {}", msg); + sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, msg); + return false; + } + + boolean isAuth; + try { + isAuth = authorization(authHeader, creds.getApplicationName(), creds.getPassword()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "checkBasicAuth failed to check authorization", e); + final String msg = "failed while checking authorization: " + e.toString(); + sendErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); + throw e; + } + + if (!isAuth) { + response.setStatus(401); + response.setContentType("application/json"); + response.getWriter().write("{\"error\":\"Unauthorized: Invalid username or password\"}"); + response.getWriter().flush(); + response.getWriter().close(); + final String msg = "Unauthorized: Access denied"; + sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, msg); + return false; + } + + // Made it to the end! + return true; + } + + /** + * + * Basic Authorization check + * + * @param auth + * @param security_user + * @param security_pass + * @return + * @throws Exception + */ + + protected boolean authorization(String auth, String security_user, String security_pass) throws Exception { + + if (auth != null && auth.startsWith("Basic")) { + String[] usernamePassword = getUserNamePassword(auth); + if (security_user.equals(usernamePassword[0]) && decrypted(security_pass).equals(usernamePassword[1])) + return true; + } + return false; + } + + public static void main(String str[]) { + System.out.println(new PortalResourceInterceptor().getUserNamePassword("Basic Qy1CVVM6X3Bhc3M=")[0]); + System.out.println(new PortalResourceInterceptor().getUserNamePassword("Basic Qy1CVVM6X3Bhc3M=")[1]); + } + + private String[] getUserNamePassword(String authValue) { + String base64Credentials = authValue.substring("Basic".length()).trim(); + String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8")); + final String[] values = credentials.split(":", 2); + return values; + } + + private String decrypted(String encrypted) throws Exception { + String result = ""; + if (encrypted != null & encrypted.length() > 0) { + try { + result = CipherUtil.decrypt(encrypted, SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); + throw e; + } + } + return result; + } + + private Boolean matchRoleFunctions(String portalApiPath, Set roleFunctions) { + for (String roleFunction : roleFunctions) { + if (portalApiPath.matches(roleFunction)) + return true; + } + return false; + + } + + protected void handleSessionUpdates(HttpServletRequest request) { + PortalTimeoutHandler.handleSessionUpdatesNative(request, null, null, null, null, manageService); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/HealthMonitor.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/HealthMonitor.java new file mode 100644 index 00000000..b8e608cd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/HealthMonitor.java @@ -0,0 +1,355 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.listener; + +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.ueb.EPUebHelper; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class HealthMonitor { + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private EPUebHelper epUebHelper; + + private static boolean databaseUp; + private static boolean uebUp; + private static boolean frontEndUp; + private static boolean backEndUp; + private static boolean dbClusterStatusOk; + private static boolean dbPermissionsOk; + public static boolean isSuspended = false; + + Thread healthMonitorThread; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HealthMonitor.class); + + public HealthMonitor() { + + } + + public static boolean isDatabaseUp() { + return databaseUp; + } + + public static boolean isClusterStatusOk() { + return dbClusterStatusOk; + } + + public static boolean isDatabasePermissionsOk() { + return dbPermissionsOk; + } + + public static boolean isUebUp() { + return uebUp; + } + + public static boolean isFrontEndUp() { + return frontEndUp; + } + + public static boolean isBackEndUp() { + return backEndUp; + } + + private void monitorEPHealth() throws InterruptedException { + + int numIntervalsDatabaseHasBeenDown = 0; + int numIntervalsClusterNotHealthy = 0; + int numIntervalsDatabasePermissionsIncorrect = 0; + int numIntervalsUebHasBeenDown = 0; + + logger.debug(EELFLoggerDelegate.debugLogger, "==> Health Monitor thread started"); + + long sleepInterval = (Long + .valueOf(SystemProperties.getProperty(EPCommonSystemProperties.HEALTH_POLL_INTERVAL_SECONDS)) * 1000); + long numIntervalsBetweenAlerts = Long + .valueOf(SystemProperties.getProperty(EPCommonSystemProperties.HEALTHFAIL_ALERT_EVERY_X_INTERVALS)); + logger.debug(EELFLoggerDelegate.debugLogger, + "Polling health every " + sleepInterval + " milliseconds. Alerting every " + + (sleepInterval * numIntervalsBetweenAlerts) / 1000 + " seconds when component remains down."); + + while (true) { + // + // Get DB status. If down, signal alert once every X intervals. + // + databaseUp = this.checkIfDatabaseUp(); + if (databaseUp == false) { + + if ((numIntervalsDatabaseHasBeenDown % numIntervalsBetweenAlerts) == 0) { + // Write a Log entry that will generate an alert + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHealthCheckMySqlError); + logger.debug(EELFLoggerDelegate.debugLogger, + "Database down, logging to error log to trigger alert."); + numIntervalsDatabaseHasBeenDown++; + } else { + numIntervalsDatabaseHasBeenDown = 0; + } + } + + dbClusterStatusOk = this.checkClusterStatus(); + if (dbClusterStatusOk == false) { + + if ((numIntervalsClusterNotHealthy % numIntervalsBetweenAlerts) == 0) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHealthCheckMySqlError); + logger.debug(EELFLoggerDelegate.debugLogger, + "Cluster nodes appear to be down, logging to error log to trigger alert."); + numIntervalsClusterNotHealthy++; + } else { + numIntervalsClusterNotHealthy = 0; + } + } + + dbPermissionsOk = this.checkDatabaseAndPermissions(); + if (dbPermissionsOk == false) { + + if ((numIntervalsDatabasePermissionsIncorrect % numIntervalsBetweenAlerts) == 0) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHealthCheckMySqlError); + logger.debug(EELFLoggerDelegate.debugLogger, + "Database permissions don't seem correct, logging to error log to trigger alert."); + numIntervalsDatabasePermissionsIncorrect++; + } else { + numIntervalsDatabasePermissionsIncorrect = 0; + } + } + + // + // Get UEB status. Publish a bogus message to EP inbox, if 200 OK + // returned, status is Up. + // If down, signal alert once every X intervals. + // EP will ignore this bogus message. + // + uebUp = this.checkIfUebUp(); + if (uebUp == false) { + + if ((numIntervalsUebHasBeenDown % numIntervalsBetweenAlerts) == 0) { + // Write a Log entry that will generate an alert + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHealthCheckUebClusterError); + logger.debug(EELFLoggerDelegate.debugLogger, "UEB down, logging to error log to trigger alert"); + numIntervalsUebHasBeenDown++; + } else { + numIntervalsUebHasBeenDown = 0; + } + } + + // The front end should be up because the API is called through + // proxy front end server. + frontEndUp = true; + + // If the rest API called, the backend is always up + backEndUp = true; + + // + // future nice to have...get Partner status + // + // For all apps exposing a rest url, query one of the rest + // urls(/roles?) and manage a list + // of app name/status. We might not return back a non 200 OK in + // health check, but we + // could return information in the json content of a health check. + // + + // + // Get DB status. If down, signal alert once every X intervals. + // + if (Thread.interrupted()) { + logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting"); + break; + } + + try { + Thread.sleep(sleepInterval); + } catch (InterruptedException e) { + logger.error(EELFLoggerDelegate.errorLogger, "monitorEPHealth interrupted", e); + Thread.currentThread().interrupt(); + } + } + } + + @PostConstruct + public void initHealthMonitor() { + + healthMonitorThread = new Thread("EP HealthMonitor thread") { + public void run() { + try { + monitorEPHealth(); + } catch (InterruptedException e) { + logger.debug(EELFLoggerDelegate.debugLogger, "healthMonitorThread interrupted", e); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "healthMonitorThread failed", e); + } + } + }; + if (healthMonitorThread != null) { + healthMonitorThread.start(); + } + } + + @PreDestroy + public void closeHealthMonitor() { + this.healthMonitorThread.interrupt(); + } + + private boolean checkIfDatabaseUp() { + + boolean isUp = false; + + Session localSession = null; + + try { + localSession = sessionFactory.openSession(); + + if (localSession != null) { + + String sql = "select app_name from fn_app where app_id=1"; + Query query = localSession.createSQLQuery(sql); + @SuppressWarnings("unchecked") + List queryList = query.list(); + if (queryList != null) { + isUp = true; + } + localSession.close(); + } + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, "checkIfDatabaseUp failed", e); + isUp = false; + } + + return isUp; + } + + private boolean checkClusterStatus() { + + boolean isUp = false; + + Session localSession = null; + + try { + localSession = sessionFactory.openSession(); + if (localSession != null) { + // If all nodes are unhealthy in a cluster, this will throw an + // exception + String sql = "select * from mysql.user"; + Query query = localSession.createSQLQuery(sql); + @SuppressWarnings("unchecked") + List queryList = query.list(); + if (queryList != null) { + isUp = true; + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "checkClusterStatus failed", e); + if ((e.getCause() != null) && (e.getCause().getMessage() != null)) { + logger.error(EELFLoggerDelegate.errorLogger, + "checkClusterStatus() exception msg = " + e.getCause().getMessage()); + } + isUp = false; + } finally { + if (localSession != null) { + localSession.close(); + } + } + + return isUp; + + } + + private boolean checkDatabaseAndPermissions() { + + boolean isUp = false; + + Session localSession = null; + + try { + localSession = sessionFactory.openSession(); + if (localSession != null) { + String sql = "SHOW GRANTS FOR CURRENT_USER"; + Query query = localSession.createSQLQuery(sql); + @SuppressWarnings("unchecked") + List grantsList = query.list(); + for (String str : grantsList) { + if ((str.toUpperCase().contains("ALL")) + || (str.toUpperCase().contains("DELETE") && str.toUpperCase().contains("SELECT") + && str.toUpperCase().contains("UPDATE") && str.toUpperCase().contains("INSERT"))) { + isUp = true; + break; + } + } + if (isUp == false) { + logger.error(EELFLoggerDelegate.errorLogger, + "checkDatabaseAndPermissions() returning false. SHOW GRANTS FOR CURRENT_USER being dumped:"); + for (String str : grantsList) { + logger.error(EELFLoggerDelegate.errorLogger, "grants output item = [" + str + "]"); + } + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "checkDatabaseAndPermissions failed", e); + if ((e.getCause() != null) && (e.getCause().getMessage() != null)) { + logger.error(EELFLoggerDelegate.errorLogger, + "checkDatabaseAndPermissions() exception msg = " + e.getCause().getMessage()); + } + isUp = false; + } finally { + if (localSession != null) { + localSession.close(); + } + } + + return isUp; + + } + + private boolean checkIfUebUp() { + boolean uebUp = false; + try { + boolean isAvailable = epUebHelper.checkAvailability(); + boolean messageCanBeSent = epUebHelper.MessageCanBeSentToTopic(); + uebUp = (isAvailable && messageCanBeSent); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "checkIfUebUp failed", e); + } + + return uebUp; + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserContextListener.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserContextListener.java new file mode 100644 index 00000000..05af7388 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserContextListener.java @@ -0,0 +1,51 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.listener; + +import java.util.HashMap; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +@WebListener +public class UserContextListener implements ServletContextListener{ + @SuppressWarnings("rawtypes") + public void contextInitialized(ServletContextEvent event){ + ServletContext context = event.getServletContext(); + // + // instanciate a map to store references to all the active + // sessions and bind it to context scope. + // + HashMap activeUsers = new HashMap(); + context.setAttribute("activeUsers", activeUsers); + } + + /** + * Needed for the ServletContextListener interface. + */ + public void contextDestroyed(ServletContextEvent event){ + // To overcome the problem with losing the session references + // during server restarts, put code here to serialize the + // activeUsers HashMap. Then put code in the contextInitialized + // method that reads and reloads it if it exists... + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserSessionListener.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserSessionListener.java new file mode 100644 index 00000000..ebab2aa3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/listener/UserSessionListener.java @@ -0,0 +1,126 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ + +package org.openecomp.portalapp.portal.listener; + +import java.util.HashMap; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.annotation.WebListener; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.util.StringUtils; + +import org.openecomp.portalsdk.core.domain.support.CollaborateList; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.service.SharedContextService; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +/** + * Listens for session-create and session-destroy events. + */ +@WebListener +@SuppressWarnings({ "unchecked", "rawtypes" }) +public class UserSessionListener implements HttpSessionListener { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserSessionListener.class); + + /** + * Access to the database + */ + @Autowired + SharedContextService sharedContextService; + + public void init(ServletConfig config) { + } + + /** + * Adds sessions to the context scoped HashMap when they begin. + */ + public void sessionCreated(HttpSessionEvent event) { + HttpSession session = event.getSession(); + ServletContext context = session.getServletContext(); + HashMap activeUsers = (HashMap) context.getAttribute("activeUsers"); + + activeUsers.put(session.getId(), session); + context.setAttribute("activeUsers", activeUsers); + logger.info(EELFLoggerDelegate.debugLogger, "Session Created : " + session.getId()); + } + + /** + * Removes sessions from the context scoped HashMap when they expire or are + * invalidated. + */ + public void sessionDestroyed(HttpSessionEvent event) { + + try { + HttpSession session = event.getSession(); + ServletContext context = session.getServletContext(); + HashMap activeUsers = (HashMap) context.getAttribute("activeUsers"); + activeUsers.remove(session.getId()); + + EPUser user = (EPUser) session + .getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); + if (user!=null && !StringUtils.isEmpty(user.getOrgUserId())) { + CollaborateList.delUserName(user.getOrgUserId()); + } + + // Remove any shared context entries for this session. + if (getSharedContextService()!=null) { + getSharedContextService().deleteSharedContexts(session.getId()); + + // Clean the shared context each time a session is destroyed. + // TODO: move the threshold to configuration file. + getSharedContextService().expireSharedContexts(60 * 60 * 8); + } + + logger.info(EELFLoggerDelegate.debugLogger, "Session Destroyed : " + session.getId()); + + } catch (Exception e) { + logger.warn(EELFLoggerDelegate.errorLogger, "Exception occurred while executing sessionDestroyed. Details: " + EcompPortalUtils.getStackTrace(e)); + } + } + + private static ApplicationContext applicationContext; + + public static void setApplicationContext(ApplicationContext _applicationContext) { + applicationContext = _applicationContext; + } + + public SharedContextService getSharedContextService() { + if(sharedContextService == null){ + if (applicationContext != null) + sharedContextService = (SharedContextService)applicationContext.getBean("sharedContextService"); + } + + return sharedContextService; + } + + public void setSharedContextService(SharedContextService sharedContextService) { + this.sharedContextService = sharedContextService; + } +} + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java new file mode 100644 index 00000000..965866c8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPAuditLog.java @@ -0,0 +1,31 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface EPAuditLog { + String value() default ""; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java new file mode 100644 index 00000000..89f1b92f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java @@ -0,0 +1,371 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.aop; + +import java.net.InetAddress; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; + +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.exception.SessionExpiredException; +import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; +import org.openecomp.portalsdk.core.logging.format.AuditLogFormatter; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.slf4j.MDC; + +import com.att.eelf.configuration.Configuration; + +@org.springframework.context.annotation.Configuration +public class EPEELFLoggerAdvice { + + private EELFLoggerDelegate adviceLogger = EELFLoggerDelegate.getLogger(EPEELFLoggerAdvice.class); + + /** + * DateTime Format according to the ECOMP Application Logging Guidelines. + */ + private static final SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + + /** + * @return Current date and time in the format specified by the ECOMP + * Application Logging Guidelines. + */ + public static String getCurrentDateTimeUTC() { + String currentDateTime = ecompLogDateFormat.format(new Date()); + return currentDateTime; + } + + /** + * Sets logging context with values from HttpServletRequest object. + * + * @param req + * HttpServletRequest + * @param securityEventType + * SecurityEventTypeEnum + */ + public void loadServletRequestBasedDefaults(HttpServletRequest req, SecurityEventTypeEnum securityEventType) { + try { + setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, req.getServletPath()); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, "loadServletRequestBasedDefaults failed", e); + } + } + + /** + * + * @param securityEventType + * @param args + * @param passOnArgs + * @return + */ + public Object[] before(SecurityEventTypeEnum securityEventType, Object[] args, Object[] passOnArgs) { + String className = ""; + if (passOnArgs[0] != null) { + className = passOnArgs[0].toString(); + } + + String methodName = ""; + if (passOnArgs[1] != null) { + methodName = passOnArgs[1].toString(); + } + + // Initialize Request defaults only for controller methods. + MDC.put(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE); + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName); + if (securityEventType != null) { + MDC.put(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, + getCurrentDateTimeUTC()); + HttpServletRequest req = null; + if (args[0] != null && args[0] instanceof HttpServletRequest) { + req = (HttpServletRequest) args[0]; + this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName); + } + } + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); + logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName); + return new Object[] { "" }; + } + + /** + * + * @param securityEventType + * @param statusCode + * @param responseCode + * @param args + * @param returnArgs + * @param passOnArgs + */ + public void after(SecurityEventTypeEnum securityEventType, String statusCode, String responseCode, Object[] args, + Object[] returnArgs, Object[] passOnArgs) { + String className = ""; + if (passOnArgs[0] != null) + className = passOnArgs[0].toString(); + + // Method Name + String methodName = ""; + if (passOnArgs[1] != null) + methodName = passOnArgs[1].toString(); + + if (MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME) == null + || MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME) == "") + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName); + + if (MDC.get(EPCommonSystemProperties.TARGET_ENTITY) == null + || MDC.get(EPCommonSystemProperties.TARGET_ENTITY) == "") + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE); + + MDC.put(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, + MDC.get(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP)); + MDC.put(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); + this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP), + MDC.get(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP)); + + // Making sure to reload the INCOMING request MDC defaults if they have + // been wiped out by either Outgoing or LDAP Phone book search + // operations. + if (securityEventType != null && args[0] != null && args[0] instanceof HttpServletRequest + && securityEventType == SecurityEventTypeEnum.INCOMING_REST_MESSAGE + && (MDC.get(EPCommonSystemProperties.FULL_URL) == null + || MDC.get(EPCommonSystemProperties.FULL_URL) == "")) { + HttpServletRequest req = (HttpServletRequest) args[0]; + this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName); + } + + // Use external API response code in case if it resulted in an error. + String externalAPIResponseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + if (externalAPIResponseCode == null || externalAPIResponseCode == "" + || externalAPIResponseCode.trim().equalsIgnoreCase("200")) { + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, responseCode); + MDC.put(EPCommonSystemProperties.STATUS_CODE, statusCode); + } else { + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, externalAPIResponseCode); + MDC.put(EPCommonSystemProperties.STATUS_CODE, "ERROR"); + } + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); + logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName); + + // Log security message, if necessary + if (securityEventType != null) { + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, + MDC.get(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP)); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); + this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP), + MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP)); + + this.logSecurityMessage(logger, securityEventType, methodName); + + // Outgoing & LDAP messages are part of Incoming requests so, + // keep "RequestId", "PartnerName", "ServiceName", "LoginId" & + // "ResponseCode" etc. in memory and remove it only when + // finished processing the parent incoming message. + if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE + && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + MDC.remove(Configuration.MDC_SERVICE_NAME); + MDC.remove(EPCommonSystemProperties.MDC_LOGIN_ID); + MDC.remove(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + } + + // clear when finishes audit logging + MDC.remove(EPCommonSystemProperties.FULL_URL); + MDC.remove(EPCommonSystemProperties.PROTOCOL); + MDC.remove(EPCommonSystemProperties.STATUS_CODE); + MDC.remove(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.RESPONSE_CODE); + } + MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.MDC_TIMER); + MDC.remove(EPCommonSystemProperties.TARGET_ENTITY); + MDC.remove(EPCommonSystemProperties.TARGET_SERVICE_NAME); + } + + /** + * + * @param logger + * @param securityEventType + * @param restMethod + */ + private void logSecurityMessage(EELFLoggerDelegate logger, SecurityEventTypeEnum securityEventType, + String restMethod) { + StringBuilder additionalInfoAppender = new StringBuilder(); + String auditMessage = ""; + + if (securityEventType == SecurityEventTypeEnum.OUTGOING_REST_MESSAGE) { + additionalInfoAppender.append(String.format("%s '%s' request was initiated.", restMethod, + MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME))); + } else if (securityEventType == SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + additionalInfoAppender.append("LDAP Phonebook search operation is performed."); + } else { + additionalInfoAppender.append(String.format("%s request was received.", restMethod)); + + if (securityEventType == SecurityEventTypeEnum.FE_LOGIN_ATTEMPT) { + String loginId = ""; + String additionalMessage = " Successfully authenticated."; + loginId = MDC.get(EPCommonSystemProperties.MDC_LOGIN_ID); + if (loginId == null || loginId == "" || loginId == EPCommonSystemProperties.UNKNOWN) { + additionalMessage = " No cookies are found."; + } + additionalInfoAppender.append(additionalMessage); + } else if (securityEventType == SecurityEventTypeEnum.FE_LOGOUT) { + additionalInfoAppender.append(" User has been successfully logged out."); + } + } + + String fullURL = MDC.get(EPCommonSystemProperties.FULL_URL); + if (fullURL != null && fullURL != "") { + additionalInfoAppender.append(" Request-URL:" + MDC.get(EPCommonSystemProperties.FULL_URL)); + } + + auditMessage = AuditLogFormatter.getInstance().createMessage(MDC.get(EPCommonSystemProperties.PROTOCOL), + securityEventType.name(), MDC.get(EPCommonSystemProperties.MDC_LOGIN_ID), + additionalInfoAppender.toString()); + + logger.info(EELFLoggerDelegate.auditLogger, auditMessage); + } + + /** + * + * @param req + * @param securityEventType + * @param restMethod + */ + private void setHttpRequestBasedDefaultsIntoGlobalLoggingContext(HttpServletRequest req, + SecurityEventTypeEnum securityEventType, String restMethod) { + /** + * No need to load the request based defaults for the following security + * messages since either they are initiated by the Portal BE or not Http + * request based. + */ + if (req != null) { + if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE + && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH + && securityEventType != SecurityEventTypeEnum.INCOMING_UEB_MESSAGE) { + // Load the RequestID (aka TrasactionId) into MDC context. + String requestId = UserUtils.getRequestId(req); + if (requestId == "" || requestId == null) { + requestId = UUID.randomUUID().toString(); + } + MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId); + + // Load user agent into MDC context, if available. + String accessingClient = "Unknown"; + accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME); + if (accessingClient != null && accessingClient != "" && (accessingClient.contains("Mozilla") + || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) { + accessingClient = EPCommonSystemProperties.ECOMP_PORTAL_FE; + } + MDC.put(EPCommonSystemProperties.PARTNER_NAME, accessingClient); + + // Load loginId into MDC context. + EPUser user = null; + try { + user = EPUserUtils.getUserSession(req); + } catch (SessionExpiredException se) { + adviceLogger.debug(EELFLoggerDelegate.debugLogger, + "setHttpRequestBasedDefaultsIntoGlobalLoggingContext: No user found in session"); + } + + MDC.put(EPCommonSystemProperties.MDC_LOGIN_ID, (user != null ? user.getOrgUserId() : "NoUser")); + + // Rest URL & Protocol + String restURL = ""; + MDC.put(EPCommonSystemProperties.FULL_URL, EPCommonSystemProperties.UNKNOWN); + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP); + restURL = UserUtils.getFullURL(req); + if (restURL != null && restURL != "") { + MDC.put(EPCommonSystemProperties.FULL_URL, restURL); + if (restURL.toLowerCase().contains("https")) { + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS); + } + } + + // Rest Path + MDC.put(Configuration.MDC_SERVICE_NAME, restMethod); + String restPath = req.getServletPath(); + if (restPath != null && restPath != "") { + MDC.put(Configuration.MDC_SERVICE_NAME, restPath); + } + + // Client IPAddress i.e. IPAddress of the remote host who is + // making this request. + String clientIPAddress = ""; + clientIPAddress = req.getHeader("X-FORWARDED-FOR"); + if (clientIPAddress == null) { + clientIPAddress = req.getRemoteAddr(); + } + MDC.put(EPCommonSystemProperties.CLIENT_IP_ADDRESS, clientIPAddress); + } else if (securityEventType == SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, "Phonebook"); + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, "search"); + } + } else { + MDC.put(Configuration.MDC_SERVICE_NAME, restMethod); + MDC.put(EPCommonSystemProperties.PARTNER_NAME, EPCommonSystemProperties.ECOMP_PORTAL_FE); + } + + MDC.put(Configuration.MDC_SERVICE_INSTANCE_ID, ""); + MDC.put(Configuration.MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.toString()); + try { + MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName()); + MDC.put(Configuration.MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); + MDC.put(Configuration.MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, + "setHttpRequestBasedDefaultsIntoGlobalLoggingContext failed", e); + } + } + + /** + * + * @param beginDateTime + * @param endDateTime + */ + private void calculateDateTimeDifference(String beginDateTime, String endDateTime) { + if (beginDateTime != null && endDateTime != null) { + try { + Date beginDate = ecompLogDateFormat.parse(beginDateTime); + Date endDate = ecompLogDateFormat.parse(endDateTime); + String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime()); + MDC.put(SystemProperties.MDC_TIMER, timeDifference); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, "calculateDateTimeDifference failed", e); + } + } + } + + public String getInternalResponseCode() { + return MDC.get(EPCommonSystemProperties.RESPONSE_CODE); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java new file mode 100644 index 00000000..ab8a3672 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPMetricsLog.java @@ -0,0 +1,31 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface EPMetricsLog { + String value() default ""; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties new file mode 100644 index 00000000..6ee63b24 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/ApplicationCodes.properties @@ -0,0 +1,141 @@ +### +# ================================================================================ +# 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. +# 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. +# ================================================================================ +### +######################################################################## +#Resource key=Error Code|Message text|Resolution text |Description text +####### +#Newlines can be utilized to add some clarity ensuring continuing line +#has atleast one leading space +#ResourceKey=\ +# ERR0000E\ +# Sample error msg txt\ +# Sample resolution msg\ +# Sample description txt +# +###### +#Error code classification category +#100 Permission errors +#200 Availability errors/Timeouts +#300 Data errors +#400 Schema Interface type/validation errors +#500 Business process errors +#900 Unknown errors +# +######################################################################## + +# Define Alarm Codes Specific to ECOMP Portal +BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT= ||Reason: {0}.|\ + An Authentication failure occurred during access to UEB server. Please check that UEB keys are configured correctly under fusion.properties file. + +BERESTAPIAUTHENTICATIONERROR = |||Please check application credentials defined in Database or portal.properties file. + +INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. + +INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. + +INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. + +INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT=||Description: {0}.|Please check the logs for more information. + +BEHEALTHCHECKERROR= |||Please check the logs for more information. + +BEHEALTHCHECKMYSQLERROR= ||Please check the logs for more information.|\ + Check connectivity to MYSQL is configured correctly under system.properties file. + +BEHEALTHCHECKUEBCLUSTERERROR= ||Please check the logs for more information.|\ + Check connectivity to UEB cluster which is configured under portal.properties file. + +FEHEALTHCHECKERROR= |||Please check connectivity from this FE instance towards BE or BE Load Balancer. + +BEHEALTHCHECKRECOVERY= |||Please check logs for more specific information about the problem. + +BEHEALTHCHECKMYSQLRECOVERY= |||Please check logs for more specific information about the problem. + +BEHEALTHCHECKUEBCLUSTERRECOVERY= |||Please check logs for more specific information about the problem. + +FEHEALTHCHECKRECOVERY= |||Please check logs for more specific information about the problem. + +#UEB communication +BEUEBCONNECTIONERROR_ONE_ARGUMENT= ||Reason: {0}.|\ + Please check UEB server list and keys configured under Portal.Properties file. + +BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT= ||Cannot reach host {0}.|\ + Please check UEB server list and keys configured under Portal.Properties file. + +#Onboarding apps +BEUEBREGISTERONBOARDINGAPPERROR= ||Reason: {0}.|\ + Please check UEB server list and keys configured under Portal.Properties file. + +#HTTP communication +BEHTTPCONNECTIONERROR_ONE_ARGUMENT= ||Reason: {0}.|Please check the logs for more information. + +INTERNALCONNECTIONINFO_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. + +INTERNALCONNECTIONWARNING_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. + +INTERNALCONNECTIONERROR_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. + +INTERNALCONNECTIONFATAL_ONE_ARGUMENT= ||Description: {0}.|Please check the logs for more information. + +BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT= ||Data not found: {0}.|\ + An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic. + +#Login error codes +BEUSERMISSINGERROR_ONE_ARGUMENT= |||\ + User {0} must be added to the corresponding application with proper user roles. + +BEUSERINACTIVEWARNING_ONE_ARGUMENT= |||\ + User {0} must be added to the corresponding application with proper user roles. + +BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT= |||\ + User {0} should be given proper administrator role for the corresponding application to perform the necessary actions. + +BEINVALIDJSONINPUT= |||Please check error logs for more information. + +BEINCORRECTHTTPSTATUSERROR= |||Please check logs for more information. + +BEINITIALIZATIONERROR= |||Please check logs for more information. + +BEUEBSYSTEMERROR= ||\ + Operation: {0}.|\ + An error occurred in {1} distribution mechanism. Please check the logs for more information. + +BEDAOSYSTEMERROR= |||Please check MySQL DB health or look at the logs for more details. + +BESYSTEMERROR= |||Please check logs for more information. + +BEEXECUTEROLLBACKERROR= |||Please check MYSQL DB health or look at the logs for more details. + +FEHTTPLOGGINGERROR= |||Please check MYSQL DB health or look at the logs for more details. + +FEPORTALSERVLETERROR= |||Please check logs for more specific information about the problem. + +BEDAOCLOSESESSIONERROR= |||Please check MYSQL DB health or look at the logs form more details. + +BERESTAPIGENERALERROR= |||Please check error log for more information. + +FEHEALTHCHECKGENERALERROR= |||Please check error log for more information. + +INTERNALUNEXPECTEDINFO_ONE_ARGUMENT= |||Description: {0}. + +INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT= |||Description: {0}. + +INTERNALUNEXPECTEDERROR_ONE_ARGUMENT= |||Description: {0}. + +INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT= |||Description: {0}. diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java new file mode 100644 index 00000000..a9cb2e4c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPAppMessagesEnum.java @@ -0,0 +1,260 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.format; + +import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; +import org.openecomp.portalsdk.core.logging.format.ErrorSeverityEnum; +import org.openecomp.portalsdk.core.logging.format.ErrorTypeEnum; + +/** + * + * @author rc580q + * Add ECOMP Portal Specific Error Code Enums here, for generic + * ones (ones you think are useful not only Portal but also SDK), add it + * to the enum class AppMessagesEnum defined in SDK. + */ +public enum EPAppMessagesEnum { + /* + 100-199 Security/Permission Related + - Authentication problems (from external client, to external server) + - Certification errors + - + + 200-299 Availability/Timeout Related + - connectivity error + - connection timeout + + 300-399 Data Access/Integrity Related + - Data in graph in invalid(E.g. no creator is found for service) + - Artifact is missing in ES, but exists in graph. + + 400-499 Schema Interface Type/Validation + - received Pay-load checksum is invalid + - received JSON is not valid + + 500-599 Business/Flow Processing Related + - check out to service is not allowed + - Roll-back is done + - failed to generate heat file + + + 600-899 Reserved - do not use + + 900-999 Unknown Errors + - Unexpected exception + */ + + BeUebAuthenticationError(EPErrorCodesEnum.BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR100E", "An Authentication failure occurred during access to UEB server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), + + BeRestApiAuthenticationError(EPErrorCodesEnum.BERESTAPIAUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR101E", "Rejected an incoming REST API request due to invalid credentials", "", "Please check application credentials defined in Database or properties files."), + + InternalAuthenticationInfo(EPErrorCodesEnum.INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR199I", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), + + InternalAuthenticationWarning(EPErrorCodesEnum.INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR199W", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), + + InternalAuthenticationError(EPErrorCodesEnum.INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR199E", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), + + InternalAuthenticationFatal(EPErrorCodesEnum.INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR199F", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), + + BeHealthCheckError(EPErrorCodesEnum.BeHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR200E", "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", "", "Please check the logs for more information."), + + BeHealthCheckMySqlError(EPErrorCodesEnum.BEHEALTHCHECKMYSQLERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR201E", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", "Check connectivity to MYSQL is configured correctly under system.properties file."), + + BeHealthCheckUebClusterError(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR203E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", "Check connectivity to UEB cluster which is configured under portal.properties file."), + + FeHealthCheckError(EPErrorCodesEnum.FEHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR204E", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", "Please check connectivity from this FE instance towards BE or BE Load Balancer."), + + BeHealthCheckRecovery(EPErrorCodesEnum.BEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR205I", "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", "Please check logs for more specific information about the problem."), + + BeHealthCheckMySqlRecovery(EPErrorCodesEnum.BEHEALTHCHECKMYSQLRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR206I", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", "Please check logs for more specific information about the problem."), + + BeHealthCheckUebClusterRecovery(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR208I", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", "Please check logs for more specific information about the problem."), + + FeHealthCheckRecovery(EPErrorCodesEnum.FEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR209I", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", "Please check logs for more specific information about the problem."), + + BeUebConnectionError(EPErrorCodesEnum.BEUEBCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR210E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), + + BeUebUnkownHostError(EPErrorCodesEnum.BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR211E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), + + BeUebRegisterOnboardingAppError(EPErrorCodesEnum.BEUEBREGISTERONBOARDINGAPPERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR212E", "Failed to register the On-boarding application with UEB Communication server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), + + BeHttpConnectionError(EPErrorCodesEnum.BEHTTPCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR213E", "It could be that communication to an external application might resulted an exception or failed to reach the external application", + "Details: {0}.", "Please check logs for more information."), + + InternalConnectionInfo(EPErrorCodesEnum.INTERNALCONNECTIONINFO_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR299I", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionWarning(EPErrorCodesEnum.INTERNALCONNECTIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR299W", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionError(EPErrorCodesEnum.INTERNALCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR299E", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionFatal(EPErrorCodesEnum.INTERNALCONNECTIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR299F", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + BeUebObjectNotFoundError(EPErrorCodesEnum.BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR303E", "Error occurred during access to U-EB Server.", "Data not found: {0}.", "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."), + + BeUserMissingError(EPErrorCodesEnum.BEUSERMISSINGERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR310E", "User is not found", "", "User {0} must be added to the corresponding application with proper user roles."), + + BeUserInactiveWarning(EPErrorCodesEnum.BEUSERINACTIVEWARNING_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR313W", "User is found but in-active", "", "User {0} must be added to the corresponding application with proper user roles."), + + BeUserAdminPrivilegesInfo(EPErrorCodesEnum.BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR314W", "User is found but don't have administrative privileges", "", "User {0} should be given administrator role for the corresponding application to perform the necessary actions."), + + BeInvalidJsonInput(EPErrorCodesEnum.BEINVALIDJSONINPUT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR405E", "Failed to convert JSON input to object", "", "Please check logs for more information."), + + BeIncorrectHttpStatusError(EPErrorCodesEnum.BEINCORRECTHTTPSTATUSERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR407E", "Communication to an external application is resulted in with Incorrect Http response code", "", "Please check logs for more information."), + + BeInitializationError(EPErrorCodesEnum.BEINITIALIZATIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR500E", "ECOMP-PORTAL Back-end was not initialized properly", "", "Please check logs for more information."), + + BeUebSystemError(EPErrorCodesEnum.BEUEBSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR502E", "Error occurred during access to U-EB Server", "Details: {0}.", "An error occurred in {1} distribution mechanism. Please check the logs for more information."), + + BeDaoSystemError(EPErrorCodesEnum.BEDAOSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR505E", "Performing DDL or DML operations on database might have failed", "", "Please check MySQL DB health or look at the logs for more details."), + + BeSystemError(EPErrorCodesEnum.BESYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR506E", "Unexpected error during operation", "", "Please check logs for more information."), + + BeExecuteRollbackError(EPErrorCodesEnum.BEEXECUTEROLLBACKERROR, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR507E", "Roll-back operation towards database has failed", "", "Please check MYSQL DB health or look at the logs for more details."), + + FeHttpLoggingError(EPErrorCodesEnum.FEHTTPLOGGINGERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.ERROR, + "ERR517E", "Error when logging FE HTTP request/response", "", "Please check MYSQL DB health or look at the logs for more details."), + + FePortalServletError(EPErrorCodesEnum.FEPORTALSERVLETERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR518E", "Error when trying to access FE Portal page.", "", "Please check logs for more information."), + + BeDaoCloseSessionError(EPErrorCodesEnum.BEDAOCLOSESESSIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR519E", "Close local session operation with database failed", "", "Please check MYSQL DB health or look at the logs form more details."), + + BeRestApiGeneralError(EPErrorCodesEnum.BERESTAPIGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR900E", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", "Please check error log for more information."), + + FeHealthCheckGeneralError(EPErrorCodesEnum.FEHEALTHCHECKGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR901E", "General error during FE Health Check", "", "Please check error log for more information."), + + InternalUnexpectedInfo(EPErrorCodesEnum.INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR999I", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedWarning(EPErrorCodesEnum.INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR999W", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedError(EPErrorCodesEnum.INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR999E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedFatal(EPErrorCodesEnum.INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR999F", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + ; + + ErrorTypeEnum eType; + AlarmSeverityEnum alarmSeverity; + EPErrorCodesEnum messageCode; + ErrorSeverityEnum errorSeverity; + String errorCode; + String errorDescription; + String details; + String resolution; + + EPAppMessagesEnum(EPErrorCodesEnum messageCode, ErrorTypeEnum eType, AlarmSeverityEnum alarmSeverity, ErrorSeverityEnum errorSeverity, String errorCode, String errorDescription, + String details, String resolution) { + this.messageCode = messageCode; + this.eType = eType; + this.alarmSeverity = alarmSeverity; + this.errorSeverity = errorSeverity; + this.errorCode = errorCode; + this.errorDescription = errorDescription; + this.details = details; + this.resolution = resolution; + } + + public String getDetails() { + return this.details; + } + + public String getResolution() { + return this.resolution; + } + public String getErrorCode() { + return this.errorCode; + } + + public String getErrorDescription() { + return this.errorDescription; + } + + public ErrorSeverityEnum getErrorSeverity() { + return this.errorSeverity; + } + + public void setErrorSeverity(ErrorSeverityEnum errorSeverity) { + this.errorSeverity = errorSeverity; + } + + public EPErrorCodesEnum getMessageCode() { + return messageCode; + } + + public void setMessageCode(EPErrorCodesEnum messageCode) { + this.messageCode = messageCode; + } + + public AlarmSeverityEnum getAlarmSeverity() { + return alarmSeverity; + } + + public void setAlarmSeverity(AlarmSeverityEnum alarmSeverity) { + this.alarmSeverity = alarmSeverity; + } + + public ErrorTypeEnum getErrorType() { + return eType; + } + + public void setErrorType(ErrorTypeEnum eType) { + this.eType = eType; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java new file mode 100644 index 00000000..cbfb4fa3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/format/EPErrorCodesEnum.java @@ -0,0 +1,95 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.format; + +import com.att.eelf.i18n.EELFResolvableErrorEnum; +import com.att.eelf.i18n.EELFResourceManager; + +/** + * + * @author rc580q + * Add ECOMP Portal Specific Error Code Enums here, for generic + * ones (ones you think are useful not only Portal but also SDK), add it + * to the enum class AppMessagesEnum defined in SDK. + */ +public enum EPErrorCodesEnum implements EELFResolvableErrorEnum { + BERESTAPIAUTHENTICATIONERROR, + BEHTTPCONNECTIONERROR_ONE_ARGUMENT, + BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, + + INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, + INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, + INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, + INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, + + BEHEALTHCHECKRECOVERY, + BEHEALTHCHECKMYSQLRECOVERY, + BEHEALTHCHECKUEBCLUSTERRECOVERY, + FEHEALTHCHECKRECOVERY, + BeHEALTHCHECKERROR, + + BEHEALTHCHECKMYSQLERROR, + BEHEALTHCHECKUEBCLUSTERERROR, + FEHEALTHCHECKERROR, + BEUEBCONNECTIONERROR_ONE_ARGUMENT, + BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, + BEUEBREGISTERONBOARDINGAPPERROR, + + INTERNALCONNECTIONINFO_ONE_ARGUMENT, + INTERNALCONNECTIONWARNING_ONE_ARGUMENT, + INTERNALCONNECTIONERROR_ONE_ARGUMENT, + INTERNALCONNECTIONFATAL_ONE_ARGUMENT, + + BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, + BEUSERMISSINGERROR_ONE_ARGUMENT, + + BEUSERINACTIVEWARNING_ONE_ARGUMENT, + BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, + + BEINVALIDJSONINPUT, + BEINCORRECTHTTPSTATUSERROR, + + BEINITIALIZATIONERROR, + BEUEBSYSTEMERROR, + BEDAOSYSTEMERROR, + BESYSTEMERROR, + BEEXECUTEROLLBACKERROR, + + FEHTTPLOGGINGERROR, + FEPORTALSERVLETERROR, + BEDAOCLOSESESSIONERROR, + + BERESTAPIGENERALERROR, + FEHEALTHCHECKGENERALERROR, + + INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, + INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, + INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, + INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, + ; + + /** + * Static initializer to ensure the resource bundles for this class are loaded... + * Here this application loads messages from three bundles + */ + static { + EELFResourceManager.loadMessageBundle("org/openecomp/portalapp/portal/logging/format/ApplicationCodes"); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java new file mode 100644 index 00000000..aa86765b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/logging/logic/EPLogUtil.java @@ -0,0 +1,270 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.logging.logic; + +import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY; + +import java.text.MessageFormat; + +import org.slf4j.MDC; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; +import org.openecomp.portalsdk.core.logging.format.ErrorSeverityEnum; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; + +public class EPLogUtil { + + // This class has no logger. It uses loggers passed to it. + + /** + * Formats and writes a message to the error log with the class name and the + * specified parameters, using log level info, warn or error appropriate for + * the specified severity + * + * @param classLogger + * Logger for the class where the error occurred; the logger + * carries the class name. + * @param epMessageEnum + * Enum carrying alarm and error severity + * @param param + * Values used to build the message. + */ + public static void logEcompError(EELFLoggerDelegate classLogger, EPAppMessagesEnum epMessageEnum, String... param) { + logEcompError(classLogger, epMessageEnum, null, param); + } + + /** + * Formats and writes a message to the error log with the class name and the + * specified parameters, using log level info, warn or error appropriate for + * the specified severity + * + * @param classLogger + * Logger for the class where the error occurred; the logger + * carries the class name. + * @param epMessageEnum + * Enum carrying alarm and error severity + * @param param + * Values used to build the message. + */ + private static EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger(); + public static void logEcompError(EPAppMessagesEnum epMessageEnum, String... param) { + try { + AlarmSeverityEnum alarmSeverityEnum = epMessageEnum.getAlarmSeverity(); + ErrorSeverityEnum errorSeverityEnum = epMessageEnum.getErrorSeverity(); + + MDC.put(MDC_ALERT_SEVERITY, alarmSeverityEnum.name()); + MDC.put("ErrorCode", epMessageEnum.getErrorCode()); + MDC.put("ErrorDescription", epMessageEnum.getErrorDescription()); + MDC.put("ClassName", EPLogUtil.class.getName()); + + String resolution = EPLogUtil.formatMessage(epMessageEnum.getDetails() + " " + epMessageEnum.getResolution(), (Object[]) param); + if (errorSeverityEnum == ErrorSeverityEnum.WARN) { + errorLogger.warn(resolution); + } else if(errorSeverityEnum == ErrorSeverityEnum.INFO) { + errorLogger.info(resolution); + } else { + errorLogger.error(resolution); + } + } catch(Exception e) { + errorLogger.error("Failed to log the error code. Details: " + UserUtils.getStackTrace(e)); + } finally { + MDC.remove("ErrorCode"); + MDC.remove("ErrorDescription"); + MDC.remove("ClassName"); + MDC.remove(MDC_ALERT_SEVERITY); + } + } + + /** + * Formats and writes a message to the error log with the class name, + * throwable and the specified parameters, using log level info, warn or + * error appropriate for the specified severity + * + * @param classLogger + * Logger for the class where the error occurred; the logger + * carries the class name. + * @param epMessageEnum + * Enum carrying alarm and error severity + * @param th + * Throwable; ignored if null + * @param param + * Array of Strings used to build the message. + */ + @SuppressWarnings("static-access") + public static void logEcompError(EELFLoggerDelegate classLogger, EPAppMessagesEnum epMessageEnum, Throwable th, + String... param) { + + AlarmSeverityEnum alarmSeverityEnum = epMessageEnum.getAlarmSeverity(); + ErrorSeverityEnum errorSeverityEnum = epMessageEnum.getErrorSeverity(); + + MDC.put(MDC_ALERT_SEVERITY, alarmSeverityEnum.name()); + MDC.put("ErrorCode", epMessageEnum.getErrorCode()); + MDC.put("ErrorDescription", epMessageEnum.getErrorDescription()); + + final String message = EPLogUtil.formatMessage(epMessageEnum.getDetails() + " " + epMessageEnum.getResolution(), + (Object[]) param); + if (errorSeverityEnum == ErrorSeverityEnum.INFO) { + if (th == null) + classLogger.info(classLogger.errorLogger, message); + else + classLogger.info(classLogger.errorLogger, message, th); + } else if (errorSeverityEnum == ErrorSeverityEnum.WARN) { + if (th == null) + classLogger.warn(classLogger.errorLogger, message); + else + classLogger.warn(classLogger.errorLogger, message, th); + } else { + if (th == null) + classLogger.error(classLogger.errorLogger, message); + else + classLogger.error(classLogger.errorLogger, message, th); + } + + // Clean up + MDC.remove(MDC_ALERT_SEVERITY); + MDC.remove("ErrorCode"); + MDC.remove("ErrorDescription"); + } + + /** + * Builds a string using the format and parameters. + * @param message + * @param args + * @return + */ + private static String formatMessage(String message, Object... args) { + StringBuilder sbFormattedMessage = new StringBuilder(); + if (args != null && args.length > 0 && message != null && message != "") { + MessageFormat mf = new MessageFormat(message); + sbFormattedMessage.append(mf.format(args)); + } else { + sbFormattedMessage.append(message); + } + return sbFormattedMessage.toString(); + } + + /** + * Builds a comma-separated string of values to document a user action. + * + * @param action + * @param activity + * @param userId + * @param affectedId + * @param comment + * @return Value suitable for writing to the audit log file. + */ + public static String formatAuditLogMessage(String action, String activity, String userId, String affectedId, + String comment) { + StringBuilder auditLogMsg = new StringBuilder(); + auditLogMsg.append("Click_A:["); + if (action != null && !action.equals("")) { + auditLogMsg.append(" Action: "); + auditLogMsg.append(action); + } + + if (activity != null && !activity.equals("")) { + auditLogMsg.append(",Activity CD: "); + auditLogMsg.append(activity); + } + + if (userId != null && !userId.equals("")) { + auditLogMsg.append(",User ID: "); + auditLogMsg.append(userId); + } + + if (affectedId != null && !affectedId.equals("")) { + auditLogMsg.append(",Affected ID: "); + auditLogMsg.append(affectedId); + } + + if (comment != null && !comment.equals("")) { + auditLogMsg.append(",Comment: "); + auditLogMsg.append(comment); + } + auditLogMsg.append("]"); + return auditLogMsg.toString(); + } + + /** + * Builds a comma-separated string of values to document a user browser + * action. + * + * @param orgUserId + * @param action + * @param activity + * @param actionLink + * @param page + * @param function + * @param type + * @return Value suitable for writing to the audit log file. + */ + public static String formatStoreAnalyticsAuditLogMessage(String orgUserId, String appName, String action, String activity, + String actionLink, String page, String function, String type) { + StringBuilder auditLogStoreAnalyticsMsg = new StringBuilder(); + auditLogStoreAnalyticsMsg.append("Click_Analytics:["); + if (orgUserId != null && !orgUserId.equals("")) { + auditLogStoreAnalyticsMsg.append(" Organization User ID: "); + auditLogStoreAnalyticsMsg.append(orgUserId); + } + + if (appName != null && !appName.equals("")) { + auditLogStoreAnalyticsMsg.append(",AppName: "); + auditLogStoreAnalyticsMsg.append(appName); + } + + if (action != null && !action.equals("")) { + auditLogStoreAnalyticsMsg.append(",Action: "); + auditLogStoreAnalyticsMsg.append(action); + } + + if (activity != null && !activity.equals("")) { + auditLogStoreAnalyticsMsg.append(",Activity: "); + auditLogStoreAnalyticsMsg.append(activity); + } + + if (actionLink != null && !actionLink.equals("")) { + auditLogStoreAnalyticsMsg.append(",ActionLink: "); + auditLogStoreAnalyticsMsg.append(actionLink); + } + + if (page != null && !page.equals("")) { + auditLogStoreAnalyticsMsg.append(",Page: "); + auditLogStoreAnalyticsMsg.append(page); + } + + if (function != null && !function.equals("")) { + auditLogStoreAnalyticsMsg.append(",Function: "); + auditLogStoreAnalyticsMsg.append(function); + } + + if (type != null && !type.equals("")) { + auditLogStoreAnalyticsMsg.append(",Type: "); + auditLogStoreAnalyticsMsg.append(type); + } + auditLogStoreAnalyticsMsg.append("]"); + return auditLogStoreAnalyticsMsg.toString(); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesService.java new file mode 100644 index 00000000..a1016e1c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesService.java @@ -0,0 +1,56 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.transport.AppsListWithAdminRole; + +public interface AdminRolesService { + + public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(String orgUserId); + + public boolean setAppsWithAdminRoleStateForUser(AppsListWithAdminRole newAppsListWithAdminRoles); + + /** + * Attention! User roles in ECOMP PORTAL cannot be managed by this function. + * @param user + * @return 'true' if user has Super Administrator role SYS_ADMIN_ROLE_ID (1 for now) in ECOMP PORTAL, 'false' otherwise + */ + public boolean isSuperAdmin(EPUser user); + + /** + * Attention! User roles in ECOMP PORTAL cannot be managed by this function. + * @param user + * @return 'true' if user has Account Administrator role ACCOUNT_ADMIN_ROLE_ID (999 for now) for any application except ECOMP Portal, 'false' otherwise + */ + public boolean isAccountAdmin(EPUser user); + + /** + * Attention! User roles in ECOMP PORTAL cannot be managed by this function. + * @param user + * @return 'true' if user has any remote(!) role within any application (ECOMP Portal roles are not included), 'false' otherwise + */ + public boolean isUser(EPUser user); + + List getRolesByApp(EPUser user, Long appId); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesServiceImpl.java new file mode 100644 index 00000000..50e7348e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AdminRolesServiceImpl.java @@ -0,0 +1,329 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.apache.cxf.common.util.StringUtils; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserApp; +import org.openecomp.portalapp.portal.domain.UserIdRoleId; +import org.openecomp.portalapp.portal.domain.UserRole; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.transport.AppNameIdIsAdmin; +import org.openecomp.portalapp.portal.transport.AppsListWithAdminRole; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("adminRolesService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy + +public class AdminRolesServiceImpl implements AdminRolesService { + + private Long SYS_ADMIN_ROLE_ID = 1L; + private Long ACCOUNT_ADMIN_ROLE_ID = 999L; + private Long ECOMP_APP_ID = 1L; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AdminRolesServiceImpl.class); + + @Autowired + private SessionFactory sessionFactory; + @Autowired + private DataAccessService dataAccessService; + @Autowired + SearchService searchService; + @Autowired + EPAppService appsService; + + @PostConstruct + private void init() { + try { + SYS_ADMIN_ROLE_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.SYS_ADMIN_ROLE_ID)); + ACCOUNT_ADMIN_ROLE_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ACCOUNT_ADMIN_ROLE_ID)); + ECOMP_APP_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ECOMP_APP_ID)); + } catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + } + + @Override + @EPMetricsLog + @SuppressWarnings("unchecked") + public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(String orgUserId) { + AppsListWithAdminRole appsListWithAdminRole = null; + + try { + List userList = dataAccessService.getList(EPUser.class, " where orgUserId = '" + orgUserId + "'", null, + null); + HashMap appsUserAdmin = new HashMap(); + if (userList.size() > 0) { + EPUser user = userList.get(0); + List userAppList = null; + try { + userAppList = dataAccessService.getList(EPUserApp.class, + " where userId = " + user.getId() + " and role.id = " + ACCOUNT_ADMIN_ROLE_ID, null, null); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + EPLogUtil.logEcompError(EPAppMessagesEnum.BeDaoSystemError); + } + for (EPUserApp userApp : userAppList) { + appsUserAdmin.put(userApp.getAppId(), userApp.getUserId()); + } + } + + appsListWithAdminRole = new AppsListWithAdminRole(); + appsListWithAdminRole.orgUserId = orgUserId; + List appsList = null; + try { + appsList = dataAccessService.getList(EPApp.class, " where ( enabled = 'Y' or id = " + ECOMP_APP_ID + ")", null, null); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + EPLogUtil.logEcompError(EPAppMessagesEnum.BeDaoSystemError); + } + for (EPApp app : appsList) { + AppNameIdIsAdmin appNameIdIsAdmin = new AppNameIdIsAdmin(); + appNameIdIsAdmin.id = app.getId(); + appNameIdIsAdmin.appName = app.getName(); + appNameIdIsAdmin.isAdmin = new Boolean(appsUserAdmin.containsKey(app.getId())); + appNameIdIsAdmin.restrictedApp = app.isRestrictedApp(); + appsListWithAdminRole.appsRoles.add(appNameIdIsAdmin); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing AdminRolesServiceImpl.getAppsWithAdminRoleStateForUser operation, Details:" + + EcompPortalUtils.getStackTrace(e)); + } + + return appsListWithAdminRole; + } + + private static final Object syncRests = new Object(); + + @Override + @EPMetricsLog + @SuppressWarnings("unchecked") + public boolean setAppsWithAdminRoleStateForUser(AppsListWithAdminRole newAppsListWithAdminRoles) { + boolean result = false; + // No changes if no new roles list or no userId. + if (!StringUtils.isEmpty(newAppsListWithAdminRoles.orgUserId) && newAppsListWithAdminRoles.appsRoles != null) { + synchronized (syncRests) { + List apps = appsService.getAppsFullList(); + HashMap enabledApps = new HashMap(); + for (EPApp app : apps) { + if (app.getEnabled().booleanValue() || app.getId() == ECOMP_APP_ID) { + enabledApps.put(app.getId(), app); + } + } + List newAppsWhereUserIsAdmin = new ArrayList(); + for (AppNameIdIsAdmin adminRole : newAppsListWithAdminRoles.appsRoles) { + // user Admin role may be added only for enabled apps + if (adminRole.isAdmin.booleanValue() && enabledApps.containsKey(adminRole.id)) { + newAppsWhereUserIsAdmin.add(adminRole); + } + } + EPUser user = null; + boolean createNewUser = false; + String orgUserId = newAppsListWithAdminRoles.orgUserId.trim(); + List localUserList = dataAccessService.getList(EPUser.class, " where org_user_id='" + orgUserId + "'", + null, null); + List oldAppsWhereUserIsAdmin = new ArrayList(); + if (localUserList.size() > 0) { + EPUser tmpUser = localUserList.get(0); + oldAppsWhereUserIsAdmin = dataAccessService.getList(EPUserApp.class, + " where userId = " + tmpUser.getId() + " and role.id = " + ACCOUNT_ADMIN_ROLE_ID, null, + null); + if (oldAppsWhereUserIsAdmin.size() > 0 || newAppsWhereUserIsAdmin.size() > 0) { + user = tmpUser; + } + } else if (newAppsWhereUserIsAdmin.size() > 0) { + // we create new user only if he has Admin Role for any App + createNewUser = true; + } + if (user != null || createNewUser) { + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + if (createNewUser) { + user = this.searchService.searchUserByUserId(orgUserId); + if (user != null) { + // insert the user with active true in order to + // pass login phase. + user.setActive(true); + localSession.save(EPUser.class.getName(), user); + } + } + for (EPUserApp oldUserApp : oldAppsWhereUserIsAdmin) { + // user Admin role may be deleted only for enabled + // apps + if (enabledApps.containsKey(oldUserApp.getAppId())) { + localSession.delete(oldUserApp); + } + } + for (AppNameIdIsAdmin appNameIdIsAdmin : newAppsWhereUserIsAdmin) { + EPApp app = (EPApp) localSession.get(EPApp.class, appNameIdIsAdmin.id); + EPRole role = (EPRole) localSession.get(EPRole.class, new Long(ACCOUNT_ADMIN_ROLE_ID)); + EPUserApp newUserApp = new EPUserApp(); + newUserApp.setUserId(user.getId()); + newUserApp.setApp(app); + newUserApp.setRole(role); + localSession.save(EPUserApp.class.getName(), newUserApp); + } + transaction.commit(); + result = true; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "setAppsWithAdminRoleStateForUser: exception in point 2", e); + try { + transaction.rollback(); + } catch (Exception ex) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeExecuteRollbackError, e); + logger.error(EELFLoggerDelegate.errorLogger, "setAppsWithAdminRoleStateForUser: exception in point 3", ex); + } + } finally { + try { + localSession.close(); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoCloseSessionError, e); + logger.error(EELFLoggerDelegate.errorLogger, "setAppsWithAdminRoleStateForUser: exception in point 4", e); + } + } + } + } + } + + return result; + } + + @SuppressWarnings("unchecked") + @Override + public boolean isSuperAdmin(EPUser user) { + if ((user != null) /* && (user.getId() == null) */ && (user.getOrgUserId() != null)) { + String sql = "SELECT user.USER_ID, user.org_user_id, userrole.ROLE_ID, userrole.APP_ID FROM fn_user_role userrole " + + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID " + "WHERE user.org_user_id = '" + + user.getOrgUserId() + "' " + "AND userrole.ROLE_ID = '" + SYS_ADMIN_ROLE_ID + "' " + + "AND userrole.APP_ID = '" + ECOMP_APP_ID + "';"; + try { + List userRoleList = dataAccessService.executeSQLQuery(sql, UserIdRoleId.class, null); + if (userRoleList != null && userRoleList.size() > 0) { + return true; + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while executing isSuperAdmin operation", e); + } + } + // else + // { + // User currentUser = user != null ? (User) + // dataAccessService.getDomainObject(User.class, user.getId(), null) : + // null; + // if (currentUser != null && currentUser.getId() != null) { + // for (UserApp userApp : currentUser.getUserApps()) { + // if (userApp.getApp().getId().equals(ECOMP_APP_ID) && + // userApp.getRole().getId().equals(SYS_ADMIN_ROLE_ID)) { + // // Super Administrator role is global, no need to keep iterating + // return true; + // } + // } + // } + // } + return false; + } + + public boolean isAccountAdmin(EPUser user) { + try { + EPUser currentUser = user != null + ? (EPUser) dataAccessService.getDomainObject(EPUser.class, user.getId(), null) : null; + if (currentUser != null && currentUser.getId() != null) { + for (EPUserApp userApp : currentUser.getEPUserApps()) { + if (//!userApp.getApp().getId().equals(ECOMP_APP_ID) + // && + userApp.getRole().getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { + // Account Administrator sees only the applications + // he/she is Administrator + return true; + } + } + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while executing isAccountAdmin operation", e); + } + return false; + } + + public boolean isUser(EPUser user) { + try { + EPUser currentUser = user != null + ? (EPUser) dataAccessService.getDomainObject(EPUser.class, user.getId(), null) : null; + if (currentUser != null && currentUser.getId() != null) { + for (EPUserApp userApp : currentUser.getEPUserApps()) { + if (!userApp.getApp().getId().equals(ECOMP_APP_ID)) { + EPRole role = userApp.getRole(); + if (!role.getId().equals(SYS_ADMIN_ROLE_ID) && !role.getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { + if (role.getActive()) { + return true; + } + } + } + } + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while executing isUser operation", e); + } + return false; + } + + @Override + @EPMetricsLog + public List getRolesByApp(EPUser user, Long appId) { + List list = new ArrayList<>(); + String sql = "SELECT * FROM FN_ROLE WHERE APP_ID = " + appId; + @SuppressWarnings("unchecked") + List roles = dataAccessService.executeSQLQuery(sql, EPRole.class, null); + for (EPRole role: roles) { + list.add(role); + } + return list; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsService.java new file mode 100644 index 00000000..e8ef64fd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsService.java @@ -0,0 +1,55 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.ecomp.model.AppCategoryFunctionsItem; +import org.openecomp.portalapp.portal.ecomp.model.AppContactUsItem; + +public interface AppContactUsService { + + /** + * Gets a list of contact-us information for all entries in + * the fn_app_contact_us table, sorted by app name. If an application is active but has no fn_app_contact_us entry, it will have no entry in this result. + * + * @return List of AppContactUsItem, one for each item in fn_app_contact_us table. + * @throws Exception + */ + public List getAppContactUs() throws Exception; + + /** + * Gets a list of contact-us information for all applications + * in the fn_app table, extended with any information in the fn_app_contact_us table. + * + * @return List of AppContactUsItem, one for each item in fn_app table. + * @throws Exception + */ + public List getAppsAndContacts() throws Exception; + + public List getAppCategoryFunctions() throws Exception; + + public String saveAppContactUs(List contactUs) throws Exception; + + public String saveAppContactUs(AppContactUsItem contactUs) throws Exception; + + public String deleteContactUs(Long id) throws Exception; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsServiceImpl.java new file mode 100644 index 00000000..41c5d9fd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppContactUsServiceImpl.java @@ -0,0 +1,189 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.AppContactUs; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.ecomp.model.AppCategoryFunctionsItem; +import org.openecomp.portalapp.portal.ecomp.model.AppContactUsItem; + +/** + * Provides database access for the contact-us page controllers. + */ +@Transactional +@org.springframework.context.annotation.Configuration +public class AppContactUsServiceImpl implements AppContactUsService { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppContactUsServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.AppContactUsService# + * getAppContactUs() + */ + @SuppressWarnings("unchecked") + @Override + public List getAppContactUs() throws Exception { + List contactUsItemList = (List) getDataAccessService() + .executeNamedQuery("getAppContactUsItems", null, null); + Collections.sort(contactUsItemList, new AppContactUsItemCompare()); + return contactUsItemList; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.AppContactUsService# + * getAllAppsAndContacts() + */ + @SuppressWarnings("unchecked") + @Override + public List getAppsAndContacts() throws Exception { + List contactUsItemList = (List) getDataAccessService() + .executeNamedQuery("getAppsAndContacts", null, null); + Collections.sort(contactUsItemList, new AppContactUsItemCompare()); + return contactUsItemList; + } + + /** + * Assists in sorting app-contact-us items by application name. + */ + class AppContactUsItemCompare implements Comparator { + @Override + public int compare(AppContactUsItem o1, AppContactUsItem o2) { + return o1.getAppName().compareTo(o2.getAppName()); + } + } + + /** + * Gets a table of category and function details for apps that participate + * in the functional menu. + */ + @Override + public List getAppCategoryFunctions() throws Exception { + @SuppressWarnings("unchecked") + // This named query requires no parameters. + List list = (List) dataAccessService + .executeNamedQuery("getAppCategoryFunctions", null, null); + logger.debug(EELFLoggerDelegate.debugLogger, "getAppCategoryFunctions: result list size is " + list.size()); + return list; + } + + /** + * Saves the list of contact-us objects to the database. + */ + @Override + @Transactional(rollbackFor = Exception.class) + public String saveAppContactUs(List contactUsModelList) throws Exception { + try { + for (AppContactUsItem contactUs : contactUsModelList) { + String status = saveAppContactUs(contactUs); + if (!status.equals("success")) + throw new Exception("saveAppContaatUsFailed: service returned " + status); + } + return "success"; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "", e); + throw new Exception(e); + } + + } + + /** + * Saves a single contact-us object to the database, either creating a new + * row or updating if the argument has the ID of an existing row. + */ + @Override + @Transactional(rollbackFor = Exception.class) + public String saveAppContactUs(AppContactUsItem contactUsModel) throws Exception { + try { + HashMap map = new HashMap(); + AppContactUs contactUs = null; + try { + contactUs = (AppContactUs) getDataAccessService().getDomainObject(AppContactUs.class, + contactUsModel.getAppId(), map); + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, "saveAppContactUs: not found for App {}, adding new entry", + contactUsModel.getAppName()); + contactUs = new AppContactUs(); + } + + // Populate the AppContactUs model for the database. + EPApp app = (EPApp) getDataAccessService().getDomainObject(EPApp.class, contactUsModel.getAppId(), map); + if (app == null || app.getId() == null) + throw new Exception("saveAppContactus: App not found for Id " + contactUsModel.getAppId()); + contactUs.setApp(app); + contactUs.setDescription(contactUsModel.getDescription()); + contactUs.setContactName(contactUsModel.getContactName()); + contactUs.setContactEmail(contactUsModel.getContactEmail()); + contactUs.setActiveYN(contactUsModel.getActiveYN()); + contactUs.setUrl(contactUsModel.getUrl()); + getDataAccessService().saveDomainObject(contactUs, map); + return "success"; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveAppContactUs failed", e); + throw e; + // return "failure"; + } + } + + /** + * Deletes the row from the app contact us table with the specified ID. + */ + @Override + public String deleteContactUs(Long id) throws Exception { + try { + HashMap map = new HashMap(); + AppContactUs contactUs = (AppContactUs) getDataAccessService().getDomainObject(AppContactUs.class, id, map); + if (contactUs.getApp() == null) + throw new Exception("Delete unsuccessful for Id " + id); + getDataAccessService().deleteDomainObject(contactUs, map); + return "success"; + } catch (Exception e) { + + logger.info(EELFLoggerDelegate.errorLogger, "", e); + throw e; + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java new file mode 100644 index 00000000..caeceb3c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java @@ -0,0 +1,53 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.apache.cxf.transport.http.HTTPException; +import org.openecomp.portalapp.util.SystemType; + +public interface ApplicationsRestClientService { + public T get(Class clazz, long app, String restPath) throws HTTPException; + public String getIncomingJsonString(long appId, String restPath) throws HTTPException; + + public T post(Class clazz, long appId, Object payload, String restPath) throws HTTPException; + public T post(Class clazz, long appId, Object payload, String restPath, SystemType type) throws HTTPException; + + public T put(Class clazz, long appId, Object payload, String restPath) throws HTTPException; + + /** + * Sends a GET request to the specified application at the specified path. + * This is a workaround for a problem triggered by a superclass/subclass + * with identical field names. + * + * @param clazz + * Expected response type + * @param appId + * Application ID + * @param restPath + * Path at the remote application + * @param useJacksonMapper + * If true, uses a com.fasterxml.jackson.databind.ObjectMapper to + * translate the remote application response from JSON to an + * object. Otherwise, uses a com.google.gson.Gson. + * @return Instance of the specified class + * @throws HTTPException + */ + public T get(Class clazz, long appId, String restPath, boolean useJacksonMapper) throws HTTPException; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java new file mode 100644 index 00000000..027d972c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java @@ -0,0 +1,411 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; + +import java.lang.reflect.Type; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Base64; +import java.util.Date; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.transport.http.HTTPException; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.SystemType; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; + +@Service("applicationsRestClientService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +public class ApplicationsRestClientServiceImpl implements ApplicationsRestClientService { + + private static final String PASSWORD_HEADER = "password"; + + private static final String APP_USERNAME_HEADER = "username"; + + private static final String BASIC_AUTHENTICATION_HEADER = "Authorization"; + + 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() { + logger.debug(EELFLoggerDelegate.debugLogger, "initializing"); + 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()); + } + }); + + 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); + WebClient client = WebClient.create(baseUri); + client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON); + client.path(path); + return client; + } + + @EPMetricsLog + private void verifyResponse(Response response) throws HTTPException { + int status = response.getStatus(); + logger.debug(EELFLoggerDelegate.debugLogger, "http response status=" + status); + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(status)); + if (!isHttpSuccess(status)) { + String errMsg = "Failed. Status=" + status + "; [" + response.getStatusInfo().getReasonPhrase().toString() + + "]"; + URL url = null; + try { + // must not be null to avoid NPE in HTTPException constructor + url = new URL("http://null"); + if (response.getLocation() != null) + url = response.getLocation().toURL(); + } catch (MalformedURLException e) { + // never mind. it is only for the debug message. + logger.warn(EELFLoggerDelegate.errorLogger, "Failed to build URL", e); + } + logger.error(EELFLoggerDelegate.errorLogger, "http response failed. " + errMsg + "; url=" + url); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeIncorrectHttpStatusError); + throw new HTTPException(status, errMsg, url); + } + } + + private static boolean isHttpSuccess(int status) { + return status / 100 == 2; + } + + + private WebClient createClientForApp(long appId, String restPath) { + return createClientFor(appId, restPath, SystemType.APPLICATION); + } + + //TODO Need to implement the mylogins once the endpoint is confirmed + @EPMetricsLog + private WebClient createClientFor(long appSystemId, String restPath, SystemType type) { + logger.debug(EELFLoggerDelegate.debugLogger, "creating client for appId=" + appSystemId + "; restPath=" + restPath); + EPApp externalApp = null; + + if(type == SystemType.APPLICATION){ + externalApp = appsCacheService.getApp(appSystemId); + }else{ + // TO DO + } + + if (externalApp != null) { + String appBaseUri = (type == SystemType.APPLICATION) ? externalApp.getAppRestEndpoint() : ""; + String username = (type == SystemType.APPLICATION) ? externalApp.getUsername(): ""; + String encriptedPwd = (type == SystemType.APPLICATION) ? externalApp.getAppPassword(): ""; + String appName = (type == SystemType.APPLICATION) ? externalApp.getName(): ""; + String decreptedAppPwd = ""; + + // Set local context + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP); + if (appBaseUri != null && appBaseUri.contains("https")) { + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS); + } + MDC.put(EPCommonSystemProperties.FULL_URL, appBaseUri + restPath); + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, appName); + MDC.put(EPCommonSystemProperties.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)); + } + + WebClient client = createClientForPath(appBaseUri, restPath); + + // support basic authentication for some partners + String encoding = Base64.getEncoder().encodeToString((username + ":" + decreptedAppPwd).getBytes()); + String encodingStr = "Basic " + encoding; + client.header(BASIC_AUTHENTICATION_HEADER, encodingStr); + + // But still keep code downward compatible for non compliant apps + 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, EPCommonSystemProperties.ECOMP_PORTAL_BE); + + logger.debug(EELFLoggerDelegate.debugLogger, + String.format("App %d found, baseUri=[%s], Headers: [%s=%s, %s=%s, %s=%s]", appSystemId, appBaseUri, + APP_USERNAME_HEADER, username, PASSWORD_HEADER, encriptedPwd, BASIC_AUTHENTICATION_HEADER, encodingStr)); + + return client; + } + return null; + } + + @Override + public T get(Class clazz, long appId, String restPath) throws HTTPException { + T t = null; + Response response = getResponse(appId, restPath); + + if (response != null) { + verifyResponse(response); + String str = response.readEntity(String.class); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET result =", str); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + + return t; + } + + @Override + public String getIncomingJsonString(long appId, String restPath) throws HTTPException { + Response response = getResponse(appId, restPath); + + if (response != null) { + verifyResponse(response); + String incomingJson = response.readEntity(String.class); + return incomingJson; + } + + return ""; + } + + + /* + * (non-Javadoc) + * + * @see + * org.openecomp.portalapp.portal.service.ApplicationsRestClientService#get( + * java.lang.Class, long, java.lang.String, boolean) + */ + @Override + public T get(Class clazz, long appId, String restPath, boolean useJacksonMapper) throws HTTPException { + + if (!useJacksonMapper) + return get(clazz, appId, restPath); + + T t = null; + Response response = getResponse(appId, restPath); + + if (response != null) { + verifyResponse(response); + String str = response.readEntity(String.class); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET result =", str); + + try { + t = mapper.readValue(str, clazz); + } catch (Exception e) { + e.printStackTrace(); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + + return t; + } + + protected Response getResponse(long appId, String restPath) { + WebClient webClient = null; + Response response = null; + + webClient = createClientForApp(appId, restPath); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "GET request =", "no-payload"); + + try { + if (webClient != null) { + response = webClient.get(); + } else { + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); + } + } catch (Exception e) { + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the GET REST API call", e); + } + return response; + } + + + @Override + public T post(Class clazz, long appId, Object payload, String restPath, SystemType type) throws HTTPException { + WebClient client = null; + Response response = null; + T t = null; + + client = createClientFor(appId, restPath, type); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST request =", payload); + + try { + if (client != null) { + response = client.post(payload); + } else { + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); + } + } catch (Exception e) { + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call", e); + } + + if (response != null) { + verifyResponse(response); + + // String contentType = response.getHeaderString("Content-Type"); + if (clazz != null) { + String str = response.readEntity(String.class); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + } + return t; + } + + @Override + public T post(Class clazz, long appId, Object payload, String restPath) throws HTTPException { + return post( clazz, appId, payload, restPath, SystemType.APPLICATION); + } + + //@Override + public T postForClass(Class clazz, long appId, Object payload, String restPath, Class forClass) throws HTTPException { + WebClient client = null; + Response response = null; + T t = null; + + client = createClientForApp(appId, restPath); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST request =", payload); + + try { + if (client != null) { + response = client.post(payload); + } else { + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); + } + } catch (Exception e) { + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call", e); + } + + if (response != null) { + verifyResponse(response); + + // String contentType = response.getHeaderString("Content-Type"); + if (clazz != null) { + String str = response.readEntity(String.class); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + } + return t; + } + + + @Override + 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(logger, restPath, "PUT request =", payload); + + try { + if (client != null) { + response = client.put(payload); + } else { + logger.error(EELFLoggerDelegate.errorLogger, + "Unable to create the Webclient to make the '" + restPath + "' API call."); + } + } catch (Exception e) { + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, + Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the PUT REST API call", e); + } + + if (response != null) { + verifyResponse(response); + String str = response.readEntity(String.class); + EcompPortalUtils.logAndSerializeObject(logger, restPath, "PUT result =", str); + try { + t = gson.fromJson(str, clazz); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + return t; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java new file mode 100644 index 00000000..aefbbbd5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java @@ -0,0 +1,42 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ + +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalapp.portal.domain.EPApp; + +public interface AppsCacheService { + + /** + * returns an app by id from the cache + * @param appId + * @return corresponding App + */ + EPApp getApp(Long appId); + + /** + * returns the corresponding application endpoint + * @param appId + * @return if appId exists in cache, then return corresponding application endpoint, null otherwise. + */ + String getAppEndpoint(Long appId); + + EPApp getAppForAnalytics(String appKey); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java new file mode 100644 index 00000000..80aa00d4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java @@ -0,0 +1,136 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("appsCacheService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class AppsCacheServiceImple implements AppsCacheService { + @Autowired + EPAppService appsService; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsCacheServiceImple.class); + + final class CacheConfiguration { + + private long updateTime = 0; + private int updateInterval = 10; + + public CacheConfiguration (long _updateTime, int _updateInterval) { + updateTime = _updateTime; + updateInterval = _updateInterval; + } + } + + CacheConfiguration appConf = null; + CacheConfiguration analyticsAppConf = null; + + + private static volatile Map appsMap; + private static volatile Map anlyticsAppsMap; + + @PostConstruct + public void init() { + appConf = new CacheConfiguration(0, 10); + analyticsAppConf = new CacheConfiguration(0, 3600); + + this.refreshAppsMap(appConf); + } + + private Map refreshAppsMap(CacheConfiguration conf) { + long now = System.currentTimeMillis(); + + if(noNeedToUpdate(now, conf)) + return null; + + synchronized (this) { + if(noNeedToUpdate(now, conf)) + return null; + List allApps = appsService.getAppsFullList(); + Map newAppsMap = new HashMap(); + for (EPApp app : allApps) { + newAppsMap.put(app.getId(), app); + } + + Map newAnalyticsAppsMap = new HashMap(); + for (EPApp app : allApps) { + newAnalyticsAppsMap.put(app.getUebKey(), app); + } + // Switch cache with the new one. + appsMap = newAppsMap; + anlyticsAppsMap = newAnalyticsAppsMap; + conf.updateTime = now; + } + + return appsMap; + } + + private boolean noNeedToUpdate(long now, CacheConfiguration conf) { + long secondsPassed = (now - conf.updateTime)/1000; + if(secondsPassed < conf.updateInterval){ + logger.debug(EELFLoggerDelegate.debugLogger, "no need to refresh yet, seconds since last refresh: " + secondsPassed + ", refresh interval (sec) = " + conf.updateInterval); + return true; // no need to update cache + } + return false; // its time to update + } + + @Override + public String getAppEndpoint(Long appId) { + refreshAppsMap(appConf); + EPApp app = appsMap.get(appId); + if(app != null) + return app.getAppRestEndpoint(); + return null; + } + + @Override + public EPApp getApp(Long appId) { + refreshAppsMap(appConf); + EPApp app = appsMap.get(appId); + if(app != null) + return app; + return null; + } + + @Override + public EPApp getAppForAnalytics(String appKey) { + refreshAppsMap(analyticsAppConf); + EPApp app = anlyticsAppsMap.get(appKey); + if(app != null) + return app; + return null; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountService.java new file mode 100644 index 00000000..011a6485 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountService.java @@ -0,0 +1,47 @@ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPEndpoint; + +public interface BasicAuthAccountService { + + /** + * Saves Basic Authentication account for external systems + * @param BasicAuthCredentials + * @return Id of the newly created account + */ + Long saveBasicAuthAccount(BasicAuthCredentials newCredential) throws Exception; + + /** + * Saves Endpoint associated with a Basic Auth account + * @param EPEndpoint + * @return Id of the newly created endpoint + */ + Long saveEndpoints(EPEndpoint endpoint) throws Exception; + + /** + * Saves Endpoint associated with a Basic Auth account + * @param accountId, endpointId + */ + void saveEndpointAccount(Long accountId, Long endpointId) throws Exception; + + /** + * Returns list of all BasicAuthCredentials in the sytem + * @return List + */ + List getAccountData() throws Exception; + + /** + * Deletes BasicAuthenticationAccount + * @param accountId + */ + void deleteEndpointAccout(Long accountId) throws Exception; + + /** + * Updates BasicAuthenticationAccount + * @param accountId, BasicAuthCredentials + */ + void updateBasicAuthAccount(Long accountId, BasicAuthCredentials newCredential) throws Exception; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountServiceImpl.java new file mode 100644 index 00000000..fd0fb597 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthAccountServiceImpl.java @@ -0,0 +1,205 @@ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.Session; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPEndpoint; +import org.openecomp.portalapp.portal.domain.EPEndpointAccount; +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.MicroserviceParameter; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +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.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +@Service("basicAuthAccountService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MicroserviceServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Override + public Long saveBasicAuthAccount(BasicAuthCredentials newCredential) throws Exception { + if (newCredential.getPassword() != null) + newCredential.setPassword(encryptedPassword(newCredential.getPassword())); + try{ + getDataAccessService().saveDomainObject(newCredential, null); + }catch(Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, "saveBasicAuthAccount() failed", e); + throw e; + } + return newCredential.getId(); + } + + + @Override + @SuppressWarnings("unchecked") + public Long saveEndpoints(EPEndpoint endpoint) throws Exception { + + List restrictionsList = new ArrayList(); + Criterion NameCrit = Restrictions.eq("name", endpoint.getName()); + restrictionsList.add(NameCrit); + + List tempList = (List) dataAccessService.getList(EPEndpoint.class, null, + restrictionsList, null); + if (tempList.size() != 0) { + return tempList.get(0).getId(); + } else { + getDataAccessService().saveDomainObject(endpoint, null); + return endpoint.getId(); + } + + } + + @Override + public void saveEndpointAccount(Long accountId, Long endpointId) throws Exception { + EPEndpointAccount record = new EPEndpointAccount(); + record.setAccount_id(accountId); + record.setEp_id(endpointId); + try { + getDataAccessService().saveDomainObject(record, null); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveEndpointAccount() failed", e); + throw e; + } + + } + + @Override + @SuppressWarnings("unchecked") + public void updateBasicAuthAccount(Long accountId, BasicAuthCredentials newCredential) throws Exception { + try { + newCredential.setId(accountId); + if (newCredential.getPassword() != null) + newCredential.setPassword(encryptedPassword(newCredential.getPassword())); + getDataAccessService().saveDomainObject(newCredential, null); + + List endpoints = newCredential.getEndpoints(); + List orig_points = getEPEndpoints(accountId); + + for(EPEndpoint temp_ep: orig_points){ + boolean flag = false; + for(EPEndpoint temp_ep2: endpoints){ + if(temp_ep2.getId() == temp_ep.getId()) + flag = true; + } + if(!flag){ + Map params = new HashMap(); + params.put("accountId", Long.toString(accountId)); + params.put("epId", Long.toString(temp_ep.getId())); + dataAccessService.executeNamedQuery("deleteAccountEndpointRecord", params, null); + } + } + + + for(int i = 0; i < endpoints.size(); i++){ + + List restrictionsList = new ArrayList(); + Criterion IdCrit = Restrictions.eq("id", endpoints.get(i).getId()); + restrictionsList.add(IdCrit); + Criterion NameCrit = Restrictions.eq("name", endpoints.get(i).getName()); + restrictionsList.add(NameCrit); + List tempList = (List) dataAccessService + .getList(EPEndpoint.class, null, restrictionsList, null); + if(tempList.size() == 0){ + if(endpoints.get(i).getId() != null){ + //delete the record endpoints.get(i).getId(), accountId + Map params = new HashMap(); + params.put("accountId", Long.toString(accountId)); + params.put("epId", Long.toString(endpoints.get(i).getId())); + dataAccessService.executeNamedQuery("deleteAccountEndpointRecord", params, null); + endpoints.get(i).setId(null); + } + //create a new endpoint + Long ep_id = saveEndpoints(endpoints.get(i)); + saveEndpointAccount(accountId, ep_id); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateBasicAuthAccount() failed", e); + throw e; + } + } + + @Override + public List getAccountData() throws Exception { + List list = (List) dataAccessService.getList(BasicAuthCredentials.class, null); + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getPassword() != null) + list.get(i).setPassword(decryptedPassword(list.get(i).getPassword())); + list.get(i).setEndpoints(getEPEndpoints(list.get(i).getId())); + } + return list; + } + + @SuppressWarnings("unchecked") + private List getEPEndpoints(long accountId) { + List result = new ArrayList<>(); + List list = (List) dataAccessService + .getList(EPEndpointAccount.class, " where account_id = '" + accountId + "'", null, null); + for(int i = 0; i < list.size(); i++){ + result.add((EPEndpoint) dataAccessService.getDomainObject(EPEndpoint.class, list.get(i).getEp_id(), null)); + } + return result; + } + + @Override + public void deleteEndpointAccout(Long accountId) throws Exception { + try{ + Map params = new HashMap(); + params.put("accountId", Long.toString(accountId)); + + dataAccessService.executeNamedQuery("deleteAccountEndpoint", params, null); + dataAccessService.executeNamedQuery("deleteBasicAuthAccount", params, null); + + }catch(Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, "deleteEndpointAccout() failed", e); + throw e; + } + } + + private String decryptedPassword(String encryptedPwd) throws Exception { + String result = ""; + if (encryptedPwd != null & encryptedPwd.length() > 0) { + try { + result = CipherUtil.decrypt(encryptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword() failed", e); + throw e; + } + } + return result; + } + + private String encryptedPassword(String decryptedPwd) throws Exception { + String result = ""; + if (decryptedPwd != null & decryptedPwd.length() > 0) { + try { + result = CipherUtil.encrypt(decryptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e); + throw e; + } + } + return result; + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialService.java new file mode 100644 index 00000000..459a6504 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialService.java @@ -0,0 +1,35 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; + +public interface BasicAuthenticationCredentialService { + /** + * Gets the basic authentication credential for the specified appName from + * table ep_basic_auth_account + * + * @param appName + * External application name + * @return BasicAuthCredentials for the specified app; null if the app is + * not known. + */ + public BasicAuthCredentials getBasicAuthCredentialByAppName(String appName); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java new file mode 100644 index 00000000..54a9d2af --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java @@ -0,0 +1,81 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPEndpoint; +import org.openecomp.portalapp.portal.domain.EPEndpointAccount; +import org.openecomp.portalapp.portal.domain.SharedContext; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +@Service("basicAuthenticationCredentialService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class BasicAuthenticationCredentialServiceImpl implements BasicAuthenticationCredentialService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BasicAuthenticationCredentialServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Override + public BasicAuthCredentials getBasicAuthCredentialByAppName(String appName) { + + List restrictionsList = new ArrayList(); + Criterion contextIdCrit = Restrictions.eq("applicationName", appName); + restrictionsList.add(contextIdCrit); + @SuppressWarnings("unchecked") + List credList = (List) dataAccessService.getList(BasicAuthCredentials.class, null, restrictionsList, null); + if (credList == null || credList.size() == 0) { + logger.error(EELFLoggerDelegate.errorLogger, + "getBasicAuthCredentialByAppName: no credential(s) for " + appName); + return null; + } + logger.debug(EELFLoggerDelegate.debugLogger, + "getBasicAuthCredentialByAppName: cred list size: " + credList.size()); + BasicAuthCredentials cred = (BasicAuthCredentials) credList.get(0); + cred.setEndpoints(getEndpointsByAccountId(cred.getId())); + return cred; + } + + private List getEndpointsByAccountId(long id){ + + List list = new ArrayList<>(); + List restrictionsList = new ArrayList(); + Criterion contextIdCrit = Restrictions.eq("account_id", id); + restrictionsList.add(contextIdCrit); + List epList = (List) dataAccessService.getList(EPEndpointAccount.class, null, restrictionsList, null); + for(EPEndpointAccount ep: epList){ + list.add((EPEndpoint) dataAccessService.getDomainObject(EPEndpoint.class, ep.getEp_id(), null)); + } + return list; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthService.java new file mode 100644 index 00000000..6ceb2cac --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthService.java @@ -0,0 +1,32 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.exceptions.NoHealthyServiceException; +import com.ecwid.consul.ConsulException; +import com.orbitz.consul.model.health.ServiceHealth; + +public interface ConsulHealthService { + public String getServiceLocation(String service) throws NoHealthyServiceException; + public List getAllHealthyNodes(String service) throws ConsulException; + public List getAllNodes(String service) throws ConsulException; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthServiceImpl.java new file mode 100644 index 00000000..1d741dca --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ConsulHealthServiceImpl.java @@ -0,0 +1,91 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import com.ecwid.consul.ConsulException; +import com.orbitz.consul.Consul; +import com.orbitz.consul.HealthClient; +import com.orbitz.consul.model.health.ServiceHealth; + +@Component +public class ConsulHealthServiceImpl implements ConsulHealthService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ConsulHealthServiceImpl.class); + + @Override + public String getServiceLocation(String service){ + + List nodes = null; + + try{ + Consul consul = Consul.builder().build(); + HealthClient healthClient = consul.healthClient(); + nodes = healthClient.getHealthyServiceInstances(service).getResponse(); + } + catch(Exception e){ + //using both loggers. + logger.debug(logger.debugLogger, " problem getting nodes for service - " + service + e.getMessage() + " - Defaulting to localhost", e); + logger.error(logger.errorLogger, " problem getting nodes for service - " + service + e.getMessage() + " - Defaulting to localhost", e); + + return "localhost:" + SystemProperties.getProperty("microservices.widget.local.port"); + } + + if(nodes == null || nodes.size() == 0){ + logger.debug(logger.debugLogger, "No healthy node found in the consul cluster running service " + service + ". Defaulting to localhost"); + return "localhost:" + SystemProperties.getProperty("microservices.widget.local.port"); + } + else{ + String locationFromConsul; + ServiceHealth node = nodes.get(0); + locationFromConsul = node.getNode().getNode() + ":" + node.getService().getPort(); + logger.debug(logger.debugLogger, "Found healthy service location using consul - returning location " + locationFromConsul); + + //if locationFromConsul is null for some reason (very unlikely at this point), default to localhost + if(null == locationFromConsul || "".equals(locationFromConsul)){ + logger.debug(logger.debugLogger, "Couldn't get location from consul for service " + service + ". Defaulting to localhost"); + return "localhost:" + SystemProperties.getProperty("microservices.widget.local.port"); + } + else{ + logger.debug(logger.debugLogger, "Found service location from consul for service " + service + ". Location is " + locationFromConsul); + return locationFromConsul; + } + } + } + + @Override + public List getAllHealthyNodes(String service) throws ConsulException{ + Consul consul = Consul.builder().build(); + HealthClient healthClient = consul.healthClient(); + return healthClient.getHealthyServiceInstances(service).getResponse(); + } + + @Override + public List getAllNodes(String service){ + Consul consul = Consul.builder().build(); + HealthClient healthClient = consul.healthClient(); + return healthClient.getAllServiceInstances(service).getResponse(); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchService.java new file mode 100644 index 00000000..177f0e6a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchService.java @@ -0,0 +1,37 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; +import java.util.Map; + +import org.openecomp.portalapp.portal.transport.CommonWidget; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalapp.portal.ecomp.model.SearchResultItem; + +public interface DashboardSearchService { + public Map> searchResults(String userId, String searchString); + public List getRelatedUsers(String userId); + + public CommonWidgetMeta getWidgetData(String resourceType); + public String saveWidgetDataBulk(CommonWidgetMeta commonWidgetMetaData); + public String saveWidgetData(CommonWidget commonWidgetData); + public String deleteWidgetData(CommonWidget eventWidget); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchServiceImpl.java new file mode 100644 index 00000000..412d833d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/DashboardSearchServiceImpl.java @@ -0,0 +1,100 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.transport.CommonWidget; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalapp.portal.ecomp.model.SearchResultItem; + +@Component +public class DashboardSearchServiceImpl implements DashboardSearchService { + + @Autowired + private DataAccessService dataAccessService; + + public Map> searchResults(String userId, String searchString) { + Map params = new HashMap<>(); + params.put("userId", userId); + params.put("searchQuery", searchString); + // Named query is stored in a *.hbm.xml file, mapped to SearchResultItem + @SuppressWarnings("unchecked") + List list = dataAccessService.executeNamedQuery("searchPortal", params, null); + Map> finalJson = null; + if (list.size() > 0) { + finalJson = new HashMap>(); + for (SearchResultItem thisResult : list) { + List thisList = finalJson.get(thisResult.getCategory().toLowerCase()); + if (thisList == null) + thisList = new ArrayList(); + thisList.add(thisResult); + finalJson.put(thisResult.getCategory().toLowerCase(), thisList); + } + } + return finalJson; + } + + @Override + public List getRelatedUsers(String userId) { + Map params = new HashMap<>(); + params.put("userId", userId); + @SuppressWarnings("unchecked") + List activeUsers = dataAccessService.executeNamedQuery("relatedUsers", params, null); + return activeUsers; + } + + @Override + public CommonWidgetMeta getWidgetData(String resourceType) { + Map params = new HashMap<>(); + params.put("cat", resourceType); + @SuppressWarnings("unchecked") + List widgetItems = (List) dataAccessService.executeNamedQuery("getCommonWidgetItem", params, null); + return new CommonWidgetMeta(resourceType, widgetItems); + } + + @Override + public String saveWidgetDataBulk(CommonWidgetMeta commonMetaWidgetData) { + for (CommonWidget widgetData : commonMetaWidgetData.getItems()) { + widgetData.setCategory(commonMetaWidgetData.getCategory()); + dataAccessService.saveDomainObject(widgetData, null); + } + return "success"; + } + + @Override + public String saveWidgetData(CommonWidget commonWidgetData) { + dataAccessService.saveDomainObject(commonWidgetData, null); + return "success"; + } + + @Override + public String deleteWidgetData(CommonWidget eventWidget) { + dataAccessService.deleteDomainObject(eventWidget, null); + return "success"; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppCommonServiceImpl.java new file mode 100644 index 00000000..a5b15e24 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppCommonServiceImpl.java @@ -0,0 +1,1368 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Base64; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.openecomp.portalapp.portal.domain.AdminUserApp; +import org.openecomp.portalapp.portal.domain.AdminUserApplications; +import org.openecomp.portalapp.portal.domain.AppIdAndNameTransportModel; +import org.openecomp.portalapp.portal.domain.AppsResponse; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserAppsManualSortPreference; +import org.openecomp.portalapp.portal.domain.EPUserAppsSortPreference; +import org.openecomp.portalapp.portal.domain.EPWidgetsManualSortPreference; +import org.openecomp.portalapp.portal.domain.EcompApp; +import org.openecomp.portalapp.portal.domain.UserRole; +import org.openecomp.portalapp.portal.domain.UserRoles; +import org.openecomp.portalapp.portal.ecomp.model.AppCatalogItem; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.transport.EPAppsManualPreference; +import org.openecomp.portalapp.portal.transport.EPAppsSortPreference; +import org.openecomp.portalapp.portal.transport.EPDeleteAppsManualSortPref; +import org.openecomp.portalapp.portal.transport.EPWidgetsSortPreference; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.LocalRole; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.ueb.EPUebHelper; +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.ueb.Helper; +import org.openecomp.portalsdk.core.onboarding.ueb.TopicManager; +import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; + +import com.att.nsa.apiClient.http.HttpException; +import com.att.nsa.cambria.client.CambriaClient.CambriaApiException; +import com.att.nsa.cambria.client.CambriaClientBuilders; +import com.att.nsa.cambria.client.CambriaIdentityManager; +import com.google.common.primitives.Ints; + +public class EPAppCommonServiceImpl implements EPAppService { + + protected String ECOMP_APP_ID = "1"; + protected String SUPER_ADMIN_ROLE_ID = "1"; + protected String ACCOUNT_ADMIN_ROLE_ID = "999"; + protected String RESTRICTED_APP_ROLE_ID = "900"; + + private static final String urlField = "url"; + private static final String nameField = "name"; + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppCommonServiceImpl.class); + + @Autowired + AdminRolesService adminRolesService; + @Autowired + private SessionFactory sessionFactory; + @Autowired + private DataAccessService dataAccessService; + @Autowired + EPUebHelper epUebHelper; + + @PostConstruct + private void init() { + SUPER_ADMIN_ROLE_ID = SystemProperties.getProperty(EPCommonSystemProperties.SYS_ADMIN_ROLE_ID); + ACCOUNT_ADMIN_ROLE_ID = SystemProperties.getProperty(EPCommonSystemProperties.ACCOUNT_ADMIN_ROLE_ID); + ECOMP_APP_ID = SystemProperties.getProperty(EPCommonSystemProperties.ECOMP_APP_ID); + RESTRICTED_APP_ROLE_ID = SystemProperties.getProperty(EPCommonSystemProperties.RESTRICTED_APP_ROLE_ID); + } + + @Override + public List getUserAsAdminApps(EPUser user) { + if (adminRolesService.isAccountAdmin(user)) { + String sql = "SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID=FN_APP.APP_ID where " + + "FN_USER_ROLE.USER_ID=" + user.getId() + " AND FN_USER_ROLE.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID + + " AND FN_APP.ENABLED = 'Y'"; + logQuery(sql); + try { + @SuppressWarnings("unchecked") + List adminApps = dataAccessService.executeSQLQuery(sql, EPApp.class, null); + return adminApps; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + return null; + } + } else { + logger.error(EELFLoggerDelegate.errorLogger, + "getUserAsAdminApps: only Account Admin may invoke this function!"); + return new ArrayList(); + } + } + + @Override + public List getUserByOrgUserIdAsAdminApps(String orgUserId) { + String format = "SELECT * FROM FN_APP app INNER JOIN FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID " + + "INNER JOIN FN_USER user on user.USER_ID = userrole.USER_ID " + + "WHERE user.org_user_id = '%s' AND userrole.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID + + " AND FN_APP.ENABLED = 'Y'"; + + String sql = String.format(format, orgUserId); + logQuery(sql); + + try { + @SuppressWarnings("unchecked") + List adminApps = dataAccessService.executeSQLQuery(sql, EPApp.class, null); + return adminApps; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + return null; + } + } + + @Override + public List getAppsFullList() { + @SuppressWarnings("unchecked") + List apps = dataAccessService.getList(EPApp.class, null); + return apps; + } + + @Override + public List getEcompAppAppsFullList() { + return transformAppsToEcompApps(getAppsFullList()); + } + + @Override + public List transformAppsToEcompApps(List appsList) { + List ecompAppList = new ArrayList(); + for (EPApp app : appsList) { + EcompApp ecompApp = new EcompApp(); + ecompApp.setId(app.getId()); + ecompApp.setName(app.getName()); + ecompApp.setImageUrl(app.getImageUrl()); + ecompApp.setDescription(app.getDescription()); + ecompApp.setNotes(app.getNotes()); + ecompApp.setUrl(app.getUrl()); + ecompApp.setAlternateUrl(app.getAlternateUrl()); + ecompApp.setUebTopicName(app.getUebTopicName()); + ecompApp.setUebKey(app.getUebKey()); + ecompApp.setUebSecret(app.getUebSecret()); + ecompApp.setEnabled(app.getEnabled()); + ecompApp.setRestrictedApp(app.isRestrictedApp()); + ecompAppList.add(ecompApp); + } + return ecompAppList; + } + + @Override + public EPApp getApp(Long appId) { + try { + @SuppressWarnings("unchecked") + List apps = dataAccessService.getList(EPApp.class, " where id = " + appId, null, null); + return (apps.size() > 0) ? apps.get(0) : null; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + return null; + } + } + + @SuppressWarnings("unchecked") + @Override + public List getAdminApps(EPUser user) { + if (adminRolesService.isAccountAdmin(user)) { + String format = "SELECT app.APP_ID, app.APP_NAME, app.APP_TYPE FROM FN_APP app inner join FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID " + + "where userrole.USER_ID = %d AND userrole.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID + + " AND (app.ENABLED = 'Y' OR app.APP_ID=1)"; + String sql = String.format(format, user.getId()); + // sql += " AND app.APP_REST_ENDPOINT IS NOT NULL AND + // app.APP_REST_ENDPOINT <> ''"; + logQuery(sql); + try { + return dataAccessService.executeSQLQuery(sql, AppIdAndNameTransportModel.class, null); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while fetching the adminApps for user " + user.getLoginId(), e); + } + } + return new ArrayList(); + } + + @Override + public EPApp getAppDetail(String appName) { + final Map params = new HashMap(); + try { + params.put("appName", appName); + @SuppressWarnings("unchecked") + List apps = (List) dataAccessService.executeNamedQuery("getAppDetails", params, null); + return (apps.size() > 0) ? apps.get(0) : null; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + return null; + } + } + + @SuppressWarnings("unchecked") + @Override + public List getAppsForSuperAdminAndAccountAdmin(EPUser user) { + if (adminRolesService.isSuperAdmin(user) || adminRolesService.isAccountAdmin(user)) { + String format = ""; + String sql = ""; + if (adminRolesService.isSuperAdmin(user)) { + format = "SELECT app.APP_ID, app.APP_NAME, app.APP_TYPE FROM FN_APP app " + + "where app.ENABLED = 'Y' AND app.app_type = 1"; + } else { + format = "SELECT app.APP_ID, app.APP_NAME, APP_TYPE FROM FN_APP app inner join FN_USER_ROLE userrole ON userrole.APP_ID=app.APP_ID " + + "where userrole.USER_ID = %d AND userrole.ROLE_ID=" + ACCOUNT_ADMIN_ROLE_ID + + " AND app.ENABLED = 'Y' AND app.app_type = 1"; + } + sql = String.format(format, user.getId()); + // sql += " AND app.APP_REST_ENDPOINT IS NOT NULL AND + // app.APP_REST_ENDPOINT <> ''"; + logQuery(sql); + try { + return dataAccessService.executeSQLQuery(sql, AppIdAndNameTransportModel.class, null); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while fetching the adminApps for user " + user.getLoginId(), e); + } + } + return new ArrayList(); + } + + protected void logQuery(String sql) { + logger.debug(EELFLoggerDelegate.debugLogger, "logQuery: " + sql); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + @Override + public List getAppsAdmins() { + String sql = "SELECT apps.APP_NAME, apps.APP_ID, user.USER_ID, user.FIRST_NAME, user.LAST_NAME, user.org_user_id FROM fn_user_role userrole " + + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID " + + "INNER JOIN fn_app apps ON apps.APP_ID = userrole.APP_ID " + "WHERE userrole.ROLE_ID = " + + ACCOUNT_ADMIN_ROLE_ID + " AND (apps.ENABLED = 'Y' OR apps.APP_ID=1)"; + logQuery(sql); + try { + @SuppressWarnings("unchecked") + List adminApps = dataAccessService.executeSQLQuery(sql, AdminUserApp.class, null); + // DataAccessService does not use generic types. + return aggregateRowsResultsByUserId(adminApps); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + return null; + } + } + + private List aggregateRowsResultsByUserId(List adminApps) { + HashMap adminUserApplications = new HashMap(); + for (AdminUserApp app : adminApps) { + Long userId = app.getUser_Id(); + if (adminUserApplications.get(userId) == null) + adminUserApplications.put(userId, new AdminUserApplications(app)); + else + adminUserApplications.get(userId).addApp(app.getAppId(), app.getAppName()); + } + return new ArrayList(adminUserApplications.values()); + } + + @Override + public List getAllApps(Boolean all) { + // If all is true, return both active and inactive apps. Otherwise, just + // active apps. + @SuppressWarnings("unchecked") + // Sort the list by application name so the drop-down looks pretty. + List apps = all + ? (List) dataAccessService.getList(EPApp.class, " where id != " + ECOMP_APP_ID, "name", null) + : (List) dataAccessService.getList(EPApp.class, + " where ( enabled = 'Y' or id = " + ECOMP_APP_ID + ")", "name", null); + + List appsModified = new ArrayList(); + for (EPApp app : apps) { + appsModified.add(new AppsResponse(app.getId(), app.getName(), app.isRestrictedApp(), app.getEnabled())); + } + return appsModified; + } + + @Override + public UserRoles getUserProfile(String loginId) { + String format = "SELECT DISTINCT user.USER_ID, role.ROLE_ID, user.org_user_id, user.FIRST_NAME, user.LAST_NAME, role.ROLE_NAME FROM fn_user_role userrole " + + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID " + + "INNER JOIN fn_role role ON role.ROLE_ID = userrole.ROLE_ID " + + "WHERE user.org_user_id = \"%s\" and (userrole.app_id = 1 or role.role_id = " + ACCOUNT_ADMIN_ROLE_ID + + ") "; + String sql = String.format(format, loginId); + logQuery(sql); + @SuppressWarnings("unchecked") + List userRoleList = dataAccessService.executeSQLQuery(sql, UserRole.class, null); + ArrayList usersRolesList = aggregateUserProfileRowsResultsByRole(userRoleList); + if (usersRolesList == null || usersRolesList.size() < 1) + return null; + + return usersRolesList.get(0); + } + + @Override + public UserRoles getUserProfileNormalized(EPUser user) { + // Check database. + UserRoles userAndRoles = getUserProfile(user.getLoginId()); + // If no roles are defined, treat this user as a guest. + if (user.isGuest() || userAndRoles == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "getUserProfile: treating user {} as guest", + user.getLoginId()); + UserRole userRole = new UserRole(); + userRole.setUser_Id(user.getId()); + userRole.setOrgUserId(user.getLoginId()); + userRole.setFirstName(user.getFirstName()); + userRole.setLastName(user.getLastName()); + userRole.setRoleId(-1L); + userRole.setRoleName("Guest"); + userRole.setUser_Id(-1L); + userAndRoles = new UserRoles(userRole); + } + + return userAndRoles; + } + + protected ArrayList aggregateUserProfileRowsResultsByRole(List userRoleList) { + HashMap userRoles = new HashMap(); + for (UserRole user : userRoleList) { + String orgUserId = user.getOrgUserId(); + if (userRoles.get(orgUserId) == null) + userRoles.put(orgUserId, new UserRoles(user)); + else + userRoles.get(orgUserId).addRole(user.getRoleName()); + } + return new ArrayList(userRoles.values()); + } + + private boolean isRestrictedApp(Long appId) { + EPApp app = getApp(appId); + return app.isRestrictedApp(); + } + + // For the functional menu edit + @Override + public List getAppRoles(Long appId) { + String sql = ""; + if (isRestrictedApp(appId)) { + sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where ROLE_ID = '" + RESTRICTED_APP_ROLE_ID + "'"; + } else { + sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where APP_ID = '" + appId + "'"; + } + logQuery(sql); + @SuppressWarnings("unchecked") + List appRoles = dataAccessService.executeSQLQuery(sql, LocalRole.class, null); + return appRoles; + } + + protected String userAppsQuery(EPUser user) { + StringBuilder query = new StringBuilder(); + if (adminRolesService.isSuperAdmin(user)) { + query.append("SELECT * FROM FN_APP where FN_APP.ENABLED = 'Y' ORDER BY APP_NAME"); + } else { + 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 = " + user.getId() + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID); + query.append(" AND FN_APP.ENABLED = 'Y'"); + } + return query.toString(); + } + + protected FieldsValidator onboardingAppFieldsChecker(OnboardingApp onboardingApp) { + FieldsValidator fieldsValidator = new FieldsValidator(); + if (onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.url == null + || onboardingApp.url.length() == 0 || onboardingApp.restrictedApp == null + || onboardingApp.isOpen == null || onboardingApp.isEnabled == null + || (onboardingApp.id != null && onboardingApp.id.equals(ECOMP_APP_ID)) + // For a normal app (appType==1), these fields must be filled + // in. + // For a restricted app (appType==2), they will be empty. + || ((!onboardingApp.restrictedApp) + && (onboardingApp.username == null || onboardingApp.username.length() == 0 + || onboardingApp.appPassword == null || onboardingApp.appPassword.length() == 0))) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + } + return fieldsValidator; + } + + @Override + public List getUserApps(EPUser user) { + List openApps = getOpenApps(); + + if (user.isGuest()) { + return openApps; + } else { + String sql = userAppsQuery(user); + logQuery(sql); + + // TreeSet distinctApps = new TreeSet(); + List appsList = new ArrayList<>(); + @SuppressWarnings("unchecked") + List adminApps = dataAccessService.executeSQLQuery(sql, EPApp.class, null); + HashSet appSet = new HashSet<>(); + for (EPApp app : adminApps) { + appSet.add(app); + appsList.add(app); + } + + for (EPApp app : openApps) { + if (!appSet.contains(app)) + appsList.add(app); + } + + return appsList; + } + } + + @Override + public List getPersAdminApps(EPUser user) { + final Map params = new HashMap<>(); + params.put("userId", user.getId()); + // Named query is stored in EP.hbm.xml, mapped to EPApp + @SuppressWarnings("unchecked") + List list = dataAccessService.executeNamedQuery("getPersAdminApps", params, null); + return list; + } + + @Override + public List getPersUserApps(EPUser user) { + final Map params = new HashMap<>(); + params.put("userId", user.getId()); + // Named query is stored in EP.hbm.xml, mapped to EPApp + @SuppressWarnings("unchecked") + List list = dataAccessService.executeNamedQuery("getPersUserApps", params, null); + return list; + } + + /* + * (non-Javadoc) + * + * @see + * org.openecomp.portalapp.portal.service.EPAppService#getAppCatalog(com.att + * .fusionapp.ecomp.portal.domain.EPUser) + */ + @Override + public List getUserAppCatalog(EPUser user) { + final Map params = new HashMap<>(); + params.put("userId", user.getId()); + // Named query is stored in EP.hbm.xml, mapped to AppCatalogItem + @SuppressWarnings("unchecked") + List list = dataAccessService.executeNamedQuery("getUserAppCatalog", params, null); + return list; + } + + /* + * (non-Javadoc) + * + * @see + * org.openecomp.portalapp.portal.service.EPAppService#getAdminAppCatalog( + * org.openecomp.portalapp.portal.domain.EPUser) + */ + @Override + public List getAdminAppCatalog(EPUser user) { + final Map params = new HashMap<>(); + params.put("userId", user.getId()); + // Named query is stored in EP.hbm.xml, mapped to AppCatalogItem + @SuppressWarnings("unchecked") + List list = dataAccessService.executeNamedQuery("getAdminAppCatalog", params, null); + return list; + } + + private List getOpenApps() { + @SuppressWarnings("unchecked") + List openApps = dataAccessService.getList(EPApp.class, " where open='Y' and enabled='Y'", null, null); + return openApps; + } + + @SuppressWarnings("unchecked") + @Override + public List getAppsOrderByName(EPUser user) { + final Map params = new HashMap<>(); + List sortedAppsByName = null; + try { + if (adminRolesService.isSuperAdmin(user)) { + params.put("userId", user.getId()); + sortedAppsByName = dataAccessService.executeNamedQuery("getPersAdminAppsOrderByName", params, null); + } else { + params.put("userId", user.getId()); + sortedAppsByName = dataAccessService.executeNamedQuery("getPersUserAppsOrderByName", params, null); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsOrderByName failed", e); + } + return sortedAppsByName; + } + + @SuppressWarnings("unchecked") + @Override + public List getAppsOrderByLastUsed(EPUser user) { + + final Map params = new HashMap<>(); + List sortedAppsByLastUsed = new ArrayList(); + List finalsortedAppsByLastUsed = new ArrayList(); + try { + if (adminRolesService.isSuperAdmin(user)) { + params.put("userId", user.getId()); + sortedAppsByLastUsed = dataAccessService.executeNamedQuery("getAdminAppsOrderByLastUsed", params, null); + } else { + params.put("userId", user.getId()); + sortedAppsByLastUsed = dataAccessService.executeNamedQuery("getUserAppsOrderByLastUsed", params, null); + } + Set epAppSet = new HashSet(); + for (EPApp eapp : sortedAppsByLastUsed) + if (!epAppSet.contains(eapp.getName())) { + finalsortedAppsByLastUsed.add(eapp); + epAppSet.add(eapp.getName()); + } + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsOrderByLastUsed failed", e); + } + return finalsortedAppsByLastUsed; + } + + @SuppressWarnings("unchecked") + @Override + public List getAppsOrderByMostUsed(EPUser user) { + final Map params = new HashMap<>(); + List sortedAppsByMostUsed = new ArrayList(); + List finalsortedAppsByMostUsed = new ArrayList(); + try { + if (adminRolesService.isSuperAdmin(user)) { + params.put("userId", user.getId()); + sortedAppsByMostUsed = dataAccessService.executeNamedQuery("getAdminAppsOrderByMostUsed", params, null); + } else { + params.put("userId", user.getId()); + sortedAppsByMostUsed = dataAccessService.executeNamedQuery("getUserAppsOrderByMostUsed", params, null); + } + Set epAppSet = new HashSet(); + + for (EPApp eapp : sortedAppsByMostUsed) { + if (!epAppSet.contains(eapp.getName())) { + finalsortedAppsByMostUsed.add(eapp); + epAppSet.add(eapp.getName()); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsOrderByMostUsed failed", e); + } + + return finalsortedAppsByMostUsed; + } + + /* + * This Method retrieves the User Apps by Sort Manual Preference + * + * @param: user--contains LoggedIn User Data + */ + @SuppressWarnings("unchecked") + @Override + public List getAppsOrderByManual(EPUser user) { + final Map params = new HashMap<>(); + List sortedAppsByManual = new ArrayList(); + List finalsortedAppsByManual = new ArrayList(); + try { + if (adminRolesService.isSuperAdmin(user)) { + params.put("userId", user.getId()); + sortedAppsByManual = dataAccessService.executeNamedQuery("getAdminAppsOrderByManual", params, null); + } else { + params.put("userId", user.getId()); + sortedAppsByManual = dataAccessService.executeNamedQuery("getUserAppsOrderByManual", params, null); + } + Set epAppSet = new HashSet(); + + for (EPApp eapp : sortedAppsByManual) { + if (!epAppSet.contains(eapp.getName())) { + finalsortedAppsByManual.add(eapp); + epAppSet.add(eapp.getName()); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppsOrderByManual failed", e); + } + return finalsortedAppsByManual; + } + + @Override + public List getOnboardingApps() { + @SuppressWarnings("unchecked") + List apps = dataAccessService.getList(EPApp.class, " where id!=" + ECOMP_APP_ID, null, null); + List onboardingAppsList = new ArrayList(); + for (EPApp app : apps) { + OnboardingApp onboardingApp = new OnboardingApp(); + createOnboardingFromApp(app, onboardingApp); + onboardingAppsList.add(onboardingApp); + } + return onboardingAppsList; + } + + @Override + public List getEnabledNonOpenOnboardingApps() { + @SuppressWarnings("unchecked") + List apps = dataAccessService.getList(EPApp.class, + " where enabled = true and open = false and id!=" + ECOMP_APP_ID, null, null); + List onboardingAppsList = new ArrayList(); + for (EPApp app : apps) { + OnboardingApp onboardingApp = new OnboardingApp(); + createOnboardingFromApp(app, onboardingApp); + onboardingAppsList.add(onboardingApp); + } + return onboardingAppsList; + } + + @SuppressWarnings("unchecked") + private void validateOnboardingApp(OnboardingApp onboardingApp, FieldsValidator fieldsValidator) { + boolean duplicatedUrl = false; + boolean duplicatedName = false; + List apps; + if (onboardingApp.id == null) { + apps = dataAccessService.getList(EPApp.class, + " where url = '" + onboardingApp.url + "' or name = '" + onboardingApp.name + "'", null, null); + } else { + apps = dataAccessService.getList(EPApp.class, " where id = " + onboardingApp.id + " or url = '" + + onboardingApp.url + "' or name = '" + onboardingApp.name + "'", null, null); + } + for (EPApp app : apps) { + if (onboardingApp.id != null && onboardingApp.id.equals(app.getId())) { + continue; + } + if (!duplicatedUrl && app.getUrl().equalsIgnoreCase(onboardingApp.url)) { + duplicatedUrl = true; + if (duplicatedName) { + break; + } + } + if (!duplicatedName && app.getName().equalsIgnoreCase(onboardingApp.name)) { + duplicatedName = true; + if (duplicatedUrl) { + break; + } + } + } + if (duplicatedUrl || duplicatedName) { + if (duplicatedUrl) { + fieldsValidator.addProblematicFieldName(urlField); + } + if (duplicatedName) { + fieldsValidator.addProblematicFieldName(nameField); + } + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + fieldsValidator.errorCode = new Long(EPCommonSystemProperties.DUBLICATED_FIELD_VALUE_ECOMP_ERROR); + } + } + + @Override + public FieldsValidator modifyOnboardingApp(OnboardingApp modifiedOnboardingApp, EPUser user) { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: entering modifyOnboardingApp"); + FieldsValidator fieldsValidator = onboardingAppFieldsChecker(modifiedOnboardingApp); + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + validateOnboardingApp(modifiedOnboardingApp, fieldsValidator); + } + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + if (modifiedOnboardingApp.id != null) { + updateApp(modifiedOnboardingApp.id, modifiedOnboardingApp, fieldsValidator, user); + } else { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + } + } + return fieldsValidator; + } + + @Override + public FieldsValidator addOnboardingApp(OnboardingApp newOnboardingApp, EPUser user) { + FieldsValidator fieldsValidator = onboardingAppFieldsChecker(newOnboardingApp); + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + validateOnboardingApp(newOnboardingApp, fieldsValidator); + } + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + if (newOnboardingApp.id == null) { + updateApp(null, newOnboardingApp, fieldsValidator, user); + } else { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + } + } + return fieldsValidator; + } + + @Override + public FieldsValidator deleteOnboardingApp(EPUser user, Long appid) { + FieldsValidator fieldsValidator = new FieldsValidator(); + if (!adminRolesService.isSuperAdmin(user)) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_FORBIDDEN); + return fieldsValidator; + } + Boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + + // 1) Remove the URL for any functional menu item associated with + // this app + String sql = "UPDATE fn_menu_functional m, fn_menu_functional_roles mr SET m.url='' " + + " WHERE m.menu_id=mr.menu_id " + " AND mr.app_id='" + appid + "'"; + logQuery(sql); + Query query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove any favorites associated with a menu item that is + // associated with this app + sql = "Delete from fn_menu_favorites " + " using fn_menu_favorites inner join fn_menu_functional_roles " + + " where fn_menu_functional_roles.app_id='" + appid + "' " + + " AND fn_menu_functional_roles.menu_id=fn_menu_favorites.menu_id"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove all role, appid records from fn_menu_functional_role + // that are associated with this app + sql = "delete from fn_menu_functional_roles where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove all records from fn_user_role associated with this app + sql = "delete from fn_user_role where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove any widgets associated with this app + sql = "delete from ep_widget_catalog_role where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove any roles associated with this app + sql = "delete from ep_role_notification " + " using ep_role_notification inner join fn_role " + + " where fn_role.app_id='" + appid + "' " + " and ep_role_notification.role_id= fn_role.role_id"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove all records from fn_role associated with this app + sql = "delete from fn_role where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove app contact us entries + sql = "delete from fn_app_contact_us where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove any widgets associated with this app + sql = "delete from fn_widget where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove rows in the app personalization selection table + sql = "delete from fn_pers_user_app_sel where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Remove rows in the app personalization sort table + sql = "delete from ep_pers_user_app_man_sort where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + // Delete the app + sql = "delete from fn_app where app_id='" + appid + "'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + + transaction.commit(); + result = true; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteOnboardingApp failed", e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError); + EcompPortalUtils.rollbackTransaction(transaction, "deleteOnboardingApp rollback, exception = " + e); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "deleteOnboardingApp"); + } + if (!result) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + private static Object syncRests = new Object(); + + // An app has been enabled/disabled. Must enable/disable all associated + // functional menu items. + private void setFunctionalMenuItemsEnabled(Session localSession, Boolean enabled, Long appId) { + String active_yn = enabled ? "Y" : "N"; + String sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn " + + "FROM fn_menu_functional m, fn_menu_functional_roles r " + "WHERE m.menu_id = r.menu_id " + + " AND r.app_id = '" + appId + "' "; + logQuery(sql); + @SuppressWarnings("unchecked") + List menuItems = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + for (FunctionalMenuItem menuItem : menuItems) { + FunctionalMenuItem myMenuItem = (FunctionalMenuItem) localSession.get(FunctionalMenuItem.class, + menuItem.menuId); + myMenuItem.active_yn = active_yn; + localSession.save(myMenuItem); + } + } + + // Attention! If (appId == null) we use this function to create application + // otherwise we use it to modify existing application + private void updateApp(Long appId, OnboardingApp onboardingApp, FieldsValidator fieldsValidator, EPUser user) { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: entering updateApp"); + // Separate out the code for a restricted app, since it doesn't need any + // of the UEB code. + if (onboardingApp.restrictedApp) { + boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + EPApp app; + if (appId == null) { + app = new EPApp(); + } else { + app = (EPApp) localSession.get(EPApp.class, appId); + if (app == null || app.getId() == null) { // App is already + // deleted! + transaction.commit(); + localSession.close(); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_NOT_FOUND); + return; + } + } + createAppFromOnboarding(app, onboardingApp, localSession); + localSession.saveOrUpdate(app); + // Enable or disable all menu items associated with this app + setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); + transaction.commit(); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "updateApp rollback, exception = " + EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "updateApp"); + } + if (!result) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + } else { + synchronized (syncRests) { + boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + EPApp app; + if (appId == null) { + app = new EPApp(); + // ------------------------------------------------------------------------------------------- + // Register this App with the UEB communication server. + // Save + // the App's unique mailbox/topic + // name and keys to the FN_APP table. The App's mailbox + // and + // keys will be visible to the + // admin on the ECOMP portal. + // ------------------------------------------------------------------------------------------- + TopicManager topicManager = new TopicManager(); + final CambriaIdentityManager im = new CambriaClientBuilders.IdentityManagerBuilder() + .usingHosts(Helper.uebUrlList()).build(); + com.att.nsa.apiClient.credentials.ApiCredential credential = im.createApiKey(user.getEmail(), + "ECOMP Portal Owner"); + String appKey = credential.getApiKey(); + String appSecret = credential.getApiSecret(); + String appMailboxName = null; + + int maxNumAttemptsToCreateATopic = 3; + boolean successfullyCreatedMailbox = false; + for (int i = 0; i < maxNumAttemptsToCreateATopic; i++) { + appMailboxName = "ECOMP-PORTAL-OUTBOX-" + (int) (Math.random() * 100000.0); + + try { + topicManager.createTopic( + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), + appMailboxName, "ECOMP outbox for app" + onboardingApp.name); + successfullyCreatedMailbox = true; + logger.debug(EELFLoggerDelegate.debugLogger, + "Successfully created " + appMailboxName + " for App " + onboardingApp.name); + logger.debug(EELFLoggerDelegate.debugLogger, " Key = " + appKey + " Secret = " + + appSecret + " generated using = " + user.getEmail()); + break; + } catch (HttpException e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebConnectionError, e); + if (e.getStatusCode() == 409) { + logger.error(EELFLoggerDelegate.errorLogger, "Topic/mailbox " + appMailboxName + + " already exists. Will try using a different name", e); + } else { + logger.error(EELFLoggerDelegate.errorLogger, "HttpException when onboarding App: ", + e); + } + } + } + + if (successfullyCreatedMailbox) { + onboardingApp.setUebTopicName(appMailboxName); + onboardingApp.setUebKey(appKey); + onboardingApp.setUebSecret(appSecret); + + try { + /* + * EP is a publisher to this App's new mailbox + */ + topicManager.addPublisher( + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + appMailboxName); + + /* + * This App is a subscriber of its own mailbox + */ + topicManager.addSubscriber( + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), appKey, + appMailboxName); + + /* + * This App is a publisher to EP + */ + topicManager.addPublisher( + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), + PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), appKey, + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); + } catch (HttpException | CambriaApiException | IOException e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e); + logger.error(EELFLoggerDelegate.errorLogger, + "Error when configuring Publisher/Subscriber for App's new mailbox", e); + transaction.commit(); + localSession.close(); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + return; + } + } else { + transaction.commit(); + localSession.close(); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + return; + } + } else { + app = (EPApp) localSession.get(EPApp.class, appId); + if (app == null || app.getId() == null) { + // App is already deleted! + transaction.commit(); + localSession.close(); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_NOT_FOUND); + return; + } + } + logger.debug(EELFLoggerDelegate.debugLogger, "LR: about to call createAppFromOnboarding"); + createAppFromOnboarding(app, onboardingApp, localSession); + logger.debug(EELFLoggerDelegate.debugLogger, + "LR: updateApp: finished calling createAppFromOnboarding"); + localSession.saveOrUpdate(app); + logger.debug(EELFLoggerDelegate.debugLogger, + "LR: updateApp: 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"); + transaction.commit(); + logger.debug(EELFLoggerDelegate.debugLogger, "LR: updateApp: finished calling transaction.commit"); + epUebHelper.addPublisher(app); + logger.debug(EELFLoggerDelegate.debugLogger, + "LR: updateApp: finished calling epUebHelper.addPublisher"); + result = true; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateApp failed", e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + EcompPortalUtils.rollbackTransaction(transaction, + "updateApp rollback, exception = " + EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "updateApp"); + } + if (!result) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + } + } + + /** + * Populates a transport model of the application from a database row model. + * Leaves out the thumbnail because the FE fetches images via a different + * API. + * + * @param app + * Model of database row + * @param onboardingApp + * Model for transport as JSON + */ + @Override + public void createOnboardingFromApp(EPApp app, OnboardingApp onboardingApp) { + onboardingApp.id = app.getId(); + onboardingApp.name = app.getName(); + onboardingApp.imageUrl = app.getImageUrl(); + onboardingApp.description = app.getDescription(); + onboardingApp.notes = app.getNotes(); + onboardingApp.url = app.getUrl(); + onboardingApp.alternateUrl = app.getAlternateUrl(); + onboardingApp.restUrl = app.getAppRestEndpoint(); + onboardingApp.isOpen = app.getOpen(); + onboardingApp.isEnabled = app.getEnabled(); + onboardingApp.username = app.getUsername(); + onboardingApp.appPassword = decryptedPassword(app.getAppPassword(), app); + onboardingApp.uebTopicName = app.getUebTopicName(); + onboardingApp.uebKey = app.getUebKey(); + onboardingApp.uebSecret = app.getUebSecret(); + onboardingApp.setRestrictedApp(app.isRestrictedApp()); + // if (app.getThumbnail() != null) + // onboardingApp.thumbnail = new + // String(Base64.getEncoder().encode(app.getThumbnail())); + } + + /** + * Creates a database object for an application from an uploaded transport + * model. Must decode the thumbnail, if any. + * + * @param app + * @param onboardingApp + * @param localSession + * @return The first argument. + */ + protected EPApp createAppFromOnboarding(EPApp app, OnboardingApp onboardingApp, Session localSession) { + app.setName(onboardingApp.name); + app.setDescription(onboardingApp.description); + app.setNotes(onboardingApp.notes); + app.setUrl(onboardingApp.url); + app.setAlternateUrl(onboardingApp.alternateUrl); + app.setAppRestEndpoint(onboardingApp.restUrl); + app.setOpen(onboardingApp.isOpen); + app.setEnabled(onboardingApp.isEnabled); + app.setUsername(onboardingApp.username); + app.setAppPassword(this.encryptedPassword(onboardingApp.appPassword, app)); + app.setUebTopicName(onboardingApp.uebTopicName); + app.setUebKey(onboardingApp.uebKey); + app.setUebSecret(onboardingApp.uebSecret); + app.setRestrictedApp(onboardingApp.restrictedApp); + if (!StringUtils.isEmpty(onboardingApp.thumbnail)) { + logger.debug(EELFLoggerDelegate.debugLogger, "createAppFromOnboarding: onboarding thumbnail is NOT empty"); + String[] splitBase64Thumbnail = onboardingApp.thumbnail.split("base64,"); + logger.debug(EELFLoggerDelegate.debugLogger, + "createAppFromOnboarding: length of splitBase64Thumbnail: " + splitBase64Thumbnail.length); + if (splitBase64Thumbnail.length > 1) { + // This occurs when we have a new image, not an existing image + byte[] decodedImage = Base64.getDecoder().decode(splitBase64Thumbnail[1].getBytes()); + logger.debug(EELFLoggerDelegate.debugLogger, "createAppFromOnboarding: finished calling decode"); + // This is basically a boolean indicator that an image is + // present. + app.setImageUrl(constructImageName(onboardingApp)); + app.setThumbnail(decodedImage); + } + } else if (app.getThumbnail() != null) { + // The thumbnail that came in from the json is empty; the previous + // thumbnail is NOT empty. Must delete it. + logger.debug(EELFLoggerDelegate.debugLogger, + "createAppFromOnboarding: onboarding thumbnail is empty; db thumbnail is NOT null"); + app.setImageUrl(null); + app.setThumbnail(null); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "createAppFromOnboarding: onboarding thumbnail is empty; db thumbnail is null"); + } + return app; + } + + protected String constructImageName(OnboardingApp onboardingApp) { + return "portal_" + String.valueOf(onboardingApp.url.hashCode() + "_" + (int) (Math.random() * 100000.0)) + + ".png"; + } + + // Don't encrypt or decrypt the password if it is null or the empty string + private String decryptedPassword(String encryptedAppPwd, EPApp app) { + String result = ""; + if (encryptedAppPwd != null & encryptedAppPwd.length() > 0) { + try { + result = CipherUtil.decrypt(encryptedAppPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed for app " + app.getName(), e); + } + } + return result; + } + + protected String encryptedPassword(String decryptedAppPwd, EPApp app) { + String result = ""; + if (decryptedAppPwd != null & decryptedAppPwd.length() > 0) { + try { + result = CipherUtil.encrypt(decryptedAppPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed for app " + app.getName(), e); + } + } + return result; + } + + @SuppressWarnings("unchecked") + @Override + public FieldsValidator saveWidgetsSortManual(List widgetsSortManual, EPUser user) { + FieldsValidator fieldsValidator = new FieldsValidator(); + final Map params = new HashMap<>(); + List epManualWidgets = new ArrayList(); + + try { + params.put("userId", user.getId()); + epManualWidgets = dataAccessService.executeNamedQuery("userWidgetManualSortPrfQuery", params, null); + Map existingWidgetsIds = new HashMap(); + for (EPWidgetsManualSortPreference userWidgetManualPref : epManualWidgets) { + existingWidgetsIds.put(userWidgetManualPref.getWidgetId(), userWidgetManualPref); + } + for (EPWidgetsSortPreference epWidgetsManPref : widgetsSortManual) { + if (epWidgetsManPref.getWidgetid() != null) { + Long widgetid = epWidgetsManPref.getWidgetid(); + if (existingWidgetsIds.containsKey(widgetid)) { + EPWidgetsManualSortPreference epWidgetsManualSort = existingWidgetsIds.get(widgetid); + epWidgetsManualSort.setWidgetRow(epWidgetsManPref.getRow()); + epWidgetsManualSort.setWidgetCol(epWidgetsManPref.getCol()); + epWidgetsManualSort.setWidgetWidth(epWidgetsManPref.getSizeX()); + epWidgetsManualSort.setWidgetHeight(epWidgetsManPref.getSizeY()); + HashMap additionalUpdateParam = new HashMap(); + additionalUpdateParam.put("userId", epWidgetsManualSort.getUserId()); + dataAccessService.saveDomainObject(epWidgetsManualSort, additionalUpdateParam); + } else { + EPWidgetsManualSortPreference epWidgetsManualSort = new EPWidgetsManualSortPreference(); + epWidgetsManualSort.setWidgetId(epWidgetsManPref.getWidgetid()); + epWidgetsManualSort.setWidgetRow(epWidgetsManPref.getRow()); + epWidgetsManualSort.setWidgetCol(epWidgetsManPref.getCol()); + epWidgetsManualSort.setWidgetWidth(epWidgetsManPref.getSizeX()); + epWidgetsManualSort.setWidgetHeight(epWidgetsManPref.getSizeY()); + epWidgetsManualSort.setUserId(Ints.checkedCast(user.getId())); + dataAccessService.saveDomainObject(epWidgetsManualSort, null); + } + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveWidgetsSortManual failed", e); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + @SuppressWarnings("unchecked") + @Override + public FieldsValidator deleteUserWidgetSortPref(List delWidgetSortPref, EPUser user) { + FieldsValidator fieldsValidator = new FieldsValidator(); + final Map params = new HashMap<>(); + List epWidgets = new ArrayList(); + try { + params.put("userId", user.getId()); + epWidgets = dataAccessService.executeNamedQuery("userWidgetManualSortPrfQuery", params, null); + Map existingWidgetIds = new HashMap(); + for (EPWidgetsManualSortPreference userWidgetSortPref : epWidgets) { + existingWidgetIds.put(userWidgetSortPref.getWidgetId(), userWidgetSortPref); + } + for (EPWidgetsSortPreference delEpWidgetsManPref : delWidgetSortPref) { + if (delEpWidgetsManPref.getWidgetid() != null) { + Long widgetId = delEpWidgetsManPref.getWidgetid(); + if (existingWidgetIds.containsKey(widgetId)) { + dataAccessService.deleteDomainObjects(EPWidgetsManualSortPreference.class, + "widget_id=" + widgetId + " AND user_id=" + user.getId(), null); + } + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteUserWidgetSortPref failed", e); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + /* + * This Method Stores the Sort Order of User Apps by Sort Manual Preference + * + * @param: appsSortManual--contains User Apps Data + * + * @param: user--contains LoggedIn User Data + */ + @SuppressWarnings("unchecked") + @Override + public FieldsValidator saveAppsSortManual(List appsSortManual, EPUser user) { + FieldsValidator fieldsValidator = new FieldsValidator(); + final Map params = new HashMap<>(); + List epManualApps = new ArrayList(); + + try { + params.put("userId", user.getId()); + epManualApps = dataAccessService.executeNamedQuery("userAppsManualSortPrfQuery", params, null); + Map existingAppIds = new HashMap(); + for (EPUserAppsManualSortPreference userAppManualPref : epManualApps) { + existingAppIds.put(userAppManualPref.getAppId(), userAppManualPref); + } + for (EPAppsManualPreference epAppsManPref : appsSortManual) { + if (epAppsManPref.getAppid() != null) { + Long appid = epAppsManPref.getAppid(); + if (existingAppIds.containsKey(appid)) { + EPUserAppsManualSortPreference epAppsManualSort = existingAppIds.get(appid); + epAppsManualSort + .setAppManualSortOrder((epAppsManPref.getCol() + (6 * epAppsManPref.getRow())) + 1); + HashMap additionalUpdateParam = new HashMap(); + additionalUpdateParam.put("userId", epAppsManualSort.getUserId()); + dataAccessService.saveDomainObject(epAppsManualSort, additionalUpdateParam); + } else { + EPUserAppsManualSortPreference epAppsManualSort = new EPUserAppsManualSortPreference(); + epAppsManualSort.setAppId(epAppsManPref.getAppid()); + epAppsManualSort + .setAppManualSortOrder((epAppsManPref.getCol() + (6 * epAppsManPref.getRow())) + 1); + epAppsManualSort.setUserId(Ints.checkedCast(user.getId())); + dataAccessService.saveDomainObject(epAppsManualSort, null); + } + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveAppsSortManual failed", e); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.EPAppService# + * deleteUserAppSortManual(java.lang.String, + * org.openecomp.portalapp.portal.domain.EPUser) + */ + @SuppressWarnings("unchecked") + @Override + public FieldsValidator deleteUserAppSortManual(EPDeleteAppsManualSortPref delAppSortManual, EPUser user) { + FieldsValidator fieldsValidator = new FieldsValidator(); + final Map params = new HashMap<>(); + List epManualApps = new ArrayList(); + try { + params.put("userId", user.getId()); + epManualApps = dataAccessService.executeNamedQuery("userAppsManualSortPrfQuery", params, null); + Map existingAppIds = new HashMap(); + for (EPUserAppsManualSortPreference userAppPref : epManualApps) { + existingAppIds.put(userAppPref.getAppId(), userAppPref); + } + if (existingAppIds.containsKey(delAppSortManual.getAppId()) && !delAppSortManual.isSelect()) { + dataAccessService.deleteDomainObjects(EPUserAppsManualSortPreference.class, + "app_id=" + delAppSortManual.getAppId() + " AND user_id=" + user.getId(), null); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "deleteUserAppSortManual failed", e); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + @SuppressWarnings("unchecked") + @Override + public FieldsValidator saveAppsSortPreference(EPAppsSortPreference appsSortPreference, EPUser user) { + FieldsValidator fieldsValidator = new FieldsValidator(); + final Map params = new HashMap<>(); + List epSortTypes = new ArrayList(); + EPUserAppsSortPreference usrSortPr = null; + try { + params.put("userId", user.getId()); + epSortTypes = dataAccessService.executeNamedQuery("userAppsSortPreferenceQuery", params, null); + if (epSortTypes.size() == 0) { + usrSortPr = new EPUserAppsSortPreference(); + usrSortPr.setUserId(Ints.checkedCast(user.getId())); + usrSortPr.setSortPref(appsSortPreference.getValue()); + dataAccessService.saveDomainObject(usrSortPr, null); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } else { + usrSortPr = epSortTypes.get(0); + usrSortPr.setSortPref(appsSortPreference.getValue()); + HashMap additionalUpdateParam = new HashMap(); + additionalUpdateParam.put("userId", usrSortPr.getUserId()); + dataAccessService.saveDomainObject(usrSortPr, additionalUpdateParam); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveAppsSortPreference failed", e); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + @SuppressWarnings("unchecked") + @Override + public String getUserAppsSortTypePreference(EPUser user) { + final Map params = new HashMap<>(); + List userSortPrefs = new ArrayList(); + try { + params.put("userId", user.getId()); + userSortPrefs = dataAccessService.executeNamedQuery("userAppsSortPreferenceQuery", params, null); + if (userSortPrefs.size() > 0) + return userSortPrefs.get(0).getSortPref(); + else + return null; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserAppsSortTypePreference failed", e); + } + return null; + + } + + @Override + public List getUserRemoteApps(String id) { + throw new RuntimeException(" Cannot be called from parent class"); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppService.java new file mode 100644 index 00000000..c7bf680d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAppService.java @@ -0,0 +1,213 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.AdminUserApplications; +import org.openecomp.portalapp.portal.domain.AppIdAndNameTransportModel; +import org.openecomp.portalapp.portal.domain.AppsResponse; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompApp; +import org.openecomp.portalapp.portal.domain.UserRoles; +import org.openecomp.portalapp.portal.ecomp.model.AppCatalogItem; +import org.openecomp.portalapp.portal.transport.EPAppsManualPreference; +import org.openecomp.portalapp.portal.transport.EPAppsSortPreference; +import org.openecomp.portalapp.portal.transport.EPDeleteAppsManualSortPref; +import org.openecomp.portalapp.portal.transport.EPWidgetsSortPreference; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.LocalRole; +import org.openecomp.portalapp.portal.transport.OnboardingApp; + +public interface EPAppService { + + /** + * Get all applications adminId is an admin + * + * @param adminId + * - the admin + * @return the admin's applications + */ + List getUserAsAdminApps(EPUser user); + + List getUserByOrgUserIdAsAdminApps(String orgUserId); + + /** + * Gets all rows and all fields from the fn_app table. + * + * @return list of EPApp objects + */ + List getAppsFullList(); + + /** + * Gets all rows and most fields from the fn_app table. + * + * @return list of EcompApp objects. + */ + List getEcompAppAppsFullList(); + + /** + * Get apps with app app admins + * + * @return List of AdminUserApplications + */ + List getAppsAdmins(); + + /** + * Get all apps from fn_app table (index, name, title only). + * + * @param all + * If all is true, returns active and inactive apps; otherwise, + * just active apps. + * @return List of AppsResponse objects. + */ + List getAllApps(Boolean all); + + UserRoles getUserProfile(String loginId); + + UserRoles getUserProfileNormalized(EPUser user); + + List getAppRoles(Long appId); + + List getAdminApps(EPUser user); + + List getAppsForSuperAdminAndAccountAdmin(EPUser user); + + /** + * Gets the applications accessible to the specified user, which includes + * all enabled open applications, plus all enabled applications for which + * the user has a defined role for that app. + * + * @param user + * EPUser object with the user's ATT UID + * @return the user's list of applications, which may be empty. + */ + List getUserApps(EPUser user); + + /** + * Gets the user-personalized list of applications for the Portal (super) + * admin, which includes enabled open applications, enabled applications for + * which the user has a defined role for that app, and/or enabled + * applications which the user has chosen to show. + * + * @param user + * EPUser object with the user's ATT UID + * @return the user's personalized list of applications, which may be empty. + */ + List getPersAdminApps(EPUser user); + + /** + * Gets the user-personalized list of accessible applications, which + * includes enabled open applications and/or enabled applications for which + * the user has a defined role for that app. Personalization means the user + * can indicate an accessible application should be excluded from this + * result. + * + * @param user + * EPUser object with the user's ATT UID + * @return the user's personalized list of applications, which may be empty. + */ + List getPersUserApps(EPUser user); + + /** + * Gets the application catalog for the specified user who is a super admin. + * This includes all enabled applications. Each item indicates whether the + * user has access (open or via a role), and whether the application is + * selected for showing in the user's home (applications) page. Admin sees + * slightly different behavior - can force an app onto the home page using + * the personalization feature (user-app-selection table). + * + * @param user + * @return list of all enabled applications, which may be empty + */ + List getAdminAppCatalog(EPUser user); + + /** + * Gets the application catalog for the specified user, who is a regular + * user. This includes all enabled applications. Each item indicates whether + * the user has access (open or via a role), and whether the application is + * selected for showing in the user's home (applications) page. + * + * @param user + * @return list of all enabled applications, which may be empty + */ + List getUserAppCatalog(EPUser user); + + List getOnboardingApps(); + + List getEnabledNonOpenOnboardingApps(); + + FieldsValidator modifyOnboardingApp(OnboardingApp modifiedOnboardingApp, EPUser user); + + FieldsValidator addOnboardingApp(OnboardingApp newOnboardingApp, EPUser user); + + /** + * Deletes the specified application from all tables where the app_id is + * used, and ultimately from the fn_app table. + * + * @param user + * Must be Portal (super) administrator + * @param onboardingAppId + * ID of application to be deleted + * @return Status code + */ + FieldsValidator deleteOnboardingApp(EPUser user, Long onboardingAppId); + + List transformAppsToEcompApps(List appsList); + + EPApp getApp(Long appId); + + EPApp getAppDetail(String appName); + + List getAppsOrderByName(EPUser user); + + FieldsValidator saveAppsSortPreference(EPAppsSortPreference appsSortPreference, EPUser user); + + FieldsValidator saveAppsSortManual(List appsSortManual, EPUser user); + + FieldsValidator saveWidgetsSortManual(List widgetsSortManual, EPUser user); + + /** + * Deletes the sort order of user apps by sort manual preference + * + * @param delAppSortManual + * User Apps Data + * @param user + * LoggedIn User Data + * @return FieldsValidator + */ + FieldsValidator deleteUserAppSortManual(EPDeleteAppsManualSortPref delAppSortManual, EPUser user); + + FieldsValidator deleteUserWidgetSortPref(List delWidgetSortPref, EPUser user); + + String getUserAppsSortTypePreference(EPUser user); + + List getAppsOrderByLastUsed(EPUser user); + + List getAppsOrderByMostUsed(EPUser user); + + List getAppsOrderByManual(EPUser user); + + List getUserRemoteApps(String id); + + void createOnboardingFromApp(EPApp app, OnboardingApp onboardingApp); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditService.java new file mode 100644 index 00000000..a35a8ba2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditService.java @@ -0,0 +1,27 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Date; + +public interface EPAuditService { + public Date getGuestLastLogin(String userId); + public void delAuditLogFromDay(); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditServiceImpl.java new file mode 100644 index 00000000..1a343866 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPAuditServiceImpl.java @@ -0,0 +1,96 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.time.LocalDate; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.domain.AuditLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; + +@Service("epAuditService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class EPAuditServiceImpl implements EPAuditService { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAuditServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Override + /* get the guest last login time with orgUserId as param. + * If record not found in table, return null. + * + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.EPUserService#getGuestLastLogin(java.lang.String) + */ + public Date getGuestLastLogin(String userId) { + Map params = new HashMap<>(); + params.put("userId", userId); + List list = getDataAccessService().executeNamedQuery("getGuestLastLogin", params, null); + Date date=null; + if(list!=null){ + if(list.size()==1) /* if list only contains one item, meaning this is the first time user logs in or record not found in db*/ + date = list.get(0); /*the guest's current log in time*/ + else if(list.size()==2) + date = list.get(1); /*most recent login date from db*/ + } + return date; + } + + @Override + /* Clean all the records in fn_audit_log table that are less than defined date in system.property + * + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.EPAuditService#delAuditLogFromDay() + */ + public void delAuditLogFromDay(){ + if (EPCommonSystemProperties.containsProperty(EPCommonSystemProperties.AUDITLOG_DEL_DAY_FROM)) { + String day = EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUDITLOG_DEL_DAY_FROM); + LocalDate removeDateFrom = LocalDate.now().minusDays(Integer.valueOf(day)); + getDataAccessService().deleteDomainObjects(AuditLog.class, "audit_date <'"+removeDateFrom+"'",null); + }else{ + logger.error(EELFLoggerDelegate.errorLogger, "delAuditLogFromDay Exception = system.propertiy value is empty on" + EPCommonSystemProperties.AUDITLOG_DEL_DAY_FROM); + } + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapService.java new file mode 100644 index 00000000..c77684fa --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapService.java @@ -0,0 +1,31 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalsdk.core.command.support.SearchResult; +import org.openecomp.portalsdk.core.domain.support.DomainVo; + + +public interface EPLdapService { + + // search POST for users based on the criteria selected in the Request + SearchResult searchPost(DomainVo searchCriteria, String sortBy1, String sortBy2, String sortBy3, int pageNo, int dataSize, int userId) throws Exception; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapServiceImpl.java new file mode 100644 index 00000000..dfcc0c7f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLdapServiceImpl.java @@ -0,0 +1,288 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.SearchControls; + +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.command.support.SearchResult; +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.support.FusionService; +import org.openecomp.portalsdk.core.service.support.ServiceLocator; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("epLdapService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +public class EPLdapServiceImpl extends FusionService implements EPLdapService { + @Autowired + private ServiceLocator serviceLocator; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPLdapServiceImpl.class); + + @EPAuditLog + @SuppressWarnings({ "rawtypes", "unchecked" }) + public SearchResult searchPost(DomainVo searchCriteria, String sortBy1, String sortBy2, String sortBy3, + int pageNo, int dataSize, int userId) throws Exception { + + String remoteHost = ""; + + // initialize the directory context to access POST + DirContext dirContext = serviceLocator.getDirContext(SystemProperties.getProperty(SystemProperties.POST_INITIAL_CONTEXT_FACTORY), + SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL), + SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL)); + + SearchResult searchResult = new SearchResult(); + + try { + + remoteHost = String.format("%s/%s", SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL), + SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL)); + MDC.put(EPCommonSystemProperties.FULL_URL, remoteHost); + + String[] postAttributes = {"nickname","givenName","initials","sn","employeeNumber","mail","telephoneNumber", + "departmentNumber","a1","street","roomNumber","l","st","postalCode","zip4","physicalDeliveryOfficeName","bc", + "friendlyCountryName","bd","bdname","bu","buname","jtname","mgrid","a2","compcode","compdesc", + "costcenter","silo","b2"}; + + SearchControls searchControls = new SearchControls(); + searchControls.setTimeLimit(5000); + searchControls.setReturningAttributes(postAttributes); + + StringBuffer filterClause = new StringBuffer("(&(objectClass=*)"); + + EPUser user = (EPUser)searchCriteria; + + if(Utilities.nvl(user.getFirstName()).length() > 0) { + filterClause.append("(givenName=").append(user.getFirstName()).append("*)"); + } + if(Utilities.nvl(user.getLastName()).length() > 0) { + filterClause.append("(sn=").append(user.getLastName()).append("*)"); + } + if(Utilities.nvl(user.getHrid()).length() > 0) { + filterClause.append("(employeeNumber=").append(user.getHrid()).append("*)"); + } + if(Utilities.nvl(user.getOrgManagerUserId()).length() > 0) { + filterClause.append("(mgrid=").append(user.getOrgManagerUserId()).append("*)"); + } + if(Utilities.nvl(user.getOrgCode()).length() > 0) { + filterClause.append("(departmentNumber=").append(user.getOrgCode()).append("*)"); + } + if(Utilities.nvl(user.getEmail()).length() > 0) { + filterClause.append("(mail=").append(user.getEmail()).append("*)"); + } + if(Utilities.nvl(user.getOrgUserId()).length() > 0) { + filterClause.append("(a1=").append(user.getOrgUserId()).append("*)"); + } + filterClause.append("(c3=N)"); // this has been added to filter CP09 entries on the LDAP server that are duplicates of existing individuals + filterClause.append(")"); + + List list = new ArrayList(); + if (!filterClause.toString().equals("(&(objectClass=*))")) { + NamingEnumeration e = dirContext.search(SystemProperties.getProperty(SystemProperties.POST_PROVIDER_URL) + "/" + + SystemProperties.getProperty(SystemProperties.POST_SECURITY_PRINCIPAL), + filterClause.toString(), + searchControls); + list = processResults(e); + } + + Collections.sort(list); + + searchResult = new SearchResult(list); + searchResult.setPageNo(pageNo); + if(dataSize >= 0) { + searchResult.setDataSize(dataSize); + } + else { + searchResult.setDataSize(list.size()); + } + } catch(NamingException ne) { + String stackTrace = EcompPortalUtils.getStackTrace(ne); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing the LDAP search. Details: " + stackTrace); + } catch(Exception e) { + String stackTrace = EcompPortalUtils.getStackTrace(e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing the LDAP search. Details: " + stackTrace); + } + finally { + dirContext.close(); + } + + return searchResult; + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @EPMetricsLog + private ArrayList processResults(NamingEnumeration e) throws NamingException { + ArrayList results = new ArrayList(); + int count = 0; + + while (e.hasMore()) { + javax.naming.directory.SearchResult searchResult = (javax.naming.directory.SearchResult)e.next(); + results.add(processAttributes(searchResult.getAttributes())); + count++; + + if(count > Integer.parseInt(SystemProperties.getProperty(SystemProperties.POST_MAX_RESULT_SIZE))) { + break; + } + } + return results; + } + + + @SuppressWarnings("rawtypes") + @EPMetricsLog + private DomainVo processAttributes(Attributes resultAttributes) throws NamingException { + EPUser user = new EPUser(); + + try { + if (resultAttributes == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "This result has no attributes"); + } else { + for (NamingEnumeration e = resultAttributes.getAll(); e.hasMore();) { //why the nested loop? + Attribute attribute = (Attribute)e.next(); + for (NamingEnumeration ie = attribute.getAll(); ie.hasMore();) { + if (attribute.getID().equalsIgnoreCase("nickname")) { + user.setFirstName((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("initials")) { + user.setMiddleInitial((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("sn")) { + user.setLastName((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("employeeNumber")) { + user.setHrid((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("mail")) { + user.setEmail((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("telephoneNumber")) { + user.setPhone((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("departmentNumber")) { + user.setOrgCode((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("a1")) { + user.setOrgUserId((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("street")) { + user.setAddress1((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("roomNumber")) { + user.setAddress2((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("l")) { + user.setCity((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("st")) { + user.setState((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("postalCode")) { + user.setZipCode((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("zip4")) { + user.setZipCodeSuffix((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("physicalDeliveryOfficeName")) { + user.setLocationClli((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("bc")) { + user.setBusinessCountryCode((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("friendlyCountryName")) { + user.setBusinessCountryName((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("bd")) { + user.setDepartment((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("bdname")) { + user.setDepartmentName((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("jtname")) { + user.setJobTitle((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("mgrid")) { + user.setOrgManagerUserId((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("a2")) { + user.setCommandChain((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("compcode")) { + user.setCompanyCode((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("compdesc")) { + user.setCompany((String) ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("bu")) { + user.setBusinessUnit((String)ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("buname")) { + user.setBusinessUnitName((String)ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("silo")) { + user.setSiloStatus((String)ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("costcenter")) { + user.setCostCenter((String)ie.next()); + } + else if (attribute.getID().equalsIgnoreCase("b2")) { + user.setFinancialLocCode((String)ie.next()); + } + else { //we don't care about returned attribute, let's move on + ie.next(); + } + + } + } + } + } catch (NamingException e) { + String stackTrace = EcompPortalUtils.getStackTrace(e); + logger.error(EELFLoggerDelegate.errorLogger, "An error occurred while processing the following user from POST with an Organization User ID of " + user.getOrgUserId()); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occcurred while processing LDAP search results, Details: " + stackTrace); + } catch(Exception e) { + String stackTrace = EcompPortalUtils.getStackTrace(e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occcurred while processing LDAP search results, Details: " + stackTrace); + } + + return user; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuService.java new file mode 100644 index 00000000..ed9c3c4d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuService.java @@ -0,0 +1,44 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Set; + +import org.openecomp.portalsdk.core.domain.MenuData; +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface EPLeftMenuService { + + /** + * Builds a JSON suitable for populating the front-end left menu from the supplied set of menu items. + * @param user + * + * @param fullMenuSet + * @param roleFunctionSet + * @return JSON String of this form: + *
+	 * {"navItems":[
+	 * 		{"name":"Home","imageSrc":"icon-location-pin","state":"root.applicationsHome"},
+	 * 	...
+	 * ] }
+	 * 
+ */ + String getLeftMenuItems(EPUser user, Set fullMenuSet, Set roleFunctionSet); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuServiceImpl.java new file mode 100644 index 00000000..2a1f466a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLeftMenuServiceImpl.java @@ -0,0 +1,195 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Collection; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.domain.MenuData; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.UserRoles; +//import org.openecomp.portalapp.portal.domain.Menu; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("leftMenuService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog + +public class EPLeftMenuServiceImpl implements EPLeftMenuService { + + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPLeftMenuServiceImpl.class); + + @Autowired + private EPAppService appService; + + /* + * (non-Javadoc) + * + * @see + * org.openecomp.portalapp.portal.service.EPLeftMenuService#getLeftMenuItems + * (java.util.Set) + */ + @Override + public String getLeftMenuItems(EPUser user, Set fullMenuSet, Set roleFunctionSet) { + final Map defaultNavMap = new LinkedHashMap(); + + resetNavMap(defaultNavMap); + + loadDefaultNavMap(defaultNavMap); + + // Handle Account Administrator in a special way; soon this will + // be revised as Account Administrator may become obsolete + try { + if (user != null) { + UserRoles uRoles = appService.getUserProfileNormalized(user); + if (uRoles.getRoles().contains("Account Administrator")) + loadAccAdminNavMap(defaultNavMap); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "getLeftMenuItems: failed to get roles for user " + user.getOrgUserId(), e); + } + + loadNavMapByRole(defaultNavMap, fullMenuSet); + + return convertToSideBarModel(defaultNavMap); + } + + /** + * Clears the map + * + * @param defaultNavMap + */ + private void resetNavMap(Map defaultNavMap) { + defaultNavMap.clear(); + } + + /** + * + * @param defaultNavMap + * @param fullMenuSet + */ + private void loadNavMapByRole(Map defaultNavMap, Set fullMenuSet) { + + class SortOrderComparator implements Comparator { + @Override + public int compare(MenuData e1, MenuData e2) { + return e1.getSortOrder().compareTo(e2.getSortOrder()); + } + } + + SortedSet sortMenuSet = new TreeSet(new SortOrderComparator()); + for (MenuData mn : fullMenuSet) { + sortMenuSet.add(mn); + } + + for (MenuData mn : sortMenuSet) { + JSONObject navItemsDetails = new JSONObject(); + navItemsDetails.put("name", mn.getLabel()); + navItemsDetails.put("state", mn.getAction()); + navItemsDetails.put("imageSrc", mn.getImageSrc()); + defaultNavMap.put(mn.getAction(), navItemsDetails); + } + } + + /** + * + * @param defaultNavMap + * @return + */ + private String convertToSideBarModel(Map defaultNavMap) { + JSONObject sidebarModel = new JSONObject(); + JSONArray navItems = new JSONArray(); + Collection jsonObjs = defaultNavMap.values(); + + for (JSONObject navItemsDetail : jsonObjs) + navItems.put(navItemsDetail); + + sidebarModel.put("label", "ECOMP portal"); + sidebarModel.put("navItems", navItems); + return sidebarModel.toString(); + } + + /** + * Loads default entries for regular user. + * + * @param defaultNavMap + */ + private void loadDefaultNavMap(Map defaultNavMap) { + + JSONObject navItemsDetails1 = new JSONObject(); + navItemsDetails1.put("name", "Home"); + navItemsDetails1.put("state", "root.applicationsHome"); + navItemsDetails1.put("imageSrc", "icon-building-home"); + defaultNavMap.put("root.applicationsHome", navItemsDetails1); + + JSONObject navItemsDetails2 = new JSONObject(); + navItemsDetails2.put("name", "Application Catalog"); + navItemsDetails2.put("state", "root.appCatalog"); + navItemsDetails2.put("imageSrc", "icon-apps-marketplace"); + defaultNavMap.put("root.appCatalog", navItemsDetails2); + + JSONObject navItemsDetails3 = new JSONObject(); + navItemsDetails3.put("name", "Widget Catalog"); + navItemsDetails3.put("state", "root.widgetCatalog"); + navItemsDetails3.put("imageSrc", "icon-apps-marketplace"); + defaultNavMap.put("root.widgetCatalog", navItemsDetails3); + + } + + /** + * Loads default entries for application administrator. + * + * @param defaultNavMap + */ + private void loadAccAdminNavMap(Map defaultNavMap) { + + JSONObject navItemsDetails1 = new JSONObject(); + navItemsDetails1.put("name", "Users"); + navItemsDetails1.put("state", "root.users"); + navItemsDetails1.put("imageSrc", "icon-user"); + defaultNavMap.put("root.users", navItemsDetails1); + + // No more widget onboarding like this: + // + // JSONObject navItemsDetails2 = new JSONObject(); + // navItemsDetails2.put("name", "Widget Onboarding"); + // navItemsDetails2.put("state", "root.widgetOnboarding"); + // navItemsDetails2.put("imageSrc", "icon-add-widget"); + // defaultNavMap.put("root.widgetOnboarding", navItemsDetails2); + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginService.java new file mode 100644 index 00000000..4bdb2009 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginService.java @@ -0,0 +1,70 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.HashMap; + +import org.openecomp.portalapp.command.EPLoginBean; +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface EPLoginService { + + /** + * Calls {@link #findUser(EPLoginBean, String, HashMap, boolean)} with the + * last parameter set to true. + * + * @param bean + * @param menuPropertiesFilename + * @param additionalParams + * @return EPUser object; null on error or if no match. + * @throws Exception + */ + @SuppressWarnings("rawtypes") + EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename, HashMap additionalParams) throws Exception; + + /** + * Searches the fn_user table for a row that matches information in the + * bean. Uses the bean's Organization User ID property if present; if not, uses the bean's + * LoginId property and (optionally, depending on matchPassword parameter) + * loginPwd property. + * + * @param bean + * EPLoginBean + * @param menuPropertiesFileName + * Always ignored + * @param additionalParams + * Used by DataAccessService when updating a matched user object + * @param matchPassword + * If true, the search must match the password + * @return EPUser object; null on error or if no match. + */ + @SuppressWarnings("rawtypes") + EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename, HashMap additionalParams, + boolean matchPassword) throws Exception; + + /** + * Searches the fn_user table for a row with a value in column login_id that + * matches the specified value. + * + * @param loginId + * @return EPUser object; null on error or if no match. + */ + public EPUser findUserWithoutPwd(String loginId); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginServiceImpl.java new file mode 100644 index 00000000..ba202d63 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPLoginServiceImpl.java @@ -0,0 +1,234 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.menu.MenuBuilder; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.service.support.FusionService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.AppUtils; +import org.openecomp.portalapp.command.EPLoginBean; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.util.EPUserUtils; + +@Service("eploginService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class EPLoginServiceImpl extends FusionService implements EPLoginService { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPLoginServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.EPLoginService#findUser(org.openecomp.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap) + */ + @SuppressWarnings("rawtypes") + public EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename, HashMap additionalParams) + throws Exception { + return findUser(bean, menuPropertiesFilename, additionalParams, true); + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.EPLoginService#findUser(org.openecomp.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap, boolean) + */ + @SuppressWarnings("rawtypes") + public EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename_ignored, HashMap additionalParams, + boolean matchPassword) throws Exception { + EPUser user = null; + EPUser userCopy = null; + + if (bean.getOrgUserId() != null) { + user = (EPUser) findUser(bean); + } else { + if (matchPassword) + user = (EPUser) findUser(bean.getLoginId(), bean.getLoginPwd()); + else + user = (EPUser) findUserWithoutPwd(bean.getLoginId()); + } + + // run this command to fetch more information from the lazily loaded + // object + + // This is funny - commenting out the following method call + // 1. What are we doing with the returned values of the following two + // methods? Nothing. + // 2. Use a guest user scenario - user object will be null - clealry, + // NPE. + // 3. A check of if(user !=null) is made AFTER these bogus calls :) - If + // these calls WERE doing anything significat (which they are not), + // shouln't they have been moved inside that if check? + + // user.getEPUserApps(); + + // Comments + // 1. This method is clearly doing more than 'getting roles' - Not a + // good name - + // 2. Also, there is no null check - guest user scenarios will break the + // code with NPE - added the check - Do not want to remove the call + // altogether - not sure how it will effect things. + + if (user != null) { + user.getEPRoles(); + + // raise an error if the portal application is locked and the user + // does not + // have system administrator privileges + if (AppUtils.isApplicationLocked() + && !EPUserUtils.hasRole(user, SystemProperties.getProperty(SystemProperties.SYS_ADMIN_ROLE_ID))) { + bean.setLoginErrorMessage(SystemProperties.MESSAGE_KEY_LOGIN_ERROR_APPLICATION_LOCKED); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUserAdminPrivilegesInfo, user.getLoginId()); + } + + // raise an error if the user is inactive + if (!user.getActive()) { + bean.setLoginErrorMessage(SystemProperties.MESSAGE_KEY_LOGIN_ERROR_USER_INACTIVE); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUserInactiveWarning, user.getLoginId()); + } + + // only login the user if no errors have occurred + if (bean.getLoginErrorMessage() == null) { + + // this will be a snapshot of the user's information as + // retrieved from the database + userCopy = (EPUser) user.clone(); + + // update the last logged in date for the user + user.setLastLoginDate(new Date()); + getDataAccessService().saveDomainObject(user, additionalParams); + + // create the application menu based on the user's privileges + MenuBuilder menuBuilder = new MenuBuilder(); + Set appMenu = menuBuilder.getMenu( + SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_SET_NAME), dataAccessService); + bean.setMenu(appMenu != null ? appMenu : new HashSet()); + Set businessDirectMenu = menuBuilder.getMenu( + SystemProperties.getProperty(SystemProperties.BUSINESS_DIRECT_MENU_SET_NAME), + dataAccessService); + bean.setBusinessDirectMenu(businessDirectMenu != null ? businessDirectMenu : new HashSet()); + + bean.setUser(userCopy); + } + + } else { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUserMissingError, bean.getOrgUserId()); + } + + return bean; + } + + /** + * Searches the fn_user table for a row that matches the specified login_id + * and login_pwd values. + * + * @param loginId + * @param password + * @return EPUser object; null on error or if no match. + */ + private EPUser findUser(String loginId, String password) { + List list = null; + + StringBuffer criteria = new StringBuffer(); + criteria.append(" where login_id = '").append(loginId).append("'").append(" and login_pwd = '").append(password) + .append("'"); + + try { + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "findUser(String) failed on " + loginId, e); + } + + return (list == null || list.size() == 0) ? null : (EPUser) list.get(0); + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.EPLoginService#findUserWithoutPwd(java.lang.String) + */ + @Override + public EPUser findUserWithoutPwd(String loginId) { + List list = null; + + StringBuffer criteria = new StringBuffer(); + criteria.append(" where login_id = '").append(loginId).append("'"); + + try { + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + String message = "findUserWithoutPwd failed on " + loginId; + logger.error(EELFLoggerDelegate.errorLogger, message, e); + } + + return (list == null || list.size() == 0) ? null : (EPUser) list.get(0); + } + + /** + * Searches the fn_user table for a row that matches the value of the bean's + * Organization User ID property. + * + * @param bean + * @return EPUser object; null on error or if no match. + */ + private EPUser findUser(EPLoginBean bean) { + List list = null; + + StringBuffer criteria = new StringBuffer(); + criteria.append(" where orgUserId = '").append(bean.getOrgUserId()).append("'"); + + try { + list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "findUser(EPLoginBean) failed", e); + } + + return (list == null || list.size() == 0) ? null : (EPUser) list.get(0); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleService.java new file mode 100644 index 00000000..32dccbe0 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleService.java @@ -0,0 +1,37 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalsdk.core.domain.RoleFunction; +import org.openecomp.portalapp.portal.domain.EPRole; + + +public interface EPRoleService { + + // Used by ECOMP. Get cached role by two columns used by ECOMP only. app id, and external app role id. + EPRole getRole(Long appId, Long appRoleid); + public void saveRole(EPRole domainRole); + EPRole getAppRole(String roleName, Long appId); + public List getRoleFunctions(); + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleServiceImpl.java new file mode 100644 index 00000000..d7661e9a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/EPRoleServiceImpl.java @@ -0,0 +1,171 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.domain.RoleFunction; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("epRoleService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class EPRoleServiceImpl implements EPRoleService{ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPRoleServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @SuppressWarnings("unchecked") + public List getRoleFunctions() { + //List msgDB = getDataAccessService().getList(Profile.class, null); + return getDataAccessService().getList(RoleFunction.class, null); + } + + @SuppressWarnings("unchecked") + public List getAvailableChildRoles(Long roleId) { + List availableChildRoles = (List)getDataAccessService().getList(EPRole.class,null); + if(roleId==null || roleId==0){ + return availableChildRoles; + } + + EPRole currentRole = (EPRole)getDataAccessService().getDomainObject(EPRole.class,roleId,null); + Set allParentRoles = new TreeSet(); + allParentRoles = getAllParentRolesAsList(currentRole, allParentRoles); + + + Iterator availableChildRolesIterator = availableChildRoles.iterator(); + while (availableChildRolesIterator.hasNext()) { + EPRole role = availableChildRolesIterator.next(); + if(!role.getActive() || allParentRoles.contains(role) || role.getId().equals(roleId)){ + availableChildRolesIterator.remove(); + } + } + return availableChildRoles; + } + + private Set getAllParentRolesAsList(EPRole role, Set allParentRoles) { + Set parentRoles = role.getParentRoles(); + allParentRoles.addAll(parentRoles); + Iterator parentRolesIterator = parentRoles.iterator(); + while (parentRolesIterator.hasNext()) { + getAllParentRolesAsList(parentRolesIterator.next(),allParentRoles); + } + return allParentRoles; + } + + public RoleFunction getRoleFunction(String code) { + return (RoleFunction)getDataAccessService().getDomainObject(RoleFunction.class, code, null); + } + + public void saveRoleFunction(RoleFunction domainRoleFunction) { + getDataAccessService().saveDomainObject(domainRoleFunction, null); + } + + public void deleteRoleFunction(RoleFunction domainRoleFunction) { + getDataAccessService().deleteDomainObject(domainRoleFunction, null); + } + + public EPRole getRole(Long id) { + return (EPRole)getDataAccessService().getDomainObject(EPRole.class, id, null); + } + + // TODO: refactor + private static final String getAppRoleSqlFormat ="SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s"; + + @SuppressWarnings("unchecked") + public EPRole getRole(Long appId, Long appRoleid) { + if(appId == null || appRoleid == null){ + logger.error(EELFLoggerDelegate.errorLogger, String.format("getRole does not support null appId or roleId. appRoleid=%s, appRoleid=%s", appId, appRoleid)); + return null; + } + + String sql = String.format(getAppRoleSqlFormat, appId, appRoleid); + + List roles = (List)dataAccessService.executeSQLQuery(sql, EPRole.class, null); + int resultsCount = roles.size(); + if(resultsCount > 1){ + logger.error(EELFLoggerDelegate.errorLogger, String.format("search by appId=%s, appRoleid=%s should have returned 0 or 1 results. Got %d. This is an internal server error.", appId, appRoleid, resultsCount)); + logger.error(EELFLoggerDelegate.errorLogger, "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); + return roles.get(0); + } else if(resultsCount == 1){ + return roles.get(0); + } + return null; + } + + @SuppressWarnings("unchecked") + public EPRole getAppRole(String roleName, Long appId) { + + final Map params = new HashMap(); + params.put("appId", appId.toString()); + params.put("roleName", roleName); + + List roles = (List)dataAccessService.executeNamedQuery("getAppRoles", params, null); + int resultsCount = roles.size(); + if(resultsCount > 1){ + logger.error(EELFLoggerDelegate.errorLogger, "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar."); + return roles.get(0); + } else if(resultsCount == 1){ + return roles.get(0); + } + return null; + } + + + public void saveRole(EPRole domainRole) { + getDataAccessService().saveDomainObject(domainRole, null); + } + + public void deleteRole(EPRole domainRole) { + getDataAccessService().deleteDomainObject(domainRole, null); + } + + @SuppressWarnings("unchecked") + public List getAvailableRoles() { + return getDataAccessService().getList(EPRole.class, null); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } +} + + diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuService.java new file mode 100644 index 00000000..0fa790c5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuService.java @@ -0,0 +1,58 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.FunctionalMenuItemWithAppID; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItemWithRoles; +import org.openecomp.portalapp.portal.transport.FunctionalMenuRole; + +public interface FunctionalMenuService { + List getFunctionalMenuItems (EPUser user); + // return all active menu items + List getFunctionalMenuItems (); + // return all active menu items. If all is true, return all active and inactive menu items. + List getFunctionalMenuItems(Boolean all); + // return all active Functional menu items for Notification Tree in User Notification . If all is true, return all active menu items. + List getFunctionalMenuItemsForNotificationTree(Boolean all); + List getFunctionalMenuItemsForApp (Integer appId); + List getFunctionalMenuItemsForUser (String orgUserId); + FunctionalMenuItem getFunctionalMenuItemDetails (Integer menuid); + FieldsValidator createFunctionalMenuItem (FunctionalMenuItemWithRoles menuItemJson); + FieldsValidator editFunctionalMenuItem (FunctionalMenuItemWithRoles menuItemJson); + FieldsValidator deleteFunctionalMenuItem (Long menuId); + FieldsValidator regenerateAncestorTable (); + //Methods relevant to favorites + FieldsValidator setFavoriteItem(FavoritesFunctionalMenuItem menuItemJson); + List getFavoriteItems(Long userId); + FieldsValidator removeFavoriteItem (Long userId, Long menuId); + List transformFunctionalMenuItemWithAppIDToFunctionalMenuItem(List functionalMenuItemWithAppIDList); + List getFunctionalMenuRole(); + //Assign URLs under Help Menu + void assignHelpURLs(List menuItems); + List getUserAppRolesList(String userId); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuServiceImpl.java new file mode 100644 index 00000000..a6a11209 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/FunctionalMenuServiceImpl.java @@ -0,0 +1,963 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.FunctionalMenuItemWithAppID; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; +import org.openecomp.portalapp.portal.transport.FunctionalMenuItemWithRoles; +import org.openecomp.portalapp.portal.transport.FunctionalMenuRole; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("functionalMenuService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class FunctionalMenuServiceImpl implements FunctionalMenuService { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuServiceImpl.class); + + private Long ACCOUNT_ADMIN_ROLE_ID = 999L; + private String RESTRICTED_APP_ROLE_ID = "900"; + + @Autowired + private DataAccessService dataAccessService; + @Autowired + private SessionFactory sessionFactory; + + @PostConstruct + private void init() { + try { + ACCOUNT_ADMIN_ROLE_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ACCOUNT_ADMIN_ROLE_ID)); + RESTRICTED_APP_ROLE_ID = SystemProperties.getProperty(EPCommonSystemProperties.RESTRICTED_APP_ROLE_ID); + } catch(Exception e) { + } + } + + public List getFunctionalMenuItems(EPUser user) { + List menuItems = new ArrayList(); + return menuItems; + } + + public List getFunctionalMenuItems() { + return getFunctionalMenuItems(false); + } + + public List getFunctionalMenuItems(Boolean all) { + // Divide this into 2 queries: one which returns the bottom-level menu items associated with Restricted apps, + // and one that returns all the other menu items. Then we can easily add the boolean flag + // restrictedApp to each FunctionalMenuItem, to be used by the front end. + String activeWhereClause = ""; + if (! all) { + activeWhereClause = " AND UPPER(m.active_yn) = 'Y' "; + } + String sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn, r.app_id " + + "FROM fn_menu_functional m, fn_menu_functional_roles r " + + "WHERE m.menu_id = r.menu_id " + + activeWhereClause //" AND UPPER(m.active_yn) = 'Y' " + + " AND r.role_id != '" + RESTRICTED_APP_ROLE_ID + "' " + + " UNION " + + " SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn,-1 app_id " + + " FROM fn_menu_functional m " + + " WHERE m.url='' " + + activeWhereClause; //" AND UPPER(m.active_yn) = 'Y' "; + logQuery(sql); + + @SuppressWarnings("unchecked") + List menuItemsWithAppIdList = dataAccessService.executeSQLQuery(sql,FunctionalMenuItemWithAppID.class, null); + List menuItems = new ArrayList<>(); + menuItems = transformFunctionalMenuItemWithAppIDToFunctionalMenuItem(menuItemsWithAppIdList); + for (FunctionalMenuItem menuItem : menuItems) { + menuItem.restrictedApp = false; + } + + sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn, r.app_id " + + "FROM fn_menu_functional m, fn_menu_functional_roles r " + + "WHERE m.menu_id = r.menu_id " + + activeWhereClause //" AND UPPER(m.active_yn) = 'Y' " + + " AND r.role_id = '" + RESTRICTED_APP_ROLE_ID + "' "; + logQuery(sql); + @SuppressWarnings("unchecked") + List menuItems2 = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + for (FunctionalMenuItem menuItem : menuItems2) { + menuItem.restrictedApp = true; + menuItems.add(menuItem); + } + + return menuItems; + } + + + public List getFunctionalMenuItemsForNotificationTree(Boolean all) { + // Divide this into 2 queries: one which returns the bottom-level menu items associated with Restricted apps, + // and one that returns all the other menu items which are active. Then we can easily add the boolean flag + // restrictedApp to each FunctionalMenuItem, to be used by the front end. + String activeWhereClause = ""; + if (! all) { + activeWhereClause = " AND UPPER(m.active_yn) = 'Y' "; + } + String sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn, r.app_id " + + "FROM fn_menu_functional m, fn_menu_functional_roles r " + + "WHERE m.menu_id = r.menu_id " + + activeWhereClause + " AND UPPER(m.active_yn) = 'Y' " + + " AND r.role_id != '" + RESTRICTED_APP_ROLE_ID + "' " + + " UNION " + + " SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn,-1 app_id " + + " FROM fn_menu_functional m " + + " WHERE m.url='' " + + activeWhereClause + " AND UPPER(m.active_yn) = 'Y' "; + logQuery(sql); + + @SuppressWarnings("unchecked") + List menuItemsWithAppIdList = dataAccessService.executeSQLQuery(sql,FunctionalMenuItemWithAppID.class, null); + List menuItems = new ArrayList<>(); + menuItems = transformFunctionalMenuItemWithAppIDToFunctionalMenuItem(menuItemsWithAppIdList); + for (FunctionalMenuItem menuItem : menuItems) { + menuItem.restrictedApp = false; + } + + sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn, r.app_id " + + "FROM fn_menu_functional m, fn_menu_functional_roles r " + + "WHERE m.menu_id = r.menu_id " + + activeWhereClause + " AND UPPER(m.active_yn) = 'Y' " + + " AND r.role_id = '" + RESTRICTED_APP_ROLE_ID + "' "; + logQuery(sql); + @SuppressWarnings("unchecked") + List menuItems2 = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + for (FunctionalMenuItem menuItem : menuItems2) { + menuItem.restrictedApp = true; + menuItems.add(menuItem); + } + + return menuItems; + } + + public List getFunctionalMenuItemsForApp(Integer appId) { + String sql = "SELECT DISTINCT m1.menu_id, m1.column_num, m1.text, m1.parent_menu_id, m1.url, m.active_yn " + + " FROM fn_menu_functional m, fn_menu_functional m1, fn_menu_functional_ancestors a, fn_menu_functional_roles mr " + + " WHERE " + " mr.app_id='" + appId + "' " + " AND mr.menu_id = m.menu_id " + " AND UPPER(m.active_yn) = 'Y'" + + " AND UPPER(m1.active_yn) ='Y'" + " AND a.menu_id = m.menu_id " + " AND a.ancestor_menu_id = m1.menu_id"; + logQuery(sql); + logger.debug(EELFLoggerDelegate.debugLogger, "getFunctionalMenuItemsForApp: logged the query"); + + @SuppressWarnings("unchecked") + List menuItems = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + + return menuItems; + } + /** + * convert List of FunctionalMenuItemWithAppID into List of FunctionalMenuItem + * + */ + public List transformFunctionalMenuItemWithAppIDToFunctionalMenuItem(List functionalMenuItemWithAppIDList) { + List functionalMenuItemList = new ArrayList(); + for (FunctionalMenuItemWithAppID functionalMenuItemWithAppID : functionalMenuItemWithAppIDList) { + FunctionalMenuItem menuItem = new FunctionalMenuItem(); + menuItem.menuId=functionalMenuItemWithAppID.menuId; + menuItem.column=functionalMenuItemWithAppID.column; + menuItem.text=functionalMenuItemWithAppID.text; + menuItem.parentMenuId=functionalMenuItemWithAppID.parentMenuId; + menuItem.url=functionalMenuItemWithAppID.url; + menuItem.active_yn=functionalMenuItemWithAppID.active_yn; + menuItem.appid=functionalMenuItemWithAppID.appid; + menuItem.setRoles(functionalMenuItemWithAppID.roles); + menuItem.restrictedApp=functionalMenuItemWithAppID.restrictedApp; + functionalMenuItemList.add(menuItem); + } + return functionalMenuItemList; + } + + public List getFunctionalMenuItemsForUser(String orgUserId) { + // m represents the functional menu items that are the leaf nodes + // m1 represents the functional menu items for all the nodes + + // Divide this into 2 queries: one which returns the bottom-level menu items associated with Restricted apps, + // and one that returns all the other menu items. Then we can easily add the boolean flag + // restrictedApp to each FunctionalMenuItem, to be used by the front end. + String sql = "SELECT DISTINCT m1.menu_id, m1.column_num, m1.text, m1.parent_menu_id, m1.url, m.active_yn " + + " FROM fn_menu_functional m, fn_menu_functional m1, fn_menu_functional_ancestors a, " + + " fn_menu_functional_roles mr, fn_user u , fn_user_role ur " + " WHERE " + " u.org_user_id='" + orgUserId + + "' " + " AND u.user_id = ur.user_id " + " AND ur.app_id = mr.app_id " + + // " AND ur.role_id = mr.role_id " + + " AND (ur.role_id = mr.role_id " + " OR ur.role_id = '" + ACCOUNT_ADMIN_ROLE_ID + "') " + + " AND m.menu_id = mr.menu_id " + " AND UPPER(m.active_yn) = 'Y'" + " AND UPPER(m1.active_yn) ='Y' " + + " AND a.menu_id = m.menu_id " + " AND a.ancestor_menu_id = m1.menu_id " + + " UNION " + // the ancestors of the restricted app menu items + + " select m1.menu_id, m1.column_num, m1.text, m1.parent_menu_id, m1.url, m1.active_yn " + + " FROM fn_menu_functional m, fn_menu_functional_roles mr, fn_menu_functional m1, " + + " fn_menu_functional_ancestors a " + + " where a.menu_id = m.menu_id " + + " AND a.ancestor_menu_id = m1.menu_id " + + " AND m.menu_id != m1.menu_id " + + " AND m.menu_id = mr.menu_id " + + " AND mr.role_id = '" + RESTRICTED_APP_ROLE_ID + "' " + + " AND UPPER(m.active_yn) = 'Y'" + " AND UPPER(m1.active_yn) ='Y' " + // Add the Favorites menu item + + " UNION " + + " SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn " + + " FROM fn_menu_functional m " + + " WHERE m.text in ('Favorites','Get Access','Contact Us','Support','User Guide','Help')"; + + logQuery(sql); + logger.debug(EELFLoggerDelegate.debugLogger, "getFunctionalMenuItemsForUser: logged the query"); + + @SuppressWarnings("unchecked") + List menuItems = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + for (FunctionalMenuItem menuItem : menuItems) { + menuItem.restrictedApp = false; + } + + sql = " SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn " + + " FROM fn_menu_functional m, fn_menu_functional_roles r " + + " WHERE m.menu_id = r.menu_id " + + " AND UPPER(m.active_yn) = 'Y' " + + " AND r.role_id = '" + RESTRICTED_APP_ROLE_ID + "' "; + logQuery(sql); + @SuppressWarnings("unchecked") + List menuItems2 = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + for (FunctionalMenuItem menuItem : menuItems2) { + menuItem.restrictedApp = true; + menuItems.add(menuItem); + } + + return menuItems; + } + + public FunctionalMenuItem getFunctionalMenuItemDetails(Integer menuid) { + // First, fill in the fields that apply to all menu items + + String sql = "SELECT * FROM fn_menu_functional WHERE menu_id = '" + menuid + "'"; + logQuery(sql); + @SuppressWarnings("unchecked") + List menuItems = dataAccessService.executeSQLQuery(sql, FunctionalMenuItem.class, null); + FunctionalMenuItem menuItem = (menuItems == null || menuItems.isEmpty() ? null : menuItems.get(0)); + // If it is a bottom-level menu item, must fill in the appid and the + // roles + sql = "SELECT * FROM fn_menu_functional_roles WHERE menu_id = '" + menuid + "'"; + logQuery(sql); + @SuppressWarnings("unchecked") + List roleItems = dataAccessService.executeSQLQuery(sql, FunctionalMenuRole.class, null); + if (roleItems.size() > 0) { + Integer appid = roleItems.get(0).appId; + menuItem.appid = appid; + List roles = new ArrayList(); + for (FunctionalMenuRole roleItem : roleItems) { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: app_id: " + roleItem.appId + "; role_id: " + roleItem.roleId + "\n"); + roles.add(roleItem.roleId); + } + menuItem.setRoles(roles); + } + + return menuItem; + } + + private FieldsValidator menuItemFieldsChecker(FunctionalMenuItemWithRoles menuItemJson) { + FieldsValidator fieldsValidator = new FieldsValidator(); + try { + // TODO: validate all the fields + @SuppressWarnings("unchecked") + List functionalMenuItems = dataAccessService.getList(FunctionalMenuItem.class, + " where text = '" + menuItemJson.text + "'", null, null); + + boolean dublicatedName = false; + for (FunctionalMenuItem fnMenuItem : functionalMenuItems) { + if (menuItemJson.menuId != null && menuItemJson.menuId.equals(fnMenuItem.menuId)) { + // FunctionalMenuItem should not be compared with itself + continue; + } + + if (!dublicatedName && fnMenuItem.text.equalsIgnoreCase(menuItemJson.text)) { + dublicatedName = true; + break; + } + } + if (dublicatedName) { + fieldsValidator.addProblematicFieldName("text"); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + fieldsValidator.errorCode = new Long(EPCommonSystemProperties.DUBLICATED_FIELD_VALUE_ECOMP_ERROR); + logger.debug(EELFLoggerDelegate.debugLogger, "In menuItemFieldsChecker, Error: we have an duplicate text field"); + } else if (StringUtils.isEmpty(menuItemJson.text) && menuItemJson.menuId == null) { + // text must be non empty for a create. For an edit, can be empty, which means it is a move request. + // a null menuId indicates a create. + fieldsValidator.addProblematicFieldName("text"); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + logger.debug(EELFLoggerDelegate.debugLogger, "In menuItemFieldsChecker, Error: we have an empty text field"); + } else { + // The url, appid, and roles must either be all filled or all empty. + Boolean urlIsEmpty = StringUtils.isEmpty(menuItemJson.url); + Boolean rolesIsEmpty = menuItemJson.getRoles() == null || menuItemJson.getRoles().isEmpty(); + Boolean appidIsEmpty = menuItemJson.appid == null || menuItemJson.appid == 0; + logger.debug(EELFLoggerDelegate.debugLogger, "LR: menuItemfieldsChecker: urlIsEmpty: " + urlIsEmpty + "; rolesIsEmpty: " + rolesIsEmpty + "; appidIsEmpty: " + appidIsEmpty +"\n"); + if (!((urlIsEmpty && rolesIsEmpty && appidIsEmpty) || (!urlIsEmpty && !rolesIsEmpty && !appidIsEmpty))) + { + fieldsValidator.addProblematicFieldName("url,roles,appid"); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + logger.debug(EELFLoggerDelegate.debugLogger, "In menuItemFieldsChecker, Error: we don't have: either all 3 fields empty or all 3 fields nonempty"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "In menuItemFieldsChecker, Success: either all 3 fields empty or all 3 fields nonempty"); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while validating the FunctionalMenuItems. Details: " + EcompPortalUtils.getStackTrace(e)); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return fieldsValidator; + } + + // Turn foreign key checks on or off + protected void setForeignKeys(Session localSession, Boolean on) { + String keyCheck = "0"; + if (on) { + keyCheck = "1"; + } + String sql = "set FOREIGN_KEY_CHECKS="+keyCheck; + logQuery(sql); + Query query = localSession.createSQLQuery(sql); + query.executeUpdate(); + } + + public FieldsValidator createFunctionalMenuItem(FunctionalMenuItemWithRoles menuItemJson) { + FieldsValidator fieldsValidator = menuItemFieldsChecker(menuItemJson); + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: createFunctionalMenuItem: test 1"); + boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + FunctionalMenuItem menuItem = new FunctionalMenuItem(); + menuItem.appid = menuItemJson.appid; + menuItem.setRoles(menuItemJson.getRoles()); + menuItem.url = menuItemJson.url; + menuItem.text = menuItemJson.text; + menuItem.parentMenuId = menuItemJson.parentMenuId; + menuItem.active_yn = "Y"; + localSession = sessionFactory.openSession(); + + // If the app is disabled, deactivate the menu item. + if (menuItemJson.appid != null) { + Long appidLong = Long.valueOf(menuItemJson.appid); + EPApp app = (EPApp) localSession.get(EPApp.class, appidLong); + if (app != null && ! app.getEnabled()) { + menuItem.active_yn = "N"; + } + } + + // Set the column number to 1 higher than the highest column + // number under this parent. + Criteria criteria = localSession.createCriteria(FunctionalMenuItem.class); + criteria.setProjection(Projections.max("column")); + criteria.add(Restrictions.eq("parentMenuId", menuItem.parentMenuId)); + Integer maxColumn = (Integer) criteria.uniqueResult(); + if (maxColumn == null) { + maxColumn = 0; + } + menuItem.column = maxColumn + 1; + logger.debug(EELFLoggerDelegate.debugLogger, "about to create menu item: " + menuItem.toString()); + + transaction = localSession.beginTransaction(); + // localSession.saveOrUpdate(newMenuItem); + localSession.save(menuItem); + Long menuid = menuItem.menuId; + menuItemJson.menuId = menuid; + logger.debug(EELFLoggerDelegate.debugLogger, "after saving menu object, new id: " + menuid); + + // Next, save all the roles + + addRoles(menuItemJson, localSession); + transaction.commit(); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "createFunctionalMenuItem rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "createFunctionalMenuItem"); + } + if (result) { + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: createFunctionalMenuItem: no result. setting httpStatusCode to " + + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } else { + logger.error(EELFLoggerDelegate.errorLogger, "FunctionalMenuServiceImpl.createFunctionalMenuItem: bad request"); + } + return fieldsValidator; + } + + /* Add all the roles in the menu item to the database */ + public void addRoles(FunctionalMenuItemWithRoles menuItemJson, Session localSession) { + logger.debug(EELFLoggerDelegate.debugLogger, "entering addRoles."); + List roles = menuItemJson.getRoles(); + if (roles != null && roles.size() > 0) { + Integer appid = menuItemJson.appid; + Long menuid = menuItemJson.menuId; + for (Integer roleid : roles) { + logger.debug(EELFLoggerDelegate.debugLogger, "about to create record for role: " + roleid); + FunctionalMenuRole role = new FunctionalMenuRole(); + role.appId = appid; + role.menuId = menuid; + role.roleId = roleid; + localSession.save(role); + logger.debug(EELFLoggerDelegate.debugLogger, "after saving role menu object, new id: " + role.id); + } + } + } + + /* Delete all the roles associated with the menu item from the database */ + public void deleteRoles(Long menuId) { + dataAccessService.deleteDomainObjects(FunctionalMenuRole.class, "menu_id='" + menuId + "'", null); + } + + /* Delete all favorites associated with the menu item from the database */ + public void deleteFavorites(Long menuId) { + dataAccessService.deleteDomainObjects(FavoritesFunctionalMenuItem.class, "menu_id='" + menuId + "'", null); + } + + private Boolean parentMenuIdEqual(Integer menuId1, Integer menuId2) { + return ((menuId1 == null && menuId2 == null) || (menuId1 != null && menuId1.equals(menuId2))); + } + + private void updateColumnForSiblings(Session localSession, Long menuId, Integer oldParentMenuId, + Integer newParentMenuId, Integer oldColumn, Integer newColumn) { + logger.debug(EELFLoggerDelegate.debugLogger, "entering updateColumnForSiblings"); + Criteria criteria = localSession.createCriteria(FunctionalMenuItem.class); + criteria.add(Restrictions.ne("menuId", menuId)); + if (parentMenuIdEqual(oldParentMenuId, newParentMenuId)) { + logger.debug(EELFLoggerDelegate.debugLogger, "moving under the same parent"); + // We are moving to a new position under the same parent + if (newParentMenuId == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "newParentMenuId is null, so using isNull"); + criteria.add(Restrictions.isNull("parentMenuId")); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "newParentMenuId is NOT null, so using eq"); + criteria.add(Restrictions.eq("parentMenuId", newParentMenuId)); + } + if (oldColumn > newColumn) { + logger.debug(EELFLoggerDelegate.debugLogger, "moving to a lower column under the same parent"); + // We are moving to a lower column under the same parent + criteria.add(Restrictions.ge("column", newColumn)); + criteria.add(Restrictions.lt("column", oldColumn)); + @SuppressWarnings("unchecked") + List menuItems = criteria.list(); + for (FunctionalMenuItem menuItem : menuItems) { + menuItem.column += 1; + localSession.save(menuItem); + } + } else if (oldColumn < newColumn) { + logger.debug(EELFLoggerDelegate.debugLogger, "moving to a higher column under the same parent"); + // We are moving to a higher column under the same parent + criteria.add(Restrictions.gt("column", oldColumn)); + criteria.add(Restrictions.le("column", newColumn)); + @SuppressWarnings("unchecked") + List menuItems = criteria.list(); + for (FunctionalMenuItem menuItem : menuItems) { + menuItem.column -= 1; + localSession.save(menuItem); + } + } else { + // No info has changed + logger.debug(EELFLoggerDelegate.debugLogger, "no info has changed, so we are not moving"); + } + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "moving under a new parent"); + // We are moving under a new parent. + + // Adjust the children under the old parent + logger.debug(EELFLoggerDelegate.debugLogger, "about to adjust the children under the old parent"); + + // If the parentId is null, must check for its children differently + if (oldParentMenuId == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "oldParentMenuId is null, so using isNull"); + criteria.add(Restrictions.isNull("parentMenuId")); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "oldParentMenuId is NOT null, so using eq"); + criteria.add(Restrictions.eq("parentMenuId", oldParentMenuId)); + } + + criteria.add(Restrictions.gt("column", oldColumn)); + @SuppressWarnings("unchecked") + List menuItems1 = criteria.list(); + for (FunctionalMenuItem menuItem : menuItems1) { + menuItem.column -= 1; + localSession.save(menuItem); + } + // Adjust the children under the new parent. + logger.debug(EELFLoggerDelegate.debugLogger, "about to adjust the children under the new parent"); + logger.debug(EELFLoggerDelegate.debugLogger, "get all menu items where menuId!=" + menuId + "; parentMenuId==" + newParentMenuId + + "; column>=" + newColumn); + criteria = localSession.createCriteria(FunctionalMenuItem.class); + criteria.add(Restrictions.ne("menuId", menuId)); + if (newParentMenuId == null) { + logger.debug(EELFLoggerDelegate.debugLogger, "newParentMenuId is null, so using isNull"); + criteria.add(Restrictions.isNull("parentMenuId")); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "newParentMenuId is NOT null, so using eq"); + criteria.add(Restrictions.eq("parentMenuId", newParentMenuId)); + } + + criteria.add(Restrictions.ge("column", newColumn)); + @SuppressWarnings("unchecked") + List menuItems2 = criteria.list(); + if (menuItems2 != null) { + logger.debug(EELFLoggerDelegate.debugLogger, "found " + menuItems2.size() + " menu items"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "found null menu items"); + } + for (FunctionalMenuItem menuItem : menuItems2) { + menuItem.column += 1; + localSession.save(menuItem); + } + } + logger.debug(EELFLoggerDelegate.debugLogger, "done with updateColumnForSiblings"); + } + + public void removeAppInfo(Session localSession, Long menuId) { + // Remove the url, role, and app info from a menu item + FunctionalMenuItem menuItem = (FunctionalMenuItem) localSession.get(FunctionalMenuItem.class, menuId); + menuItem.url = ""; + deleteRoles(menuId); + } + + public FieldsValidator editFunctionalMenuItem(FunctionalMenuItemWithRoles menuItemJson) { + boolean result = false; + Session localSession = null; + Transaction transaction = null; + Long menuId = menuItemJson.menuId; + + logger.debug(EELFLoggerDelegate.debugLogger, "LR: editFunctionalMenuItem: test 1"); + FieldsValidator fieldsValidator = menuItemFieldsChecker(menuItemJson); + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + // TODO: make sure menuId is here. And, it might not already exist + // in db table. + if (menuId == null) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + logger.error(EELFLoggerDelegate.errorLogger, "FunctionalMenuServiceImpl.editFunctionalMenuItem: bad request"); + } else { + // To simplify the code, assume we will have a transaction + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + + // Get the existing info associated with menuItem from the DB + FunctionalMenuItem menuItem = (FunctionalMenuItem) localSession.get(FunctionalMenuItem.class, menuId); + Integer oldColumn = menuItem.column; + Integer oldParentMenuId = menuItem.parentMenuId; + Integer newColumn = menuItemJson.column; + Integer newParentMenuId = menuItemJson.parentMenuId; + + logger.debug(EELFLoggerDelegate.debugLogger, "prev info: column: " + oldColumn + "; parentMenuId: " + oldParentMenuId); + + if (menuItemJson.appid != null && menuItemJson.getRoles() != null && !menuItemJson.getRoles().isEmpty() + && menuItemJson.url != null && !menuItemJson.url.isEmpty() && menuItemJson.text != null + && !menuItemJson.text.isEmpty()) { + // Scenario: appid, roles, url and text are all non-null. + // This menu item is associated with an app. + // (Note: this should only occur for a bottom-level menu + // item with no children.) + // 1) Remove all the records from fn_menu_functional_role + // for this menuId. + // 2) Add records to the fn_menu_function_role table for the + // appId and each roleId + // 3) Update the url and text for this menu item. + + // Because of foreign key constraints, delete the roles, + // then update the menuItem then add the roles. + deleteRoles(menuId); + // Assumption: this is not a Move, so don't change the + // parentMenuId and column. + menuItem.appid = menuItemJson.appid; + menuItem.setRoles(menuItemJson.getRoles()); + menuItem.url = menuItemJson.url; + menuItem.text = menuItemJson.text; + + // If the app is disabled, deactivate the menu item. + Long appidLong = Long.valueOf(menuItemJson.appid); + EPApp app = (EPApp) localSession.get(EPApp.class, appidLong); + if (app != null && ! app.getEnabled()) { + menuItem.active_yn = "N"; + } else { + menuItem.active_yn = "Y"; + } + + + localSession.update(menuItem); + addRoles(menuItemJson, localSession); + + } else if (menuItemJson.appid == null && (menuItemJson.getRoles() == null || menuItemJson.getRoles().isEmpty()) + && (menuItemJson.url == null || menuItemJson.url.isEmpty()) && menuItemJson.text != null + && !menuItemJson.text.isEmpty()) { + // Scenario: appid, roles and url are all null; text is + // non-null. + // This menu item is NOT associated with an app. + // 1) Remove all the records from fn_menu_functional_role + // for this menuId + // (in case it was previously associated with an app). + // 2) Update the text for this menu item. + // 3) Set the url to "" + deleteRoles(menuId); + // Assumption: this is not a Move, so don't change the + // parentMenuId and column. + menuItem.text = menuItemJson.text; + menuItem.url = ""; + menuItem.active_yn = "Y"; + localSession.update(menuItem); + + } else if (newColumn != null) { + // This is a "move" request. + // Menu item has been moved to a different position under + // the same parent, or under a new parent. + logger.debug(EELFLoggerDelegate.debugLogger, "Doing a move operation."); + if (parentMenuIdEqual(oldParentMenuId, newParentMenuId)) { + // The parent is the same. We have just changed the + // column + logger.debug(EELFLoggerDelegate.debugLogger, "moving under the same parent"); + menuItem.column = newColumn; + localSession.update(menuItem); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "moving under a different parent"); + menuItem.parentMenuId = newParentMenuId; + menuItem.column = newColumn; + localSession.update(menuItem); + // If we are moving under a new parent, must delete any + // app/role info from + // the new parent, since it is no longer a leaf menu + // item and cannot have app info + // associated with it. The front end will have warned + // the user and gotten confirmation. + if (menuItemJson.parentMenuId != null) { + Long parentMenuIdLong = new Long(menuItemJson.parentMenuId); + removeAppInfo(localSession, parentMenuIdLong); + // deleteRoles(parentMenuIdLong); + } + } + // must update the column for all old and new sibling menu + // items + updateColumnForSiblings(localSession, menuId, oldParentMenuId, newParentMenuId, oldColumn, + newColumn); + } + + transaction.commit(); + logger.debug(EELFLoggerDelegate.debugLogger, "LR: editFunctionalMenuItem: finished committing transaction"); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "createFunctionalMenuItem rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "editFunctionalMenuItem"); + } + + if (result) { + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: createFunctionalMenuItem: no result. setting httpStatusCode to " + + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + } + + return fieldsValidator; + } + + public FieldsValidator deleteFunctionalMenuItem(Long menuId) { + FieldsValidator fieldsValidator = new FieldsValidator(); + logger.debug(EELFLoggerDelegate.debugLogger, "LR: deleteFunctionalMenuItem: test 1"); + boolean result = false; + Session localSession = null; + Transaction transaction = null; + + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + // We must turn off foreign keys before deleting a menu item. Otherwise there will be a + // constraint violation from the ancestors table. + setForeignKeys(localSession, false); + deleteRoles(menuId); + logger.debug(EELFLoggerDelegate.debugLogger, "deleteFunctionalMenuItem: after deleting roles"); + deleteFavorites(menuId); + logger.debug(EELFLoggerDelegate.debugLogger, "deleteFunctionalMenuItem: after deleting favorites"); + localSession.delete(localSession.get(FunctionalMenuItem.class, menuId)); + logger.debug(EELFLoggerDelegate.debugLogger, "deleteFunctionalMenuItem: about to commit"); + transaction.commit(); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "deleteFunctionalMenuItem rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "deleteFunctionalMenuItem"); + } + if (result) { + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: deleteFunctionalMenuItem: no result. setting httpStatusCode to " + + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + // Regenerate the fn_menu_functional_ancestors table, which is used + // by the queries that return the functional menu items. + public FieldsValidator regenerateAncestorTable() { + FieldsValidator fieldsValidator = new FieldsValidator(); + Session localSession = null; + Transaction transaction = null; + + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + String sql = "DELETE FROM fn_menu_functional_ancestors"; + logQuery(sql); + Query query = localSession.createSQLQuery(sql); + query.executeUpdate(); + logger.debug(EELFLoggerDelegate.debugLogger, "regenerateAncestorTable: finished query 1"); + + sql = "ALTER TABLE fn_menu_functional_ancestors AUTO_INCREMENT=1"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + logger.debug(EELFLoggerDelegate.debugLogger, "regenerateAncestorTable: reset AUTO_INCREMENT to 1"); + + int depth = 0; + sql = "INSERT INTO fn_menu_functional_ancestors(menu_id, ancestor_menu_id, depth) " + + "SELECT m.menu_id, m.menu_id, " + depth + " FROM fn_menu_functional m"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + logger.debug(EELFLoggerDelegate.debugLogger, "regenerateAncestorTable: finished query 2"); + for (depth = 0; depth < 3; depth++) { + int depthPlusOne = depth + 1; + sql = "INSERT INTO fn_menu_functional_ancestors(menu_id, ancestor_menu_id, depth) " + + " SELECT a.menu_id, m.parent_menu_id, " + depthPlusOne + + " FROM fn_menu_functional m, fn_menu_functional_ancestors a " + " WHERE a.depth='" + depth + + "' AND " + " a.ancestor_menu_id = m.menu_id AND " + " m.parent_menu_id != '-1'"; + logQuery(sql); + query = localSession.createSQLQuery(sql); + query.executeUpdate(); + } + logger.debug(EELFLoggerDelegate.debugLogger, "regenerateAncestorTable: finished query 3"); + transaction.commit(); + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "regenerateAncestorTable rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "regenerateAncestorTable"); + } + return fieldsValidator; + } + + private void logQuery(String sql) { + logger.debug(EELFLoggerDelegate.debugLogger, "Executing query: " + sql); + } + + public FieldsValidator setFavoriteItem(FavoritesFunctionalMenuItem menuItemJson) { + boolean result = false; + FieldsValidator fieldsValidator = new FieldsValidator(); + + Session localSession = null; + Transaction transaction = null; + + try { + logger.debug(EELFLoggerDelegate.debugLogger, String.format("Before adding favorite for user id:{0} and menu id:{1} ",menuItemJson.userId,menuItemJson.menuId)); + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + localSession.save(menuItemJson); + transaction.commit(); + result = true; + logger.debug(EELFLoggerDelegate.debugLogger, String.format("After adding favorite for user id:{0} and menu id:{1} ",menuItemJson.userId,menuItemJson.menuId)); + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction,"setFavoriteItem rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "setFavoriteItem"); + } + + if(result) { + } + else { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return fieldsValidator; + } + + public List getFavoriteItems(Long userId) { + try { + logger.debug(EELFLoggerDelegate.debugLogger, "Before getting favorites for user id: " + userId); + + // Divide this into 2 queries: one which returns the favorites items associated with Restricted apps, + // and one that returns all the other favorites items. Then we can easily add the boolean flag + // restrictedApp to each FavoritesFunctionalMenuItemJson, to be used by the front end. + + String sql = "SELECT f.user_id,f.menu_id,m.text,m.url " + + " FROM fn_menu_favorites f, fn_menu_functional m, fn_menu_functional_roles mr " + + " WHERE f.user_id='" + userId + "' AND f.menu_id = m.menu_id " + + " AND f.menu_id = mr.menu_id " + + " AND mr.role_id = '" + RESTRICTED_APP_ROLE_ID + "' "; + + @SuppressWarnings("unchecked") + List menuItems = dataAccessService.executeSQLQuery(sql, FavoritesFunctionalMenuItemJson.class, null); + for (FavoritesFunctionalMenuItemJson menuItem : menuItems) { + menuItem.restrictedApp = true; + } + + sql = "SELECT DISTINCT f.user_id,f.menu_id,m.text,m.url " + + " FROM fn_menu_favorites f, fn_menu_functional m, fn_menu_functional_roles mr " + + " WHERE f.user_id='" + userId + "' AND f.menu_id = m.menu_id " + + " AND f.menu_id = mr.menu_id " + + " AND mr.role_id != '" + RESTRICTED_APP_ROLE_ID + "' "; + @SuppressWarnings("unchecked") + List menuItems2 = dataAccessService.executeSQLQuery(sql, FavoritesFunctionalMenuItemJson.class, null); + for (FavoritesFunctionalMenuItemJson menuItem : menuItems2) { + menuItem.restrictedApp = false; + menuItems.add(menuItem); + } + + return menuItems; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in FunctionalMenuServiceImpl.getFavoriteItems. Details: " + EcompPortalUtils.getStackTrace(e)); + List menuItems = new ArrayList(); + return menuItems; + } + } + + public FieldsValidator removeFavoriteItem(Long userId, Long menuId) { + boolean result = false; + FieldsValidator fieldsValidator = new FieldsValidator(); + + Session localSession = null; + Transaction transaction = null; + + try { + + FavoritesFunctionalMenuItem menuItemJson = new FavoritesFunctionalMenuItem(); + menuItemJson.userId = userId; + menuItemJson.menuId = menuId; + + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + localSession.delete(menuItemJson); + localSession.flush(); + transaction.commit(); + result = true; + logger.debug(EELFLoggerDelegate.debugLogger, String.format("After removing favorite for user id: " + userId + "; menu id: " + menuId)); + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction,"removeFavoriteItem rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "removeFavoriteItem"); + } + + if(result) { + } + else { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return fieldsValidator; + } + + @Override + public void assignHelpURLs(List menuItems) { + try { + String user_guide_link = SystemProperties.getProperty(EPCommonSystemProperties.USER_GUIDE_URL); + + for(FunctionalMenuItem menuItem: menuItems){ + if(menuItem.text.equalsIgnoreCase("Contact Us")){ + menuItem.setUrl("contactUs"); + //menuItem.setRestrictedApp(true); + } + if(menuItem.text.equalsIgnoreCase("Get Access")) { + menuItem.setUrl("getAccess"); + } + if(menuItem.text.equalsIgnoreCase("User Guide")) { + menuItem.setUrl(user_guide_link); + menuItem.setRestrictedApp(true); + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "assignHelpURLs process failed. Details: " + EcompPortalUtils.getStackTrace(e)); + } + + } + + public List getFunctionalMenuRole() { + String sql = "SELECT * from fn_menu_functional_roles"; + logQuery(sql); + logger.debug(EELFLoggerDelegate.debugLogger, "getFunctionalMenuRole: logged the query"); + + @SuppressWarnings("unchecked") + List functionalMenuRole = dataAccessService.executeSQLQuery(sql, FunctionalMenuRole.class, null); + + return functionalMenuRole; + } + + @SuppressWarnings("unchecked") + @Override + public List getUserAppRolesList(String userId) { + Map params = new HashMap<>(); + params.put("userId", userId); + + List userAppRoles = null; + try { + userAppRoles = dataAccessService + .executeNamedQuery("getUserApproles", params, null); + } catch (Exception e) { + // TODO Auto-generated catch block + logger.error(EELFLoggerDelegate.errorLogger, "getUserAppRolesList failed", e); + } + return userAppRoles; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessService.java new file mode 100644 index 00000000..8b5e72e5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessService.java @@ -0,0 +1,33 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.GetAccessResult; + +public interface GetAccessService { + /** + * @return One entry per application function AND role; i.e., each application + * appears many times. + */ + List getAppAccessList(EPUser user); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessServiceImpl.java new file mode 100644 index 00000000..37af1dab --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/GetAccessServiceImpl.java @@ -0,0 +1,61 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.GetAccessResult; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("getAccessService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class GetAccessServiceImpl implements GetAccessService{ + + @Autowired + private DataAccessService dataAccessService; + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.GetAccessService#getAppAccessList() + */ + @SuppressWarnings("unchecked") + @Override + public List getAppAccessList(EPUser user) { + final Map params = new HashMap<>(); + List appAccessList = null; + params.put("userId", user.getId()); + appAccessList = dataAccessService + .executeNamedQuery("getAppAccessFunctionRole", params, null); + return appAccessList; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestService.java new file mode 100644 index 00000000..7a10568d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestService.java @@ -0,0 +1,33 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.io.IOException; +import java.util.jar.Attributes; + +public interface ManifestService { + /** + * Gets the content of the webapp manifest file META-INF/MANIFEST.MF. + * + * @return Attributes object with key-value pairs from the manifest + * @throws IOException + */ + public Attributes getWebappManifest() throws IOException; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestServiceImpl.java new file mode 100644 index 00000000..3d0f34a2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ManifestServiceImpl.java @@ -0,0 +1,62 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +import javax.servlet.ServletContext; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("manifestService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class ManifestServiceImpl implements ManifestService { + @Autowired + ServletContext context; + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.ManifestService#getWebappManifest() + */ + public Attributes getWebappManifest() throws IOException { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestServiceImpl.class); + // Path to resource on classpath + final String MANIFEST_RESOURCE_PATH = "/META-INF/MANIFEST.MF"; + // Manifest is formatted as Java-style properties + try { + InputStream inputStream = context.getResourceAsStream(MANIFEST_RESOURCE_PATH); + Manifest manifest = new Manifest(inputStream); + inputStream.close(); + return manifest.getMainAttributes(); + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "getWebappManifest: failed to read/find manifest"); + throw e; + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyService.java new file mode 100644 index 00000000..00fc9ad8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyService.java @@ -0,0 +1,59 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.springframework.web.client.RestClientException; + +public interface MicroserviceProxyService { + + /** + * Gets the specific microservice from table ep_microservice, communicates + * to microservice with the specified security type. The microservice sends + * back the response. + * + * Gets the data while testing the microservice with no widget associated with + * + * @param serviceId + * Id of microservice to be used + * @return response sent from microservice + * @throws Exception + */ + String proxyToDestination(long serviceId, EPUser user, HttpServletRequest request) throws Exception; + + + + /** + * Gets the microservice data based on the user id and widget id. Different + * users have his/her own parameters for one widget. The method sends back + * the response. + * + * @param widgetId + * Id of widget to be used + * @param user + * User information + * @param request + * @return response sent from microserivce + * @throws Exception + */ + String proxyToDestinationByWidgetId(long widgetId, EPUser user, HttpServletRequest request) throws Exception; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java new file mode 100644 index 00000000..3a520c88 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java @@ -0,0 +1,222 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.codec.binary.Base64; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.MicroserviceParameter; +import org.openecomp.portalapp.portal.domain.WidgetCatalog; +import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter; +import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestTemplate; + +@Service("microserviceProxyService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MicroserviceProxyServiceImpl.class); + private static final String BASIC_AUTH = "Basic Authentication"; + private static final String NO_AUTH = "No Authentication"; + private static final String COOKIE_AUTH = "Cookie based Authentication"; + private static final String QUESTION_MARK = "?"; + private static final String ADD_MARK = "&"; + + String whatService = "widgets-service"; + + @Autowired + private ConsulHealthService consulHealthService; + + @Autowired + MicroserviceService microserviceService; + + @Autowired + WidgetParameterService widgetParameterService; + + RestTemplate template = new RestTemplate(); + + @Override + public String proxyToDestination(long serviceId, EPUser user, HttpServletRequest request) throws Exception { + + String response = null; + + // get the microservice object by the id + MicroserviceData data = microserviceService.getMicroserviceDataById(serviceId); + + // No such microservice available + if (data == null) { + return response; + } + List params = data.getParameterList(); + if (data.getSecurityType().equals(NO_AUTH)) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + + } else if (data.getSecurityType().equals(BASIC_AUTH)) { + // encoding the username and password + String plainCreds = data.getUsername() + ":" + decryptedPassword(data.getPassword()); + byte[] plainCredsBytes = plainCreds.getBytes(); + byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); + String base64Creds = new String(base64CredsBytes); + + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Basic " + base64Creds); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + } else if (data.getSecurityType().equals(COOKIE_AUTH)) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + String rawCookie = request.getHeader("Cookie"); + headers.add("Cookie", rawCookie); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + } + return response; + } + + @Override + public String proxyToDestinationByWidgetId(long widgetId, EPUser user, HttpServletRequest request) throws Exception { + + String response = null; + + ResponseEntity ans = (ResponseEntity) template.exchange( + "https://" + consulHealthService.getServiceLocation(whatService) + + "/widget/microservices/widgetCatalog/parameters/" + widgetId, + HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class); + Long serviceId = ans.getBody(); + + // get the microservice object by the id + MicroserviceData data = microserviceService.getMicroserviceDataById(serviceId); + + // No such microservice available + if (data == null) { + return response; + } + + List params = data.getParameterList(); + + for (MicroserviceParameter p : params) { + WidgetCatalogParameter userValue = widgetParameterService.getUserParamById(widgetId, user.getId(), p.getId()); + if (userValue != null) + p.setPara_value(userValue.getUser_value()); + } + + if (data.getSecurityType().equals(NO_AUTH)) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + try { + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + } catch (HttpClientErrorException e) { + throw e; + } + } else if (data.getSecurityType().equals(BASIC_AUTH)) { + // encoding the username and password + String plainCreds = data.getUsername() + ":" + decryptedPassword(data.getPassword()); + byte[] plainCredsBytes = plainCreds.getBytes(); + byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); + String base64Creds = new String(base64CredsBytes); + + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Basic " + base64Creds); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + try { + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + } catch (HttpClientErrorException e) { + throw e; + } + } else if (data.getSecurityType().equals(COOKIE_AUTH)) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + String rawCookie = request.getHeader("Cookie"); + headers.add("Cookie", rawCookie); + HttpEntity entity = new HttpEntity(headers); + + String url = microserviceUrlConverter(data, params); + try { + response = template.exchange(url, HttpMethod.GET, entity, String.class).getBody(); + } catch (HttpClientErrorException e) { + throw e; + } + } + return response; + } + + private String decryptedPassword(String encryptedPwd) throws Exception { + String result = ""; + if (encryptedPwd != null & encryptedPwd.length() > 0) { + try { + result = CipherUtil.decrypt(encryptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); + throw e; + } + } + return result; + } + + private String microserviceUrlConverter(MicroserviceData data, List params) { + String url = data.getUrl(); + for (int i = 0; i < params.size(); i++) { + if (i == 0) { + url += QUESTION_MARK; + } + url += params.get(i).getPara_key() + "=" + params.get(i).getPara_value(); + if (i != (params.size() - 1)) { + url += ADD_MARK; + } + } + return url; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceService.java new file mode 100644 index 00000000..cfc7ddb1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceService.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.MicroserviceParameter; + +public interface MicroserviceService { + + /** + * Get all microservices from the ep_microservice + * + * @return list of all microservices + * @throws Exception + */ + List getMicroserviceData() throws Exception; + + /** + * Gets the specified microservice with id from ep_microservice + * + * @param id + * ID of microservice to be fetched + * @return the microservice with the specified id + */ + MicroserviceData getMicroserviceDataById(long id); + + /** + * Saves the specified microservice to the table ep_microservice + * + * @param newService + * Content of microservice to be saved + * @return new microservice id + * @throws Exception + */ + Long saveMicroservice(MicroserviceData newService) throws Exception; + + void saveServiceParameters(long serviceId, List list) throws Exception; + + /** + * Deletes the specified microservice from all tables where the serviceId is + * used + * + * @param serviceId + * @throws Exception + */ + void deleteMicroservice(long serviceId) throws Exception; + + /** + * Updates the specified microservice from all tables where the serviceId is + * used + * + * @param serviceId + * Id of microservice to be updated + * @param newService + * Content of microservice to be updated + * @throws Exception + */ + void updateMicroservice(long serviceId, MicroserviceData newService) throws Exception; + + /** + * Gets the Service parameters by the service Id + * @param serviceId + * @return + */ + List getParametersById(long serviceId); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java new file mode 100644 index 00000000..c0a2fa41 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java @@ -0,0 +1,212 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.openecomp.portalapp.portal.domain.BasicAuthCredentials; +import org.openecomp.portalapp.portal.domain.EPUserAppRolesRequestDetail; +import org.openecomp.portalapp.portal.domain.MicroserviceData; +import org.openecomp.portalapp.portal.domain.MicroserviceParameter; +import org.openecomp.portalapp.portal.domain.WidgetCatalog; +import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders; +import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +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.context.annotation.EnableAspectJAutoProxy; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service("microserviceService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class MicroserviceServiceImpl implements MicroserviceService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MicroserviceServiceImpl.class); + + + @Autowired + private DataAccessService dataAccessService; + + @Autowired + private SessionFactory sessionFactory; + + public Long saveMicroservice(MicroserviceData newService) throws Exception { + if (newService.getPassword() != null) + newService.setPassword(encryptedPassword(newService.getPassword())); + getDataAccessService().saveDomainObject(newService, null); + return newService.getId(); + } + + public void saveServiceParameters(long serviceId, List list) throws Exception { + for (int i = 0; i < list.size(); i++) { + MicroserviceParameter para = list.get(i); + para.setServiceId(serviceId); + getDataAccessService().saveDomainObject(para, null); + } + } + + @Override + public MicroserviceData getMicroserviceDataById(long id) { + MicroserviceData data = null; + try { + data = (MicroserviceData) dataAccessService + .getList(MicroserviceData.class, " where id = '" + id + "'", null, null).get(0); + data.setParameterList(getServiceParameters(id)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getMicroserviceDataById failed", e); + throw e; + } + return data; + } + + @SuppressWarnings("unchecked") + @Override + public List getMicroserviceData() throws Exception { + List list = (List) dataAccessService.getList(MicroserviceData.class, null); + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getPassword() != null) + list.get(i).setPassword(decryptedPassword(list.get(i).getPassword())); + list.get(i).setParameterList(getServiceParameters(list.get(i).getId())); + } + return list; + } + + @SuppressWarnings("unchecked") + private List getServiceParameters(long serviceId) { + List list = (List) dataAccessService + .getList(MicroserviceParameter.class, " where service_id = '" + serviceId + "'", null, null); + return list; + } + + @Override + public void deleteMicroservice(long serviceId) throws Exception { + + try { + Map params = new HashMap(); + params.put("serviceId", Long.toString(serviceId)); + + dataAccessService.executeNamedQuery("deleteMicroserviceParameter", params, null); + dataAccessService.executeNamedQuery("deleteMicroservice", params, null); + + } catch (Exception e) { + e.printStackTrace(); + logger.error(EELFLoggerDelegate.errorLogger, "deleteMicroservice failed", e); + throw e; + } + } + + @SuppressWarnings("unchecked") + @Override + public void updateMicroservice(long serviceId, MicroserviceData newService) throws Exception { + try { + newService.setId(serviceId); + if (newService.getPassword() != null) + newService.setPassword(encryptedPassword(newService.getPassword())); + getDataAccessService().saveDomainObject(newService, null); + List oldService = getServiceParameters(serviceId); + boolean foundParam; + for (int i = 0; i < oldService.size(); i++) { + foundParam = false; + for (int n = 0; n < newService.getParameterList().size(); n++) { + if (newService.getParameterList().get(n).getId() == oldService.get(i).getId()) { + foundParam = true; + break; + } + } + if (foundParam == false) { + MicroserviceParameter pd = oldService.get(i); + Session localSession = sessionFactory.openSession(); + localSession.delete(pd); + localSession.flush(); + localSession.clear(); + } + + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateMicroservice failed", e); + throw e; + } + saveServiceParameters(serviceId, newService.getParameterList()); + } + + @Override + @SuppressWarnings("unchecked") + public List getParametersById(long serviceId) { + List restrictionsList = new ArrayList(); + Criterion contextIdCrit = Restrictions.eq("serviceId", serviceId); + restrictionsList.add(contextIdCrit); + List list = (List) dataAccessService + .getList(MicroserviceParameter.class, null, restrictionsList, null); + logger.debug(EELFLoggerDelegate.debugLogger, + "getParametersById: microservice parameters list size: " + list.size()); + return list; + } + + private String decryptedPassword(String encryptedPwd) throws Exception { + String result = ""; + if (encryptedPwd != null & encryptedPwd.length() > 0) { + try { + result = CipherUtil.decrypt(encryptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); + throw e; + } + } + return result; + } + + private String encryptedPassword(String decryptedPwd) throws Exception { + String result = ""; + if (decryptedPwd != null & decryptedPwd.length() > 0) { + try { + result = CipherUtil.encrypt(decryptedPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed", e); + throw e; + } + } + return result; + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppService.java new file mode 100644 index 00000000..7874fa74 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppService.java @@ -0,0 +1,42 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface PersUserAppService { + + /** + * Sets the appropriate code in the user personalization table to indicate + * the application is (de)selected and/or pending. + * + * @param user + * EP User + * @param app + * EP Application + * @param select + * True or false + * @param select + * True or false + */ + void setPersUserAppValue(EPUser user, EPApp app, boolean select, boolean pending); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppServiceImpl.java new file mode 100644 index 00000000..6ff10ab4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserAppServiceImpl.java @@ -0,0 +1,141 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserApp; +import org.openecomp.portalapp.portal.domain.PersUserAppSelection; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("persUserAppService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class PersUserAppServiceImpl implements PersUserAppService { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PersUserAppServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + @Autowired + private AdminRolesService adminRolesService; + @Autowired + private UserRolesService userRolesService; + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.UserAppSelectService# + * setAppCatalogSelection(org.openecomp.portalapp.portal.domain.EPUser, + * org.openecomp.portalapp.portal.transport.AppCatalogSelection) + */ + @Override + public void setPersUserAppValue(EPUser user, EPApp app, boolean select, boolean pending) { + if (user == null || app == null) + throw new IllegalArgumentException("setPersUserAppValue: Null values"); + + // Find the record for this user-app combo, if any + String filter = " where user_id = " + Long.toString(user.getId()) + " and app_id = " + + Long.toString(app.getId()); + @SuppressWarnings("unchecked") + List persList = dataAccessService.getList(PersUserAppSelection.class, filter, null, null); + + // Key constraint limits to 1 row + PersUserAppSelection persRow = null; + if (persList.size() == 1) + persRow = persList.get(0); + else + persRow = new PersUserAppSelection(null, user.getId(), app.getId(), null); + + if (app.getOpen()) { + // Pending status is not meaningful for open apps. + if (pending) + logger.error(EELFLoggerDelegate.errorLogger, + "setPersUserAppValue: invalid request, ignoring set-pending for open app"); + + // Open apps have same behavior for regular and admin users + if (select) { + // Selection of an open app requires a record + persRow.setStatusCode("S"); // show + dataAccessService.saveDomainObject(persRow, null); + } else { + // De-selection of an open app requires no record + if (persRow.getId() != null) + dataAccessService.deleteDomainObject(persRow, null); + } + } else { + // Non-open app. + + // Pending overrides select. + if (pending) { + persRow.setStatusCode("P"); + dataAccessService.saveDomainObject(persRow, null); + } else { + // Behavior depends on Portal (super) admin status, bcos an + // admin can force an app onto the dashboard. + boolean isPortalAdmin = adminRolesService.isSuperAdmin(user); + boolean adminUserHasAppRole = false; + if (isPortalAdmin) { + List roles = userRolesService.getCachedAppRolesForUser(app.getId(), user.getId()); + adminUserHasAppRole = (roles.size() > 0); + logger.debug(EELFLoggerDelegate.debugLogger, "setPersUserAppValue: app {}, admin user {}, role count {}", + app.getId(), user.getId(), roles.size()); + } + + if (select) { + if (isPortalAdmin && !adminUserHasAppRole) { + // The special case: portal admin, no role + persRow.setStatusCode("S"); // show + dataAccessService.saveDomainObject(persRow, null); + } else { + // User has role-based access to the app. + // Showing an accessible app requires no record. + if (persRow.getId() != null) + dataAccessService.deleteDomainObject(persRow, null); + } + } // select + else { + if (isPortalAdmin && !adminUserHasAppRole) { + // The special case: portal admin, no role + if (persRow.getId() != null) + dataAccessService.deleteDomainObject(persRow, null); + } else { + // User has role-based access to the app. + // Hiding an accessible app requires a record + persRow.setStatusCode("H"); // hide + dataAccessService.saveDomainObject(persRow, null); + } + } // deselect + } + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetService.java new file mode 100644 index 00000000..d3a46d98 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetService.java @@ -0,0 +1,41 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface PersUserWidgetService { + + /** + * Sets the appropriate code in the user personalization table to indicate + * the application is (de)selected and/or pending. + * + * @param user + * EP User + * @param app + * EP Application + * @param select + * True or false + * @param select + * True or false + */ + void setPersUserAppValue(EPUser user, Long widgetId, boolean select); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetServiceImpl.java new file mode 100644 index 00000000..9a45dea6 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PersUserWidgetServiceImpl.java @@ -0,0 +1,81 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.PersUserWidgetSelection; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("persUserWidgetService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class PersUserWidgetServiceImpl implements PersUserWidgetService{ + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PersUserAppServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Override + public void setPersUserAppValue(EPUser user, Long widgetId, boolean select) { + if (user == null || widgetId == null) + throw new IllegalArgumentException("setPersUserAppValue: Null values"); + + String filter = " where user_id = " + Long.toString(user.getId()) + " and widget_id = " + + Long.toString(widgetId); + @SuppressWarnings("unchecked") + List persList = dataAccessService.getList(PersUserWidgetSelection.class, filter, null, null); + + // Key constraint limits to 1 row + PersUserWidgetSelection persRow = null; + if (persList.size() == 1){ + persRow = persList.get(0); + } + else { + persRow = new PersUserWidgetSelection(null, user.getId(), widgetId, null); + } + if(select){ + if (persRow.getId() != null){ + dataAccessService.deleteDomainObject(persRow, null); + } + persRow.setStatusCode("S"); // show + dataAccessService.saveDomainObject(persRow, null); + } else{ + if (persRow.getId() != null){ + dataAccessService.deleteDomainObject(persRow, null); + } + persRow.setStatusCode("H"); // Hide + dataAccessService.saveDomainObject(persRow, null); + } + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminService.java new file mode 100644 index 00000000..55b3afd6 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminService.java @@ -0,0 +1,31 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.PortalAdmin; + +public interface PortalAdminService { + List getPortalAdmins (); + FieldsValidator createPortalAdmin(String orgUserId); + FieldsValidator deletePortalAdmin(Long userId); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminServiceImpl.java new file mode 100644 index 00000000..639bfc4c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/PortalAdminServiceImpl.java @@ -0,0 +1,210 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.PortalAdmin; +import org.openecomp.portalapp.portal.transport.PortalAdminUserRole; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("portalAdminService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class PortalAdminServiceImpl implements PortalAdminService { + + private String SYS_ADMIN_ROLE_ID = "1"; + private String ECOMP_APP_ID = "1"; + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PortalAdminServiceImpl.class); + + @Autowired + private SessionFactory sessionFactory; + @Autowired + private DataAccessService dataAccessService; + @Autowired + SearchService searchService; + + @PostConstruct + private void init() { + SYS_ADMIN_ROLE_ID = SystemProperties.getProperty(SystemProperties.SYS_ADMIN_ROLE_ID); + ECOMP_APP_ID = SystemProperties.getProperty(EPCommonSystemProperties.ECOMP_APP_ID); + } + + public List getPortalAdmins() { + try { + String sql = "SELECT u.user_id, u.first_name, u.last_name, u.login_id " + + " FROM fn_user u, fn_user_role ur WHERE u.user_id = ur.user_id AND ur.role_id=" + + SYS_ADMIN_ROLE_ID; + logQuery(sql); + + @SuppressWarnings("unchecked") + List portalAdmins = dataAccessService.executeSQLQuery(sql, PortalAdmin.class, null); + logger.debug(EELFLoggerDelegate.debugLogger, "getPortalAdmins was successful"); + return portalAdmins; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while performing getPortalAdmins operation, Details: " + + EcompPortalUtils.getStackTrace(e)); + return null; + } + } + + @SuppressWarnings("unchecked") + public FieldsValidator createPortalAdmin(String orgUserId) { + FieldsValidator fieldsValidator = new FieldsValidator(); + logger.debug(EELFLoggerDelegate.debugLogger, "LR: createPortalAdmin: test 1"); + boolean result = false; + EPUser user = null; + boolean createNewUser = false; + List localUserList = dataAccessService.getList(EPUser.class, " where orgUserId='" + orgUserId + "'", + null, null); + if (localUserList.size() > 0) { + user = localUserList.get(0); + } else { + createNewUser = true; + } + + if (user!=null && isLoggedInUserPortalAdmin(user.getId())) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + logger.error(EELFLoggerDelegate.errorLogger, "User '" + user.getOrgUserId() + "' already has PortalAdmin role assigned."); + } + else if (user != null || createNewUser) { + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + + transaction = localSession.beginTransaction(); + if (createNewUser) { + user = this.searchService.searchUserByUserId(orgUserId); + if (user != null) { + // insert the user with active true in order to + // pass login phase. + user.setActive(true); + localSession.save(EPUser.class.getName(), user); + } + } + if (user != null) { + Long userid = user.getId(); + PortalAdminUserRole userRole = new PortalAdminUserRole(); + userRole.userId = userid; + userRole.roleId = Long.valueOf(SYS_ADMIN_ROLE_ID); + userRole.appId = Long.valueOf(ECOMP_APP_ID); + + localSession.save(PortalAdminUserRole.class.getName(), userRole); + } + // logger.debug(EELFLoggerDelegate.debugLogger, "after saving menu object, new id: " + userid); + + transaction.commit(); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, + "createPortalAdmin rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "createPortalAdmin"); + } + if (!result) { + logger.debug(EELFLoggerDelegate.debugLogger, "LR: createPortalAdmin: no result. setting httpStatusCode to " + + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + logger.error(EELFLoggerDelegate.errorLogger, "PortalAdminServiceImpl.createPortalAdmin: bad request"); + } + } + return fieldsValidator; + } + + public FieldsValidator deletePortalAdmin(Long userId) { + FieldsValidator fieldsValidator = new FieldsValidator(); + logger.debug(EELFLoggerDelegate.debugLogger, "deletePortalAdmin: test 1"); + boolean result = false; + Session localSession = null; + Transaction transaction = null; + + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + dataAccessService.deleteDomainObjects(PortalAdminUserRole.class, + "user_id='" + userId + "' AND role_id='" + SYS_ADMIN_ROLE_ID + "'", null); + transaction.commit(); + result = true; + } catch (Exception e) { + EcompPortalUtils.rollbackTransaction(transaction, "deletePortalAdmin rollback, exception = " + e); + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "deletePortalAdmin"); + } + if (result) { + } else { + logger.debug(EELFLoggerDelegate.debugLogger, "deletePortalAdmin: no result. setting httpStatusCode to " + + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + return fieldsValidator; + } + + private void logQuery(String sql) { + logger.debug(EELFLoggerDelegate.debugLogger, "Executing query: " + sql); + } + + private boolean isLoggedInUserPortalAdmin(Long userId) { + try { + String sql = "SELECT u.user_id, u.first_name, u.last_name, u.login_id " + + " FROM fn_user u, fn_user_role ur " + + " WHERE u.user_id = ur.user_id " + + " AND ur.user_id=" + userId + + " AND ur.role_id=" + SYS_ADMIN_ROLE_ID; + + logQuery(sql); + + @SuppressWarnings("unchecked") + List portalAdmins = dataAccessService.executeSQLQuery(sql, PortalAdmin.class, null); + logger.debug(EELFLoggerDelegate.debugLogger, portalAdmins.toString()); + if (portalAdmins==null || portalAdmins.size()<=0) { + return false; + } + return true; + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing isLoggedInUserPortalAdmin operation, Details: " + EcompPortalUtils.getStackTrace(e)); + return false; + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java new file mode 100644 index 00000000..9aa24692 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java @@ -0,0 +1,30 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface SearchService { + + public String searchUsersInPhoneBook(String searchString); + + public EPUser searchUserByUserId(String orgUserId); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java new file mode 100644 index 00000000..88dc299f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java @@ -0,0 +1,175 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.transport.UserWithNameSurnameTitle; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Service("searchService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class SearchServiceImpl implements SearchService { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SearchServiceImpl.class); + + // TODO: the values below should be defined in other place + private static final int maxSizeOfSearchResult = 100; + + + @Autowired + EPLdapService ldapService; + + @Override + public String searchUsersInPhoneBook(String searchString) { + String orgUserId = null; + List tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); + for (int i = 0; i < tokens.size(); i++) { // find orgUserId if possible and remove it from tokens + if (tokens.get(i).matches(".*\\d+.*")) { + orgUserId = tokens.get(i); + tokens.remove(i); + } + } + while (tokens.size() > 2) { // we use no more then first 2 tokens (orgUserId is removed, see above) + tokens.remove(tokens.size() - 1); + } + EPUser attrUser = new EPUser(); + attrUser.setOrgUserId(orgUserId); + List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null; + if (tokens.size() == 2) { + attrUser.setFirstName(tokens.get(0)); + attrUser.setLastName(tokens.get(1)); + resultOfSearch = this.searchUsersByAttrs(attrUser); + resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); + resultOfSearch = this.removeWrongLastNames(resultOfSearch, tokens.get(1)); + if (resultOfSearch.size() < maxSizeOfSearchResult) { + attrUser.setFirstName(tokens.get(1)); + attrUser.setLastName(tokens.get(0)); + resultOfAdditionalSearch = this.searchUsersByAttrs(attrUser); + resultOfAdditionalSearch = this.removeWrongFirstNames(resultOfAdditionalSearch, tokens.get(1)); + resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); + } + } else if (tokens.size() == 1) { + attrUser.setFirstName(tokens.get(0)); + resultOfSearch = this.searchUsersByAttrs(attrUser); + resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); + if (resultOfSearch.size() < maxSizeOfSearchResult) { + attrUser.setFirstName(null); + attrUser.setLastName(tokens.get(0)); + resultOfAdditionalSearch = this.searchUsersByAttrs(attrUser); + resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); + } + } else if (orgUserId != null) { + resultOfSearch = this.searchUsersByAttrs(attrUser); + } + if (resultOfAdditionalSearch != null) { + resultOfSearch.addAll(resultOfAdditionalSearch); + } + resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); + ObjectMapper mapper = new ObjectMapper(); + String result = "[]"; + try { + result = mapper.writeValueAsString(resultOfSearch); + } catch (JsonProcessingException e) { + logger.error(EELFLoggerDelegate.errorLogger, "searchUsersInPhoneBook Exception = " + EcompPortalUtils.getStackTrace(e)); + } + return result; + } + + private List searchUsersByAttrs(EPUser attrUser) { + List foundUsers = new ArrayList(); + try { + org.openecomp.portalsdk.core.command.support.SearchResult searchResult = this.ldapService.searchPost(attrUser, null, null, null, 0, 0, -1); + for (Object obj : searchResult) { + EPUser user = (EPUser) obj; + UserWithNameSurnameTitle foundUser = new UserWithNameSurnameTitle(user.getOrgUserId(), user.getFirstName(), user.getLastName(), user.getJobTitle()); + foundUsers.add(foundUser); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "searchInPhoneBookWithToken Exception = " + EcompPortalUtils.getStackTrace(e)); + } + return foundUsers; + } + + private List removeWrongFirstNames(List resultOfSearch, String firstName) { + firstName = firstName.toUpperCase(); + for (int i = resultOfSearch.size() - 1; i >= 0; i--) { + UserWithNameSurnameTitle user = resultOfSearch.get(i); + if ((user.firstName == null) || !user.firstName.toUpperCase().startsWith(firstName)) { + resultOfSearch.remove(i); + } + } + return resultOfSearch; + } + + private List removeWrongLastNames(List resultOfSearch, String lastName) { + lastName = lastName.toUpperCase(); + for (int i = resultOfSearch.size() - 1; i >= 0; i--) { + UserWithNameSurnameTitle user = resultOfSearch.get(i); + if ((user.lastName == null) || !user.lastName.toUpperCase().startsWith(lastName)) { + resultOfSearch.remove(i); + } + } + return resultOfSearch; + } + + private List cutSearchResultToMaximumSize(List resultOfSearch) { + for (int i = resultOfSearch.size() - 1; i >= maxSizeOfSearchResult; i--) { + resultOfSearch.remove(i); + } + return resultOfSearch; + } + + @Override + @SuppressWarnings("unchecked") + public EPUser searchUserByUserId(String orgUserId) { + EPUser user = null; + EPUser searchedUser = new EPUser(); + searchedUser.setOrgUserId(orgUserId); + try { + List searchResult = ldapService.searchPost(searchedUser, "", null, null, 0, -1, 1); + for (Object obj : searchResult) { + if (obj instanceof EPUser) { + user = (EPUser) obj; + // This assignment should be checked later! + user.setLoginId(orgUserId); + break; + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "searchUserBy orgUserId exception = " + EcompPortalUtils.getStackTrace(e)); + } + return user; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextService.java new file mode 100644 index 00000000..0b1a6df7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextService.java @@ -0,0 +1,98 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.SharedContext; + +/** + * Defines the methods exposed by the service that manages shared context + * objects in the database via Hibernate. + */ +public interface SharedContextService { + + /** + * Gets all shared context objects for the specified context ID. + * + * @return List of SharedContext objects + */ + List getSharedContexts(String contextId); + + /** + * Gets the shared context with the specified context ID and key. + * + * @param contextId + * Context ID; usually a session ID + * @param key + * Key for the key-value pair + * @return Value found in the database, null if any parameter is null or no + * shared context exists with that context ID - key pair. + */ + SharedContext getSharedContext(String contextId, String key); + + /** + * Creates a new shared context in the database with the specified context + * ID, key and value. + * + * @param context + * SharedContext object to save. + * @param key + * Key for the key-value pair. + * @param value + * Value for the key-value pair. + */ + void addSharedContext(String contextId, String key, String value); + + /** + * Saves the specified shared context to the database. + * + * @param context + * SharedContext object to save. + */ + void saveSharedContext(SharedContext context); + + /** + * Deletes the specified shared context from the database. + * + * @param context + * SharedContext object to delete. + */ + void deleteSharedContext(SharedContext context); + + /** + * Deletes all shared contexts with the specified context ID. + * + * @param contextId + * Context ID; usually a session ID + * @return number of shared-context objects deleted + */ + int deleteSharedContexts(String contextId); + + /** + * Deletes all shared contexts with a creation time that is older than the + * specified value. + * + * @param ageInSeconds + * Expiration threshold in seconds + */ + void expireSharedContexts(int ageInSeconds); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextServiceImpl.java new file mode 100644 index 00000000..428f1354 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/SharedContextServiceImpl.java @@ -0,0 +1,177 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.SharedContext; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +/** + * Implementation of the shared-context service that talks to the database. + */ +@Service("sharedContextService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class SharedContextServiceImpl implements SharedContextService { + + @Autowired + private DataAccessService dataAccessService; + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SharedContextServiceImpl.class); + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalsdk.core.service.SharedContextService# + * getSharedContexts() + */ + @Override + @SuppressWarnings("unchecked") + public List getSharedContexts(String contextId) { + List restrictionsList = new ArrayList(); + Criterion contextIdCrit = Restrictions.eq("context_id", contextId); + restrictionsList.add(contextIdCrit); + List contexts = (List) getDataAccessService().getList(SharedContext.class, null, + restrictionsList, null); + + return contexts; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalsdk.core.service.SharedContextService# + * getSharedContext(java. lang.String, java.lang.String) + */ + @Override + public SharedContext getSharedContext(String contextId, String key) { + SharedContext context = null; + List restrictionsList = new ArrayList(); + Criterion contextIdCrit = Restrictions.eq("context_id", contextId); + Criterion keyCrit = Restrictions.eq("ckey", key); + restrictionsList.add(contextIdCrit); + restrictionsList.add(keyCrit); + @SuppressWarnings("unchecked") + List contexts = (List) getDataAccessService().getList(SharedContext.class, null, + restrictionsList, null); + if (contexts != null && contexts.size() == 1) + context = contexts.get(0); + + return context; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.SharedContextService# + * addSharedContext(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void addSharedContext(String contextId, String key, String value) { + SharedContext context = new SharedContext(contextId, key, value); + saveSharedContext(context); + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalsdk.core.service.SharedContextService# + * saveSharedContext(com. att.fusion.core.domain.SharedContext) + */ + @Override + public void saveSharedContext(SharedContext context) { + getDataAccessService().saveDomainObject(context, null); + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalsdk.core.service.SharedContextService# + * deleteSharedContext(com. att.fusion.core.domain.SharedContext) + */ + @Override + public void deleteSharedContext(SharedContext context) { + getDataAccessService().deleteDomainObject(context, null); + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.SharedContextService# + * deleteSharedContexts(java.lang.String) + */ + @Override + public int deleteSharedContexts(String contextId) { + // Uses an inefficient method to avoid a where clause + // that could be used to mount a SQL injection attack. + List contexts = getSharedContexts(contextId); + if (contexts == null) + return 0; + + logger.debug(EELFLoggerDelegate.debugLogger, "deleteSharedContexts: count is " + contexts.size()); + for (SharedContext sc : contexts) + deleteSharedContext(sc); + + return contexts.size(); + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.SharedContextService# + * expireSharedContexts(int) + */ + @Override + public void expireSharedContexts(int ageInSeconds) { + // Specific to the MySQL database. + // final String whereClause = " where create_time < ADDDATE(NOW(), + // INTERVAL - " + ageInSeconds + " SECOND)"; + final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date expiredDateTime = new Date(System.currentTimeMillis() - ageInSeconds * 1000); + logger.debug(EELFLoggerDelegate.debugLogger, + "expireSharedContexts: expire time is " + expiredDateTime.toString()); + final String whereClause = " create_time < '" + dateFormat.format(expiredDateTime) + "'"; + getDataAccessService().deleteDomainObjects(SharedContext.class, whereClause, null); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationService.java new file mode 100644 index 00000000..063fdf07 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationService.java @@ -0,0 +1,55 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EcompAppRole; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.EpNotificationItemVO; +import org.openecomp.portalapp.portal.transport.EpRoleNotificationItem; + +public interface UserNotificationService { + + List getNotifications(Long userId); + + List getNotificationRoles(Long notificationId); + + List getAppRoleList(); + /** + * Marks the notification as viewed by the specified user. + * + * @param notificationId + * @param userId + */ + void setNotificationRead(Long notificationId, int userId); + + String saveNotification(EpNotificationItem notificationItem) throws Exception; + + List getNotificationHistoryVO(Long userId); + + List getAdminNotificationVOS(); + + List getUsersByOrgIds(List OrgIds); + + List getMessageRecipients(Long notificationId); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationServiceImpl.java new file mode 100644 index 00000000..4017b2fc --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserNotificationServiceImpl.java @@ -0,0 +1,211 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hibernate.SessionFactory; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserNotification; +import org.openecomp.portalapp.portal.domain.EcompAppRole; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.transport.EpNotificationItem; +import org.openecomp.portalapp.portal.transport.EpNotificationItemVO; +import org.openecomp.portalapp.portal.transport.EpRoleNotificationItem; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +@Service("userNotificationService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class UserNotificationServiceImpl implements UserNotificationService { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + @Autowired + private SessionFactory sessionFactory; + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#getNotifications(java.lang.Long) + */ + @Override + public List getNotifications(Long userId) { + Map params = new HashMap(); + params.put("user_id", userId.toString()); + @SuppressWarnings("unchecked") + List notificationList = dataAccessService.executeNamedQuery("getNotifications", params, + null); + // set the roles to null for pure retrieval of all notifications + for (EpNotificationItem item : notificationList) { + item.setRoles(null); + } + return notificationList; + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#getNotificationHistoryVO(java.lang.Long) + */ + @Override + public List getNotificationHistoryVO(Long userId) { + Map params = new HashMap(); + params.put("user_id", userId.toString()); + @SuppressWarnings("unchecked") + List notificationList = dataAccessService.executeNamedQuery("getNotificationHistoryVO", + params, null); + return notificationList; + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#getAdminNotificationVOS() + */ + @Override + public List getAdminNotificationVOS() { + Map params = new HashMap(); + @SuppressWarnings("unchecked") + List notificationList = dataAccessService + .executeNamedQuery("getAdminNotificationHistoryVO", params, null); + return notificationList; + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#getNotificationRoles(java.lang.Long) + */ + @Override + public List getNotificationRoles(Long notificationId) { + Map params = new HashMap(); + params.put("notificationId", Long.toString(notificationId)); + @SuppressWarnings("unchecked") + List roleNotifList = dataAccessService.executeNamedQuery("getNotificationRoles", params, + null); + return roleNotifList; + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#getAppRoleList() + */ + @SuppressWarnings("unchecked") + @Override + public List getAppRoleList() { + List appRoleList = (List) dataAccessService.executeNamedQuery("getEpNotificationAppRoles", null, null); + return appRoleList; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * setNotificationsRead(java.lang.Long, int) + */ + @Override + public void setNotificationRead(Long notificationId, int userId) { + EPUserNotification userNotification = new EPUserNotification(); + userNotification.setNotificationId(notificationId); + userNotification.setUpdateTime(new Date()); + userNotification.setViewed("Y"); + userNotification.setUserId((long) userId); + getDataAccessService().saveDomainObject(userNotification, null); + } + + /* + * (non-Javadoc) + * @see org.openecomp.portalapp.portal.service.UserNotificationService#saveNotification(org.openecomp.portalapp.portal.transport.EpNotificationItem) + */ + @Override + public String saveNotification(EpNotificationItem notificationItem) throws Exception { + + // gather the roles + if (notificationItem.getRoleIds() != null && !notificationItem.getIsForAllRoles().equals("Y")) { + if (notificationItem.getRoles() == null) { + Set roleSet = new HashSet(); + notificationItem.setRoles(roleSet); + } + for (Long roleId : notificationItem.getRoleIds()) { + EpRoleNotificationItem roleItem = new EpRoleNotificationItem(); + roleItem.setNotificationId(notificationItem.getNotificationId()); + roleItem.setRoleId(roleId.intValue()); + notificationItem.getRoles().add(roleItem); + } + } + + + // for updates fetch roles and then save + if (notificationItem.getNotificationId() != null) { + EpNotificationItem updateNotificationItem = (EpNotificationItem) getDataAccessService() + .getDomainObject(EpNotificationItem.class, notificationItem.getNotificationId(), null); + notificationItem.setRoles(updateNotificationItem.getRoles()); + } + if(notificationItem.msgSource == null) + { + notificationItem.setMsgSource("EP"); + } + getDataAccessService().saveDomainObject(notificationItem, null); + return "" ; + + } + @Override + public List getUsersByOrgIds(List OrgIds) { + Map params = new HashMap(); + params.put("OrgIds", OrgIds); + @SuppressWarnings("unchecked") + List userList = dataAccessService.executeNamedQuery("getUsersByOrgIdsNotifications", params, null); + return userList; + } + + @Override + public List getMessageRecipients(Long notificationId) { + Map params = new HashMap<>(); + params.put("notificationId", Long.toString(notificationId)); + @SuppressWarnings("unchecked") + List activeUsers = dataAccessService.executeNamedQuery("messageRecipients", params, null); + return activeUsers; + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + public SessionFactory getSessionFactory() { + return sessionFactory; + } + + public void setSessionFactory(SessionFactory sessionFactory) { + this.sessionFactory = sessionFactory; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java new file mode 100644 index 00000000..1b9dfd04 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesService.java @@ -0,0 +1,67 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.apache.cxf.transport.http.HTTPException; +import org.openecomp.portalapp.externalsystemapproval.model.ExternalSystemUser; +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserApp; +import org.openecomp.portalapp.portal.domain.EPUserAppCatalogRoles; +import org.openecomp.portalapp.portal.domain.ExternalSystemAccess; +import org.openecomp.portalapp.portal.transport.AppWithRolesForUser; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.RoleInAppForUser; +import org.openecomp.portalapp.portal.transport.UserApplicationRoles; + +public interface UserRolesService { + + public List getAppRolesForUser(Long appId, String userId); + + public boolean setAppWithUserRoleStateForUser(EPUser user, AppWithRolesForUser newAppRolesForUser); + + public List getUsersFromAppEndpoint(Long appId) throws HTTPException; + + public List importRolesFromRemoteApplication(Long appId) throws HTTPException; + + /** + * Gets entries from the local fn_user_role table for the specified user and + * app. + * + * @param appId + * ID of row in fn_app + * @param userid + * ID of row in fn_user + * @return List of EPRole; empty if none found. + */ + public List getCachedAppRolesForUser(Long appId, Long userId); + + public FieldsValidator putUserAppRolesRequest(AppWithRolesForUser userAppRolesData, EPUser user); + + String setAppWithUserRoleStateForUser(ExternalSystemUser newAppRolesForUser); + + public List getUserAppCatalogRoles(EPUser user, String appName); + + public String updateRemoteUserProfile(String orgUserId, Long appId); + + public ExternalSystemAccess getExternalRequestAccess(); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserService.java new file mode 100644 index 00000000..2d8e9112 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserService.java @@ -0,0 +1,34 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; + +public interface UserService { + + List getUserByUserId(String orgUserId); + + List getUserByFirstLastName(String firstName, String lastName); + + public String saveNewUser(EPUser newUser, String checkDuplicate) throws Exception; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java new file mode 100644 index 00000000..4de2c497 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java @@ -0,0 +1,260 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalsdk.core.FusionObject.Utilities; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +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; +import org.springframework.transaction.annotation.Transactional; + +@Service("userService") +@Transactional +public class UserServiceImpl implements UserService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } + + @SuppressWarnings("unchecked") + @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 = EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUTH_USER_SERVER); + URL obj = new URL(url); + + con = (HttpURLConnection) obj.openConnection(); + + // optional default is GET + con.setRequestMethod("GET"); + con.setConnectTimeout(3000); + 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()); + 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,"getUserByUserId failed to close", 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; + + } + + } + + @SuppressWarnings("unchecked") + @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 = EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUTH_USER_SERVER); + URL obj = new URL(url); + + con = (HttpURLConnection) obj.openConnection(); + + // optional default is GET + con.setRequestMethod("GET"); + con.setConnectTimeout(3000); + 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, "getUserByFirstLastName failed", e); + } finally { + try { + in.close(); + con.disconnect(); + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed to close", e); + } + } + + return filterdUsers; + } + + } + + @SuppressWarnings("unchecked") + 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-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterService.java new file mode 100644 index 00000000..df01fb96 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterService.java @@ -0,0 +1,64 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter; + +public interface WidgetParameterService { + + /** + * Saves the specified user-defined widget parameters to the table ep_widget_parameters + * + * @param newParameter + */ + void saveUserParameter(WidgetCatalogParameter newParameter); + + /** + * Gets the specified user-defined widget parameter where paramId is used from all users + * + * @param paramId + * @return + * List of widget parameters + */ + List getUserParameterById(Long paramId); + + + /** + * Deletes the specified user-defined widget parameters from ep_widget_parameters table + * where paramId is used + * + * @param paramId + */ + void deleteUserParameterById(Long paramId); + + + /** + * Gets the specified user-defined widget parameter where paramId is used from the specified + * user with userId + * @param widgetId + * @param userId + * @param paramId + * @return + */ + WidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterServiceImpl.java new file mode 100644 index 00000000..a3e9c61c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetParameterServiceImpl.java @@ -0,0 +1,92 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +@Service("widgetParameterService") +@EnableAspectJAutoProxy +@EPMetricsLog +public class WidgetParameterServiceImpl implements WidgetParameterService{ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetParameterServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @SuppressWarnings("unchecked") + @Override + public WidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) { + List restrictionsList = new ArrayList(); + Criterion widgetIdCrit = Restrictions.eq("widgetId", widgetId); + restrictionsList.add(widgetIdCrit); + Criterion attIdCrit = Restrictions.eq("userId", userId); + restrictionsList.add(attIdCrit); + Criterion paramIdCrit = Restrictions.eq("paramId", paramId); + restrictionsList.add(paramIdCrit); + + + WidgetCatalogParameter widgetParam = null; + List list = (List) dataAccessService + .getList(WidgetCatalogParameter.class, null, restrictionsList, null); + if(list.size() != 0) + widgetParam = list.get(0); + logger.debug(EELFLoggerDelegate.debugLogger, + "getUserParamById: widget parameters: " + widgetParam); + return widgetParam; + } + + @Override + public void saveUserParameter(WidgetCatalogParameter newParameter) { + dataAccessService.saveDomainObject(newParameter, null); + } + + @SuppressWarnings("unchecked") + @Override + public List getUserParameterById(Long paramId) { + List restrictionsList = new ArrayList(); + Criterion paramIdCrit = Restrictions.eq("paramId", paramId); + restrictionsList.add(paramIdCrit); + List list = (List) dataAccessService + .getList(WidgetCatalogParameter.class, null, restrictionsList, null); + return list; + } + + @Override + public void deleteUserParameterById(Long paramId) { + Map params = new HashMap(); + params.put("paramId", Long.toString(paramId)); + dataAccessService.executeNamedQuery("deleteWidgetCatalogParameter", params, null); + dataAccessService.executeNamedQuery("deleteMicroserviceParameterById", params, null); + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetService.java new file mode 100644 index 00000000..b44a19f3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetService.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.List; + +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.OnboardingWidget; + +public interface WidgetService { + + List getOnboardingWidgets(EPUser user, boolean managed); + + FieldsValidator setOnboardingWidget(EPUser user, OnboardingWidget onboardingWidget); + + FieldsValidator deleteOnboardingWidget(EPUser user, Long onboardingWidgetId); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetServiceImpl.java new file mode 100644 index 00000000..484bef4f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/WidgetServiceImpl.java @@ -0,0 +1,276 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserApp; +import org.openecomp.portalapp.portal.domain.Widget; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.transport.FieldsValidator; +import org.openecomp.portalapp.portal.transport.OnboardingWidget; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("widgetService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class WidgetServiceImpl implements WidgetService { + + private static final String baseSqlToken = " widget.WIDGET_ID, widget.WDG_NAME, widget.APP_ID, app.APP_NAME, widget.WDG_WIDTH, widget.WDG_HEIGHT, widget.WDG_URL" + + " from FN_WIDGET widget join FN_APP app ON widget.APP_ID = app.APP_ID"; + + private String validAppsFilter = ""; + + private Long LONG_ECOMP_APP_ID = 1L; + private Long ACCOUNT_ADMIN_ROLE_ID = 999L; + private static final Long DUBLICATED_FIELD_VALUE_ECOMP_ERROR = new Long(EPCommonSystemProperties.DUBLICATED_FIELD_VALUE_ECOMP_ERROR); + + private static final String urlField = "url"; + + private static final String nameField = "name"; + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetServiceImpl.class); + + @Autowired + AdminRolesService adminRolesService; + @Autowired + private SessionFactory sessionFactory; + @Autowired + private DataAccessService dataAccessService; + + @PostConstruct + private void init() { + try { + validAppsFilter = " AND app.ENABLED = 'Y' AND app.APP_ID != " + SystemProperties.getProperty(EPCommonSystemProperties.ECOMP_APP_ID); + ACCOUNT_ADMIN_ROLE_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ACCOUNT_ADMIN_ROLE_ID)); + LONG_ECOMP_APP_ID = Long.valueOf(SystemProperties.getProperty(EPCommonSystemProperties.ECOMP_APP_ID)); + } catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + } + + private String sqlWidgetsForAllApps() { + return "SELECT" + baseSqlToken + validAppsFilter; + } + + private String sqlWidgetsForAllAppsWhereUserIsAdmin(Long userId) { + return "SELECT" + baseSqlToken + " join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = app.APP_ID where FN_USER_ROLE.USER_ID = " + userId + + " AND FN_USER_ROLE.ROLE_ID = " + ACCOUNT_ADMIN_ROLE_ID + validAppsFilter; + } + + private String sqlWidgetsForAllAppsWhereUserHasAnyRole(Long userId) { + return "SELECT DISTINCT" + baseSqlToken + " join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = app.APP_ID where FN_USER_ROLE.USER_ID = " + + userId + validAppsFilter; + } + + @SuppressWarnings("unchecked") + @Override + public List getOnboardingWidgets(EPUser user, boolean managed) { + List onboardingWidgets = new ArrayList(); + String sql = null; + if (adminRolesService.isSuperAdmin(user)) { + sql = this.sqlWidgetsForAllApps(); + } else if (managed) { + if (adminRolesService.isAccountAdmin(user)) { + sql = this.sqlWidgetsForAllAppsWhereUserIsAdmin(user.getId()); + } + } else if (adminRolesService.isAccountAdmin(user) || adminRolesService.isUser(user)) { + sql = this.sqlWidgetsForAllAppsWhereUserHasAnyRole(user.getId()); + } + if (sql != null) { + onboardingWidgets = dataAccessService.executeSQLQuery(sql, OnboardingWidget.class, null); + } + return onboardingWidgets; + } + + private static final Object syncRests = new Object(); + + private boolean isUserAdminOfAppForWidget(boolean superAdmin, Long userId, Long appId) { + if (!superAdmin) { + @SuppressWarnings("unchecked") + List userRoles = dataAccessService.getList(EPUserApp.class, + " where userId = " + userId + " and role.id = " + ACCOUNT_ADMIN_ROLE_ID + " and app.id = " + appId, null, null); + return (userRoles.size() > 0); + } + return true; + } + + private void validateOnboardingWidget(OnboardingWidget onboardingWidget, FieldsValidator fieldsValidator) { + @SuppressWarnings("unchecked") + List widgets = dataAccessService.getList(Widget.class, + " where url = '" + onboardingWidget.url + "'" + " or name = '" + onboardingWidget.name + "'", null, null); + boolean dublicatedUrl = false; + boolean dublicatedName = false; + for (Widget widget : widgets) { + if (onboardingWidget.id != null && onboardingWidget.id.equals(widget.getId())) { + // widget should not be compared with itself + continue; + } + if (!dublicatedUrl && widget.getUrl().equals(onboardingWidget.url)) { + dublicatedUrl = true; + if (dublicatedName) { + break; + } + } + if (!dublicatedName && widget.getName().equalsIgnoreCase(onboardingWidget.name) && widget.getAppId().equals(onboardingWidget.appId)) { + dublicatedName = true; + if (dublicatedUrl) { + break; + } + } + } + if (dublicatedUrl || dublicatedName) { + if (dublicatedUrl) { + fieldsValidator.addProblematicFieldName(urlField); + } + if (dublicatedName) { + fieldsValidator.addProblematicFieldName(nameField); + } + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_CONFLICT); + fieldsValidator.errorCode = DUBLICATED_FIELD_VALUE_ECOMP_ERROR; + } + } + + private void applyOnboardingWidget(OnboardingWidget onboardingWidget, FieldsValidator fieldsValidator) { + boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + Widget widget; + if (onboardingWidget.id == null) { + widget = new Widget(); + } else { + widget = (Widget) localSession.get(Widget.class, onboardingWidget.id); + } + widget.setAppId(onboardingWidget.appId); + widget.setName(onboardingWidget.name); + widget.setWidth(onboardingWidget.width); + widget.setHeight(onboardingWidget.height); + widget.setUrl(onboardingWidget.url); + localSession.saveOrUpdate(widget); + transaction.commit(); + result = true; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + EcompPortalUtils.rollbackTransaction(transaction, "applyOnboardingWidget rollback, exception = " + e); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "applyOnboardingWidget"); + } + if (!result) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + + private FieldsValidator updateOrSaveWidget(boolean superAdmin, Long userId, OnboardingWidget onboardingWidget) { + FieldsValidator fieldsValidator = new FieldsValidator(); + if (!this.isUserAdminOfAppForWidget(superAdmin, userId, onboardingWidget.appId)) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_FORBIDDEN); + return fieldsValidator; + } + synchronized (syncRests) { + // onboardingWidget.id is null for POST and not null for PUT + if (onboardingWidget.id == null) { + this.validateOnboardingWidget(onboardingWidget, fieldsValidator); + } else { + Widget widget = (Widget) dataAccessService.getDomainObject(Widget.class, onboardingWidget.id, null); + if (widget == null || widget.getId() == null) { + // Widget not found + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_NOT_FOUND); + return fieldsValidator; + } + this.validateOnboardingWidget(onboardingWidget, fieldsValidator); + } + if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { + this.applyOnboardingWidget(onboardingWidget, fieldsValidator); + } + } + return fieldsValidator; + } + + @Override + public FieldsValidator setOnboardingWidget(EPUser user, OnboardingWidget onboardingWidget) { + if (onboardingWidget.name.length() == 0 || onboardingWidget.url.length() == 0 || onboardingWidget.appId == null + || onboardingWidget.appId.equals(LONG_ECOMP_APP_ID) || onboardingWidget.width.intValue() <= 0 || onboardingWidget.height.intValue() <= 0) { + if (onboardingWidget.appId.equals(LONG_ECOMP_APP_ID)) { + // logger.error("Alarm!!! Security breach attempt on user " + user.getFullName() + ", userId = " + user.getUserId()); + } + FieldsValidator fieldsValidator = new FieldsValidator(); + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); + return fieldsValidator; + } + return this.updateOrSaveWidget(adminRolesService.isSuperAdmin(user), user.getId(), onboardingWidget); + } + + @Override + public FieldsValidator deleteOnboardingWidget(EPUser user, Long onboardingWidgetId) { + FieldsValidator fieldsValidator = new FieldsValidator(); + synchronized (syncRests) { + Widget widget = (Widget) dataAccessService.getDomainObject(Widget.class, onboardingWidgetId, null); + if (widget != null && widget.getId() != null) { // widget exists + if (!this.isUserAdminOfAppForWidget(adminRolesService.isSuperAdmin(user), user.getId(), widget.getAppId())) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_FORBIDDEN); + } else { + boolean result = false; + Session localSession = null; + Transaction transaction = null; + try { + localSession = sessionFactory.openSession(); + transaction = localSession.beginTransaction(); + localSession.delete(localSession.get(Widget.class, onboardingWidgetId)); + transaction.commit(); + result = true; + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + EcompPortalUtils.rollbackTransaction(transaction, "deleteOnboardingWidget rollback, exception = " + e); + } finally { + EcompPortalUtils.closeLocalSession(localSession, "deleteOnboardingWidget"); + } + if (!result) { + fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + } + } + return fieldsValidator; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AllAppsWithRolesForUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AllAppsWithRolesForUser.java new file mode 100644 index 00000000..da776ded --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AllAppsWithRolesForUser.java @@ -0,0 +1,40 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +public class AllAppsWithRolesForUser { + + public String orgUserId; + + public List apps; + + public static class AppWithUserRoles { + + public Long appId; + + public String appName; + + public List appRoles; + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/Analytics.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/Analytics.java new file mode 100644 index 00000000..adc5ad2b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/Analytics.java @@ -0,0 +1,66 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Analytics { + + private String action; + private String page; + private String function; + private String userId; + private String type; + + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getAction() { + return action; + } + public void setAction(String action) { + this.action = action; + } + public String getPage() { + return page; + } + public void setPage(String page) { + this.page = page; + } + public String getFunction() { + return function; + } + public void setFunction(String function) { + this.function = function; + } + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppCatalogPersonalization.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppCatalogPersonalization.java new file mode 100644 index 00000000..7c24917b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppCatalogPersonalization.java @@ -0,0 +1,94 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +/** + * Model for the object PUT to the controller when the user takes an action on + * an application in the catalog. + */ +public class AppCatalogPersonalization { + + public Long appId; + public Boolean select; + public Boolean pending; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public Boolean getSelect() { + return select; + } + + public void setSelect(Boolean select) { + this.select = select; + } + + public Boolean getPending() { + return pending; + } + + public void setPending(Boolean pending) { + this.pending = pending; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appId == null) ? 0 : appId.hashCode()); + result = prime * result + ((pending == null) ? 0 : pending.hashCode()); + result = prime * result + ((select == null) ? 0 : select.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppCatalogPersonalization other = (AppCatalogPersonalization) obj; + if (appId == null) { + if (other.appId != null) + return false; + } else if (!appId.equals(other.appId)) + return false; + if (pending == null) { + if (other.pending != null) + return false; + } else if (!pending.equals(other.pending)) + return false; + if (select == null) { + if (other.select != null) + return false; + } else if (!select.equals(other.select)) + return false; + return true; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppNameIdIsAdmin.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppNameIdIsAdmin.java new file mode 100644 index 00000000..484fffad --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppNameIdIsAdmin.java @@ -0,0 +1,114 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class AppNameIdIsAdmin { + + public Long id; + + public String appName; + + public Boolean isAdmin; + + public Boolean restrictedApp; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public Boolean getIsAdmin() { + return isAdmin; + } + + public void setIsAdmin(Boolean isAdmin) { + this.isAdmin = isAdmin; + } + + public Boolean getRestrictedApp() { + return restrictedApp; + } + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appName == null) ? 0 : appName.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((isAdmin == null) ? 0 : isAdmin.hashCode()); + result = prime * result + ((restrictedApp == null) ? 0 : restrictedApp.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppNameIdIsAdmin other = (AppNameIdIsAdmin) obj; + if (appName == null) { + if (other.appName != null) + return false; + } else if (!appName.equals(other.appName)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (isAdmin == null) { + if (other.isAdmin != null) + return false; + } else if (!isAdmin.equals(other.isAdmin)) + return false; + if (restrictedApp == null) { + if (other.restrictedApp != null) + return false; + } else if (!restrictedApp.equals(other.restrictedApp)) + return false; + return true; + } + + @Override + public String toString() { + return "AppNameIdIsAdmin [id=" + id + ", appName=" + appName + ", isAdmin=" + isAdmin + ", restrictedApp=" + + restrictedApp + "]"; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppWithRolesForUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppWithRolesForUser.java new file mode 100644 index 00000000..4e37ee00 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppWithRolesForUser.java @@ -0,0 +1,73 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +public class AppWithRolesForUser { + + public String orgUserId; + + public Long appId; + + public String appName; + + public List appRoles; + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public List getAppRoles() { + return appRoles; + } + + public void setAppRoles(List appRoles) { + this.appRoles = appRoles; + } + + @Override + public String toString() { + return "AppWithRolesForUser [orgUserId=" + orgUserId + ", appId=" + appId + ", appName=" + appName + + ", appRoles=" + appRoles + "]"; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppsListWithAdminRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppsListWithAdminRole.java new file mode 100644 index 00000000..0000e2a7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/AppsListWithAdminRole.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.ArrayList; + +public class AppsListWithAdminRole { + + public String orgUserId; + + public ArrayList appsRoles; + + public AppsListWithAdminRole() { + appsRoles = new ArrayList(); + } + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + + public ArrayList getAppsRoles() { + return appsRoles; + } + + public void setAppsRoles(ArrayList appsRoles) { + this.appsRoles = appsRoles; + } + + @Override + public String toString() { + return "AppsListWithAdminRole [orgUserId=" + orgUserId + ", appsRoles=" + appsRoles + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appsRoles == null) ? 0 : appsRoles.hashCode()); + result = prime * result + ((orgUserId == null) ? 0 : orgUserId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AppsListWithAdminRole other = (AppsListWithAdminRole) obj; + if (appsRoles == null) { + if (other.appsRoles != null) + return false; + } else if (!appsRoles.equals(other.appsRoles)) + return false; + if (orgUserId == null) { + if (other.orgUserId != null) + return false; + } else if (!orgUserId.equals(other.orgUserId)) + return false; + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRole.java new file mode 100644 index 00000000..47658786 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRole.java @@ -0,0 +1,108 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@Entity +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessCardApplicationRole implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + + public BusinessCardApplicationRole() { + } + + + @Id + @Column(name="app_name") + private String appName; + + @Id + @Column(name="role_name") + private String roleName; + + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + @Override + public String toString() { + return "BusinessCardUserApplicationRoles [appName=" + appName + ", roleName=" + roleName + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appName == null) ? 0 : appName.hashCode()); + result = prime * result + ((roleName == null) ? 0 : roleName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BusinessCardApplicationRole other = (BusinessCardApplicationRole) obj; + if (appName == null) { + if (other.appName != null) + return false; + } else if (!appName.equals(other.appName)) + return false; + if (roleName == null) { + if (other.roleName != null) + return false; + } else if (!roleName.equals(other.roleName)) + return false; + return true; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRolesList.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRolesList.java new file mode 100644 index 00000000..15c3aff2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/BusinessCardApplicationRolesList.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessCardApplicationRolesList { + + public BusinessCardApplicationRolesList(){} + + private String appName; + private List roleNames; + + + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } + public List getRoleNames() { + return roleNames; + } + public void setRoleNames(List roleNames) { + this.roleNames = roleNames; + } + public BusinessCardApplicationRolesList(String appName, List roleNames) { + super(); + this.appName = appName; + this.roleNames = roleNames; + } + @Override + public String toString() { + return "BusinessCardUserAppRoles [appName=" + appName + ", roleNames=" + roleNames + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appName == null) ? 0 : appName.hashCode()); + result = prime * result + ((roleNames == null) ? 0 : roleNames.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BusinessCardApplicationRolesList other = (BusinessCardApplicationRolesList) obj; + if (appName == null) { + if (other.appName != null) + return false; + } else if (!appName.equals(other.appName)) + return false; + if (roleNames == null) { + if (other.roleNames != null) + return false; + } else if (!roleNames.equals(other.roleNames)) + return false; + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidget.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidget.java new file mode 100644 index 00000000..da2ae4ea --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidget.java @@ -0,0 +1,139 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * This is to handle portal admins + * @author aw3218 + */ +@Entity +@Table(name="fn_common_widget_data") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CommonWidget extends DomainVo{ + + private static final long serialVersionUID = 7897021982887364557L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "id") + private Long id; + + @Column(name = "category") + public String category; + + @Column(name = "href") + public String href; + + @Column(name = "title") + public String title; + + @Column(name = "content") + public String content; + + @Column(name = "event_date") + public String eventDate; + + @Column(name = "sort_order") + public Integer sortOrder; + + + public CommonWidget(){ + + } + + public CommonWidget(String category, String href, String title, String content, String eventDate, Integer sortOrder){ + this.category = category; + this.href = href; + this.title = title; + this.content = content; + this.eventDate = eventDate; + this.sortOrder = sortOrder; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getEventDate() { + return eventDate; + } + + public void setEventDate(String eventDate) { + this.eventDate = eventDate; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidgetMeta.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidgetMeta.java new file mode 100644 index 00000000..ad71b081 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/CommonWidgetMeta.java @@ -0,0 +1,50 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +public class CommonWidgetMeta { + + private String category; + private List items; + + public CommonWidgetMeta(){ + + } + + public CommonWidgetMeta(String category, List items){ + this.category = category; + this.items = items; + } + + public String getCategory() { + return category; + } + public void setCategory(String category) { + this.category = category; + } + public List getItems() { + return items; + } + public void setItems(List items) { + this.items = items; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsManualPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsManualPreference.java new file mode 100644 index 00000000..658ef51e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsManualPreference.java @@ -0,0 +1,114 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class EPAppsManualPreference { + + private Long appid; + private int col; + private String headerText; + private String imageLink; + private int order; + private boolean restrictedApp; + private int row; + private int sizeX; + private int sizeY; + private String subHeaderText; + private String url; + private boolean addRemoveApps; + + + public boolean isAddRemoveApps() { + return addRemoveApps; + } + public void setAddRemoveApps(boolean addRemoveApps) { + this.addRemoveApps = addRemoveApps; + } + public Long getAppid() { + return appid; + } + public void setAppid(Long appid) { + this.appid = appid; + } + public int getCol() { + return col; + } + public void setCol(int col) { + this.col = col; + } + public String getHeaderText() { + return headerText; + } + public void setHeaderText(String headerText) { + this.headerText = headerText; + } + public String getImageLink() { + return imageLink; + } + public void setImageLink(String imageLink) { + this.imageLink = imageLink; + } + public int getOrder() { + return order; + } + public void setOrder(int order) { + this.order = order; + } + public boolean isRestrictedApp() { + return restrictedApp; + } + public void setRestrictedApp(boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } + public int getRow() { + return row; + } + public void setRow(int row) { + this.row = row; + } + public int getSizeX() { + return sizeX; + } + public void setSizeX(int sizeX) { + this.sizeX = sizeX; + } + public int getSizeY() { + return sizeY; + } + public void setSizeY(int sizeY) { + this.sizeY = sizeY; + } + public String getSubHeaderText() { + return subHeaderText; + } + public void setSubHeaderText(String subHeaderText) { + this.subHeaderText = subHeaderText; + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + + public boolean isValid(){ + return appid != null; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsSortPreference.java new file mode 100644 index 00000000..8aa0860c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPAppsSortPreference.java @@ -0,0 +1,47 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class EPAppsSortPreference { + + private int index; + private String value; + private String title; + + public int getIndex() { + return index; + } + public void setIndex(int index) { + this.index = index; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPDeleteAppsManualSortPref.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPDeleteAppsManualSortPref.java new file mode 100644 index 00000000..700b74b1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPDeleteAppsManualSortPref.java @@ -0,0 +1,51 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class EPDeleteAppsManualSortPref { + private Long appId; + private boolean select; + private boolean pending; + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public boolean isSelect() { + return select; + } + + public void setSelect(boolean select) { + this.select = select; + } + + public boolean isPending() { + return pending; + } + + public void setPending(boolean pending) { + this.pending = pending; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPWidgetsSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPWidgetsSortPreference.java new file mode 100644 index 00000000..3fadf1a4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EPWidgetsSortPreference.java @@ -0,0 +1,92 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +public class EPWidgetsSortPreference { + + private int SizeX; + private int SizeY; + private String headerText; + private String url; + private Long widgetid; + private List attrb; + private String widgetIdentifier; + private int row; + private int col; + + public String getWidgetIdentifier() { + return widgetIdentifier; + } + public List getAttrb() { + return attrb; + } + public void setAttrb(List attrb) { + this.attrb = attrb; + } + public void setWidgetIdentifier(String widgetIdentifier) { + this.widgetIdentifier = widgetIdentifier; + } + public int getSizeX() { + return SizeX; + } + public void setSizeX(int sizeX) { + SizeX = sizeX; + } + public int getSizeY() { + return SizeY; + } + public void setSizeY(int sizeY) { + SizeY = sizeY; + } + public String getHeaderText() { + return headerText; + } + public void setHeaderText(String headerText) { + this.headerText = headerText; + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public Long getWidgetid() { + return widgetid; + } + public void setWidgetid(Long widgetid) { + this.widgetid = widgetid; + } + public int getRow() { + return row; + } + public void setRow(int row) { + this.row = row; + } + public int getCol() { + return col; + } + public void setCol(int col) { + this.col = col; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItem.java new file mode 100644 index 00000000..94fbe59a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItem.java @@ -0,0 +1,328 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + + +/** + * This is to handle notifications in notification PopUp + */ + + +@Entity +@Table(name = "ep_notification") +public class EpNotificationItem extends DomainVo { + public EpNotificationItem() { + }; + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "notification_ID") + public Long notificationId; + + @Column(name = "is_for_online_users") + public String isForOnlineUsers; + + @Column(name = "is_for_all_roles") + public String isForAllRoles; + + @Column(name = "active_YN") + public String activeYn; + + @Column(name = "msg_header") + public String msgHeader; + + @Column(name = "msg_description") + public String msgDescription; + + @Column(name = "msg_source") + public String msgSource; + + @Column(name = "start_time") + public Date startTime; + + @Column(name = "end_time") + public Date endTime; + + @Column(name = "priority") + public Long priority; + + @Column(name = "creator_ID") + public Long creatorId; + + @Column(name = "created_date") + public Date createdDate; + + + @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.ALL}, orphanRemoval = true) + @JoinColumn(name="notification_ID") + private Set roles; + + @Transient + private List roleIds; + + public Long getNotificationId() { + return notificationId; + } + + public void setNotificationId(Long notificationId) { + this.notificationId = notificationId; + } + + public String getIsForOnlineUsers() { + return isForOnlineUsers; + } + + public void setIsForOnlineUsers(String isForOnlineUsers) { + this.isForOnlineUsers = isForOnlineUsers; + } + + public String getIsForAllRoles() { + return isForAllRoles; + } + + public void setIsForAllRoles(String isForAllRoles) { + this.isForAllRoles = isForAllRoles; + } + + public String getActiveYn() { + return activeYn; + } + + public void setActiveYn(String activeYn) { + this.activeYn = activeYn; + } + + public String getMsgHeader() { + return msgHeader; + } + + public void setMsgHeader(String msgHeader) { + this.msgHeader = msgHeader; + } + + public String getMsgDescription() { + return msgDescription; + } + + public void setMsgDescription(String msgDescription) { + this.msgDescription = msgDescription; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Long getPriority() { + return priority; + } + + public void setPriority(Long priority) { + this.priority = priority; + } + + public Long getCreatorId() { + return creatorId; + } + + public void setCreatorId(Long creatorId) { + this.creatorId = creatorId; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } + + public List getRoleIds() { + return roleIds; + } + + public void setRoleIds(List roleIds) { + this.roleIds = roleIds; + } + + public String getMsgSource() { + return msgSource; + } + + public void setMsgSource(String msgSource) { + this.msgSource = msgSource; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activeYn == null) ? 0 : activeYn.hashCode()); + result = prime * result + ((createdDate == null) ? 0 : createdDate.hashCode()); + result = prime * result + ((creatorId == null) ? 0 : creatorId.hashCode()); + result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); + result = prime * result + ((isForAllRoles == null) ? 0 : isForAllRoles.hashCode()); + result = prime * result + ((isForOnlineUsers == null) ? 0 : isForOnlineUsers.hashCode()); + result = prime * result + ((msgDescription == null) ? 0 : msgDescription.hashCode()); + result = prime * result + ((msgHeader == null) ? 0 : msgHeader.hashCode()); + result = prime * result + ((msgSource == null) ? 0 : msgSource.hashCode()); + result = prime * result + ((notificationId == null) ? 0 : notificationId.hashCode()); + result = prime * result + ((priority == null) ? 0 : priority.hashCode()); + result = prime * result + ((roleIds == null) ? 0 : roleIds.hashCode()); + result = prime * result + ((roles == null) ? 0 : roles.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EpNotificationItem other = (EpNotificationItem) obj; + if (activeYn == null) { + if (other.activeYn != null) + return false; + } else if (!activeYn.equals(other.activeYn)) + return false; + if (createdDate == null) { + if (other.createdDate != null) + return false; + } else if (!createdDate.equals(other.createdDate)) + return false; + if (creatorId == null) { + if (other.creatorId != null) + return false; + } else if (!creatorId.equals(other.creatorId)) + return false; + if (endTime == null) { + if (other.endTime != null) + return false; + } else if (!endTime.equals(other.endTime)) + return false; + if (isForAllRoles == null) { + if (other.isForAllRoles != null) + return false; + } else if (!isForAllRoles.equals(other.isForAllRoles)) + return false; + if (isForOnlineUsers == null) { + if (other.isForOnlineUsers != null) + return false; + } else if (!isForOnlineUsers.equals(other.isForOnlineUsers)) + return false; + if (msgDescription == null) { + if (other.msgDescription != null) + return false; + } else if (!msgDescription.equals(other.msgDescription)) + return false; + if (msgHeader == null) { + if (other.msgHeader != null) + return false; + } else if (!msgHeader.equals(other.msgHeader)) + return false; + if (msgSource == null) { + if (other.msgSource != null) + return false; + } else if (!msgSource.equals(other.msgSource)) + return false; + if (notificationId == null) { + if (other.notificationId != null) + return false; + } else if (!notificationId.equals(other.notificationId)) + return false; + if (priority == null) { + if (other.priority != null) + return false; + } else if (!priority.equals(other.priority)) + return false; + if (roleIds == null) { + if (other.roleIds != null) + return false; + } else if (!roleIds.equals(other.roleIds)) + return false; + if (roles == null) { + if (other.roles != null) + return false; + } else if (!roles.equals(other.roles)) + return false; + if (startTime == null) { + if (other.startTime != null) + return false; + } else if (!startTime.equals(other.startTime)) + return false; + return true; + } + + @Override + public String toString() { + return "EpNotificationItem [notificationId=" + notificationId + ", isForOnlineUsers=" + isForOnlineUsers + + ", isForAllRoles=" + isForAllRoles + ", activeYn=" + activeYn + ", msgHeader=" + msgHeader + + ", msgDescription=" + msgDescription + ", msgSource=" + msgSource + ", startTime=" + startTime + + ", endTime=" + endTime + ", priority=" + priority + ", creatorId=" + creatorId + ", createdDate=" + + createdDate + ", roles=" + roles + ", roleIds=" + roleIds + "]"; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemExtVO.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemExtVO.java new file mode 100644 index 00000000..4a3dc80d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemExtVO.java @@ -0,0 +1,119 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EpNotificationItemExtVO { + + private Character activeYn; + + private String msgHeader; + + private String msgDescription; + + private Date startTime; + + private Date endTime; + + private Integer priority; + + private Integer creatorId; + + private Date createdDate; + + private String loginId; + + public Character getActiveYn() { + return activeYn; + } + + public void setActiveYn(Character activeYn) { + this.activeYn = activeYn; + } + + public String getMsgHeader() { + return msgHeader; + } + + public void setMsgHeader(String msgHeader) { + this.msgHeader = msgHeader; + } + + public String getMsgDescription() { + return msgDescription; + } + + public void setMsgDescription(String msgDescription) { + this.msgDescription = msgDescription; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getCreatorId() { + return creatorId; + } + + public void setCreatorId(Integer creatorId) { + this.creatorId = creatorId; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemVO.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemVO.java new file mode 100644 index 00000000..d22a4b79 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpNotificationItemVO.java @@ -0,0 +1,191 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +/** + * This is to handle notifications in user notifications and in notification history + */ + +/** + * POJO that models a single notification with the org user ID (not integer + * user_id). + */ +@Entity +public class EpNotificationItemVO extends DomainVo { + + private static final long serialVersionUID = 9095479701352339201L; + + @Id + private Integer notificationId; + + private Character isForOnlineUsers; + + private Character isForAllRoles; + + private Character activeYn; + + private String msgHeader; + + private String msgDescription; + + private String msgSource; + + private Date startTime; + + private Date endTime; + + private Integer priority; + + private Integer creatorId; + + private Date createdDate; + + private String loginId; + + /** + * Answers whether the notification is expired. + * + * @return true if the end time is past the current time, else false. + */ + public boolean isExpired() { + boolean result = false; + if (endTime != null) { + int expired = endTime.compareTo(new Date()); + result = (expired == -1) ? true : false; + } + return result; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public Integer getNotificationId() { + return notificationId; + } + + public void setNotificationId(Integer notificationId) { + this.notificationId = notificationId; + } + + public Character getIsForOnlineUsers() { + return isForOnlineUsers; + } + + public void setIsForOnlineUsers(Character isForOnlineUsers) { + this.isForOnlineUsers = isForOnlineUsers; + } + + public Character getIsForAllRoles() { + return isForAllRoles; + } + + public void setIsForAllRoles(Character isForAllRoles) { + this.isForAllRoles = isForAllRoles; + } + + public Character getActiveYn() { + return activeYn; + } + + public void setActiveYn(Character activeYn) { + this.activeYn = activeYn; + } + + public String getMsgHeader() { + return msgHeader; + } + + public void setMsgHeader(String msgHeader) { + this.msgHeader = msgHeader; + } + + public String getMsgDescription() { + return msgDescription; + } + + public void setMsgDescription(String msgDescription) { + this.msgDescription = msgDescription; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getCreatorId() { + return creatorId; + } + + public void setCreatorId(Integer creatorId) { + this.creatorId = creatorId; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + + public String getMsgSource() { + return msgSource; + } + + public void setMsgSource(String msgSource) { + this.msgSource = msgSource; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpRoleNotificationItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpRoleNotificationItem.java new file mode 100644 index 00000000..66840ed7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EpRoleNotificationItem.java @@ -0,0 +1,90 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +@Entity +@Table(name="ep_role_notification") +public class EpRoleNotificationItem extends DomainVo { + public EpRoleNotificationItem(){}; + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "ID") + public Long id; + + @Column(name = "notification_ID") + public Long notificationId; + + @Column(name = "role_ID") + public Integer roleId; + + @Column(name = "recv_user_id") + public Integer RecvUserId; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getNotificationId() { + return notificationId; + } + + public void setNotificationId(Long notificationId) { + this.notificationId = notificationId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public Integer getRecvUserId() { + return RecvUserId; + } + + public void setRecvUserId(Integer recvUserId) { + RecvUserId = recvUserId; + } + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidget.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidget.java new file mode 100644 index 00000000..569dc138 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidget.java @@ -0,0 +1,138 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +/*package org.openecomp.portalapp.portal.transport; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import com.fasterxml.jackson.annotation.JsonInclude; + +*//** + * This is to handle portal admins + * @author aw3218 + *//* +@Entity +@Table(name="fn_event_widget_data") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EventWidget extends DomainVo{ + + *//** + * + *//* + private static final long serialVersionUID = -2784849102886421352L; + + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "id") + private Long id; + + @Column(name = "category") + private String category; + + @Column(name = "title") + private String title; + + @Column(name = "href") + private String href; + + @Column(name = "content") + private String content; + + @Column(name = "month_val") + private String mon; + + @Column(name = "day_val") + private Integer day; + + @Column(name = "year_val") + private Integer year; + + @Column(name = "sort_order") + private Integer sortOrder; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getMon() { + return mon; + } + + public void setMonth(String mon) { + this.mon = mon; + } + + public Integer getDay() { + return day; + } + + public void setDay(Integer day) { + this.day = day; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + +} +*/ diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidgetMeta.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidgetMeta.java new file mode 100644 index 00000000..2182d7b3 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/EventWidgetMeta.java @@ -0,0 +1,51 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +/*package org.openecomp.portalapp.portal.transport; + +import java.util.List; + +public class EventWidgetMeta { + + private String category; + private List items; + + public EventWidgetMeta(){ + + } + + public EventWidgetMeta(String category, List items){ + this.category = category; + this.items = items; + } + + public String getCategory() { + return category; + } + public void setCategory(String category) { + this.category = category; + } + public List getItems() { + return items; + } + public void setItems(List items) { + this.items = items; + } +} +*/ diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItem.java new file mode 100644 index 00000000..d90dfc1e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItem.java @@ -0,0 +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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + + +/** + * This is to handle functional menu favorites + */ +@Entity +@Table(name="fn_menu_favorites") +public class FavoritesFunctionalMenuItem implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "user_id") + public Long userId; + + @Id + @Column(name = "menu_id") + public Long menuId; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItemJson.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItemJson.java new file mode 100644 index 00000000..e469e0f9 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FavoritesFunctionalMenuItemJson.java @@ -0,0 +1,57 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + + + +/** + * This is to handle functional menu favorites + */ +@Entity +@Table(name="fn_menu_favorites") +public class FavoritesFunctionalMenuItemJson implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "user_id") + public Long userId; + + @Id + @Column(name = "menu_id") + public Long menuId; + + @Column(name = "text") + public String text; + + @Column(name = "url") + public String url; + + @Transient + public Boolean restrictedApp; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FieldsValidator.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FieldsValidator.java new file mode 100644 index 00000000..ab51b7b1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FieldsValidator.java @@ -0,0 +1,125 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +public class FieldsValidator { + + public Long httpStatusCode = new Long(HttpServletResponse.SC_OK); + + public Long errorCode; + + public class FieldName { + + public String name; + + public FieldName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + + public List fields = new ArrayList(); + + public void addProblematicFieldName(String name) { + fields.add(new FieldName(name)); + } + + public Long getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(Long httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public Long getErrorCode() { + return errorCode; + } + + public void setErrorCode(Long errorCode) { + this.errorCode = errorCode; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + @Override + public String toString() { + return "FieldsValidator [httpStatusCode=" + httpStatusCode + ", errorCode=" + errorCode + ", fields=" + fields + + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((errorCode == null) ? 0 : errorCode.hashCode()); + result = prime * result + ((fields == null) ? 0 : fields.hashCode()); + result = prime * result + ((httpStatusCode == null) ? 0 : httpStatusCode.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + FieldsValidator other = (FieldsValidator) obj; + if (errorCode == null) { + if (other.errorCode != null) + return false; + } else if (!errorCode.equals(other.errorCode)) + return false; + if (fields == null) { + if (other.fields != null) + return false; + } else if (!fields.equals(other.fields)) + return false; + if (httpStatusCode == null) { + if (other.httpStatusCode != null) + return false; + } else if (!httpStatusCode.equals(other.httpStatusCode)) + return false; + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItem.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItem.java new file mode 100644 index 00000000..707b08bc --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItem.java @@ -0,0 +1,100 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +@Entity +@Table(name="fn_menu_functional") +public class FunctionalMenuItem implements Serializable { + public FunctionalMenuItem(){}; + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "MENU_ID") + public Long menuId; + + @Column(name = "COLUMN_NUM") + public Integer column; + + @Column(name = "TEXT") + public String text; + + @Column(name = "PARENT_MENU_ID") + public Integer parentMenuId; + + @Column(name = "URL") + public String url; + + @Column(name="ACTIVE_YN") + public String active_yn; + + @Transient + public Integer appid; + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + @Transient + private List roles; + + @Transient + public Boolean restrictedApp; + + public void normalize() { + if (this.column == null) + this.column = new Integer(1); + this.text = (this.text == null) ? "" : this.text.trim(); + if (this.parentMenuId == null) + this.parentMenuId = new Integer(-1); + this.url = (this.url == null) ? "" : this.url.trim(); + } + + @Override + public String toString() { + return "FunctionalMenuItem [menuId=" + menuId + ", column=" + column + ", text=" + text + ", parentMenuId=" + + parentMenuId + ", url=" + url + ", active_yn=" + active_yn + ", appid=" + appid + ", roles=" + roles + + ", restrictedApp=" + restrictedApp + "]"; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItemWithRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItemWithRoles.java new file mode 100644 index 00000000..8e33a5f7 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuItemWithRoles.java @@ -0,0 +1,60 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; +import java.util.List; + +// This type is used to read the Json in from the API call from the Front End +public class FunctionalMenuItemWithRoles implements Serializable { + private static final long serialVersionUID = 1L; + + public Long menuId; + + public Integer column; + + public String text; + + public Integer parentMenuId; + + public String url; + + public Integer appid; + + private List roles; + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public void normalize() { + if (this.column == null) + this.column = new Integer(1); + this.text = (this.text == null) ? "" : this.text.trim(); + if (this.parentMenuId == null) + this.parentMenuId = new Integer(-1); + this.url = (this.url == null) ? "" : this.url.trim(); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuRole.java new file mode 100644 index 00000000..0033b62a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/FunctionalMenuRole.java @@ -0,0 +1,115 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name="fn_menu_functional_roles") +public class FunctionalMenuRole implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "ID") + public Integer id; + + @Column(name = "MENU_ID") + public Long menuId; + + @Column(name = "APP_ID") + public Integer appId; + + @Column(name = "ROLE_ID") + public Integer roleId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Long getMenuId() { + return menuId; + } + + public void setMenuId(Long menuId) { + this.menuId = menuId; + } + + public Integer getAppId() { + return appId; + } + + public void setAppId(Integer appId) { + this.appId = appId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + @Override + public String toString() { + return "FunctionalMenuRole [id=" + id + ", menuId=" + menuId + ", appId=" + appId + ", roleId=" + roleId + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((appId == null) ? 0 : appId.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((menuId == null) ? 0 : menuId.hashCode()); + result = prime * result + ((roleId == null) ? 0 : roleId.hashCode()); + return result; + } + + @Override + public boolean equals(Object o) { + + if (o == this) return true; + if (!(o instanceof FunctionalMenuRole)) { + return false; + } + FunctionalMenuRole functionalMenuRole = (FunctionalMenuRole) o; + System.out.println("test"); + return id.equals(functionalMenuRole.getId()) && + menuId.equals(functionalMenuRole.menuId) && + appId.equals(functionalMenuRole.appId) && + roleId.equals(functionalMenuRole.roleId) ; + } + + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/LocalRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/LocalRole.java new file mode 100644 index 00000000..06fd6aec --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/LocalRole.java @@ -0,0 +1,42 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class LocalRole implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "ROLE_ID") + public Integer roleId; + + @Column(name = "ROLE_NAME") + public String rolename; + + public void normalize() { + this.rolename = (this.rolename == null) ? "" : this.rolename.trim(); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java new file mode 100644 index 00000000..977269d2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java @@ -0,0 +1,99 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +/** + * Model of rows in the fn_app table; serialized as a message add or update an + * on-boarded application. + */ +public class OnboardingApp { + + public Long id; + + public String name; + + public String imageUrl; + + public String description; + + public String notes; + + public String url; + + public String alternateUrl; + + public String restUrl; + + public Boolean isOpen; + + public Boolean isEnabled; + + public Long motsId; + + public String myLoginsAppName; + + public String myLoginsAppOwner; + + public String username; + + public String appPassword; + + public String thumbnail; + + public String uebTopicName; + + public String uebKey; + + public String uebSecret; + + public Boolean restrictedApp; + + /** + * Sets the name, myLoginsAppName, myLoginsAppOwner, username and + * appPassword fields to the empty string OR trims leading/trailing space, + * as appropriate. + */ + public void normalize() { + this.name = (this.name == null) ? "" : this.name.trim(); + this.myLoginsAppName = (this.myLoginsAppName == null) ? "" : this.myLoginsAppName.trim(); + this.myLoginsAppOwner = (this.myLoginsAppOwner == null) ? "" : this.myLoginsAppOwner.trim(); + this.username = (this.username == null) ? "" : this.username.trim(); + this.appPassword = (this.appPassword == null) ? "" : this.appPassword.trim(); + } + + public void setUebTopicName(String topicName) { + this.uebTopicName = topicName; + } + + public void setUebKey(String key) { + this.uebKey = key; + } + + public void setUebSecret(String secret) { + this.uebSecret = secret; + } + + // Hide the implementation of restricted and normal app from the front end. + // The json sent and received will include restrictedApp but not appType. + + public void setRestrictedApp(Boolean restrictedApp) { + this.restrictedApp = restrictedApp; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingWidget.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingWidget.java new file mode 100644 index 00000000..09471d7f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingWidget.java @@ -0,0 +1,65 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class OnboardingWidget implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "WIDGET_ID") + public Long id; + + @Column(name = "WDG_NAME") + public String name; + + @Column(name = "APP_ID") + public Long appId; + + @Column(name = "APP_NAME") + public String appName; + + @Column(name = "WDG_WIDTH") + public Integer width; + + @Column(name = "WDG_HEIGHT") + public Integer height; + + @Column(name = "WDG_URL") + public String url; + + public void normalize() { + this.name = (this.name == null) ? "" : this.name.trim(); + this.appName = (this.appName == null) ? "" : this.appName.trim(); + if (this.width == null) + this.width = new Integer(0); + if (this.height == null) + this.height = new Integer(0); + this.url = (this.url == null) ? "" : this.url.trim(); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdmin.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdmin.java new file mode 100644 index 00000000..0481eb61 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdmin.java @@ -0,0 +1,53 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * This is to handle portal admins + */ +@Entity +@Table(name="fn_user") +public class PortalAdmin implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "user_id") + public Long userId; + + @Column(name = "login_id") + public String loginId; + + @Column(name = "first_name") + public String firstName; + + @Column(name = "last_name") + public String lastName; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdminUserRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdminUserRole.java new file mode 100644 index 00000000..06229fc1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/PortalAdminUserRole.java @@ -0,0 +1,48 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * This is to handle portal admins + */ +@Entity +@Table(name="fn_user_role") +public class PortalAdminUserRole implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "user_id") + public Long userId; + + @Id + @Column(name = "role_id") + public Long roleId; + + @Column(name = "app_id") + public Long appId; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteRole.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteRole.java new file mode 100644 index 00000000..0f152772 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteRole.java @@ -0,0 +1,44 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class RemoteRole { + + private Long id; + private String name; + + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "RemoteRole [id=" + id + ", name=" + name + "]"; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteUserWithRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteUserWithRoles.java new file mode 100644 index 00000000..7095991c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RemoteUserWithRoles.java @@ -0,0 +1,197 @@ +package org.openecomp.portalapp.portal.transport; + +import java.util.ArrayList; +import java.util.List; + +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ + +/** + * User description which we receive in response from request to remote + * application: applicationsRestClientService.get(RemoteUserWithRoles[].class, + * appId, "/users"). It contains the most important info about remote + * application user including his roles in this application. + */ +public class RemoteUserWithRoles { + + private Long orgId; + + private Long managerId; + + private String firstName; + + private String middleInitial; + + private String lastName; + + private String phone; + + private String email; + + private String hrid; + + private String orgUserId; + + private String orgCode; + + private String orgManagerUserId; + + private String jobTitle; + + private String loginId; + + private Boolean active; + + private List roles = new ArrayList(); + + public Long getOrgId() { + return orgId; + } + + public void setOrgId(Long orgId) { + this.orgId = orgId; + } + + public Long getManagerId() { + return managerId; + } + + public void setManagerId(Long managerId) { + this.managerId = managerId; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getMiddleInitial() { + return middleInitial; + } + + public void setMiddleInitial(String middleInitial) { + this.middleInitial = middleInitial; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getHrid() { + return hrid; + } + + public void setHrid(String hrid) { + this.hrid = hrid; + } + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + if(this.orgUserId == null) + this.orgUserId = orgUserId; + } + + public String getOrgCode() { + return orgCode; + } + + public void setOrgCode(String orgCode) { + this.orgCode = orgCode; + } + + public String getOrgManagerUserId() { + return orgManagerUserId; + } + + public void setOrgManagerUserId(String orgManagerUserId) { + this.orgManagerUserId = orgManagerUserId; + } + + public String getJobTitle() { + return jobTitle; + } + + public void setJobTitle(String jobTitle) { + this.jobTitle = jobTitle; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + @Override + public String toString() { + return "RemoteUserWithRoles [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + + ", middleInitial=" + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", email=" + + email + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", orgManagerUserId=" + + orgManagerUserId + ", jobTitle=" + jobTitle + ", loginId=" + loginId + ", active=" + active + + ", roles=" + roles + "]"; + } + + + + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RoleInAppForUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RoleInAppForUser.java new file mode 100644 index 00000000..dad1c98b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RoleInAppForUser.java @@ -0,0 +1,105 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class RoleInAppForUser { + + + public RoleInAppForUser() { + } + + public RoleInAppForUser(Long id, String name) { + this.roleId = id; + this.roleName = name; + } + + public Long roleId; + + public String roleName; + + public Boolean isApplied; + + public Long getRoleId() { + return roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public Boolean getIsApplied() { + return isApplied; + } + + public void setIsApplied(Boolean isApplied) { + this.isApplied = isApplied; + } + + @Override + public String toString() { + return "RoleInAppForUser [roleId=" + roleId + ", roleName=" + roleName + ", isApplied=" + isApplied + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((isApplied == null) ? 0 : isApplied.hashCode()); + result = prime * result + ((roleId == null) ? 0 : roleId.hashCode()); + result = prime * result + ((roleName == null) ? 0 : roleName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RoleInAppForUser other = (RoleInAppForUser) obj; + if (isApplied == null) { + if (other.isApplied != null) + return false; + } else if (!isApplied.equals(other.isApplied)) + return false; + if (roleId == null) { + if (other.roleId != null) + return false; + } else if (!roleId.equals(other.roleId)) + return false; + if (roleName == null) { + if (other.roleName != null) + return false; + } else if (!roleName.equals(other.roleName)) + return false; + return true; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RolesInAppForUser.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RolesInAppForUser.java new file mode 100644 index 00000000..8720304d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/RolesInAppForUser.java @@ -0,0 +1,33 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.ArrayList; +import java.util.List; + +public class RolesInAppForUser { + + public String orgUserId; + + public Long appId; + + public List roles = new ArrayList(); + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserApplicationRoles.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserApplicationRoles.java new file mode 100644 index 00000000..75aba7ab --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserApplicationRoles.java @@ -0,0 +1,86 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +import java.util.ArrayList; +import java.util.List; + +/** + * A specific application user and his application specific roles. + * + */ +public class UserApplicationRoles { + + private Long appId; + + private String orgUserId; + + private String firstName; + + private String lastName; + + private List roles = new ArrayList(); + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public String getOrgUserId() { + return orgUserId; + } + + public void setOrgUserId(String orgUserId) { + this.orgUserId = orgUserId; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + @Override + public String toString() { + return "UserApplicationRoles [appId=" + appId + ", orgUserId=" + orgUserId + ", firstName=" + firstName + + ", lastName=" + lastName + ", roles=" + roles + "]"; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserWithNameSurnameTitle.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserWithNameSurnameTitle.java new file mode 100644 index 00000000..ba411e65 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/UserWithNameSurnameTitle.java @@ -0,0 +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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +public class UserWithNameSurnameTitle { + + public String orgUserId; + + public String firstName; + + public String lastName; + + public String jobTitle; + + public UserWithNameSurnameTitle(String orgUserId, String firstName, String lastName, String jobTitle) { + this.orgUserId = orgUserId; + this.firstName = firstName; + this.lastName = lastName; + this.jobTitle = jobTitle; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/WidgetCatalogPersonalization.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/WidgetCatalogPersonalization.java new file mode 100644 index 00000000..5117e8f2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/transport/WidgetCatalogPersonalization.java @@ -0,0 +1,57 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.transport; + +/** + * Model for the object PUT to the controller when the user takes an action on + * a widget in the catalog. + */ + +public class WidgetCatalogPersonalization { + + public Long widgetId; + public Boolean select; + // not needed as only 'SHOW' and 'HIDE' status_cd is expected from the micro service now + //public Boolean pending; + + public Long getWidgetId() { + return widgetId; + } + + public void setWidgetId(Long widgetId) { + this.widgetId = widgetId; + } + + public Boolean getSelect() { + return select; + } + + public void setSelect(Boolean select) { + this.select = select; + } + + /*public Boolean getPending() { + return pending; + } + + public void setPending(Boolean pending) { + this.pending = pending; + }*/ +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java new file mode 100644 index 00000000..3c447e2a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java @@ -0,0 +1,217 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ueb; + +import java.net.HttpURLConnection; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +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.portalapp.portal.domain.EPApp; +import org.openecomp.portalapp.portal.domain.EcompApp; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.EPAppService; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Component +@Transactional +@org.springframework.context.annotation.Configuration +@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 + // + @SuppressWarnings("unused") + @EPMetricsLog + public void refreshPublisherList() + { + Session localSession = null; + 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()); + 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){ + UebManager.getInstance().removePublisher(apps.get(i).getUebTopicName()); + } + } + } + } + catch (Exception e) + { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebSystemError, e, "add/remove Publisher"); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while refreshing the publisher list", e); + } + + //publisherList.print(); + + if (addedPublisher == true) // Give publishers time to initialize + { + Helper.sleep(400); + } + } + + @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)); + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebConnectionError, e); + String stackTrace = EcompPortalUtils.getStackTrace(e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while initializing the publisher. Details: " + stackTrace); + } + + Thread thread = new Thread("EPUebManager: postConstructMethod - refreshPublisherList") { + public void run(){ + refreshPublisherList(); + } + }; + if (thread != null) { + thread.start(); + } + } + + @EPMetricsLog + public void addPublisher(EPApp app) { + // TODO Auto-generated method stub + 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); + } + } + + public boolean checkAvailability() { + + // + // Test existence of topic at UEB url + // + // (ie http://uebsb91kcdc.it.att.com:3904/topics/ECOMP-PORTAL-INBOX) + // + 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(logger, 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); + } + } + } + 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(logger, EPAppMessagesEnum.BeHealthCheckUebClusterError, e); + 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-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java new file mode 100644 index 00000000..aef02545 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java @@ -0,0 +1,27 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.ueb; + +import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes; + +public interface EPUebMsgTypes extends UebMsgTypes { + + public static final String UEB_MSG_TYPE_HEALTH_CHECK = "uebHealthCheckPing"; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/CustomLoggingFilter.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/CustomLoggingFilter.java new file mode 100644 index 00000000..a43f5177 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/CustomLoggingFilter.java @@ -0,0 +1,54 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + +/** + * Custom Filter class bind with logback.xml + * configuration file to strip out certain log messages + * coming out of special packages or classes. + * + */ +public class CustomLoggingFilter extends Filter { + + /** + * Custom Filter is added to strip out the continuous U-EB logging messages + * But make sure we log the ERROR & WARNING Level messages. + */ + @Override + public FilterReply decide(ILoggingEvent event) { + try { + if ((event.getLevel() != Level.ERROR || event.getLevel() != Level.WARN) && + (event.getThreadName().equalsIgnoreCase("UEBConsumerThread")) && + (event.getLoggerName().contains("org.openecomp.nsa") || event.getLoggerName().contains("org.apache.http")) + ) { + return FilterReply.DENY; + } else { + return FilterReply.NEUTRAL; + } + } catch(Exception e) { + return FilterReply.NEUTRAL; + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java new file mode 100644 index 00000000..38b6608a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java @@ -0,0 +1,64 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +import org.openecomp.portalsdk.core.util.SystemProperties; + +public class EPCommonSystemProperties extends SystemProperties { + + public static final String LOGIN_URL_NO_RET_VAL = "login_url_no_ret_val"; + public static final String ECOMP_APP_ID = "ecomp_app_id"; + public static final String SYS_ADMIN_ROLE_ID = "sys_admin_role_id"; + public static final String DUBLICATED_FIELD_VALUE_ECOMP_ERROR = "1201"; + public static final String ACCOUNT_ADMIN_ROLE_ID = "account_admin_role_id"; + public static final String RESTRICTED_APP_ROLE_ID = "restricted_app_role_id"; + public static final String FE_URL = "frontend_url"; + public static final String HEALTH_POLL_INTERVAL_SECONDS = "health_poll_interval_seconds"; + public static final String HEALTHFAIL_ALERT_EVERY_X_INTERVALS = "health_fail_alert_every_x_intervals"; + public static final String USER_GUIDE_URL = "user_guide_link"; + + public static final String USER_FIRST_NAME = "USER_FIRST_NAME"; + public static final String USER_LAST_NAME = "USER_LAST_NAME"; + public static final String USER_EMAIL = "USER_EMAIL"; + public static final String USER_ORG_USERID = "USER_ORG_USERID"; + + public static final String USH_TICKET_URL = "ush_ticket_url"; + + public static final String EXTERNAL_API_RESPONSE_CODE = "External_API_ResponseCode"; + public static final String COOKIE_DOMAIN = "cookie_domain"; + + public static final String FEEDBACK_EMAIL_ADDRESS = "feedback_email_address"; + public static final String PORTAL_INFO_URL = "portal_info_url"; + + public static final String ONLINE_USER_UPDATE_RATE = "online_user_update_rate"; + public static final String ONLINE_USER_UPDATE_DURATION = "online_user_update_duration"; + + public static final String NOTIFICATION_UPDATE_RATE = "notification_update_rate"; + public static final String NOTIFICATION_UPDATE_DURATION = "notification_update_duration"; + + public static final String WINDOW_WIDTH_THRESHOLD_LEFT_MENU = "window_width_threshold_left_menu"; + public static final String WINDOW_WIDTH_THRESHOLD_RIGHT_MENU = "window_width_threshold_right_menu"; + + public static final String AUDITLOG_DEL_DAY_FROM = "auditlog_del_day_from"; + public static final String AUDITLOG_DELETE_CRON = "auditlog_delete_cron"; + + public static final String AUTH_USER_SERVER = "auth_user_server"; + public static final String EXTERNAL_ACCESS_ENABLE = "external_access_enable"; +} \ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java new file mode 100644 index 00000000..adf36b2b --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java @@ -0,0 +1,331 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.slf4j.MDC; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class EcompPortalUtils { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EcompPortalUtils.class); + + /** + * @param orgUserId + * @return true if orgUserId is not empty and contains only alphanumeric, + * false otherwise + */ + public static boolean legitimateUserId(String orgUserId) { + return orgUserId.matches("^[a-zA-Z0-9]+$"); + } + + /** + * Splits the string into a list of tokens using the specified regular + * expression + * + * @param source + * @param regex + * @return List of tokens split from the source + */ + public static List parsingByRegularExpression(String source, String regex) { + List tokens = new ArrayList(); + if (source != null && source.length() > 0) { + String[] parsed = source.split(regex); + for (String token : parsed) { + if (token.length() > 0) { + tokens.add(token); + } + } + } + return tokens; + } + + /** + * Builds a JSON object with error code and message information. + * + * @param errorCode + * @param errorMessage + * @return JSON object as a String + */ + public static String jsonErrorMessageResponse(int errorCode, String errorMessage) { + return "{\"error\":{\"code\":" + errorCode + "," + "\"message\":\"" + errorMessage + "\"}}"; + } + + /** + * Builds a JSON object with the specified message + * + * @param message + * @return JSON object as a String + */ + public static String jsonMessageResponse(String message) { + return String.format("{\"message\":\"%s\"}", message); + } + + /** + * Serializes the specified object as JSON and writes the result to the + * debug log. If serialization fails, logs a message to the error logger. + * + * @param logger + * Logger for the class where the object was built; the logger + * carries the class name. + * @param source + * First portion of the log message + * @param msg + * Second portion of the log message + * @param obj + * Object to serialize as JSON + */ + public static void logAndSerializeObject(EELFLoggerDelegate logger, String source, String msg, Object obj) { + try { + String objectAsJson = new ObjectMapper().writeValueAsString(obj); + logger.debug(EELFLoggerDelegate.debugLogger, + String.format("source= [%s]; %s [%s];", source, msg, objectAsJson)); + } catch (JsonProcessingException e) { + logger.warn(EELFLoggerDelegate.errorLogger, "logAndSerializedObject failed to serialize", e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "logAndSerializedObject failed", e); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + } + } + + /** + * Serializes the specified object as JSON and writes the result to the + * debug log. If serialization fails, logs a message to the error logger. + * + * @param source + * First portion of the log message + * @param msg + * Second portion of the log message + * @param obj + * Object to serialize as JSON + */ + public static void logAndSerializeObject(String source, String msg, Object obj) { + logAndSerializeObject(logger, source, msg, obj); + } + + public static void rollbackTransaction(Transaction transaction, String errorMessage) { + logger.error(EELFLoggerDelegate.errorLogger, errorMessage); + try { + if (transaction != null) { + transaction.rollback(); + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeExecuteRollbackError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing a rollback transaction", + e); + } + } + + public static void closeLocalSession(Session localSession, String errorMessage) { + logger.error(EELFLoggerDelegate.errorLogger, errorMessage); + try { + if (localSession != null) { + localSession.close(); + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoCloseSessionError, e); + logger.error(EELFLoggerDelegate.errorLogger, errorMessage + ", closeLocalSession exception", e); + } + } + + // TODO: GLOBAL_LOGIN_URL is the same as in SessionTimeoutInterceptor. + // It should be defined in SystemProperties. + private static final String GLOBAL_LOGIN_URL = "global-login-url"; + + /** + * Set response status to Unauthorized if user == null and to Forbidden in + * all (!) other cases. Logging is not performed if invocator == null + * + * @param user + * @param response + * @param invocator + * - may be null + */ + public static void setBadPermissions(EPUser user, HttpServletResponse response, String invocator) { + if (user == null) { + String loginUrl = SystemProperties.getProperty(EPCommonSystemProperties.LOGIN_URL_NO_RET_VAL); + response.setHeader(GLOBAL_LOGIN_URL, loginUrl); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_UNAUTHORIZED)); + } else { + response.setStatus(HttpServletResponse.SC_FORBIDDEN); + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_FORBIDDEN)); + } + if (invocator != null) { + logger.warn(EELFLoggerDelegate.errorLogger, + invocator + ", permissions problem, response status = " + response.getStatus()); + } + } + + public static int getExternalAppResponseCode() { + String responseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + int responseCodeInt = 0; + try { + if (responseCode != null && responseCode != "") { + responseCodeInt = Integer.valueOf(responseCode); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred in getResponseCode(). Details: " + EcompPortalUtils.getStackTrace(e)); + } + return responseCodeInt; + } + + // This method might be just for testing purposes. + public static void setExternalAppResponseCode(int responseCode) { + try { + String responseCodeString = String.valueOf(responseCode); + MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, responseCodeString); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred in setResponseCode(). Details: " + EcompPortalUtils.getStackTrace(e)); + } + } + + public static String getHTTPStatusString(int httpStatusCode) { + String httpStatusString = "unknown_error"; + try { + httpStatusString = org.springframework.http.HttpStatus.valueOf(httpStatusCode).name(); + if (httpStatusString != null) { + httpStatusString = httpStatusString.toLowerCase(); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred in getHTTPStatusString(). Details: " + EcompPortalUtils.getStackTrace(e)); + } + return httpStatusString; + } + + public static String getFEErrorString(Boolean internal, int responseCode) { + // Return a String like the following: + // "Internal Ecomp Error: 500 internal_server_error" or + // "External App Error: 404 not_found" + // TODO: create our own Ecomp error codes, starting with 1000 and up. + String responseString = ""; + String internalExternalString = internal ? "Ecomp Error: " : "App Error: "; + String httpStatusString = "unknown_error"; + try { + if (responseCode < 1000) { + httpStatusString = getHTTPStatusString(responseCode); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred in getFEErrorString(). Details: " + EcompPortalUtils.getStackTrace(e)); + } + responseString = internalExternalString + responseCode + " " + httpStatusString; + return responseString; + } + + public static boolean isProductionBuild() { + boolean productionBuild = true; + String epVersion = EcompVersion.buildNumber; + if (epVersion != null) { + int buildNum = epVersion.lastIndexOf('.'); + if (buildNum > 0) { + int buildNumber = Integer.parseInt(epVersion.substring(buildNum + 1)); + if (buildNumber < 3000) // Production versions are 3000+, (ie + // 1.0.3003) + { + productionBuild = false; + } + } + } + return productionBuild; + } + + private static final Object stackTraceLock = new Object(); + + public static String getStackTrace(Throwable t) { + synchronized (stackTraceLock) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + return sw.toString(); + } + } + + public static String getMyIpAdddress() { + InetAddress ip; + String localIp; + try { + ip = InetAddress.getLocalHost(); + localIp = ip.getHostAddress(); + } catch (UnknownHostException e) { + localIp = "unknown"; + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + return localIp; + } + + public static String getMyHostName() { + InetAddress ip; + String hostName; + try { + ip = InetAddress.getLocalHost(); + hostName = ip.getHostName(); + } catch (UnknownHostException e) { + hostName = "unknown"; + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + return hostName; + } + + /* return a default property if the expected one is not available */ + public static String getPropertyOrDefault(String property, String defaultValue) { + return ((null == SystemProperties.getProperty(property) || SystemProperties.getProperty(property).equals("")) + ? defaultValue : SystemProperties.getProperty(property)); + } + + public static void calculateDateTimeDifferenceForLog(String beginDateTime, String endDateTime) { + if (beginDateTime != null && endDateTime != null) { + try { + SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + + Date beginDate = ecompLogDateFormat.parse(beginDateTime); + Date endDate = ecompLogDateFormat.parse(endDateTime); + String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime()); + MDC.put(SystemProperties.MDC_TIMER, timeDifference); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompVersion.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompVersion.java new file mode 100644 index 00000000..a4d5e0c1 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompVersion.java @@ -0,0 +1,33 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +// +// Hardcoded for now, wanted to use maven and resource file. Possibly just read +// pom.properties file with version added, but spent several hours already running +// into issues with that and other ideas not working. So, for 1604 deadlines I +// am just putting the version in the code here... for now. +// +public final class EcompVersion { + + // TODO - not used - manifest service reads from manifest + public static final String buildNumber="1610.1.999"; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/HashMapFromList.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/HashMapFromList.java new file mode 100644 index 00000000..3a781af9 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/HashMapFromList.java @@ -0,0 +1,99 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +/** + * + * @author Vladimir Turovets This class is used to create HashMap + * from the list of T objects. We suppose that + * 1) T object contains field 'parmName' or getter 'getParmName()'. + * The value of object.parmName or object.getParmName() is used as + * a key in created hashMap. + * 2) for all objects in the list 'parmName' or getter + * 'getParmName().toString' has to be unique and not null. + * This class has one function only: + * HashMap hashMap(List list, String name) and returns + * hash map created from list. + * + * @param + */ +public class HashMapFromList { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HashMapFromList.class); + + public HashMap hashMap(List list, String name) { + HashMap result = new HashMap(); + if (list == null || list.size() == 0 || name == null) { + return result; + } + name = name.trim(); + if (name.length() > 0) { + T object = list.get(0); + try { + String parmName = name; + Field field = object.getClass().getField(parmName); + for (T obj : list) { + try { + Object o = field.get(obj); + if (o != null) + result.put(o.toString(), obj); + } catch (Exception e1) { + String stackTrace = EcompPortalUtils.getStackTrace(e1); + logger.error(EELFLoggerDelegate.errorLogger, "Object of class " + object.getClass().getName() + ", field " + parmName + ". Details: ", stackTrace); + return new HashMap(); + } + } + } catch (Exception e) { + String getterName = "get" + (name.length() == 1 ? name.toUpperCase() : (name.substring(0, 1).toUpperCase() + name.substring(1))); + try { + Class[] parmClasses = null; + Method method = object.getClass().getMethod(getterName, parmClasses); + Object[] parmValues = new Object[0]; + for (T obj : list) { + try { + Object o = method.invoke(obj, parmValues); + if (o != null) + result.put(o.toString(), obj); + } catch (Exception e2) { + String stackTrace = EcompPortalUtils.getStackTrace(e2); + logger.error(EELFLoggerDelegate.errorLogger, "Object of class " + object.getClass().getName() + ", method " + getterName + ". Details: ", stackTrace); + return new HashMap(); + } + } + } catch (Exception e3) { + String stackTrace = EcompPortalUtils.getStackTrace(e3); + logger.error(EELFLoggerDelegate.errorLogger, "Object of class " + object.getClass().getName() + ", bad field '" + name + "' or method '" + getterName + "()'. Details: " + stackTrace); + return new HashMap(); + } + } + } + if (list.size() != result.size()) { + logger.warn(EELFLoggerDelegate.errorLogger, "Duplicated or empty keys were found!!!"); + } + return result; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/ParallelExecutor.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/ParallelExecutor.java new file mode 100644 index 00000000..1ddb550d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/ParallelExecutor.java @@ -0,0 +1,83 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; + +public abstract class ParallelExecutor { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ParallelExecutor.class); + + protected static abstract class ThreadOperation { + public abstract T execute(List parms); + } + + protected abstract ThreadOperation getThreadOperation(); + + private static class CallableOperationThread implements Callable { + + List parms; + + private ThreadOperation operation; + + public CallableOperationThread(ThreadOperation operation, List parms) { + this.parms = parms; + this.operation = operation; + } + + @Override + public T call() throws Exception { + return this.operation.execute(this.parms); + } + + } + + public List performAllOperations(int ThreadPoolSize, List> listOfParms) { + List result = new ArrayList(); + if (ThreadPoolSize > 0 && listOfParms != null) { + ExecutorService executor = Executors.newFixedThreadPool(ThreadPoolSize); + List> list = new ArrayList>(); + for (List parms : listOfParms) { + CallableOperationThread getter = new CallableOperationThread(this.getThreadOperation(), parms); + Future submit = executor.submit(getter); + list.add(submit); + } + for (Future future : list) { + try { + if (future != null) { + result.add(future.get()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + } + executor.shutdown(); + } + return result; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/PortalConstants.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/PortalConstants.java new file mode 100644 index 00000000..a0dc7d68 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/PortalConstants.java @@ -0,0 +1,26 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.portal.utils; + +public interface PortalConstants { + public static final Long PORTAL_APP_ID = 1L; + public static final Long DEFAULT_NOTIFICATION_CREATOR = 1L; + public static final String REST_AUX_API = "/auxapi"; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/AdminAuthExtension.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/AdminAuthExtension.java new file mode 100644 index 00000000..3585f3a4 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/AdminAuthExtension.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalapp.portal.domain.EPUser; + + +@Service("adminAuthExtension") +@Transactional +public class AdminAuthExtension { + + public void saveUserExtension(EPUser user){ + //app's developer implement their own logic here, like updating app's related tables + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileService.java new file mode 100644 index 00000000..0adde120 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileService.java @@ -0,0 +1,36 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service; + +import java.util.List; + +import org.openecomp.portalsdk.core.domain.Profile; +import org.openecomp.portalapp.portal.domain.EPUser; + + +public interface EPProfileService { + List findAll(); + + Profile getProfile(int id); + + EPUser getUser(String id); + + void saveUser(EPUser user); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileServiceImpl.java new file mode 100644 index 00000000..27975971 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/EPProfileServiceImpl.java @@ -0,0 +1,77 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import org.openecomp.portalsdk.core.dao.ProfileDao; +import org.openecomp.portalsdk.core.domain.Profile; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; + +@Service("epProfileService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class EPProfileServiceImpl implements EPProfileService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPProfileServiceImpl.class); + + @Autowired + private ProfileDao profileDao; + + @Autowired + private DataAccessService dataAccessService; + + @SuppressWarnings("unchecked") + public List findAll() { + // List msgDB = getDataAccessService().getList(Profile.class, null); + return getDataAccessService().getList(Profile.class, null); + } + + public EPUser getUser(String userId) { + return (EPUser) getDataAccessService().getDomainObject(EPUser.class, Long.parseLong(userId), null); + } + + public void saveUser(EPUser user) { + + getDataAccessService().saveDomainObject(user, null); + } + + public Profile getProfile(int id) { + return profileDao.getProfile(id); + } + + public DataAccessService getDataAccessService() { + return dataAccessService; + } + + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallService.java new file mode 100644 index 00000000..71d9dd12 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallService.java @@ -0,0 +1,48 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service; + +public interface RemoteWebServiceCallService { + + /** + * Answers whether the specified credentials match application information + * in the database. + * + * @param secretKey + * Key used to decrypt passwords; ignored if null. + * @param requestUebKey + * UEB key that identifies the application + * @param requesUserName + * User name for the application + * @param requestPassword + * Password for the application + * @return True if the UEB key and the credentials match the database + * entries; else false. + * @throws Exception + * If decryption fails. + */ + public boolean verifyRESTCredential(String secretKey, String requestUebKey, String requestUserName, + String requestPassword) throws Exception; + + + + public boolean verifyAppKeyCredential(String requestUebKey) throws Exception; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/CoreTimeoutHandler.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/CoreTimeoutHandler.java new file mode 100644 index 00000000..897d9cd9 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/CoreTimeoutHandler.java @@ -0,0 +1,166 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service.sessionmgt; + +import java.util.Calendar; +import java.util.Hashtable; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalsdk.core.domain.sessionmgt.TimeoutVO; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + + +@Service +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class CoreTimeoutHandler{ + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CoreTimeoutHandler.class); + + public static final Map sessionMap = new Hashtable(); + public static final Integer repeatInterval = 15 * 60; // 15 minutes + ObjectMapper mapper = new ObjectMapper(); + + + public static void sessionCreated(String portalJSessionId, String jSessionId, HttpSession session) { + + storeMaxInactiveTime(session); + + // this key is a combination of portal jsession id and app session id + session.setAttribute(PortalApiConstants.PORTAL_JSESSION_ID,jSessionKey(jSessionId, portalJSessionId)); + sessionMap.put((String)session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID), session); + + } + + protected static void storeMaxInactiveTime(HttpSession session) { + + if(session.getAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME) == null) + session.setAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME,session.getMaxInactiveInterval()); + } + + public static void sessionDestroyed(HttpSession session) { + + try{ + sessionMap.remove((String)session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID)); + }catch(Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, "************************ Session Management: Error while destroying session for " + session.getId() + " Details: " + EcompPortalUtils.getStackTrace(e)); + } + + } + + public String gatherSessionExtenstions() { + + Map sessionTimeoutMap = new Hashtable(); + String jsonMap = ""; + + + for(String jSessionKey: sessionMap.keySet()) { + + try{ + // get the expirytime in seconds + HttpSession session = sessionMap.get(jSessionKey); + + Long lastAccessedTimeMilliSec = session.getLastAccessedTime(); + Long maxIntervalMilliSec = session.getMaxInactiveInterval() * 1000L; + //Long currentTimeMilliSec = Calendar.getInstance().getTimeInMillis() ; + //(maxIntervalMilliSec - (currentTimeMilliSec - lastAccessedTimeMilliSec) + ; + Calendar instance = Calendar.getInstance(); + instance.setTimeInMillis(session.getLastAccessedTime()); + logger.info(EELFLoggerDelegate.errorLogger, "************************ Session Management: Last Accessed time for "+ jSessionKey + ": " + instance.getTime()); + + Long sessionTimOutMilliSec = maxIntervalMilliSec + lastAccessedTimeMilliSec; + + sessionTimeoutMap.put( portalJSessionId(jSessionKey), new TimeoutVO(jSessionId(jSessionKey),sessionTimOutMilliSec)); + + + jsonMap = mapper.writeValueAsString(sessionTimeoutMap); + } catch(Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "************************ Session Management: Error during JsonSessionTimout conversion. Details: " + EcompPortalUtils.getStackTrace(e)); + } + } + + return jsonMap; + + } + + + public void updateSessionExtensions(String sessionTimeoutMapStr) throws Exception { + + //Map sessionTimeoutMap = mapper.readValue(sessionTimeoutMapStr, Map.class); + Map sessionTimeoutMap; + try{ + TypeReference> typeRef + = new TypeReference>() {}; + + sessionTimeoutMap = mapper.readValue(sessionTimeoutMapStr, typeRef); + }catch(Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, "************************ Session Management: Error while to parse update session extension in portal", e); + return; + } + for(String jPortalSessionId: sessionTimeoutMap.keySet()) { + try { + + TimeoutVO extendedTimeoutVO = mapper.readValue(mapper.writeValueAsString(sessionTimeoutMap.get(jPortalSessionId)),TimeoutVO.class); + HttpSession session = sessionMap.get(jSessionKey(extendedTimeoutVO.getjSessionId(), jPortalSessionId)); + + if(session == null) { + continue; + } + + Long lastAccessedTimeMilliSec = session.getLastAccessedTime(); + Long maxIntervalMilliSec = session.getMaxInactiveInterval() * 1000L; + Long sessionTimOutMilliSec = maxIntervalMilliSec + lastAccessedTimeMilliSec; + + Long maxTimeoutTimeMilliSec = extendedTimeoutVO.getSessionTimOutMilliSec(); + if(maxTimeoutTimeMilliSec>sessionTimOutMilliSec) { + logger.debug(EELFLoggerDelegate.debugLogger, "************************ Session Management: " + " updated session max idle time"); + session.setMaxInactiveInterval((int)(maxTimeoutTimeMilliSec-lastAccessedTimeMilliSec)/1000); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "************************ Session Management: " + EcompPortalUtils.getStackTrace(e)); + } + + } + + } + + protected static String jSessionKey(String jSessionId, String portalJSessionId) { + return portalJSessionId + "-" + jSessionId; + } + + protected String portalJSessionId(String jSessionKey) { + return jSessionKey.split("-")[0]; + } + + protected String jSessionId(String jSessionKey) { + return jSessionKey.split("-")[1]; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/ManageService.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/ManageService.java new file mode 100644 index 00000000..52cc0825 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/ManageService.java @@ -0,0 +1,101 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service.sessionmgt; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.service.EPAppService; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.quartz.CronExpression; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +@Service("manageService") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class ManageService implements PortalTimeoutHandler.SessionCommInf { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManageService.class); + + @Autowired + EPAppService appService; + + @Autowired + SessionCommunication sessionCommunication; + + public Integer fetchSessionSlotCheckInterval(String... params) throws Exception { + + String defaultCronExpressionStr = "0 0/5 * * * ? *"; + String cronExpressionStr = SystemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON); + + if (cronExpressionStr == null) { + cronExpressionStr = defaultCronExpressionStr; + } + + CronExpression cal = new CronExpression(cronExpressionStr); + final Date nowTime = Calendar.getInstance().getTime(); + Date nextTime = cal.getNextValidTimeAfter(nowTime); + Date nextNextTime = cal.getNextValidTimeAfter(nextTime); + + final int timeDiff = (int)(nextNextTime.getTime()-nextTime.getTime()); + logger.debug(EELFLoggerDelegate.debugLogger, "Time interval between subsequent session checks " + timeDiff); + + return timeDiff; + } + + public void extendSessionTimeOuts(String... params) throws Exception { + try { + String sessionMap = params[3]; + + logger.debug(EELFLoggerDelegate.debugLogger, "Extending the App sessions for last minute request: " + sessionMap); + + if (StringUtils.isEmpty(sessionMap)) { + logger.error(EELFLoggerDelegate.errorLogger, "extendSessionTimeOuts: Skipping session updates since the portal session value is empty."); + } else { + List appList = appService.getEnabledNonOpenOnboardingApps(); + for (OnboardingApp onApp : appList) { + sessionCommunication.pingSession(onApp, sessionMap); + } + updateSessionExtensions(sessionMap); + sessionCommunication.clear(false); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in extendSessionTimeOuts(). Details: " + EcompPortalUtils.getStackTrace(e)); + } + } + + public String gatherSessionExtenstions() { + return PortalTimeoutHandler.gatherSessionExtensions(); + } + + public void updateSessionExtensions(String sessionTimeoutMapStr) throws Exception { + PortalTimeoutHandler.updateSessionExtensions(sessionTimeoutMapStr); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/SessionCommunication.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/SessionCommunication.java new file mode 100644 index 00000000..11c0890e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/SessionCommunication.java @@ -0,0 +1,271 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service.sessionmgt; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.UUID; + +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.MDC; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import com.att.eelf.configuration.Configuration; +import org.openecomp.portalsdk.core.exception.UrlAccessRestrictedException; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; + +@Service("sessionCommunication") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +public class SessionCommunication { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionCommunication.class); + + @EPAuditLog + public String sendGet(OnboardingApp app) throws Exception { + String appResponse = ""; + String appName = "Unknwon"; + int responseCode = 0; + + try { + if (app != null && app.name != null && app.name != "") { + appName = app.name; + } + String url = app.restUrl + "/sessionTimeOuts"; + String encriptedPwdDB = app.appPassword; + String appUserName = app.username; + + setLocalMDCContext(app, "/sessionTimeOuts", url); + + URL obj = new URL(url); + + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // optional default is GET + con.setRequestMethod("GET"); + con.setConnectTimeout(3000); + con.setReadTimeout(8000); + // add request header + con.setRequestProperty("username", appUserName); + con.setRequestProperty("password", encriptedPwdDB); + + // con.set + responseCode = con.getResponseCode(); + logger.debug(EELFLoggerDelegate.debugLogger, "Response Code : " + responseCode); + + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + StringBuffer response = new StringBuffer(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + + in.close(); + appResponse = response.toString(); + } catch (UrlAccessRestrictedException e) { + responseCode = HttpServletResponse.SC_UNAUTHORIZED; + logger.error(EELFLoggerDelegate.errorLogger, String.format("SessionCommunication.sendGet received an un-authorized exception. AppName: %s", appName)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiAuthenticationError, e); + } catch (Exception e) { + responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + String message = String.format( + "SessionCommunication.sendGet encountered an Exception. AppName: %s, Details: %s", appName, + EcompPortalUtils.getStackTrace(e)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHttpConnectionError, e); + logger.error(EELFLoggerDelegate.errorLogger, message); + } finally { + EcompPortalUtils.setExternalAppResponseCode(responseCode); + } + return appResponse; + } + + @EPAuditLog + public Boolean pingSession(OnboardingApp app, String sessionTimeoutMap) throws Exception { + String appName = "Unknwon"; + int responseCode = 0; + try { + if (app != null && app.name != null && app.name != "") { + appName = app.name; + } + + String url = app.restUrl + "/updateSessionTimeOuts"; + String encriptedPwdDB = app.appPassword; + String appUserName = app.username; + // String decreptedPwd = CipherUtil.decrypt(encriptedPwdDB, + // SystemProperties.getProperty(SystemProperties.Decryption_Key)); + + setLocalMDCContext(app, "/updateSessionTimeOuts", url); + + URL obj = new URL(url); + + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // optional default is GET + con.setRequestMethod("POST"); + con.setConnectTimeout(3000); + con.setReadTimeout(15000); + + // add request header + con.setRequestProperty("username", appUserName); + con.setRequestProperty("password", encriptedPwdDB); + + con.setRequestProperty("sessionMap", sessionTimeoutMap); + con.setDoInput(true); + con.setDoOutput(true); + con.getOutputStream().write(sessionTimeoutMap.getBytes()); + con.getOutputStream().flush(); + con.getOutputStream().close(); + + responseCode = con.getResponseCode(); + logger.debug(EELFLoggerDelegate.debugLogger, "Response Code : " + responseCode); + } catch (UrlAccessRestrictedException e) { + responseCode = HttpServletResponse.SC_UNAUTHORIZED; + String message = String.format( + "SessionCommunication.pingSession received an un-authorized exception. AppName: %s", appName); + logger.error(EELFLoggerDelegate.errorLogger, message); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiAuthenticationError, e); + } catch (Exception e) { + responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + String message = String.format( + "SessionCommunication.pingSession encountered an Exception. AppName: %s, Details: %s", appName, + EcompPortalUtils.getStackTrace(e)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHttpConnectionError, e); + logger.error(EELFLoggerDelegate.errorLogger, message); + } finally { + EcompPortalUtils.setExternalAppResponseCode(responseCode); + } + + return true; + } + + @EPAuditLog + public Boolean timeoutSession(OnboardingApp app, String portalJSessionId) throws Exception { + String appName = "Unknwon"; + int responseCode = 0; + try { + if (app != null && app.name != null && app.name != "") { + appName = app.name; + } + + String url = app.restUrl + "/timeoutSession" + "?portalJSessionId=" + portalJSessionId; + + String encriptedPwdDB = app.appPassword; + String appUserName = app.username; + // String decreptedPwd = CipherUtil.decrypt(encriptedPwdDB, + // SystemProperties.getProperty(SystemProperties.Decryption_Key)); + + setLocalMDCContext(app, "/timeoutSession", url); + + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // optional default is GET + con.setRequestMethod("POST"); + con.setConnectTimeout(3000); + con.setReadTimeout(15000); + + // add request header + con.setRequestProperty("username", appUserName); + con.setRequestProperty("password", encriptedPwdDB); + + // con.setRequestProperty("portalJSessionId", portalJSessionId); + con.setDoInput(true); + con.setDoOutput(true); + con.getOutputStream().flush(); + con.getOutputStream().close(); + + responseCode = con.getResponseCode(); + logger.debug(EELFLoggerDelegate.debugLogger, "Response Code : " + responseCode); + } catch (UrlAccessRestrictedException e) { + responseCode = HttpServletResponse.SC_UNAUTHORIZED; + String message = String.format( + "SessionCommunication.timeoutSession received an un-authorized exception. AppName: %s", appName); + logger.error(EELFLoggerDelegate.errorLogger, message); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiAuthenticationError, e); + } catch (Exception e) { + responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + String message = String.format( + "SessionCommunication.timeoutSession encountered an Exception. AppName: %s, Details: %s", appName, + EcompPortalUtils.getStackTrace(e)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeHttpConnectionError, e); + logger.error(EELFLoggerDelegate.errorLogger, message); + } finally { + EcompPortalUtils.setExternalAppResponseCode(responseCode); + } + return true; + } + + @EPMetricsLog + private void setLocalMDCContext(OnboardingApp app, String restPath, String url) { + setRequestId(); + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP); + if (url!=null && url.contains("https")) { + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS); + } + MDC.put(EPCommonSystemProperties.FULL_URL, url); + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, app.myLoginsAppName); + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, restPath); + } + + /** + * Generates request id, service name fields and loads them + * into MDC, as these values could be empty as these + * session timeout requests are generated at + * scheduled intervals using quartz scheduler. + */ + @EPMetricsLog + public void setRequestId() { + String requestId = MDC.get(Configuration.MDC_KEY_REQUEST_ID); + if (StringUtils.isEmpty(requestId)) { + MDC.put(Configuration.MDC_KEY_REQUEST_ID, UUID.randomUUID().toString()); + } + + MDC.put(Configuration.MDC_SERVICE_NAME, "/quartz/keepSessionAlive"); + MDC.put(EPCommonSystemProperties.PARTNER_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE); + } + + /** + * Remove the values from MDC as these requests are + * executed at regular intervals based on quartz rather + * incoming REST API requests. + * @param bAll + */ + @EPMetricsLog + public void clear(Boolean bAll) { + MDC.remove(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + if (bAll) { + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(Configuration.MDC_SERVICE_NAME); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + } + } +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/TimeoutHandler.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/TimeoutHandler.java new file mode 100644 index 00000000..53258c06 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/service/sessionmgt/TimeoutHandler.java @@ -0,0 +1,252 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.service.sessionmgt; + +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.quartz.DisallowConcurrentExecution; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.PersistJobDataAfterExecution; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.scheduling.quartz.QuartzJobBean; + +import org.openecomp.portalsdk.core.domain.sessionmgt.TimeoutVO; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; +import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; +import org.openecomp.portalapp.portal.service.EPAppService; +import org.openecomp.portalapp.portal.transport.OnboardingApp; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Executed periodically by Quartz to discover remote application sessions and + * update timeouts suitably. + */ +@PersistJobDataAfterExecution +@DisallowConcurrentExecution +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class TimeoutHandler extends QuartzJobBean { + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TimeoutHandler.class); + + ObjectMapper mapper = new ObjectMapper(); + + /** + * Supports static call {@link #timeoutSessions(HttpSession)} + */ + private static List onboardedAppList = null; + + @Autowired + SessionCommunication sessionCommunication; + + @Override + protected void executeInternal(JobExecutionContext context) throws JobExecutionException { + try { + //Create a request id if there is none available, + //and which will internally be used when making + //session extended timeout calls to the partner applications. + if (getSessionCommunication()!=null) { + getSessionCommunication().setRequestId(); + } + logger.info(EELFLoggerDelegate.debugLogger, "Quartz Cronjob for Session Management begins"); + + ManageService manageService = (ManageService) applicationContext.getBean("manageService"); + EPAppService appService = (EPAppService) applicationContext.getBean("epAppService"); + + List appList = appService.getEnabledNonOpenOnboardingApps(); + onboardedAppList = appList; + TypeReference> typeRef = new TypeReference>() { + }; + String portalJsonSessionStr; + Map portalSessionTimeoutMap = null; + + portalJsonSessionStr = manageService.gatherSessionExtenstions(); + if (portalJsonSessionStr == null || portalJsonSessionStr == "") { + logger.error(EELFLoggerDelegate.errorLogger, "Session Management: Portal session information is empty."); + return; + } + + try { + portalSessionTimeoutMap = mapper.readValue(portalJsonSessionStr, typeRef); + } catch (JsonMappingException | JsonParseException je) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, je); + logger.error(EELFLoggerDelegate.errorLogger, "Session Management: JSON Mapping Exception occurred while gathering the Session", je); + return; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Session Management: Error while gather Session from portal", e); + return; + } + + Map> appSessionTimeOutMap = new Hashtable>(); + // determine the Max TimeOut Time for each of the managed sessions + for (OnboardingApp app : appList) { + if (app.restUrl == null) { + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: null restUrl, not fetching from app " + app.name); + continue; + } + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Calling App " + app.name + " at URL " + app.restUrl); + String jsonSessionStr = fetchAppSessions(app); + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: App " + app.name + " returned " + jsonSessionStr); + if (jsonSessionStr == null || jsonSessionStr.isEmpty()) + continue; + + try { + Map sessionTimeoutMap = mapper.readValue(jsonSessionStr, typeRef); + appSessionTimeOutMap.put(app.id, sessionTimeoutMap); + for (String portalJSessionId : sessionTimeoutMap.keySet()) { + final TimeoutVO maxTimeoutVO = portalSessionTimeoutMap.get(portalJSessionId); + final TimeoutVO compareTimeoutVO = sessionTimeoutMap.get(portalJSessionId); + if (maxTimeoutVO != null && compareTimeoutVO != null) { + if (maxTimeoutVO.compareTo(compareTimeoutVO) < 0) + portalSessionTimeoutMap.get(portalJSessionId) + .setSessionTimOutMilliSec(compareTimeoutVO.getSessionTimOutMilliSec()); + } + } + } catch (JsonParseException | JsonMappingException e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e); + logger.error(EELFLoggerDelegate.errorLogger, + "JSON Mapping/Processing Exception occurred while mapping/parsing the jsonSessionStr", e); + continue; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while mapping/parsing the jsonSessionStr", e); + continue; + } + + } + + // post the updated session timeouts back to the Apps + for (OnboardingApp app : appList) { + if (app.restUrl == null) { + logger.warn(EELFLoggerDelegate.errorLogger, "Session Management: null restUrl, not posting back to app " + app.name); + continue; + } + + Map sessionTimeoutMap = appSessionTimeOutMap.get(app.id); + if (sessionTimeoutMap == null || sessionTimeoutMap.isEmpty()) + continue; + + for (String portalJSessionId : sessionTimeoutMap.keySet()) { + try { + final TimeoutVO maxTimeoutVO = portalSessionTimeoutMap.get(portalJSessionId); + final TimeoutVO setTimeoutVO = sessionTimeoutMap.get(portalJSessionId); + if (maxTimeoutVO == null || setTimeoutVO == null) { + String message = String.format( + "Session Management: Failed to update the session timeouts for the app: %s and the sessionId: %s.", + app.name, portalJSessionId); + logger.warn(EELFLoggerDelegate.errorLogger, message); + continue; + } + setTimeoutVO.setSessionTimOutMilliSec(maxTimeoutVO.getSessionTimOutMilliSec()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Session Management: error while updating the session timeout map", e); + continue; + } + } + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Updating App " + app.restUrl); + String sessionTimeoutMapStr = ""; + try { + sessionTimeoutMapStr = mapper.writeValueAsString(sessionTimeoutMap); + } catch (JsonProcessingException je) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while processing sessionTimeOutMap object to a String. Details: " + + EcompPortalUtils.getStackTrace(je)); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, je); + } + pingAppSessions(app, sessionTimeoutMapStr); + } + String portalSessionTimeoutMapStr = ""; + try { + portalSessionTimeoutMapStr = mapper.writeValueAsString(portalSessionTimeoutMap); + } catch (JsonProcessingException je) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while processing portalSessionTimeOutMap object to a String", je); + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, je); + } + manageService.updateSessionExtensions(portalSessionTimeoutMapStr); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "************************ Session Management: error in managing session timeouts", e); + } finally { + getSessionCommunication().clear(true); + } + } + + private String fetchAppSessions(OnboardingApp app) throws Exception { + String jsonSessionValue = getSessionCommunication().sendGet(app); + getSessionCommunication().clear(false); + return jsonSessionValue; + } + + private void pingAppSessions(OnboardingApp app, String sessionTimeoutMapStr) throws Exception { + getSessionCommunication().pingSession(app, sessionTimeoutMapStr); + getSessionCommunication().clear(false); + } + + public void timeoutSessions(HttpSession session) throws Exception { + String portalJSessionId = portalJSessionId(session); + if (onboardedAppList == null) + return; + + for (OnboardingApp app : onboardedAppList) { + getSessionCommunication().timeoutSession(app, portalJSessionId); + getSessionCommunication().clear(false); + } + } + + protected static String portalJSessionId(HttpSession session) { + final Object attribute = session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID); + if (attribute == null) + return ""; + String jSessionKey = (String) attribute; + return jSessionKey.split("-")[0]; + } + + private static ApplicationContext applicationContext; + + public static void setApplicationContext(ApplicationContext _applicationContext) { + applicationContext = _applicationContext; + } + + public SessionCommunication getSessionCommunication() { + if(sessionCommunication == null){ + if (applicationContext != null) + sessionCommunication = (SessionCommunication)applicationContext.getBean("sessionCommunication"); + } + + return sessionCommunication; + } + + public void setSessionCommunication(SessionCommunication sessionCommunication) { + this.sessionCommunication = sessionCommunication; + } + +} \ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/EPUserUtils.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/EPUserUtils.java new file mode 100644 index 00000000..a14bbe81 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/EPUserUtils.java @@ -0,0 +1,407 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.util; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.openecomp.portalapp.portal.domain.EPRole; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.domain.EPUserApp; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalsdk.core.domain.RoleFunction; +import org.openecomp.portalsdk.core.exception.SessionExpiredException; +import org.openecomp.portalsdk.core.lm.FusionLicenseManager; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.menu.MenuBuilder; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.AppUtils; +import org.springframework.beans.factory.annotation.Autowired; + +public class EPUserUtils { + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUserUtils.class); + + private final static Long ACCOUNT_ADMIN_ROLE_ID = 999L; + + public static final String ALL_ROLE_FUNCTIONS = "allRoleFunctions"; + + private static DataAccessService dataAccessService; + + /** + * Gets the EPUser object from the session. + * + * @param request + * HttpServletRequest + * @return EPUser object that was created upon login + * @throws SessionExpiredException + * if no session exists. + */ + public static EPUser getUserSession(HttpServletRequest request) { + HttpSession session = AppUtils.getSession(request); + if (session == null) + throw new SessionExpiredException(); + return (EPUser) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); + } + + /** + * Establishes the user's portal session + * + * @param request + * HttpServletRequest + * @param user + * EPUser + * @param applicationMenuData + * Menu data + * @param businessDirectMenuData + * Menu data + * @param loginMethod_ignored + * How the user authenticated; ignored + * @param allRoleFunctions + * Set of user's roles + */ + @SuppressWarnings("rawtypes") + public static void setUserSession(HttpServletRequest request, EPUser user, Set applicationMenuData, + Set businessDirectMenuData, String loginMethod_ignored, List allRoleFunctions) { + HttpSession session = request.getSession(true); + + // clear the current user session to avoid any conflicts + EPUserUtils.clearUserSession(request); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); + + getAllRoleFunctions(allRoleFunctions, session); + + getRoleFunctions(request); + + // truncate the role (and therefore the role function) data to save + // memory in the session + user.setEPRoles(null); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_NAME), user.getFullName()); + + ServletContext context = session.getServletContext(); + int licenseVerificationFlag = 3; + try { + licenseVerificationFlag = (Integer) context.getAttribute("licenseVerification"); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "setUserSession failed to get licenseVerification attribute", + e); + } + switch (licenseVerificationFlag) { + case FusionLicenseManager.DEVELOPER_LICENSE: + session.setAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME), + "My Portal [Development Version]"); + break; + case FusionLicenseManager.EXPIRED_LICENSE: + session.setAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME), + "My Portal [LICENSE EXPIRED]"); + break; + case FusionLicenseManager.VALID_LICENSE: + session.setAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME), "My Portal"); + break; + default: + session.setAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME), + "My Portal [INVALID LICENSE]"); + break; + } + + session.setAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME), + MenuBuilder.filterMenu(applicationMenuData, request)); + session.setAttribute(SystemProperties.getProperty(SystemProperties.BUSINESS_DIRECT_MENU_ATTRIBUTE_NAME), + MenuBuilder.filterMenu(businessDirectMenuData, request)); + } + + /** + * Creates a set of role function names and stores the set as a session + * attribute. + * + * @param allRoleFunctions + * List of role functions. + * @param session + * HttpSession + */ + private static void getAllRoleFunctions(List allRoleFunctions, HttpSession session) { + if (allRoleFunctions == null) + return; + Set roleFnSet = new HashSet(); + for (RoleFunction roleFn : allRoleFunctions) + roleFnSet.add(roleFn.getCode()); + session.setAttribute(ALL_ROLE_FUNCTIONS, roleFnSet); + } + + /** + * Removes all stored attributes from the user's session + * + * @param request + * HttpServletRequest + * @throws SessionExpiredException + * if no session exists + */ + private static void clearUserSession(HttpServletRequest request) { + HttpSession session = AppUtils.getSession(request); + if (session == null) + throw new SessionExpiredException(); + + // removes all stored attributes from the current user's session + session.removeAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); + session.removeAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); + session.removeAttribute(SystemProperties.getProperty(SystemProperties.BUSINESS_DIRECT_MENU_ATTRIBUTE_NAME)); + session.removeAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME)); + session.removeAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME)); + } + + /** + * Builds a set of role functions and sets a session attribute with it. + * + * @param request + * HttpServletRequest + * @return Set of role functions that was built. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static Set getRoleFunctions(HttpServletRequest request) { + HashSet roleFunctions = null; + + HttpSession session = request.getSession(); + roleFunctions = (HashSet) session + .getAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME)); + + if (roleFunctions == null) { + HashMap roles = getRoles(request); + roleFunctions = new HashSet(); + + Iterator i = roles.keySet().iterator(); + + while (i.hasNext()) { + Long roleKey = (Long) i.next(); + EPRole role = (EPRole) roles.get(roleKey); + + Iterator j = role.getRoleFunctions().iterator(); + + while (j.hasNext()) { + RoleFunction function = (RoleFunction) j.next(); + roleFunctions.add(function.getCode()); + } + } + + session.setAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME), + roleFunctions); + } + + return roleFunctions; + } + + /** + * Gets role information from the user session, in the cached user object. + * As a side effect sets a session variable with the roles. + * + * @param request + * HttpServletRequest + * @return Map of role ID to role object + */ + @SuppressWarnings("rawtypes") + private static HashMap getRoles(HttpServletRequest request) { + HashMap roles = null; + + HttpSession session = AppUtils.getSession(request); + roles = (HashMap) session.getAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME)); + + // if roles are not already cached, let's grab them from the user + // session + if (roles == null) { + EPUser user = getUserSession(request); + + // get all user roles (including the tree of child roles) + roles = getAllUserRoles(user); + + session.setAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME), roles); + } + + return roles; + } + + /** + * Builds a map of role ID to role object. + * + * @param user + * EPUser + * @return Map of role ID to role object + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static HashMap getAllUserRoles(EPUser user) { + HashMap roles = new HashMap(); + Iterator i = user.getEPRoles().iterator(); + + while (i.hasNext()) { + EPRole role = (EPRole) i.next(); + + if (role.getActive()) { + roles.put(role.getId(), role); + + // let's take a recursive trip down the tree to add all child + // roles + addChildRoles(role, roles); + } + } + + // Additionally; the account admin role is overloaded between ecomp + // portal and partners; lets also include that + Iterator appRolesIterator = user.getEPUserApps().iterator(); + while (appRolesIterator.hasNext()) { + EPRole role = (EPRole) appRolesIterator.next().getRole(); + + if (role.getActive() && role.getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { + roles.put(role.getId(), role); + + // let's take a recursive trip down the tree to add all child + // roles + addChildRoles(role, roles); + } + } + + return roles; + } + + /** + * Adds all child roles of the specified role to the map of roles. + * + * @param role + * EPRole + * @param roles + * Maps role id to role object + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static void addChildRoles(EPRole role, HashMap roles) { + Set childRoles = role.getChildRoles(); + + if (childRoles != null && childRoles.size() > 0) { + Iterator j = childRoles.iterator(); + while (j.hasNext()) { + EPRole childRole = (EPRole) j.next(); + + if (childRole.getActive()) { + roles.put(childRole.getId(), childRole); + + addChildRoles(childRole, roles); + } + } + } + + } + + public static boolean hasRole(EPUser user, String roleKey) { + return getAllUserRoles(user).keySet().contains(new Long(roleKey)); + } + + public static DataAccessService getDataAccessService() { + return dataAccessService; + } + + @Autowired + public void setDataAccessService(DataAccessService dataAccessService) { + EPUserUtils.dataAccessService = dataAccessService; + } + + /** + * Gets the user's ID from the user object in the session + * + * @param request + * HttpServletRequest + * @return Integer ID of current user + */ + public static int getUserId(HttpServletRequest request) { + return getUserIdAsLong(request).intValue(); + } + + /** + * Gets the user's ID from the user object in the session + * + * @param request + * HttpServletREquest + * @return Long ID of current user + */ + public static Long getUserIdAsLong(HttpServletRequest request) { + Long userId = new Long(SystemProperties.getProperty(SystemProperties.APPLICATION_USER_ID)); + if (request != null) { + if (getUserSession(request) != null) { + userId = getUserSession(request).getId(); + } + } + return userId; + } + + /** + * Gets the request ID from the request. + * + * @param request + * HttpServletRequest + * @return Request ID + */ + public static 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; + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "HEADER!!!! Exception : " + EcompPortalUtils.getStackTrace(e)); + } + + return (requestId.isEmpty() ? UUID.randomUUID().toString() : requestId); + } + + /** + * Gets the full URL from the request. + * + * @param request + * HttpServletRequest + * @return Full URL + */ + public static String getFullURL(HttpServletRequest request) { + if (request != null) { + StringBuffer requestURL = request.getRequestURL(); + String queryString = request.getQueryString(); + + if (queryString == null) { + return requestURL.toString(); + } else { + return requestURL.append('?').append(queryString).toString(); + } + } + return ""; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java new file mode 100644 index 00000000..1ef44a44 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java @@ -0,0 +1,129 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.util; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +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.util.SystemProperties; +import org.openecomp.portalsdk.core.web.support.AppUtils; + +public class SessionCookieUtil { + + //private static final String JSESSIONID = "JSESSIONID"; + private static final String EP_SERVICE = "EPService"; + private static final String USER_ID = "UserId"; + private static Integer cookieMaxAge = -1; + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionCookieUtil.class); + + public static void preSetUp(HttpServletRequest request, + HttpServletResponse response) { + initateSessionMgtHandler(request); + //set up EPService cookie + setUpEPServiceCookie(request, response); + } + + public static void setUpEPServiceCookie(HttpServletRequest request, + HttpServletResponse response) { + String jSessionId = getJessionId(request); + Cookie cookie1 = new Cookie(EP_SERVICE, jSessionId); + cookie1.setMaxAge(cookieMaxAge); + cookie1.setDomain(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.COOKIE_DOMAIN)); + cookie1.setPath("/"); + response.addCookie(cookie1); + } + + public static void setUpUserIdCookie(HttpServletRequest request, + HttpServletResponse response,String userId) throws Exception { + logger.info("************** session cookie util set up UserId cookie begins"); + userId = CipherUtil.encrypt(userId, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + Cookie cookie1 = new Cookie(USER_ID, userId); + cookie1.setMaxAge(cookieMaxAge); + cookie1.setDomain(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.COOKIE_DOMAIN)); + cookie1.setPath("/"); + response.addCookie(cookie1); + logger.info("************** session cookie util set up EP cookie completed"); + } + + public static String getUserIdFromCookie(HttpServletRequest request, + HttpServletResponse response) throws Exception { + String userId = ""; + Cookie[] cookies = request.getCookies(); + Cookie userIdcookie = null; + if (cookies != null) + for (Cookie cookie : cookies) + if (cookie.getName().equals(USER_ID)) + userIdcookie = cookie; + if(userIdcookie!=null){ + userId = CipherUtil.decrypt(userIdcookie.getValue(), + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } + + logger.info("************** session cookie util set up EP cookie completed"); + return userId; + } + + public static String getJessionId(HttpServletRequest request){ + + return request.getSession().getId(); + /* + Cookie ep = WebUtils.getCookie(request, JSESSIONID); + if(ep==null){ + return request.getSession().getId(); + } + return ep.getValue(); + */ + } + + protected static void initateSessionMgtHandler(HttpServletRequest request) { + String jSessionId = getJessionId(request); + storeMaxInactiveTime(request); + PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request)); + } + + protected static void storeMaxInactiveTime(HttpServletRequest request) { + HttpSession session = AppUtils.getSession(request); + if(session.getAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME) == null) + session.setAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME,session.getMaxInactiveInterval()); + } + + public static void resetSessionMaxIdleTimeOut(HttpServletRequest request) { + try { + HttpSession session = AppUtils.getSession(request); + final Object maxIdleAttribute = session.getAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME); + if(session != null && maxIdleAttribute != null) { + session.setMaxInactiveInterval(Integer.parseInt(maxIdleAttribute.toString())); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Could not reset the session timeout. Details: " + EcompPortalUtils.getStackTrace(e)); + } + + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SystemType.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SystemType.java new file mode 100644 index 00000000..fb0e35fc --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/util/SystemType.java @@ -0,0 +1,26 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalapp.util; + +public enum SystemType { + + APPLICATION, +// SYSTEM +} diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalsdk/core/lm/FusionLicenseManagerUtils.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalsdk/core/lm/FusionLicenseManagerUtils.java new file mode 100644 index 00000000..72461206 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalsdk/core/lm/FusionLicenseManagerUtils.java @@ -0,0 +1,75 @@ +/*- + * ================================================================================ + * 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. + * 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. + * ================================================================================ + */ +package org.openecomp.portalsdk.core.lm; + +import java.util.Date; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; +import org.openecomp.portalsdk.core.util.SystemProperties; +//import org.openecomp.portalapp.lm.FusionLicenseManagerImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.support.RequestContextUtils; + +@Component +public class FusionLicenseManagerUtils { + + @Autowired + private FusionLicenseManager licenseManager; + + @Autowired + private EPCommonSystemProperties sysProps; + static { + } + + public int verifyLicense(ServletContext context) { + if(sysProps == null) { + try { + sysProps = new EPCommonSystemProperties(); + sysProps.setServletContext(context); +// sysProps.load(); +// licenseManager = new FusionLicenseManagerImpl(new LicenseableClassImpl()); + System.out.println(licenseManager); + licenseManager.installLicense(); + } + catch(Exception ex) { + ex.printStackTrace(); + } + } + + + +// WebApplicationContext ctx =RequestContextUtils.getWebApplicationContext(request); +// int flag = ((FusionLicenseManager)ctx.getBean("fusionLicenseManager")).verifyLicense(request); +// logger.debug("****************FLAG ******************** " + flag); +// return flag; +// return 2; + return licenseManager.verifyLicense(context); + } + + public static Date getLicenseExpiryDate(HttpServletRequest request) { + WebApplicationContext ctx =RequestContextUtils.getWebApplicationContext(request); + return ((FusionLicenseManager)ctx.getBean("fusionLicenseManager")).getExpiredDate(); + } +} diff --git a/ecomp-portal-BE/war/META-INF/MANIFEST.MF b/ecomp-portal-BE-common/src/main/webapp/META-INF/MANIFEST.MF similarity index 100% rename from ecomp-portal-BE/war/META-INF/MANIFEST.MF rename to ecomp-portal-BE-common/src/main/webapp/META-INF/MANIFEST.MF diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/defs/definitions.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/defs/definitions.xml new file mode 100644 index 00000000..18445f20 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/defs/definitions.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/defs/definitions.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/defs/definitions.xml new file mode 100644 index 00000000..433fec8a --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/defs/definitions.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE/war/WEB-INF/fusion/jsp/.gitignore b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/jsp/.gitignore similarity index 100% rename from ecomp-portal-BE/war/WEB-INF/fusion/jsp/.gitignore rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/jsp/.gitignore diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml new file mode 100644 index 00000000..bda281c2 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml @@ -0,0 +1,1595 @@ + + + + + + + + + + + + seq_fn_widget + + + + + + + + + + + + + + + + + + + + + + + + + seq_ep_endpoint + + + + + + + + + + + + seq_ep_endpoints_basic_auth_account + + + + + + + + + + + + + + seq_ep_widget_catalog_parameter + + + + + + + + + + + + + + + + + + + + + + seq_ep_basic_auth_account + + + + + + + + + + + + + + + + + + + + + seq_ep_user_notification + + + + + + + + + + + + + + seq_fn_user + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_ep_microservice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_ep_microservice_parameter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_fn_app + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_ep_usrappsrtprf + + + + + + + + + + + seq_ep_usrmanappsrtprf + + + + + + + + + + + seq_ep_usrwidgetsrtprf + + + + + + + + + + + + + + + seq_fn_role + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app + + + + + + + + + + + + + + + + + seq_fn_pers_user_app_sel + + + + + + + + + + + seq_ep_pers_user_widget_sel + + + + + + + + + + + + seq_ep_user_role_request + + + + + + + + + + + + + + + + + + + seq_ep_user_role_request_det + + + + + + + + + + + + + + + + + + + 'Y' + and (upper(d.wdg_name) like upper(CONCAT('%', :searchQuery, '%')) or upper(d.wdg_desc) like upper(CONCAT('%', :searchQuery, '%'))) + ) + union + ( + select distinct 'Widget' CATEGORY, d.wdg_name NAME, + d.widget_id UUID, + d.wdg_desc TARGET + from ep_widget_catalog d + where d.all_user_flag='Y' + and (upper(d.wdg_name) like upper(CONCAT('%', :searchQuery, '%')) or upper(d.wdg_desc) like upper(CONCAT('%', :searchQuery, '%'))) + ) + union + ( + select distinct 'Widget' CATEGORY, d.wdg_name NAME, + d.widget_id UUID, + d.wdg_desc TARGET + from fn_user a, fn_user_role b, ep_widget_catalog d + where upper(a.org_user_id) = upper( :userId ) + and a.user_id = b.user_id + and b.role_id = 1 + and (upper(d.wdg_name) like upper(CONCAT('%', :searchQuery, '%')) or upper(d.wdg_desc) like upper(CONCAT('%', :searchQuery, '%'))) + ) + ) y + ) t, + (SELECT @rn /*'*/:=/*'*/ 0) t2 order by NAME + ; + + ]]> + + + + + + = start_time) + and a.is_for_all_roles = 'N' + ) a, + ( + select a.user_id, c.role_id, c.app_id, d.APP_NAME + from fn_user a, fn_user_role b, fn_role c, fn_app d + where a.user_id = b.user_id + and a.user_id = :user_id + and b.role_id = c.role_id + and c.app_id = d.app_id + and d.enabled='Y' + )b + where + ( + a.role_id = b.role_id||a.recv_user_id=:user_id + ) + union + ( + select :user_id user_id, notification_id, is_for_online_users, is_for_all_roles, msg_header, msg_description, msg_source,start_Time, end_time, priority, created_date, creator_ID,active_YN + from ep_notification a + where a.notification_id + and (end_time is null || SYSDATE() <= end_time ) + and (start_time is null || SYSDATE() >= start_time) + and a.is_for_all_roles = 'Y' + ) + ) a + where + active_YN = 'Y' + and + not exists + ( + select * from ep_user_notification m where user_id = :user_id and m.notification_id = a.notification_id and is_viewed = 'Y' + ) + order by priority desc, start_Time desc,created_date desc + + + ) t, + (SELECT @rn /*'*/:=/*'*/ 0) t2 + ; + ]]> + + + + + + + + + + + + + + + + + + + + 1) b +union +select fn_role.app_id,fn_app.app_name, fn_role.role_id ,fn_role.role_name +from fn_app, fn_role +where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' order by app_name + + + + ]]> + + + + + + = DATE_ADD(curdate(),INTERVAL-31 DAY)) + or + (start_time is not null and end_time is null and start_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + or + (start_time is null and end_time is not null and end_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + or + (start_time is not null and end_time is not null and end_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + ) + ) a, + ( + select a.user_id, c.role_id, c.app_id, d.APP_NAME + from fn_user a, fn_user_role b, fn_role c, fn_app d + where a.user_id = b.user_id + and a.user_id = :user_id + and b.role_id = c.role_id + and c.app_id = d.app_id + and d.enabled='Y' + ) b + where + ( + a.role_id = b.role_id||a.recv_user_id=:user_id + ) + union + ( + select + :user_id user_id, b.login_id,notification_id, is_for_online_users, is_for_all_roles, + msg_header, msg_description,msg_source, start_Time, end_time, priority, a.created_date, + creator_ID, a.active_YN + from ep_notification a JOIN fn_user b on b.user_id=a.creator_ID + where a.notification_id + and a.is_for_all_roles = 'Y' + and ( + (start_time is null and end_time is null and a.created_date >= DATE_ADD(curdate(),INTERVAL-31 DAY)) + or + (start_time is not null and end_time is null and start_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + or + (start_time is null and end_time is not null and end_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + or + (start_time is not null and end_time is not null and end_time >= DATE_ADD(curdate(),INTERVAL -31 DAY)) + ) + ) + ) a left outer join ( + select m.notification_ID, m.is_viewed from ep_user_notification m where user_id = :user_id + ) m + on a.notification_id = m.notification_ID + where + active_YN = 'Y' + + order by start_Time desc,end_time desc + ) t, + (SELECT @rn /*'*/:=/*'*/ 0) t2 where startTime<=SYSDATE() + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + from CommonWidget where category = :cat order by + sortOrder, title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml new file mode 100644 index 00000000..f6d22a27 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml @@ -0,0 +1,335 @@ + + + + + + + + + + + + + seq_fn_user + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_fn_role + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_fn_menu + + + + + + + + + + + + + + + + + + + + + + + seq_fn_menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_fn_broadcast_message + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + seq_fn_audit_log + + + + + + + + + + + + + + + + + + + + + + + + + select distinct functionCd from MenuData + + + + from MenuData where menuSetCode = :menu_set_cd and parentMenu is null + + + FROM UrlsAccessible A where upper(A.urlsAccessibleKey.url) = upper(:current_url) + + + + select firstName, lastName from User where id = :user_id + + + + select email from User where id = :user_id + + + + select id, firstName, lastName from User where active = true order by lastName, firstName + + + + select name from Role where id = :role_id + + + + select id, name from Role order by name + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Workflow.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Workflow.hbm.xml new file mode 100644 index 00000000..9a853e7f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Workflow.hbm.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/error.jsp b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/error.jsp new file mode 100644 index 00000000..0505b68c --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/error.jsp @@ -0,0 +1,20 @@ +<%-- + ================================================================================ + 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. + 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. + ================================================================================ + --%> +${errMsg} diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/index.jsp b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/index.jsp new file mode 100644 index 00000000..39437e78 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/index.jsp @@ -0,0 +1,21 @@ +<%-- + ================================================================================ + 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. + 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. + ================================================================================ + --%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login.jsp b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login.jsp new file mode 100644 index 00000000..e10ba624 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login.jsp @@ -0,0 +1,120 @@ +<%-- + ================================================================================ + 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. + 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. + ================================================================================ + --%> +<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page import="java.net.URLEncoder" %> +<%@ page import="org.openecomp.portalsdk.core.util.SystemProperties" %> + + + + + + + + + + + + + + + + + + + + <% + String returnUrl = request.getParameter("returnUrl"); + String redirectUrl = request.getParameter("redirectUrl"); + returnUrl = ((returnUrl == null) ? (request.isSecure() ?"https://":"http://") + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/process_csp" + "?redirectUrl=" + redirectUrl: URLEncoder.encode(returnUrl)); + %> + + +
+ +
+ AT&T +
+
+
+
+
+ +
+ + Click here to login + +
+
+
+
+
+







+ +
+ + + + diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login_external.jsp b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login_external.jsp new file mode 100644 index 00000000..fe5eef06 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/jsp/login_external.jsp @@ -0,0 +1,162 @@ +<%-- + ================================================================================ + 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. + 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. + ================================================================================ + --%> +<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> +<%@ page import="org.openecomp.portalsdk.core.util.SystemProperties" %> + +" /> + + + + + + Login + + + + + + + + + + + + + + + + + +
+ +
+ AT&T +
+
+ +
+
+ Portal +

ECOMP Portal

+ + +
+
+ + +
+
+                + +
+
+
+






+ +
+ + + + diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/angular-sanitize.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/angular-sanitize.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/angular-sanitize.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/angular-sanitize.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/angular.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/angular.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/angular.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/angular.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/app.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/app.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/app.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/app.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/att-abs-tpls-1.2.51.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/att-abs-tpls-1.2.51.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/att-abs-tpls-1.2.51.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/att-abs-tpls-1.2.51.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/attHeaderSnippet.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeaderSnippet.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/attHeaderSnippet.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeaderSnippet.js diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeader_new.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeader_new.js new file mode 100644 index 00000000..b0314dd5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/attHeader_new.js @@ -0,0 +1,1375 @@ +/* Start of definition of the adobe analytics variable, "digitalData" .*/ +var wcaUser = "false",menuClicked; +var digitalData=digitalData||{}; +digitalData={ + page:{ + pageInfo:{}, + category:{}, + attributes:{}, + internalSearch:{} + }, + event:[{ + eventInfo:{} + }], + product:[{ + productInfo:{} + }], + cart:{}, + transaction:{ + item:[{ + productInfo:{}, + price:{} + }], + profile:{ + address:{} + }, + total:{}, + attributes:{} + }, + user:[{ + profile:[{ + profileInfo:{}, + attributes:{ + profileFAN:{} + } + }] + }] +}; +/* End of definition of the adobe analytics variable, "digitalData" .*/ + +/* Self-Invoking Anonymous Function to run on every load of the header content. */ + +$(function(){ + /* Variables to hold the header data retrieved from the database. */ + var headerData, secMenuData, megaMenuData ; + var homePageNameInfo; + var loginId; + var bdToolsWindow; + var checkSessionIntervalMins = 29; + var bdSessionTimeout = 60; + var bdSessionId; + loadJSWithCallBack = function(src, callback) { + if ($('script[src*="'+src+'"]').length === 0) { + $.getScript(src) + .done(function( script, textStatus ) { + callback.call(); + }) + .fail(function( jqxhr, settings, exception ) { + //console.log("file not loaded " + src); + }); + }else{ + /* Script loaded already*/ + callback.call(); + } + } + + var headerFunction = function() { + this.getHeaderData = function() { + /* $.ajax({ + + type: "post", + dataType: 'json', + url: window.dashboardContext + "/mnm/map/common/dashboardNavigation.jsp", + success: function(data) { + + if (data) { + headerData = data; + /* Generating the html for the primary menu using handlebars. */ + /* var primaryMenuTmpl = Handlebars.compile($("#primaryMenu_tmpl").html()), + primaryMenuHtml = primaryMenuTmpl(data); + $(".primaryMenuOptionsContainer").removeClass('primaryMenuOption'); + $('.primaryMenuOption').replaceWith(''); + $(".primaryMenuOptionsContainer").append(primaryMenuHtml); + var dataForNavigation = {}; + if (window.location.hash) { + dataForNavigation.pageUrl = window.location.pathname + "?" + window.location.hash; + } else { + dataForNavigation.pageUrl = window.location.pathname; + } + + /* Ajax call to get the name of the home page from the DB based on the current url. */ + /* $.ajax({ + type: "post", + dataType: 'json', + data: dataForNavigation, + url: window.dashboardContext + "/mnm/map/common/navigationParent.jsp", + headers: {"X-CSRF-Token":window.softToken}, + success: function(data) { + if (data) { + homePageNameInfo = data; + $(".pageNameContainer .pageName").html(data.name); + + $.each(headerData.childNavigation, function(dataIndex, primaryMenuData) { + + $.each(primaryMenuData.childNavigation, function(dataIndex, secondaryMenuData) { + + if (secondaryMenuData.name == homePageNameInfo.name) { + + $(".pageName").attr("href", secondaryMenuData.url); + } + + }); + + }); + + + showSecondaryMenu(homePageNameInfo); + } + }, + error: function() { + //console.log("Error Response From Service"); + } + }); + } + }, + error: function() { + //console.log("Error Response From Service"); + } + }); */ + } +} +primaryMenuItemClick = function(primaryMenuLinkObj) { + + var $this = $(primaryMenuLinkObj); + + /* $('.categoryContainerColumn').remove();*/ + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + $(".selectionDiv").hide(); + $('.secondaryMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + $('.thirdMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + + /* Arrow left position calculation. */ + + var elementLeft = $this.position().left, + elementWidth = $this.width(), + centerValue = elementLeft + 24 + (elementWidth) / 2; + $('.selectedOptionIndicator').css('left', centerValue); + $('.selectedOptionIndicator').show(); //Added By Robert 6/9/15 + // when clicked on Support link + if ($this.text() === 'Support') { + return populateSecondaryMenu(primaryMenuLinkObj, getSupportLinkData()); + } + + /*$.ajax({ + type: "get", + dataType: 'json', + async: false, + contentType :'application/json', + //url: window.dashboardContext + "/navigation/gadgets/megaMenuNavigation.jsp?megaMenu="+escape($this.text()).toUpperCase(), + url: window.ebizDashboardContext + "/navigation/"+escape($this.text()), + //headers: {"X-CSRF-Token":window.softToken}, + success: function(data) { + populateSecondaryMenu(primaryMenuLinkObj, data); + }, + complete : function() { + }, + error: function() { + if (typeof console == 'object') { + console.log("Error Response From Service"); + } + } + });*/ +} + +populateSecondaryMenu = function(primaryMenuLinkObj, data) { + //primary menu link object + var $this = $(primaryMenuLinkObj); + + if (data) { + headerData = data; + + if (data.childNavigation.length != 0) { + $.each(data.childNavigation, function(dataIndex, childNavigation) { + if(childNavigation == null){ + childNavigation = {}; + secondaryMenuTmpl = Handlebars.compile($("#secondaryMenu_tmpl").html()), + secondaryMenuHtml = secondaryMenuTmpl(childNavigation); + $('.secondaryMenuOption').remove(); + $(".secondaryMenuContentContainer").append(secondaryMenuHtml); + }else{ + secMenuData = childNavigation.childNavigation; + + var noOfCols = childNavigation.childNavigation.length, + secondaryMenuTmpl = Handlebars.compile($("#secondaryMenu_tmpl").html()), + secondaryMenuHtml = secondaryMenuTmpl(childNavigation); + + $('.secondaryMenuOption').remove(); + $(".secondaryMenuContentContainer").append(secondaryMenuHtml); + + if (noOfCols < 6) { + $('.secondaryMenuOption').css('margin-left', 40); + } else if (noOfCols == 6) { + $('.secondaryMenuOption').css('margin-left', 30); + } else if (noOfCols > 6 && noOfCols < 9) { + $('.secondaryMenuOption').css('margin-left', 20); + } + } + $('.selectedOptionIndicator').show(); + + if (window.location.pathname == window.ebizDashboardContext + "/index.jsp") { + $('.secondaryMenuContainerForDashboard').show(); + } else if (window.location.pathname.indexOf('login') > 0) { + $('.secondaryMenuContainerForApplication').show(); + } else { + $(".secondaryMenuContainerForApplication").show(); + /*if(!($('.switch-message-div').is(':visible'))){ + $('.secondaryMenuContainer').css("margin-top", 50); + }*/ + } + $('.primaryMenuOptionLink').removeClass('selectedPrimaryMenuOption'); + $this.addClass("selectedPrimaryMenuOption"); + var currentUrl = window.location.href; + if(currentUrl != null){ + var emaintenanceMatch = currentUrl.search('emaintenance'); + if(emaintenanceMatch >= 0){ + $(".pageNameContainer .pageName").html("Network"); + } + } + }) + } else { + $('.selectedOptionIndicator').hide(); + $('.secondaryMenuContainer').hide(); + $('.secondaryMenuOption').remove(); + $('.primaryMenuOptionLink').removeClass('selectedPrimaryMenuOption'); + } + } +} + + +if($(".switch-message-div").is(':visible')){ + $(".dashboardHeadTitle").css("margin-top","60px"); + $(".dashboardHeadIcons").css("top","127px"); + $("#openWalkThrough").css("margin-top","40px"); + $(".dashboardHeadWhiteOverlay").css("margin-top", "36px"); + $("#dashBoardContainer").css("margin-top", "43px"); +} + +if(!($('.switch-message-div').is(':visible'))){ + $(".dashboardHeadWhiteOverlay").css("margin-top", 0); + $(".dashboardHeadTitle").css("margin-top","30px"); + $(".dashboardHeadIcons").css("top","90px"); + $("#openWalkThrough").css("margin-top","0px"); + $("#dashBoardContainer").css("margin-top", "4px"); +} + +getSupportLinkData = function() { + return { + "name": "ESTRATEGY_NAVIGATION", + "id": "Support", + "url": null, + "childNavigation": [ + { + "name": "Support", + "url": null, + "childNavigation": [ + { + "name": "User Information", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=profileInfo", + "childNavigation": [] + }, + { + "name": "Registration and Login", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=registration", + "childNavigation": [] + }, + { + "name": "Orders", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=order", + "childNavigation": [] + }, + { + "name": "Billing", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=billing", + "childNavigation": [] + }, + { + "name": "Network", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=networkInfo", + "childNavigation": [] + }, + { + "name": "Reports", + "url": "/ebiz/ebcsupport/eBCSupport.jsp?module_id=reporting", + "childNavigation": [] + } + ], + "urlWithTitle": null, + "navClass": null + } + ], + "urlWithTitle": null, + "navClass": null + }; +} + + +highlightHomePageNameInSecMenu = function(secondaryMenuItemObj) { + + var $this = $(secondaryMenuItemObj); + + $this.parents(".secondaryMenuOption").find(".selectionDiv").show(); + $this.addClass('homePageNameHighlight'); +} + +showSecondaryMenu = function(homePageNameInfo) { + + var primaryMenuItem; + if (headerData && headerData.childNavigation) { + $.each(headerData.childNavigation, function(dataIndex, primaryMenuData) { + + primaryMenuItemToClick = primaryMenuData.name; + $.each(primaryMenuData.childNavigation, function(dataIndex, secondaryMenuData) { + + if (secondaryMenuData.name == homePageNameInfo.name) { + + $.each($('.primaryMenuOptionLink'), function(i, val) { + + var $this = $(this); + + if ($this.html() == primaryMenuItemToClick) { + alert(""); + primaryMenuItemClick($this); + } + }); + + $.each($('.secondaryMenuOptionLink'), function(i, val) { + + var $this = $(this); + + if ($.trim($this.html().split("<")[0]) == secondaryMenuData.name) { + + highlightHomePageNameInSecMenu($this); + } + }); + $.each($('.thirdMenuOptionLink'), function(i, val) { + + var $this = $(this); + + if ($.trim($this.html().split("<")[0]) == secondaryMenuData.name) { + + highlightHomePageNameInSecMenu($this); + } + }); + + + } + + }); + + }); + } +} + +secondaryMenuItemHover = function(secondaryMenuItemObj) { + + var $this = $(secondaryMenuItemObj); + + $(".selectionDiv").hide(); + $('.secondaryMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + $('.thirdMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + + if ($this.hasClass("pageName")) { + $.each(headerData.childNavigation, function(dataIndex, childNavigation) { + var child1 = childNavigation.childNavigation; + $.each(child1, function(dataIndex, childNavigation) { + if (childNavigation.name === $.trim($this.html())) { + if (childNavigation.childNavigation.length != 0) { + secMenuData = child1; + } + } + }); + }); + $(".megaMenuContainer").addClass("addMargin"); + } else { + $(".megaMenuContainer").removeClass("addMargin"); + } + /* + $('.categoryContainerColumn').remove(); + $.each(secMenuData, function(dataIndex, childNavigation) { + + if (childNavigation.name == $.trim($this.html().split("<")[0])) { + Generating the html for the secondary menu. + + if (childNavigation.childNavigation.length != 0) { + + megaMenuData = childNavigation.childNavigation; + var megaMenuFirstRowData = {}, + megaMenuSecondRowData = {}, + firstRowDataIndex = 0, + secondRowDataIndex = 0; + + megaMenuFirstRowData.childNavigation = {}; + megaMenuSecondRowData.childNavigation = {}; + + $.each(childNavigation.childNavigation, function(dataIndex, columnInfo) { + + if (dataIndex < 6) { + megaMenuFirstRowData.childNavigation[firstRowDataIndex++] = columnInfo; + } else if (dataIndex > 5 && dataIndex < 12) { + megaMenuSecondRowData.childNavigation[secondRowDataIndex++] = columnInfo; + } + + }); + + var megaMenuTmpl = Handlebars.compile($("#megaMenu_tmpl").html()), + megaMenuFirstRowHtml = megaMenuTmpl(megaMenuFirstRowData); + + $(".megaMenuFirstRow").append(megaMenuFirstRowHtml); + + if (megaMenuData.length > 6) { + + var megaMenuSecondRowHtml = megaMenuTmpl(megaMenuSecondRowData); + $(".megaMenuSecondRow").append(megaMenuSecondRowHtml); + $(".megaMenuSecondRow").show(); + } + + $('.megaMenuContainer').show(); + $this.find(".selectionDiv").show(); + $this.addClass('selectedSecondaryMenuOption'); +*/ + /* Width and margin assignments for each column (6 columns max in a row) in the mega menu. */ +/* switch (megaMenuData.length) { + + case 1: + + $('.categoryContainer').css('margin-left', '30px'); + $('.categoryContainer').width(300); + break; + + case 2: + + $('.categoryContainer').css('margin-left', '20px'); + $('.categoryContainer').width(300); + break; + + case 3: + + $('.categoryContainer').css('margin-left', '20px'); + $('.categoryContainer').width(293); + break; + + case 4: + + $('.categoryContainer').css('margin-left', '20px'); + $('.categoryContainer').width(215); + break; + + case 5: + + $('.categoryContainer').css('margin-left', '10px'); + $('.categoryContainer').width(175); + break; + + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + $('.categoryContainer').css('margin-left', '10px'); + $('.categoryContainer').width(145); + break; + + default: + $('.categoryContainer').css('margin-left', '10px'); + $('.categoryContainer').width(145); + break; + } + + $('.megaMenuFirstRow .categoryContainer:first').css('margin-left', '30px'); + $('.megaMenuSecondRow .categoryContainer:first').css('margin-left', '30px'); + + } else { + + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + $(".selectionDiv").hide(); + $('.secondaryMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + } + } + + });*/ +} +/* Loading handlebars.js if it isn't already. */ +/*if (userLoggedIn) { + Generating the html for the primary menu using handlebars. + var primaryMenuNames = {"childNavigation": [{"name" : "Manage"},{"name" : "Tools"},{"name" : "Support"}]}; + + var primaryMenuTmpl = Handlebars.compile($("#primaryMenu_tmpl").html()); + primaryMenuHtml = primaryMenuTmpl(primaryMenuNames); + + $(".primaryMenuOptionsContainer").removeClass('primaryMenuOption'); + $('.primaryMenuOption').replaceWith(''); + $(".primaryMenuOptionsContainer").append(primaryMenuHtml); + var dataForNavigation = {}; + if (window.location.hash) { + dataForNavigation.pageUrl = window.location.pathname + "?" + window.location.hash; + } else { + dataForNavigation.pageUrl = window.location.pathname; + } +}*/ + +/* On click of any primary menu option, display the corresponding secondary menu. */ +$(document).on('click keyup', '.primaryMenuOptionLink', function(ev) { + if (ev.keyCode==13 || ev.type=='click') { + ev.stopImmediatePropagation(); + primaryMenuItemClick($(this)); + + if (homePageNameInfo) { + + $.each($('.secondaryMenuOptionLink'), function() { + + var $this = $(this); + + if ($.trim($this.html().split("<")[0]) == homePageNameInfo.name) { + + highlightHomePageNameInSecMenu($this); + } + }); + $.each($('.thirdMenuOptionLink'), function() { + + var $this = $(this); + + if ($.trim($this.html().split("<")[0]) == homePageNameInfo.name) { + + highlightHomePageNameInSecMenu($this); + } + }); + + + } + } +}); + +/* Code related to the CATO compliance for navigation through key board */ +// tab-out of a primaryLink in expanded mode +$(document).on('keydown', '.primaryMenuOptionLink', function(e) { + var keyCode = e.keyCode || e.which; + // when shift tab pressed retain default behaviour + if (e.shiftKey && e.keyCode == 9) { + return; + } + + e.preventDefault(); + if (keyCode == 40) { //down arrow : focus on the first secondary menu link + $('.secondaryMenuContentContainer a.secondaryMenuOptionLink:first').focus(); + $('.secondaryMenuContentContainer a.thirdMenuOptionLink:first').focus(); + } + + if (keyCode == 9 || keyCode == 39) { //tab or right arrow + if ($(this).parent().next().length) { //next primary link + $(this).parent().next().find("a.primaryMenuOptionLink").focus(); + } else { + $(".openpopbox").focus(); //traverse to login icon + } + } + + if (keyCode == 37) { //left arrow + if ($(this).parent().prev().length) { //next primary link + $(this).parent().prev().find("a.primaryMenuOptionLink").focus(); + } + } +}); + + +//tab-out of a secondary in expanded mode +$(document).on('keydown', '.secondaryMenuOptionLink', function(e) { + var keyCode = e.keyCode || e.which; + //enter key + if(keyCode == 13) { + window.location = $(this).attr('href'); + } + + e.preventDefault(); + if (keyCode == 40) { //down arrow : focus on the first mega menu link + $('.megaMenuContainer a.categoryOptionLink:first').focus(); + } + + if (keyCode == 38) {// up arrow: traverse to current primary link + $(getSelectedPrimaryMenuOption()).find("a.primaryMenuOptionLink").focus(); + } + + if (keyCode == 9 || keyCode == 39) { //tab or right arrow + if($(this).parent().next().length) { // traverse to next secondary link if exists + $(this).parent().next().find("a.secondaryMenuOptionLink").focus(); + } else { //traverse to next primary link + $(getSelectedPrimaryMenuOption()).next().find("a.primaryMenuOptionLink").focus(); + } + } + + if (keyCode == 37) {// left arrow: + if ($(this).parent().prev().length) { // traverse to previous link if exists + $(this).parent().prev().find("a.secondaryMenuOptionLink").focus(); + } else { // traverse to current primary link + $(getSelectedPrimaryMenuOption()).find("a.primaryMenuOptionLink").focus(); + } + } +}); + +$(document).on('keydown', '.thirdMenuOptionLink', function(e) { + var keyCode = e.keyCode || e.which; + //enter key + if(keyCode == 13) { + window.location = $(this).attr('href'); + } + + e.preventDefault(); + if (keyCode == 40) { //down arrow : focus on the first mega menu link + $('.megaMenuContainer a.categoryOptionLink:first').focus(); + } + + if (keyCode == 38) {// up arrow: traverse to current primary link + $(getSelectedPrimaryMenuOption()).find("a.primaryMenuOptionLink").focus(); + } + + if (keyCode == 9 || keyCode == 39) { //tab or right arrow + if($(this).parent().next().length) { // traverse to next secondary link if exists + $(this).parent().next().find("a.thirdMenuOptionLink").focus(); + } else { //traverse to next primary link + $(getSelectedPrimaryMenuOption()).next().find("a.primaryMenuOptionLink").focus(); + } + } + + if (keyCode == 37) {// left arrow: + if ($(this).parent().prev().length) { // traverse to previous link if exists + $(this).parent().prev().find("a.thirdMenuOptionLink").focus(); + } else { // traverse to current primary link + $(getSelectedPrimaryMenuOption()).find("a.primaryMenuOptionLink").focus(); + } + } +}); +//tab-out of a categoryOptionLink +$(document).on('keydown', '.categoryOptionLink', function(e) { + var keyCode = e.keyCode || e.which; + //enter key + if(keyCode == 13) { + window.location = $(this).attr('href'); + menuClicked = $(this).attr('href'); + } + + e.preventDefault(); + + if (keyCode == 39) { // right arrow + $(this).parent().parent().parent().next().find("a.categoryOptionLink:first").focus(); + } else if(keyCode == 37) { //left arrow + $(this).parent().parent().parent().prev().find("a.categoryOptionLink:first").focus(); + } else if(keyCode == 38) { //up arrow + if($(this).parent().prev(".categoryOption").length) { + $(this).parent().prev(".categoryOption").find("a.categoryOptionLink").focus(); + } else { + if ($(this).parent().parent().parent().prev().length) { //traverse to prev category column if exists + $(this).parent().parent().parent().prev().find("a.categoryOptionLink:last").focus(); + } else { //traverse to current secondary column + $(getSelectedSecondaryMenuOption()).find("a.secondaryMenuOptionLink").focus(); + $(getSelectedSecondaryMenuOption()).find("a.thirdMenuOptionLink").focus(); + + } + } + } else if(keyCode == 40) { //down arrow + if ($(this).parent().next(".categoryOption").length) { + $(this).parent().next(".categoryOption").find("a.categoryOptionLink").focus(); + } else { + if ($(this).parent().parent().parent().next().length) { //traverse to next category column if exists + $(this).parent().parent().parent().next().find("a.categoryOptionLink:first").focus(); + } else { //traverse to next secondary link + $(getSelectedSecondaryMenuOption()).next().find("a.secondaryMenuOptionLink").focus(); + $(getSelectedSecondaryMenuOption()).next().find("a.thirdMenuOptionLink").focus(); + + } + } + } + +}); + +//get selected primary menu option +function getSelectedPrimaryMenuOption() { + var retValue; + $.each($(".primaryMenuContainer .primaryMenuOption"), function(index, value) { + var primaryLink = $(this).find("a.primaryMenuOptionLink"); + if ($(primaryLink).hasClass("selectedPrimaryMenuOption")) { + retValue = $(this); + } + }); + return retValue; +} + +//get selected secondary menu option +function getSelectedSecondaryMenuOption() { + var retValue; + $.each($(".secondaryMenuContentContainer .secondaryMenuOption"), function(index, value) { + if( $(this).find("div.selectionDiv") != null && $(this).find("div.selectionDiv").is(':visible')) { + retValue = $(this); + } + }); + return retValue; +} + +/* End of Code related to the CATO compliance for navigation through key board */ + +/* On click of home page name in the primary menu (available on scroll). */ +$(document).on('click', '.pageName', function(ev) { + + window.scrollTo(0, 0); +}); + +$(".headerContentContainer").on("mouseenter", function() { + + /* $('.categoryContainerColumn').remove();*/ + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + $(".selectionDiv").hide(); + $('.secondaryMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + $('.thirdMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + + if (homePageNameInfo) { + + $.each($('.secondaryMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + } + + if (homePageNameInfo) { + + $.each($('.thirdMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + } + +}); + +/* On click of any secondary menu option. */ +$(document).on('click keyup', '.secondaryMenuOptionLink', function(ev) { + if (ev.keyCode==13 || ev.type=='click') { + var $this = $(this); + if (homePageNameInfo) { + if ($.trim($this.html().split("<")[0]) != homePageNameInfo.name) { + $this.parents(".secondaryMenuOption").find(".selectionDiv").hide(); + $this.removeClass('selectedSecondaryMenuOption'); + } + } + } + } +); +$(document).on('click keyup', '.thirdMenuOptionLink', function(ev) { + if (ev.keyCode==13 || ev.type=='click') { + var $this = $(this); + if (homePageNameInfo) { + if ($.trim($this.html().split("<")[0]) != homePageNameInfo.name) { + $this.parents(".secondaryMenuOption").find(".selectionDiv").hide(); + $this.removeClass('selectedSecondaryMenuOption'); + } + } + } + } +); + + + /* On click of any bdLink create Session. */ + $(document).on('click','.bdLink', function(ev){ + var $this = $(this); + var attr = $this.attr('href'); + + if (typeof attr !== typeof undefined && attr !== false) { + BdNotify.createSessionForBDLinks(ev, $this.attr("href")); + } + }); + + +/* getProfileData = function(){ + $.ajax({ + type: "post", + dataType: 'json', + url: window.dashboardContext + "", + success: function (data) { + if(data){ + loginId = data.profileData.repositoryId; + digitalData.user[0].profile[0].profileInfo.profileID = ""; + digitalData.user[0].profile[0].attributes.profileRole = data.profileData.userRole; + } + }, + error: function (){ + console.log("error"); + } + }); + } +*/ + // BD Tools Menu changes + + +/* getProfileData = function(){ + $.ajax({ + type: "post", + dataType: 'json', + url: window.dashboardContext + "", + success: function (data) { + if(data){ + loginId = data.profileData.repositoryId; + } + }, + error: function (){ + if (typeof console == 'object') { + console.log("error"); + } + } + }); + }*/ + +/* if(!wcaUser) { + getProfileData(); + }*/ + BdNotify = { + createSessionForBDLinks : function(ev, urlOpen) { + ev.preventDefault(); + $.ajax({ + type:"post", + dataType: 'json', + headers: {"authSecurityToken" : window.authSecurityToken}, + url: window.ebizDashboardContext +'/bd/createSession', + contentType: "application/json; charset=utf-8", + Accept: "application/json", + async: true, + success : function(response){ + var sessionResponse = eval(response); + var acss = null; + var weigs = null; + var tid = null; + if(sessionResponse.sessionId != null && null != sessionResponse.sessionPwd && null != sessionResponse.bdProfileId){ + tid = sessionResponse.sessionId + ":" + sessionResponse.sessionPwd+ ":"+sessionResponse.bdProfileId; + } + + if(null != sessionResponse.acssipAddress && null != sessionResponse.accexpires && null != sessionResponse.acsshash && null !=sessionResponse.acssuser && null != sessionResponse.acsstime ){ + acss = "ip&"+sessionResponse.acssipAddress+ "&expires&"+sessionResponse.acssexpires+"&hash&"+sessionResponse.acsshash+"&user&"+sessionResponse.acssuser+"&time&"+sessionResponse.acsstime; + } + if(null != sessionResponse.weigsIpAddress && null != sessionResponse.weigsExpires && null != sessionResponse.weigsHash && null != sessionResponse.weigsUser && null != sessionResponse.weigsTime){ + weigs = "ip&"+sessionResponse.weigsIpAddress+ "&expires&"+sessionResponse.weigsExpires+"&hash&"+sessionResponse.weigsHash+"&user&"+sessionResponse.weigsUser+"&time&"+sessionResponse.weigsTime; + } + + + if(null != tid){ + document.cookie = "ECCUser="+tid+"; path=/; domain=.att.com"; + } + if(null != acss){ + document.cookie = "ACSS_LOGIN="+acss+"; path=/; domain=.att.com"; + } + if(null != weigs){ + document.cookie = "WEIGS="+weigs+"; path=/; domain=.att.com"; + } + + + + document.cookie = "BDTimeOutEnabled=Y; path=/; domain=.att.com"; + + bdSessionId=sessionResponse.sessionId; + bdToolsWindow = window.open(urlOpen,'BDApplication','left=0,top=0,width=900,height=300,status=0,resizable=1,scrollbars=1'); + + // TODO: fix the session timeout and the session check + setTimeout(BdNotify.checkBDTimeoutAndExtendSession, 1000*60*checkSessionIntervalMins); + } + }); + }, + + checkBDTimeoutAndExtendSession : function(){ + if(bdToolsWindow!=null && !bdToolsWindow.closed){ + //console.log("TimeOut***************************"+ bdSessionId); + $.ajax({ + type:"post", + dataType: 'json', + // url: '/rest/model/com/att/b2b/ebcare/rest/actorchain/EBizCareServiceActor/terminateSession?userId='+loginId+'&bdSessionId='+ bdSessionId, + url: window.ebizDashboardContext +'/bd/'+bdSessionId+'/checkSession', + async: false, + success : function(response){ + var sessionResponse = eval(response); + if(sessionResponse>=0){ + + if(sessionResponse >= bdSessionTimeout ) { + // call terminate + terminateBDSession(); + } else { + // TODO: return timeToExpire from controller + // var timeToExpire = sessionResponse.BD_TIMEOUT - sessionResponse.LAST_ACCESS_BD_TIME; + //Set Timeout to call same function again after 25 mins + setTimeout(BdNotify.checkBDTimeoutAndExtendSession, 1000*60*checkSessionIntervalMins); + } + } + }, + error : function(e){ + + } + }); + } + } + } + + //End of BD Tools menu changes + + + /* Click event for the links provided in the mega menu. */ + $(document).on('click','.categoryOptionLink',function(ev){ + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + window.scrollTo(0, 0); + }); + +$(document).on('click', '.secondaryMenuContainer', function(ev) { + + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); +}); + +/* Display Mega menu on hovering over any of the secondary menu links. */ +$(document).on('touchstart mouseenter focus', '.secondaryMenuOptionLink, .pageName', function(ev) { + editHeaderMenuForBilling($(this)); + secondaryMenuItemHover($(this)); + + /* Function to handle Menu's on CFD Billing Iframe Pages */ + iframeHover(); +}); + +$(document).on('touchstart mouseenter focus', '.thirdMenuOptionLink, .pageName', function(ev) { + editHeaderMenuForBilling($(this)); + secondaryMenuItemHover($(this)); + + /* Function to handle Menu's on CFD Billing Iframe Pages */ + iframeHover(); +}); + +function editHeaderMenuForBilling(Obj) { + var url = window.location.pathname; + var $this = $(Obj); + + //If it is CFD Billing Iframe Page + if (url == "/ebiz/billing/iframe.jsp" && $.trim($this.html().split("<")[0]) == "Billing") { + var currentHeaderData = headerData; + var errorPage = "/ebiz/billing/error.jsp"; + var iframeSrc = $("#CFDIframe").attr('src'); + if (iframeSrc != errorPage) { + var MenuArea = $("#CFDIframe").contents().find('.hideMenuArea'); + if (MenuArea.length != 0) { + var MenuHtml = MenuArea.html(); + var payment_array = []; + var report_array = []; + + var paymentUrls = ["ImplCleanPaymentHistoryAction", "ImplOTPaymentContextSelectAction", "ImplRECPaymentContextSelectAction"]; + var reportUrls = ["ImplPreLoadFFReportListAction", "ImplExternalWFReports", "ImplPreLoadRawDataOutputAction", "ImplDeliveryProfilesContextSelectAction"]; + for (var i = 0; i < paymentUrls.length; i++) { + if (MenuHtml.indexOf(paymentUrls[i]) >= 0) { + payment_array.push(i + 1); + } + } + + for (var i = 0; i < reportUrls.length; i++) { + if (MenuHtml.indexOf(reportUrls[i]) >= 0) { + report_array.push(i + 1); + } + } + + $.each(headerData.childNavigation, function(dataIndex, childNavigation) { + if (childNavigation.name == "Manage") { + var mIndex = dataIndex; + var child1 = childNavigation.childNavigation; + $.each(child1, function(dataIndex, childNavigation) { + if (childNavigation.name == "Billing") { + var bIndex = dataIndex; + var child2 = childNavigation.childNavigation; + $.each(child2, function(dataIndex, childNavigation) { + if (childNavigation.name == "Payments") { + var pIndex = dataIndex; + var child3 = childNavigation.childNavigation; + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation = []; + + $.each(payment_array, function(dataIndex, item) { + if (item == 1) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600153", + "name": "Payment History", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplCleanPaymentHistoryAction.do" + }); + } else if (item == 2) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600155", + "name": "One Time Payment", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplOTPaymentContextSelectAction.do" + }); + } else if (item == 3) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600157", + "name": "Recurring Payments", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplRECPaymentContextSelectAction.do" + }); + } + }); + } else if (childNavigation.name == "Reports") { + var pIndex = dataIndex; + var child3 = childNavigation.childNavigation; + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation = []; + + $.each(report_array, function(dataIndex, item) { + if (item == 1) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600159", + "name": "Create/View Customized Reports", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplPreLoadFFReportListAction.do" + }); + } else if (item == 2) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600161", + "name": "Bill Analysis", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplExternalWFReports.do" + }); + } else if (item == 3) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600163", + "name": "Raw Data Output", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplPreLoadRawDataOutputAction.do" + }); + } else if (item == 4) { + headerData.childNavigation[mIndex].childNavigation[bIndex].childNavigation[pIndex].childNavigation.push({ + "childNavigation": [], + "id": "600165", + "name": "Delivery Profiles", + "url": "/ebiz/billing/iframe.jsp?destUrl=ImplDeliveryProfilesContextSelectAction.do" + }); + } + + }); + } + }); + } + }); + } + }); + } + } + } +} +/* For all the pages except CFD Iframe Page */ +function iframeHover() { + var url = window.location.pathname; + //If it is CFD Billing Iframe Page + if (url == "/ebiz/billing/iframe.jsp") { + $("a.categoryOptionLink").click(function() { + var status_url = $(this).attr('href').split('destUrl=')[1].split('&')[0]; + if (status_url != null && status_url != undefined) { + $('iframe').attr('src', cfd_handoff_url + '/businesscare-ebill/' + status_url); + if (history.pushState) { + history.pushState('', 'AT&T Billing', 'iframe.jsp?destUrl=' + status_url); + } + + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + window.scrollTo(0, 0); + + return false; + } else { + return true; + } + }); + } else { + return true; + } + +} + +$(document).on('mouseleave', '.secondaryMenuOptionLink', function(ev) { + + if ($(".megaMenuContainer").is(":hidden")) { + + if (homePageNameInfo) { + + $.each($('.secondaryMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + } + } +}); + +$(document).on('mouseleave', '.thirdMenuOptionLink', function(ev) { + + if ($(".megaMenuContainer").is(":hidden")) { + + if (homePageNameInfo) { + + $.each($('.thirdMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + } + } +}); + + +/* Hide the Mega menu on mouseleave. */ +$(document).on('mouseleave', '.megaMenuContainer', function(ev) { + /* $('.categoryContainerColumn').remove();*/ + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + $(".selectionDiv").hide(); + $('.secondaryMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + $('.thirdMenuOptionLink').removeClass('selectedSecondaryMenuOption'); + + if (homePageNameInfo) { + + $.each($('.secondaryMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + $.each($('.thirdMenuOptionLink'), function() { + + var $this = $(this); + + if ($this.hasClass("homePageNameHighlight")) { + + highlightHomePageNameInSecMenu($this); + } + }); + + + } +}); + +/* On scroll of the page, display the name of the page in the primary menu. + On scrolling back to the top, display the original primary menu. */ +$(window).on('scroll', function() { + if($('.mapHeader').is(':visible')){ + return false; + } else { + $('.secondaryMenuContainer').hide(); + $('.primaryMenuOptionLink').removeClass("selectedPrimaryMenuOption"); + $('.selectedOptionIndicator').hide(); + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + $('.primaryMenuOptionsContainer').hide(); + $(".pageNameContainer").show(); + if ($(window).scrollTop() === 0) { + if(!($('.switch-message-div').is(':visible'))){ + $(".dashboardHeadIcons").css("top","90px"); + } + else{ + $(".dashboardHeadIcons").css("top","127px"); + } + $('.primaryMenuOptionsContainer').show(); + var currentUrl = window.location.href; + if(currentUrl != null){ + var emaintenanceMatch = currentUrl.search('emaintenance'); + if(emaintenanceMatch >= 0){ + $(".secondaryMenuContainerForApplication").show(); + $('.selectedOptionIndicator').show(); + } + } + if (homePageNameInfo) { + showSecondaryMenu(homePageNameInfo); + } + $(".pageNameContainer").hide(); + } else { + if ($(".pageNameContainer .pageName").length && $(".pageNameContainer .pageName").text() !== "") { + $('.primaryMenuOptionsContainer').hide(); + $(".pageNameContainer").show(); + } else { + $('.primaryMenuOptionsContainer').show(); + $(".pageNameContainer").hide(); + } + } + } +}); + $(".reg-logout-btn").click(function(){ + if(bdToolsWindow!=null && !bdToolsWindow.closed){ + // console.log("log-out with Session Id" + bdSessionId); + bdToolsWindow.close(); + terminateBDSession(); +/* $.ajax({ + type:"delete", + dataType: 'json', + // url: '/rest/model/com/att/b2b/ebcare/rest/actorchain/EBizCareServiceActor/terminateSession?byPassLastAccess=true&userId='+loginId+'&bdSessionId='+ bdSessionId, + url: window.ebizDashboardContext +'/bd/'+bdSessionId+'/terminateSession', + async: false, + success : function(response){ + // console.log("BD-LOG-OUT-Sucess"); + }, + error : function(e){ + // console.log("BD-LOG-OUT-Error"); + } + });*/ + + } + /* Commenting the logout code.As logout functionality is handled by the regular form submition. + $.ajax({ + type: "get", + dataType: 'json', + url: "/rest/model/atg/userprofiling/ProfileActor/logout", + async: false, + success: function (response) { + // console.log("dashboard logout success"); + }, + error: function (){ + window.location.href = "/ebiz/registration/index.jsp?DPSLogout=true"; + // console.log("dashboard logout error"); + } + } );*/ + + }); + + function terminateBDSession() { + $.ajax({ + type:"delete", + dataType: 'json', + // url: '/rest/model/com/att/b2b/ebcare/rest/actorchain/EBizCareServiceActor/terminateSession?byPassLastAccess=true&userId='+loginId+'&bdSessionId='+ bdSessionId, + url: window.ebizDashboardContext +'/bd/'+bdSessionId+'/terminateSession', + async: false, + success : function(response){ + // console.log("BD-LOG-OUT-Sucess"); + }, + error : function(e){ + // console.log("BD-LOG-OUT-Error"); + } + }); + }; + /* + * Function Definition to Get Click To Chat Data + * ========================================== */ + function getClickToChatData() { + /* $.ajax({ + type: "get", + dataType: 'json', + contentType :'application/json', + url: window.ebizDashboardContext + "/clicktochat", + success: populateClickToChat, + error: function() {}, + complete: clickToChatPopBox + });*/ + } + + function populateClickToChat(response) { + + var template = Handlebars.compile($("#clickToChatMultiple_tmpl").html()); + var clickToChat = template(response); + $(".headerIconContainer").append(clickToChat); + + }; + + function clickToChatPopBox() { + /* var chatbox = $('.chatBox'); + + var methods = { + open: function(){chatbox.css('display','block');}, + close: function(){chatbox.fadeOut('fast');} + }; + $(document).on('click keyup ', '.chatIcon', function(ev) { + if(ev.keyCode==13 || ev.type=='click'){ + //$('.chatIcon').click(function() + if (chatbox.css('display') == 'block'){ + methods.close(); + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200); + if($(window).scrollTop() > 20){ + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200); + }; + } else { + $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); + methods.open(); + $(settings['box']).fadeOut("fast"); + } } + }); +*/ + // Close chat-box on clicking cross icon + $('.circle_close_chat').click(function(){ + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200); + methods.close(); + if($(window).scrollTop() > 20){ + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200); + }; + }); + + // Close chat-box on Escape key press + $(document).bind('keyup', function(event){ + if(event.keyCode == 27){ + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200); + /* methods.close();*/ + if($(window).scrollTop() > 20){ + setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200); + }; + } + }); + }; + + function JSONLength(json) { + var length = 0; + for (var key in json) { + length++; + }; + return length; + }; + + function prepareData(data) { + var modifiedJSON = {options: []}; + for (var key in data) { + var temp = {linkName:key, linkValue:data[key]}; + modifiedJSON['options'].push(temp); + }; + return modifiedJSON; + }; + + getClickToChatData(); +}); + +$('.emailAddress input').focus(function() { + var dispVal = $(this).val(); + if (dispVal == "Email Address") { + $(this).val(""); + } +}).blur(function() { + var dispVal1 = $(this).val(); + if (dispVal1 == "") { + $(this).val("Email Address"); + } +}); + +$(document).bind("ajaxSend", function(elm, xhr, s){ + if (s.type == "POST" || s.type == "GET") { + var token = window.softToken; + xhr.setRequestHeader('X-CSRF-Token', token); + } + }); +$(document).ready(function() { + onClickOfMenu = function(url){ + $('.megaMenuContainer').scrollTop(0); + $('.megaMenuContainer').hide(); + window.scrollTo(0, 0); + menuClicked = url; + window.location.href = url; + } +}); \ No newline at end of file diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/att_abs_tpls.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/att_abs_tpls.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/att_abs_tpls.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/att_abs_tpls.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/checklist-model.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/checklist-model.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/checklist-model.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/checklist-model.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/checklist-model.min.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/checklist-model.min.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/checklist-model.min.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/checklist-model.min.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/d7100892.modernizr.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/d7100892.modernizr.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/d7100892.modernizr.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/d7100892.modernizr.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/ebiz_keepalive.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ebiz_keepalive.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/ebiz_keepalive.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ebiz_keepalive.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/footer.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/footer.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/footer.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/footer.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/footer_new.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/footer_new.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/footer_new.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/footer_new.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/gestures.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/gestures.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/gestures.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/gestures.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/ng_base.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ng_base.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/ng_base.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ng_base.js diff --git a/ecomp-portal-BE/war/static/ebz/angular_js/ui-charts-tpls.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ui-charts-tpls.js similarity index 100% rename from ecomp-portal-BE/war/static/ebz/angular_js/ui-charts-tpls.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/ebz/angular_js/ui-charts-tpls.js diff --git a/ecomp-portal-BE/war/static/fusion/images/login_button.gif b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/fusion/images/login_button.gif similarity index 100% rename from ecomp-portal-BE/war/static/fusion/images/login_button.gif rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/fusion/images/login_button.gif diff --git a/ecomp-portal-BE/war/static/js/jquery-1.10.2.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery-1.10.2.js similarity index 100% rename from ecomp-portal-BE/war/static/js/jquery-1.10.2.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery-1.10.2.js diff --git a/ecomp-portal-BE/war/static/js/jquery-ui.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery-ui.js similarity index 100% rename from ecomp-portal-BE/war/static/js/jquery-ui.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery-ui.js diff --git a/ecomp-portal-BE/war/static/js/jquery.mask.min.js b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery.mask.min.js similarity index 100% rename from ecomp-portal-BE/war/static/js/jquery.mask.min.js rename to ecomp-portal-BE-common/src/main/webapp/WEB-INF/static/js/jquery.mask.min.js diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/web.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..9c89f942 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,56 @@ + + + + + fusion + + + + + + + + CorsFilter + org.apache.catalina.filters.CorsFilter + + cors.allowed.methods + GET,POST,HEAD,OPTIONS,PUT,DELETE + + + cors.allowed.headers + EPService,JSESSIONID,X-ECOMP-RequestID,X-Widgets-Type,Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers + + + + + CorsFilter + /* + + diff --git a/ecomp-portal-BE/war/images/cache/README.txt b/ecomp-portal-BE-common/src/main/webapp/images/cache/README.txt similarity index 100% rename from ecomp-portal-BE/war/images/cache/README.txt rename to ecomp-portal-BE-common/src/main/webapp/images/cache/README.txt diff --git a/ecomp-portal-BE-common/src/main/webapp/index.jsp b/ecomp-portal-BE-common/src/main/webapp/index.jsp new file mode 100644 index 00000000..dfff393d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/index.jsp @@ -0,0 +1,34 @@ +<%-- + ================================================================================ + 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. + 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. + ================================================================================ + --%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + +<%-- Redirected because we can't set the welcome page to a virtual URL. --%> +<%-- + --%> + + + ecompportal-BE index.jsp + + +

ECOMP Portal Core

+ This is the ecompportal-BE application, page index.jsp. + + + diff --git a/ecomp-portal-FE/client/bower_components/angular-animate/angular-animate.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-animate.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-animate/angular-animate.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-animate.js diff --git a/ecomp-portal-FE/client/bower_components/angular-animate/angular-animate.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-animate.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-animate/angular-animate.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-animate.min.js diff --git a/ecomp-portal-FE/client/bower_components/angular-aria/angular-aria.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-aria.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-aria/angular-aria.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-aria.js diff --git a/ecomp-portal-FE/client/bower_components/angular-aria/angular-aria.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-aria.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-aria/angular-aria.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-aria.min.js diff --git a/ecomp-portal-FE/client/bower_components/angular-cookies/angular-cookies.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-cookies.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-cookies/angular-cookies.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-cookies.js diff --git a/ecomp-portal-FE/client/bower_components/angular-cookies/angular-cookies.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-cookies.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-cookies/angular-cookies.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-cookies.min.js diff --git a/ecomp-portal-FE/client/bower_components/angular/angular-csp.css b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-csp.css similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular/angular-csp.css rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-csp.css diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.js new file mode 100644 index 00000000..77948fd5 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.js @@ -0,0 +1,484 @@ +/** + * @license AngularJS v1.5.0 + * (c) 2010-2016 Google, Inc. http://angularjs.org + * License: MIT + */ + +(function() {'use strict'; + function isFunction(value) {return typeof value === 'function';}; + +/* global: toDebugString: true */ + +function serializeObject(obj) { + var seen = []; + + return JSON.stringify(obj, function(key, val) { + val = toJsonReplacer(key, val); + if (isObject(val)) { + + if (seen.indexOf(val) >= 0) return '...'; + + seen.push(val); + } + return val; + }); +} + +function toDebugString(obj) { + if (typeof obj === 'function') { + return obj.toString().replace(/ \{[\s\S]*$/, ''); + } else if (isUndefined(obj)) { + return 'undefined'; + } else if (typeof obj !== 'string') { + return serializeObject(obj); + } + return obj; +} + +/** + * @description + * + * This object provides a utility for producing rich Error messages within + * Angular. It can be called as follows: + * + * var exampleMinErr = minErr('example'); + * throw exampleMinErr('one', 'This {0} is {1}', foo, bar); + * + * The above creates an instance of minErr in the example namespace. The + * resulting error will have a namespaced error code of example.one. The + * resulting error will replace {0} with the value of foo, and {1} with the + * value of bar. The object is not restricted in the number of arguments it can + * take. + * + * If fewer arguments are specified than necessary for interpolation, the extra + * interpolation markers will be preserved in the final string. + * + * Since data will be parsed statically during a build step, some restrictions + * are applied with respect to how minErr instances are created and called. + * Instances should have names of the form namespaceMinErr for a minErr created + * using minErr('namespace') . Error codes, namespaces and template strings + * should all be static strings, not variables or general expressions. + * + * @param {string} module The namespace to use for the new minErr instance. + * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning + * error from returned function, for cases when a particular type of error is useful. + * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance + */ + +function minErr(module, ErrorConstructor) { + ErrorConstructor = ErrorConstructor || Error; + return function() { + var SKIP_INDEXES = 2; + + var templateArgs = arguments, + code = templateArgs[0], + message = '[' + (module ? module + ':' : '') + code + '] ', + template = templateArgs[1], + paramPrefix, i; + + message += template.replace(/\{\d+\}/g, function(match) { + var index = +match.slice(1, -1), + shiftedIndex = index + SKIP_INDEXES; + + if (shiftedIndex < templateArgs.length) { + return toDebugString(templateArgs[shiftedIndex]); + } + + return match; + }); + + message += '\nhttp://errors.angularjs.org/1.5.0/' + + (module ? module + '/' : '') + code; + + for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') { + message += paramPrefix + 'p' + (i - SKIP_INDEXES) + '=' + + encodeURIComponent(toDebugString(templateArgs[i])); + } + + return new ErrorConstructor(message); + }; +} + +/** + * @ngdoc type + * @name angular.Module + * @module ng + * @description + * + * Interface for configuring angular {@link angular.module modules}. + */ + +function setupModuleLoader(window) { + + var $injectorMinErr = minErr('$injector'); + var ngMinErr = minErr('ng'); + + function ensure(obj, name, factory) { + return obj[name] || (obj[name] = factory()); + } + + var angular = ensure(window, 'angular', Object); + + // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap + angular.$$minErr = angular.$$minErr || minErr; + + return ensure(angular, 'module', function() { + /** @type {Object.} */ + var modules = {}; + + /** + * @ngdoc function + * @name angular.module + * @module ng + * @description + * + * The `angular.module` is a global place for creating, registering and retrieving Angular + * modules. + * All modules (angular core or 3rd party) that should be available to an application must be + * registered using this mechanism. + * + * Passing one argument retrieves an existing {@link angular.Module}, + * whereas passing more than one argument creates a new {@link angular.Module} + * + * + * # Module + * + * A module is a collection of services, directives, controllers, filters, and configuration information. + * `angular.module` is used to configure the {@link auto.$injector $injector}. + * + * ```js + * // Create a new module + * var myModule = angular.module('myModule', []); + * + * // register a new service + * myModule.value('appName', 'MyCoolApp'); + * + * // configure existing services inside initialization blocks. + * myModule.config(['$locationProvider', function($locationProvider) { + * // Configure existing providers + * $locationProvider.hashPrefix('!'); + * }]); + * ``` + * + * Then you can create an injector and load your modules like this: + * + * ```js + * var injector = angular.injector(['ng', 'myModule']) + * ``` + * + * However it's more likely that you'll just use + * {@link ng.directive:ngApp ngApp} or + * {@link angular.bootstrap} to simplify this process for you. + * + * @param {!string} name The name of the module to create or retrieve. + * @param {!Array.=} requires If specified then new module is being created. If + * unspecified then the module is being retrieved for further configuration. + * @param {Function=} configFn Optional configuration function for the module. Same as + * {@link angular.Module#config Module#config()}. + * @returns {angular.Module} new module with the {@link angular.Module} api. + */ + return function module(name, requires, configFn) { + var assertNotHasOwnProperty = function(name, context) { + if (name === 'hasOwnProperty') { + throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context); + } + }; + + assertNotHasOwnProperty(name, 'module'); + if (requires && modules.hasOwnProperty(name)) { + modules[name] = null; + } + return ensure(modules, name, function() { + if (!requires) { + throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " + + "the module name or forgot to load it. If registering a module ensure that you " + + "specify the dependencies as the second argument.", name); + } + + /** @type {!Array.>} */ + var invokeQueue = []; + + /** @type {!Array.} */ + var configBlocks = []; + + /** @type {!Array.} */ + var runBlocks = []; + + var config = invokeLater('$injector', 'invoke', 'push', configBlocks); + + /** @type {angular.Module} */ + var moduleInstance = { + // Private state + _invokeQueue: invokeQueue, + _configBlocks: configBlocks, + _runBlocks: runBlocks, + + /** + * @ngdoc property + * @name angular.Module#requires + * @module ng + * + * @description + * Holds the list of modules which the injector will load before the current module is + * loaded. + */ + requires: requires, + + /** + * @ngdoc property + * @name angular.Module#name + * @module ng + * + * @description + * Name of the module. + */ + name: name, + + + /** + * @ngdoc method + * @name angular.Module#provider + * @module ng + * @param {string} name service name + * @param {Function} providerType Construction function for creating new instance of the + * service. + * @description + * See {@link auto.$provide#provider $provide.provider()}. + */ + provider: invokeLaterAndSetModuleName('$provide', 'provider'), + + /** + * @ngdoc method + * @name angular.Module#factory + * @module ng + * @param {string} name service name + * @param {Function} providerFunction Function for creating new instance of the service. + * @description + * See {@link auto.$provide#factory $provide.factory()}. + */ + factory: invokeLaterAndSetModuleName('$provide', 'factory'), + + /** + * @ngdoc method + * @name angular.Module#service + * @module ng + * @param {string} name service name + * @param {Function} constructor A constructor function that will be instantiated. + * @description + * See {@link auto.$provide#service $provide.service()}. + */ + service: invokeLaterAndSetModuleName('$provide', 'service'), + + /** + * @ngdoc method + * @name angular.Module#value + * @module ng + * @param {string} name service name + * @param {*} object Service instance object. + * @description + * See {@link auto.$provide#value $provide.value()}. + */ + value: invokeLater('$provide', 'value'), + + /** + * @ngdoc method + * @name angular.Module#constant + * @module ng + * @param {string} name constant name + * @param {*} object Constant value. + * @description + * Because the constants are fixed, they get applied before other provide methods. + * See {@link auto.$provide#constant $provide.constant()}. + */ + constant: invokeLater('$provide', 'constant', 'unshift'), + + /** + * @ngdoc method + * @name angular.Module#decorator + * @module ng + * @param {string} The name of the service to decorate. + * @param {Function} This function will be invoked when the service needs to be + * instantiated and should return the decorated service instance. + * @description + * See {@link auto.$provide#decorator $provide.decorator()}. + */ + decorator: invokeLaterAndSetModuleName('$provide', 'decorator'), + + /** + * @ngdoc method + * @name angular.Module#animation + * @module ng + * @param {string} name animation name + * @param {Function} animationFactory Factory function for creating new instance of an + * animation. + * @description + * + * **NOTE**: animations take effect only if the **ngAnimate** module is loaded. + * + * + * Defines an animation hook that can be later used with + * {@link $animate $animate} service and directives that use this service. + * + * ```js + * module.animation('.animation-name', function($inject1, $inject2) { + * return { + * eventName : function(element, done) { + * //code to run the animation + * //once complete, then run done() + * return function cancellationFunction(element) { + * //code to cancel the animation + * } + * } + * } + * }) + * ``` + * + * See {@link ng.$animateProvider#register $animateProvider.register()} and + * {@link ngAnimate ngAnimate module} for more information. + */ + animation: invokeLaterAndSetModuleName('$animateProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#filter + * @module ng + * @param {string} name Filter name - this must be a valid angular expression identifier + * @param {Function} filterFactory Factory function for creating new instance of filter. + * @description + * See {@link ng.$filterProvider#register $filterProvider.register()}. + * + *
+ * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`. + * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace + * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores + * (`myapp_subsection_filterx`). + *
+ */ + filter: invokeLaterAndSetModuleName('$filterProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#controller + * @module ng + * @param {string|Object} name Controller name, or an object map of controllers where the + * keys are the names and the values are the constructors. + * @param {Function} constructor Controller constructor function. + * @description + * See {@link ng.$controllerProvider#register $controllerProvider.register()}. + */ + controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#directive + * @module ng + * @param {string|Object} name Directive name, or an object map of directives where the + * keys are the names and the values are the factories. + * @param {Function} directiveFactory Factory function for creating new instance of + * directives. + * @description + * See {@link ng.$compileProvider#directive $compileProvider.directive()}. + */ + directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'), + + /** + * @ngdoc method + * @name angular.Module#component + * @module ng + * @param {string} name Name of the component in camel-case (i.e. myComp which will match as my-comp) + * @param {Object} options Component definition object (a simplified + * {@link ng.$compile#directive-definition-object directive definition object}) + * + * @description + * See {@link ng.$compileProvider#component $compileProvider.component()}. + */ + component: invokeLaterAndSetModuleName('$compileProvider', 'component'), + + /** + * @ngdoc method + * @name angular.Module#config + * @module ng + * @param {Function} configFn Execute this function on module load. Useful for service + * configuration. + * @description + * Use this method to register work which needs to be performed on module loading. + * For more about how to configure services, see + * {@link providers#provider-recipe Provider Recipe}. + */ + config: config, + + /** + * @ngdoc method + * @name angular.Module#run + * @module ng + * @param {Function} initializationFn Execute this function after injector creation. + * Useful for application initialization. + * @description + * Use this method to register work which should be performed when the injector is done + * loading all modules. + */ + run: function(block) { + runBlocks.push(block); + return this; + } + }; + + if (configFn) { + config(configFn); + } + + return moduleInstance; + + /** + * @param {string} provider + * @param {string} method + * @param {String=} insertMethod + * @returns {angular.Module} + */ + function invokeLater(provider, method, insertMethod, queue) { + if (!queue) queue = invokeQueue; + return function() { + queue[insertMethod || 'push']([provider, method, arguments]); + return moduleInstance; + }; + } + + /** + * @param {string} provider + * @param {string} method + * @returns {angular.Module} + */ + function invokeLaterAndSetModuleName(provider, method) { + return function(recipeName, factoryFunction) { + if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name; + invokeQueue.push([provider, method, arguments]); + return moduleInstance; + }; + } + }); + }; + }); + +} + +setupModuleLoader(window); +})(window); + +/** + * Closure compiler type information + * + * @typedef { { + * requires: !Array., + * invokeQueue: !Array.>, + * + * service: function(string, Function):angular.Module, + * factory: function(string, Function):angular.Module, + * value: function(string, *):angular.Module, + * + * filter: function(string, Function):angular.Module, + * + * init: function(Function):angular.Module + * } } + */ +angular.Module; + diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.min.js new file mode 100644 index 00000000..316ee26e --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-loader.min.js @@ -0,0 +1,10 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(){'use strict';function d(b){return function(){var a=arguments[0],e;e="["+(b?b+":":"")+a+"] http://errors.angularjs.org/1.5.0/"+(b?b+"/":"")+a;for(a=1;a= line.length) { + index -= line.length; + } else { + return { line: i + 1, column: index + 1 }; + } + } +} +var PARSE_CACHE_FOR_TEXT_LITERALS = Object.create(null); + +function parseTextLiteral(text) { + var cachedFn = PARSE_CACHE_FOR_TEXT_LITERALS[text]; + if (cachedFn != null) { + return cachedFn; + } + function parsedFn(context) { return text; } + parsedFn['$$watchDelegate'] = function watchDelegate(scope, listener, objectEquality) { + var unwatch = scope['$watch'](noop, + function textLiteralWatcher() { + if (isFunction(listener)) { listener.call(null, text, text, scope); } + unwatch(); + }, + objectEquality); + return unwatch; + }; + PARSE_CACHE_FOR_TEXT_LITERALS[text] = parsedFn; + parsedFn['exp'] = text; // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + parsedFn['expressions'] = []; // Require this to call $compile.$$addBindingInfo() which allows Protractor to find elements by binding. + return parsedFn; +} + +function subtractOffset(expressionFn, offset) { + if (offset === 0) { + return expressionFn; + } + function minusOffset(value) { + return (value == void 0) ? value : value - offset; + } + function parsedFn(context) { return minusOffset(expressionFn(context)); } + var unwatch; + parsedFn['$$watchDelegate'] = function watchDelegate(scope, listener, objectEquality) { + unwatch = scope['$watch'](expressionFn, + function pluralExpressionWatchListener(newValue, oldValue) { + if (isFunction(listener)) { listener.call(null, minusOffset(newValue), minusOffset(oldValue), scope); } + }, + objectEquality); + return unwatch; + }; + return parsedFn; +} + +// NOTE: ADVANCED_OPTIMIZATIONS mode. +// +// This file is compiled with Closure compiler's ADVANCED_OPTIMIZATIONS flag! Be wary of using +// constructs incompatible with that mode. + +/* global $interpolateMinErr: false */ +/* global isFunction: false */ +/* global noop: false */ + +/** + * @constructor + * @private + */ +function MessageSelectorBase(expressionFn, choices) { + var self = this; + this.expressionFn = expressionFn; + this.choices = choices; + if (choices["other"] === void 0) { + throw $interpolateMinErr('reqother', '“other” is a required option.'); + } + this.parsedFn = function(context) { return self.getResult(context); }; + this.parsedFn['$$watchDelegate'] = function $$watchDelegate(scope, listener, objectEquality) { + return self.watchDelegate(scope, listener, objectEquality); + }; + this.parsedFn['exp'] = expressionFn['exp']; + this.parsedFn['expressions'] = expressionFn['expressions']; +} + +MessageSelectorBase.prototype.getMessageFn = function getMessageFn(value) { + return this.choices[this.categorizeValue(value)]; +}; + +MessageSelectorBase.prototype.getResult = function getResult(context) { + return this.getMessageFn(this.expressionFn(context))(context); +}; + +MessageSelectorBase.prototype.watchDelegate = function watchDelegate(scope, listener, objectEquality) { + var watchers = new MessageSelectorWatchers(this, scope, listener, objectEquality); + return function() { watchers.cancelWatch(); }; +}; + +/** + * @constructor + * @private + */ +function MessageSelectorWatchers(msgSelector, scope, listener, objectEquality) { + var self = this; + this.scope = scope; + this.msgSelector = msgSelector; + this.listener = listener; + this.objectEquality = objectEquality; + this.lastMessage = void 0; + this.messageFnWatcher = noop; + var expressionFnListener = function(newValue, oldValue) { return self.expressionFnListener(newValue, oldValue); }; + this.expressionFnWatcher = scope['$watch'](msgSelector.expressionFn, expressionFnListener, objectEquality); +} + +MessageSelectorWatchers.prototype.expressionFnListener = function expressionFnListener(newValue, oldValue) { + var self = this; + this.messageFnWatcher(); + var messageFnListener = function(newMessage, oldMessage) { return self.messageFnListener(newMessage, oldMessage); }; + var messageFn = this.msgSelector.getMessageFn(newValue); + this.messageFnWatcher = this.scope['$watch'](messageFn, messageFnListener, this.objectEquality); +}; + +MessageSelectorWatchers.prototype.messageFnListener = function messageFnListener(newMessage, oldMessage) { + if (isFunction(this.listener)) { + this.listener.call(null, newMessage, newMessage === oldMessage ? newMessage : this.lastMessage, this.scope); + } + this.lastMessage = newMessage; +}; + +MessageSelectorWatchers.prototype.cancelWatch = function cancelWatch() { + this.expressionFnWatcher(); + this.messageFnWatcher(); +}; + +/** + * @constructor + * @extends MessageSelectorBase + * @private + */ +function SelectMessage(expressionFn, choices) { + MessageSelectorBase.call(this, expressionFn, choices); +} + +function SelectMessageProto() {} +SelectMessageProto.prototype = MessageSelectorBase.prototype; + +SelectMessage.prototype = new SelectMessageProto(); +SelectMessage.prototype.categorizeValue = function categorizeSelectValue(value) { + return (this.choices[value] !== void 0) ? value : "other"; +}; + +/** + * @constructor + * @extends MessageSelectorBase + * @private + */ +function PluralMessage(expressionFn, choices, offset, pluralCat) { + MessageSelectorBase.call(this, expressionFn, choices); + this.offset = offset; + this.pluralCat = pluralCat; +} + +function PluralMessageProto() {} +PluralMessageProto.prototype = MessageSelectorBase.prototype; + +PluralMessage.prototype = new PluralMessageProto(); +PluralMessage.prototype.categorizeValue = function categorizePluralValue(value) { + if (isNaN(value)) { + return "other"; + } else if (this.choices[value] !== void 0) { + return value; + } else { + var category = this.pluralCat(value - this.offset); + return (this.choices[category] !== void 0) ? category : "other"; + } +}; + +// NOTE: ADVANCED_OPTIMIZATIONS mode. +// +// This file is compiled with Closure compiler's ADVANCED_OPTIMIZATIONS flag! Be wary of using +// constructs incompatible with that mode. + +/* global $interpolateMinErr: false */ +/* global isFunction: false */ +/* global parseTextLiteral: false */ + +/** + * @constructor + * @private + */ +function InterpolationParts(trustedContext, allOrNothing) { + this.trustedContext = trustedContext; + this.allOrNothing = allOrNothing; + this.textParts = []; + this.expressionFns = []; + this.expressionIndices = []; + this.partialText = ''; + this.concatParts = null; +} + +InterpolationParts.prototype.flushPartialText = function flushPartialText() { + if (this.partialText) { + if (this.concatParts == null) { + this.textParts.push(this.partialText); + } else { + this.textParts.push(this.concatParts.join('')); + this.concatParts = null; + } + this.partialText = ''; + } +}; + +InterpolationParts.prototype.addText = function addText(text) { + if (text.length) { + if (!this.partialText) { + this.partialText = text; + } else if (this.concatParts) { + this.concatParts.push(text); + } else { + this.concatParts = [this.partialText, text]; + } + } +}; + +InterpolationParts.prototype.addExpressionFn = function addExpressionFn(expressionFn) { + this.flushPartialText(); + this.expressionIndices.push(this.textParts.length); + this.expressionFns.push(expressionFn); + this.textParts.push(''); +}; + +InterpolationParts.prototype.getExpressionValues = function getExpressionValues(context) { + var expressionValues = new Array(this.expressionFns.length); + for (var i = 0; i < this.expressionFns.length; i++) { + expressionValues[i] = this.expressionFns[i](context); + } + return expressionValues; +}; + +InterpolationParts.prototype.getResult = function getResult(expressionValues) { + for (var i = 0; i < this.expressionIndices.length; i++) { + var expressionValue = expressionValues[i]; + if (this.allOrNothing && expressionValue === void 0) return; + this.textParts[this.expressionIndices[i]] = expressionValue; + } + return this.textParts.join(''); +}; + + +InterpolationParts.prototype.toParsedFn = function toParsedFn(mustHaveExpression, originalText) { + var self = this; + this.flushPartialText(); + if (mustHaveExpression && this.expressionFns.length === 0) { + return void 0; + } + if (this.textParts.length === 0) { + return parseTextLiteral(''); + } + if (this.trustedContext && this.textParts.length > 1) { + $interpolateMinErr['throwNoconcat'](originalText); + } + if (this.expressionFns.length === 0) { + if (this.textParts.length != 1) { this.errorInParseLogic(); } + return parseTextLiteral(this.textParts[0]); + } + var parsedFn = function(context) { + return self.getResult(self.getExpressionValues(context)); + }; + parsedFn['$$watchDelegate'] = function $$watchDelegate(scope, listener, objectEquality) { + return self.watchDelegate(scope, listener, objectEquality); + }; + + parsedFn['exp'] = originalText; // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + parsedFn['expressions'] = new Array(this.expressionFns.length); // Require this to call $compile.$$addBindingInfo() which allows Protractor to find elements by binding. + for (var i = 0; i < this.expressionFns.length; i++) { + parsedFn['expressions'][i] = this.expressionFns[i]['exp']; + } + + return parsedFn; +}; + +InterpolationParts.prototype.watchDelegate = function watchDelegate(scope, listener, objectEquality) { + var watcher = new InterpolationPartsWatcher(this, scope, listener, objectEquality); + return function() { watcher.cancelWatch(); }; +}; + +function InterpolationPartsWatcher(interpolationParts, scope, listener, objectEquality) { + this.interpolationParts = interpolationParts; + this.scope = scope; + this.previousResult = (void 0); + this.listener = listener; + var self = this; + this.expressionFnsWatcher = scope['$watchGroup'](interpolationParts.expressionFns, function(newExpressionValues, oldExpressionValues) { + self.watchListener(newExpressionValues, oldExpressionValues); + }); +} + +InterpolationPartsWatcher.prototype.watchListener = function watchListener(newExpressionValues, oldExpressionValues) { + var result = this.interpolationParts.getResult(newExpressionValues); + if (isFunction(this.listener)) { + this.listener.call(null, result, newExpressionValues === oldExpressionValues ? result : this.previousResult, this.scope); + } + this.previousResult = result; +}; + +InterpolationPartsWatcher.prototype.cancelWatch = function cancelWatch() { + this.expressionFnsWatcher(); +}; + +// NOTE: ADVANCED_OPTIMIZATIONS mode. +// +// This file is compiled with Closure compiler's ADVANCED_OPTIMIZATIONS flag! Be wary of using +// constructs incompatible with that mode. + +/* global $interpolateMinErr: false */ +/* global indexToLineAndColumn: false */ +/* global InterpolationParts: false */ +/* global PluralMessage: false */ +/* global SelectMessage: false */ +/* global subtractOffset: false */ + +// The params src and dst are exactly one of two types: NestedParserState or MessageFormatParser. +// This function is fully optimized by V8. (inspect via IRHydra or --trace-deopt.) +// The idea behind writing it this way is to avoid repeating oneself. This is the ONE place where +// the parser state that is saved/restored when parsing nested mustaches is specified. +function copyNestedParserState(src, dst) { + dst.expressionFn = src.expressionFn; + dst.expressionMinusOffsetFn = src.expressionMinusOffsetFn; + dst.pluralOffset = src.pluralOffset; + dst.choices = src.choices; + dst.choiceKey = src.choiceKey; + dst.interpolationParts = src.interpolationParts; + dst.ruleChoiceKeyword = src.ruleChoiceKeyword; + dst.msgStartIndex = src.msgStartIndex; + dst.expressionStartIndex = src.expressionStartIndex; +} + +function NestedParserState(parser) { + copyNestedParserState(parser, this); +} + +/** + * @constructor + * @private + */ +function MessageFormatParser(text, startIndex, $parse, pluralCat, stringifier, + mustHaveExpression, trustedContext, allOrNothing) { + this.text = text; + this.index = startIndex || 0; + this.$parse = $parse; + this.pluralCat = pluralCat; + this.stringifier = stringifier; + this.mustHaveExpression = !!mustHaveExpression; + this.trustedContext = trustedContext; + this.allOrNothing = !!allOrNothing; + this.expressionFn = null; + this.expressionMinusOffsetFn = null; + this.pluralOffset = null; + this.choices = null; + this.choiceKey = null; + this.interpolationParts = null; + this.msgStartIndex = null; + this.nestedStateStack = []; + this.parsedFn = null; + this.rule = null; + this.ruleStack = null; + this.ruleChoiceKeyword = null; + this.interpNestLevel = null; + this.expressionStartIndex = null; + this.stringStartIndex = null; + this.stringQuote = null; + this.stringInterestsRe = null; + this.angularOperatorStack = null; + this.textPart = null; +} + +// preserve v8 optimization. +var EMPTY_STATE = new NestedParserState(new MessageFormatParser( + /* text= */ '', /* startIndex= */ 0, /* $parse= */ null, /* pluralCat= */ null, /* stringifier= */ null, + /* mustHaveExpression= */ false, /* trustedContext= */ null, /* allOrNothing */ false)); + +MessageFormatParser.prototype.pushState = function pushState() { + this.nestedStateStack.push(new NestedParserState(this)); + copyNestedParserState(EMPTY_STATE, this); +}; + +MessageFormatParser.prototype.popState = function popState() { + if (this.nestedStateStack.length === 0) { + this.errorInParseLogic(); + } + var previousState = this.nestedStateStack.pop(); + copyNestedParserState(previousState, this); +}; + +// Oh my JavaScript! Who knew you couldn't match a regex at a specific +// location in a string but will always search forward?! +// Apparently you'll be growing this ability via the sticky flag (y) in +// ES6. I'll just to work around you for now. +MessageFormatParser.prototype.matchRe = function matchRe(re, search) { + re.lastIndex = this.index; + var match = re.exec(this.text); + if (match != null && (search === true || (match.index == this.index))) { + this.index = re.lastIndex; + return match; + } + return null; +}; + +MessageFormatParser.prototype.searchRe = function searchRe(re) { + return this.matchRe(re, true); +}; + + +MessageFormatParser.prototype.consumeRe = function consumeRe(re) { + // Without the sticky flag, we can't use the .test() method to consume a + // match at the current index. Instead, we'll use the slower .exec() method + // and verify match.index. + return !!this.matchRe(re); +}; + +// Run through our grammar avoiding deeply nested function call chains. +MessageFormatParser.prototype.run = function run(initialRule) { + this.ruleStack = [initialRule]; + do { + this.rule = this.ruleStack.pop(); + while (this.rule) { + this.rule(); + } + this.assertRuleOrNull(this.rule); + } while (this.ruleStack.length > 0); +}; + +MessageFormatParser.prototype.errorInParseLogic = function errorInParseLogic() { + throw $interpolateMinErr('logicbug', + 'The messageformat parser has encountered an internal error. Please file a github issue against the AngularJS project and provide this message text that triggers the bug. Text: “{0}”', + this.text); +}; + +MessageFormatParser.prototype.assertRuleOrNull = function assertRuleOrNull(rule) { + if (rule === void 0) { + this.errorInParseLogic(); + } +}; + +var NEXT_WORD_RE = /\s*(\w+)\s*/g; +MessageFormatParser.prototype.errorExpecting = function errorExpecting() { + // What was wrong with the syntax? Unsupported type, missing comma, or something else? + var match = this.matchRe(NEXT_WORD_RE), position; + if (match == null) { + position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('reqarg', + 'Expected one of “plural” or “select” at line {0}, column {1} of text “{2}”', + position.line, position.column, this.text); + } + var word = match[1]; + if (word == "select" || word == "plural") { + position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('reqcomma', + 'Expected a comma after the keyword “{0}” at line {1}, column {2} of text “{3}”', + word, position.line, position.column, this.text); + } else { + position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('unknarg', + 'Unsupported keyword “{0}” at line {0}, column {1}. Only “plural” and “select” are currently supported. Text: “{3}”', + word, position.line, position.column, this.text); + } +}; + +var STRING_START_RE = /['"]/g; +MessageFormatParser.prototype.ruleString = function ruleString() { + var match = this.matchRe(STRING_START_RE); + if (match == null) { + var position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('wantstring', + 'Expected the beginning of a string at line {0}, column {1} in text “{2}”', + position.line, position.column, this.text); + } + this.startStringAtMatch(match); +}; + +MessageFormatParser.prototype.startStringAtMatch = function startStringAtMatch(match) { + this.stringStartIndex = match.index; + this.stringQuote = match[0]; + this.stringInterestsRe = this.stringQuote == "'" ? SQUOTED_STRING_INTEREST_RE : DQUOTED_STRING_INTEREST_RE; + this.rule = this.ruleInsideString; +}; + +var SQUOTED_STRING_INTEREST_RE = /\\(?:\\|'|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{2}|[0-7]{3}|\r\n|\n|[\s\S])|'/g; +var DQUOTED_STRING_INTEREST_RE = /\\(?:\\|"|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{2}|[0-7]{3}|\r\n|\n|[\s\S])|"/g; +MessageFormatParser.prototype.ruleInsideString = function ruleInsideString() { + var match = this.searchRe(this.stringInterestsRe); + if (match == null) { + var position = indexToLineAndColumn(this.text, this.stringStartIndex); + throw $interpolateMinErr('untermstr', + 'The string beginning at line {0}, column {1} is unterminated in text “{2}”', + position.line, position.column, this.text); + } + var chars = match[0]; + if (match == this.stringQuote) { + this.rule = null; + } +}; + +var PLURAL_OR_SELECT_ARG_TYPE_RE = /\s*(plural|select)\s*,\s*/g; +MessageFormatParser.prototype.rulePluralOrSelect = function rulePluralOrSelect() { + var match = this.searchRe(PLURAL_OR_SELECT_ARG_TYPE_RE); + if (match == null) { + this.errorExpecting(); + } + var argType = match[1]; + switch (argType) { + case "plural": this.rule = this.rulePluralStyle; break; + case "select": this.rule = this.ruleSelectStyle; break; + default: this.errorInParseLogic(); + } +}; + +MessageFormatParser.prototype.rulePluralStyle = function rulePluralStyle() { + this.choices = Object.create(null); + this.ruleChoiceKeyword = this.rulePluralValueOrKeyword; + this.rule = this.rulePluralOffset; +}; + +MessageFormatParser.prototype.ruleSelectStyle = function ruleSelectStyle() { + this.choices = Object.create(null); + this.ruleChoiceKeyword = this.ruleSelectKeyword; + this.rule = this.ruleSelectKeyword; +}; + +var NUMBER_RE = /[0]|(?:[1-9][0-9]*)/g; +var PLURAL_OFFSET_RE = new RegExp("\\s*offset\\s*:\\s*(" + NUMBER_RE.source + ")", "g"); + +MessageFormatParser.prototype.rulePluralOffset = function rulePluralOffset() { + var match = this.matchRe(PLURAL_OFFSET_RE); + this.pluralOffset = (match == null) ? 0 : parseInt(match[1], 10); + this.expressionMinusOffsetFn = subtractOffset(this.expressionFn, this.pluralOffset); + this.rule = this.rulePluralValueOrKeyword; +}; + +MessageFormatParser.prototype.assertChoiceKeyIsNew = function assertChoiceKeyIsNew(choiceKey, index) { + if (this.choices[choiceKey] !== void 0) { + var position = indexToLineAndColumn(this.text, index); + throw $interpolateMinErr('dupvalue', + 'The choice “{0}” is specified more than once. Duplicate key is at line {1}, column {2} in text “{3}”', + choiceKey, position.line, position.column, this.text); + } +}; + +var SELECT_KEYWORD = /\s*(\w+)/g; +MessageFormatParser.prototype.ruleSelectKeyword = function ruleSelectKeyword() { + var match = this.matchRe(SELECT_KEYWORD); + if (match == null) { + this.parsedFn = new SelectMessage(this.expressionFn, this.choices).parsedFn; + this.rule = null; + return; + } + this.choiceKey = match[1]; + this.assertChoiceKeyIsNew(this.choiceKey, match.index); + this.rule = this.ruleMessageText; +}; + +var EXPLICIT_VALUE_OR_KEYWORD_RE = new RegExp("\\s*(?:(?:=(" + NUMBER_RE.source + "))|(\\w+))", "g"); +MessageFormatParser.prototype.rulePluralValueOrKeyword = function rulePluralValueOrKeyword() { + var match = this.matchRe(EXPLICIT_VALUE_OR_KEYWORD_RE); + if (match == null) { + this.parsedFn = new PluralMessage(this.expressionFn, this.choices, this.pluralOffset, this.pluralCat).parsedFn; + this.rule = null; + return; + } + if (match[1] != null) { + this.choiceKey = parseInt(match[1], 10); + } else { + this.choiceKey = match[2]; + } + this.assertChoiceKeyIsNew(this.choiceKey, match.index); + this.rule = this.ruleMessageText; +}; + +var BRACE_OPEN_RE = /\s*{/g; +var BRACE_CLOSE_RE = /}/g; +MessageFormatParser.prototype.ruleMessageText = function ruleMessageText() { + if (!this.consumeRe(BRACE_OPEN_RE)) { + var position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('reqopenbrace', + 'The plural choice “{0}” must be followed by a message in braces at line {1}, column {2} in text “{3}”', + this.choiceKey, position.line, position.column, this.text); + } + this.msgStartIndex = this.index; + this.interpolationParts = new InterpolationParts(this.trustedContext, this.allOrNothing); + this.rule = this.ruleInInterpolationOrMessageText; +}; + +// Note: Since "\" is used as an escape character, don't allow it to be part of the +// startSymbol/endSymbol when I add the feature to allow them to be redefined. +var INTERP_OR_END_MESSAGE_RE = /\\.|{{|}/g; +var INTERP_OR_PLURALVALUE_OR_END_MESSAGE_RE = /\\.|{{|#|}/g; +var ESCAPE_OR_MUSTACHE_BEGIN_RE = /\\.|{{/g; +MessageFormatParser.prototype.advanceInInterpolationOrMessageText = function advanceInInterpolationOrMessageText() { + var currentIndex = this.index, match, re; + if (this.ruleChoiceKeyword == null) { // interpolation + match = this.searchRe(ESCAPE_OR_MUSTACHE_BEGIN_RE); + if (match == null) { // End of interpolation text. Nothing more to process. + this.textPart = this.text.substring(currentIndex); + this.index = this.text.length; + return null; + } + } else { + match = this.searchRe(this.ruleChoiceKeyword == this.rulePluralValueOrKeyword ? + INTERP_OR_PLURALVALUE_OR_END_MESSAGE_RE : INTERP_OR_END_MESSAGE_RE); + if (match == null) { + var position = indexToLineAndColumn(this.text, this.msgStartIndex); + throw $interpolateMinErr('reqendbrace', + 'The plural/select choice “{0}” message starting at line {1}, column {2} does not have an ending closing brace. Text “{3}”', + this.choiceKey, position.line, position.column, this.text); + } + } + // match is non-null. + var token = match[0]; + this.textPart = this.text.substring(currentIndex, match.index); + return token; +}; + +MessageFormatParser.prototype.ruleInInterpolationOrMessageText = function ruleInInterpolationOrMessageText() { + var currentIndex = this.index; + var token = this.advanceInInterpolationOrMessageText(); + if (token == null) { + // End of interpolation text. Nothing more to process. + this.index = this.text.length; + this.interpolationParts.addText(this.text.substring(currentIndex)); + this.rule = null; + return; + } + if (token[0] == "\\") { + // unescape next character and continue + this.interpolationParts.addText(this.textPart + token[1]); + return; + } + this.interpolationParts.addText(this.textPart); + if (token == "{{") { + this.pushState(); + this.ruleStack.push(this.ruleEndMustacheInInterpolationOrMessage); + this.rule = this.ruleEnteredMustache; + } else if (token == "}") { + this.choices[this.choiceKey] = this.interpolationParts.toParsedFn(/*mustHaveExpression=*/false, this.text); + this.rule = this.ruleChoiceKeyword; + } else if (token == "#") { + this.interpolationParts.addExpressionFn(this.expressionMinusOffsetFn); + } else { + this.errorInParseLogic(); + } +}; + +MessageFormatParser.prototype.ruleInterpolate = function ruleInterpolate() { + this.interpolationParts = new InterpolationParts(this.trustedContext, this.allOrNothing); + this.rule = this.ruleInInterpolation; +}; + +MessageFormatParser.prototype.ruleInInterpolation = function ruleInInterpolation() { + var currentIndex = this.index; + var match = this.searchRe(ESCAPE_OR_MUSTACHE_BEGIN_RE); + if (match == null) { + // End of interpolation text. Nothing more to process. + this.index = this.text.length; + this.interpolationParts.addText(this.text.substring(currentIndex)); + this.parsedFn = this.interpolationParts.toParsedFn(this.mustHaveExpression, this.text); + this.rule = null; + return; + } + var token = match[0]; + if (token[0] == "\\") { + // unescape next character and continue + this.interpolationParts.addText(this.text.substring(currentIndex, match.index) + token[1]); + return; + } + this.interpolationParts.addText(this.text.substring(currentIndex, match.index)); + this.pushState(); + this.ruleStack.push(this.ruleInterpolationEndMustache); + this.rule = this.ruleEnteredMustache; +}; + +MessageFormatParser.prototype.ruleInterpolationEndMustache = function ruleInterpolationEndMustache() { + var expressionFn = this.parsedFn; + this.popState(); + this.interpolationParts.addExpressionFn(expressionFn); + this.rule = this.ruleInInterpolation; +}; + +MessageFormatParser.prototype.ruleEnteredMustache = function ruleEnteredMustache() { + this.parsedFn = null; + this.ruleStack.push(this.ruleEndMustache); + this.rule = this.ruleAngularExpression; +}; + +MessageFormatParser.prototype.ruleEndMustacheInInterpolationOrMessage = function ruleEndMustacheInInterpolationOrMessage() { + var expressionFn = this.parsedFn; + this.popState(); + this.interpolationParts.addExpressionFn(expressionFn); + this.rule = this.ruleInInterpolationOrMessageText; +}; + + + +var INTERP_END_RE = /\s*}}/g; +MessageFormatParser.prototype.ruleEndMustache = function ruleEndMustache() { + var match = this.matchRe(INTERP_END_RE); + if (match == null) { + var position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('reqendinterp', + 'Expecting end of interpolation symbol, “{0}”, at line {1}, column {2} in text “{3}”', + '}}', position.line, position.column, this.text); + } + if (this.parsedFn == null) { + // If we parsed a MessageFormat extension, (e.g. select/plural today, maybe more some other + // day), then the result *has* to be a string and those rules would have already set + // this.parsedFn. If there was no MessageFormat extension, then there is no requirement to + // stringify the result and parsedFn isn't set. We set it here. While we could have set it + // unconditionally when exiting the Angular expression, I intend for us to not just replace + // $interpolate, but also to replace $parse in a future version (so ng-bind can work), and in + // such a case we do not want to unnecessarily stringify something if it's not going to be used + // in a string context. + this.parsedFn = this.$parse(this.expressionFn, this.stringifier); + this.parsedFn['exp'] = this.expressionFn['exp']; // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + this.parsedFn['expressions'] = this.expressionFn['expressions']; // Require this to call $compile.$$addBindingInfo() which allows Protractor to find elements by binding. + } + this.rule = null; +}; + +MessageFormatParser.prototype.ruleAngularExpression = function ruleAngularExpression() { + this.angularOperatorStack = []; + this.expressionStartIndex = this.index; + this.rule = this.ruleInAngularExpression; +}; + +function getEndOperator(opBegin) { + switch (opBegin) { + case "{": return "}"; + case "[": return "]"; + case "(": return ")"; + default: return null; + } +} + +function getBeginOperator(opEnd) { + switch (opEnd) { + case "}": return "{"; + case "]": return "["; + case ")": return "("; + default: return null; + } +} + +// TODO(chirayu): The interpolation endSymbol must also be accounted for. It +// just so happens that "}" is an operator so it's in the list below. But we +// should support any other type of start/end interpolation symbol. +var INTERESTING_OPERATORS_RE = /[[\]{}()'",]/g; +MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularExpression() { + var startIndex = this.index; + var match = this.searchRe(INTERESTING_OPERATORS_RE); + var position; + if (match == null) { + if (this.angularOperatorStack.length === 0) { + // This is the end of the Angular expression so this is actually a + // success. Note that when inside an interpolation, this means we even + // consumed the closing interpolation symbols if they were curlies. This + // is NOT an error at this point but will become an error further up the + // stack when the part that saw the opening curlies is unable to find the + // closing ones. + this.index = this.text.length; + this.expressionFn = this.$parse(this.text.substring(this.expressionStartIndex, this.index)); + // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + this.expressionFn['exp'] = this.text.substring(this.expressionStartIndex, this.index); + this.expressionFn['expressions'] = this.expressionFn['expressions']; + this.rule = null; + return; + } + var innermostOperator = this.angularOperatorStack[0]; + throw $interpolateMinErr('badexpr', + 'Unexpected end of Angular expression. Expecting operator “{0}” at the end of the text “{1}”', + this.getEndOperator(innermostOperator), this.text); + } + var operator = match[0]; + if (operator == "'" || operator == '"') { + this.ruleStack.push(this.ruleInAngularExpression); + this.startStringAtMatch(match); + return; + } + if (operator == ",") { + if (this.trustedContext) { + position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('unsafe', + 'Use of select/plural MessageFormat syntax is currently disallowed in a secure context ({0}). At line {1}, column {2} of text “{3}”', + this.trustedContext, position.line, position.column, this.text); + } + // only the top level comma has relevance. + if (this.angularOperatorStack.length === 0) { + // todo: does this need to be trimmed? + this.expressionFn = this.$parse(this.text.substring(this.expressionStartIndex, match.index)); + // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + this.expressionFn['exp'] = this.text.substring(this.expressionStartIndex, match.index); + this.expressionFn['expressions'] = this.expressionFn['expressions']; + this.rule = null; + this.rule = this.rulePluralOrSelect; + } + return; + } + if (getEndOperator(operator) != null) { + this.angularOperatorStack.unshift(operator); + return; + } + var beginOperator = getBeginOperator(operator); + if (beginOperator == null) { + this.errorInParseLogic(); + } + if (this.angularOperatorStack.length > 0) { + if (beginOperator == this.angularOperatorStack[0]) { + this.angularOperatorStack.shift(); + return; + } + position = indexToLineAndColumn(this.text, this.index); + throw $interpolateMinErr('badexpr', + 'Unexpected operator “{0}” at line {1}, column {2} in text. Was expecting “{3}”. Text: “{4}”', + operator, position.line, position.column, getEndOperator(this.angularOperatorStack[0]), this.text); + } + // We are trying to pop off the operator stack but there really isn't anything to pop off. + this.index = match.index; + this.expressionFn = this.$parse(this.text.substring(this.expressionStartIndex, this.index)); + // Needed to pretend to be $interpolate for tests copied from interpolateSpec.js + this.expressionFn['exp'] = this.text.substring(this.expressionStartIndex, this.index); + this.expressionFn['expressions'] = this.expressionFn['expressions']; + this.rule = null; +}; + +// NOTE: ADVANCED_OPTIMIZATIONS mode. +// +// This file is compiled with Closure compiler's ADVANCED_OPTIMIZATIONS flag! Be wary of using +// constructs incompatible with that mode. + +/* global $interpolateMinErr: false */ +/* global MessageFormatParser: false */ +/* global stringify: false */ + +/** + * @ngdoc service + * @name $$messageFormat + * + * @description + * Angular internal service to recognize MessageFormat extensions in interpolation expressions. + * For more information, see: + * https://docs.google.com/a/google.com/document/d/1pbtW2yvtmFBikfRrJd8VAsabiFkKezmYZ_PbgdjQOVU/edit + * + * ## Example + * + * + * + *
+ *
+ * {{recipients.length, plural, offset:1 + * =0 {{{sender.name}} gave no gifts (\#=#)} + * =1 {{{sender.name}} gave one gift to {{recipients[0].name}} (\#=#)} + * one {{{sender.name}} gave {{recipients[0].name}} and one other person a gift (\#=#)} + * other {{{sender.name}} gave {{recipients[0].name}} and # other people a gift (\#=#)} + * }} + *
+ *
+ * + * + * function Person(name, gender) { + * this.name = name; + * this.gender = gender; + * } + * + * var alice = new Person("Alice", "female"), + * bob = new Person("Bob", "male"), + * charlie = new Person("Charlie", "male"), + * harry = new Person("Harry Potter", "male"); + * + * angular.module('msgFmtExample', ['ngMessageFormat']) + * .controller('AppController', ['$scope', function($scope) { + * $scope.recipients = [alice, bob, charlie]; + * $scope.sender = harry; + * $scope.decreaseRecipients = function() { + * --$scope.recipients.length; + * }; + * }]); + * + * + * + * describe('MessageFormat plural', function() { + * it('should pluralize initial values', function() { + * var messageElem = element(by.binding('recipients.length')), decreaseRecipientsBtn = element(by.id('decreaseRecipients')); + * expect(messageElem.getText()).toEqual('Harry Potter gave Alice and 2 other people a gift (#=2)'); + * decreaseRecipientsBtn.click(); + * expect(messageElem.getText()).toEqual('Harry Potter gave Alice and one other person a gift (#=1)'); + * decreaseRecipientsBtn.click(); + * expect(messageElem.getText()).toEqual('Harry Potter gave one gift to Alice (#=0)'); + * decreaseRecipientsBtn.click(); + * expect(messageElem.getText()).toEqual('Harry Potter gave no gifts (#=-1)'); + * }); + * }); + * + *
+ */ +var $$MessageFormatFactory = ['$parse', '$locale', '$sce', '$exceptionHandler', function $$messageFormat( + $parse, $locale, $sce, $exceptionHandler) { + + function getStringifier(trustedContext, allOrNothing, text) { + return function stringifier(value) { + try { + value = trustedContext ? $sce['getTrusted'](trustedContext, value) : $sce['valueOf'](value); + return allOrNothing && (value === void 0) ? value : stringify(value); + } catch (err) { + $exceptionHandler($interpolateMinErr['interr'](text, err)); + } + }; + } + + function interpolate(text, mustHaveExpression, trustedContext, allOrNothing) { + var stringifier = getStringifier(trustedContext, allOrNothing, text); + var parser = new MessageFormatParser(text, 0, $parse, $locale['pluralCat'], stringifier, + mustHaveExpression, trustedContext, allOrNothing); + parser.run(parser.ruleInterpolate); + return parser.parsedFn; + } + + return { + 'interpolate': interpolate + }; +}]; + +var $$interpolateDecorator = ['$$messageFormat', '$delegate', function $$interpolateDecorator($$messageFormat, $interpolate) { + if ($interpolate['startSymbol']() != "{{" || $interpolate['endSymbol']() != "}}") { + throw $interpolateMinErr('nochgmustache', 'angular-message-format.js currently does not allow you to use custom start and end symbols for interpolation.'); + } + var interpolate = $$messageFormat['interpolate']; + interpolate['startSymbol'] = $interpolate['startSymbol']; + interpolate['endSymbol'] = $interpolate['endSymbol']; + return interpolate; +}]; + + +/** + * @ngdoc module + * @name ngMessageFormat + * @packageName angular-message-format + * @description + */ +var module = window['angular']['module']('ngMessageFormat', ['ng']); +module['factory']('$$messageFormat', $$MessageFormatFactory); +module['config'](['$provide', function($provide) { + $provide['decorator']('$interpolate', $$interpolateDecorator); +}]); + + +})(window, window.angular); diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-message-format.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-message-format.min.js new file mode 100644 index 00000000..f85a5876 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-message-format.min.js @@ -0,0 +1,26 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(h){'use strict';function C(a){if(null==a)return"";switch(typeof a){case "string":return a;case "number":return""+a;default:return D(a)}}function f(a,b){for(var d=a.split(/\n/g),k=0;k=c.length)b-=c.length;else return{h:k+1,f:b+1}}}function t(a){function b(){return a}var d=u[a];if(null!=d)return d;b.$$watchDelegate=function(b,d,c){var e=b.$watch(v,function(){m(d)&&d.call(null,a,a,b);e()},c);return e};u[a]=b;b.exp=a;b.expressions=[];return b}function F(a,b){function d(a){return void 0== +a?a:a-b}function c(b){return d(a(b))}if(0===b)return a;var e;c.$$watchDelegate=function(b,c,k){return e=b.$watch(a,function(a,k){m(c)&&c.call(null,d(a),d(k),b)},k)};return c}function l(a,b){var d=this;this.b=a;this.e=b;if(void 0===b.other)throw e("reqother");this.d=function(a){return d.D(a)};this.d.$$watchDelegate=function(a,b,c){return d.P(a,b,c)};this.d.exp=a.exp;this.d.expressions=a.expressions}function n(a,b,d,c){var e=this;this.scope=b;this.oa=a;this.v=d;this.qa=c;this.U=void 0;this.K=v;this.ka= +b.$watch(a.b,function(a){return e.ja(a)},c)}function p(a,b){l.call(this,a,b)}function w(){}function q(a,b,d,c){l.call(this,a,b);this.offset=d;this.M=c}function x(){}function g(a,b){this.u=a;this.B=b;this.i=[];this.g=[];this.J=[];this.s="";this.q=null}function r(a,b,d){this.c=a;this.scope=b;this.W=void 0;this.v=d;var c=this;this.la=b.$watchGroup(a.g,function(a,b){c.Ea(a,b)})}function s(a,b){b.b=a.b;b.C=a.C;b.w=a.w;b.e=a.e;b.k=a.k;b.c=a.c;b.n=a.n;b.F=a.F;b.l=a.l}function y(a){s(a,this)}function c(a, +b,d,c,e,E,f,g){this.text=a;this.index=b||0;this.A=d;this.M=c;this.Da=e;this.pa=!!E;this.u=f;this.B=!!g;this.F=this.c=this.k=this.e=this.w=this.C=this.b=null;this.L=[];this.G=this.j=this.ca=this.O=this.da=this.l=this.n=this.o=this.a=this.d=null}function z(a){switch(a){case "{":return"}";case "[":return"]";case "(":return")";default:return null}}function G(a){switch(a){case "}":return"{";case "]":return"[";case ")":return"(";default:return null}}var e=h.angular.$interpolateMinErr,v=h.angular.noop,m= +h.angular.isFunction,D=h.angular.toJson,u=Object.create(null);l.prototype.T=function(a){return this.e[this.R(a)]};l.prototype.D=function(a){return this.T(this.b(a))(a)};l.prototype.P=function(a,b,d){var c=new n(this,a,b,d);return function(){c.I()}};n.prototype.ja=function(a){var b=this;this.K();a=this.oa.T(a);this.K=this.scope.$watch(a,function(a,c){return b.na(a,c)},this.qa)};n.prototype.na=function(a,b){m(this.v)&&this.v.call(null,a,a===b?a:this.U,this.scope);this.U=a};n.prototype.I=function(){this.ka(); +this.K()};w.prototype=l.prototype;p.prototype=new w;p.prototype.R=function(a){return void 0!==this.e[a]?a:"other"};x.prototype=l.prototype;q.prototype=new x;q.prototype.R=function(a){if(isNaN(a))return"other";if(void 0!==this.e[a])return a;a=this.M(a-this.offset);return void 0!==this.e[a]?a:"other"};g.prototype.S=function(){this.s&&(null==this.q?this.i.push(this.s):(this.i.push(this.q.join("")),this.q=null),this.s="")};g.prototype.p=function(a){a.length&&(this.s?this.q?this.q.push(a):this.q=[this.s, +a]:this.s=a)};g.prototype.H=function(a){this.S();this.J.push(this.i.length);this.g.push(a);this.i.push("")};g.prototype.ma=function(a){for(var b=Array(this.g.length),d=0;d + * + *
+ *
You did not enter a field
+ *
+ * Your email must be between 5 and 100 characters long + *
+ *
+ * + * ``` + * + * Now whatever key/value entries are present within the provided object (in this case `$error`) then + * the ngMessages directive will render the inner first ngMessage directive (depending if the key values + * match the attribute value present on each ngMessage directive). In other words, if your errors + * object contains the following data: + * + * ```javascript + * + * myField.$error = { minlength : true, required : true }; + * ``` + * + * Then the `required` message will be displayed first. When required is false then the `minlength` message + * will be displayed right after (since these messages are ordered this way in the template HTML code). + * The prioritization of each message is determined by what order they're present in the DOM. + * Therefore, instead of having custom JavaScript code determine the priority of what errors are + * present before others, the presentation of the errors are handled within the template. + * + * By default, ngMessages will only display one error at a time. However, if you wish to display all + * messages then the `ng-messages-multiple` attribute flag can be used on the element containing the + * ngMessages directive to make this happen. + * + * ```html + * + *
...
+ * + * + * ... + * ``` + * + * ## Reusing and Overriding Messages + * In addition to prioritization, ngMessages also allows for including messages from a remote or an inline + * template. This allows for generic collection of messages to be reused across multiple parts of an + * application. + * + * ```html + * + * + *
+ *
+ *
+ * ``` + * + * However, including generic messages may not be useful enough to match all input fields, therefore, + * `ngMessages` provides the ability to override messages defined in the remote template by redefining + * them within the directive container. + * + * ```html + * + * + * + *
+ * + * + *
+ * + *
You did not enter your email address
+ * + * + *
Your email address is invalid
+ * + * + *
+ *
+ *
+ * ``` + * + * In the example HTML code above the message that is set on required will override the corresponding + * required message defined within the remote template. Therefore, with particular input fields (such + * email addresses, date fields, autocomplete inputs, etc...), specialized error messages can be applied + * while more generic messages can be used to handle other, more general input errors. + * + * ## Dynamic Messaging + * ngMessages also supports using expressions to dynamically change key values. Using arrays and + * repeaters to list messages is also supported. This means that the code below will be able to + * fully adapt itself and display the appropriate message when any of the expression data changes: + * + * ```html + *
+ * + *
+ *
You did not enter your email address
+ *
+ * + *
{{ errorMessage.text }}
+ *
+ *
+ *
+ * ``` + * + * The `errorMessage.type` expression can be a string value or it can be an array so + * that multiple errors can be associated with a single error message: + * + * ```html + * + *
+ *
You did not enter your email address
+ *
+ * Your email must be between 5 and 100 characters long + *
+ *
+ * ``` + * + * Feel free to use other structural directives such as ng-if and ng-switch to further control + * what messages are active and when. Be careful, if you place ng-message on the same element + * as these structural directives, Angular may not be able to determine if a message is active + * or not. Therefore it is best to place the ng-message on a child element of the structural + * directive. + * + * ```html + *
+ *
+ *
Please enter something
+ *
+ *
+ * ``` + * + * ## Animations + * If the `ngAnimate` module is active within the application then the `ngMessages`, `ngMessage` and + * `ngMessageExp` directives will trigger animations whenever any messages are added and removed from + * the DOM by the `ngMessages` directive. + * + * Whenever the `ngMessages` directive contains one or more visible messages then the `.ng-active` CSS + * class will be added to the element. The `.ng-inactive` CSS class will be applied when there are no + * messages present. Therefore, CSS transitions and keyframes as well as JavaScript animations can + * hook into the animations whenever these classes are added/removed. + * + * Let's say that our HTML code for our messages container looks like so: + * + * ```html + * + * ``` + * + * Then the CSS animation code for the message container looks like so: + * + * ```css + * .my-messages { + * transition:1s linear all; + * } + * .my-messages.ng-active { + * // messages are visible + * } + * .my-messages.ng-inactive { + * // messages are hidden + * } + * ``` + * + * Whenever an inner message is attached (becomes visible) or removed (becomes hidden) then the enter + * and leave animation is triggered for each particular element bound to the `ngMessage` directive. + * + * Therefore, the CSS code for the inner messages looks like so: + * + * ```css + * .some-message { + * transition:1s linear all; + * } + * + * .some-message.ng-enter {} + * .some-message.ng-enter.ng-enter-active {} + * + * .some-message.ng-leave {} + * .some-message.ng-leave.ng-leave-active {} + * ``` + * + * {@link ngAnimate Click here} to learn how to use JavaScript animations or to learn more about ngAnimate. + */ +angular.module('ngMessages', []) + + /** + * @ngdoc directive + * @module ngMessages + * @name ngMessages + * @restrict AE + * + * @description + * `ngMessages` is a directive that is designed to show and hide messages based on the state + * of a key/value object that it listens on. The directive itself complements error message + * reporting with the `ngModel` $error object (which stores a key/value state of validation errors). + * + * `ngMessages` manages the state of internal messages within its container element. The internal + * messages use the `ngMessage` directive and will be inserted/removed from the page depending + * on if they're present within the key/value object. By default, only one message will be displayed + * at a time and this depends on the prioritization of the messages within the template. (This can + * be changed by using the `ng-messages-multiple` or `multiple` attribute on the directive container.) + * + * A remote template can also be used to promote message reusability and messages can also be + * overridden. + * + * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`. + * + * @usage + * ```html + * + * + * ... + * ... + * ... + * + * + * + * + * ... + * ... + * ... + * + * ``` + * + * @param {string} ngMessages an angular expression evaluating to a key/value object + * (this is typically the $error object on an ngModel instance). + * @param {string=} ngMessagesMultiple|multiple when set, all messages will be displayed with true + * + * @example + * + * + *
+ * + *
myForm.myName.$error = {{ myForm.myName.$error | json }}
+ * + *
+ *
You did not enter a field
+ *
Your field is too short
+ *
Your field is too long
+ *
+ *
+ *
+ * + * angular.module('ngMessagesExample', ['ngMessages']); + * + *
+ */ + .directive('ngMessages', ['$animate', function($animate) { + var ACTIVE_CLASS = 'ng-active'; + var INACTIVE_CLASS = 'ng-inactive'; + + return { + require: 'ngMessages', + restrict: 'AE', + controller: ['$element', '$scope', '$attrs', function($element, $scope, $attrs) { + var ctrl = this; + var latestKey = 0; + var nextAttachId = 0; + + this.getAttachId = function getAttachId() { return nextAttachId++; }; + + var messages = this.messages = {}; + var renderLater, cachedCollection; + + this.render = function(collection) { + collection = collection || {}; + + renderLater = false; + cachedCollection = collection; + + // this is true if the attribute is empty or if the attribute value is truthy + var multiple = isAttrTruthy($scope, $attrs.ngMessagesMultiple) || + isAttrTruthy($scope, $attrs.multiple); + + var unmatchedMessages = []; + var matchedKeys = {}; + var messageItem = ctrl.head; + var messageFound = false; + var totalMessages = 0; + + // we use != instead of !== to allow for both undefined and null values + while (messageItem != null) { + totalMessages++; + var messageCtrl = messageItem.message; + + var messageUsed = false; + if (!messageFound) { + forEach(collection, function(value, key) { + if (!messageUsed && truthy(value) && messageCtrl.test(key)) { + // this is to prevent the same error name from showing up twice + if (matchedKeys[key]) return; + matchedKeys[key] = true; + + messageUsed = true; + messageCtrl.attach(); + } + }); + } + + if (messageUsed) { + // unless we want to display multiple messages then we should + // set a flag here to avoid displaying the next message in the list + messageFound = !multiple; + } else { + unmatchedMessages.push(messageCtrl); + } + + messageItem = messageItem.next; + } + + forEach(unmatchedMessages, function(messageCtrl) { + messageCtrl.detach(); + }); + + unmatchedMessages.length !== totalMessages + ? $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS) + : $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS); + }; + + $scope.$watchCollection($attrs.ngMessages || $attrs['for'], ctrl.render); + + this.reRender = function() { + if (!renderLater) { + renderLater = true; + $scope.$evalAsync(function() { + if (renderLater) { + cachedCollection && ctrl.render(cachedCollection); + } + }); + } + }; + + this.register = function(comment, messageCtrl) { + var nextKey = latestKey.toString(); + messages[nextKey] = { + message: messageCtrl + }; + insertMessageNode($element[0], comment, nextKey); + comment.$$ngMessageNode = nextKey; + latestKey++; + + ctrl.reRender(); + }; + + this.deregister = function(comment) { + var key = comment.$$ngMessageNode; + delete comment.$$ngMessageNode; + removeMessageNode($element[0], comment, key); + delete messages[key]; + ctrl.reRender(); + }; + + function findPreviousMessage(parent, comment) { + var prevNode = comment; + var parentLookup = []; + while (prevNode && prevNode !== parent) { + var prevKey = prevNode.$$ngMessageNode; + if (prevKey && prevKey.length) { + return messages[prevKey]; + } + + // dive deeper into the DOM and examine its children for any ngMessage + // comments that may be in an element that appears deeper in the list + if (prevNode.childNodes.length && parentLookup.indexOf(prevNode) == -1) { + parentLookup.push(prevNode); + prevNode = prevNode.childNodes[prevNode.childNodes.length - 1]; + } else { + prevNode = prevNode.previousSibling || prevNode.parentNode; + } + } + } + + function insertMessageNode(parent, comment, key) { + var messageNode = messages[key]; + if (!ctrl.head) { + ctrl.head = messageNode; + } else { + var match = findPreviousMessage(parent, comment); + if (match) { + messageNode.next = match.next; + match.next = messageNode; + } else { + messageNode.next = ctrl.head; + ctrl.head = messageNode; + } + } + } + + function removeMessageNode(parent, comment, key) { + var messageNode = messages[key]; + + var match = findPreviousMessage(parent, comment); + if (match) { + match.next = messageNode.next; + } else { + ctrl.head = messageNode.next; + } + } + }] + }; + + function isAttrTruthy(scope, attr) { + return (isString(attr) && attr.length === 0) || //empty attribute + truthy(scope.$eval(attr)); + } + + function truthy(val) { + return isString(val) ? val.length : !!val; + } + }]) + + /** + * @ngdoc directive + * @name ngMessagesInclude + * @restrict AE + * @scope + * + * @description + * `ngMessagesInclude` is a directive with the purpose to import existing ngMessage template + * code from a remote template and place the downloaded template code into the exact spot + * that the ngMessagesInclude directive is placed within the ngMessages container. This allows + * for a series of pre-defined messages to be reused and also allows for the developer to + * determine what messages are overridden due to the placement of the ngMessagesInclude directive. + * + * @usage + * ```html + * + * + * ... + * + * + * + * + * ... + * + * ``` + * + * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`. + * + * @param {string} ngMessagesInclude|src a string value corresponding to the remote template. + */ + .directive('ngMessagesInclude', + ['$templateRequest', '$document', '$compile', function($templateRequest, $document, $compile) { + + return { + restrict: 'AE', + require: '^^ngMessages', // we only require this for validation sake + link: function($scope, element, attrs) { + var src = attrs.ngMessagesInclude || attrs.src; + $templateRequest(src).then(function(html) { + $compile(html)($scope, function(contents) { + element.after(contents); + + // the anchor is placed for debugging purposes + var anchor = jqLite($document[0].createComment(' ngMessagesInclude: ' + src + ' ')); + element.after(anchor); + + // we don't want to pollute the DOM anymore by keeping an empty directive element + element.remove(); + }); + }); + } + }; + }]) + + /** + * @ngdoc directive + * @name ngMessage + * @restrict AE + * @scope + * + * @description + * `ngMessage` is a directive with the purpose to show and hide a particular message. + * For `ngMessage` to operate, a parent `ngMessages` directive on a parent DOM element + * must be situated since it determines which messages are visible based on the state + * of the provided key/value map that `ngMessages` listens on. + * + * More information about using `ngMessage` can be found in the + * {@link module:ngMessages `ngMessages` module documentation}. + * + * @usage + * ```html + * + * + * ... + * ... + * + * + * + * + * ... + * ... + * + * ``` + * + * @param {expression} ngMessage|when a string value corresponding to the message key. + */ + .directive('ngMessage', ngMessageDirectiveFactory()) + + + /** + * @ngdoc directive + * @name ngMessageExp + * @restrict AE + * @priority 1 + * @scope + * + * @description + * `ngMessageExp` is a directive with the purpose to show and hide a particular message. + * For `ngMessageExp` to operate, a parent `ngMessages` directive on a parent DOM element + * must be situated since it determines which messages are visible based on the state + * of the provided key/value map that `ngMessages` listens on. + * + * @usage + * ```html + * + * + * ... + * + * + * + * + * ... + * + * ``` + * + * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`. + * + * @param {expression} ngMessageExp|whenExp an expression value corresponding to the message key. + */ + .directive('ngMessageExp', ngMessageDirectiveFactory()); + +function ngMessageDirectiveFactory() { + return ['$animate', function($animate) { + return { + restrict: 'AE', + transclude: 'element', + priority: 1, // must run before ngBind, otherwise the text is set on the comment + terminal: true, + require: '^^ngMessages', + link: function(scope, element, attrs, ngMessagesCtrl, $transclude) { + var commentNode = element[0]; + + var records; + var staticExp = attrs.ngMessage || attrs.when; + var dynamicExp = attrs.ngMessageExp || attrs.whenExp; + var assignRecords = function(items) { + records = items + ? (isArray(items) + ? items + : items.split(/[\s,]+/)) + : null; + ngMessagesCtrl.reRender(); + }; + + if (dynamicExp) { + assignRecords(scope.$eval(dynamicExp)); + scope.$watchCollection(dynamicExp, assignRecords); + } else { + assignRecords(staticExp); + } + + var currentElement, messageCtrl; + ngMessagesCtrl.register(commentNode, messageCtrl = { + test: function(name) { + return contains(records, name); + }, + attach: function() { + if (!currentElement) { + $transclude(scope, function(elm) { + $animate.enter(elm, null, element); + currentElement = elm; + + // Each time we attach this node to a message we get a new id that we can match + // when we are destroying the node later. + var $$attachId = currentElement.$$attachId = ngMessagesCtrl.getAttachId(); + + // in the event that the parent element is destroyed + // by any other structural directive then it's time + // to deregister the message from the controller + currentElement.on('$destroy', function() { + if (currentElement && currentElement.$$attachId === $$attachId) { + ngMessagesCtrl.deregister(commentNode); + messageCtrl.detach(); + } + }); + }); + } + }, + detach: function() { + if (currentElement) { + var elm = currentElement; + currentElement = null; + $animate.leave(elm); + } + } + }); + } + }; + }]; + + function contains(collection, key) { + if (collection) { + return isArray(collection) + ? collection.indexOf(key) >= 0 + : collection.hasOwnProperty(key); + } + } +} + + +})(window, window.angular); diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-messages.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-messages.min.js new file mode 100644 index 00000000..19f59cc8 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-messages.min.js @@ -0,0 +1,12 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(A,d,B){'use strict';function l(){return["$animate",function(v){return{restrict:"AE",transclude:"element",priority:1,terminal:!0,require:"^^ngMessages",link:function(n,r,a,b,m){var k=r[0],f,p=a.ngMessage||a.when;a=a.ngMessageExp||a.whenExp;var d=function(a){f=a?w(a)?a:a.split(/[\s,]+/):null;b.reRender()};a?(d(n.$eval(a)),n.$watchCollection(a,d)):d(p);var e,q;b.register(k,q={test:function(a){var g=f;a=g?w(g)?0<=g.indexOf(a):g.hasOwnProperty(a):void 0;return a},attach:function(){e||m(n,function(a){v.enter(a, +null,r);e=a;var g=e.$$attachId=b.getAttachId();e.on("$destroy",function(){e&&e.$$attachId===g&&(b.deregister(k),q.detach())})})},detach:function(){if(e){var a=e;e=null;v.leave(a)}}})}}}]}var w=d.isArray,x=d.forEach,y=d.isString,z=d.element;d.module("ngMessages",[]).directive("ngMessages",["$animate",function(d){function n(a,b){return y(b)&&0===b.length||r(a.$eval(b))}function r(a){return y(a)?a.length:!!a}return{require:"ngMessages",restrict:"AE",controller:["$element","$scope","$attrs",function(a, +b,m){function k(a,b){for(var c=b,f=[];c&&c!==a;){var h=c.$$ngMessageNode;if(h&&h.length)return e[h];c.childNodes.length&&-1==f.indexOf(c)?(f.push(c),c=c.childNodes[c.childNodes.length-1]):c=c.previousSibling||c.parentNode}}var f=this,p=0,l=0;this.getAttachId=function(){return l++};var e=this.messages={},q,s;this.render=function(g){g=g||{};q=!1;s=g;for(var e=n(b,m.ngMessagesMultiple)||n(b,m.multiple),c=[],k={},h=f.head,p=!1,l=0;null!=h;){l++;var t=h.message,u=!1;p||x(g,function(a,c){!u&&r(a)&&t.test(c)&& +!k[c]&&(u=k[c]=!0,t.attach())});u?p=!e:c.push(t);h=h.next}x(c,function(a){a.detach()});c.length!==l?d.setClass(a,"ng-active","ng-inactive"):d.setClass(a,"ng-inactive","ng-active")};b.$watchCollection(m.ngMessages||m["for"],f.render);this.reRender=function(){q||(q=!0,b.$evalAsync(function(){q&&s&&f.render(s)}))};this.register=function(g,b){var c=p.toString();e[c]={message:b};var d=a[0],h=e[c];f.head?(d=k(d,g))?(h.next=d.next,d.next=h):(h.next=f.head,f.head=h):f.head=h;g.$$ngMessageNode=c;p++;f.reRender()}; +this.deregister=function(b){var d=b.$$ngMessageNode;delete b.$$ngMessageNode;var c=e[d];(b=k(a[0],b))?b.next=c.next:f.head=c.next;delete e[d];f.reRender()}}]}}]).directive("ngMessagesInclude",["$templateRequest","$document","$compile",function(d,n,l){return{restrict:"AE",require:"^^ngMessages",link:function(a,b,m){var k=m.ngMessagesInclude||m.src;d(k).then(function(d){l(d)(a,function(a){b.after(a);a=z(n[0].createComment(" ngMessagesInclude: "+k+" "));b.after(a);b.remove()})})}}}]).directive("ngMessage", +l()).directive("ngMessageExp",l())})(window,window.angular); +//# sourceMappingURL=angular-messages.min.js.map diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-mocks.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-mocks.js new file mode 100644 index 00000000..34d36087 --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-mocks.js @@ -0,0 +1,2842 @@ +/** + * @license AngularJS v1.5.0 + * (c) 2010-2016 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) { + +'use strict'; + +/** + * @ngdoc object + * @name angular.mock + * @description + * + * Namespace from 'angular-mocks.js' which contains testing related code. + */ +angular.mock = {}; + +/** + * ! This is a private undocumented service ! + * + * @name $browser + * + * @description + * This service is a mock implementation of {@link ng.$browser}. It provides fake + * implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr, + * cookies, etc... + * + * The api of this service is the same as that of the real {@link ng.$browser $browser}, except + * that there are several helper methods available which can be used in tests. + */ +angular.mock.$BrowserProvider = function() { + this.$get = function() { + return new angular.mock.$Browser(); + }; +}; + +angular.mock.$Browser = function() { + var self = this; + + this.isMock = true; + self.$$url = "http://server/"; + self.$$lastUrl = self.$$url; // used by url polling fn + self.pollFns = []; + + // TODO(vojta): remove this temporary api + self.$$completeOutstandingRequest = angular.noop; + self.$$incOutstandingRequestCount = angular.noop; + + + // register url polling fn + + self.onUrlChange = function(listener) { + self.pollFns.push( + function() { + if (self.$$lastUrl !== self.$$url || self.$$state !== self.$$lastState) { + self.$$lastUrl = self.$$url; + self.$$lastState = self.$$state; + listener(self.$$url, self.$$state); + } + } + ); + + return listener; + }; + + self.$$applicationDestroyed = angular.noop; + self.$$checkUrlChange = angular.noop; + + self.deferredFns = []; + self.deferredNextId = 0; + + self.defer = function(fn, delay) { + delay = delay || 0; + self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId}); + self.deferredFns.sort(function(a, b) { return a.time - b.time;}); + return self.deferredNextId++; + }; + + + /** + * @name $browser#defer.now + * + * @description + * Current milliseconds mock time. + */ + self.defer.now = 0; + + + self.defer.cancel = function(deferId) { + var fnIndex; + + angular.forEach(self.deferredFns, function(fn, index) { + if (fn.id === deferId) fnIndex = index; + }); + + if (angular.isDefined(fnIndex)) { + self.deferredFns.splice(fnIndex, 1); + return true; + } + + return false; + }; + + + /** + * @name $browser#defer.flush + * + * @description + * Flushes all pending requests and executes the defer callbacks. + * + * @param {number=} number of milliseconds to flush. See {@link #defer.now} + */ + self.defer.flush = function(delay) { + if (angular.isDefined(delay)) { + self.defer.now += delay; + } else { + if (self.deferredFns.length) { + self.defer.now = self.deferredFns[self.deferredFns.length - 1].time; + } else { + throw new Error('No deferred tasks to be flushed'); + } + } + + while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) { + self.deferredFns.shift().fn(); + } + }; + + self.$$baseHref = '/'; + self.baseHref = function() { + return this.$$baseHref; + }; +}; +angular.mock.$Browser.prototype = { + +/** + * @name $browser#poll + * + * @description + * run all fns in pollFns + */ + poll: function poll() { + angular.forEach(this.pollFns, function(pollFn) { + pollFn(); + }); + }, + + url: function(url, replace, state) { + if (angular.isUndefined(state)) { + state = null; + } + if (url) { + this.$$url = url; + // Native pushState serializes & copies the object; simulate it. + this.$$state = angular.copy(state); + return this; + } + + return this.$$url; + }, + + state: function() { + return this.$$state; + }, + + notifyWhenNoOutstandingRequests: function(fn) { + fn(); + } +}; + + +/** + * @ngdoc provider + * @name $exceptionHandlerProvider + * + * @description + * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors + * passed to the `$exceptionHandler`. + */ + +/** + * @ngdoc service + * @name $exceptionHandler + * + * @description + * Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed + * to it. See {@link ngMock.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration + * information. + * + * + * ```js + * describe('$exceptionHandlerProvider', function() { + * + * it('should capture log messages and exceptions', function() { + * + * module(function($exceptionHandlerProvider) { + * $exceptionHandlerProvider.mode('log'); + * }); + * + * inject(function($log, $exceptionHandler, $timeout) { + * $timeout(function() { $log.log(1); }); + * $timeout(function() { $log.log(2); throw 'banana peel'; }); + * $timeout(function() { $log.log(3); }); + * expect($exceptionHandler.errors).toEqual([]); + * expect($log.assertEmpty()); + * $timeout.flush(); + * expect($exceptionHandler.errors).toEqual(['banana peel']); + * expect($log.log.logs).toEqual([[1], [2], [3]]); + * }); + * }); + * }); + * ``` + */ + +angular.mock.$ExceptionHandlerProvider = function() { + var handler; + + /** + * @ngdoc method + * @name $exceptionHandlerProvider#mode + * + * @description + * Sets the logging mode. + * + * @param {string} mode Mode of operation, defaults to `rethrow`. + * + * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log` + * mode stores an array of errors in `$exceptionHandler.errors`, to allow later + * assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and + * {@link ngMock.$log#reset reset()} + * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there + * is a bug in the application or test, so this mock will make these tests fail. + * For any implementations that expect exceptions to be thrown, the `rethrow` mode + * will also maintain a log of thrown errors. + */ + this.mode = function(mode) { + + switch (mode) { + case 'log': + case 'rethrow': + var errors = []; + handler = function(e) { + if (arguments.length == 1) { + errors.push(e); + } else { + errors.push([].slice.call(arguments, 0)); + } + if (mode === "rethrow") { + throw e; + } + }; + handler.errors = errors; + break; + default: + throw new Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!"); + } + }; + + this.$get = function() { + return handler; + }; + + this.mode('rethrow'); +}; + + +/** + * @ngdoc service + * @name $log + * + * @description + * Mock implementation of {@link ng.$log} that gathers all logged messages in arrays + * (one array per logging level). These arrays are exposed as `logs` property of each of the + * level-specific log function, e.g. for level `error` the array is exposed as `$log.error.logs`. + * + */ +angular.mock.$LogProvider = function() { + var debug = true; + + function concat(array1, array2, index) { + return array1.concat(Array.prototype.slice.call(array2, index)); + } + + this.debugEnabled = function(flag) { + if (angular.isDefined(flag)) { + debug = flag; + return this; + } else { + return debug; + } + }; + + this.$get = function() { + var $log = { + log: function() { $log.log.logs.push(concat([], arguments, 0)); }, + warn: function() { $log.warn.logs.push(concat([], arguments, 0)); }, + info: function() { $log.info.logs.push(concat([], arguments, 0)); }, + error: function() { $log.error.logs.push(concat([], arguments, 0)); }, + debug: function() { + if (debug) { + $log.debug.logs.push(concat([], arguments, 0)); + } + } + }; + + /** + * @ngdoc method + * @name $log#reset + * + * @description + * Reset all of the logging arrays to empty. + */ + $log.reset = function() { + /** + * @ngdoc property + * @name $log#log.logs + * + * @description + * Array of messages logged using {@link ng.$log#log `log()`}. + * + * @example + * ```js + * $log.log('Some Log'); + * var first = $log.log.logs.unshift(); + * ``` + */ + $log.log.logs = []; + /** + * @ngdoc property + * @name $log#info.logs + * + * @description + * Array of messages logged using {@link ng.$log#info `info()`}. + * + * @example + * ```js + * $log.info('Some Info'); + * var first = $log.info.logs.unshift(); + * ``` + */ + $log.info.logs = []; + /** + * @ngdoc property + * @name $log#warn.logs + * + * @description + * Array of messages logged using {@link ng.$log#warn `warn()`}. + * + * @example + * ```js + * $log.warn('Some Warning'); + * var first = $log.warn.logs.unshift(); + * ``` + */ + $log.warn.logs = []; + /** + * @ngdoc property + * @name $log#error.logs + * + * @description + * Array of messages logged using {@link ng.$log#error `error()`}. + * + * @example + * ```js + * $log.error('Some Error'); + * var first = $log.error.logs.unshift(); + * ``` + */ + $log.error.logs = []; + /** + * @ngdoc property + * @name $log#debug.logs + * + * @description + * Array of messages logged using {@link ng.$log#debug `debug()`}. + * + * @example + * ```js + * $log.debug('Some Error'); + * var first = $log.debug.logs.unshift(); + * ``` + */ + $log.debug.logs = []; + }; + + /** + * @ngdoc method + * @name $log#assertEmpty + * + * @description + * Assert that all of the logging methods have no logged messages. If any messages are present, + * an exception is thrown. + */ + $log.assertEmpty = function() { + var errors = []; + angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) { + angular.forEach($log[logLevel].logs, function(log) { + angular.forEach(log, function(logItem) { + errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + + (logItem.stack || '')); + }); + }); + }); + if (errors.length) { + errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or " + + "an expected log message was not checked and removed:"); + errors.push(''); + throw new Error(errors.join('\n---------\n')); + } + }; + + $log.reset(); + return $log; + }; +}; + + +/** + * @ngdoc service + * @name $interval + * + * @description + * Mock implementation of the $interval service. + * + * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to + * move forward by `millis` milliseconds and trigger any functions scheduled to run in that + * time. + * + * @param {function()} fn A function that should be called repeatedly. + * @param {number} delay Number of milliseconds between each function call. + * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat + * indefinitely. + * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise + * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. + * @param {...*=} Pass additional parameters to the executed function. + * @returns {promise} A promise which will be notified on each iteration. + */ +angular.mock.$IntervalProvider = function() { + this.$get = ['$browser', '$rootScope', '$q', '$$q', + function($browser, $rootScope, $q, $$q) { + var repeatFns = [], + nextRepeatId = 0, + now = 0; + + var $interval = function(fn, delay, count, invokeApply) { + var hasParams = arguments.length > 4, + args = hasParams ? Array.prototype.slice.call(arguments, 4) : [], + iteration = 0, + skipApply = (angular.isDefined(invokeApply) && !invokeApply), + deferred = (skipApply ? $$q : $q).defer(), + promise = deferred.promise; + + count = (angular.isDefined(count)) ? count : 0; + promise.then(null, null, (!hasParams) ? fn : function() { + fn.apply(null, args); + }); + + promise.$$intervalId = nextRepeatId; + + function tick() { + deferred.notify(iteration++); + + if (count > 0 && iteration >= count) { + var fnIndex; + deferred.resolve(iteration); + + angular.forEach(repeatFns, function(fn, index) { + if (fn.id === promise.$$intervalId) fnIndex = index; + }); + + if (angular.isDefined(fnIndex)) { + repeatFns.splice(fnIndex, 1); + } + } + + if (skipApply) { + $browser.defer.flush(); + } else { + $rootScope.$apply(); + } + } + + repeatFns.push({ + nextTime:(now + delay), + delay: delay, + fn: tick, + id: nextRepeatId, + deferred: deferred + }); + repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;}); + + nextRepeatId++; + return promise; + }; + /** + * @ngdoc method + * @name $interval#cancel + * + * @description + * Cancels a task associated with the `promise`. + * + * @param {promise} promise A promise from calling the `$interval` function. + * @returns {boolean} Returns `true` if the task was successfully cancelled. + */ + $interval.cancel = function(promise) { + if (!promise) return false; + var fnIndex; + + angular.forEach(repeatFns, function(fn, index) { + if (fn.id === promise.$$intervalId) fnIndex = index; + }); + + if (angular.isDefined(fnIndex)) { + repeatFns[fnIndex].deferred.reject('canceled'); + repeatFns.splice(fnIndex, 1); + return true; + } + + return false; + }; + + /** + * @ngdoc method + * @name $interval#flush + * @description + * + * Runs interval tasks scheduled to be run in the next `millis` milliseconds. + * + * @param {number=} millis maximum timeout amount to flush up until. + * + * @return {number} The amount of time moved forward. + */ + $interval.flush = function(millis) { + now += millis; + while (repeatFns.length && repeatFns[0].nextTime <= now) { + var task = repeatFns[0]; + task.fn(); + task.nextTime += task.delay; + repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;}); + } + return millis; + }; + + return $interval; + }]; +}; + + +/* jshint -W101 */ +/* The R_ISO8061_STR regex is never going to fit into the 100 char limit! + * This directive should go inside the anonymous function but a bug in JSHint means that it would + * not be enacted early enough to prevent the warning. + */ +var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; + +function jsonStringToDate(string) { + var match; + if (match = string.match(R_ISO8061_STR)) { + var date = new Date(0), + tzHour = 0, + tzMin = 0; + if (match[9]) { + tzHour = toInt(match[9] + match[10]); + tzMin = toInt(match[9] + match[11]); + } + date.setUTCFullYear(toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); + date.setUTCHours(toInt(match[4] || 0) - tzHour, + toInt(match[5] || 0) - tzMin, + toInt(match[6] || 0), + toInt(match[7] || 0)); + return date; + } + return string; +} + +function toInt(str) { + return parseInt(str, 10); +} + +function padNumber(num, digits, trim) { + var neg = ''; + if (num < 0) { + neg = '-'; + num = -num; + } + num = '' + num; + while (num.length < digits) num = '0' + num; + if (trim) { + num = num.substr(num.length - digits); + } + return neg + num; +} + + +/** + * @ngdoc type + * @name angular.mock.TzDate + * @description + * + * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`. + * + * Mock of the Date type which has its timezone specified via constructor arg. + * + * The main purpose is to create Date-like instances with timezone fixed to the specified timezone + * offset, so that we can test code that depends on local timezone settings without dependency on + * the time zone settings of the machine where the code is running. + * + * @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored) + * @param {(number|string)} timestamp Timestamp representing the desired time in *UTC* + * + * @example + * !!!! WARNING !!!!! + * This is not a complete Date object so only methods that were implemented can be called safely. + * To make matters worse, TzDate instances inherit stuff from Date via a prototype. + * + * We do our best to intercept calls to "unimplemented" methods, but since the list of methods is + * incomplete we might be missing some non-standard methods. This can result in errors like: + * "Date.prototype.foo called on incompatible Object". + * + * ```js + * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z'); + * newYearInBratislava.getTimezoneOffset() => -60; + * newYearInBratislava.getFullYear() => 2010; + * newYearInBratislava.getMonth() => 0; + * newYearInBratislava.getDate() => 1; + * newYearInBratislava.getHours() => 0; + * newYearInBratislava.getMinutes() => 0; + * newYearInBratislava.getSeconds() => 0; + * ``` + * + */ +angular.mock.TzDate = function(offset, timestamp) { + var self = new Date(0); + if (angular.isString(timestamp)) { + var tsStr = timestamp; + + self.origDate = jsonStringToDate(timestamp); + + timestamp = self.origDate.getTime(); + if (isNaN(timestamp)) { + throw { + name: "Illegal Argument", + message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string" + }; + } + } else { + self.origDate = new Date(timestamp); + } + + var localOffset = new Date(timestamp).getTimezoneOffset(); + self.offsetDiff = localOffset * 60 * 1000 - offset * 1000 * 60 * 60; + self.date = new Date(timestamp + self.offsetDiff); + + self.getTime = function() { + return self.date.getTime() - self.offsetDiff; + }; + + self.toLocaleDateString = function() { + return self.date.toLocaleDateString(); + }; + + self.getFullYear = function() { + return self.date.getFullYear(); + }; + + self.getMonth = function() { + return self.date.getMonth(); + }; + + self.getDate = function() { + return self.date.getDate(); + }; + + self.getHours = function() { + return self.date.getHours(); + }; + + self.getMinutes = function() { + return self.date.getMinutes(); + }; + + self.getSeconds = function() { + return self.date.getSeconds(); + }; + + self.getMilliseconds = function() { + return self.date.getMilliseconds(); + }; + + self.getTimezoneOffset = function() { + return offset * 60; + }; + + self.getUTCFullYear = function() { + return self.origDate.getUTCFullYear(); + }; + + self.getUTCMonth = function() { + return self.origDate.getUTCMonth(); + }; + + self.getUTCDate = function() { + return self.origDate.getUTCDate(); + }; + + self.getUTCHours = function() { + return self.origDate.getUTCHours(); + }; + + self.getUTCMinutes = function() { + return self.origDate.getUTCMinutes(); + }; + + self.getUTCSeconds = function() { + return self.origDate.getUTCSeconds(); + }; + + self.getUTCMilliseconds = function() { + return self.origDate.getUTCMilliseconds(); + }; + + self.getDay = function() { + return self.date.getDay(); + }; + + // provide this method only on browsers that already have it + if (self.toISOString) { + self.toISOString = function() { + return padNumber(self.origDate.getUTCFullYear(), 4) + '-' + + padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' + + padNumber(self.origDate.getUTCDate(), 2) + 'T' + + padNumber(self.origDate.getUTCHours(), 2) + ':' + + padNumber(self.origDate.getUTCMinutes(), 2) + ':' + + padNumber(self.origDate.getUTCSeconds(), 2) + '.' + + padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'; + }; + } + + //hide all methods not implemented in this mock that the Date prototype exposes + var unimplementedMethods = ['getUTCDay', + 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', + 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', + 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', + 'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString', + 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf']; + + angular.forEach(unimplementedMethods, function(methodName) { + self[methodName] = function() { + throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock"); + }; + }); + + return self; +}; + +//make "tzDateInstance instanceof Date" return true +angular.mock.TzDate.prototype = Date.prototype; +/* jshint +W101 */ + + +/** + * @ngdoc service + * @name $animate + * + * @description + * Mock implementation of the {@link ng.$animate `$animate`} service. Exposes two additional methods + * for testing animations. + */ +angular.mock.animate = angular.module('ngAnimateMock', ['ng']) + + .config(['$provide', function($provide) { + + $provide.factory('$$forceReflow', function() { + function reflowFn() { + reflowFn.totalReflows++; + } + reflowFn.totalReflows = 0; + return reflowFn; + }); + + $provide.factory('$$animateAsyncRun', function() { + var queue = []; + var queueFn = function() { + return function(fn) { + queue.push(fn); + }; + }; + queueFn.flush = function() { + if (queue.length === 0) return false; + + for (var i = 0; i < queue.length; i++) { + queue[i](); + } + queue = []; + + return true; + }; + return queueFn; + }); + + $provide.decorator('$$animateJs', ['$delegate', function($delegate) { + var runners = []; + + var animateJsConstructor = function() { + var animator = $delegate.apply($delegate, arguments); + // If no javascript animation is found, animator is undefined + if (animator) { + runners.push(animator); + } + return animator; + }; + + animateJsConstructor.$closeAndFlush = function() { + runners.forEach(function(runner) { + runner.end(); + }); + runners = []; + }; + + return animateJsConstructor; + }]); + + $provide.decorator('$animateCss', ['$delegate', function($delegate) { + var runners = []; + + var animateCssConstructor = function(element, options) { + var animator = $delegate(element, options); + runners.push(animator); + return animator; + }; + + animateCssConstructor.$closeAndFlush = function() { + runners.forEach(function(runner) { + runner.end(); + }); + runners = []; + }; + + return animateCssConstructor; + }]); + + $provide.decorator('$animate', ['$delegate', '$timeout', '$browser', '$$rAF', '$animateCss', '$$animateJs', + '$$forceReflow', '$$animateAsyncRun', '$rootScope', + function($delegate, $timeout, $browser, $$rAF, $animateCss, $$animateJs, + $$forceReflow, $$animateAsyncRun, $rootScope) { + var animate = { + queue: [], + cancel: $delegate.cancel, + on: $delegate.on, + off: $delegate.off, + pin: $delegate.pin, + get reflows() { + return $$forceReflow.totalReflows; + }, + enabled: $delegate.enabled, + /** + * @ngdoc method + * @name $animate#closeAndFlush + * @description + * + * This method will close all pending animations (both {@link ngAnimate#javascript-based-animations Javascript} + * and {@link ngAnimate.$animateCss CSS}) and it will also flush any remaining animation frames and/or callbacks. + */ + closeAndFlush: function() { + // we allow the flush command to swallow the errors + // because depending on whether CSS or JS animations are + // used, there may not be a RAF flush. The primary flush + // at the end of this function must throw an exception + // because it will track if there were pending animations + this.flush(true); + $animateCss.$closeAndFlush(); + $$animateJs.$closeAndFlush(); + this.flush(); + }, + /** + * @ngdoc method + * @name $animate#flush + * @description + * + * This method is used to flush the pending callbacks and animation frames to either start + * an animation or conclude an animation. Note that this will not actually close an + * actively running animation (see {@link ngMock.$animate#closeAndFlush `closeAndFlush()`} for that). + */ + flush: function(hideErrors) { + $rootScope.$digest(); + + var doNextRun, somethingFlushed = false; + do { + doNextRun = false; + + if ($$rAF.queue.length) { + $$rAF.flush(); + doNextRun = somethingFlushed = true; + } + + if ($$animateAsyncRun.flush()) { + doNextRun = somethingFlushed = true; + } + } while (doNextRun); + + if (!somethingFlushed && !hideErrors) { + throw new Error('No pending animations ready to be closed or flushed'); + } + + $rootScope.$digest(); + } + }; + + angular.forEach( + ['animate','enter','leave','move','addClass','removeClass','setClass'], function(method) { + animate[method] = function() { + animate.queue.push({ + event: method, + element: arguments[0], + options: arguments[arguments.length - 1], + args: arguments + }); + return $delegate[method].apply($delegate, arguments); + }; + }); + + return animate; + }]); + + }]); + + +/** + * @ngdoc function + * @name angular.mock.dump + * @description + * + * *NOTE*: this is not an injectable instance, just a globally available function. + * + * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for + * debugging. + * + * This method is also available on window, where it can be used to display objects on debug + * console. + * + * @param {*} object - any object to turn into string. + * @return {string} a serialized string of the argument + */ +angular.mock.dump = function(object) { + return serialize(object); + + function serialize(object) { + var out; + + if (angular.isElement(object)) { + object = angular.element(object); + out = angular.element('
'); + angular.forEach(object, function(element) { + out.append(angular.element(element).clone()); + }); + out = out.html(); + } else if (angular.isArray(object)) { + out = []; + angular.forEach(object, function(o) { + out.push(serialize(o)); + }); + out = '[ ' + out.join(', ') + ' ]'; + } else if (angular.isObject(object)) { + if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) { + out = serializeScope(object); + } else if (object instanceof Error) { + out = object.stack || ('' + object.name + ': ' + object.message); + } else { + // TODO(i): this prevents methods being logged, + // we should have a better way to serialize objects + out = angular.toJson(object, true); + } + } else { + out = String(object); + } + + return out; + } + + function serializeScope(scope, offset) { + offset = offset || ' '; + var log = [offset + 'Scope(' + scope.$id + '): {']; + for (var key in scope) { + if (Object.prototype.hasOwnProperty.call(scope, key) && !key.match(/^(\$|this)/)) { + log.push(' ' + key + ': ' + angular.toJson(scope[key])); + } + } + var child = scope.$$childHead; + while (child) { + log.push(serializeScope(child, offset + ' ')); + child = child.$$nextSibling; + } + log.push('}'); + return log.join('\n' + offset); + } +}; + +/** + * @ngdoc service + * @name $httpBackend + * @description + * Fake HTTP backend implementation suitable for unit testing applications that use the + * {@link ng.$http $http service}. + * + * *Note*: For fake HTTP backend implementation suitable for end-to-end testing or backend-less + * development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}. + * + * During unit testing, we want our unit tests to run quickly and have no external dependencies so + * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or + * [JSONP](http://en.wikipedia.org/wiki/JSONP) requests to a real server. All we really need is + * to verify whether a certain request has been sent or not, or alternatively just let the + * application make requests, respond with pre-trained responses and assert that the end result is + * what we expect it to be. + * + * This mock implementation can be used to respond with static or dynamic responses via the + * `expect` and `when` apis and their shortcuts (`expectGET`, `whenPOST`, etc). + * + * When an Angular application needs some data from a server, it calls the $http service, which + * sends the request to a real server using $httpBackend service. With dependency injection, it is + * easy to inject $httpBackend mock (which has the same API as $httpBackend) and use it to verify + * the requests and respond with some testing data without sending a request to a real server. + * + * There are two ways to specify what test data should be returned as http responses by the mock + * backend when the code under test makes http requests: + * + * - `$httpBackend.expect` - specifies a request expectation + * - `$httpBackend.when` - specifies a backend definition + * + * + * ## Request Expectations vs Backend Definitions + * + * Request expectations provide a way to make assertions about requests made by the application and + * to define responses for those requests. The test will fail if the expected requests are not made + * or they are made in the wrong order. + * + * Backend definitions allow you to define a fake backend for your application which doesn't assert + * if a particular request was made or not, it just returns a trained response if a request is made. + * The test will pass whether or not the request gets made during testing. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Request expectationsBackend definitions
Syntax.expect(...).respond(...).when(...).respond(...)
Typical usagestrict unit testsloose (black-box) unit testing
Fulfills multiple requestsNOYES
Order of requests mattersYESNO
Request requiredYESNO
Response requiredoptional (see below)YES
+ * + * In cases where both backend definitions and request expectations are specified during unit + * testing, the request expectations are evaluated first. + * + * If a request expectation has no response specified, the algorithm will search your backend + * definitions for an appropriate response. + * + * If a request didn't match any expectation or if the expectation doesn't have the response + * defined, the backend definitions are evaluated in sequential order to see if any of them match + * the request. The response from the first matched definition is returned. + * + * + * ## Flushing HTTP requests + * + * The $httpBackend used in production always responds to requests asynchronously. If we preserved + * this behavior in unit testing, we'd have to create async unit tests, which are hard to write, + * to follow and to maintain. But neither can the testing mock respond synchronously; that would + * change the execution of the code under test. For this reason, the mock $httpBackend has a + * `flush()` method, which allows the test to explicitly flush pending requests. This preserves + * the async api of the backend, while allowing the test to execute synchronously. + * + * + * ## Unit testing with mock $httpBackend + * The following code shows how to setup and use the mock backend when unit testing a controller. + * First we create the controller under test: + * + ```js + // The module code + angular + .module('MyApp', []) + .controller('MyController', MyController); + + // The controller code + function MyController($scope, $http) { + var authToken; + + $http.get('/auth.py').then(function(response) { + authToken = response.headers('A-Token'); + $scope.user = response.data; + }); + + $scope.saveMessage = function(message) { + var headers = { 'Authorization': authToken }; + $scope.status = 'Saving...'; + + $http.post('/add-msg.py', message, { headers: headers } ).then(function(response) { + $scope.status = ''; + }).catch(function() { + $scope.status = 'Failed...'; + }); + }; + } + ``` + * + * Now we setup the mock backend and create the test specs: + * + ```js + // testing controller + describe('MyController', function() { + var $httpBackend, $rootScope, createController, authRequestHandler; + + // Set up the module + beforeEach(module('MyApp')); + + beforeEach(inject(function($injector) { + // Set up the mock http service responses + $httpBackend = $injector.get('$httpBackend'); + // backend definition common for all tests + authRequestHandler = $httpBackend.when('GET', '/auth.py') + .respond({userId: 'userX'}, {'A-Token': 'xxx'}); + + // Get hold of a scope (i.e. the root scope) + $rootScope = $injector.get('$rootScope'); + // The $controller service is used to create instances of controllers + var $controller = $injector.get('$controller'); + + createController = function() { + return $controller('MyController', {'$scope' : $rootScope }); + }; + })); + + + afterEach(function() { + $httpBackend.verifyNoOutstandingExpectation(); + $httpBackend.verifyNoOutstandingRequest(); + }); + + + it('should fetch authentication token', function() { + $httpBackend.expectGET('/auth.py'); + var controller = createController(); + $httpBackend.flush(); + }); + + + it('should fail authentication', function() { + + // Notice how you can change the response even after it was set + authRequestHandler.respond(401, ''); + + $httpBackend.expectGET('/auth.py'); + var controller = createController(); + $httpBackend.flush(); + expect($rootScope.status).toBe('Failed...'); + }); + + + it('should send msg to server', function() { + var controller = createController(); + $httpBackend.flush(); + + // now you don’t care about the authentication, but + // the controller will still send the request and + // $httpBackend will respond without you having to + // specify the expectation and response for this request + + $httpBackend.expectPOST('/add-msg.py', 'message content').respond(201, ''); + $rootScope.saveMessage('message content'); + expect($rootScope.status).toBe('Saving...'); + $httpBackend.flush(); + expect($rootScope.status).toBe(''); + }); + + + it('should send auth header', function() { + var controller = createController(); + $httpBackend.flush(); + + $httpBackend.expectPOST('/add-msg.py', undefined, function(headers) { + // check if the header was sent, if it wasn't the expectation won't + // match the request and the test will fail + return headers['Authorization'] == 'xxx'; + }).respond(201, ''); + + $rootScope.saveMessage('whatever'); + $httpBackend.flush(); + }); + }); + ``` + * + * ## Dynamic responses + * + * You define a response to a request by chaining a call to `respond()` onto a definition or expectation. + * If you provide a **callback** as the first parameter to `respond(callback)` then you can dynamically generate + * a response based on the properties of the request. + * + * The `callback` function should be of the form `function(method, url, data, headers, params)`. + * + * ### Query parameters + * + * By default, query parameters on request URLs are parsed into the `params` object. So a request URL + * of `/list?q=searchstr&orderby=-name` would set `params` to be `{q: 'searchstr', orderby: '-name'}`. + * + * ### Regex parameter matching + * + * If an expectation or definition uses a **regex** to match the URL, you can provide an array of **keys** via a + * `params` argument. The index of each **key** in the array will match the index of a **group** in the + * **regex**. + * + * The `params` object in the **callback** will now have properties with these keys, which hold the value of the + * corresponding **group** in the **regex**. + * + * This also applies to the `when` and `expect` shortcut methods. + * + * + * ```js + * $httpBackend.expect('GET', /\/user\/(.+)/, undefined, undefined, ['id']) + * .respond(function(method, url, data, headers, params) { + * // for requested url of '/user/1234' params is {id: '1234'} + * }); + * + * $httpBackend.whenPATCH(/\/user\/(.+)\/article\/(.+)/, undefined, undefined, ['user', 'article']) + * .respond(function(method, url, data, headers, params) { + * // for url of '/user/1234/article/567' params is {user: '1234', article: '567'} + * }); + * ``` + * + * ## Matching route requests + * + * For extra convenience, `whenRoute` and `expectRoute` shortcuts are available. These methods offer colon + * delimited matching of the url path, ignoring the query string. This allows declarations + * similar to how application routes are configured with `$routeProvider`. Because these methods convert + * the definition url to regex, declaration order is important. Combined with query parameter parsing, + * the following is possible: + * + ```js + $httpBackend.whenRoute('GET', '/users/:id') + .respond(function(method, url, data, headers, params) { + return [200, MockUserList[Number(params.id)]]; + }); + + $httpBackend.whenRoute('GET', '/users') + .respond(function(method, url, data, headers, params) { + var userList = angular.copy(MockUserList), + defaultSort = 'lastName', + count, pages, isPrevious, isNext; + + // paged api response '/v1/users?page=2' + params.page = Number(params.page) || 1; + + // query for last names '/v1/users?q=Archer' + if (params.q) { + userList = $filter('filter')({lastName: params.q}); + } + + pages = Math.ceil(userList.length / pagingLength); + isPrevious = params.page > 1; + isNext = params.page < pages; + + return [200, { + count: userList.length, + previous: isPrevious, + next: isNext, + // sort field -> '/v1/users?sortBy=firstName' + results: $filter('orderBy')(userList, params.sortBy || defaultSort) + .splice((params.page - 1) * pagingLength, pagingLength) + }]; + }); + ``` + */ +angular.mock.$HttpBackendProvider = function() { + this.$get = ['$rootScope', '$timeout', createHttpBackendMock]; +}; + +/** + * General factory function for $httpBackend mock. + * Returns instance for unit testing (when no arguments specified): + * - passing through is disabled + * - auto flushing is disabled + * + * Returns instance for e2e testing (when `$delegate` and `$browser` specified): + * - passing through (delegating request to real backend) is enabled + * - auto flushing is enabled + * + * @param {Object=} $delegate Real $httpBackend instance (allow passing through if specified) + * @param {Object=} $browser Auto-flushing enabled if specified + * @return {Object} Instance of $httpBackend mock + */ +function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) { + var definitions = [], + expectations = [], + responses = [], + responsesPush = angular.bind(responses, responses.push), + copy = angular.copy; + + function createResponse(status, data, headers, statusText) { + if (angular.isFunction(status)) return status; + + return function() { + return angular.isNumber(status) + ? [status, data, headers, statusText] + : [200, status, data, headers]; + }; + } + + // TODO(vojta): change params to: method, url, data, headers, callback + function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) { + var xhr = new MockXhr(), + expectation = expectations[0], + wasExpected = false; + + function prettyPrint(data) { + return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp) + ? data + : angular.toJson(data); + } + + function wrapResponse(wrapped) { + if (!$browser && timeout) { + timeout.then ? timeout.then(handleTimeout) : $timeout(handleTimeout, timeout); + } + + return handleResponse; + + function handleResponse() { + var response = wrapped.response(method, url, data, headers, wrapped.params(url)); + xhr.$$respHeaders = response[2]; + callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(), + copy(response[3] || '')); + } + + function handleTimeout() { + for (var i = 0, ii = responses.length; i < ii; i++) { + if (responses[i] === handleResponse) { + responses.splice(i, 1); + callback(-1, undefined, ''); + break; + } + } + } + } + + if (expectation && expectation.match(method, url)) { + if (!expectation.matchData(data)) { + throw new Error('Expected ' + expectation + ' with different data\n' + + 'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data); + } + + if (!expectation.matchHeaders(headers)) { + throw new Error('Expected ' + expectation + ' with different headers\n' + + 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + + prettyPrint(headers)); + } + + expectations.shift(); + + if (expectation.response) { + responses.push(wrapResponse(expectation)); + return; + } + wasExpected = true; + } + + var i = -1, definition; + while ((definition = definitions[++i])) { + if (definition.match(method, url, data, headers || {})) { + if (definition.response) { + // if $browser specified, we do auto flush all requests + ($browser ? $browser.defer : responsesPush)(wrapResponse(definition)); + } else if (definition.passThrough) { + $delegate(method, url, data, callback, headers, timeout, withCredentials); + } else throw new Error('No response defined !'); + return; + } + } + throw wasExpected ? + new Error('No response defined !') : + new Error('Unexpected request: ' + method + ' ' + url + '\n' + + (expectation ? 'Expected ' + expectation : 'No more request expected')); + } + + /** + * @ngdoc method + * @name $httpBackend#when + * @description + * Creates a new backend definition. + * + * @param {string} method HTTP method. + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives + * data string and returns true if the data is as expected. + * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header + * object and returns true if the headers match the current definition. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + * + * - respond – + * `{function([status,] data[, headers, statusText]) + * | function(function(method, url, data, headers, params)}` + * – The respond method takes a set of static data to be returned or a function that can + * return an array containing response status (number), response data (string), response + * headers (Object), and the text for the status (string). The respond method returns the + * `requestHandler` object for possible overrides. + */ + $httpBackend.when = function(method, url, data, headers, keys) { + var definition = new MockHttpExpectation(method, url, data, headers, keys), + chain = { + respond: function(status, data, headers, statusText) { + definition.passThrough = undefined; + definition.response = createResponse(status, data, headers, statusText); + return chain; + } + }; + + if ($browser) { + chain.passThrough = function() { + definition.response = undefined; + definition.passThrough = true; + return chain; + }; + } + + definitions.push(definition); + return chain; + }; + + /** + * @ngdoc method + * @name $httpBackend#whenGET + * @description + * Creates a new backend definition for GET requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#whenHEAD + * @description + * Creates a new backend definition for HEAD requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#whenDELETE + * @description + * Creates a new backend definition for DELETE requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#whenPOST + * @description + * Creates a new backend definition for POST requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives + * data string and returns true if the data is as expected. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#whenPUT + * @description + * Creates a new backend definition for PUT requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives + * data string and returns true if the data is as expected. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#whenJSONP + * @description + * Creates a new backend definition for JSONP requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + createShortMethods('when'); + + /** + * @ngdoc method + * @name $httpBackend#whenRoute + * @description + * Creates a new backend definition that compares only with the requested route. + * + * @param {string} method HTTP method. + * @param {string} url HTTP url string that supports colon param matching. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. See #when for more info. + */ + $httpBackend.whenRoute = function(method, url) { + var pathObj = parseRoute(url); + return $httpBackend.when(method, pathObj.regexp, undefined, undefined, pathObj.keys); + }; + + function parseRoute(url) { + var ret = { + regexp: url + }, + keys = ret.keys = []; + + if (!url || !angular.isString(url)) return ret; + + url = url + .replace(/([().])/g, '\\$1') + .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) { + var optional = option === '?' ? option : null; + var star = option === '*' ? option : null; + keys.push({ name: key, optional: !!optional }); + slash = slash || ''; + return '' + + (optional ? '' : slash) + + '(?:' + + (optional ? slash : '') + + (star && '(.+?)' || '([^/]+)') + + (optional || '') + + ')' + + (optional || ''); + }) + .replace(/([\/$\*])/g, '\\$1'); + + ret.regexp = new RegExp('^' + url, 'i'); + return ret; + } + + /** + * @ngdoc method + * @name $httpBackend#expect + * @description + * Creates a new request expectation. + * + * @param {string} method HTTP method. + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that + * receives data string and returns true if the data is as expected, or Object if request body + * is in JSON format. + * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header + * object and returns true if the headers match the current expectation. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + * + * - respond – + * `{function([status,] data[, headers, statusText]) + * | function(function(method, url, data, headers, params)}` + * – The respond method takes a set of static data to be returned or a function that can + * return an array containing response status (number), response data (string), response + * headers (Object), and the text for the status (string). The respond method returns the + * `requestHandler` object for possible overrides. + */ + $httpBackend.expect = function(method, url, data, headers, keys) { + var expectation = new MockHttpExpectation(method, url, data, headers, keys), + chain = { + respond: function(status, data, headers, statusText) { + expectation.response = createResponse(status, data, headers, statusText); + return chain; + } + }; + + expectations.push(expectation); + return chain; + }; + + /** + * @ngdoc method + * @name $httpBackend#expectGET + * @description + * Creates a new request expectation for GET requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. See #expect for more info. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectHEAD + * @description + * Creates a new request expectation for HEAD requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectDELETE + * @description + * Creates a new request expectation for DELETE requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectPOST + * @description + * Creates a new request expectation for POST requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that + * receives data string and returns true if the data is as expected, or Object if request body + * is in JSON format. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectPUT + * @description + * Creates a new request expectation for PUT requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that + * receives data string and returns true if the data is as expected, or Object if request body + * is in JSON format. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectPATCH + * @description + * Creates a new request expectation for PATCH requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that + * receives data string and returns true if the data is as expected, or Object if request body + * is in JSON format. + * @param {Object=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + + /** + * @ngdoc method + * @name $httpBackend#expectJSONP + * @description + * Creates a new request expectation for JSONP requests. For more info see `expect()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives an url + * and returns true if the url matches the current definition. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. + */ + createShortMethods('expect'); + + /** + * @ngdoc method + * @name $httpBackend#expectRoute + * @description + * Creates a new request expectation that compares only with the requested route. + * + * @param {string} method HTTP method. + * @param {string} url HTTP url string that supports colon param matching. + * @returns {requestHandler} Returns an object with `respond` method that controls how a matched + * request is handled. You can save this object for later use and invoke `respond` again in + * order to change how a matched request is handled. See #expect for more info. + */ + $httpBackend.expectRoute = function(method, url) { + var pathObj = parseRoute(url); + return $httpBackend.expect(method, pathObj.regexp, undefined, undefined, pathObj.keys); + }; + + + /** + * @ngdoc method + * @name $httpBackend#flush + * @description + * Flushes all pending requests using the trained responses. + * + * @param {number=} count Number of responses to flush (in the order they arrived). If undefined, + * all pending requests will be flushed. If there are no pending requests when the flush method + * is called an exception is thrown (as this typically a sign of programming error). + */ + $httpBackend.flush = function(count, digest) { + if (digest !== false) $rootScope.$digest(); + if (!responses.length) throw new Error('No pending request to flush !'); + + if (angular.isDefined(count) && count !== null) { + while (count--) { + if (!responses.length) throw new Error('No more pending request to flush !'); + responses.shift()(); + } + } else { + while (responses.length) { + responses.shift()(); + } + } + $httpBackend.verifyNoOutstandingExpectation(digest); + }; + + + /** + * @ngdoc method + * @name $httpBackend#verifyNoOutstandingExpectation + * @description + * Verifies that all of the requests defined via the `expect` api were made. If any of the + * requests were not made, verifyNoOutstandingExpectation throws an exception. + * + * Typically, you would call this method following each test case that asserts requests using an + * "afterEach" clause. + * + * ```js + * afterEach($httpBackend.verifyNoOutstandingExpectation); + * ``` + */ + $httpBackend.verifyNoOutstandingExpectation = function(digest) { + if (digest !== false) $rootScope.$digest(); + if (expectations.length) { + throw new Error('Unsatisfied requests: ' + expectations.join(', ')); + } + }; + + + /** + * @ngdoc method + * @name $httpBackend#verifyNoOutstandingRequest + * @description + * Verifies that there are no outstanding requests that need to be flushed. + * + * Typically, you would call this method following each test case that asserts requests using an + * "afterEach" clause. + * + * ```js + * afterEach($httpBackend.verifyNoOutstandingRequest); + * ``` + */ + $httpBackend.verifyNoOutstandingRequest = function() { + if (responses.length) { + throw new Error('Unflushed requests: ' + responses.length); + } + }; + + + /** + * @ngdoc method + * @name $httpBackend#resetExpectations + * @description + * Resets all request expectations, but preserves all backend definitions. Typically, you would + * call resetExpectations during a multiple-phase test when you want to reuse the same instance of + * $httpBackend mock. + */ + $httpBackend.resetExpectations = function() { + expectations.length = 0; + responses.length = 0; + }; + + return $httpBackend; + + + function createShortMethods(prefix) { + angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD'], function(method) { + $httpBackend[prefix + method] = function(url, headers, keys) { + return $httpBackend[prefix](method, url, undefined, headers, keys); + }; + }); + + angular.forEach(['PUT', 'POST', 'PATCH'], function(method) { + $httpBackend[prefix + method] = function(url, data, headers, keys) { + return $httpBackend[prefix](method, url, data, headers, keys); + }; + }); + } +} + +function MockHttpExpectation(method, url, data, headers, keys) { + + this.data = data; + this.headers = headers; + + this.match = function(m, u, d, h) { + if (method != m) return false; + if (!this.matchUrl(u)) return false; + if (angular.isDefined(d) && !this.matchData(d)) return false; + if (angular.isDefined(h) && !this.matchHeaders(h)) return false; + return true; + }; + + this.matchUrl = function(u) { + if (!url) return true; + if (angular.isFunction(url.test)) return url.test(u); + if (angular.isFunction(url)) return url(u); + return url == u; + }; + + this.matchHeaders = function(h) { + if (angular.isUndefined(headers)) return true; + if (angular.isFunction(headers)) return headers(h); + return angular.equals(headers, h); + }; + + this.matchData = function(d) { + if (angular.isUndefined(data)) return true; + if (data && angular.isFunction(data.test)) return data.test(d); + if (data && angular.isFunction(data)) return data(d); + if (data && !angular.isString(data)) { + return angular.equals(angular.fromJson(angular.toJson(data)), angular.fromJson(d)); + } + return data == d; + }; + + this.toString = function() { + return method + ' ' + url; + }; + + this.params = function(u) { + return angular.extend(parseQuery(), pathParams()); + + function pathParams() { + var keyObj = {}; + if (!url || !angular.isFunction(url.test) || !keys || keys.length === 0) return keyObj; + + var m = url.exec(u); + if (!m) return keyObj; + for (var i = 1, len = m.length; i < len; ++i) { + var key = keys[i - 1]; + var val = m[i]; + if (key && val) { + keyObj[key.name || key] = val; + } + } + + return keyObj; + } + + function parseQuery() { + var obj = {}, key_value, key, + queryStr = u.indexOf('?') > -1 + ? u.substring(u.indexOf('?') + 1) + : ""; + + angular.forEach(queryStr.split('&'), function(keyValue) { + if (keyValue) { + key_value = keyValue.replace(/\+/g,'%20').split('='); + key = tryDecodeURIComponent(key_value[0]); + if (angular.isDefined(key)) { + var val = angular.isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true; + if (!hasOwnProperty.call(obj, key)) { + obj[key] = val; + } else if (angular.isArray(obj[key])) { + obj[key].push(val); + } else { + obj[key] = [obj[key],val]; + } + } + } + }); + return obj; + } + function tryDecodeURIComponent(value) { + try { + return decodeURIComponent(value); + } catch (e) { + // Ignore any invalid uri component + } + } + }; +} + +function createMockXhr() { + return new MockXhr(); +} + +function MockXhr() { + + // hack for testing $http, $httpBackend + MockXhr.$$lastInstance = this; + + this.open = function(method, url, async) { + this.$$method = method; + this.$$url = url; + this.$$async = async; + this.$$reqHeaders = {}; + this.$$respHeaders = {}; + }; + + this.send = function(data) { + this.$$data = data; + }; + + this.setRequestHeader = function(key, value) { + this.$$reqHeaders[key] = value; + }; + + this.getResponseHeader = function(name) { + // the lookup must be case insensitive, + // that's why we try two quick lookups first and full scan last + var header = this.$$respHeaders[name]; + if (header) return header; + + name = angular.lowercase(name); + header = this.$$respHeaders[name]; + if (header) return header; + + header = undefined; + angular.forEach(this.$$respHeaders, function(headerVal, headerName) { + if (!header && angular.lowercase(headerName) == name) header = headerVal; + }); + return header; + }; + + this.getAllResponseHeaders = function() { + var lines = []; + + angular.forEach(this.$$respHeaders, function(value, key) { + lines.push(key + ': ' + value); + }); + return lines.join('\n'); + }; + + this.abort = angular.noop; +} + + +/** + * @ngdoc service + * @name $timeout + * @description + * + * This service is just a simple decorator for {@link ng.$timeout $timeout} service + * that adds a "flush" and "verifyNoPendingTasks" methods. + */ + +angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $browser) { + + /** + * @ngdoc method + * @name $timeout#flush + * @description + * + * Flushes the queue of pending tasks. + * + * @param {number=} delay maximum timeout amount to flush up until + */ + $delegate.flush = function(delay) { + $browser.defer.flush(delay); + }; + + /** + * @ngdoc method + * @name $timeout#verifyNoPendingTasks + * @description + * + * Verifies that there are no pending tasks that need to be flushed. + */ + $delegate.verifyNoPendingTasks = function() { + if ($browser.deferredFns.length) { + throw new Error('Deferred tasks to flush (' + $browser.deferredFns.length + '): ' + + formatPendingTasksAsString($browser.deferredFns)); + } + }; + + function formatPendingTasksAsString(tasks) { + var result = []; + angular.forEach(tasks, function(task) { + result.push('{id: ' + task.id + ', ' + 'time: ' + task.time + '}'); + }); + + return result.join(', '); + } + + return $delegate; +}]; + +angular.mock.$RAFDecorator = ['$delegate', function($delegate) { + var rafFn = function(fn) { + var index = rafFn.queue.length; + rafFn.queue.push(fn); + return function() { + rafFn.queue.splice(index, 1); + }; + }; + + rafFn.queue = []; + rafFn.supported = $delegate.supported; + + rafFn.flush = function() { + if (rafFn.queue.length === 0) { + throw new Error('No rAF callbacks present'); + } + + var length = rafFn.queue.length; + for (var i = 0; i < length; i++) { + rafFn.queue[i](); + } + + rafFn.queue = rafFn.queue.slice(i); + }; + + return rafFn; +}]; + +/** + * + */ +angular.mock.$RootElementProvider = function() { + this.$get = function() { + return angular.element('
'); + }; +}; + +/** + * @ngdoc service + * @name $controller + * @description + * A decorator for {@link ng.$controller} with additional `bindings` parameter, useful when testing + * controllers of directives that use {@link $compile#-bindtocontroller- `bindToController`}. + * + * + * ## Example + * + * ```js + * + * // Directive definition ... + * + * myMod.directive('myDirective', { + * controller: 'MyDirectiveController', + * bindToController: { + * name: '@' + * } + * }); + * + * + * // Controller definition ... + * + * myMod.controller('MyDirectiveController', ['$log', function($log) { + * $log.info(this.name); + * })]; + * + * + * // In a test ... + * + * describe('myDirectiveController', function() { + * it('should write the bound name to the log', inject(function($controller, $log) { + * var ctrl = $controller('MyDirectiveController', { /* no locals */ }, { name: 'Clark Kent' }); + * expect(ctrl.name).toEqual('Clark Kent'); + * expect($log.info.logs).toEqual(['Clark Kent']); + * }); + * }); + * + * ``` + * + * @param {Function|string} constructor If called with a function then it's considered to be the + * controller constructor function. Otherwise it's considered to be a string which is used + * to retrieve the controller constructor using the following steps: + * + * * check if a controller with given name is registered via `$controllerProvider` + * * check if evaluating the string on the current scope returns a constructor + * * if $controllerProvider#allowGlobals, check `window[constructor]` on the global + * `window` object (not recommended) + * + * The string can use the `controller as property` syntax, where the controller instance is published + * as the specified property on the `scope`; the `scope` must be injected into `locals` param for this + * to work correctly. + * + * @param {Object} locals Injection locals for Controller. + * @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used + * to simulate the `bindToController` feature and simplify certain kinds of tests. + * @return {Object} Instance of given controller. + */ +angular.mock.$ControllerDecorator = ['$delegate', function($delegate) { + return function(expression, locals, later, ident) { + if (later && typeof later === 'object') { + var create = $delegate(expression, locals, true, ident); + angular.extend(create.instance, later); + return create(); + } + return $delegate(expression, locals, later, ident); + }; +}]; + +/** + * @ngdoc service + * @name $componentController + * @description + * A service that can be used to create instances of component controllers. + *
+ * Be aware that the controller will be instantiated and attached to the scope as specified in + * the component definition object. That means that you must always provide a `$scope` object + * in the `locals` param. + *
+ * @param {string} componentName the name of the component whose controller we want to instantiate + * @param {Object} locals Injection locals for Controller. + * @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used + * to simulate the `bindToController` feature and simplify certain kinds of tests. + * @param {string=} ident Override the property name to use when attaching the controller to the scope. + * @return {Object} Instance of requested controller. + */ +angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) { + return { + $get: ['$controller','$injector', function($controller,$injector) { + return function $componentController(componentName, locals, bindings, ident) { + // get all directives associated to the component name + var directives = $injector.get(componentName + 'Directive'); + // look for those directives that are components + var candidateDirectives = directives.filter(function(directiveInfo) { + // components have controller, controllerAs and restrict:'E' + return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict === 'E'; + }); + // check if valid directives found + if (candidateDirectives.length === 0) { + throw new Error('No component found'); + } + if (candidateDirectives.length > 1) { + throw new Error('Too many components found'); + } + // get the info of the component + var directiveInfo = candidateDirectives[0]; + return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs); + }; + }] + }; +}]; + + +/** + * @ngdoc module + * @name ngMock + * @packageName angular-mocks + * @description + * + * # ngMock + * + * The `ngMock` module provides support to inject and mock Angular services into unit tests. + * In addition, ngMock also extends various core ng services such that they can be + * inspected and controlled in a synchronous manner within test code. + * + * + *
+ * + */ +angular.module('ngMock', ['ng']).provider({ + $browser: angular.mock.$BrowserProvider, + $exceptionHandler: angular.mock.$ExceptionHandlerProvider, + $log: angular.mock.$LogProvider, + $interval: angular.mock.$IntervalProvider, + $httpBackend: angular.mock.$HttpBackendProvider, + $rootElement: angular.mock.$RootElementProvider, + $componentController: angular.mock.$ComponentControllerProvider +}).config(['$provide', function($provide) { + $provide.decorator('$timeout', angular.mock.$TimeoutDecorator); + $provide.decorator('$$rAF', angular.mock.$RAFDecorator); + $provide.decorator('$rootScope', angular.mock.$RootScopeDecorator); + $provide.decorator('$controller', angular.mock.$ControllerDecorator); +}]); + +/** + * @ngdoc module + * @name ngMockE2E + * @module ngMockE2E + * @packageName angular-mocks + * @description + * + * The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing. + * Currently there is only one mock present in this module - + * the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock. + */ +angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { + $provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator); +}]); + +/** + * @ngdoc service + * @name $httpBackend + * @module ngMockE2E + * @description + * Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of + * applications that use the {@link ng.$http $http service}. + * + * *Note*: For fake http backend implementation suitable for unit testing please see + * {@link ngMock.$httpBackend unit-testing $httpBackend mock}. + * + * This implementation can be used to respond with static or dynamic responses via the `when` api + * and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the + * real $httpBackend for specific requests (e.g. to interact with certain remote apis or to fetch + * templates from a webserver). + * + * As opposed to unit-testing, in an end-to-end testing scenario or in scenario when an application + * is being developed with the real backend api replaced with a mock, it is often desirable for + * certain category of requests to bypass the mock and issue a real http request (e.g. to fetch + * templates or static files from the webserver). To configure the backend with this behavior + * use the `passThrough` request handler of `when` instead of `respond`. + * + * Additionally, we don't want to manually have to flush mocked out requests like we do during unit + * testing. For this reason the e2e $httpBackend flushes mocked out requests + * automatically, closely simulating the behavior of the XMLHttpRequest object. + * + * To setup the application to run with this http backend, you have to create a module that depends + * on the `ngMockE2E` and your application modules and defines the fake backend: + * + * ```js + * myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']); + * myAppDev.run(function($httpBackend) { + * phones = [{name: 'phone1'}, {name: 'phone2'}]; + * + * // returns the current list of phones + * $httpBackend.whenGET('/phones').respond(phones); + * + * // adds a new phone to the phones array + * $httpBackend.whenPOST('/phones').respond(function(method, url, data) { + * var phone = angular.fromJson(data); + * phones.push(phone); + * return [200, phone, {}]; + * }); + * $httpBackend.whenGET(/^\/templates\//).passThrough(); + * //... + * }); + * ``` + * + * Afterwards, bootstrap your app with this new module. + */ + +/** + * @ngdoc method + * @name $httpBackend#when + * @module ngMockE2E + * @description + * Creates a new backend definition. + * + * @param {string} method HTTP method. + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp)=} data HTTP request body. + * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header + * object and returns true if the headers match the current definition. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + * + * - respond – + * `{function([status,] data[, headers, statusText]) + * | function(function(method, url, data, headers, params)}` + * – The respond method takes a set of static data to be returned or a function that can return + * an array containing response status (number), response data (string), response headers + * (Object), and the text for the status (string). + * - passThrough – `{function()}` – Any request matching a backend definition with + * `passThrough` handler will be passed through to the real backend (an XHR request will be made + * to the server.) + * - Both methods return the `requestHandler` object for possible overrides. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenGET + * @module ngMockE2E + * @description + * Creates a new backend definition for GET requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenHEAD + * @module ngMockE2E + * @description + * Creates a new backend definition for HEAD requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenDELETE + * @module ngMockE2E + * @description + * Creates a new backend definition for DELETE requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenPOST + * @module ngMockE2E + * @description + * Creates a new backend definition for POST requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp)=} data HTTP request body. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenPUT + * @module ngMockE2E + * @description + * Creates a new backend definition for PUT requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp)=} data HTTP request body. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenPATCH + * @module ngMockE2E + * @description + * Creates a new backend definition for PATCH requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(string|RegExp)=} data HTTP request body. + * @param {(Object|function(Object))=} headers HTTP headers. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ + +/** + * @ngdoc method + * @name $httpBackend#whenJSONP + * @module ngMockE2E + * @description + * Creates a new backend definition for JSONP requests. For more info see `when()`. + * + * @param {string|RegExp|function(string)} url HTTP url or function that receives a url + * and returns true if the url matches the current definition. + * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on + * {@link ngMock.$httpBackend $httpBackend mock}. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ +/** + * @ngdoc method + * @name $httpBackend#whenRoute + * @module ngMockE2E + * @description + * Creates a new backend definition that compares only with the requested route. + * + * @param {string} method HTTP method. + * @param {string} url HTTP url string that supports colon param matching. + * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that + * control how a matched request is handled. You can save this object for later use and invoke + * `respond` or `passThrough` again in order to change how a matched request is handled. + */ +angular.mock.e2e = {}; +angular.mock.e2e.$httpBackendDecorator = + ['$rootScope', '$timeout', '$delegate', '$browser', createHttpBackendMock]; + + +/** + * @ngdoc type + * @name $rootScope.Scope + * @module ngMock + * @description + * {@link ng.$rootScope.Scope Scope} type decorated with helper methods useful for testing. These + * methods are automatically available on any {@link ng.$rootScope.Scope Scope} instance when + * `ngMock` module is loaded. + * + * In addition to all the regular `Scope` methods, the following helper methods are available: + */ +angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) { + + var $rootScopePrototype = Object.getPrototypeOf($delegate); + + $rootScopePrototype.$countChildScopes = countChildScopes; + $rootScopePrototype.$countWatchers = countWatchers; + + return $delegate; + + // ------------------------------------------------------------------------------------------ // + + /** + * @ngdoc method + * @name $rootScope.Scope#$countChildScopes + * @module ngMock + * @description + * Counts all the direct and indirect child scopes of the current scope. + * + * The current scope is excluded from the count. The count includes all isolate child scopes. + * + * @returns {number} Total number of child scopes. + */ + function countChildScopes() { + // jshint validthis: true + var count = 0; // exclude the current scope + var pendingChildHeads = [this.$$childHead]; + var currentScope; + + while (pendingChildHeads.length) { + currentScope = pendingChildHeads.shift(); + + while (currentScope) { + count += 1; + pendingChildHeads.push(currentScope.$$childHead); + currentScope = currentScope.$$nextSibling; + } + } + + return count; + } + + + /** + * @ngdoc method + * @name $rootScope.Scope#$countWatchers + * @module ngMock + * @description + * Counts all the watchers of direct and indirect child scopes of the current scope. + * + * The watchers of the current scope are included in the count and so are all the watchers of + * isolate child scopes. + * + * @returns {number} Total number of watchers. + */ + function countWatchers() { + // jshint validthis: true + var count = this.$$watchers ? this.$$watchers.length : 0; // include the current scope + var pendingChildHeads = [this.$$childHead]; + var currentScope; + + while (pendingChildHeads.length) { + currentScope = pendingChildHeads.shift(); + + while (currentScope) { + count += currentScope.$$watchers ? currentScope.$$watchers.length : 0; + pendingChildHeads.push(currentScope.$$childHead); + currentScope = currentScope.$$nextSibling; + } + } + + return count; + } +}]; + + +if (window.jasmine || window.mocha) { + + var currentSpec = null, + annotatedFunctions = [], + isSpecRunning = function() { + return !!currentSpec; + }; + + angular.mock.$$annotate = angular.injector.$$annotate; + angular.injector.$$annotate = function(fn) { + if (typeof fn === 'function' && !fn.$inject) { + annotatedFunctions.push(fn); + } + return angular.mock.$$annotate.apply(this, arguments); + }; + + + (window.beforeEach || window.setup)(function() { + annotatedFunctions = []; + currentSpec = this; + }); + + (window.afterEach || window.teardown)(function() { + var injector = currentSpec.$injector; + + annotatedFunctions.forEach(function(fn) { + delete fn.$inject; + }); + + angular.forEach(currentSpec.$modules, function(module) { + if (module && module.$$hashKey) { + module.$$hashKey = undefined; + } + }); + + currentSpec.$injector = null; + currentSpec.$modules = null; + currentSpec.$providerInjector = null; + currentSpec = null; + + if (injector) { + injector.get('$rootElement').off(); + injector.get('$rootScope').$destroy(); + } + + // clean up jquery's fragment cache + angular.forEach(angular.element.fragments, function(val, key) { + delete angular.element.fragments[key]; + }); + + MockXhr.$$lastInstance = null; + + angular.forEach(angular.callbacks, function(val, key) { + delete angular.callbacks[key]; + }); + angular.callbacks.counter = 0; + }); + + /** + * @ngdoc function + * @name angular.mock.module + * @description + * + * *NOTE*: This function is also published on window for easy access.
+ * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha + * + * This function registers a module configuration code. It collects the configuration information + * which will be used when the injector is created by {@link angular.mock.inject inject}. + * + * See {@link angular.mock.inject inject} for usage example + * + * @param {...(string|Function|Object)} fns any number of modules which are represented as string + * aliases or as anonymous module initialization functions. The modules are used to + * configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an + * object literal is passed each key-value pair will be registered on the module via + * {@link auto.$provide $provide}.value, the key being the string name (or token) to associate + * with the value on the injector. + */ + window.module = angular.mock.module = function() { + var moduleFns = Array.prototype.slice.call(arguments, 0); + return isSpecRunning() ? workFn() : workFn; + ///////////////////// + function workFn() { + if (currentSpec.$injector) { + throw new Error('Injector already created, can not register a module!'); + } else { + var fn, modules = currentSpec.$modules || (currentSpec.$modules = []); + angular.forEach(moduleFns, function(module) { + if (angular.isObject(module) && !angular.isArray(module)) { + fn = function($provide) { + angular.forEach(module, function(value, key) { + $provide.value(key, value); + }); + }; + } else { + fn = module; + } + if (currentSpec.$providerInjector) { + currentSpec.$providerInjector.invoke(fn); + } else { + modules.push(fn); + } + }); + } + } + }; + + /** + * @ngdoc function + * @name angular.mock.inject + * @description + * + * *NOTE*: This function is also published on window for easy access.
+ * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha + * + * The inject function wraps a function into an injectable function. The inject() creates new + * instance of {@link auto.$injector $injector} per test, which is then used for + * resolving references. + * + * + * ## Resolving References (Underscore Wrapping) + * Often, we would like to inject a reference once, in a `beforeEach()` block and reuse this + * in multiple `it()` clauses. To be able to do this we must assign the reference to a variable + * that is declared in the scope of the `describe()` block. Since we would, most likely, want + * the variable to have the same name of the reference we have a problem, since the parameter + * to the `inject()` function would hide the outer variable. + * + * To help with this, the injected parameters can, optionally, be enclosed with underscores. + * These are ignored by the injector when the reference name is resolved. + * + * For example, the parameter `_myService_` would be resolved as the reference `myService`. + * Since it is available in the function body as _myService_, we can then assign it to a variable + * defined in an outer scope. + * + * ``` + * // Defined out reference variable outside + * var myService; + * + * // Wrap the parameter in underscores + * beforeEach( inject( function(_myService_){ + * myService = _myService_; + * })); + * + * // Use myService in a series of tests. + * it('makes use of myService', function() { + * myService.doStuff(); + * }); + * + * ``` + * + * See also {@link angular.mock.module angular.mock.module} + * + * ## Example + * Example of what a typical jasmine tests looks like with the inject method. + * ```js + * + * angular.module('myApplicationModule', []) + * .value('mode', 'app') + * .value('version', 'v1.0.1'); + * + * + * describe('MyApp', function() { + * + * // You need to load modules that you want to test, + * // it loads only the "ng" module by default. + * beforeEach(module('myApplicationModule')); + * + * + * // inject() is used to inject arguments of all given functions + * it('should provide a version', inject(function(mode, version) { + * expect(version).toEqual('v1.0.1'); + * expect(mode).toEqual('app'); + * })); + * + * + * // The inject and module method can also be used inside of the it or beforeEach + * it('should override a version and test the new version is injected', function() { + * // module() takes functions or strings (module aliases) + * module(function($provide) { + * $provide.value('version', 'overridden'); // override version here + * }); + * + * inject(function(version) { + * expect(version).toEqual('overridden'); + * }); + * }); + * }); + * + * ``` + * + * @param {...Function} fns any number of functions which will be injected using the injector. + */ + + + + var ErrorAddingDeclarationLocationStack = function(e, errorForStack) { + this.message = e.message; + this.name = e.name; + if (e.line) this.line = e.line; + if (e.sourceId) this.sourceId = e.sourceId; + if (e.stack && errorForStack) + this.stack = e.stack + '\n' + errorForStack.stack; + if (e.stackArray) this.stackArray = e.stackArray; + }; + ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString; + + window.inject = angular.mock.inject = function() { + var blockFns = Array.prototype.slice.call(arguments, 0); + var errorForStack = new Error('Declaration Location'); + return isSpecRunning() ? workFn.call(currentSpec) : workFn; + ///////////////////// + function workFn() { + var modules = currentSpec.$modules || []; + var strictDi = !!currentSpec.$injectorStrict; + modules.unshift(function($injector) { + currentSpec.$providerInjector = $injector; + }); + modules.unshift('ngMock'); + modules.unshift('ng'); + var injector = currentSpec.$injector; + if (!injector) { + if (strictDi) { + // If strictDi is enabled, annotate the providerInjector blocks + angular.forEach(modules, function(moduleFn) { + if (typeof moduleFn === "function") { + angular.injector.$$annotate(moduleFn); + } + }); + } + injector = currentSpec.$injector = angular.injector(modules, strictDi); + currentSpec.$injectorStrict = strictDi; + } + for (var i = 0, ii = blockFns.length; i < ii; i++) { + if (currentSpec.$injectorStrict) { + // If the injector is strict / strictDi, and the spec wants to inject using automatic + // annotation, then annotate the function here. + injector.annotate(blockFns[i]); + } + try { + /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */ + injector.invoke(blockFns[i] || angular.noop, this); + /* jshint +W040 */ + } catch (e) { + if (e.stack && errorForStack) { + throw new ErrorAddingDeclarationLocationStack(e, errorForStack); + } + throw e; + } finally { + errorForStack = null; + } + } + } + }; + + + angular.mock.inject.strictDi = function(value) { + value = arguments.length ? !!value : true; + return isSpecRunning() ? workFn() : workFn; + + function workFn() { + if (value !== currentSpec.$injectorStrict) { + if (currentSpec.$injector) { + throw new Error('Injector already created, can not modify strict annotations'); + } else { + currentSpec.$injectorStrict = value; + } + } + } + }; +} + + +})(window, window.angular); diff --git a/ecomp-portal-FE/client/bower_components/angular-resource/angular-resource.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-resource.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-resource/angular-resource.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-resource.js diff --git a/ecomp-portal-FE/client/bower_components/angular-resource/angular-resource.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-resource.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-resource/angular-resource.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-resource.min.js diff --git a/ecomp-portal-FE/client/bower_components/angular-route/angular-route.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-route.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-route/angular-route.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-route.js diff --git a/ecomp-portal-FE/client/bower_components/angular-route/angular-route.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-route.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-route/angular-route.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-route.min.js diff --git a/ecomp-portal-FE/client/bower_components/angular-sanitize/angular-sanitize.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-sanitize.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-sanitize/angular-sanitize.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-sanitize.js diff --git a/ecomp-portal-FE/client/bower_components/angular-sanitize/angular-sanitize.min.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-sanitize.min.js similarity index 100% rename from ecomp-portal-FE/client/bower_components/angular-sanitize/angular-sanitize.min.js rename to ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-sanitize.min.js diff --git a/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-scenario.js b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-scenario.js new file mode 100644 index 00000000..20af805f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/webapp/static/app/fusion/external/angular-1.5/angular-scenario.js @@ -0,0 +1,41849 @@ +/*! + * jQuery JavaScript Library v2.1.1 + * http://jquery.com/ + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * + * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-05-01T17:11Z + */ + +(function( global, factory ) {'use strict'; + + if ( typeof module === "object" && typeof module.exports === "object" ) { + // For CommonJS and CommonJS-like environments where a proper window is present, + // execute the factory and get jQuery + // For environments that do not inherently posses a window with a document + // (such as Node.js), expose a jQuery-making factory as module.exports + // This accentuates the need for the creation of a real window + // e.g. var jQuery = require("jquery")(window); + // See ticket #14549 for more info + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Can't do this because several apps including ASP.NET trace +// the stack via arguments.caller.callee and Firefox dies if +// you try to trace through "use strict" call chains. (#13335) +// Support: Firefox 18+ +// + +var arr = []; + +var slice = arr.slice; + +var concat = arr.concat; + +var push = arr.push; + +var indexOf = arr.indexOf; + +var class2type = {}; + +var toString = class2type.toString; + +var hasOwn = class2type.hasOwnProperty; + +var support = {}; + + + +var + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + + version = "2.1.1", + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }, + + // Support: Android<4.1 + // Make sure we trim BOM and NBSP + rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + + // Matches dashed string for camelizing + rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return letter.toUpperCase(); + }; + +jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // Start with an empty selector + selector: "", + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num != null ? + + // Return just the one element from the set + ( num < 0 ? this[ num + this.length ] : this[ num ] ) : + + // Return all the elements in a clean array + slice.call( this ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + ret.context = this.context; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray, + + isWindow: function( obj ) { + return obj != null && obj === obj.window; + }, + + isNumeric: function( obj ) { + // parseFloat NaNs numeric-cast false positives (null|true|false|"") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0; + }, + + isPlainObject: function( obj ) { + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.constructor && + !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { + return false; + } + + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + type: function( obj ) { + if ( obj == null ) { + return obj + ""; + } + // Support: Android < 4.0, iOS < 6 (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call(obj) ] || "object" : + typeof obj; + }, + + // Evaluates a script in a global context + globalEval: function( code ) { + var script, + indirect = eval; + + code = jQuery.trim( code ); + + if ( code ) { + // If the code includes a valid, prologue position + // strict mode pragma, execute code by injecting a + // script tag into the document. + if ( code.indexOf("use strict") === 1 ) { + script = document.createElement("script"); + script.text = code; + document.head.appendChild( script ).parentNode.removeChild( script ); + } else { + // Otherwise, avoid the DOM node creation, insertion + // and removal by using an indirect global eval + indirect( code ); + } + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); + + if ( args ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } + } + + return obj; + }, + + // Support: Android<4.1 + trim: function( text ) { + return text == null ? + "" : + ( text + "" ).replace( rtrim, "" ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, + i = 0, + length = elems.length, + isArray = isArraylike( elems ), + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + var tmp, args, proxy; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; + }, + + now: Date.now, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); + + if ( type === "function" || jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.nodeType === 1 && length ) { + return true; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} +var Sizzle = +/*! + * Sizzle CSS Selector Engine v1.10.19 + * http://sizzlejs.com/ + * + * Copyright 2013 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-04-18 + */ +(function( window ) { + +var i, + support, + Expr, + getText, + isXML, + tokenize, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // General-purpose constants + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, + + // Instance methods + hasOwn = ({}).hasOwnProperty, + arr = [], + pop = arr.pop, + push_native = arr.push, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf if we can't use a native one + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + + "*\\]", + + pseudos = ":(" + characterEncoding + ")(?:\\((" + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), + + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + rescape = /'|\\/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), + funescape = function( _, escaped, escapedWhitespace ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + // Support: Firefox<24 + // Workaround erroneous numeric interpretation of +"0x" + return high !== high || escapedWhitespace ? + escaped : + high < 0 ? + // BMP codepoint + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + (arr = slice.call( preferredDoc.childNodes )), + preferredDoc.childNodes + ); + // Support: Android<4.0 + // Detect silently failing push.apply + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + push_native.apply( target, slice.call(els) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + // Can't trust NodeList.length + while ( (target[j++] = els[i++]) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; + + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + + context = context || document; + results = results || []; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } + + if ( documentIsHTML && !seed ) { + + // Shortcuts + if ( (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document (jQuery #6963) + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // QSA path + if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + nid = old = expando; + newContext = context; + newSelector = nodeType === 9 && selector; + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return (cache[ key + " " ] = value); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); + + try { + return !!fn( div ); + } catch (e) { + return false; + } finally { + // Remove from its parent by default + if ( div.parentNode ) { + div.parentNode.removeChild( div ); + } + // release memory in IE + div = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split("|"), + i = attrs.length; + + while ( i-- ) { + Expr.attrHandle[ arr[i] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + ( ~b.sourceIndex || MAX_NEGATIVE ) - + ( ~a.sourceIndex || MAX_NEGATIVE ); + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== strundefined && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, + doc = node ? node.ownerDocument || node : preferredDoc, + parent = doc.defaultView; + + // If no document and documentElement is available, return + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Set our document + document = doc; + docElem = doc.documentElement; + + // Support tests + documentIsHTML = !isXML( doc ); + + // Support: IE>8 + // If iframe document is assigned to "document" variable and if iframe has been reloaded, + // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 + // IE6-8 do not support the defaultView property so parent will be undefined + if ( parent && parent !== parent.top ) { + // IE11 does not have attachEvent, so all must suffer + if ( parent.addEventListener ) { + parent.addEventListener( "unload", function() { + setDocument(); + }, false ); + } else if ( parent.attachEvent ) { + parent.attachEvent( "onunload", function() { + setDocument(); + }); + } + } + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) + support.attributes = assert(function( div ) { + div.className = "i"; + return !div.getAttribute("className"); + }); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Check if getElementsByClassName can be trusted + support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { + div.innerHTML = "
"; + + // Support: Safari<4 + // Catch class over-caching + div.firstChild.className = "i"; + // Support: Opera<10 + // Catch gEBCN failure to find non-leading classes + return div.getElementsByClassName("i").length === 2; + }); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert(function( div ) { + docElem.appendChild( div ).id = expando; + return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + }); + + // ID find and filter + if ( support.getById ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && documentIsHTML ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [ m ] : []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + // Support: IE6/7 + // getElementById is not reliable as a find shortcut + delete Expr.find["ID"]; + + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + + // Tag + Expr.find["TAG"] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See http://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( div.querySelectorAll("[msallowclip^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || + docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + return doc; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, document, null, [ elem ] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + while ( (node = elem[i++]) ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[6] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[3] ) { + match[2] = match[4] || match[5] || ""; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifier + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +tokenize = Sizzle.tokenize = function( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( (tokens = []) ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +}; + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (oldCache = outerCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return (newCache[ 2 ] = oldCache[ 2 ]); + } else { + // Reuse newcache so results back-propagate to previous elements + outerCache[ dir ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; + + if ( outermost ) { + outermostContext = context !== document && context; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + + // Save selector and tokenization + cached.selector = selector; + } + return cached; +}; + +/** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +select = Sizzle.select = function( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( (selector = compiled.selector || selector) ); + + results = results || []; + + // Try to minimize operations if there is no seed and only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { + + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; + + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + + // Compile and execute a filtering function if one is not provided + // Provide `match` to avoid retokenization if we modified the selector above + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +}; + +// One-time assignments + +// Sort stability +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; + +// Support: Chrome<14 +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert(function( div1 ) { + // Should return 1, but returns 4 (following) + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; + } + }); +} + +return Sizzle; + +})( window ); + + + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + + +var rneedsContext = jQuery.expr.match.needsContext; + +var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); + + + +var risSimple = /^.[^:#\[\.,]*$/; + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + }); + + } + + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + }); + + } + + if ( typeof qualifier === "string" ) { + if ( risSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); + } + + qualifier = jQuery.filter( qualifier, elements ); + } + + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; + }); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + })); +}; + +jQuery.fn.extend({ + find: function( selector ) { + var i, + len = this.length, + ret = [], + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function( selector ) { + return this.pushStack( winnow(this, selector || [], false) ); + }, + not: function( selector ) { + return this.pushStack( winnow(this, selector || [], true) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +}); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + init = jQuery.fn.init = function( selector, context ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return typeof rootjQuery.ready !== "undefined" ? + rootjQuery.ready( selector ) : + // Execute immediately if ready is not present + selector( jQuery ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.extend({ + dir: function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; + }, + + sibling: function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; + } +}); + +jQuery.fn.extend({ + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter(function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { + // Always skip document fragments + if ( cur.nodeType < 11 && (pos ? + pos.index(cur) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector(cur, selectors)) ) { + + matched.push( cur ); + break; + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.unique( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +function sibling( cur, dir ) { + while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return elem.contentDocument || jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.unique( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +}); +var rnotwhite = (/\S+/g); + + + +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + firingLength = 0; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( list && ( !fired || stack ) ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); + + +// The deferred used on DOM ready +var readyList; + +jQuery.fn.ready = function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; +}; + +jQuery.extend({ + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.triggerHandler ) { + jQuery( document ).triggerHandler( "ready" ); + jQuery( document ).off( "ready" ); + } + } +}); + +/** + * The ready event handler and self cleanup method + */ +function completed() { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + jQuery.ready(); +} + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + } else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + } + } + return readyList.promise( obj ); +}; + +// Kick off the DOM ready check even if the user does not +jQuery.ready.promise(); + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + len ? fn( elems[0], key ) : emptyGet; +}; + + +/** + * Determines whether an object can have data + */ +jQuery.acceptData = function( owner ) { + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + /* jshint -W018 */ + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; + + +function Data() { + // Support: Android < 4, + // Old WebKit does not have Object.preventExtensions/freeze method, + // return new empty object instead with no [[set]] accessor + Object.defineProperty( this.cache = {}, 0, { + get: function() { + return {}; + } + }); + + this.expando = jQuery.expando + Math.random(); +} + +Data.uid = 1; +Data.accepts = jQuery.acceptData; + +Data.prototype = { + key: function( owner ) { + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return the key for a frozen object. + if ( !Data.accepts( owner ) ) { + return 0; + } + + var descriptor = {}, + // Check if the owner object already has a cache key + unlock = owner[ this.expando ]; + + // If not, create one + if ( !unlock ) { + unlock = Data.uid++; + + // Secure it in a non-enumerable, non-writable property + try { + descriptor[ this.expando ] = { value: unlock }; + Object.defineProperties( owner, descriptor ); + + // Support: Android < 4 + // Fallback to a less secure definition + } catch ( e ) { + descriptor[ this.expando ] = unlock; + jQuery.extend( owner, descriptor ); + } + } + + // Ensure the cache object + if ( !this.cache[ unlock ] ) { + this.cache[ unlock ] = {}; + } + + return unlock; + }, + set: function( owner, data, value ) { + var prop, + // There may be an unlock assigned to this node, + // if there is no entry for this "owner", create one inline + // and set the unlock as though an owner entry had always existed + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + // Handle: [ owner, key, value ] args + if ( typeof data === "string" ) { + cache[ data ] = value; + + // Handle: [ owner, { properties } ] args + } else { + // Fresh assignments by object are shallow copied + if ( jQuery.isEmptyObject( cache ) ) { + jQuery.extend( this.cache[ unlock ], data ); + // Otherwise, copy the properties one-by-one to the cache object + } else { + for ( prop in data ) { + cache[ prop ] = data[ prop ]; + } + } + } + return cache; + }, + get: function( owner, key ) { + // Either a valid cache is found, or will be created. + // New caches will be created and the unlock returned, + // allowing direct access to the newly created + // empty data object. A valid owner object must be provided. + var cache = this.cache[ this.key( owner ) ]; + + return key === undefined ? + cache : cache[ key ]; + }, + access: function( owner, key, value ) { + var stored; + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ((key && typeof key === "string") && value === undefined) ) { + + stored = this.get( owner, key ); + + return stored !== undefined ? + stored : this.get( owner, jQuery.camelCase(key) ); + } + + // [*]When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, name, camel, + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + if ( key === undefined ) { + this.cache[ unlock ] = {}; + + } else { + // Support array or space separated string of keys + if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = key.concat( key.map( jQuery.camelCase ) ); + } else { + camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation + if ( key in cache ) { + name = [ key, camel ]; + } else { + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + name = camel; + name = name in cache ? + [ name ] : ( name.match( rnotwhite ) || [] ); + } + } + + i = name.length; + while ( i-- ) { + delete cache[ name[ i ] ]; + } + } + }, + hasData: function( owner ) { + return !jQuery.isEmptyObject( + this.cache[ owner[ this.expando ] ] || {} + ); + }, + discard: function( owner ) { + if ( owner[ this.expando ] ) { + delete this.cache[ owner[ this.expando ] ]; + } + } +}; +var data_priv = new Data(); + +var data_user = new Data(); + + + +/* + Implementation Summary + + 1. Enforce API surface and semantic compatibility with 1.9.x branch + 2. Improve the module's maintainability by reducing the storage + paths to a single mechanism. + 3. Use the same single mechanism to support "private" and "user" data. + 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) + 5. Avoid exposing implementation details on user objects (eg. expando properties) + 6. Provide a clear path for implementation upgrade to WeakMap in 2014 +*/ +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /([A-Z])/g; + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + data_user.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + +jQuery.extend({ + hasData: function( elem ) { + return data_user.hasData( elem ) || data_priv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return data_user.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + data_user.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to data_priv methods, these can be deprecated. + _data: function( elem, name, data ) { + return data_priv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + data_priv.remove( elem, name ); + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = data_user.get( elem ); + + if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + + // Support: IE11+ + // The attrs elements can be null (#14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice(5) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + data_priv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + data_user.set( this, key ); + }); + } + + return access( this, function( value ) { + var data, + camelKey = jQuery.camelCase( key ); + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + // Attempt to get data from the cache + // with the key as-is + data = data_user.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to get data from the cache + // with the key camelized + data = data_user.get( elem, camelKey ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, camelKey, undefined ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each(function() { + // First, attempt to store a copy or reference of any + // data that might've been store with a camelCased key. + var data = data_user.get( this, camelKey ); + + // For HTML5 data-* attribute interop, we have to + // store property names with dashes in a camelCase form. + // This might not apply to all properties...* + data_user.set( this, camelKey, value ); + + // *... In the case of properties that might _actually_ + // have dashes, we need to also store a copy of that + // unchanged property. + if ( key.indexOf("-") !== -1 && data !== undefined ) { + data_user.set( this, key, value ); + } + }); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each(function() { + data_user.remove( this, key ); + }); + } +}); + + +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = data_priv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray( data ) ) { + queue = data_priv.access( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return data_priv.get( elem, key ) || data_priv.access( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + data_priv.remove( elem, [ type + "queue", key ] ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = data_priv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var isHidden = function( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); + }; + +var rcheckableType = (/^(?:checkbox|radio)$/i); + + + +(function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); + + // #11217 - WebKit loses check when the name is after the checked attribute + // Support: Windows Web Apps (WWA) + // `name` and `type` need .setAttribute for WWA + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 + // old WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Make sure textarea (and checkbox) defaultValue is properly cloned + // Support: IE9-IE11+ + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; +})(); +var strundefined = typeof undefined; + + + +support.focusinBubbles = "onfocusin" in window; + + +var + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.get( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.hasData( elem ) && data_priv.get( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + data_priv.remove( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && jQuery.acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && + jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, j, ret, matched, handleObj, + handlerQueue = [], + args = slice.call( arguments ), + handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, matches, sel, handleObj, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.disabled !== true || event.type !== "click" ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } + + // Support: Safari 6.0+, Chrome < 28 + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + this.click(); + return false; + } + }, + + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } +}; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + src.defaultPrevented === undefined && + // Support: Android < 4.0 + src.returnValue === false ? + returnTrue : + returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && e.preventDefault ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && e.stopPropagation ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + + this.isImmediatePropagationStopped = returnTrue; + + if ( e && e.stopImmediatePropagation ) { + e.stopImmediatePropagation(); + } + + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +// Support: Chrome 15+ +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// Create "bubbling" focus and blur events +// Support: Firefox, Chrome, Safari +if ( !support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + data_priv.remove( doc, fix ); + + } else { + data_priv.access( doc, fix, attaches ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); + + +var + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rhtml = /<|&#?\w+;/, + rnoInnerhtml = /<(?:script|style|link)/i, + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /^$|\/(?:java|ecma)script/i, + rscriptTypeMasked = /^true\/(.*)/, + rcleanScript = /^\s*\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + + // Support: IE 9 + option: [ 1, "" ], + + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + + _default: [ 0, "", "" ] + }; + +// Support: IE 9 +wrapMap.optgroup = wrapMap.option; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// Support: 1.x compatibility +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName("tbody")[0] || + elem.appendChild( elem.ownerDocument.createElement("tbody") ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + + if ( match ) { + elem.type = match[ 1 ]; + } else { + elem.removeAttribute("type"); + } + + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + data_priv.set( + elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) + ); + } +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( data_priv.hasData( src ) ) { + pdataOld = data_priv.access( src ); + pdataCur = data_priv.set( dest, pdataOld ); + events = pdataOld.events; + + if ( events ) { + delete pdataCur.handle; + pdataCur.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( data_user.hasData( src ) ) { + udataOld = data_user.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + data_user.set( dest, udataCur ); + } +} + +function getAll( context, tag ) { + var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : + context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : + []; + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], ret ) : + ret; +} + +// Support: IE >= 9 +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = jQuery.contains( elem.ownerDocument, elem ); + + // Support: IE >= 9 + // Fix Cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var elem, tmp, tag, wrap, contains, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Fixes #12346 + // Support: Webkit, IE + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; + }, + + cleanData: function( elems ) { + var data, elem, type, key, + special = jQuery.event.special, + i = 0; + + for ( ; (elem = elems[ i ]) !== undefined; i++ ) { + if ( jQuery.acceptData( elem ) ) { + key = elem[ data_priv.expando ]; + + if ( key && (data = data_priv.cache[ key ]) ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + if ( data_priv.cache[ key ] ) { + // Discard any remaining `private` data + delete data_priv.cache[ key ]; + } + } + } + // Discard any remaining `user` data + delete data_user.cache[ elem[ data_user.expando ] ]; + } + } +}); + +jQuery.fn.extend({ + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each(function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + }); + }, null, value, arguments.length ); + }, + + append: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + remove: function( selector, keepData /* Internal Use Only */ ) { + var elem, + elems = selector ? jQuery.filter( selector, this ) : this, + i = 0; + + for ( ; (elem = elems[i]) != null; i++ ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map(function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var arg = arguments[ 0 ]; + + // Make the changes, replacing each context element with the new content + this.domManip( arguments, function( elem ) { + arg = this.parentNode; + + jQuery.cleanData( getAll( this ) ); + + if ( arg ) { + arg.replaceChild( elem, this ); + } + }); + + // Force removal if there was no new content (e.g., from empty arguments) + return arg && (arg.length || arg.nodeType) ? this : this.remove(); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, callback ) { + + // Flatten any nested arrays + args = concat.apply( [], args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[ 0 ], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + self.domManip( args, callback ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( this[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl ) { + jQuery._evalUrl( node.src ); + } + } else { + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + } + } + } + } + } + } + + return this; + } +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: QtWebKit + // .get() because push.apply(_, arraylike) throws + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + + +var iframe, + elemdisplay = {}; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ +// Called only from within defaultDisplay +function actualDisplay( name, doc ) { + var style, + elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + + // getDefaultComputedStyle might be reliably used only on attached element + display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? + + // Use of this method is a temporary fix (more like optmization) until something better comes along, + // since it was removed from specification and supported only in FF + style.display : jQuery.css( elem[ 0 ], "display" ); + + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); + + return display; +} + +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + + // Use the already-created iframe if possible + iframe = (iframe || jQuery( "' : ''); - inst._keyEvent = false; - return html; - }, - - /* Generate the month and year header. */ - _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, - secondary, monthNames, monthNamesShort) { - var changeMonth = this._get(inst, 'changeMonth'); - var changeYear = this._get(inst, 'changeYear'); - var showMonthAfterYear = this._get(inst, 'showMonthAfterYear'); - var html = '
'; - var monthHtml = ''; - // month selection - if (secondary || !changeMonth) - monthHtml += '' + monthNames[drawMonth] + ''; - else { - var inMinYear = (minDate && minDate.getFullYear() == drawYear); - var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); - monthHtml += ''; - } - if (!showMonthAfterYear) - html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : ''); - // year selection - if ( !inst.yearshtml ) { - inst.yearshtml = ''; - if (secondary || !changeYear) - html += '' + drawYear + ''; - else { - // determine range of years to display - var years = this._get(inst, 'yearRange').split(':'); - var thisYear = new Date().getFullYear(); - var determineYear = function(value) { - var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) : - (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) : - parseInt(value, 10))); - return (isNaN(year) ? thisYear : year); - }; - var year = determineYear(years[0]); - var endYear = Math.max(year, determineYear(years[1] || '')); - year = (minDate ? Math.max(year, minDate.getFullYear()) : year); - endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); - inst.yearshtml += ''; - - html += inst.yearshtml; - inst.yearshtml = null; - } - } - html += this._get(inst, 'yearSuffix'); - if (showMonthAfterYear) - html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml; - html += '
'; // Close datepicker_header - return html; - }, - - /* Adjust one of the date sub-fields. */ - _adjustInstDate: function(inst, offset, period) { - var year = inst.drawYear + (period == 'Y' ? offset : 0); - var month = inst.drawMonth + (period == 'M' ? offset : 0); - var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + - (period == 'D' ? offset : 0); - var date = this._restrictMinMax(inst, - this._daylightSavingAdjust(new Date(year, month, day))); - inst.selectedDay = date.getDate(); - inst.drawMonth = inst.selectedMonth = date.getMonth(); - inst.drawYear = inst.selectedYear = date.getFullYear(); - if (period == 'M' || period == 'Y') - this._notifyChange(inst); - }, - - /* Ensure a date is within any min/max bounds. */ - _restrictMinMax: function(inst, date) { - var minDate = this._getMinMaxDate(inst, 'min'); - var maxDate = this._getMinMaxDate(inst, 'max'); - var newDate = (minDate && date < minDate ? minDate : date); - newDate = (maxDate && newDate > maxDate ? maxDate : newDate); - return newDate; - }, - - /* Notify change of month/year. */ - _notifyChange: function(inst) { - var onChange = this._get(inst, 'onChangeMonthYear'); - if (onChange) - onChange.apply((inst.input ? inst.input[0] : null), - [inst.selectedYear, inst.selectedMonth + 1, inst]); - }, - - /* Determine the number of months to show. */ - _getNumberOfMonths: function(inst) { - var numMonths = this._get(inst, 'numberOfMonths'); - return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); - }, - - /* Determine the current maximum date - ensure no time components are set. */ - _getMinMaxDate: function(inst, minMax) { - return this._determineDate(inst, this._get(inst, minMax + 'Date'), null); - }, - - /* Find the number of days in a given month. */ - _getDaysInMonth: function(year, month) { - return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate(); - }, - - /* Find the day of the week of the first of a month. */ - _getFirstDayOfMonth: function(year, month) { - return new Date(year, month, 1).getDay(); - }, - - /* Determines if we should allow a "next/prev" month display change. */ - _canAdjustMonth: function(inst, offset, curYear, curMonth) { - var numMonths = this._getNumberOfMonths(inst); - var date = this._daylightSavingAdjust(new Date(curYear, - curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1)); - if (offset < 0) - date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); - return this._isInRange(inst, date); - }, - - /* Is the given date in the accepted range? */ - _isInRange: function(inst, date) { - var minDate = this._getMinMaxDate(inst, 'min'); - var maxDate = this._getMinMaxDate(inst, 'max'); - return ((!minDate || date.getTime() >= minDate.getTime()) && - (!maxDate || date.getTime() <= maxDate.getTime())); - }, - - /* Provide the configuration settings for formatting/parsing. */ - _getFormatConfig: function(inst) { - var shortYearCutoff = this._get(inst, 'shortYearCutoff'); - shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : - new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); - return {shortYearCutoff: shortYearCutoff, - dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), - monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; - }, - - /* Format the given date for display. */ - _formatDate: function(inst, day, month, year) { - if (!day) { - inst.currentDay = inst.selectedDay; - inst.currentMonth = inst.selectedMonth; - inst.currentYear = inst.selectedYear; - } - var date = (day ? (typeof day == 'object' ? day : - this._daylightSavingAdjust(new Date(year, month, day))) : - this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); - return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst)); - } -}); - -/* - * Bind hover events for datepicker elements. - * Done via delegate so the binding only occurs once in the lifetime of the parent div. - * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. - */ -function bindHover(dpDiv) { - var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a'; - return dpDiv.delegate(selector, 'mouseout', function() { - $(this).removeClass('ui-state-hover'); - if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); - if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); - }) - .delegate(selector, 'mouseover', function(){ - if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) { - $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); - $(this).addClass('ui-state-hover'); - if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); - if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); - } - }); -} - -/* jQuery extend now ignores nulls! */ -function extendRemove(target, props) { - $.extend(target, props); - for (var name in props) - if (props[name] == null || props[name] == undefined) - target[name] = props[name]; - return target; -}; - -/* Invoke the datepicker functionality. - @param options string - a command, optionally followed by additional parameters or - Object - settings for attaching new datepicker functionality - @return jQuery object */ -$.fn.datepicker = function(options){ - - /* Verify an empty collection wasn't passed - Fixes #6976 */ - if ( !this.length ) { - return this; - } - - /* Initialise the date picker. */ - if (!$.datepicker.initialized) { - $(document).mousedown($.datepicker._checkExternalClick). - find(document.body).append($.datepicker.dpDiv); - $.datepicker.initialized = true; - } - - var otherArgs = Array.prototype.slice.call(arguments, 1); - if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget')) - return $.datepicker['_' + options + 'Datepicker']. - apply($.datepicker, [this[0]].concat(otherArgs)); - if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string') - return $.datepicker['_' + options + 'Datepicker']. - apply($.datepicker, [this[0]].concat(otherArgs)); - return this.each(function() { - typeof options == 'string' ? - $.datepicker['_' + options + 'Datepicker']. - apply($.datepicker, [this].concat(otherArgs)) : - $.datepicker._attachDatepicker(this, options); - }); -}; - -$.datepicker = new Datepicker(); // singleton instance -$.datepicker.initialized = false; -$.datepicker.uuid = new Date().getTime(); -$.datepicker.version = "1.9.2"; - -// Workaround for #4055 -// Add another global to avoid noConflict issues with inline event handlers -window['DP_jQuery_' + dpuuid] = $; - -})(jQuery); -(function( $, undefined ) { - -var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ", - sizeRelatedOptions = { - buttons: true, - height: true, - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true, - width: true - }, - resizableRelatedOptions = { - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true - }; - -$.widget("ui.dialog", { - version: "1.9.2", - options: { - autoOpen: true, - buttons: {}, - closeOnEscape: true, - closeText: "close", - dialogClass: "", - draggable: true, - hide: null, - height: "auto", - maxHeight: false, - maxWidth: false, - minHeight: 150, - minWidth: 150, - modal: false, - position: { - my: "center", - at: "center", - of: window, - collision: "fit", - // ensure that the titlebar is never outside the document - using: function( pos ) { - var topOffset = $( this ).css( pos ).offset().top; - if ( topOffset < 0 ) { - $( this ).css( "top", pos.top - topOffset ); - } - } - }, - resizable: true, - show: null, - stack: true, - title: "", - width: 300, - zIndex: 1000 - }, - - _create: function() { - this.originalTitle = this.element.attr( "title" ); - // #5742 - .attr() might return a DOMElement - if ( typeof this.originalTitle !== "string" ) { - this.originalTitle = ""; - } - this.oldPosition = { - parent: this.element.parent(), - index: this.element.parent().children().index( this.element ) - }; - this.options.title = this.options.title || this.originalTitle; - var that = this, - options = this.options, - - title = options.title || " ", - uiDialog, - uiDialogTitlebar, - uiDialogTitlebarClose, - uiDialogTitle, - uiDialogButtonPane; - - uiDialog = ( this.uiDialog = $( "
" ) ) - .addClass( uiDialogClasses + options.dialogClass ) - .css({ - display: "none", - outline: 0, // TODO: move to stylesheet - zIndex: options.zIndex - }) - // setting tabIndex makes the div focusable - .attr( "tabIndex", -1) - .keydown(function( event ) { - if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && - event.keyCode === $.ui.keyCode.ESCAPE ) { - that.close( event ); - event.preventDefault(); - } - }) - .mousedown(function( event ) { - that.moveToTop( false, event ); - }) - .appendTo( "body" ); - - this.element - .show() - .removeAttr( "title" ) - .addClass( "ui-dialog-content ui-widget-content" ) - .appendTo( uiDialog ); - - uiDialogTitlebar = ( this.uiDialogTitlebar = $( "
" ) ) - .addClass( "ui-dialog-titlebar ui-widget-header " + - "ui-corner-all ui-helper-clearfix" ) - .bind( "mousedown", function() { - // Dialog isn't getting focus when dragging (#8063) - uiDialog.focus(); - }) - .prependTo( uiDialog ); - - uiDialogTitlebarClose = $( "" ) - .addClass( "ui-dialog-titlebar-close ui-corner-all" ) - .attr( "role", "button" ) - .click(function( event ) { - event.preventDefault(); - that.close( event ); - }) - .appendTo( uiDialogTitlebar ); - - ( this.uiDialogTitlebarCloseText = $( "" ) ) - .addClass( "ui-icon ui-icon-closethick" ) - .text( options.closeText ) - .appendTo( uiDialogTitlebarClose ); - - uiDialogTitle = $( "" ) - .uniqueId() - .addClass( "ui-dialog-title" ) - .html( title ) - .prependTo( uiDialogTitlebar ); - - uiDialogButtonPane = ( this.uiDialogButtonPane = $( "
" ) ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); - - ( this.uiButtonSet = $( "
" ) ) - .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); - - uiDialog.attr({ - role: "dialog", - "aria-labelledby": uiDialogTitle.attr( "id" ) - }); - - uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection(); - this._hoverable( uiDialogTitlebarClose ); - this._focusable( uiDialogTitlebarClose ); - - if ( options.draggable && $.fn.draggable ) { - this._makeDraggable(); - } - if ( options.resizable && $.fn.resizable ) { - this._makeResizable(); - } - - this._createButtons( options.buttons ); - this._isOpen = false; - - if ( $.fn.bgiframe ) { - uiDialog.bgiframe(); - } - - // prevent tabbing out of modal dialogs - this._on( uiDialog, { keydown: function( event ) { - if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) { - return; - } - - var tabbables = $( ":tabbable", uiDialog ), - first = tabbables.filter( ":first" ), - last = tabbables.filter( ":last" ); - - if ( event.target === last[0] && !event.shiftKey ) { - first.focus( 1 ); - return false; - } else if ( event.target === first[0] && event.shiftKey ) { - last.focus( 1 ); - return false; - } - }}); - }, - - _init: function() { - if ( this.options.autoOpen ) { - this.open(); - } - }, - - _destroy: function() { - var next, - oldPosition = this.oldPosition; - - if ( this.overlay ) { - this.overlay.destroy(); - } - this.uiDialog.hide(); - this.element - .removeClass( "ui-dialog-content ui-widget-content" ) - .hide() - .appendTo( "body" ); - this.uiDialog.remove(); - - if ( this.originalTitle ) { - this.element.attr( "title", this.originalTitle ); - } - - next = oldPosition.parent.children().eq( oldPosition.index ); - // Don't try to place the dialog next to itself (#8613) - if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { - next.before( this.element ); - } else { - oldPosition.parent.append( this.element ); - } - }, - - widget: function() { - return this.uiDialog; - }, - - close: function( event ) { - var that = this, - maxZ, thisZ; - - if ( !this._isOpen ) { - return; - } - - if ( false === this._trigger( "beforeClose", event ) ) { - return; - } - - this._isOpen = false; - - if ( this.overlay ) { - this.overlay.destroy(); - } - - if ( this.options.hide ) { - this._hide( this.uiDialog, this.options.hide, function() { - that._trigger( "close", event ); - }); - } else { - this.uiDialog.hide(); - this._trigger( "close", event ); - } - - $.ui.dialog.overlay.resize(); - - // adjust the maxZ to allow other modal dialogs to continue to work (see #4309) - if ( this.options.modal ) { - maxZ = 0; - $( ".ui-dialog" ).each(function() { - if ( this !== that.uiDialog[0] ) { - thisZ = $( this ).css( "z-index" ); - if ( !isNaN( thisZ ) ) { - maxZ = Math.max( maxZ, thisZ ); - } - } - }); - $.ui.dialog.maxZ = maxZ; - } - - return this; - }, - - isOpen: function() { - return this._isOpen; - }, - - // the force parameter allows us to move modal dialogs to their correct - // position on open - moveToTop: function( force, event ) { - var options = this.options, - saveScroll; - - if ( ( options.modal && !force ) || - ( !options.stack && !options.modal ) ) { - return this._trigger( "focus", event ); - } - - if ( options.zIndex > $.ui.dialog.maxZ ) { - $.ui.dialog.maxZ = options.zIndex; - } - if ( this.overlay ) { - $.ui.dialog.maxZ += 1; - $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ; - this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ ); - } - - // Save and then restore scroll - // Opera 9.5+ resets when parent z-index is changed. - // http://bugs.jqueryui.com/ticket/3193 - saveScroll = { - scrollTop: this.element.scrollTop(), - scrollLeft: this.element.scrollLeft() - }; - $.ui.dialog.maxZ += 1; - this.uiDialog.css( "z-index", $.ui.dialog.maxZ ); - this.element.attr( saveScroll ); - this._trigger( "focus", event ); - - return this; - }, - - open: function() { - if ( this._isOpen ) { - return; - } - - var hasFocus, - options = this.options, - uiDialog = this.uiDialog; - - this._size(); - this._position( options.position ); - uiDialog.show( options.show ); - this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null; - this.moveToTop( true ); - - // set focus to the first tabbable element in the content area or the first button - // if there are no tabbable elements, set focus on the dialog itself - hasFocus = this.element.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = uiDialog; - } - } - hasFocus.eq( 0 ).focus(); - - this._isOpen = true; - this._trigger( "open" ); - - return this; - }, - - _createButtons: function( buttons ) { - var that = this, - hasButtons = false; - - // if we already have a button pane, remove it - this.uiDialogButtonPane.remove(); - this.uiButtonSet.empty(); - - if ( typeof buttons === "object" && buttons !== null ) { - $.each( buttons, function() { - return !(hasButtons = true); - }); - } - if ( hasButtons ) { - $.each( buttons, function( name, props ) { - var button, click; - props = $.isFunction( props ) ? - { click: props, text: name } : - props; - // Default to a non-submitting button - props = $.extend( { type: "button" }, props ); - // Change the context for the click callback to be the main element - click = props.click; - props.click = function() { - click.apply( that.element[0], arguments ); - }; - button = $( "", props ) - .appendTo( that.uiButtonSet ); - if ( $.fn.button ) { - button.button(); - } - }); - this.uiDialog.addClass( "ui-dialog-buttons" ); - this.uiDialogButtonPane.appendTo( this.uiDialog ); - } else { - this.uiDialog.removeClass( "ui-dialog-buttons" ); - } - }, - - _makeDraggable: function() { - var that = this, - options = this.options; - - function filteredUi( ui ) { - return { - position: ui.position, - offset: ui.offset - }; - } - - this.uiDialog.draggable({ - cancel: ".ui-dialog-content, .ui-dialog-titlebar-close", - handle: ".ui-dialog-titlebar", - containment: "document", - start: function( event, ui ) { - $( this ) - .addClass( "ui-dialog-dragging" ); - that._trigger( "dragStart", event, filteredUi( ui ) ); - }, - drag: function( event, ui ) { - that._trigger( "drag", event, filteredUi( ui ) ); - }, - stop: function( event, ui ) { - options.position = [ - ui.position.left - that.document.scrollLeft(), - ui.position.top - that.document.scrollTop() - ]; - $( this ) - .removeClass( "ui-dialog-dragging" ); - that._trigger( "dragStop", event, filteredUi( ui ) ); - $.ui.dialog.overlay.resize(); - } - }); - }, - - _makeResizable: function( handles ) { - handles = (handles === undefined ? this.options.resizable : handles); - var that = this, - options = this.options, - // .ui-resizable has position: relative defined in the stylesheet - // but dialogs have to use absolute or fixed positioning - position = this.uiDialog.css( "position" ), - resizeHandles = typeof handles === 'string' ? - handles : - "n,e,s,w,se,sw,ne,nw"; - - function filteredUi( ui ) { - return { - originalPosition: ui.originalPosition, - originalSize: ui.originalSize, - position: ui.position, - size: ui.size - }; - } - - this.uiDialog.resizable({ - cancel: ".ui-dialog-content", - containment: "document", - alsoResize: this.element, - maxWidth: options.maxWidth, - maxHeight: options.maxHeight, - minWidth: options.minWidth, - minHeight: this._minHeight(), - handles: resizeHandles, - start: function( event, ui ) { - $( this ).addClass( "ui-dialog-resizing" ); - that._trigger( "resizeStart", event, filteredUi( ui ) ); - }, - resize: function( event, ui ) { - that._trigger( "resize", event, filteredUi( ui ) ); - }, - stop: function( event, ui ) { - $( this ).removeClass( "ui-dialog-resizing" ); - options.height = $( this ).height(); - options.width = $( this ).width(); - that._trigger( "resizeStop", event, filteredUi( ui ) ); - $.ui.dialog.overlay.resize(); - } - }) - .css( "position", position ) - .find( ".ui-resizable-se" ) - .addClass( "ui-icon ui-icon-grip-diagonal-se" ); - }, - - _minHeight: function() { - var options = this.options; - - if ( options.height === "auto" ) { - return options.minHeight; - } else { - return Math.min( options.minHeight, options.height ); - } - }, - - _position: function( position ) { - var myAt = [], - offset = [ 0, 0 ], - isVisible; - - if ( position ) { - // deep extending converts arrays to objects in jQuery <= 1.3.2 :-( - // if (typeof position == 'string' || $.isArray(position)) { - // myAt = $.isArray(position) ? position : position.split(' '); - - if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { - myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ]; - if ( myAt.length === 1 ) { - myAt[ 1 ] = myAt[ 0 ]; - } - - $.each( [ "left", "top" ], function( i, offsetPosition ) { - if ( +myAt[ i ] === myAt[ i ] ) { - offset[ i ] = myAt[ i ]; - myAt[ i ] = offsetPosition; - } - }); - - position = { - my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + - myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), - at: myAt.join( " " ) - }; - } - - position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); - } else { - position = $.ui.dialog.prototype.options.position; - } - - // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is( ":visible" ); - if ( !isVisible ) { - this.uiDialog.show(); - } - this.uiDialog.position( position ); - if ( !isVisible ) { - this.uiDialog.hide(); - } - }, - - _setOptions: function( options ) { - var that = this, - resizableOptions = {}, - resize = false; - - $.each( options, function( key, value ) { - that._setOption( key, value ); - - if ( key in sizeRelatedOptions ) { - resize = true; - } - if ( key in resizableRelatedOptions ) { - resizableOptions[ key ] = value; - } - }); - - if ( resize ) { - this._size(); - } - if ( this.uiDialog.is( ":data(resizable)" ) ) { - this.uiDialog.resizable( "option", resizableOptions ); - } - }, - - _setOption: function( key, value ) { - var isDraggable, isResizable, - uiDialog = this.uiDialog; - - switch ( key ) { - case "buttons": - this._createButtons( value ); - break; - case "closeText": - // ensure that we always pass a string - this.uiDialogTitlebarCloseText.text( "" + value ); - break; - case "dialogClass": - uiDialog - .removeClass( this.options.dialogClass ) - .addClass( uiDialogClasses + value ); - break; - case "disabled": - if ( value ) { - uiDialog.addClass( "ui-dialog-disabled" ); - } else { - uiDialog.removeClass( "ui-dialog-disabled" ); - } - break; - case "draggable": - isDraggable = uiDialog.is( ":data(draggable)" ); - if ( isDraggable && !value ) { - uiDialog.draggable( "destroy" ); - } - - if ( !isDraggable && value ) { - this._makeDraggable(); - } - break; - case "position": - this._position( value ); - break; - case "resizable": - // currently resizable, becoming non-resizable - isResizable = uiDialog.is( ":data(resizable)" ); - if ( isResizable && !value ) { - uiDialog.resizable( "destroy" ); - } - - // currently resizable, changing handles - if ( isResizable && typeof value === "string" ) { - uiDialog.resizable( "option", "handles", value ); - } - - // currently non-resizable, becoming resizable - if ( !isResizable && value !== false ) { - this._makeResizable( value ); - } - break; - case "title": - // convert whatever was passed in o a string, for html() to not throw up - $( ".ui-dialog-title", this.uiDialogTitlebar ) - .html( "" + ( value || " " ) ); - break; - } - - this._super( key, value ); - }, - - _size: function() { - /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content - * divs will both have width and height set, so we need to reset them - */ - var nonContentHeight, minContentHeight, autoHeight, - options = this.options, - isVisible = this.uiDialog.is( ":visible" ); - - // reset content sizing - this.element.show().css({ - width: "auto", - minHeight: 0, - height: 0 - }); - - if ( options.minWidth > options.width ) { - options.width = options.minWidth; - } - - // reset wrapper sizing - // determine the height of all the non-content elements - nonContentHeight = this.uiDialog.css({ - height: "auto", - width: options.width - }) - .outerHeight(); - minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); - - if ( options.height === "auto" ) { - // only needed for IE6 support - if ( $.support.minHeight ) { - this.element.css({ - minHeight: minContentHeight, - height: "auto" - }); - } else { - this.uiDialog.show(); - autoHeight = this.element.css( "height", "auto" ).height(); - if ( !isVisible ) { - this.uiDialog.hide(); - } - this.element.height( Math.max( autoHeight, minContentHeight ) ); - } - } else { - this.element.height( Math.max( options.height - nonContentHeight, 0 ) ); - } - - if (this.uiDialog.is( ":data(resizable)" ) ) { - this.uiDialog.resizable( "option", "minHeight", this._minHeight() ); - } - } -}); - -$.extend($.ui.dialog, { - uuid: 0, - maxZ: 0, - - getTitleId: function($el) { - var id = $el.attr( "id" ); - if ( !id ) { - this.uuid += 1; - id = this.uuid; - } - return "ui-dialog-title-" + id; - }, - - overlay: function( dialog ) { - this.$el = $.ui.dialog.overlay.create( dialog ); - } -}); - -$.extend( $.ui.dialog.overlay, { - instances: [], - // reuse old instances due to IE memory leak with alpha transparency (see #5185) - oldInstances: [], - maxZ: 0, - events: $.map( - "focus,mousedown,mouseup,keydown,keypress,click".split( "," ), - function( event ) { - return event + ".dialog-overlay"; - } - ).join( " " ), - create: function( dialog ) { - if ( this.instances.length === 0 ) { - // prevent use of anchors and inputs - // we use a setTimeout in case the overlay is created from an - // event that we're going to be cancelling (see #2804) - setTimeout(function() { - // handle $(el).dialog().dialog('close') (see #4065) - if ( $.ui.dialog.overlay.instances.length ) { - $( document ).bind( $.ui.dialog.overlay.events, function( event ) { - // stop events if the z-index of the target is < the z-index of the overlay - // we cannot return true when we don't want to cancel the event (#3523) - if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) { - return false; - } - }); - } - }, 1 ); - - // handle window resize - $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize ); - } - - var $el = ( this.oldInstances.pop() || $( "
" ).addClass( "ui-widget-overlay" ) ); - - // allow closing by pressing the escape key - $( document ).bind( "keydown.dialog-overlay", function( event ) { - var instances = $.ui.dialog.overlay.instances; - // only react to the event if we're the top overlay - if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el && - dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && - event.keyCode === $.ui.keyCode.ESCAPE ) { - - dialog.close( event ); - event.preventDefault(); - } - }); - - $el.appendTo( document.body ).css({ - width: this.width(), - height: this.height() - }); - - if ( $.fn.bgiframe ) { - $el.bgiframe(); - } - - this.instances.push( $el ); - return $el; - }, - - destroy: function( $el ) { - var indexOf = $.inArray( $el, this.instances ), - maxZ = 0; - - if ( indexOf !== -1 ) { - this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] ); - } - - if ( this.instances.length === 0 ) { - $( [ document, window ] ).unbind( ".dialog-overlay" ); - } - - $el.height( 0 ).width( 0 ).remove(); - - // adjust the maxZ to allow other modal dialogs to continue to work (see #4309) - $.each( this.instances, function() { - maxZ = Math.max( maxZ, this.css( "z-index" ) ); - }); - this.maxZ = maxZ; - }, - - height: function() { - var scrollHeight, - offsetHeight; - // handle IE - if ( $.ui.ie ) { - scrollHeight = Math.max( - document.documentElement.scrollHeight, - document.body.scrollHeight - ); - offsetHeight = Math.max( - document.documentElement.offsetHeight, - document.body.offsetHeight - ); - - if ( scrollHeight < offsetHeight ) { - return $( window ).height() + "px"; - } else { - return scrollHeight + "px"; - } - // handle "good" browsers - } else { - return $( document ).height() + "px"; - } - }, - - width: function() { - var scrollWidth, - offsetWidth; - // handle IE - if ( $.ui.ie ) { - scrollWidth = Math.max( - document.documentElement.scrollWidth, - document.body.scrollWidth - ); - offsetWidth = Math.max( - document.documentElement.offsetWidth, - document.body.offsetWidth - ); - - if ( scrollWidth < offsetWidth ) { - return $( window ).width() + "px"; - } else { - return scrollWidth + "px"; - } - // handle "good" browsers - } else { - return $( document ).width() + "px"; - } - }, - - resize: function() { - /* If the dialog is draggable and the user drags it past the - * right edge of the window, the document becomes wider so we - * need to stretch the overlay. If the user then drags the - * dialog back to the left, the document will become narrower, - * so we need to shrink the overlay to the appropriate size. - * This is handled by shrinking the overlay before setting it - * to the full document size. - */ - var $overlays = $( [] ); - $.each( $.ui.dialog.overlay.instances, function() { - $overlays = $overlays.add( this ); - }); - - $overlays.css({ - width: 0, - height: 0 - }).css({ - width: $.ui.dialog.overlay.width(), - height: $.ui.dialog.overlay.height() - }); - } -}); - -$.extend( $.ui.dialog.overlay.prototype, { - destroy: function() { - $.ui.dialog.overlay.destroy( this.$el ); - } -}); - -}( jQuery ) ); -(function( $, undefined ) { - -$.widget("ui.draggable", $.ui.mouse, { - version: "1.9.2", - widgetEventPrefix: "drag", - options: { - addClasses: true, - appendTo: "parent", - axis: false, - connectToSortable: false, - containment: false, - cursor: "auto", - cursorAt: false, - grid: false, - handle: false, - helper: "original", - iframeFix: false, - opacity: false, - refreshPositions: false, - revert: false, - revertDuration: 500, - scope: "default", - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - snap: false, - snapMode: "both", - snapTolerance: 20, - stack: false, - zIndex: false - }, - _create: function() { - - if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) - this.element[0].style.position = 'relative'; - - (this.options.addClasses && this.element.addClass("ui-draggable")); - (this.options.disabled && this.element.addClass("ui-draggable-disabled")); - - this._mouseInit(); - - }, - - _destroy: function() { - this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); - this._mouseDestroy(); - }, - - _mouseCapture: function(event) { - - var o = this.options; - - // among others, prevent a drag on a resizable-handle - if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) - return false; - - //Quit if we're not on a valid handle - this.handle = this._getHandle(event); - if (!this.handle) - return false; - - $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { - $('
') - .css({ - width: this.offsetWidth+"px", height: this.offsetHeight+"px", - position: "absolute", opacity: "0.001", zIndex: 1000 - }) - .css($(this).offset()) - .appendTo("body"); - }); - - return true; - - }, - - _mouseStart: function(event) { - - var o = this.options; - - //Create and append the visible helper - this.helper = this._createHelper(event); - - this.helper.addClass("ui-draggable-dragging"); - - //Cache the helper size - this._cacheHelperProportions(); - - //If ddmanager is used for droppables, set the global draggable - if($.ui.ddmanager) - $.ui.ddmanager.current = this; - - /* - * - Position generation - - * This block generates everything position related - it's the core of draggables. - */ - - //Cache the margins of the original element - this._cacheMargins(); - - //Store the helper's css position - this.cssPosition = this.helper.css("position"); - this.scrollParent = this.helper.scrollParent(); - - //The element's absolute position on the page minus margins - this.offset = this.positionAbs = this.element.offset(); - this.offset = { - top: this.offset.top - this.margins.top, - left: this.offset.left - this.margins.left - }; - - $.extend(this.offset, { - click: { //Where the click happened, relative to the element - left: event.pageX - this.offset.left, - top: event.pageY - this.offset.top - }, - parent: this._getParentOffset(), - relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper - }); - - //Generate the original position - this.originalPosition = this.position = this._generatePosition(event); - this.originalPageX = event.pageX; - this.originalPageY = event.pageY; - - //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied - (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); - - //Set a containment if given in the options - if(o.containment) - this._setContainment(); - - //Trigger event + callbacks - if(this._trigger("start", event) === false) { - this._clear(); - return false; - } - - //Recache the helper size - this._cacheHelperProportions(); - - //Prepare the droppable offsets - if ($.ui.ddmanager && !o.dropBehaviour) - $.ui.ddmanager.prepareOffsets(this, event); - - - this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position - - //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) - if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event); - - return true; - }, - - _mouseDrag: function(event, noPropagation) { - - //Compute the helpers position - this.position = this._generatePosition(event); - this.positionAbs = this._convertPositionTo("absolute"); - - //Call plugins and callbacks and use the resulting position if something is returned - if (!noPropagation) { - var ui = this._uiHash(); - if(this._trigger('drag', event, ui) === false) { - this._mouseUp({}); - return false; - } - this.position = ui.position; - } - - if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; - if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; - if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); - - return false; - }, - - _mouseStop: function(event) { - - //If we are using droppables, inform the manager about the drop - var dropped = false; - if ($.ui.ddmanager && !this.options.dropBehaviour) - dropped = $.ui.ddmanager.drop(this, event); - - //if a drop comes from outside (a sortable) - if(this.dropped) { - dropped = this.dropped; - this.dropped = false; - } - - //if the original element is no longer in the DOM don't bother to continue (see #8269) - var element = this.element[0], elementInDom = false; - while ( element && (element = element.parentNode) ) { - if (element == document ) { - elementInDom = true; - } - } - if ( !elementInDom && this.options.helper === "original" ) - return false; - - if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { - var that = this; - $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { - if(that._trigger("stop", event) !== false) { - that._clear(); - } - }); - } else { - if(this._trigger("stop", event) !== false) { - this._clear(); - } - } - - return false; - }, - - _mouseUp: function(event) { - //Remove frame helpers - $("div.ui-draggable-iframeFix").each(function() { - this.parentNode.removeChild(this); - }); - - //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) - if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event); - - return $.ui.mouse.prototype._mouseUp.call(this, event); - }, - - cancel: function() { - - if(this.helper.is(".ui-draggable-dragging")) { - this._mouseUp({}); - } else { - this._clear(); - } - - return this; - - }, - - _getHandle: function(event) { - - var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - $(this.options.handle, this.element) - .find("*") - .andSelf() - .each(function() { - if(this == event.target) handle = true; - }); - - return handle; - - }, - - _createHelper: function(event) { - - var o = this.options; - var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element); - - if(!helper.parents('body').length) - helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); - - if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) - helper.css("position", "absolute"); - - return helper; - - }, - - _adjustOffsetFromHelper: function(obj) { - if (typeof obj == 'string') { - obj = obj.split(' '); - } - if ($.isArray(obj)) { - obj = {left: +obj[0], top: +obj[1] || 0}; - } - if ('left' in obj) { - this.offset.click.left = obj.left + this.margins.left; - } - if ('right' in obj) { - this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; - } - if ('top' in obj) { - this.offset.click.top = obj.top + this.margins.top; - } - if ('bottom' in obj) { - this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; - } - }, - - _getParentOffset: function() { - - //Get the offsetParent and cache its position - this.offsetParent = this.helper.offsetParent(); - var po = this.offsetParent.offset(); - - // This is a special case where we need to modify a offset calculated on start, since the following happened: - // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent - // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that - // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag - if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) { - po.left += this.scrollParent.scrollLeft(); - po.top += this.scrollParent.scrollTop(); - } - - if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information - || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix - po = { top: 0, left: 0 }; - - return { - top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), - left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) - }; - - }, - - _getRelativeOffset: function() { - - if(this.cssPosition == "relative") { - var p = this.element.position(); - return { - top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), - left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() - }; - } else { - return { top: 0, left: 0 }; - } - - }, - - _cacheMargins: function() { - this.margins = { - left: (parseInt(this.element.css("marginLeft"),10) || 0), - top: (parseInt(this.element.css("marginTop"),10) || 0), - right: (parseInt(this.element.css("marginRight"),10) || 0), - bottom: (parseInt(this.element.css("marginBottom"),10) || 0) - }; - }, - - _cacheHelperProportions: function() { - this.helperProportions = { - width: this.helper.outerWidth(), - height: this.helper.outerHeight() - }; - }, - - _setContainment: function() { - - var o = this.options; - if(o.containment == 'parent') o.containment = this.helper[0].parentNode; - if(o.containment == 'document' || o.containment == 'window') this.containment = [ - o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left, - o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top, - (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, - (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top - ]; - - if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { - var c = $(o.containment); - var ce = c[0]; if(!ce) return; - var co = c.offset(); - var over = ($(ce).css("overflow") != 'hidden'); - - this.containment = [ - (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), - (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), - (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, - (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom - ]; - this.relative_container = c; - - } else if(o.containment.constructor == Array) { - this.containment = o.containment; - } - - }, - - _convertPositionTo: function(d, pos) { - - if(!pos) pos = this.position; - var mod = d == "absolute" ? 1 : -1; - var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); - - return { - top: ( - pos.top // The absolute mouse position - + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent - + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) - - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) - ), - left: ( - pos.left // The absolute mouse position - + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent - + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) - - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) - ) - }; - - }, - - _generatePosition: function(event) { - - var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); - var pageX = event.pageX; - var pageY = event.pageY; - - /* - * - Position constraining - - * Constrain the position to a mix of grid, containment. - */ - - if(this.originalPosition) { //If we are not dragging yet, we won't check for options - var containment; - if(this.containment) { - if (this.relative_container){ - var co = this.relative_container.offset(); - containment = [ this.containment[0] + co.left, - this.containment[1] + co.top, - this.containment[2] + co.left, - this.containment[3] + co.top ]; - } - else { - containment = this.containment; - } - - if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left; - if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top; - if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left; - if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top; - } - - if(o.grid) { - //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) - var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; - pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; - - var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; - pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; - } - - } - - return { - top: ( - pageY // The absolute mouse position - - this.offset.click.top // Click offset (relative to the element) - - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent - - this.offset.parent.top // The offsetParent's offset without borders (offset + border) - + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) - ), - left: ( - pageX // The absolute mouse position - - this.offset.click.left // Click offset (relative to the element) - - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent - - this.offset.parent.left // The offsetParent's offset without borders (offset + border) - + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) - ) - }; - - }, - - _clear: function() { - this.helper.removeClass("ui-draggable-dragging"); - if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); - //if($.ui.ddmanager) $.ui.ddmanager.current = null; - this.helper = null; - this.cancelHelperRemoval = false; - }, - - // From now on bulk stuff - mainly helpers - - _trigger: function(type, event, ui) { - ui = ui || this._uiHash(); - $.ui.plugin.call(this, type, [event, ui]); - if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins - return $.Widget.prototype._trigger.call(this, type, event, ui); - }, - - plugins: {}, - - _uiHash: function(event) { - return { - helper: this.helper, - position: this.position, - originalPosition: this.originalPosition, - offset: this.positionAbs - }; - } - -}); - -$.ui.plugin.add("draggable", "connectToSortable", { - start: function(event, ui) { - - var inst = $(this).data("draggable"), o = inst.options, - uiSortable = $.extend({}, ui, { item: inst.element }); - inst.sortables = []; - $(o.connectToSortable).each(function() { - var sortable = $.data(this, 'sortable'); - if (sortable && !sortable.options.disabled) { - inst.sortables.push({ - instance: sortable, - shouldRevert: sortable.options.revert - }); - sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page). - sortable._trigger("activate", event, uiSortable); - } - }); - - }, - stop: function(event, ui) { - - //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper - var inst = $(this).data("draggable"), - uiSortable = $.extend({}, ui, { item: inst.element }); - - $.each(inst.sortables, function() { - if(this.instance.isOver) { - - this.instance.isOver = 0; - - inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance - this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) - - //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' - if(this.shouldRevert) this.instance.options.revert = true; - - //Trigger the stop of the sortable - this.instance._mouseStop(event); - - this.instance.options.helper = this.instance.options._helper; - - //If the helper has been the original item, restore properties in the sortable - if(inst.options.helper == 'original') - this.instance.currentItem.css({ top: 'auto', left: 'auto' }); - - } else { - this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance - this.instance._trigger("deactivate", event, uiSortable); - } - - }); - - }, - drag: function(event, ui) { - - var inst = $(this).data("draggable"), that = this; - - var checkPos = function(o) { - var dyClick = this.offset.click.top, dxClick = this.offset.click.left; - var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; - var itemHeight = o.height, itemWidth = o.width; - var itemTop = o.top, itemLeft = o.left; - - return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); - }; - - $.each(inst.sortables, function(i) { - - var innermostIntersecting = false; - var thisSortable = this; - //Copy over some variables to allow calling the sortable's native _intersectsWith - this.instance.positionAbs = inst.positionAbs; - this.instance.helperProportions = inst.helperProportions; - this.instance.offset.click = inst.offset.click; - - if(this.instance._intersectsWith(this.instance.containerCache)) { - innermostIntersecting = true; - $.each(inst.sortables, function () { - this.instance.positionAbs = inst.positionAbs; - this.instance.helperProportions = inst.helperProportions; - this.instance.offset.click = inst.offset.click; - if (this != thisSortable - && this.instance._intersectsWith(this.instance.containerCache) - && $.ui.contains(thisSortable.instance.element[0], this.instance.element[0])) - innermostIntersecting = false; - return innermostIntersecting; - }); - } - - - if(innermostIntersecting) { - //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once - if(!this.instance.isOver) { - - this.instance.isOver = 1; - //Now we fake the start of dragging for the sortable instance, - //by cloning the list group item, appending it to the sortable and using it as inst.currentItem - //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) - this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true); - this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it - this.instance.options.helper = function() { return ui.helper[0]; }; - - event.target = this.instance.currentItem[0]; - this.instance._mouseCapture(event, true); - this.instance._mouseStart(event, true, true); - - //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes - this.instance.offset.click.top = inst.offset.click.top; - this.instance.offset.click.left = inst.offset.click.left; - this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; - this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; - - inst._trigger("toSortable", event); - inst.dropped = this.instance.element; //draggable revert needs that - //hack so receive/update callbacks work (mostly) - inst.currentItem = inst.element; - this.instance.fromOutside = inst; - - } - - //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable - if(this.instance.currentItem) this.instance._mouseDrag(event); - - } else { - - //If it doesn't intersect with the sortable, and it intersected before, - //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval - if(this.instance.isOver) { - - this.instance.isOver = 0; - this.instance.cancelHelperRemoval = true; - - //Prevent reverting on this forced stop - this.instance.options.revert = false; - - // The out event needs to be triggered independently - this.instance._trigger('out', event, this.instance._uiHash(this.instance)); - - this.instance._mouseStop(event, true); - this.instance.options.helper = this.instance.options._helper; - - //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size - this.instance.currentItem.remove(); - if(this.instance.placeholder) this.instance.placeholder.remove(); - - inst._trigger("fromSortable", event); - inst.dropped = false; //draggable revert needs that - } - - }; - - }); - - } -}); - -$.ui.plugin.add("draggable", "cursor", { - start: function(event, ui) { - var t = $('body'), o = $(this).data('draggable').options; - if (t.css("cursor")) o._cursor = t.css("cursor"); - t.css("cursor", o.cursor); - }, - stop: function(event, ui) { - var o = $(this).data('draggable').options; - if (o._cursor) $('body').css("cursor", o._cursor); - } -}); - -$.ui.plugin.add("draggable", "opacity", { - start: function(event, ui) { - var t = $(ui.helper), o = $(this).data('draggable').options; - if(t.css("opacity")) o._opacity = t.css("opacity"); - t.css('opacity', o.opacity); - }, - stop: function(event, ui) { - var o = $(this).data('draggable').options; - if(o._opacity) $(ui.helper).css('opacity', o._opacity); - } -}); - -$.ui.plugin.add("draggable", "scroll", { - start: function(event, ui) { - var i = $(this).data("draggable"); - if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); - }, - drag: function(event, ui) { - - var i = $(this).data("draggable"), o = i.options, scrolled = false; - - if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { - - if(!o.axis || o.axis != 'x') { - if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) - i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; - else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) - i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; - } - - if(!o.axis || o.axis != 'y') { - if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) - i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; - else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) - i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; - } - - } else { - - if(!o.axis || o.axis != 'x') { - if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) - scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); - else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) - scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); - } - - if(!o.axis || o.axis != 'y') { - if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) - scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); - else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) - scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); - } - - } - - if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) - $.ui.ddmanager.prepareOffsets(i, event); - - } -}); - -$.ui.plugin.add("draggable", "snap", { - start: function(event, ui) { - - var i = $(this).data("draggable"), o = i.options; - i.snapElements = []; - - $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { - var $t = $(this); var $o = $t.offset(); - if(this != i.element[0]) i.snapElements.push({ - item: this, - width: $t.outerWidth(), height: $t.outerHeight(), - top: $o.top, left: $o.left - }); - }); - - }, - drag: function(event, ui) { - - var inst = $(this).data("draggable"), o = inst.options; - var d = o.snapTolerance; - - var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, - y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; - - for (var i = inst.snapElements.length - 1; i >= 0; i--){ - - var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, - t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; - - //Yes, I know, this is insane ;) - if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { - if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); - inst.snapElements[i].snapping = false; - continue; - } - - if(o.snapMode != 'inner') { - var ts = Math.abs(t - y2) <= d; - var bs = Math.abs(b - y1) <= d; - var ls = Math.abs(l - x2) <= d; - var rs = Math.abs(r - x1) <= d; - if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; - if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; - if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; - if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; - } - - var first = (ts || bs || ls || rs); - - if(o.snapMode != 'outer') { - var ts = Math.abs(t - y1) <= d; - var bs = Math.abs(b - y2) <= d; - var ls = Math.abs(l - x1) <= d; - var rs = Math.abs(r - x2) <= d; - if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; - if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; - if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; - if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; - } - - if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) - (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); - inst.snapElements[i].snapping = (ts || bs || ls || rs || first); - - }; - - } -}); - -$.ui.plugin.add("draggable", "stack", { - start: function(event, ui) { - - var o = $(this).data("draggable").options; - - var group = $.makeArray($(o.stack)).sort(function(a,b) { - return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); - }); - if (!group.length) { return; } - - var min = parseInt(group[0].style.zIndex) || 0; - $(group).each(function(i) { - this.style.zIndex = min + i; - }); - - this[0].style.zIndex = min + group.length; - - } -}); - -$.ui.plugin.add("draggable", "zIndex", { - start: function(event, ui) { - var t = $(ui.helper), o = $(this).data("draggable").options; - if(t.css("zIndex")) o._zIndex = t.css("zIndex"); - t.css('zIndex', o.zIndex); - }, - stop: function(event, ui) { - var o = $(this).data("draggable").options; - if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); - } -}); - -})(jQuery); -(function( $, undefined ) { - -$.widget("ui.droppable", { - version: "1.9.2", - widgetEventPrefix: "drop", - options: { - accept: '*', - activeClass: false, - addClasses: true, - greedy: false, - hoverClass: false, - scope: 'default', - tolerance: 'intersect' - }, - _create: function() { - - var o = this.options, accept = o.accept; - this.isover = 0; this.isout = 1; - - this.accept = $.isFunction(accept) ? accept : function(d) { - return d.is(accept); - }; - - //Store the droppable's proportions - this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; - - // Add the reference and positions to the manager - $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || []; - $.ui.ddmanager.droppables[o.scope].push(this); - - (o.addClasses && this.element.addClass("ui-droppable")); - - }, - - _destroy: function() { - var drop = $.ui.ddmanager.droppables[this.options.scope]; - for ( var i = 0; i < drop.length; i++ ) - if ( drop[i] == this ) - drop.splice(i, 1); - - this.element.removeClass("ui-droppable ui-droppable-disabled"); - }, - - _setOption: function(key, value) { - - if(key == 'accept') { - this.accept = $.isFunction(value) ? value : function(d) { - return d.is(value); - }; - } - $.Widget.prototype._setOption.apply(this, arguments); - }, - - _activate: function(event) { - var draggable = $.ui.ddmanager.current; - if(this.options.activeClass) this.element.addClass(this.options.activeClass); - (draggable && this._trigger('activate', event, this.ui(draggable))); - }, - - _deactivate: function(event) { - var draggable = $.ui.ddmanager.current; - if(this.options.activeClass) this.element.removeClass(this.options.activeClass); - (draggable && this._trigger('deactivate', event, this.ui(draggable))); - }, - - _over: function(event) { - - var draggable = $.ui.ddmanager.current; - if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element - - if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { - if(this.options.hoverClass) this.element.addClass(this.options.hoverClass); - this._trigger('over', event, this.ui(draggable)); - } - - }, - - _out: function(event) { - - var draggable = $.ui.ddmanager.current; - if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element - - if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { - if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); - this._trigger('out', event, this.ui(draggable)); - } - - }, - - _drop: function(event,custom) { - - var draggable = custom || $.ui.ddmanager.current; - if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element - - var childrenIntersection = false; - this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() { - var inst = $.data(this, 'droppable'); - if( - inst.options.greedy - && !inst.options.disabled - && inst.options.scope == draggable.options.scope - && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) - && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance) - ) { childrenIntersection = true; return false; } - }); - if(childrenIntersection) return false; - - if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { - if(this.options.activeClass) this.element.removeClass(this.options.activeClass); - if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); - this._trigger('drop', event, this.ui(draggable)); - return this.element; - } - - return false; - - }, - - ui: function(c) { - return { - draggable: (c.currentItem || c.element), - helper: c.helper, - position: c.position, - offset: c.positionAbs - }; - } - -}); - -$.ui.intersect = function(draggable, droppable, toleranceMode) { - - if (!droppable.offset) return false; - - var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, - y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height; - var l = droppable.offset.left, r = l + droppable.proportions.width, - t = droppable.offset.top, b = t + droppable.proportions.height; - - switch (toleranceMode) { - case 'fit': - return (l <= x1 && x2 <= r - && t <= y1 && y2 <= b); - break; - case 'intersect': - return (l < x1 + (draggable.helperProportions.width / 2) // Right Half - && x2 - (draggable.helperProportions.width / 2) < r // Left Half - && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half - && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half - break; - case 'pointer': - var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left), - draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top), - isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width); - return isOver; - break; - case 'touch': - return ( - (y1 >= t && y1 <= b) || // Top edge touching - (y2 >= t && y2 <= b) || // Bottom edge touching - (y1 < t && y2 > b) // Surrounded vertically - ) && ( - (x1 >= l && x1 <= r) || // Left edge touching - (x2 >= l && x2 <= r) || // Right edge touching - (x1 < l && x2 > r) // Surrounded horizontally - ); - break; - default: - return false; - break; - } - -}; - -/* - This manager tracks offsets of draggables and droppables -*/ -$.ui.ddmanager = { - current: null, - droppables: { 'default': [] }, - prepareOffsets: function(t, event) { - - var m = $.ui.ddmanager.droppables[t.options.scope] || []; - var type = event ? event.type : null; // workaround for #2317 - var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); - - droppablesLoop: for (var i = 0; i < m.length; i++) { - - if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted - for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item - m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue - - if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables - - m[i].offset = m[i].element.offset(); - m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; - - } - - }, - drop: function(draggable, event) { - - var dropped = false; - $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { - - if(!this.options) return; - if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) - dropped = this._drop.call(this, event) || dropped; - - if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { - this.isout = 1; this.isover = 0; - this._deactivate.call(this, event); - } - - }); - return dropped; - - }, - dragStart: function( draggable, event ) { - //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) - draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() { - if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event ); - }); - }, - drag: function(draggable, event) { - - //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. - if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event); - - //Run through all droppables and check their positions based on specific tolerance options - $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { - - if(this.options.disabled || this.greedyChild || !this.visible) return; - var intersects = $.ui.intersect(draggable, this, this.options.tolerance); - - var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null); - if(!c) return; - - var parentInstance; - if (this.options.greedy) { - // find droppable parents with same scope - var scope = this.options.scope; - var parent = this.element.parents(':data(droppable)').filter(function () { - return $.data(this, 'droppable').options.scope === scope; - }); - - if (parent.length) { - parentInstance = $.data(parent[0], 'droppable'); - parentInstance.greedyChild = (c == 'isover' ? 1 : 0); - } - } - - // we just moved into a greedy child - if (parentInstance && c == 'isover') { - parentInstance['isover'] = 0; - parentInstance['isout'] = 1; - parentInstance._out.call(parentInstance, event); - } - - this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; - this[c == "isover" ? "_over" : "_out"].call(this, event); - - // we just moved out of a greedy child - if (parentInstance && c == 'isout') { - parentInstance['isout'] = 0; - parentInstance['isover'] = 1; - parentInstance._over.call(parentInstance, event); - } - }); - - }, - dragStop: function( draggable, event ) { - draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" ); - //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) - if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event ); - } -}; - -})(jQuery); -;(jQuery.effects || (function($, undefined) { - -var backCompat = $.uiBackCompat !== false, - // prefix used for storing data on .data() - dataSpace = "ui-effects-"; - -$.effects = { - effect: {} -}; - -/*! - * jQuery Color Animations v2.0.0 - * http://jquery.com/ - * - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * Date: Mon Aug 13 13:41:02 2012 -0500 - */ -(function( jQuery, undefined ) { - - var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "), - - // plusequals test for += 100 -= 100 - rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, - // a set of RE's that can match strings and generate color tuples. - stringParsers = [{ - re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ], - execResult[ 3 ], - execResult[ 4 ] - ]; - } - }, { - re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ] * 2.55, - execResult[ 2 ] * 2.55, - execResult[ 3 ] * 2.55, - execResult[ 4 ] - ]; - } - }, { - // this regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ], 16 ) - ]; - } - }, { - // this regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) - ]; - } - }, { - re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - space: "hsla", - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ] / 100, - execResult[ 3 ] / 100, - execResult[ 4 ] - ]; - } - }], - - // jQuery.Color( ) - color = jQuery.Color = function( color, green, blue, alpha ) { - return new jQuery.Color.fn.parse( color, green, blue, alpha ); - }, - spaces = { - rgba: { - props: { - red: { - idx: 0, - type: "byte" - }, - green: { - idx: 1, - type: "byte" - }, - blue: { - idx: 2, - type: "byte" - } - } - }, - - hsla: { - props: { - hue: { - idx: 0, - type: "degrees" - }, - saturation: { - idx: 1, - type: "percent" - }, - lightness: { - idx: 2, - type: "percent" - } - } - } - }, - propTypes = { - "byte": { - floor: true, - max: 255 - }, - "percent": { - max: 1 - }, - "degrees": { - mod: 360, - floor: true - } - }, - support = color.support = {}, - - // element for support tests - supportElem = jQuery( "

" )[ 0 ], - - // colors = jQuery.Color.names - colors, - - // local aliases of functions called often - each = jQuery.each; - -// determine rgba support immediately -supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; -support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; - -// define cache name and alpha properties -// for rgba and hsla spaces -each( spaces, function( spaceName, space ) { - space.cache = "_" + spaceName; - space.props.alpha = { - idx: 3, - type: "percent", - def: 1 - }; -}); - -function clamp( value, prop, allowEmpty ) { - var type = propTypes[ prop.type ] || {}; - - if ( value == null ) { - return (allowEmpty || !prop.def) ? null : prop.def; - } - - // ~~ is an short way of doing floor for positive numbers - value = type.floor ? ~~value : parseFloat( value ); - - // IE will pass in empty strings as value for alpha, - // which will hit this case - if ( isNaN( value ) ) { - return prop.def; - } - - if ( type.mod ) { - // we add mod before modding to make sure that negatives values - // get converted properly: -10 -> 350 - return (value + type.mod) % type.mod; - } - - // for now all property types without mod have min and max - return 0 > value ? 0 : type.max < value ? type.max : value; -} - -function stringParse( string ) { - var inst = color(), - rgba = inst._rgba = []; - - string = string.toLowerCase(); - - each( stringParsers, function( i, parser ) { - var parsed, - match = parser.re.exec( string ), - values = match && parser.parse( match ), - spaceName = parser.space || "rgba"; - - if ( values ) { - parsed = inst[ spaceName ]( values ); - - // if this was an rgba parse the assignment might happen twice - // oh well.... - inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; - rgba = inst._rgba = parsed._rgba; - - // exit each( stringParsers ) here because we matched - return false; - } - }); - - // Found a stringParser that handled it - if ( rgba.length ) { - - // if this came from a parsed string, force "transparent" when alpha is 0 - // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) - if ( rgba.join() === "0,0,0,0" ) { - jQuery.extend( rgba, colors.transparent ); - } - return inst; - } - - // named colors - return colors[ string ]; -} - -color.fn = jQuery.extend( color.prototype, { - parse: function( red, green, blue, alpha ) { - if ( red === undefined ) { - this._rgba = [ null, null, null, null ]; - return this; - } - if ( red.jquery || red.nodeType ) { - red = jQuery( red ).css( green ); - green = undefined; - } - - var inst = this, - type = jQuery.type( red ), - rgba = this._rgba = []; - - // more than 1 argument specified - assume ( red, green, blue, alpha ) - if ( green !== undefined ) { - red = [ red, green, blue, alpha ]; - type = "array"; - } - - if ( type === "string" ) { - return this.parse( stringParse( red ) || colors._default ); - } - - if ( type === "array" ) { - each( spaces.rgba.props, function( key, prop ) { - rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); - }); - return this; - } - - if ( type === "object" ) { - if ( red instanceof color ) { - each( spaces, function( spaceName, space ) { - if ( red[ space.cache ] ) { - inst[ space.cache ] = red[ space.cache ].slice(); - } - }); - } else { - each( spaces, function( spaceName, space ) { - var cache = space.cache; - each( space.props, function( key, prop ) { - - // if the cache doesn't exist, and we know how to convert - if ( !inst[ cache ] && space.to ) { - - // if the value was null, we don't need to copy it - // if the key was alpha, we don't need to copy it either - if ( key === "alpha" || red[ key ] == null ) { - return; - } - inst[ cache ] = space.to( inst._rgba ); - } - - // this is the only case where we allow nulls for ALL properties. - // call clamp with alwaysAllowEmpty - inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); - }); - - // everything defined but alpha? - if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { - // use the default of 1 - inst[ cache ][ 3 ] = 1; - if ( space.from ) { - inst._rgba = space.from( inst[ cache ] ); - } - } - }); - } - return this; - } - }, - is: function( compare ) { - var is = color( compare ), - same = true, - inst = this; - - each( spaces, function( _, space ) { - var localCache, - isCache = is[ space.cache ]; - if (isCache) { - localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; - each( space.props, function( _, prop ) { - if ( isCache[ prop.idx ] != null ) { - same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); - return same; - } - }); - } - return same; - }); - return same; - }, - _space: function() { - var used = [], - inst = this; - each( spaces, function( spaceName, space ) { - if ( inst[ space.cache ] ) { - used.push( spaceName ); - } - }); - return used.pop(); - }, - transition: function( other, distance ) { - var end = color( other ), - spaceName = end._space(), - space = spaces[ spaceName ], - startColor = this.alpha() === 0 ? color( "transparent" ) : this, - start = startColor[ space.cache ] || space.to( startColor._rgba ), - result = start.slice(); - - end = end[ space.cache ]; - each( space.props, function( key, prop ) { - var index = prop.idx, - startValue = start[ index ], - endValue = end[ index ], - type = propTypes[ prop.type ] || {}; - - // if null, don't override start value - if ( endValue === null ) { - return; - } - // if null - use end - if ( startValue === null ) { - result[ index ] = endValue; - } else { - if ( type.mod ) { - if ( endValue - startValue > type.mod / 2 ) { - startValue += type.mod; - } else if ( startValue - endValue > type.mod / 2 ) { - startValue -= type.mod; - } - } - result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); - } - }); - return this[ spaceName ]( result ); - }, - blend: function( opaque ) { - // if we are already opaque - return ourself - if ( this._rgba[ 3 ] === 1 ) { - return this; - } - - var rgb = this._rgba.slice(), - a = rgb.pop(), - blend = color( opaque )._rgba; - - return color( jQuery.map( rgb, function( v, i ) { - return ( 1 - a ) * blend[ i ] + a * v; - })); - }, - toRgbaString: function() { - var prefix = "rgba(", - rgba = jQuery.map( this._rgba, function( v, i ) { - return v == null ? ( i > 2 ? 1 : 0 ) : v; - }); - - if ( rgba[ 3 ] === 1 ) { - rgba.pop(); - prefix = "rgb("; - } - - return prefix + rgba.join() + ")"; - }, - toHslaString: function() { - var prefix = "hsla(", - hsla = jQuery.map( this.hsla(), function( v, i ) { - if ( v == null ) { - v = i > 2 ? 1 : 0; - } - - // catch 1 and 2 - if ( i && i < 3 ) { - v = Math.round( v * 100 ) + "%"; - } - return v; - }); - - if ( hsla[ 3 ] === 1 ) { - hsla.pop(); - prefix = "hsl("; - } - return prefix + hsla.join() + ")"; - }, - toHexString: function( includeAlpha ) { - var rgba = this._rgba.slice(), - alpha = rgba.pop(); - - if ( includeAlpha ) { - rgba.push( ~~( alpha * 255 ) ); - } - - return "#" + jQuery.map( rgba, function( v ) { - - // default to 0 when nulls exist - v = ( v || 0 ).toString( 16 ); - return v.length === 1 ? "0" + v : v; - }).join(""); - }, - toString: function() { - return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); - } -}); -color.fn.parse.prototype = color.fn; - -// hsla conversions adapted from: -// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 - -function hue2rgb( p, q, h ) { - h = ( h + 1 ) % 1; - if ( h * 6 < 1 ) { - return p + (q - p) * h * 6; - } - if ( h * 2 < 1) { - return q; - } - if ( h * 3 < 2 ) { - return p + (q - p) * ((2/3) - h) * 6; - } - return p; -} - -spaces.hsla.to = function ( rgba ) { - if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { - return [ null, null, null, rgba[ 3 ] ]; - } - var r = rgba[ 0 ] / 255, - g = rgba[ 1 ] / 255, - b = rgba[ 2 ] / 255, - a = rgba[ 3 ], - max = Math.max( r, g, b ), - min = Math.min( r, g, b ), - diff = max - min, - add = max + min, - l = add * 0.5, - h, s; - - if ( min === max ) { - h = 0; - } else if ( r === max ) { - h = ( 60 * ( g - b ) / diff ) + 360; - } else if ( g === max ) { - h = ( 60 * ( b - r ) / diff ) + 120; - } else { - h = ( 60 * ( r - g ) / diff ) + 240; - } - - if ( l === 0 || l === 1 ) { - s = l; - } else if ( l <= 0.5 ) { - s = diff / add; - } else { - s = diff / ( 2 - add ); - } - return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; -}; - -spaces.hsla.from = function ( hsla ) { - if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { - return [ null, null, null, hsla[ 3 ] ]; - } - var h = hsla[ 0 ] / 360, - s = hsla[ 1 ], - l = hsla[ 2 ], - a = hsla[ 3 ], - q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, - p = 2 * l - q; - - return [ - Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), - Math.round( hue2rgb( p, q, h ) * 255 ), - Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), - a - ]; -}; - - -each( spaces, function( spaceName, space ) { - var props = space.props, - cache = space.cache, - to = space.to, - from = space.from; - - // makes rgba() and hsla() - color.fn[ spaceName ] = function( value ) { - - // generate a cache for this space if it doesn't exist - if ( to && !this[ cache ] ) { - this[ cache ] = to( this._rgba ); - } - if ( value === undefined ) { - return this[ cache ].slice(); - } - - var ret, - type = jQuery.type( value ), - arr = ( type === "array" || type === "object" ) ? value : arguments, - local = this[ cache ].slice(); - - each( props, function( key, prop ) { - var val = arr[ type === "object" ? key : prop.idx ]; - if ( val == null ) { - val = local[ prop.idx ]; - } - local[ prop.idx ] = clamp( val, prop ); - }); - - if ( from ) { - ret = color( from( local ) ); - ret[ cache ] = local; - return ret; - } else { - return color( local ); - } - }; - - // makes red() green() blue() alpha() hue() saturation() lightness() - each( props, function( key, prop ) { - // alpha is included in more than one space - if ( color.fn[ key ] ) { - return; - } - color.fn[ key ] = function( value ) { - var vtype = jQuery.type( value ), - fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), - local = this[ fn ](), - cur = local[ prop.idx ], - match; - - if ( vtype === "undefined" ) { - return cur; - } - - if ( vtype === "function" ) { - value = value.call( this, cur ); - vtype = jQuery.type( value ); - } - if ( value == null && prop.empty ) { - return this; - } - if ( vtype === "string" ) { - match = rplusequals.exec( value ); - if ( match ) { - value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); - } - } - local[ prop.idx ] = value; - return this[ fn ]( local ); - }; - }); -}); - -// add .fx.step functions -each( stepHooks, function( i, hook ) { - jQuery.cssHooks[ hook ] = { - set: function( elem, value ) { - var parsed, curElem, - backgroundColor = ""; - - if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) { - value = color( parsed || value ); - if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { - curElem = hook === "backgroundColor" ? elem.parentNode : elem; - while ( - (backgroundColor === "" || backgroundColor === "transparent") && - curElem && curElem.style - ) { - try { - backgroundColor = jQuery.css( curElem, "backgroundColor" ); - curElem = curElem.parentNode; - } catch ( e ) { - } - } - - value = value.blend( backgroundColor && backgroundColor !== "transparent" ? - backgroundColor : - "_default" ); - } - - value = value.toRgbaString(); - } - try { - elem.style[ hook ] = value; - } catch( error ) { - // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' - } - } - }; - jQuery.fx.step[ hook ] = function( fx ) { - if ( !fx.colorInit ) { - fx.start = color( fx.elem, hook ); - fx.end = color( fx.end ); - fx.colorInit = true; - } - jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); - }; -}); - -jQuery.cssHooks.borderColor = { - expand: function( value ) { - var expanded = {}; - - each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { - expanded[ "border" + part + "Color" ] = value; - }); - return expanded; - } -}; - -// Basic color names only. -// Usage of any of the other color names requires adding yourself or including -// jquery.color.svg-names.js. -colors = jQuery.Color.names = { - // 4.1. Basic color keywords - aqua: "#00ffff", - black: "#000000", - blue: "#0000ff", - fuchsia: "#ff00ff", - gray: "#808080", - green: "#008000", - lime: "#00ff00", - maroon: "#800000", - navy: "#000080", - olive: "#808000", - purple: "#800080", - red: "#ff0000", - silver: "#c0c0c0", - teal: "#008080", - white: "#ffffff", - yellow: "#ffff00", - - // 4.2.3. "transparent" color keyword - transparent: [ null, null, null, 0 ], - - _default: "#ffffff" -}; - -})( jQuery ); - - - -/******************************************************************************/ -/****************************** CLASS ANIMATIONS ******************************/ -/******************************************************************************/ -(function() { - -var classAnimationActions = [ "add", "remove", "toggle" ], - shorthandStyles = { - border: 1, - borderBottom: 1, - borderColor: 1, - borderLeft: 1, - borderRight: 1, - borderTop: 1, - borderWidth: 1, - margin: 1, - padding: 1 - }; - -$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { - $.fx.step[ prop ] = function( fx ) { - if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { - jQuery.style( fx.elem, prop, fx.end ); - fx.setAttr = true; - } - }; -}); - -function getElementStyles() { - var style = this.ownerDocument.defaultView ? - this.ownerDocument.defaultView.getComputedStyle( this, null ) : - this.currentStyle, - newStyle = {}, - key, - len; - - // webkit enumerates style porperties - if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { - len = style.length; - while ( len-- ) { - key = style[ len ]; - if ( typeof style[ key ] === "string" ) { - newStyle[ $.camelCase( key ) ] = style[ key ]; - } - } - } else { - for ( key in style ) { - if ( typeof style[ key ] === "string" ) { - newStyle[ key ] = style[ key ]; - } - } - } - - return newStyle; -} - - -function styleDifference( oldStyle, newStyle ) { - var diff = {}, - name, value; - - for ( name in newStyle ) { - value = newStyle[ name ]; - if ( oldStyle[ name ] !== value ) { - if ( !shorthandStyles[ name ] ) { - if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { - diff[ name ] = value; - } - } - } - } - - return diff; -} - -$.effects.animateClass = function( value, duration, easing, callback ) { - var o = $.speed( duration, easing, callback ); - - return this.queue( function() { - var animated = $( this ), - baseClass = animated.attr( "class" ) || "", - applyClassChange, - allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; - - // map the animated objects to store the original styles. - allAnimations = allAnimations.map(function() { - var el = $( this ); - return { - el: el, - start: getElementStyles.call( this ) - }; - }); - - // apply class change - applyClassChange = function() { - $.each( classAnimationActions, function(i, action) { - if ( value[ action ] ) { - animated[ action + "Class" ]( value[ action ] ); - } - }); - }; - applyClassChange(); - - // map all animated objects again - calculate new styles and diff - allAnimations = allAnimations.map(function() { - this.end = getElementStyles.call( this.el[ 0 ] ); - this.diff = styleDifference( this.start, this.end ); - return this; - }); - - // apply original class - animated.attr( "class", baseClass ); - - // map all animated objects again - this time collecting a promise - allAnimations = allAnimations.map(function() { - var styleInfo = this, - dfd = $.Deferred(), - opts = jQuery.extend({}, o, { - queue: false, - complete: function() { - dfd.resolve( styleInfo ); - } - }); - - this.el.animate( this.diff, opts ); - return dfd.promise(); - }); - - // once all animations have completed: - $.when.apply( $, allAnimations.get() ).done(function() { - - // set the final class - applyClassChange(); - - // for each animated element, - // clear all css properties that were animated - $.each( arguments, function() { - var el = this.el; - $.each( this.diff, function(key) { - el.css( key, '' ); - }); - }); - - // this is guarnteed to be there if you use jQuery.speed() - // it also handles dequeuing the next anim... - o.complete.call( animated[ 0 ] ); - }); - }); -}; - -$.fn.extend({ - _addClass: $.fn.addClass, - addClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { add: classNames }, speed, easing, callback ) : - this._addClass( classNames ); - }, - - _removeClass: $.fn.removeClass, - removeClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { remove: classNames }, speed, easing, callback ) : - this._removeClass( classNames ); - }, - - _toggleClass: $.fn.toggleClass, - toggleClass: function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - // without speed parameter - return this._toggleClass( classNames, force ); - } else { - return $.effects.animateClass.call( this, - (force ? { add: classNames } : { remove: classNames }), - speed, easing, callback ); - } - } else { - // without force parameter - return $.effects.animateClass.call( this, - { toggle: classNames }, force, speed, easing ); - } - }, - - switchClass: function( remove, add, speed, easing, callback) { - return $.effects.animateClass.call( this, { - add: add, - remove: remove - }, speed, easing, callback ); - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EFFECTS **********************************/ -/******************************************************************************/ - -(function() { - -$.extend( $.effects, { - version: "1.9.2", - - // Saves a set of properties in a data storage - save: function( element, set ) { - for( var i=0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); - } - } - }, - - // Restores a set of previously saved properties from a data storage - restore: function( element, set ) { - var val, i; - for( i=0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - val = element.data( dataSpace + set[ i ] ); - // support: jQuery 1.6.2 - // http://bugs.jquery.com/ticket/9917 - // jQuery 1.6.2 incorrectly returns undefined for any falsy value. - // We can't differentiate between "" and 0 here, so we just assume - // empty string since it's likely to be a more common value... - if ( val === undefined ) { - val = ""; - } - element.css( set[ i ], val ); - } - } - }, - - setMode: function( el, mode ) { - if (mode === "toggle") { - mode = el.is( ":hidden" ) ? "show" : "hide"; - } - return mode; - }, - - // Translates a [top,left] array into a baseline value - // this should be a little more flexible in the future to handle a string & hash - getBaseline: function( origin, original ) { - var y, x; - switch ( origin[ 0 ] ) { - case "top": y = 0; break; - case "middle": y = 0.5; break; - case "bottom": y = 1; break; - default: y = origin[ 0 ] / original.height; - } - switch ( origin[ 1 ] ) { - case "left": x = 0; break; - case "center": x = 0.5; break; - case "right": x = 1; break; - default: x = origin[ 1 ] / original.width; - } - return { - x: x, - y: y - }; - }, - - // Wraps the element around a wrapper that copies position properties - createWrapper: function( element ) { - - // if the element is already wrapped, return it - if ( element.parent().is( ".ui-effects-wrapper" )) { - return element.parent(); - } - - // wrap the element - var props = { - width: element.outerWidth(true), - height: element.outerHeight(true), - "float": element.css( "float" ) - }, - wrapper = $( "

" ) - .addClass( "ui-effects-wrapper" ) - .css({ - fontSize: "100%", - background: "transparent", - border: "none", - margin: 0, - padding: 0 - }), - // Store the size in case width/height are defined in % - Fixes #5245 - size = { - width: element.width(), - height: element.height() - }, - active = document.activeElement; - - // support: Firefox - // Firefox incorrectly exposes anonymous content - // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 - try { - active.id; - } catch( e ) { - active = document.body; - } - - element.wrap( wrapper ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - - wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element - - // transfer positioning properties to the wrapper - if ( element.css( "position" ) === "static" ) { - wrapper.css({ position: "relative" }); - element.css({ position: "relative" }); - } else { - $.extend( props, { - position: element.css( "position" ), - zIndex: element.css( "z-index" ) - }); - $.each([ "top", "left", "bottom", "right" ], function(i, pos) { - props[ pos ] = element.css( pos ); - if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { - props[ pos ] = "auto"; - } - }); - element.css({ - position: "relative", - top: 0, - left: 0, - right: "auto", - bottom: "auto" - }); - } - element.css(size); - - return wrapper.css( props ).show(); - }, - - removeWrapper: function( element ) { - var active = document.activeElement; - - if ( element.parent().is( ".ui-effects-wrapper" ) ) { - element.parent().replaceWith( element ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - } - - - return element; - }, - - setTransition: function( element, list, factor, value ) { - value = value || {}; - $.each( list, function( i, x ) { - var unit = element.cssUnit( x ); - if ( unit[ 0 ] > 0 ) { - value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; - } - }); - return value; - } -}); - -// return an effect options object for the given parameters: -function _normalizeArguments( effect, options, speed, callback ) { - - // allow passing all options as the first parameter - if ( $.isPlainObject( effect ) ) { - options = effect; - effect = effect.effect; - } - - // convert to an object - effect = { effect: effect }; - - // catch (effect, null, ...) - if ( options == null ) { - options = {}; - } - - // catch (effect, callback) - if ( $.isFunction( options ) ) { - callback = options; - speed = null; - options = {}; - } - - // catch (effect, speed, ?) - if ( typeof options === "number" || $.fx.speeds[ options ] ) { - callback = speed; - speed = options; - options = {}; - } - - // catch (effect, options, callback) - if ( $.isFunction( speed ) ) { - callback = speed; - speed = null; - } - - // add options to effect - if ( options ) { - $.extend( effect, options ); - } - - speed = speed || options.duration; - effect.duration = $.fx.off ? 0 : - typeof speed === "number" ? speed : - speed in $.fx.speeds ? $.fx.speeds[ speed ] : - $.fx.speeds._default; - - effect.complete = callback || options.complete; - - return effect; -} - -function standardSpeed( speed ) { - // valid standard speeds - if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { - return true; - } - - // invalid strings - treat as "normal" speed - if ( typeof speed === "string" && !$.effects.effect[ speed ] ) { - // TODO: remove in 2.0 (#7115) - if ( backCompat && $.effects[ speed ] ) { - return false; - } - return true; - } - - return false; -} - -$.fn.extend({ - effect: function( /* effect, options, speed, callback */ ) { - var args = _normalizeArguments.apply( this, arguments ), - mode = args.mode, - queue = args.queue, - effectMethod = $.effects.effect[ args.effect ], - - // DEPRECATED: remove in 2.0 (#7115) - oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ]; - - if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) { - // delegate to the original method (e.g., .show()) if possible - if ( mode ) { - return this[ mode ]( args.duration, args.complete ); - } else { - return this.each( function() { - if ( args.complete ) { - args.complete.call( this ); - } - }); - } - } - - function run( next ) { - var elem = $( this ), - complete = args.complete, - mode = args.mode; - - function done() { - if ( $.isFunction( complete ) ) { - complete.call( elem[0] ); - } - if ( $.isFunction( next ) ) { - next(); - } - } - - // if the element is hiddden and mode is hide, - // or element is visible and mode is show - if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { - done(); - } else { - effectMethod.call( elem[0], args, done ); - } - } - - // TODO: remove this check in 2.0, effectMethod will always be true - if ( effectMethod ) { - return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); - } else { - // DEPRECATED: remove in 2.0 (#7115) - return oldEffectMethod.call(this, { - options: args, - duration: args.duration, - callback: args.complete, - mode: args.mode - }); - } - }, - - _show: $.fn.show, - show: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._show.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }, - - _hide: $.fn.hide, - hide: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._hide.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }, - - // jQuery core overloads toggle and creates _toggle - __toggle: $.fn.toggle, - toggle: function( speed ) { - if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { - return this.__toggle.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }, - - // helper functions - cssUnit: function(key) { - var style = this.css( key ), - val = []; - - $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { - if ( style.indexOf( unit ) > 0 ) { - val = [ parseFloat( style ), unit ]; - } - }); - return val; - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EASING ***********************************/ -/******************************************************************************/ - -(function() { - -// based on easing equations from Robert Penner (http://www.robertpenner.com/easing) - -var baseEasings = {}; - -$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { - baseEasings[ name ] = function( p ) { - return Math.pow( p, i + 2 ); - }; -}); - -$.extend( baseEasings, { - Sine: function ( p ) { - return 1 - Math.cos( p * Math.PI / 2 ); - }, - Circ: function ( p ) { - return 1 - Math.sqrt( 1 - p * p ); - }, - Elastic: function( p ) { - return p === 0 || p === 1 ? p : - -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); - }, - Back: function( p ) { - return p * p * ( 3 * p - 2 ); - }, - Bounce: function ( p ) { - var pow2, - bounce = 4; - - while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} - return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); - } -}); - -$.each( baseEasings, function( name, easeIn ) { - $.easing[ "easeIn" + name ] = easeIn; - $.easing[ "easeOut" + name ] = function( p ) { - return 1 - easeIn( 1 - p ); - }; - $.easing[ "easeInOut" + name ] = function( p ) { - return p < 0.5 ? - easeIn( p * 2 ) / 2 : - 1 - easeIn( p * -2 + 2 ) / 2; - }; -}); - -})(); - -})(jQuery)); -(function( $, undefined ) { - -var rvertical = /up|down|vertical/, - rpositivemotion = /up|left|vertical|horizontal/; - -$.effects.effect.blind = function( o, done ) { - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - direction = o.direction || "up", - vertical = rvertical.test( direction ), - ref = vertical ? "height" : "width", - ref2 = vertical ? "top" : "left", - motion = rpositivemotion.test( direction ), - animation = {}, - show = mode === "show", - wrapper, distance, margin; - - // if already wrapped, the wrapper's properties are my property. #6245 - if ( el.parent().is( ".ui-effects-wrapper" ) ) { - $.effects.save( el.parent(), props ); - } else { - $.effects.save( el, props ); - } - el.show(); - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - - distance = wrapper[ ref ](); - margin = parseFloat( wrapper.css( ref2 ) ) || 0; - - animation[ ref ] = show ? distance : 0; - if ( !motion ) { - el - .css( vertical ? "bottom" : "right", 0 ) - .css( vertical ? "top" : "left", "auto" ) - .css({ position: "absolute" }); - - animation[ ref2 ] = show ? margin : distance + margin; - } - - // start at 0 if we are showing - if ( show ) { - wrapper.css( ref, 0 ); - if ( ! motion ) { - wrapper.css( ref2, margin + distance ); - } - } - - // Animate - wrapper.animate( animation, { - duration: o.duration, - easing: o.easing, - queue: false, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.bounce = function( o, done ) { - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - - // defaults: - mode = $.effects.setMode( el, o.mode || "effect" ), - hide = mode === "hide", - show = mode === "show", - direction = o.direction || "up", - distance = o.distance, - times = o.times || 5, - - // number of internal animations - anims = times * 2 + ( show || hide ? 1 : 0 ), - speed = o.duration / anims, - easing = o.easing, - - // utility: - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ), - i, - upAnim, - downAnim, - - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - - // Avoid touching opacity to prevent clearType and PNG issues in IE - if ( show || hide ) { - props.push( "opacity" ); - } - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); // Create Wrapper - - // default distance for the BIGGEST bounce is the outer Distance / 3 - if ( !distance ) { - distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; - } - - if ( show ) { - downAnim = { opacity: 1 }; - downAnim[ ref ] = 0; - - // if we are showing, force opacity 0 and set the initial position - // then do the "first" animation - el.css( "opacity", 0 ) - .css( ref, motion ? -distance * 2 : distance * 2 ) - .animate( downAnim, speed, easing ); - } - - // start at the smallest distance if we are hiding - if ( hide ) { - distance = distance / Math.pow( 2, times - 1 ); - } - - downAnim = {}; - downAnim[ ref ] = 0; - // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here - for ( i = 0; i < times; i++ ) { - upAnim = {}; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - el.animate( upAnim, speed, easing ) - .animate( downAnim, speed, easing ); - - distance = hide ? distance * 2 : distance / 2; - } - - // Last Bounce when Hiding - if ( hide ) { - upAnim = { opacity: 0 }; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - el.animate( upAnim, speed, easing ); - } - - el.queue(function() { - if ( hide ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - el.dequeue(); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.clip = function( o, done ) { - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - direction = o.direction || "vertical", - vert = direction === "vertical", - size = vert ? "height" : "width", - position = vert ? "top" : "left", - animation = {}, - wrapper, animate, distance; - - // Save & Show - $.effects.save( el, props ); - el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - animate = ( el[0].tagName === "IMG" ) ? wrapper : el; - distance = animate[ size ](); - - // Shift - if ( show ) { - animate.css( size, 0 ); - animate.css( position, distance / 2 ); - } - - // Create Animation Object: - animation[ size ] = show ? distance : 0; - animation[ position ] = show ? 0 : distance / 2; - - // Animate - animate.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( !show ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.drop = function( o, done ) { - - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - direction = o.direction || "left", - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg", - animation = { - opacity: show ? 1 : 0 - }, - distance; - - // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - - distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2; - - if ( show ) { - el - .css( "opacity", 0 ) - .css( ref, motion === "pos" ? -distance : distance ); - } - - // Animation - animation[ ref ] = ( show ? - ( motion === "pos" ? "+=" : "-=" ) : - ( motion === "pos" ? "-=" : "+=" ) ) + - distance; - - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.explode = function( o, done ) { - - var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3, - cells = rows, - el = $( this ), - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - - // show and then visibility:hidden the element before calculating offset - offset = el.show().css( "visibility", "hidden" ).offset(), - - // width and height of a piece - width = Math.ceil( el.outerWidth() / cells ), - height = Math.ceil( el.outerHeight() / rows ), - pieces = [], - - // loop - i, j, left, top, mx, my; - - // children animate complete: - function childComplete() { - pieces.push( this ); - if ( pieces.length === rows * cells ) { - animComplete(); - } - } - - // clone the element for each row and cell. - for( i = 0; i < rows ; i++ ) { // ===> - top = offset.top + i * height; - my = i - ( rows - 1 ) / 2 ; - - for( j = 0; j < cells ; j++ ) { // ||| - left = offset.left + j * width; - mx = j - ( cells - 1 ) / 2 ; - - // Create a clone of the now hidden main element that will be absolute positioned - // within a wrapper div off the -left and -top equal to size of our pieces - el - .clone() - .appendTo( "body" ) - .wrap( "
" ) - .css({ - position: "absolute", - visibility: "visible", - left: -j * width, - top: -i * height - }) - - // select the wrapper - make it overflow: hidden and absolute positioned based on - // where the original was located +left and +top equal to the size of pieces - .parent() - .addClass( "ui-effects-explode" ) - .css({ - position: "absolute", - overflow: "hidden", - width: width, - height: height, - left: left + ( show ? mx * width : 0 ), - top: top + ( show ? my * height : 0 ), - opacity: show ? 0 : 1 - }).animate({ - left: left + ( show ? 0 : mx * width ), - top: top + ( show ? 0 : my * height ), - opacity: show ? 1 : 0 - }, o.duration || 500, o.easing, childComplete ); - } - } - - function animComplete() { - el.css({ - visibility: "visible" - }); - $( pieces ).remove(); - if ( !show ) { - el.hide(); - } - done(); - } -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.fade = function( o, done ) { - var el = $( this ), - mode = $.effects.setMode( el, o.mode || "toggle" ); - - el.animate({ - opacity: mode - }, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: done - }); -}; - -})( jQuery ); -(function( $, undefined ) { - -$.effects.effect.fold = function( o, done ) { - - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - hide = mode === "hide", - size = o.size || 15, - percent = /([0-9]+)%/.exec( size ), - horizFirst = !!o.horizFirst, - widthFirst = show !== horizFirst, - ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], - duration = o.duration / 2, - wrapper, distance, - animation1 = {}, - animation2 = {}; - - $.effects.save( el, props ); - el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - distance = widthFirst ? - [ wrapper.width(), wrapper.height() ] : - [ wrapper.height(), wrapper.width() ]; - - if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; - } - if ( show ) { - wrapper.css( horizFirst ? { - height: 0, - width: size - } : { - height: size, - width: 0 - }); - } - - // Animation - animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; - animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; - - // Animate - wrapper - .animate( animation1, duration, o.easing ) - .animate( animation2, duration, o.easing, function() { - if ( hide ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.highlight = function( o, done ) { - var elem = $( this ), - props = [ "backgroundImage", "backgroundColor", "opacity" ], - mode = $.effects.setMode( elem, o.mode || "show" ), - animation = { - backgroundColor: elem.css( "backgroundColor" ) - }; - - if (mode === "hide") { - animation.opacity = 0; - } - - $.effects.save( elem, props ); - - elem - .show() - .css({ - backgroundImage: "none", - backgroundColor: o.color || "#ffff99" - }) - .animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - elem.hide(); - } - $.effects.restore( elem, props ); - done(); - } - }); -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.pulsate = function( o, done ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "show" ), - show = mode === "show", - hide = mode === "hide", - showhide = ( show || mode === "hide" ), - - // showing or hiding leaves of the "last" animation - anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), - duration = o.duration / anims, - animateTo = 0, - queue = elem.queue(), - queuelen = queue.length, - i; - - if ( show || !elem.is(":visible")) { - elem.css( "opacity", 0 ).show(); - animateTo = 1; - } - - // anims - 1 opacity "toggles" - for ( i = 1; i < anims; i++ ) { - elem.animate({ - opacity: animateTo - }, duration, o.easing ); - animateTo = 1 - animateTo; - } - - elem.animate({ - opacity: animateTo - }, duration, o.easing); - - elem.queue(function() { - if ( hide ) { - elem.hide(); - } - done(); - }); - - // We just queued up "anims" animations, we need to put them next in the queue - if ( queuelen > 1 ) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - elem.dequeue(); -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.puff = function( o, done ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "hide" ), - hide = mode === "hide", - percent = parseInt( o.percent, 10 ) || 150, - factor = percent / 100, - original = { - height: elem.height(), - width: elem.width(), - outerHeight: elem.outerHeight(), - outerWidth: elem.outerWidth() - }; - - $.extend( o, { - effect: "scale", - queue: false, - fade: true, - mode: mode, - complete: done, - percent: hide ? percent : 100, - from: hide ? - original : - { - height: original.height * factor, - width: original.width * factor, - outerHeight: original.outerHeight * factor, - outerWidth: original.outerWidth * factor - } - }); - - elem.effect( o ); -}; - -$.effects.effect.scale = function( o, done ) { - - // Create element - var el = $( this ), - options = $.extend( true, {}, o ), - mode = $.effects.setMode( el, o.mode || "effect" ), - percent = parseInt( o.percent, 10 ) || - ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ), - direction = o.direction || "both", - origin = o.origin, - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() - }, - factor = { - y: direction !== "horizontal" ? (percent / 100) : 1, - x: direction !== "vertical" ? (percent / 100) : 1 - }; - - // We are going to pass this effect to the size effect: - options.effect = "size"; - options.queue = false; - options.complete = done; - - // Set default origin and restore for show/hide - if ( mode !== "effect" ) { - options.origin = origin || ["middle","center"]; - options.restore = true; - } - - options.from = o.from || ( mode === "show" ? { - height: 0, - width: 0, - outerHeight: 0, - outerWidth: 0 - } : original ); - options.to = { - height: original.height * factor.y, - width: original.width * factor.x, - outerHeight: original.outerHeight * factor.y, - outerWidth: original.outerWidth * factor.x - }; - - // Fade option to support puff - if ( options.fade ) { - if ( mode === "show" ) { - options.from.opacity = 0; - options.to.opacity = 1; - } - if ( mode === "hide" ) { - options.from.opacity = 1; - options.to.opacity = 0; - } - } - - // Animate - el.effect( options ); - -}; - -$.effects.effect.size = function( o, done ) { - - // Create element - var original, baseline, factor, - el = $( this ), - props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ], - - // Always restore - props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ], - - // Copy for children - props2 = [ "width", "height", "overflow" ], - cProps = [ "fontSize" ], - vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ], - hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ], - - // Set options - mode = $.effects.setMode( el, o.mode || "effect" ), - restore = o.restore || mode !== "effect", - scale = o.scale || "both", - origin = o.origin || [ "middle", "center" ], - position = el.css( "position" ), - props = restore ? props0 : props1, - zero = { - height: 0, - width: 0, - outerHeight: 0, - outerWidth: 0 - }; - - if ( mode === "show" ) { - el.show(); - } - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() - }; - - if ( o.mode === "toggle" && mode === "show" ) { - el.from = o.to || zero; - el.to = o.from || original; - } else { - el.from = o.from || ( mode === "show" ? zero : original ); - el.to = o.to || ( mode === "hide" ? zero : original ); - } - - // Set scaling factor - factor = { - from: { - y: el.from.height / original.height, - x: el.from.width / original.width - }, - to: { - y: el.to.height / original.height, - x: el.to.width / original.width - } - }; - - // Scale the css box - if ( scale === "box" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( vProps ); - el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - props = props.concat( hProps ); - el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); - el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); - } - } - - // Scale the content - if ( scale === "content" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( cProps ).concat( props2 ); - el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); - } - } - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - el.css( "overflow", "hidden" ).css( el.from ); - - // Adjust - if (origin) { // Calculate baseline shifts - baseline = $.effects.getBaseline( origin, original ); - el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; - el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; - el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; - el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; - } - el.css( el.from ); // set top & left - - // Animate - if ( scale === "content" || scale === "both" ) { // Scale the children - - // Add margins/font-size - vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); - hProps = hProps.concat([ "marginLeft", "marginRight" ]); - props2 = props0.concat(vProps).concat(hProps); - - el.find( "*[width]" ).each( function(){ - var child = $( this ), - c_original = { - height: child.height(), - width: child.width(), - outerHeight: child.outerHeight(), - outerWidth: child.outerWidth() - }; - if (restore) { - $.effects.save(child, props2); - } - - child.from = { - height: c_original.height * factor.from.y, - width: c_original.width * factor.from.x, - outerHeight: c_original.outerHeight * factor.from.y, - outerWidth: c_original.outerWidth * factor.from.x - }; - child.to = { - height: c_original.height * factor.to.y, - width: c_original.width * factor.to.x, - outerHeight: c_original.height * factor.to.y, - outerWidth: c_original.width * factor.to.x - }; - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); - child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); - child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); - } - - // Animate children - child.css( child.from ); - child.animate( child.to, o.duration, o.easing, function() { - - // Restore children - if ( restore ) { - $.effects.restore( child, props2 ); - } - }); - }); - } - - // Animate - el.animate( el.to, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( el.to.opacity === 0 ) { - el.css( "opacity", el.from.opacity ); - } - if( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - if ( !restore ) { - - // we need to calculate our new positioning based on the scaling - if ( position === "static" ) { - el.css({ - position: "relative", - top: el.to.top, - left: el.to.left - }); - } else { - $.each([ "top", "left" ], function( idx, pos ) { - el.css( pos, function( _, str ) { - var val = parseInt( str, 10 ), - toRef = idx ? el.to.left : el.to.top; - - // if original was "auto", recalculate the new value from wrapper - if ( str === "auto" ) { - return toRef + "px"; - } - - return val + toRef + "px"; - }); - }); - } - } - - $.effects.removeWrapper( el ); - done(); - } - }); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.shake = function( o, done ) { - - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "effect" ), - direction = o.direction || "left", - distance = o.distance || 20, - times = o.times || 3, - anims = times * 2 + 1, - speed = Math.round(o.duration/anims), - ref = (direction === "up" || direction === "down") ? "top" : "left", - positiveMotion = (direction === "up" || direction === "left"), - animation = {}, - animation1 = {}, - animation2 = {}, - i, - - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - - // Animation - animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; - animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; - animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; - - // Animate - el.animate( animation, speed, o.easing ); - - // Shakes - for ( i = 1; i < times; i++ ) { - el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing ); - } - el - .animate( animation1, speed, o.easing ) - .animate( animation, speed / 2, o.easing ) - .queue(function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - el.dequeue(); - -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.slide = function( o, done ) { - - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "width", "height" ], - mode = $.effects.setMode( el, o.mode || "show" ), - show = mode === "show", - direction = o.direction || "left", - ref = (direction === "up" || direction === "down") ? "top" : "left", - positiveMotion = (direction === "up" || direction === "left"), - distance, - animation = {}; - - // Adjust - $.effects.save( el, props ); - el.show(); - distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ); - - $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - - if ( show ) { - el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance ); - } - - // Animation - animation[ ref ] = ( show ? - ( positiveMotion ? "+=" : "-=") : - ( positiveMotion ? "-=" : "+=")) + - distance; - - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); -}; - -})(jQuery); -(function( $, undefined ) { - -$.effects.effect.transfer = function( o, done ) { - var elem = $( this ), - target = $( o.to ), - targetFixed = target.css( "position" ) === "fixed", - body = $("body"), - fixTop = targetFixed ? body.scrollTop() : 0, - fixLeft = targetFixed ? body.scrollLeft() : 0, - endPosition = target.offset(), - animation = { - top: endPosition.top - fixTop , - left: endPosition.left - fixLeft , - height: target.innerHeight(), - width: target.innerWidth() - }, - startPosition = elem.offset(), - transfer = $( '
' ) - .appendTo( document.body ) - .addClass( o.className ) - .css({ - top: startPosition.top - fixTop , - left: startPosition.left - fixLeft , - height: elem.innerHeight(), - width: elem.innerWidth(), - position: targetFixed ? "fixed" : "absolute" - }) - .animate( animation, o.duration, o.easing, function() { - transfer.remove(); - done(); - }); -}; - -})(jQuery); -(function( $, undefined ) { - -var mouseHandled = false; - -$.widget( "ui.menu", { - version: "1.9.2", - defaultElement: "