From 25038bbf6325a31d9d1cc9c51a2c430a4f09a865 Mon Sep 17 00:00:00 2001
From: "Barbara B. Frosik" <bfrosik@aps.anl.gov>
Date: Mon, 9 Feb 2015 16:24:26 +0000
Subject: [PATCH]

---
 .../controllers/ExperimentController.java     | 135 ++++++++----------
 .../portal/controllers/LoginController.java   |   6 -
 .../controllers/UserInfoController.java       |   2 +-
 .../dm/portal/model/entities/UserInfo.java    |  17 ++-
 .../aps/dm/portal/utilities/DoubleKeyMap.java |  58 --------
 .../js/common/forwardNotAuthorized.js         |   2 +
 .../web/templates/dmAdminOnlyTemplate.xhtml   |  10 ++
 .../web/templates/dmRestrictedTemplate.xhtml  |  10 ++
 ...Template4x3.xhtml => dmViewTemplate.xhtml} |   8 +-
 .../web/views/experiment/create.xhtml         |   7 +-
 .../web/views/experiment/edit.xhtml           |   7 +-
 .../experiment/experimentListDataTable.xhtml  |   9 +-
 .../experimentUsersEditDataTable.xhtml        |   9 +-
 .../web/views/experiment/list.xhtml           |   6 +-
 .../web/views/experiment/view.xhtml           |  10 +-
 .../web/views/experimentType/create.xhtml     |   9 +-
 .../web/views/experimentType/edit.xhtml       |   9 +-
 .../web/views/experimentType/list.xhtml       |   6 +-
 .../web/views/experimentType/view.xhtml       |   6 +-
 src/java/DmWebPortal/web/views/home.xhtml     |   4 +-
 .../DmWebPortal/web/views/roleType/edit.xhtml |   9 +-
 .../DmWebPortal/web/views/roleType/list.xhtml |   6 +-
 .../DmWebPortal/web/views/roleType/view.xhtml |   6 +-
 .../web/views/userInfo/create.xhtml           |   9 +-
 .../DmWebPortal/web/views/userInfo/edit.xhtml |   9 +-
 .../DmWebPortal/web/views/userInfo/list.xhtml |   6 +-
 .../userExperimentsListDataTable.xhtml        |   2 +-
 .../DmWebPortal/web/views/userInfo/view.xhtml |   7 +-
 .../web/views/userSystemRole/list.xhtml       |   6 +-
 29 files changed, 189 insertions(+), 201 deletions(-)
 delete mode 100644 src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/utilities/DoubleKeyMap.java
 create mode 100644 src/java/DmWebPortal/web/resources/js/common/forwardNotAuthorized.js
 create mode 100644 src/java/DmWebPortal/web/templates/dmAdminOnlyTemplate.xhtml
 create mode 100644 src/java/DmWebPortal/web/templates/dmRestrictedTemplate.xhtml
 rename src/java/DmWebPortal/web/templates/{contentViewTemplate4x3.xhtml => dmViewTemplate.xhtml} (93%)

diff --git a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/ExperimentController.java b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/ExperimentController.java
index 881eb054..b4273cd3 100644
--- a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/ExperimentController.java
+++ b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/ExperimentController.java
@@ -15,10 +15,8 @@ import gov.anl.aps.dm.portal.model.entities.CloneableEntity;
 import gov.anl.aps.dm.portal.model.entities.RoleType;
 import gov.anl.aps.dm.portal.model.entities.UserExperimentRole;
 import gov.anl.aps.dm.portal.model.entities.UserInfo;
