diff options
author | 2017-08-01 14:04:04 -0400 | |
---|---|---|
committer | 2017-08-01 15:25:38 -0400 | |
commit | 39a2ffd9ccd28539ec00e7fc16c7c9c051b1809a (patch) | |
tree | e21eef7629012a51c8a82443a39ae1a9f85e9847 /ecomp-portal-BE-os/src/main/java/org/openecomp | |
parent | 47e5623c1392c5b7e6471aec782509079e968d96 (diff) |
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) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os/src/main/java/org/openecomp')
-rw-r--r-- | ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java | 78 |
1 files changed, 78 insertions, 0 deletions
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<String> urlList, String key, String secret) throws GeneralSecurityException, Exception{ return CambriaClientFactory.createTopicManager( null, urlList, key, secret); } |