Author: channa
Date: Thu Jan 24 12:38:38 2008
New Revision: 12847

Log:

Removing user's profile in registry while deleting user in user manager.

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

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
      Thu Jan 24 12:38:38 2008
@@ -15,20 +15,20 @@
  */
 package org.wso2.mashup.webapp.userprofile;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.om.OMElement;
 import org.wso2.mashup.MashupConstants;
 import org.wso2.mashup.MashupFault;
 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.usermanager.Realm;
 import org.wso2.usermanager.UserManagerException;
@@ -38,7 +38,6 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -105,8 +104,10 @@
      * @param request  Servlet request object.
      * @param userName Identifier of user to be deleted.
      * @return true if deletion succeeded.
+     * @throws MashupFault on errors.
      */
-    public static boolean deleteUser(HttpServletRequest request, String 
userName) throws MashupFault {
+    public static boolean deleteUser(HttpServletRequest request, String 
userName)
+            throws MashupFault {
         boolean deletionSuccess = false;
         SecureRegistry registry =
                 (SecureRegistry) 
request.getSession().getAttribute(MashupConstants.USER_REGISTRY);
@@ -115,12 +116,22 @@
             // Check deletable - API level check for calls not validated via 
UI.
             if (isUserDeletable(realm, userName)) {
                 UserStoreAdmin userStoreAdmin = realm.getUserStoreAdmin();
+
+                // Delete user's profile in registry.
+                Map properties = userStoreAdmin.getUserProperties(userName);
+                if (properties.containsKey(MashupConstants.PROFILE_PATH)) {
+                    String profilePath = 
properties.get(MashupConstants.PROFILE_PATH).toString();
+                    registry.delete(profilePath);
+                }
+
                 userStoreAdmin.deleteUser(userName);
                 deleteUserResources(userName, request.getSession().getId());
                 deletionSuccess = true;
             }
         } catch (UserManagerException e) {
-            log.error("Error deleting user", e);
+            log.error("User manager error deleting user", e);
+        } catch (RegistryException e) {
+            log.error("Registry error deleting user", e);
         }
         return deletionSuccess;
     }
@@ -130,7 +141,6 @@
      *
      * @param userName name of user, who's resources must be deleted.
      * @return true if the purge succeeded.
-     * todo: implement removal of services and all registry based resources.
      */
     private static boolean deleteUserResources(String userName, String 
cookieString) throws MashupFault {
         boolean purgeSuccess;

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

Reply via email to