Dynamic context determination via basehref 89/110289/2
authorstatta <statta@research.att.com>
Thu, 16 Jul 2020 18:23:01 +0000 (14:23 -0400)
committerstatta <statta@research.att.com>
Wed, 29 Jul 2020 21:59:37 +0000 (17:59 -0400)
Issue-ID: PORTAL-949
Change-Id: Ia30876f51edd4a48633769c5a01f3646ca7fb9b2
Signed-off-by: statta <statta@research.att.com>
ecomp-sdk/epsdk-app-os/ngappsrc/angular.json
ecomp-sdk/epsdk-app-os/ngappsrc/src/ngwelcome.html
ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java

index 02ce945..64b1351 100644 (file)
@@ -12,7 +12,6 @@
         "build": {
           "builder": "@angular-devkit/build-angular:browser",
           "options": {
-            "baseHref": "/ONAPPORTALSDK/",
             "outputPath": "dist",
             "index": "src/ngwelcome.html",
             "main": "src/main.ts",
index d290b96..b85e25d 100644 (file)
  <!doctype html>
 <html lang="en">
 <head>
+
+<script>
+        __Zone_enable_cross_context_check = true;
+        function nthIndex(str, pat, n) {
+          var L = str.length, i = -1;
+          while (n-- && i++ < L) {
+            i = str.indexOf(pat, i);
+            if (i < 0) break;
+          }
+          return i;
+        }
+        function addBaseHref(base) {
+          //document.write("<base href='" + base + "' />");
+          baseNode=document.createElement('base');
+          baseNode.href=base;
+
+          //document.getElementsByTagName('head')[0].appendChild(baseNode);
+          var head = document.getElementsByTagName('head')[0];
+          head.insertBefore(baseNode,head.childNodes[0] || null);
+          window.base = base;
+        }
+       
+          var base = window.location.pathname.substring(0, nthIndex(window.location.pathname,"/", 2) + 1);
+          addBaseHref(base);
+
+        
+      </script>
   <meta charset="utf-8">
   <title>Portal SDK</title>
-  <base href="/">
 
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="icon" type="image/x-icon" href="favicon.ico">
index 1b3c79c..90c39b5 100644 (file)
@@ -84,7 +84,8 @@ public class PortalTimeoutHandler {
                        String sessionSlot = SessionCommunicationService.getSessionSlotCheckInterval(ecompRestURL, userName, pwd,
                                        uebKey);
                        if (sessionSlot == null)
-                               return null;
+                               sessionSlot = "30000"; // default to 5 minutes
+                       
                        return Integer.parseInt(sessionSlot);
                }
 
@@ -341,18 +342,19 @@ public class PortalTimeoutHandler {
 
                Object portalSessionSlotCheckObj = session.getServletContext()
                                .getAttribute(PortalApiConstants.PORTAL_SESSION_SLOT_CHECK);
-               Integer portalSessionSlotCheckinMilliSec = 5 * 60 * 1000; // (5 minutes)
+               Integer portalSessionSlotCheckinMilliSec = 0;
                if (portalSessionSlotCheckObj != null) {
                        portalSessionSlotCheckinMilliSec = Integer.valueOf(portalSessionSlotCheckObj.toString());
                } else {
                        portalSessionSlotCheckObj = _sessionComm
                                        .fetchSessionSlotCheckInterval(new String[] { ecompRestURL, userName, pwd, uebKey });
-                       logger.debug("Fetching Portal Session Slot Object: " + portalSessionSlotCheckObj);
+                       logger.debug("Fetched Portal Session Slot Object: " + portalSessionSlotCheckObj);
+
                        if (portalSessionSlotCheckObj != null) {
                                portalSessionSlotCheckinMilliSec = Integer.valueOf(portalSessionSlotCheckObj.toString());
                                session.getServletContext().setAttribute(PortalApiConstants.PORTAL_SESSION_SLOT_CHECK,
                                                portalSessionSlotCheckinMilliSec);
-                       }
+                       } 
                }
 
                Object previousToLastAccessTimeObj = session.getAttribute(PortalApiConstants.SESSION_PREVIOUS_ACCESS_TIME);