portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r899650 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/decorations/layout/greenearth/ applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/ applications/jetspeed/src/main/webapp/decorations/layout/...
Date Fri, 15 Jan 2010 14:57:38 GMT
Author: ate
Date: Fri Jan 15 14:57:37 2010
New Revision: 899650

URL: http://svn.apache.org/viewvc?rev=899650&view=rev
Log:
Fix UnsupportedOperationException in JPT as the User.infoMap is (by design) unmodifiable.
I hit this one when connecting with a new user without any attributes.
Adding a String getUserAttribute(name,defaultValue) as convenient helper method and adjusting
the layout header.vm's accordingly

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/greenearth/header.vm
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/header.vm
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/purpleplanet/header.vm
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/turbo/header.vm
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/JetspeedPowerTool.java

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/greenearth/header.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/greenearth/header.vm?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/greenearth/header.vm
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/greenearth/header.vm
Fri Jan 15 14:57:37 2010
@@ -76,7 +76,7 @@
 <!--  BEGIN: layout/html/jetspeed/decorator.vm -->
 <!-- Page Action Bar -->
 #if ($request.getUserPrincipal())
-<span class="layout-statusarea"><b>$jetspeed.getUserAttributes().get("user.name.given")
$jetspeed.getUserAttributes().get("user.name.family")</b> | Profile | Tasks (5) | Notifications
(2) | <a href="#BaseHref()login/logout">Log out</a></span>
+<span class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","")
$jetspeed.getUserAttribute("user.name.family", ${request.userPrincipal.name})</b> |
Profile | Tasks (5) | Notifications (2) | <a href="#BaseHref()login/logout">Log out</a></span>
 #end
 #if (!$jetspeed.isAjaxCustomizationEnabled())
 #PageActionBar()

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/header.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/header.vm?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/header.vm
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/jetspeed/header.vm
Fri Jan 15 14:57:37 2010
@@ -76,7 +76,7 @@
 <!--  BEGIN: layout/html/jetspeed/decorator.vm -->
 <!-- Page Action Bar -->
 #if ($request.getUserPrincipal())
-<span class="layout-statusarea"><b>$jetspeed.getUserAttributes().get("user.name.given")
$jetspeed.getUserAttributes().get("user.name.family")</b> | Profile | Tasks (5) | Notifications
(2) | <a href="#BaseHref()login/logout">Log out</a></span>
+<span class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","")
$jetspeed.getUserAttribute("user.name.family", ${request.userPrincipal.name})</b> |
Profile | Tasks (5) | Notifications (2) | <a href="#BaseHref()login/logout">Log out</a></span>
 #end
 #if (!$jetspeed.isAjaxCustomizationEnabled())
 #PageActionBar()

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/purpleplanet/header.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/purpleplanet/header.vm?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/purpleplanet/header.vm
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/purpleplanet/header.vm
Fri Jan 15 14:57:37 2010
@@ -76,7 +76,7 @@
 <!--  BEGIN: layout/html/jetspeed/decorator.vm -->
 <!-- Page Action Bar -->
 #if ($request.getUserPrincipal())
-<span class="layout-statusarea"><b>$jetspeed.getUserAttributes().get("user.name.given")
$jetspeed.getUserAttributes().get("user.name.family")</b> | Profile | Tasks (5) | Notifications
(2) | <a href="#BaseHref()login/logout">Log out</a></span>
+<span class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","")
$jetspeed.getUserAttribute("user.name.family", ${request.userPrincipal.name})</b> |
Profile | Tasks (5) | Notifications (2) | <a href="#BaseHref()login/logout">Log out</a></span>
 #end
 #if (!$jetspeed.isAjaxCustomizationEnabled())
 #PageActionBar()

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/turbo/header.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/turbo/header.vm?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/turbo/header.vm
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/layout/turbo/header.vm
Fri Jan 15 14:57:37 2010
@@ -76,7 +76,7 @@
 <!--  BEGIN: layout/html/jetspeed/decorator.vm -->
 <!-- Page Action Bar -->
 #if ($request.getUserPrincipal())
-<span class="layout-statusarea"><b>$jetspeed.getUserAttributes().get("user.name.given")
$jetspeed.getUserAttributes().get("user.name.family")</b> | Profile | Tasks (5) | Notifications
(2) | <a href="#BaseHref()login/logout">Log out</a></span>
+<span class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","")
$jetspeed.getUserAttribute("user.name.family", ${request.userPrincipal.name})</b> |
Profile | Tasks (5) | Notifications (2) | <a href="#BaseHref()login/logout">Log out</a></span>
 #end
 #if (!$jetspeed.isAjaxCustomizationEnabled())
 #PageActionBar()

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
Fri Jan 15 14:57:37 2010
@@ -905,22 +905,25 @@
         return this.ajaxCustomization;
     }
 
-    public Map getUserAttributes()
+    public Map<String,String> getUserAttributes()
     {
         RequestContext rc = getRequestContext();
-        Map map = null;
+        Map<String,String> map = null;
         Principal principal = rc.getRequest().getUserPrincipal();
         if (principal instanceof UserSubjectPrincipal)
         {
             UserSubjectPrincipal jp = (UserSubjectPrincipal)principal;
             map = jp.getUser().getInfoMap();
-            if (map.get("user.name.given") == null)
-                map.put("user.name.given", "");
-            if (map.get("user.name.family") == null)
-                map.put("user.name.family", jp.getName());            
         }
         return map;
     }
+    
+    public String getUserAttribute(String attributeName, String defaultValue)
+    {
+        Map<String,String> infoMap = getUserAttributes();
+        String value = infoMap != null ? infoMap.get(attributeName) : null;
+        return value != null ? value : defaultValue;
+    }
 
     public PortalConfiguration getPortalConfiguration()
     {

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/JetspeedPowerTool.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/JetspeedPowerTool.java?rev=899650&r1=899649&r2=899650&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/JetspeedPowerTool.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/JetspeedPowerTool.java
Fri Jan 15 14:57:37 2010
@@ -279,7 +279,15 @@
      */
     boolean isAjaxCustomizationEnabled();
     
-    Map getUserAttributes();
+    /**
+     * @return an unmodifiable Map of the User "info" attributes or null if not authenticated
+     */
+    Map<String,String> getUserAttributes();
+    
+    /**
+     * @return the value for the User "info" attribute or the provided defaultValue if not
authenticated or if the attribute is undefined
+     */
+    String getUserAttribute(String attributeName, String defaultValue);
     
     PortalConfiguration getPortalConfiguration();
     



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message