-import gov.anl.aps.dm.portal.utilities.DoubleKeyMap;
 import gov.anl.aps.dm.portal.utilities.SessionUtility;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -53,27 +51,26 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
     
     public class ExperimentUser extends CloneableEntity {
 
-        String username;
         String name;
-        int userId;
         int experimentId;
+        private final UserInfo user;
         private final boolean[] userRoles;
 
-        public ExperimentUser(int experimentId, int userId) {
+        public ExperimentUser(int experimentId, UserInfo user) {
             userRoles = new boolean[maxExperimentRoleTypeId + 1];
             this.experimentId = experimentId;
-            this.userId = userId;
+            this.user = user;
         }
-
-        public String getUsername() {
-            return username;
+        
+        public UserInfo getUser() {
+            return user;
         }
 
-        public void setUsername(String username) {
-            this.username = username;
+        public String getUsername() {
+            return user.getUsername();
         }
 
-        public String getName() {
+         public String getName() {
             return name;
         }
 
@@ -113,19 +110,9 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
             return userRoles;
         }
 
-        public void removeAllExperimentRoles() {
-            UserExperimentRole userExperimentRole;
-            for (RoleType role : experimentRoles.values()) {
-                if (userRoles[role.getId()]) {
-                    userExperimentRole = userExperimentRoleFacade.findByUserExperimentRole(userId, experimentId, role.getId());
-                    userExperimentRoleFacade.remove(userExperimentRole);                 
-                }
-            }
-        }
-        
         @Override
         public int hashCode() {
-            return userId + experimentId * 100;
+            return user.getId() + experimentId * 100;
         }
 
         @Override
@@ -134,7 +121,7 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
             if (!(object instanceof ExperimentUser)) {
                 return false;
             }
-            return ((userId == ((ExperimentUser) object).userId) && (experimentId == ((ExperimentUser) object).experimentId));
+            return ((user.getId() == ((ExperimentUser) object).user.getId()) && (experimentId == ((ExperimentUser) object).experimentId));
         }
     }
 
@@ -156,18 +143,15 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
                 initializeRoleTypes();
             }
             logger.debug("converting ExperimentUser ");
-            Collection<RoleType> roleTypes;
-            roleTypes = experimentRoles.values();
             ExperimentUser experimentUser;
             for (UserInfo user : list) {
-                if ((experimentUser = experimentUsers.getByFirstKey(user)) == null) {
-                    experimentUser = new ExperimentUser(getCurrent().getId(), user.getId());
-                    experimentUser.setUsername(user.getUsername());
+                if ((experimentUser = experimentUsers.get(user)) == null) {
+                    experimentUser = new ExperimentUser(getCurrent().getId(), user);
                     experimentUser.setName(user.getLastName() + ", " + user.getFirstName());
-                    experimentUsers.put(user, user.getId(), experimentUser);
+                    experimentUsers.put(user, experimentUser);
                 }
-                for (RoleType roleType : roleTypes) {
-                    boolean inRole = user.inRole(roleType.getId(), getCurrent().getId());
+                for (RoleType roleType : experimentRoles.values()) {
+                    boolean inRole = (user.getExperimetRole(roleType.getId(), getCurrent().getId()) != null);
                     experimentUser.setIsInRole(roleType, inRole);
                 }
             }
@@ -202,11 +186,10 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
     private ExperimentController.ExperimentUsersTable experimentUsersListTable = new ExperimentController.ExperimentUsersTable();
     private ExperimentController.ExperimentUsersTable experimentUsersEditTable = new ExperimentController.ExperimentUsersTable();
     private ExperimentController.NoExperimentUsersTypeTable noExperimentUsersTypeTable = new ExperimentController.NoExperimentUsersTypeTable();
-    final private DoubleKeyMap<UserInfo, Integer, ExperimentUser> experimentUsers = new DoubleKeyMap<>();
+    final private Map<UserInfo, ExperimentUser> experimentUsers = new HashMap<>();
     final private Map<String, RoleType> experimentRoles = new HashMap<>();
     int maxExperimentRoleTypeId = 0;
     boolean initialized = false;
-    private UserInfo loggedUser = null;
 
     public ExperimentController() {
         this.experimentUsersListTable = new ExperimentController.ExperimentUsersTable();
@@ -251,12 +234,6 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
         return super.prepareEdit(experiment);
     }
 
-    @Override
-    public String prepareView(Experiment experiment) {
-        clear();
-        return super.prepareView(experiment);
-    }
-
     private void initializeRoleTypes() {
         List<RoleType> roleTypesList = roleTypeFacade.findAll();
         for (RoleType roleType : roleTypesList) {
@@ -313,6 +290,7 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
    
 // the methods for Experiment User
 
+    @Override
     public void clear() {
         experimentUsersListTable.resetList();
         experimentUsersEditTable.resetList();
@@ -346,15 +324,13 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
         
     public void updateRemovedExperimentRoles() {
         UserExperimentRole userExperimentRole;
-        for (UserInfo user : experimentUsers.firstKeySet()) {
-            ExperimentUser experimentUser = experimentUsers.getByFirstKey(user);
+        for (UserInfo user : experimentUsers.keySet()) {
+            ExperimentUser experimentUser = experimentUsers.get(user);
             for (RoleType roleType : experimentRoles.values()) {
                 int roleId = roleType.getId();
-                if ((!experimentUser.userRoles[roleId]) && (user.inRole(roleId, experimentUser.experimentId))) {
-                    userExperimentRole = userExperimentRoleFacade.findByUserExperimentRole(experimentUser.userId, experimentUser.experimentId, roleId);
-                    if (userExperimentRole != null) {
-                        userExperimentRoleFacade.remove(userExperimentRole);
-                    }
+                userExperimentRole = user.getExperimetRole(roleId, experimentUser.experimentId);
+                if ((userExperimentRole != null ) && (!experimentUser.userRoles[roleId]) ) {
+                   userExperimentRoleFacade.remove(userExperimentRole);
                 }
             }
         }
@@ -363,24 +339,24 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
     @Override
     public String update() {
         boolean updated;
-        for (UserInfo user : experimentUsers.firstKeySet()) {
+        for (UserInfo user : experimentUsers.keySet()) {
             updated = false;
-            ExperimentUser experimentUser = experimentUsers.getByFirstKey(user);
+            ExperimentUser experimentUser = experimentUsers.get(user);
             for (RoleType roleType : experimentRoles.values()) {
                 if (!roleType.isIsSystemRole()) {
                     int roleId = roleType.getId();
-                    if (!user.inRole(roleId, experimentUser.experimentId)) {
+                    if (user.getExperimetRole(roleId, experimentUser.experimentId) == null) {
                         if (experimentUser.userRoles[roleId]) {
-                            UserExperimentRole userExperimentRole = new UserExperimentRole(experimentUser.userId, experimentUser.experimentId, roleId);
+                            UserExperimentRole userExperimentRole = new UserExperimentRole(user.getId(), experimentUser.experimentId, roleId);
                             user.addUserExperimentRole(userExperimentRole);
                             updated = true;
-                            logger.debug("adding userExperimentRole " + experimentUser.userId + " " + experimentUser.experimentId + " " + roleId);
+                            logger.debug("adding userExperimentRole " + user.getId() + " " + experimentUser.experimentId + " " + roleId);
                         }
                     }
                     else if (!experimentUser.userRoles[roleId]) {
                             user.removeExperimentRole(roleId, experimentUser.experimentId);
                             updated = true;
-                            logger.debug("adding userExperimentRole " + experimentUser.userId + " " + experimentUser.experimentId + " " + roleId);
+                            logger.debug("adding userExperimentRole " + user.getId() + " " + experimentUser.experimentId + " " + roleId);
                         }
                     }
                     if (updated) {
@@ -401,10 +377,9 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
     }
         
     public String removeUser() {
-        List<RoleType> roleTypesList = roleTypeFacade.findAll();
         ExperimentUser experimentUser = experimentUsersEditTable.getCurrentObject();
-        UserInfo user = findUserInExperiment(experimentUser);
-        for (RoleType roleType : roleTypesList) {
+        UserInfo user = experimentUser.getUser();
+        for (RoleType roleType : experimentRoles.values()) {
             int roleId = roleType.getId();
             if (experimentUser.userRoles[roleId]) {
                 user.removeExperimentRole(roleId, experimentUser.experimentId);
@@ -417,18 +392,13 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
     
     public void removeUserRoles() {
         ExperimentUser experimentUser = experimentUsersEditTable.getCurrentObject();
-        experimentUser.removeAllExperimentRoles();        
-    }
-    
-    private UserInfo findUserInExperiment(ExperimentUser experimentUser) {
-        for (UserInfo user : experimentUsers.firstKeySet()) {
-            if (experimentUsers.getByFirstKey(user).equals(experimentUser)) {
-                return user;
-            }
+        UserInfo user = experimentUser.getUser();
+        List<UserExperimentRole> roleList = user.getUserExperimentRoles(experimentUser.experimentId);
+        for (UserExperimentRole userExperimentRole : roleList) {
+             userExperimentRoleFacade.remove(userExperimentRole); 
         }
-        return null;
     }
-
+    
     public String addExperimentUser() {
         List<UserInfo> newUsers = noExperimentUsersTypeTable.getSelectedObjectList();
         if (newUsers == null) {
@@ -454,36 +424,47 @@ public class ExperimentController extends CrudEntityController<Experiment, Exper
         }
     }
     
-    public boolean canEditExperiment(int userId, int experimentId) {
+    public boolean canEditExperiment(int experimentId) {
         if (!initialized) {
             initializeRoleTypes();
         }
         // user that is Manager or PI can edit experiment
         int managerRoleId = experimentRoles.get(RoleTypeName.MANAGER).getId();
         int piRoleId = experimentRoles.get(RoleTypeName.PI).getId();
-        return ((userExperimentRoleFacade.findByUserExperimentRole(userId, experimentId, managerRoleId) != null) ||
-              (userExperimentRoleFacade.findByUserExperimentRole(userId, experimentId, piRoleId) != null));      
+        UserInfo logged = (UserInfo) SessionUtility.getUser();
+        return (logged.getExperimetRole(managerRoleId, experimentId) != null) || (logged.getExperimetRole(piRoleId, experimentId) != null);
     }
     
-    public boolean canDeleteExperiment(int userId, int experimentId) {
+    public boolean isRestricted() {
+        if (current == null) {
+            return true;
+        }     
+        int managerRoleId = experimentRoles.get(RoleTypeName.MANAGER).getId();
+        int piRoleId = experimentRoles.get(RoleTypeName.PI).getId();
+        UserInfo logged = (UserInfo) SessionUtility.getUser();
+        return (logged.getExperimetRole(managerRoleId, current.getId()) == null) && (logged.getExperimetRole(piRoleId, current.getId()) == null);
+    }
+    
+    public boolean canDeleteExperiment(int experimentId) {
         if (!initialized) {
             initializeRoleTypes();
         }
-        // user that is Manager can delete experiment
-        return (userExperimentRoleFacade.findByUserExperimentRole(userId, experimentId, experimentRoles.get(RoleTypeName.MANAGER).getId()) != null);      
+        int managerRoleId = experimentRoles.get(RoleTypeName.MANAGER).getId();
+        UserInfo logged = (UserInfo) SessionUtility.getUser();
+        return logged.getExperimetRole(managerRoleId, experimentId) != null;
     }
     
-    public boolean canAddManager(int userId) {
-        ExperimentUser logged = experimentUsers.getBySecondKey(userId);
+    public boolean canAddManager() {
+       ExperimentUser logged = experimentUsers.get((UserInfo) SessionUtility.getUser());
         if (logged == null) {
             return false;
         }
         return logged.isIsManager();
     }
     
-    public boolean canAddPiAndUser(int userId) {
-        ExperimentUser logged = experimentUsers.getBySecondKey(userId);
-        if (logged == null) {
+    public boolean canAddPiAndUser() {
+       ExperimentUser logged = experimentUsers.get((UserInfo) SessionUtility.getUser());
+         if (logged == null) {
             return false;
         }
         return logged.isIsManager() || logged.isIsPI();
diff --git a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/LoginController.java b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/LoginController.java
index 3852c260..37e692f0 100644
--- a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/LoginController.java
+++ b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/LoginController.java
@@ -35,7 +35,6 @@ public class LoginController implements Serializable
     private RoleTypeFacade roleTypeFacade;
     
     private String username = null;
-    private int id;
     private String password = null;
     private boolean loggedIn = false;
     private UserInfo user = null;
@@ -85,10 +84,6 @@ public class LoginController implements Serializable
         this.username = username;
     }
 
-    public int getUserId() {
-        return id;
-    }
-
     /**
      * Check if user is logged in.
      *
@@ -136,7 +131,6 @@ public class LoginController implements Serializable
             loggedIn = true;
             SessionUtility.addInfoMessage("Successful Login", "User " + username + " is logged in.");
             isAdmin = roleTypeFacade.findByName(RoleTypeName.ADMIN).isAdmin(username);
-            id = user.getId();
             return getLandingPage();
         }
         else {
diff --git a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/UserInfoController.java b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/UserInfoController.java
index 50d9bb2e..8e3078a5 100644
--- a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/UserInfoController.java
+++ b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/controllers/UserInfoController.java
@@ -132,7 +132,7 @@ public class UserInfoController extends CrudEntityController<UserInfo, UserInfoF
                 experimentUser.setDescription(experiment.getDescription());
                 userExperiments.add(experimentUser);
                 for (RoleType roleType : roleTypes) {
-                    boolean inRole = getCurrent().inRole(roleType.getId(), experiment.getId());
+                    boolean inRole = (getCurrent().getExperimetRole(roleType.getId(), experiment.getId()) != null);
                     experimentUser.setIsInRole(roleType, inRole);
                 }
             }
diff --git a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/model/entities/UserInfo.java b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/model/entities/UserInfo.java
index 8c7ea57e..d1fc360a 100644
--- a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/model/entities/UserInfo.java
+++ b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/model/entities/UserInfo.java
@@ -6,6 +6,7 @@
 
 package gov.anl.aps.dm.portal.model.entities;
 
+import java.util.ArrayList;
 import java.util.List;
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
@@ -208,16 +209,26 @@ public class UserInfo extends CloneableEntity
         }
     }
     
+    public List<UserExperimentRole> getUserExperimentRoles(int experimentId) {
+        List<UserExperimentRole> roleList = new ArrayList<>();
+        for (UserExperimentRole experimentRole : userExperimentRoleList) {
+            if (experimentRole.getUserExperimentRolePK().getExperimentId() == experimentId) {
+                roleList.add(experimentRole);
+            }
+        }
+        return roleList;
+    }
+    
     public void addUserExperimentRole(UserExperimentRole userExperimentRole) {
         userExperimentRoleList.add(userExperimentRole);
     }
     
-    public boolean inRole(int roleId, int experimentId) {
+    public UserExperimentRole getExperimetRole(int roleId, int experimentId) {
         for (UserExperimentRole experimentRole : userExperimentRoleList) {
             if ((experimentRole.getUserExperimentRolePK().getRoleTypeId() == roleId) && (experimentRole.getUserExperimentRolePK().getExperimentId() == experimentId))
-                return true;
+                return experimentRole;
         }
-        return false;
+        return null;
     }
 
     @Override
diff --git a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/utilities/DoubleKeyMap.java b/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/utilities/DoubleKeyMap.java
deleted file mode 100644
index fe225e14..00000000
--- a/src/java/DmWebPortal/src/java/gov/anl/aps/dm/portal/utilities/DoubleKeyMap.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package gov.anl.aps.dm.portal.utilities;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author bfrosik
- * @param <K1>
- * @param <K2>
- * @param <E>
- */
-public class DoubleKeyMap <K1, K2, E> {
-    private final Map<K1, E> map1 = new HashMap<>();
-    private final Map<K2, E> map2 = new HashMap<>();
-    
-    public void put(K1 key1, K2 key2, E value) {
-        map1.put(key1, value);
-        map2.put(key2, value);
-    }
-    
-    public E getByFirstKey(K1 key1) {
-        return map1.get(key1);
-    }
-
-    public E getBySecondKey(K2 key2) {
-        return map2.get(key2);
-    }
-    
-    public void remove(K1 key1, K2 key2) {
-        map1.remove(key1);
-        map2.remove(key2);
-    }
-    
-    public Collection<E> values() {
-        return map1.values();
-    }
-
-    public Collection<K1> firstKeySet() {
-        return map1.keySet();
-    }
-
-    public Collection<K2> secondKeySet() {
-        return map2.keySet();
-    }
-    
-    public void clear() {
-        map1.clear();
-        map2.clear();
-    }
-}
diff --git a/src/java/DmWebPortal/web/resources/js/common/forwardNotAuthorized.js b/src/java/DmWebPortal/web/resources/js/common/forwardNotAuthorized.js
new file mode 100644
index 00000000..adcc2eec
--- /dev/null
+++ b/src/java/DmWebPortal/web/resources/js/common/forwardNotAuthorized.js
@@ -0,0 +1,2 @@
+  window.location = "/dm/views/home.xhtml";
+
diff --git a/src/java/DmWebPortal/web/templates/dmAdminOnlyTemplate.xhtml b/src/java/DmWebPortal/web/templates/dmAdminOnlyTemplate.xhtml
new file mode 100644
index 00000000..26a79979
--- /dev/null
+++ b/src/java/DmWebPortal/web/templates/dmAdminOnlyTemplate.xhtml
@@ -0,0 +1,10 @@
+<!--<?xml version='1.0' encoding='UTF-8' ?>-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html">
+
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:include src="/templates/contentViewTemplate4x3.xhtml"/>
+</html>
\ No newline at end of file
diff --git a/src/java/DmWebPortal/web/templates/dmRestrictedTemplate.xhtml b/src/java/DmWebPortal/web/templates/dmRestrictedTemplate.xhtml
new file mode 100644
index 00000000..72180d70
--- /dev/null
+++ b/src/java/DmWebPortal/web/templates/dmRestrictedTemplate.xhtml
@@ -0,0 +1,10 @@
+<!--<?xml version='1.0' encoding='UTF-8' ?>-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html">
+
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin and experimentController.isRestricted()}"/>
+    <ui:include src="/templates/contentViewTemplate4x3.xhtml"/>
+</html>
\ No newline at end of file
diff --git a/src/java/DmWebPortal/web/templates/contentViewTemplate4x3.xhtml b/src/java/DmWebPortal/web/templates/dmViewTemplate.xhtml
similarity index 93%
rename from src/java/DmWebPortal/web/templates/contentViewTemplate4x3.xhtml
rename to src/java/DmWebPortal/web/templates/dmViewTemplate.xhtml
index d86b7d60..bd06b4df 100644
--- a/src/java/DmWebPortal/web/templates/contentViewTemplate4x3.xhtml
+++ b/src/java/DmWebPortal/web/templates/dmViewTemplate.xhtml
@@ -6,7 +6,7 @@
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://xmlns.jcp.org/jsf/core">
 
-    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+
     
     <h:head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -25,10 +25,8 @@
             <div>
                 <div id="topRight" class="topRightContent">
                     <ui:insert name="topRight">
-                        <h:outputText value="Username: #{loginController.displayUsername()}"/>
-                        <br/>
-
-                        <h:outputText value="Role: #{userSystemRoleController.displayRole(loginController.username)}"/>
+          
+                        <h:outputText value="Administrator" rendered="#{loginController.admin}"/>
 
                     </ui:insert>
                 </div>
diff --git a/src/java/DmWebPortal/web/views/experiment/create.xhtml b/src/java/DmWebPortal/web/views/experiment/create.xhtml
index a22b8705..1a0f34da 100644
--- a/src/java/DmWebPortal/web/views/experiment/create.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/create.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
     
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Add Experiment</h1>
@@ -25,6 +27,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/experiment/edit.xhtml b/src/java/DmWebPortal/web/views/experiment/edit.xhtml
index e6194487..94e0c53d 100644
--- a/src/java/DmWebPortal/web/views/experiment/edit.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/edit.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin and experimentController.isRestricted()}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="editExperimentForm">
 
@@ -38,6 +40,7 @@
                 <ui:include src="experimentUserRemoveDialog.xhtml" />
          </h:form>
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/experiment/experimentListDataTable.xhtml b/src/java/DmWebPortal/web/views/experiment/experimentListDataTable.xhtml
index 30264fa0..52f7128d 100644
--- a/src/java/DmWebPortal/web/views/experiment/experimentListDataTable.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/experimentListDataTable.xhtml
@@ -56,12 +56,13 @@
         <p:column headerText="Actions" >
             <div class="actionLink">
                 <p:commandLink action="#{experimentController.prepareView(experimentObject)}" styleClass="ui-icon ui-icon-info" title="View">
-
                 </p:commandLink>
-                <p:commandLink action="#{experimentController.prepareEdit(experimentObject)}" rendered="#{loginController.admin or experimentController.canEditExperiment(loginController.userId, experimentObject.id)}" styleClass="ui-icon ui-icon-pencil" title="Edit">
-
+    
+                <p:commandLink action="#{experimentController.prepareEdit(experimentObject)}" rendered="#{loginController.admin or experimentController.canEditExperiment(experimentObject.id)}" styleClass="ui-icon ui-icon-pencil" title="Edit">
+                    <f:setPropertyActionListener value="#{experimentObject}" target="#{experimentController.current}"/>
                 </p:commandLink>
-                <p:commandLink oncomplete="PF('experimentDestroyDialogWidget').show()" rendered="#{loginController.admin or experimentController.canDeleteExperiment(loginController.userId, experimentObject.id)}" styleClass="ui-icon ui-icon-trash" title="Delete" update="@form">
+
+                <p:commandLink oncomplete="PF('experimentDestroyDialogWidget').show()" rendered="#{loginController.admin or experimentController.canDeleteExperiment(experimentObject.id)}" styleClass="ui-icon ui-icon-trash" title="Delete" update="@form">
                     <f:setPropertyActionListener value="#{experimentObject}" target="#{experimentController.current}"/>
                 </p:commandLink>
             </div>
diff --git a/src/java/DmWebPortal/web/views/experiment/experimentUsersEditDataTable.xhtml b/src/java/DmWebPortal/web/views/experiment/experimentUsersEditDataTable.xhtml
index 0a483d7d..4b01e585 100644
--- a/src/java/DmWebPortal/web/views/experiment/experimentUsersEditDataTable.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/experimentUsersEditDataTable.xhtml
@@ -34,8 +34,8 @@
                  widgetVar="experimentUsersEditWidget" 
                  emptyMessage="No users found.">
 
-        <ui:param name="isManager" value="#{experimentController.canAddManager(loginController.userId)}" />
-        <ui:param name="isPi" value="#{experimentController.canAddPiAndUser(loginController.userId)}" />
+        <ui:param name="isManager" value="#{experimentController.canAddManager()}" />
+        <ui:param name="isPi" value="#{experimentController.canAddPiAndUser()}" />
 
         <p:column sortBy="#{experimentUserObject.username}" headerText="Username"
                   filterBy="#{experimentUserObject.username}" filterMatchMode="contains" >
@@ -63,9 +63,10 @@
         </p:column>
 
 
-        <p:column headerText="Actions" rendered="#{isAdmin or isManager}">
+        <ui:param name="isEditedManager" value="#{experimentUserObject.isManager}" />
+        <p:column headerText="Actions" rendered="#{isAdmin or isManager or isPi}">
             <div class="actionLink" >
-                <p:commandLink oncomplete="PF('experimentUserRemoveDialogWidget').show()" rendered="true" styleClass="ui-icon ui-icon-trash" title="Remove"  update="@form">
+                <p:commandLink oncomplete="PF('experimentUserRemoveDialogWidget').show()" rendered="#{!experimentUserObject.isManager or isAdmin or isManager}" styleClass="ui-icon ui-icon-trash" title="Remove"  update="@form">
                     <f:setPropertyActionListener value="#{experimentUserObject}" target="#{experimentController.experimentUsersEditTable.currentObject}" />
                 </p:commandLink>
             </div>
diff --git a/src/java/DmWebPortal/web/views/experiment/list.xhtml b/src/java/DmWebPortal/web/views/experiment/list.xhtml
index 0e2487af..97706fd3 100644
--- a/src/java/DmWebPortal/web/views/experiment/list.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/list.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Experiments</h1>
@@ -26,4 +27,5 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
diff --git a/src/java/DmWebPortal/web/views/experiment/view.xhtml b/src/java/DmWebPortal/web/views/experiment/view.xhtml
index f059e962..50570664 100644
--- a/src/java/DmWebPortal/web/views/experiment/view.xhtml
+++ b/src/java/DmWebPortal/web/views/experiment/view.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="viewExperimentForm">
             <div class="pageTitle">
@@ -30,13 +31,14 @@
             <p/>
 
             <div class="actionButton">
-                <p:commandButton action="#{experimentController.prepareEdit(experimentObject)}" rendered="#{loginController.admin or experimentController.canEditExperiment(loginController.userId, experimentObject.id)}" value="Edit" alt="Edit" icon="ui-icon-pencil"/>
+                <p:commandButton action="#{experimentController.prepareEdit(experimentObject)}" rendered="#{loginController.admin or experimentController.canEditExperiment(experimentObject.id)}" value="Edit" alt="Edit" icon="ui-icon-pencil"/>
                 <p:commandButton action="#{experimentController.prepareList()}" value="Return" alt="Return" icon="ui-icon-arrowreturnthick-1-w"/>
             </div>
 
         </h:form>
     </ui:define>
-
+        
+</ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/experimentType/create.xhtml b/src/java/DmWebPortal/web/views/experimentType/create.xhtml
index ad514f2f..75c24d9d 100644
--- a/src/java/DmWebPortal/web/views/experimentType/create.xhtml
+++ b/src/java/DmWebPortal/web/views/experimentType/create.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
-
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+    
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Add Experiment Type</h1>
@@ -25,6 +27,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/experimentType/edit.xhtml b/src/java/DmWebPortal/web/views/experimentType/edit.xhtml
index 53281c4d..1331c8ef 100644
--- a/src/java/DmWebPortal/web/views/experimentType/edit.xhtml
+++ b/src/java/DmWebPortal/web/views/experimentType/edit.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
-
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+    
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="editExperimentTypeForm">
 
@@ -27,6 +29,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/experimentType/list.xhtml b/src/java/DmWebPortal/web/views/experimentType/list.xhtml
index def1112b..0f5adbf3 100644
--- a/src/java/DmWebPortal/web/views/experimentType/list.xhtml
+++ b/src/java/DmWebPortal/web/views/experimentType/list.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Experiment Types</h1>
@@ -26,4 +27,5 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
diff --git a/src/java/DmWebPortal/web/views/experimentType/view.xhtml b/src/java/DmWebPortal/web/views/experimentType/view.xhtml
index afe75501..b4fa02f8 100644
--- a/src/java/DmWebPortal/web/views/experimentType/view.xhtml
+++ b/src/java/DmWebPortal/web/views/experimentType/view.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="viewExperimentTypeForm">
 
@@ -35,6 +36,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 
 </ui:composition>
 
diff --git a/src/java/DmWebPortal/web/views/home.xhtml b/src/java/DmWebPortal/web/views/home.xhtml
index d534f931..5bfdf960 100644
--- a/src/java/DmWebPortal/web/views/home.xhtml
+++ b/src/java/DmWebPortal/web/views/home.xhtml
@@ -7,8 +7,8 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://xmlns.jcp.org/jsf/core">
 
-
-    <ui:composition template="../templates/contentViewTemplate4x3.xhtml">
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../templates/dmViewTemplate.xhtml">
         <ui:define name="middleCenter">
 
             <div class="homePage">
diff --git a/src/java/DmWebPortal/web/views/roleType/edit.xhtml b/src/java/DmWebPortal/web/views/roleType/edit.xhtml
index 92a6a7ef..ffb705f4 100644
--- a/src/java/DmWebPortal/web/views/roleType/edit.xhtml
+++ b/src/java/DmWebPortal/web/views/roleType/edit.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
-
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+    
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="editRoleTypeForm">
 
@@ -27,4 +29,5 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
diff --git a/src/java/DmWebPortal/web/views/roleType/list.xhtml b/src/java/DmWebPortal/web/views/roleType/list.xhtml
index 3ae2e81e..13a1a205 100644
--- a/src/java/DmWebPortal/web/views/roleType/list.xhtml
+++ b/src/java/DmWebPortal/web/views/roleType/list.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Role Types</h1>
@@ -31,4 +32,5 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
diff --git a/src/java/DmWebPortal/web/views/roleType/view.xhtml b/src/java/DmWebPortal/web/views/roleType/view.xhtml
index e3b1491e..3e9942d7 100644
--- a/src/java/DmWebPortal/web/views/roleType/view.xhtml
+++ b/src/java/DmWebPortal/web/views/roleType/view.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="viewRoleTypeForm">
 
@@ -30,6 +31,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 
 </ui:composition>
 
diff --git a/src/java/DmWebPortal/web/views/userInfo/create.xhtml b/src/java/DmWebPortal/web/views/userInfo/create.xhtml
index 5252c365..160b5147 100644
--- a/src/java/DmWebPortal/web/views/userInfo/create.xhtml
+++ b/src/java/DmWebPortal/web/views/userInfo/create.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
-
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+    
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Add User</h1>
@@ -25,6 +27,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/userInfo/edit.xhtml b/src/java/DmWebPortal/web/views/userInfo/edit.xhtml
index 3a2bd6b2..99fa500b 100644
--- a/src/java/DmWebPortal/web/views/userInfo/edit.xhtml
+++ b/src/java/DmWebPortal/web/views/userInfo/edit.xhtml
@@ -5,9 +5,11 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
-
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+    
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <h:outputScript library="js/common" name="forwardNotAuthorized.js" rendered="#{!loginController.admin}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="editUserInfoForm">
 
@@ -29,6 +31,7 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/userInfo/list.xhtml b/src/java/DmWebPortal/web/views/userInfo/list.xhtml
index 62cf4f84..b96418de 100644
--- a/src/java/DmWebPortal/web/views/userInfo/list.xhtml
+++ b/src/java/DmWebPortal/web/views/userInfo/list.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Registered Users</h1>
@@ -26,4 +27,5 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
diff --git a/src/java/DmWebPortal/web/views/userInfo/userExperimentsListDataTable.xhtml b/src/java/DmWebPortal/web/views/userInfo/userExperimentsListDataTable.xhtml
index 74727954..627f361a 100644
--- a/src/java/DmWebPortal/web/views/userInfo/userExperimentsListDataTable.xhtml
+++ b/src/java/DmWebPortal/web/views/userInfo/userExperimentsListDataTable.xhtml
@@ -22,7 +22,7 @@
                  rows="6"
                  binding="#{userInfoController.userExperimentsListTable.listDataTable}"
                  widgetVar="userExperimentsListWidget" 
-                 emptyMessage="No users found.">
+                 emptyMessage="No experiments found.">
 
         <p:column sortBy="#{userExperimentObject.experimentName}" headerText="Experiment Name"
                   filterBy="#{userExperimentObject.experimentName}" filterMatchMode="contains" >
diff --git a/src/java/DmWebPortal/web/views/userInfo/view.xhtml b/src/java/DmWebPortal/web/views/userInfo/view.xhtml
index 5847bc78..33da299b 100644
--- a/src/java/DmWebPortal/web/views/userInfo/view.xhtml
+++ b/src/java/DmWebPortal/web/views/userInfo/view.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <h:form id="viewUserInfoForm">
             <div class="pageTitle">
@@ -42,7 +43,7 @@
         </h:form>
     </ui:define>
 
-
+    </ui:composition>
 </ui:composition>
 
 
diff --git a/src/java/DmWebPortal/web/views/userSystemRole/list.xhtml b/src/java/DmWebPortal/web/views/userSystemRole/list.xhtml
index 652683ec..3d5782fa 100644
--- a/src/java/DmWebPortal/web/views/userSystemRole/list.xhtml
+++ b/src/java/DmWebPortal/web/views/userSystemRole/list.xhtml
@@ -5,9 +5,10 @@
                 xmlns:p="http://primefaces.org/ui"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
-                template="../../templates/contentViewTemplate4x3.xhtml">
+                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
 
+    <h:outputScript library="js/common" name="forwardNotLoggedin.js" rendered="#{!loginController.loggedIn}"/>
+    <ui:composition template="../../templates/dmViewTemplate.xhtml">
     <ui:define name="middleCenter">
         <div class="pageTitle">
             <h1>Administrators</h1>
@@ -36,5 +37,6 @@
         </h:form>
 
     </ui:define>
+    </ui:composition>
 </ui:composition>
 
-- 
GitLab