Author: channa
Date: Fri Jan 18 03:12:48 2008
New Revision: 12475

Log:

Added user reactivation ability, renaming value object to avoid conflict.

Added:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
      - copied, changed from r12468, 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInfo.java
   trunk/mashup/java/modules/www/images/user_enable.gif   (contents, props 
changed)
Removed:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInfo.java
Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
   trunk/mashup/java/modules/www/delete_user.jsp
   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
      Fri Jan 18 03:12:48 2008
@@ -55,9 +55,9 @@
                         .get(MashupConstants.FULL_NAME);
                 // If the full name is available, use it, otherwise just show 
the user name.
                 fullName = fullName != null ? fullName : allUsers[userCount];
-                UserInfo userInfo = new UserInfo(fullName, 
isUserActive(registry,
+                UserInformation userInformation = new 
UserInformation(fullName, isUserActive(registry,
                                allUsers[userCount]), isUserDeletable(realm, 
allUsers[userCount]));
-                userMap.put(allUsers[userCount], userInfo);
+                userMap.put(allUsers[userCount], userInformation);
             }
         } catch (UserManagerException e) {
             log.error("User manager error retrieving user list", e);

Copied: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
 (from r12468, 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInfo.java)
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInfo.java
 (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
  Fri Jan 18 03:12:48 2008
@@ -18,12 +18,12 @@
 /**
  * Value object used to populate manage user page contents.
  */
-public class UserInfo {
+public class UserInformation {
     private boolean userActive;
     private boolean userDeletable;
     private String fullName;
 
-    public UserInfo(String userFullName, boolean userActive, boolean 
userDeleteable) {
+    public UserInformation(String userFullName, boolean userActive, boolean 
userDeleteable) {
         this.userActive = userActive;
         this.userDeletable = userDeleteable;
         this.fullName = userFullName;

Modified: trunk/mashup/java/modules/www/delete_user.jsp
==============================================================================
--- trunk/mashup/java/modules/www/delete_user.jsp       (original)
+++ trunk/mashup/java/modules/www/delete_user.jsp       Fri Jan 18 03:12:48 2008
@@ -24,11 +24,12 @@
 
 <%
     String firstcall = request.getParameter("firstcall");
+    String reactivate = request.getParameter("reactivate");
     String userName = request.getParameter("username");
     String fullName = request.getParameter("fullname");
     String message = "Confirm User Deletion";
     String bounceback = request.getParameter("bounceback");
-    boolean deletionFailed = false;
+    boolean actionFailed = false;
 
     if (bounceback == null) {
         bounceback = "index.jsp";
@@ -51,19 +52,28 @@
                     response.sendRedirect(bounceback);
                 } else {
                     message = "User Deletion Failed";
-                    deletionFailed = true;
+                    actionFailed = true;
                 }
             } else {
-                if (ManageUsers.setUserActiveStatus(request, userName, false)) 
{
-                    response.sendRedirect(bounceback);
+                if ("true".equals(reactivate)) {
+                    if (ManageUsers.setUserActiveStatus(request, userName, 
true)) {
+                        response.sendRedirect(bounceback);
+                    } else {
+                        message = "Could not reactivate user profile.";
+                        actionFailed = true;
+                    }
                 } else {
-                    message = "Could not disable user profile.";
-                    deletionFailed = true;
+                    if (ManageUsers.setUserActiveStatus(request, userName, 
false)) {
+                        response.sendRedirect(bounceback);
+                    } else {
+                        message = "Could not disable user profile.";
+                        actionFailed = true;
+                    }
                 }
             }
         } else {
-            message = "You are not authorized to delete users!";
-            deletionFailed = true;
+            message = "You are not authorized to manage users!";
+            actionFailed = true;
         }
     }
 %>
@@ -102,7 +112,7 @@
                                 <td><input type="checkbox" name="purge" 
value="true"/></td>
                             </tr>
                             <tr>
-                                <% if (deletionFailed) { %>
+                                <% if (actionFailed) { %>
                                 You may return to the page you were on using 
this <a
                                     href="<%=bounceback%>">link</a>.
                                 <% } else { %>

Added: trunk/mashup/java/modules/www/images/user_enable.gif
==============================================================================
Binary file. No diff available.

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      Fri Jan 18 03:12:48 2008
@@ -28,7 +28,7 @@
 <%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler" %>
 <%@ page import="org.wso2.mashup.webapp.identity.RegistrationBean" %>
 <%@ page import="org.wso2.mashup.webapp.userprofile.ManageUsers" %>
-<%@ page import="org.wso2.mashup.webapp.userprofile.UserInfo" %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.UserInformation" %>
 <%@ page import="org.wso2.mashup.webapp.userprofile.UserQuery" %>
 <%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils" %>
 <%@ page import="org.wso2.registry.Comment" %>
@@ -54,6 +54,10 @@
 <%@ include file="validate_login.jsp" %>
 
 <%
+    if (!RegistryUtils.isAdminRole(registry)) {
+        response.sendRedirect("index.jsp");
+    }
+    
     String bounceback = request.getParameter("bounceback");
     if (bounceback == null) {
         bounceback = "index.jsp";
@@ -90,14 +94,21 @@
           </tr>
           <%  for (Iterator userNames = users.keySet().iterator(); 
userNames.hasNext();) {
                    String userName =  (String) userNames.next();
-                            UserInfo userInfo = (UserInfo) users.get(userName);
+                            UserInformation userInformation = 
(UserInformation) users.get(userName);
                         %>
           <tr class="results">
-                 <td><img src="images/user.gif" align="absmiddle"></td>
-            <td><%= userInfo.getFullName() %></td>
+              <td>
+                  <% if (userInformation.isUserActive()) {%>
+                  <img src="images/user.gif" align="absmiddle">
+                  <% } else { %>
+                  <a href="delete_user.jsp?username=<%= 
URLEncoder.encode(userName,"UTF-8") %>&fullname=<%= 
URLEncoder.encode(userInformation.getFullName(),"UTF-8") 
%>&reactivate=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>"><img
+                          src="images/user_enable.gif" alt="Reactivate user" 
title="Reactivate user" border="0"></a>
+                  <% } %>
+              </td>
+              <td><%= userInformation.getFullName() %></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>
-            <% if (userInfo.isUserDeletable()) { %>
-            <td align="center"><a href="delete_user.jsp?username=<%= 
URLEncoder.encode(userName,"UTF-8") %>&fullname=<%= 
URLEncoder.encode(userInfo.getFullName(),"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>
+            <% if (userInformation.isUserDeletable()) { %>
+            <td align="center"><a href="delete_user.jsp?username=<%= 
URLEncoder.encode(userName,"UTF-8") %>&fullname=<%= 
URLEncoder.encode(userInformation.getFullName(),"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>
           <% }%>

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

Reply via email to