Author: channa
Date: Fri Dec 14 04:26:40 2007
New Revision: 11134

Log:

Added user management (edit and delete) functionality.

Added:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
   trunk/mashup/java/modules/www/org/delete_user.jsp
   trunk/mashup/java/modules/www/org/manage_users.jsp
Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/AddUserBean.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
   
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   trunk/mashup/java/modules/www/org/add_user.jsp
   trunk/mashup/java/modules/www/org/user.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/AddUserBean.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/AddUserBean.java
      (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/AddUserBean.java
      Fri Dec 14 04:26:40 2007
@@ -15,23 +15,26 @@
  */
 package org.wso2.mashup.webapp.userprofile;
 
-import org.wso2.usermanager.Realm;
-import org.wso2.usermanager.UserStoreAdmin;
-import org.wso2.usermanager.AccessControlAdmin;
-import org.wso2.usermanager.UserManagerException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.mashup.MashupConstants;
+import org.wso2.mashup.webapp.utils.RegistryUtils;
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.RegistryException;
-import org.wso2.registry.secure.SecureRegistry;
-import org.wso2.registry.secure.RegistryUserManager;
+import org.wso2.registry.Resource;
 import org.wso2.registry.jdbc.JDBCRegistry;
-import org.wso2.mashup.MashupConstants;
-import org.wso2.mashup.webapp.utils.RegistryUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.wso2.registry.secure.RegistryUserManager;
+import org.wso2.registry.secure.SecureRegistry;
+import org.wso2.usermanager.AccessControlAdmin;
+import org.wso2.usermanager.Realm;
+import org.wso2.usermanager.UserManagerException;
+import org.wso2.usermanager.UserStoreAdmin;
+import org.wso2.usermanager.UserStoreReader;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Hashtable;
+import java.util.Map;
 
 /**
  * Captures submitted new user information, validates mandatory fields and 
creates user.
@@ -45,7 +48,6 @@
     private String password;
     private String bio;
     private Hashtable errors;
-    private boolean valid;
 
     public String getUserName() {
         return userName;
@@ -94,35 +96,69 @@
      * @return true if user creation succeeded.
      */
     public boolean addUser(HttpServletRequest request) {
-        valid = true;
-        
-        if (userName.equals("")) {
-            errors.put("userName", "User name cannot be empty.");
-            userName = "";
-            valid = false;
-        }
+        boolean success = isValid();
 
-        if (formalName.equals("")) {
-            errors.put("formalName", "Formal name cannot be empty.");
-            formalName = "";
-            valid = false;
+        // If all input is valid attempt to create user. If that fails, 
indicate.
+        if (success) {
+            if (!createUser(request)) {
+                errors.put("exception", "Error adding user.");
+            } else {
+                success = true;
+            }
         }
+        return success;
+    }
 
-        if (password.equals("")) {
-            errors.put("password", "Password cannot be empty.");
-            password = "";
-            valid = false;
+    /**
+     * Retrieves information stored in user manager and registry, then assigns 
to bean properties.
+     *
+     * @param request  Servlet request object.
+     * @param userName Name of user for whom details are to be loaded.
+     */
+    public void loadUserDetails(HttpServletRequest request, String userName) {
+        ServletContext context = request.getSession().getServletContext();
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        JDBCRegistry registry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+        this.userName = userName;
+        try {
+            // Get an instance of the secure registry as admin, in order to 
retrieve profile.
+            SecureRegistry secureRegistry = new 
SecureRegistry(RegistryConstants.ADMIN_USER,
+                                                               
MashupConstants.ADMIN_PASSWORD,
+                                                               registry, 
realm);
+            // Get profile values.
+            User userProfile = RegistryUtils.getUserProfile(userName, 
secureRegistry);
+            emailId = userProfile.getEmailAddress();
+            bio = userProfile.getBio();
+
+            // Get propertes
+            Map userProperties = 
realm.getUserStoreReader().getUserProperties(userName);
+            formalName = (String) 
userProperties.get(MashupConstants.FORMAL_NAME);
+        } catch (UserManagerException e) {
+            log.error("Error adding user in user manager", e);
+        } catch (RegistryException e) {
+            log.error("Error adding user resources", e);
         }
+    }
+
+    /**
+     * Validates changed information and attempts to update user details.
+     *
+     * @param request Servlet request object.
+     * @return true if user creation succeeded.
+     */
+    public boolean editUser(HttpServletRequest request) {
+        boolean success = isValid();
 
         // If all input is valid attempt to create user. If that fails, 
indicate.
-        if (valid) {
-            if (!createUser(request)) {
-                errors.put("exception", "Error adding user.");
+        if (success) {
+            if (!updateUser(request)) {
+                errors.put("exception", "Error updating user details.");
             } else {
-                valid = true;
+                success = true;
             }
         }
-        return valid;
+        return success;
     }
 
     /**
@@ -139,6 +175,7 @@
 
     /**
      * Return any added error messages.
+     *
      * @param key Key to identify error.
      * @return Message associated with key, if it exists.
      */
@@ -181,4 +218,66 @@
         }
         return created;
     }
+
+    /**
+     * Attempts to update information in the user manager, including resetting 
the password.
+     *
+     * @param request Servlet request object.
+     * @return true if user info update succeeded.
+     */
+    private boolean updateUser(HttpServletRequest request) {
+        boolean created = false;
+        ServletContext context = request.getSession().getServletContext();
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        JDBCRegistry registry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+
+        try {
+            // Get an instance of the secure registry as admin and then get 
it's user manager.
+            SecureRegistry secureRegistry = new 
SecureRegistry(RegistryConstants.ADMIN_USER,
+                                                               
MashupConstants.ADMIN_PASSWORD,
+                                                               registry, 
realm);
+            RegistryUserManager registryUserManager = 
secureRegistry.getUserManager();
+            UserStoreAdmin userStoreAdmin = realm.getUserStoreAdmin();
+
+            // Create the user in the user manager and the profile in the 
registry.
+            // todo: need way for admin to reset password without knowing 
previous one.
+            userStoreAdmin.updateUser(userName, password, password);
+            RegistryUtils.updateUser(registry, registryUserManager, userName, 
formalName, emailId,
+                                     bio);
+            created = true;
+        } catch (UserManagerException e) {
+            log.error("Error adding user in user manager", e);
+        } catch (RegistryException e) {
+            log.error("Error adding user resources", e);
+        }
+        return created;
+    }
+
+    /**
+     * Validates the information in mandatory fields.
+     *
+     * @return true if validation is successful.
+     */
+    private boolean isValid() {
+        boolean valid = true;
+        if (userName.equals("")) {
+            errors.put("userName", "User name cannot be empty.");
+            userName = "";
+            valid = false;
+        }
+
+        if (formalName.equals("")) {
+            errors.put("formalName", "Formal name cannot be empty.");
+            formalName = "";
+            valid = false;
+        }
+
+        if (password.equals("")) {
+            errors.put("password", "Password cannot be empty.");
+            password = "";
+            valid = false;
+        }
+        return valid;
+    }
 }

Added: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
==============================================================================
--- (empty file)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ManageUsers.java
      Fri Dec 14 04:26:40 2007
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      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.
+ */
+package org.wso2.mashup.webapp.userprofile;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.mashup.MashupConstants;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.jdbc.JDBCRegistry;
+import org.wso2.registry.secure.RegistryUserManager;
+import org.wso2.registry.secure.SecureRegistry;
+import org.wso2.usermanager.Realm;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ManageUsers {
+    private static final Log log = LogFactory.getLog(ManageUsers.class);
+
+    /**
+     * Gets a hashmap containing the formal names of all users registered on 
the mashup server, keyed by
+     * user name.
+     * @param request Servlet request object.
+     * @return Map of user names.
+     */
+    public static Map getAllUsers(HttpServletRequest request) {
+        Map userMap = new HashMap();
+        ServletContext context = request.getSession().getServletContext();
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        JDBCRegistry registry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+
+        try {
+            // Get an instance of the secure registry as admin and then get 
it's user manager.
+            SecureRegistry secureRegistry = new 
SecureRegistry(RegistryConstants.ADMIN_USER,
+                                                               
MashupConstants.ADMIN_PASSWORD,
+                                                               registry, 
realm);
+            RegistryUserManager registryUserManager = 
secureRegistry.getUserManager();
+            String[] allUsers = registryUserManager.getAllUsers();
+            for (int userCount = 0; userCount < allUsers.length; userCount++) {
+                String formalName = 
registryUserManager.getUserProperty(allUsers[userCount],
+                                                                    
MashupConstants.FORMAL_NAME);
+                userMap.put(allUsers[userCount], formalName);
+            }
+        } catch (RegistryException e) {
+            log.error("Error retrieving user list", e);
+        }
+        return userMap;
+    }
+
+    /**
+     * Returns a list of registered user names.
+     * @param request Servlet request object.
+     * @return String array of user names.
+     */
+    public static String[] getAllUserNames(HttpServletRequest request) {
+        String [] allUserNames = null;
+        ServletContext context = request.getSession().getServletContext();
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        JDBCRegistry registry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+
+        try {
+            // Get an instance of the secure registry as admin and then get 
it's user manager.
+            SecureRegistry secureRegistry = new 
SecureRegistry(RegistryConstants.ADMIN_USER,
+                                                               
MashupConstants.ADMIN_PASSWORD,
+                                                               registry, 
realm);
+            RegistryUserManager registryUserManager = 
secureRegistry.getUserManager();
+            allUserNames = registryUserManager.getAllUsers();
+        } catch (RegistryException e) {
+            log.error("Error retrieving user list", e);
+        }
+        return allUserNames;
+    }
+
+    /**
+     * Removes a given user from the registry user manager.
+     * @param request Servlet request object.
+     * @param userName Identifier of user to be deleted.
+     * @return true if deletion succeeded.
+     */
+    public static boolean deleteUser(HttpServletRequest request, String 
userName) {
+        boolean deletionSuccess = false;
+        ServletContext context = request.getSession().getServletContext();
+        Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+        JDBCRegistry registry =
+                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+
+        try {
+            // Get an instance of the secure registry as admin and then get 
it's user manager.
+            SecureRegistry secureRegistry = new 
SecureRegistry(RegistryConstants.ADMIN_USER,
+                                                               
MashupConstants.ADMIN_PASSWORD,
+                                                               registry, 
realm);
+            RegistryUserManager registryUserManager = 
secureRegistry.getUserManager();
+            registryUserManager.removeUser(userName);
+            deletionSuccess = true;
+        } catch (RegistryException e) {
+            log.error("Error retrieving user list", e);
+        }
+        return deletionSuccess;
+    }
+}

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  Fri Dec 14 04:26:40 2007
@@ -492,4 +492,36 @@
             deploymentEngine.setDirectoryToExtensionMappingMap(newMap);
         }
     }
