diff options
author | Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com> | 2018-05-14 17:19:51 -0400 |
---|---|---|
committer | Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com> | 2018-05-25 13:39:38 -0400 |
commit | 2845910b34682056c1949f82e39d9205a26554e9 (patch) | |
tree | 825474a899dc5783e6ea8c4aefd26b6d4c881dfd /ecomp-portal-BE-os | |
parent | 485296388748c1efb5737cf7ae9d4a8254681552 (diff) |
Bulk upload changes and music health check apis
Issue-ID: PORTAL-290, PORTAL-291
Bulk upload changes and music health check apis
Change-Id: I63d289d75420658ff4a14385a5106838fa8c32b2
Signed-off-by: Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os')
17 files changed, 89 insertions, 786 deletions
diff --git a/ecomp-portal-BE-os/README.md b/ecomp-portal-BE-os/README.md index 8cf6d975..682dbfce 100644 --- a/ecomp-portal-BE-os/README.md +++ b/ecomp-portal-BE-os/README.md @@ -15,7 +15,7 @@ https://www.eclipse.org/m2e-wtp/ ## Release Notes Version 2.2 -- [PORTAL-255] Scheduler Popup opens when page loads +- [PORTAL-255] Scheduler popup shows up automatically when users land on home page - [PORTAL-210] Music jar update - [PORTAL-179] wrong menu available to App Admin User - [PORTAL-207] Raise 4 % percentage (from 44 to 48) sonar code coverage for ONAP PORTAL @@ -31,7 +31,6 @@ Version 2.2 - [Portal-121] GUI controls overlapping on app onboarding dialog - [Portal-133] Replace ECOMP wording from contact us page with ONAP - [Portal-88] unable to deselect widget on Widget catalog page -- [Portal-88] Unable to deselect widget on Widget catalog page - [Portal-111] Centralized Role Management Task(Integration to AAF) - [PORTAL-157] OpenID connect conflicting with spring security - [Portal-174] missing DB statement in DML script(Users, Roles Page fix) @@ -40,9 +39,10 @@ Version 2.2 - [Portal-168] CVE-2015-0254 JSTL-Upgrade to 1.2.3+ - [Portal-155] Review security issues: portal - [Portal-19] Removed the ecomp keyword from the license text -- [Portal-241] To reteieve roles on Users page for sdk(external app) -- [Portal-220] Fix to delete a portal admin - [Portal-256] Fix to make the userRole dynamic on Users modal popup +- [Portal-241] To reteieve roles on Users page for sdk(external app) +- [Portal-220] Fix to delete a portal admin, removed the OS test case +- [Portal-248] Id value fix in in Add App Account Management modal - [Portal-211] High memory Usage by Portal, SDK, Cassandra Version 1.1.0 (Amsterdam), November 2017 diff --git a/ecomp-portal-BE-os/pom.xml b/ecomp-portal-BE-os/pom.xml index dc01eea2..ad4e86ee 100644 --- a/ecomp-portal-BE-os/pom.xml +++ b/ecomp-portal-BE-os/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal</groupId> <artifactId>onap-portal-parent</artifactId> - <version>2.2.0</version> + <version>2.3.0</version> </parent> <artifactId>portal-be-os</artifactId> @@ -660,6 +660,24 @@ <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-music</artifactId> <version>${epsdk.version}</version> + + <exclusions> + <exclusion> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-server</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-json</artifactId> + </exclusion><exclusion> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-servlet</artifactId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java index d85a07b7..ee53eba0 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java @@ -74,7 +74,6 @@ import org.onap.portalapp.portal.service.ExternalAccessRolesService; import org.onap.portalapp.portal.service.UserRolesService; import org.onap.portalapp.portal.transport.ExternalAuthUserRole; import org.onap.portalapp.portal.transport.ExternalRoleDescription; -import org.onap.portalapp.portal.ueb.EPUebHelper; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EPSystemProperties; import org.onap.portalapp.scheduler.RegistryAdapter; @@ -286,7 +285,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable { registry.addInterceptor(sessionTimeoutInterceptor()).excludePathPatterns("/oid-login", "/portalApi/healthCheck", "/portalApi/healthCheck/", "/portalApi/healthCheckSuspend", "/portalApi/healthCheckSuspend/", "/portalApi/healthCheckResume", "/portalApi/healthCheckResume/", "/login_external", - "/login_external.htm*", "login", "/login.htm*", "/auxapi/*", "/context/*", "/api*", + "/login_external.htm*", "login", "/login.htm*", "/auxapi/**/*", "/context/*", "/api*", "/single_signon.htm", "/single_signon", "/dashboard", "/OpenSourceLogin.htm"); registry.addInterceptor(portalResourceInterceptor()); @@ -300,11 +299,11 @@ public class ExternalAppConfig extends AppConfig implements Configurable { * @return New instance of {@link SchedulerFactoryBean} */ - @Bean +/* @Bean public EPUebHelper epUebHelper() { return new EPUebHelper(); } - +*/ @Bean public HealthMonitor healthMonitor() { return new HealthMonitor(); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ONAPWelcomeController.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ONAPWelcomeController.java index 13ea316c..26564a04 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ONAPWelcomeController.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ONAPWelcomeController.java @@ -80,6 +80,7 @@ public class ONAPWelcomeController extends EPRestrictedBaseController{ this.viewName = viewName; } + // TODO Need to revisit this as its conflicting with Spring Security; check web.xml's oid-context.xml config //@Resource(name = "namedAdmins") private Set<SubjectIssuerGrantedAuthority> admins; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/PeerBroadcastSocket.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/PeerBroadcastSocket.java index 8f7ffc65..efad3c68 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/PeerBroadcastSocket.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/PeerBroadcastSocket.java @@ -82,12 +82,12 @@ public class PeerBroadcastSocket { if (to == null) return; Object toSessionObj = channelMap.get(to); - if (toSessionObj != null) { + /*if (toSessionObj != null) { Session toSession = null; toSession = (Session) toSessionObj; toSession.getBasicRemote().sendText(message); } - +*/ } catch (Exception ex) { logger.error(EELFLoggerDelegate.errorLogger, "Failed to send text" + ex.getMessage()); } diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/ueb/EPUebMsgTypes.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulVersionController.java index 2b7f11d5..d8a7adf1 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/ueb/EPUebMsgTypes.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulVersionController.java @@ -33,13 +33,38 @@ * * ============LICENSE_END============================================ * - * */ -package org.onap.portalapp.portal.ueb; +package org.onap.portalapp.portal.controller; -import org.onap.portalsdk.core.onboarding.ueb.UebMsgTypes; +import java.util.List; -public interface EPUebMsgTypes extends UebMsgTypes { +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; - public static final String UEB_MSG_TYPE_HEALTH_CHECK = "uebHealthCheckPing"; +import org.onap.portalapp.annotation.ApiVersion; +import org.onap.portalapp.portal.logging.aop.EPAuditLog; +import org.onap.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; +import org.onap.portalapp.portal.transport.FunctionalMenuItem; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +@ApiVersion +public class ExternalAppsRestfulVersionController { + + @Autowired + ExternalAppsRestfulController externalAppsRestfulController; + + @ApiVersion(max = "v3", service = "/v3/getFavorites", min = 0, method = "GET") + public List<FavoritesFunctionalMenuItemJson> getFavoritesForUser(HttpServletRequest request, + HttpServletResponse response) throws Exception { + return externalAppsRestfulController.getFavoritesForUser(request, response); + } + + @ApiVersion(max = "v3", service = "/v3/functionalMenuItemsForUser", min = 0, method = "GET") + public List<FunctionalMenuItem> getFunctionalMenuItemsForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { + return externalAppsRestfulController.getFunctionalMenuItemsForUser(request, response); + } } diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/EPAppServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/EPAppServiceImpl.java index ce10a7c6..c2385085 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/EPAppServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/EPAppServiceImpl.java @@ -100,74 +100,7 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer return userApps; } - @Override - protected void updateRestrictedApp(Long appId, OnboardingApp onboardingApp, FieldsValidator fieldsValidator, - EPUser user) { - 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(); - /* - * In the parent class, the UEB code is responsible for generating the - * keys/secret/mailbox but UEB Messaging is not actually being used currently; - * may be used in future at which point we can just remove this method and - * depend on parent class's method So, using UUID generator to generate the - * unique key instead. - */ - String uuidStr = UUID.randomUUID().toString(); - String appKey = uuidStr; - String appSecret = uuidStr; - String appMailboxName = "ECOMP-PORTAL-OUTBOX"; - onboardingApp.setUebTopicName(appMailboxName); - onboardingApp.setUebKey(appKey); - onboardingApp.setUebSecret(appSecret); - } 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, - "updateRestrictedApp: about to call createAppFromOnboarding"); - createAppFromOnboarding(app, onboardingApp, localSession); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling createAppFromOnboarding"); - localSession.saveOrUpdate(app); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling localSession.saveOrUpdate"); - // Enable or disable all menu items associated with this app - setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling setFunctionalMenuItemsEnabled"); - transaction.commit(); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling transaction.commit"); - result = true; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "updateRestrictedApp failed", e); - EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e); - EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); - EcompPortalUtils.rollbackTransaction(transaction, - "updateRestrictedApp rollback, exception = " + e.toString()); - } finally { - EcompPortalUtils.closeLocalSession(localSession, "updateRestrictedApp"); - } - if (!result) { - fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - } - } @Override public CambriaTopicManager getTopicManager(List<String> urlList, String key, String secret) diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java index 82be074e..34515705 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java @@ -48,10 +48,8 @@ import java.util.List; import org.json.JSONArray; import org.json.JSONObject; import org.onap.portalapp.portal.domain.EPUser; -import org.onap.portalapp.portal.service.UserService; -import org.onap.portalapp.portal.service.UserServiceImpl; import org.onap.portalapp.portal.utils.EPSystemProperties; -import org.onap.portalsdk.core.FusionObject.Utilities; +import org.onap.portalsdk.core.domain.FusionObject.Utilities; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.service.DataAccessService; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/ueb/EPUebHelper.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/ueb/EPUebHelper.java deleted file mode 100644 index fd7aca2c..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/ueb/EPUebHelper.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.portal.ueb; - -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.portal.domain.EcompApp; -import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; -import org.onap.portalapp.portal.logging.logic.EPLogUtil; -import org.onap.portalapp.portal.service.EPAppService; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.ueb.Helper; -import org.onap.portalsdk.core.onboarding.ueb.Publisher; -import org.onap.portalsdk.core.onboarding.ueb.UebException; -import org.onap.portalsdk.core.onboarding.ueb.UebManager; -import org.onap.portalsdk.core.onboarding.ueb.UebMsg; -import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; -import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@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 ONAP 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<EcompApp> 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(EPAppMessagesEnum.BeUebSystemError, "add/remove Publisher"); - logger.error(EELFLoggerDelegate.errorLogger, "refreshPublisherList failed", 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(EPAppMessagesEnum.BeUebConnectionError, e.getMessage()); - logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e); - } - - 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) { - logger.error(EELFLoggerDelegate.errorLogger, "addPublisher failed", e); - } - } - - public boolean checkAvailability() { - - // - // Test existence of topic at UEB url - // - // - // - boolean available = true; - LinkedList<String> urlList = (LinkedList<String>) Helper.uebUrlList(); - if (!urlList.isEmpty()) { - String url = "http://" + urlList.getFirst() + ":3904/topics/" - + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME); - if (!url.isEmpty()) { - try { - URL siteURL = new URL(url); - HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection(); - connection.setRequestMethod("GET"); - connection.connect(); - - int code = connection.getResponseCode(); - if (code == 200) { - available = true; - } else { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, url); - available = false; - logger.warn(EELFLoggerDelegate.errorLogger, - "Warning! UEB topic existence check failed, topic = " + url); - logger.debug(EELFLoggerDelegate.debugLogger, - "Warning! UEB topic existence check failed, topic = " + url); - } - } catch (Exception e) { - available = false; - logger.error(EELFLoggerDelegate.errorLogger, "checkAvailability failed", e); - } - } - } - return available; - } - - public boolean MessageCanBeSentToTopic() { - - boolean sentMsgSuccessfully = false; - - UebMsg msg = new UebMsg(); - msg.putSourceTopicName(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); - msg.putPayload("Pinging topic for health check"); - msg.putMsgType(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK); - - try { - // epPublisher.send(msg); - sentMsgSuccessfully = true; - } catch (Exception e) { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeHealthCheckUebClusterError); - sentMsgSuccessfully = false; - logger.warn(EELFLoggerDelegate.errorLogger, "Warning! could not successfully publish a UEB msg to " - + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME), e); - } - - return sentMsgSuccessfully; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/FunctionalMenuHandler.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/FunctionalMenuHandler.java deleted file mode 100644 index e7341b26..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/FunctionalMenuHandler.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.uebhandler; - -import java.util.List; - -import org.onap.portalapp.portal.domain.EPUser; -import org.onap.portalapp.portal.logging.aop.EPAuditLog; -import org.onap.portalapp.portal.service.AdminRolesService; -import org.onap.portalapp.portal.service.FunctionalMenuService; -import org.onap.portalapp.portal.service.SearchService; -import org.onap.portalapp.portal.transport.FunctionalMenuItem; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.ueb.UebException; -import org.onap.portalsdk.core.onboarding.ueb.UebManager; -import org.onap.portalsdk.core.onboarding.ueb.UebMsg; -import org.onap.portalsdk.core.service.DataAccessService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import com.google.gson.Gson; - -@Component -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPAuditLog -public class FunctionalMenuHandler { - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuHandler.class); - - @Autowired - private AdminRolesService adminRolesService; - - @Autowired - private FunctionalMenuService functionalMenuService; - - @Autowired - private SearchService searchSvc; - - @Async - public Boolean getFunctionalMenu(UebMsg requestMsg) { - UebMsg returnMsg = new UebMsg(); - - if (requestMsg == null) { - logger.error(EELFLoggerDelegate.errorLogger, "handleMenuRequest received null message"); - return false; - } else if (requestMsg.getSourceTopicName() == null) { - logger.error(EELFLoggerDelegate.errorLogger, - "A source topic name is required and not found in this msg:" + requestMsg.toString()); - return false; - } else if (requestMsg.getUserId() == null) { - logger.debug(EELFLoggerDelegate.debugLogger, - "Error getting functional menu. A userId is required and not found in this msg: " - + requestMsg.toString()); - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response - returnMsg.putPayload("Error: A userId is required. Call msg.putUserId() with an userId"); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, - "Getting functional menu for user = " + requestMsg.getUserId()); - EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId()); - - List<FunctionalMenuItem> menuItems = null; - if (user == null) { - logger.debug(EELFLoggerDelegate.debugLogger, - "Error getting functional menu. userId not found in directory or is guest: " - + requestMsg.toString()); - } else if (adminRolesService.isSuperAdmin(user)) { - logger.debug(EELFLoggerDelegate.debugLogger, - "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()"); - menuItems = functionalMenuService.getFunctionalMenuItems(); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, - "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()"); - menuItems = functionalMenuService.getFunctionalMenuItemsForUser(requestMsg.getUserId()); - } - - if (menuItems != null) { - String functionalMenuJsonString = new Gson().toJson(menuItems); - logger.debug(EELFLoggerDelegate.debugLogger, "returning functional menu : " + functionalMenuJsonString); - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response - returnMsg.putPayload(functionalMenuJsonString); - } else { - returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response - returnMsg.putPayload("Error: Not found for userId = " + requestMsg.getUserId()); - } - } - - try { - UebManager.getInstance().publishReplyEP(returnMsg, requestMsg.getSourceTopicName()); - } catch (UebException e) { - logger.error(EELFLoggerDelegate.errorLogger, - "getFunctionalMenu failed to publish reply", e); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, - "getFunctionalMenu failed", e); - } - - return true; - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/InitUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/InitUebHandler.java deleted file mode 100644 index 0343bdd0..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/InitUebHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.uebhandler; - -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.ueb.UebManager; -import org.onap.portalsdk.core.onboarding.ueb.UebMsg; -import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; -import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; - -// -// Adding this class for the sole purpose of insuring that the MainUebHandler really -// honors @Async and kicks off a thread. For more info google @Async and read about -// @Async only working if called from different class. -// -//@Configuration -//@EnableAspectJAutoProxy -//@EPMetricsLog -public class InitUebHandler { - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class); - - // @Autowired - private MainUebHandler mainUebHandler; - - public InitUebHandler() { - - } - - // @PostConstruct - public void initUeb() { - try { - String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE); - if (enableListenerThread.equalsIgnoreCase("true")) { - ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>(); - UebManager.getInstance().initListener(inboxQueue); - mainUebHandler.runHandler(inboxQueue); - logger.info(EELFLoggerDelegate.errorLogger, "Returned from initiating mainUebHandler..."); - } else { - logger.info(EELFLoggerDelegate.errorLogger, - "Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file."); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e); - logger.info(EELFLoggerDelegate.errorLogger, - "Not starting UEB listening thread because property could not be read " - + PortalApiConstants.UEB_LISTENERS_ENABLE + e.getMessage()); - } - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/MainUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/MainUebHandler.java deleted file mode 100644 index 6a5b8574..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/MainUebHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.uebhandler; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.onap.portalapp.portal.ueb.EPUebMsgTypes; -import org.onap.portalapp.portal.utils.EPSystemProperties; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.ueb.UebMsg; -import org.onap.portalsdk.core.onboarding.ueb.UebMsgTypes; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import com.att.eelf.configuration.Configuration; - -//------------------------------------------------------------------------- -// Listens for received UEB messages and handles the messages -// -// Note: To implement a synchronous reply call getMsgId on the request -// and putMsgId on the reply (echoing the request MsgId). -// -//------------------------------------------------------------------------- -@Component("MainUebHandler") -public class MainUebHandler { - final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class); - - private ConcurrentLinkedQueue<UebMsg> inboxQueue = null; - - @Autowired - private FunctionalMenuHandler funcMenuHandler; - - @Autowired - private WidgetNotificationHandler widgetNotificationHandler; - - @Async - public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) { - inboxQueue = queue; - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "==> MainUebHandler started"); - while (true) { - UebMsg msg = null; - while ((msg = inboxQueue.poll()) != null) { - if ((msg.getMsgType() != null) - && (!msg.getMsgType().equalsIgnoreCase(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK))) { - // TODO: switch this back to debug - logger.info(EELFLoggerDelegate.errorLogger, - dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); - logger.info(EELFLoggerDelegate.debugLogger, - dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString()); - MDC.put(EPSystemProperties.PARTNER_NAME, msg.getSourceTopicName()); - MDC.put(Configuration.MDC_SERVICE_NAME, msg.getMsgType().toString()); - switch (msg.getMsgType()) { - case UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU: { - funcMenuHandler.getFunctionalMenu(msg); - break; - } - case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: { - widgetNotificationHandler.handleWidgetNotification(msg); - break; - } - default: { - logger.info(EELFLoggerDelegate.debugLogger, - dateFormat.format(new Date()) + "Unknown UEB message type " + msg.toString()); - break; - } - } - } - } - - if (Thread.interrupted()) { - logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting"); - break; - } - - try { - Thread.sleep(10); - } catch (InterruptedException e) { - logger.error(EELFLoggerDelegate.errorLogger, "runHandler interrupted during sleep", e); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "runHandler failed", e); - } - } - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/WidgetNotificationHandler.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/WidgetNotificationHandler.java deleted file mode 100644 index eb821d43..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/uebhandler/WidgetNotificationHandler.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.uebhandler; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.portal.domain.EPUser; -import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.service.EPAppService; -import org.onap.portalapp.portal.service.SearchService; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.ueb.UebException; -import org.onap.portalsdk.core.onboarding.ueb.UebManager; -import org.onap.portalsdk.core.onboarding.ueb.UebMsg; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -@Component -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class WidgetNotificationHandler { - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetNotificationHandler.class); - - final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - - @Autowired - EPAppService appSvc; - - @Autowired - SearchService searchSvc; - - public WidgetNotificationHandler() { - } - - @Async - public void handleWidgetNotification(UebMsg requestMsg) { - if (requestMsg.getUserId() != null) { - logger.debug(EELFLoggerDelegate.debugLogger, - "handleWidgetNotification: getting widgets/apps for user = " + requestMsg.getUserId()); - EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId()); - if (user != null && (appSvc != null)) { - logger.debug(EELFLoggerDelegate.debugLogger, "Debug mytag: " + appSvc); - List<EPApp> apps = appSvc.getUserApps(user); - for (EPApp app : apps) { - if (app.getUebTopicName() != null) { - UebMsg widgetMsg = new UebMsg(); - widgetMsg.putSourceTopicName(app.getUebTopicName()); - logger.debug(EELFLoggerDelegate.debugLogger, "app.getUebTopicName was invoked"); - widgetMsg.putPayload(requestMsg.getPayload()); - try { - logger.debug(EELFLoggerDelegate.debugLogger, "Sending widget notification from " - + requestMsg.getSourceTopicName() + " to " + app.getUebTopicName()); - UebManager.getInstance().publishEP(widgetMsg, app.getUebTopicName()); - } catch (UebException e) { - logger.error(EELFLoggerDelegate.errorLogger, "handleWidgetNotification failed", e); - } - } - } - } else { - logger.error(EELFLoggerDelegate.errorLogger, - dateFormat.format(new Date()) + "handleWidgetNotification: user " + requestMsg.getUserId() - + " not found" + " source = " + requestMsg.getSourceTopicName() - + ". This widget notification cannot be posted to other widgets"); - } - } - } - -} diff --git a/ecomp-portal-BE-os/src/main/resources/music.properties b/ecomp-portal-BE-os/src/main/resources/music.properties index 22d0a02d..fdf6e499 100644 --- a/ecomp-portal-BE-os/src/main/resources/music.properties +++ b/ecomp-portal-BE-os/src/main/resources/music.properties @@ -1,27 +1,30 @@ -music.endpoint = http://vm-ep-dev4.research.att.com/MUSIC/rest/ -music.version = v2 -music.keyspace = keyspaces music.session.keyspace = test_session -music.tables = tables music.session.attr.tables = spring_session_attributes music.session.meta.tables = spring_session -music.rows = rows -music.sesion.rows = -music.x.minor.version = 3 -music.x.patch.version = 0 -music.aid = -music.ns = com.att.ecomp.portal.demeter -music.user.id = m00468@portal.ecomp.att.com -music.password = friedG33nS- -music.consistency.info = type -music.consistency.info.value = eventual -music.cache = false +#music.cache = false +music.serialize.compress = true music.session.max.inactive.interval.seconds = 1800 +music.exclude.api = /portalApi/healthCheck,/portalApi/healthCheckSuspend,/portalApi/healthCheckResume #By default it's eventual -music.atomic.get = false -music.atomic.put = true - +music.atomic.get = false +music.atomic.put = false +#how often the session clean up would happen (hour) +music.cleanup.frequency = 6 +#how old of session need to be cleaned up (hour) +music.cleanup.threshold = 10 cassandra.host=135.197.226.103 -zookeeper.host=135.197.226.103 +zookeeper.host=135.197.226.103, 135.197.226.108, 135.197.226.119 cassandra.user=cassandra -cassandra.password=cassandra
\ No newline at end of file +cassandra.password=cassandra + +#Music API +#music.endpoint = http://vm-ep-dev4.research.att.com/MUSIC/rest/ +#music.version = v2 +#music.keyspace = keyspaces +#music.x.minor.version = 3 +#music.x.patch.version = 0 +#music.ns = com.att.ecomp.portal.demeter +#music.user.id = m00468@portal.ecomp.att.com +#music.password = friedG33nS- +#music.consistency.info = type +#music.consistency.info.value = eventual
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties index 64974c55..67d93285 100644 --- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties +++ b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties @@ -122,6 +122,8 @@ online_user_update_duration = 900 # User notification refresh interval and duration, in seconds notification_update_rate = 90 notification_update_duration = 900 +#Widgets upload flag +microservices.widget.upload.flag=true #Microservices Related Properties for Portal microservices.widget.username = widget_user diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/web.xml b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/web.xml index 58d52706..6984cc91 100644 --- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/web.xml +++ b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/web.xml @@ -71,7 +71,7 @@ </listener> <filter> <filter-name>springSessionRepositoryFilter</filter-name> - <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> + <filter-class>org.onap.portalapp.music.filter.MusicSessionRepositoryFilter</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> diff --git a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/controller/LoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/controller/LoginControllerTest.java index 4af05344..f7c9ce35 100644 --- a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/controller/LoginControllerTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/controller/LoginControllerTest.java @@ -114,6 +114,7 @@ public class LoginControllerTest { HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); NullPointerException nullPointerException = new NullPointerException(); + private DelegatingServletInputStream dsi; @Test public void loginIfAuthNullTest() { @@ -151,8 +152,8 @@ public class LoginControllerTest { HttpServletResponse response = mock(HttpServletResponse.class); HttpSession session = mock(HttpSession.class); String json = "{\"loginId\":\"test\", \"password\":\"xyz\"}"; - when(request.getInputStream()).thenReturn( - new DelegatingServletInputStream(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)))); + dsi = new DelegatingServletInputStream(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))); + when(request.getInputStream()).thenReturn(dsi); when(request.getReader()).thenReturn(new BufferedReader(new StringReader(json))); when(request.getContentType()).thenReturn("application/json"); when(request.getCharacterEncoding()).thenReturn("UTF-8"); |