Author: channa
Date: Mon Jan 14 19:34:06 2008
New Revision: 12231

Log:

Improving user management code to handle exceptional situations.

Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
   trunk/mashup/java/modules/www/manage_users.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
      (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
      Mon Jan 14 19:34:06 2008
@@ -51,7 +51,13 @@
             for (int userCount = 0; userCount < allUsers.length; userCount++) {
                 String fullName = (String) 
userStoreAdmin.getUserProperties(allUsers[userCount])
                         .get(MashupConstants.FULL_NAME);
-                userMap.put(allUsers[userCount], fullName);
+
+                // If the full name is available, use it, otherwise just show 
the user name.
+                if (fullName != null) {
+                    userMap.put(allUsers[userCount], fullName);
+                } else {
+                    userMap.put(allUsers[userCount], allUsers[userCount]);
+                }
             }
         } catch (UserManagerException e) {
             log.error("User manager error retrieving user list", e);

Modified: trunk/mashup/java/modules/www/manage_users.jsp
==============================================================================
--- trunk/mashup/java/modules/www/manage_users.jsp      (original)
+++ trunk/mashup/java/modules/www/manage_users.jsp      Mon Jan 14 19:34:06 2008
@@ -58,7 +58,6 @@
         bounceback = URLDecoder.decode(bounceback, "UTF-8");
     }
     Map users = ManageUsers.getAllUsers(request);
-    String [] keys = ManageUsers.getAllUserNames(request);
 %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
 <html>
@@ -86,18 +85,17 @@
             <td width="20" align="center" class="headers" ></td>
                        <td width="20" align="center" class="headers" ></td>
           </tr>
-          <%  for (int userCount = 0; userCount < keys.length; userCount++) {
-                            if (users.containsKey(keys[userCount])) {
-                            String fullName = (String) 
users.get(keys[userCount]);
+          <%  for (Iterator userNames = users.keySet().iterator(); 
userNames.hasNext();) {
+                   String userName =  (String) userNames.next();
+                            String fullName = (String) users.get(userName);
                         %>
           <tr class="results">
                  <td><img src="images/user.gif" align="absmiddle"></td>
             <td><%= fullName %></td>
-            <td align="center"><a 
href="add_user.jsp?username=<%=keys[userCount]%>&editmode=true&firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>"><img
 src="images/edit.gif" alt="Edit user" title="Edit user" border="0"></a></td>
-            <td align="center"><a href="delete_user.jsp?username=<%= 
URLEncoder.encode(keys[userCount],"UTF-8") %>&fullname=<%= 
URLEncoder.encode(fullName,"UTF-8") 
%>&firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>"><img 
src="images/delete.gif" alt="Delete user" title="Delete user" 
border="0"></a></td>
+            <td align="center"><a 
href="add_user.jsp?username=<%=userName%>&editmode=true&firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>"><img
 src="images/edit.gif" alt="Edit user" title="Edit user" border="0"></a></td>
+            <td align="center"><a href="delete_user.jsp?username=<%= 
URLEncoder.encode(userName,"UTF-8") %>&fullname=<%= 
URLEncoder.encode(fullName,"UTF-8") 
%>&firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>"><img 
src="images/delete.gif" alt="Delete user" title="Delete user" 
border="0"></a></td>
           </tr>
-          <% }
-                        }%>
+          <% }%>
       </table>
         <br>
         <br>

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to