Update license; improve coverage; add docs dir
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / listener / UserSessionListener.java
index ebab2aa..a009356 100644 (file)
@@ -1,21 +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.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 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
- * 
+ *
+ *             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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
 package org.openecomp.portalapp.portal.listener;
@@ -29,16 +47,14 @@ 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.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.service.SharedContextService;
 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;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.util.StringUtils;
 
 /**
  * Listens for session-create and session-destroy events.
@@ -75,7 +91,6 @@ public class UserSessionListener implements HttpSessionListener {
         * invalidated.
         */
        public void sessionDestroyed(HttpSessionEvent event) {
-
                try {
                        HttpSession session = event.getSession();
                        ServletContext context = session.getServletContext();
@@ -84,14 +99,14 @@ public class UserSessionListener implements HttpSessionListener {
 
                        EPUser user = (EPUser) session
                                        .getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME));
-                       if (user!=null && !StringUtils.isEmpty(user.getOrgUserId())) {
+                       if (user != null && !StringUtils.isEmpty(user.getOrgUserId())) {
                                CollaborateList.delUserName(user.getOrgUserId());
                        }
 
                        // Remove any shared context entries for this session.
-                       if (getSharedContextService()!=null) {
+                       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);
@@ -100,10 +115,10 @@ public class UserSessionListener implements HttpSessionListener {
                        logger.info(EELFLoggerDelegate.debugLogger, "Session Destroyed : " + session.getId());
 
                } catch (Exception e) {
-                       logger.warn(EELFLoggerDelegate.errorLogger, "Exception occurred while executing sessionDestroyed. Details: " + EcompPortalUtils.getStackTrace(e));
+                       logger.warn(EELFLoggerDelegate.errorLogger, "sessionDestroyed failed", e);
                }
        }
-       
+
        private static ApplicationContext applicationContext;
 
        public static void setApplicationContext(ApplicationContext _applicationContext) {
@@ -111,11 +126,11 @@ public class UserSessionListener implements HttpSessionListener {
        }
 
        public SharedContextService getSharedContextService() {
-               if(sharedContextService == null){
-                       if (applicationContext != null)                         
-                               sharedContextService = (SharedContextService)applicationContext.getBean("sharedContextService");
+               if (sharedContextService == null) {
+                       if (applicationContext != null)
+                               sharedContextService = (SharedContextService) applicationContext.getBean("sharedContextService");
                }
-               
+
                return sharedContextService;
        }
 
@@ -123,4 +138,3 @@ public class UserSessionListener implements HttpSessionListener {
                this.sharedContextService = sharedContextService;
        }
 }
-