+
+    /**
+     * Updates information for a given user in the user manager and the 
registry.
+     *
+     * @param registry     Instance of the JDBC registry.
+     * @param userManager  Registry user manager instance.
+     * @param userName     Name of user to add to registry.
+     * @param formalName   Formal name of user.
+     * @param eMailId      User's e-mail ID.
+     * @param bio          User's bio.
+     * @throws UserManagerException
+     * @throws RegistryException
+     */
+    public static void updateUser(JDBCRegistry registry, RegistryUserManager 
userManager,
+                                  String userName, String formalName, String 
eMailId, String bio)
+            throws UserManagerException, RegistryException {
+
+        // Add some predefined queries for the new user.
+        String profilePath = "/users/" + userName + "/profile";
+        userManager.setUserProperty(userName, MashupConstants.FORMAL_NAME, 
formalName);
+
+        // Create instance of user object and assign property values.
+        User user = new User();
+        user.setEmailAddress(eMailId);
+        user.setUsername(userName);
+        user.setBio(bio);
+
+        // Add profile as a new registry resource.
+        Resource userProfile = registry.get(profilePath);
+        userProfile.setContent(user.serializeUserProfile().getBytes());
+        registry.put(profilePath, userProfile);
+    }
 }

Modified: 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
==============================================================================
--- 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   (original)
+++ 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   Fri Dec 14 04:26:40 2007
@@ -810,6 +810,8 @@
                 // Create the admin user profile.
                 RegistryUtils.createUser(registry, userManager, ac, us, 
RegistryConstants.ADMIN_USER,
                            "Administrator", "none", "System administrator");
