esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r829509 - /incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala
Date Sun, 25 Oct 2009 08:13:47 GMT
Author: rhirsch
Date: Sun Oct 25 08:13:47 2009
New Revision: 829509

URL: http://svn.apache.org/viewvc?rev=829509&view=rev
Log:
[ESME-87] The current access pool UI doesn't allow users to be deleted to an access pool.
Patch from Xuefeng Wu applied

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala?rev=829509&r1=829508&r2=829509&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala Sun
Oct 25 08:13:47 2009
@@ -206,21 +206,29 @@
     // get the current user
     val user = User.currentUser
 
-    def deleteUserFromPool(in: Privilege) {
-       //Delete current admin only if admin permissions by other users exist
-    if(in.permission.is == Permission.Admin ||
+    def validateDeleteUser(in: Privilege): Boolean = {
+      //Delete current admin only if admin permissions by other users exist
+      !(in.permission.is == Permission.Admin &&
       Privilege.find(By(Privilege.pool, in.pool),
         By(Privilege.permission,Permission.Admin),
         NotBy(Privilege.user, in.user)).isEmpty)
-      throw new Exception("No other admin users in pool!")
-      
+    }
+    def deleteUserFromPool(in: Privilege) {
+    if(validateDeleteUser(in)) 
+    {
       val userId = in.user.is
-
       in.delete_!
-
       Distributor ! Distributor.RefreshUser(userId)
     }
+    else 
+      throw new Exception("No other admin users in pool!")
       
+    }
+    def operationLinks(in: Privilege): NodeSeq = {
+      if (validateDeleteUser(in))
+    	  link("", () => deleteUserFromPool(in), Text("Delete"))//delete user from pool
+      else NodeSeq.Empty
+    }
     def doRender(): NodeSeq = {
     val accessPool = AccessPool.find(By(AccessPool.id, poolId.is))  
     Privilege.findAll(By(Privilege.pool, poolId.is)) match {
@@ -231,7 +239,7 @@
                                                    "name" -> User.find(i.user).map(
                                                              _.nickname.is).getOrElse(""),
                                                    "privilege" -> i.permission.is.toString,
-                                                   "operations" -> link("", () => deleteUserFromPool(i),
Text("Delete"))//delete user from pool  
+                                                   "operations" -> operationLinks(i) 

                       ))))
     }
     }



Mime
View raw message