From 39a2ffd9ccd28539ec00e7fc16c7c9c051b1809a Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Tue, 1 Aug 2017 14:04:04 -0400 Subject: Repair ONAP portal release problems - Remove duplicate & buggy code blocking widget authentication - Set UEB URL list property to ueb.api.simpledemo.openecomp.org - Refactor to generate app key without using UEB - Abbreviate WMS connection string to drop "&timeout=2000" Issue: PORTAL-30, PORTAL-37, PORTAL-48 Change-Id: I5ff5844aba05781e2c5a2d833403e821e355811c Signed-off-by: Christopher Lott (cl778h) --- ecomp-portal-BE-os/README.md | 4 +- .../portalapp/portal/service/EPAppServiceImpl.java | 78 ++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) (limited to 'ecomp-portal-BE-os') diff --git a/ecomp-portal-BE-os/README.md b/ecomp-portal-BE-os/README.md index be584cba..89621049 100644 --- a/ecomp-portal-BE-os/README.md +++ b/ecomp-portal-BE-os/README.md @@ -19,7 +19,9 @@ Version 1.1.?, July 2017 - [Portal-35] Replaced the portal logo with onap logo on the login screen. - [Portal-40] Fix to add user roles - [Portal-47] Fix to eliminate duplicate roles on Users page -- [Portal-45] Fix to save on an application Onboarding +- [Portal-45] Fix to update an existing app on Application Onboarding +- [Portal-48] Fix to save a new app on Application onboarding + Version 1.1.0, July 2017 - [Portal-7] Improvements added as part of the rebasing process diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java index 1f829380..41e51be6 100644 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java @@ -25,9 +25,20 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.TreeSet; +import java.util.UUID; +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.Session; +import org.hibernate.Transaction; import org.openecomp.portalapp.portal.domain.EPApp; +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.portal.transport.FieldsValidator; +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.service.DataAccessService; import org.springframework.beans.factory.annotation.Autowired; @@ -47,6 +58,8 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppServiceImpl.class); + private static Object syncRests = new Object(); + @Autowired private DataAccessService dataAccessService; @@ -74,6 +87,71 @@ public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppSer } + 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, "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"); + 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); + } + } + + } + public CambriaTopicManager getTopicManager(LinkedList urlList, String key, String secret) throws GeneralSecurityException, Exception{ return CambriaClientFactory.createTopicManager( null, urlList, key, secret); } -- cgit 1.2.3-korg