+                // Assign admin user the 'admin' role.
+                us.addUserToRole(RegistryConstants.ADMIN_USER, 
RegistryConstants.ADMIN_ROLE);
 
                 // Create the system user profile.
                 RegistryUtils.createUser(registry, userManager, ac, us, 
MashupConstants.SYSTEM_USER,

Modified: trunk/mashup/java/modules/www/org/add_user.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/add_user.jsp      (original)
+++ trunk/mashup/java/modules/www/org/add_user.jsp      Fri Dec 14 04:26:40 2007
@@ -51,7 +51,9 @@
 <%@ page import="java.util.List" %>
 <%@ page import="java.util.Map" %>
 <%
-    String firstcall = request.getParameter("firstcall");
+    String firstCall = request.getParameter("firstcall");
+    String userName = request.getParameter("username");
+    String editMode = request.getParameter("editmode");
     Registry registry = RegistryUtils.getRegistry(request);
     String bounceback = request.getParameter("bounceback");
     if (bounceback == null) {
@@ -65,9 +67,19 @@
     <jsp:setProperty name="addUserHandler" property="*"/>
 </jsp:useBean>
 <%
-    if (!"true".equals(firstcall)) {
-        if (addUserHandler.addUser(request)) {
-            response.sendRedirect(bounceback);
+    if (!"true".equals(firstCall)) {
+        if ("true".equals(editMode)) {
+            if (addUserHandler.editUser(request)) {
+                response.sendRedirect(bounceback);
+            }
+        } else {
+            if (addUserHandler.addUser(request)) {
+                response.sendRedirect(bounceback);
+            }
+        }
+    } else {
+        if ("true".equals(editMode)) {
+            addUserHandler.loadUserDetails(request, userName);
         }
     }
 %>
@@ -93,35 +105,42 @@
                 <td>
                     <form name="formAddUser" method='post' 
action="add_user.jsp">
                         <input type="hidden" name="bounceback" 
value="<%=bounceback%>"/>
+                        <input type="hidden" name="editmode" 
value="<%=editMode%>"/>
                         <table width="100%" border="0" cellspacing="0" 
cellpadding="3">
                             <tr>
                                 <td width="130"><label><strong>User 
Name:</strong></label></td>
-                                <td><input type="text" name="userName" 
value="<%=addUserHandler.getUserName()%>"/>
+                                <td><input type="text" name="userName"
+                                           
value="<%=addUserHandler.getUserName()%>"/>
                                     
<br><%=addUserHandler.getErrorMessage("userName")%>
                                 </td>
                             </tr>
                             <tr>
                                 <td width="130"><label><strong>Formal 
Name:</strong></label></td>
-                                <td><input type="text" name="formalName" 
value="<%=addUserHandler.getFormalName()%>"/>
-                                     
<br><%=addUserHandler.getErrorMessage("formalName")%>
+                                <td><input type="text" name="formalName"
+                                           
value="<%=addUserHandler.getFormalName()%>"/>
+                                    
<br><%=addUserHandler.getErrorMessage("formalName")%>
                                 </td>
                             </tr>
                             <tr>
                                 <td 
width="130"><label><strong>E-mail:</strong></label></td>
-                                <td><input type="text" name="emailId" 
value="<%=addUserHandler.getEmailId()%>"/></td>
+                                <td><input type="text" name="emailId"
+                                           
value="<%=addUserHandler.getEmailId()%>"/></td>
                             </tr>
                             <tr>
                                 
<td><label><strong>Password:</strong></label></td>
-                                <td><input type="password" name="password" 
value="<%=addUserHandler.getPassword()%>"/>
-                                     
<br><%=addUserHandler.getErrorMessage("password")%>
+                                <td><input type="password" name="password"
+                                           
value="<%=addUserHandler.getPassword()%>"/>
+                                    
<br><%=addUserHandler.getErrorMessage("password")%>
                                 </td>
                             </tr>
                             <tr>
                                 <td><label><strong>Bio:</strong></label></td>
-                                <td><input type="text" name="bio" 
value="<%=addUserHandler.getBio()%>"/></td>
+                                <td><input type="text" name="bio"
+                                           
value="<%=addUserHandler.getBio()%>"/></td>
                             </tr>
                             <tr>
-                                
<td><%=addUserHandler.getErrorMessage("exception")%></td>
+                                
<td><%=addUserHandler.getErrorMessage("exception")%>
+                                </td>
                             </tr>
                             <tr>
                                 <td>&nbsp;</td>

Added: trunk/mashup/java/modules/www/org/delete_user.jsp
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/www/org/delete_user.jsp   Fri Dec 14 04:26:40 2007
@@ -0,0 +1,103 @@
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+--%>
+<%@ page import="org.wso2.mashup.webapp.userprofile.ManageUsers" %>
+<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
+<%@ page import="org.wso2.registry.Registry" %>
+<%@ page import="java.net.URLDecoder" %>
+<%
+    String firstcall = request.getParameter("firstcall");
+    String userName = request.getParameter("username");
+    String formalName = request.getParameter("formalname");
+    String message = "Confirm User Deletion";
+    Registry registry = RegistryUtils.getRegistry(request);
+    String bounceback = request.getParameter("bounceback");
+    boolean deletionFailed = false;
+
+    if (bounceback == null) {
+        bounceback = "index.jsp";
+    } else {
+        bounceback = URLDecoder.decode(bounceback, "UTF-8");
+    }
+    if (!"true".equals(firstcall)) {
+        if (RegistryUtils.isAdminRole(registry)) {
+            if (ManageUsers.deleteUser(request, userName)) {
+                response.sendRedirect(bounceback);
+            } else {
+                message = "User Deletion Failed";
+                deletionFailed = true;
+            }
+        } else {
+            message = "You are not authorized to delete users!";
+            deletionFailed = true;
+        }
+    }
+%>
+<html>
+<head>
+    <title>Mashups.wso2.org</title>
+    <!-- Required CSS -->
+    <link href="css/styles.css" rel="stylesheet" type="text/css"/>
+    <script language="javascript" src="js/common.js" 
type="text/javascript"></script>
+    <script language="javascript"
+            type="text/javascript">userLoggedOn = 
<%=RegistryUtils.isLoggedIn(registry) %>;</script>
+</head>
+<body>
+<div id="page">
+    <% String thisPage = "registration_result.jsp"; %>
+    <%@ include file="header.jsp" %>
+    <div id="content">
+        <table width="100%" height="400" border="0" cellspacing="0" 
cellpadding="5">
+            <tr>
+                <th><label><%= message %>
+                </label></th>
+            </tr>
+            <tr>
+                <td>
+                    <form name="formDeleteUser" method='post' 
action="delete_user.jsp">
+                        <input type="hidden" name="bounceback" 
value="<%=bounceback%>"/>
+                        <input type="hidden" name="username" 
value="<%=userName%>"/>
+                        <table width="100%" border="0" cellspacing="0" 
cellpadding="3">
+                            <tr>
+                                <td width="130"><label><strong>Deleting 
User:</strong></label></td>
+                                <td><label><%= userName %>
+                                </label>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td width="130"><label><strong>Formal 
Name:</strong></label></td>
+                                <td><label><%= formalName %>
+                                </label>
+                                </td>
+                            </tr>
+                            <tr>
+                                <% if (deletionFailed) { %>
+                                You may return to the page you were on using 
this <a
+                                    
href="<%=URLEncoder.encode(bounceback,"UTF-8")%>">link</a>.
+                                <% } else { %>
+                                <td><input type="submit" value="Delete"/></td>
+                                <td><input type="button" value="Cancel" 
onclick="document.location = '<%= bounceback %>';"></td>
+                                <% } %>
+                            </tr>
+                        </table>
+                    </form>
+                </td>
+            </tr>
+        </table>
+    </div>
+    <%@ include file="footer.jsp" %>
+</div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/mashup/java/modules/www/org/manage_users.jsp
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/www/org/manage_users.jsp  Fri Dec 14 04:26:40 2007
@@ -0,0 +1,110 @@
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+--%>
+<%@ page import="com.sun.syndication.feed.synd.SyndContent" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndContentImpl" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntry" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntryImpl" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeed" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeedImpl" %>
+<%@ page import="com.sun.syndication.io.SyndFeedOutput" %>
+<%@ page import="org.wso2.mashup.MashupConstants" %>
+<%@ page import="org.wso2.mashup.utils.QueryResult" %>
+<%@ page import="org.wso2.mashup.utils.QueryResults" %>
+<%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler" %>
+<%@ page import="org.wso2.mashup.webapp.identity.Registration" %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.ManageUsers" %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.User" %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.UserQuery" %>
+<%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils" %>
+<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
+<%@ page import="org.wso2.registry.Comment" %>
+<%@ page import="org.wso2.registry.Registry" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
+<%@ page import="org.wso2.registry.RegistryException" %>
+<%@ page import="org.wso2.registry.Resource" %>
+<%@ page import="org.wso2.registry.Tag" %>
+<%@ page import="org.wso2.registry.jdbc.JDBCRegistry" %>
+<%@ page import="org.wso2.registry.secure.SecureRegistry" %>
+<%@ page import="org.wso2.usermanager.Realm" %>
+<%@ page import="org.wso2.usermanager.UserManagerException" %>
+<%@ page import="javax.servlet.ServletContext" %>
+<%@ page import="java.net.URL" %>
+<%@ page import="java.net.URLDecoder" %>
+<%@ page import="java.util.ArrayList" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="java.util.List" %>
+<%@ page import="java.util.Map" %>
+<%
+    Registry registry = RegistryUtils.getRegistry(request);
+    String bounceback = request.getParameter("bounceback");
+    if (bounceback == null) {
+        bounceback = "index.jsp";
+    } else {
+        bounceback = URLDecoder.decode(bounceback, "UTF-8");
+    }
+    Map users = ManageUsers.getAllUsers(request);
+    String [] keys = ManageUsers.getAllUserNames(request);
+%>
+<html>
+<head>
+    <title>Mashups.wso2.org</title>
+    <!-- Required CSS -->
+    <link href="css/styles.css" rel="stylesheet" type="text/css"/>
+    <script language="javascript" src="js/common.js" 
type="text/javascript"></script>
+    <script language="javascript"
+            type="text/javascript">userLoggedOn = 
<%=RegistryUtils.isLoggedIn(registry) %>;</script>
+</head>
+<body>
+<div id="page">
+    <% String thisPage = "manage_users.jsp"; %>
+    <%@ include file="header.jsp" %>
+    <div id="search"></div>
+    <div id="content">
+        <table width="100%" border="0" class="box" cellspacing="0" 
cellpadding="0">
+            <tr>
+                <th><label>Manage Users</label></th>
+            </tr>
+            <tr>
+                <td>
+                    <table width="100%" border="1" class="box" cellspacing="0" 
cellpadding="0">
+                        <tr>
+                            <th>User</th>
+                            <th>Edit</th>
+                            <th>Delete</th>
+                        </tr>
+                        <%  for (int userCount = 0; userCount < keys.length; 
userCount++) {
+                            if (users.containsKey(keys[userCount])) {
+                            String formalName = (String) 
users.get(keys[userCount]);
+                        %>
+                        <tr>
+                            <td><%= formalName %></td>
+                            <td><a 
href="add_user.jsp?username=<%=keys[userCount]%>&editmode=true&firstcall=true">Edit</a></td>
+                            <td><a href="delete_user.jsp?username=<%= 
URLEncoder.encode(keys[userCount],"UTF-8") %>&formalname=<%= formalName 
%>&firstcall=true">Delete</a></td>
+                        </tr>
+                        <% }
+                        }%>
+                    </table>
+                </td>
+            </tr>
+        </table>
+        <br>
+        <br>
+    </div>
+    <%@ include file="footer.jsp" %>
+</div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/mashup/java/modules/www/org/user.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/user.jsp  (original)
+++ trunk/mashup/java/modules/www/org/user.jsp  Fri Dec 14 04:26:40 2007
@@ -191,16 +191,17 @@
                     <li>
                         <a href="#">Add virtual directory**</a>
                     </li>
+                    <% if (RegistryUtils.isAdminRole(registry)) { %>
                     <li>
-                        <a href="add_user.jsp?firstcall=true">Add user**</a>
+                        <a href="add_user.jsp?firstcall=true">Add User</a>
                     </li>
                     <li>
-                        <a href="#">Allow internet guests**</a>
+                        <a href="manage_users.jsp">Manage Users</a>
                     </li>
+                    <% } %>
                     <li>
-                        <a href="#">Delete user** ***</a>
+                        <a href="#">Allow internet guests**</a>
                     </li>
-
                     <!--Will only be available for logged in users-->
                     <% if (RegistryUtils.isLoggedIn(registry)) { %>
                     <li>

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

Reply via email to