esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r882737 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/AccessPoolMgr.scala model/Privilege.scala
Date Fri, 20 Nov 2009 22:20:14 GMT
Author: vdichev
Date: Fri Nov 20 22:20:13 2009
New Revision: 882737

URL: http://svn.apache.org/viewvc?rev=882737&view=rev
Log:
ESME-69 Modified deletion of a user from a pool using another permission type

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.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=882737&r1=882736&r2=882737&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 Fri
Nov 20 22:20:13 2009
@@ -176,7 +176,7 @@
      case d => Text(dateFormat.format(d))
    }
     
-    def disPlayUserName(uid: Long): NodeSeq = {
+    def displayUserName(uid: Long): NodeSeq = {
       User.find(uid) match {
         case Full(user) => <span>{user.nickname}</span>
         case _ => NodeSeq.Empty
@@ -188,9 +188,9 @@
         case Full(ap) => bind(
         "pool", in,
         "name" -> ap.getName,     
-        "creator" -> disPlayUserName(ap.creator),
+        "creator" -> displayUserName(ap.creator),
         "createdDate" -> getDateHtml(ap.createdDate),
-        "modifier" -> disPlayUserName(ap.modifier),
+        "modifier" -> displayUserName(ap.modifier),
         "lastModifyDate" -> getDateHtml(ap.lastModifyDate))
       case _ => NodeSeq.Empty
       }
@@ -206,40 +206,17 @@
     // get the current user
     val user = User.currentUser
 
-    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)
-    }
-    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
-    }
+      // Distributor ! Distributor.RefreshUser(userId)
     def doRender(): NodeSeq = {
     val accessPool = AccessPool.find(By(AccessPool.id, poolId.is))  
-    Privilege.findAll(By(Privilege.pool, poolId.is)) match {
+    Privilege.findAll(By(Privilege.pool, poolId.is), NotBy(Privilege.permission, Permission.Denied))
match {
       case Nil => NodeSeq.Empty
       case xs => bind("pool", in,
                       "user" -> 
                       (lst => xs.flatMap(i => bind("user", lst,
                                                    "name" -> User.find(i.user).map(
                                                              _.nickname.is).getOrElse(""),
-                                                   "privilege" -> i.permission.is.toString,
-                                                   "operations" -> operationLinks(i) 

+                                                   "privilege" -> i.permission.is.toString
                       ))))
     }
     }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala?rev=882737&r1=882736&r2=882737&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala Fri Nov
20 22:20:13 2009
@@ -59,12 +59,14 @@
   
   def findViewablePools(userId: Long): Set[Long] =
   Set(Privilege.findMap(
-    By(Privilege.user, userId)
+    By(Privilege.user, userId),
+    NotBy(Privilege.permission, Permission.Denied)
   )(p => Full(p.pool.is)) :_*)
 
   def findWritablePools(userId: Long): Set[Long] = Set(Privilege.findMap(
     By(Privilege.user, userId),
-    NotBy(Privilege.permission, Permission.Read)
+    NotBy(Privilege.permission, Permission.Read),
+    NotBy(Privilege.permission, Permission.Denied)
   )(p => Full(p.pool.is)) :_*)
 
   def findAdminPools(userId: Long): Set[Long] = Set(Privilege.findMap(
@@ -92,5 +94,6 @@
   val Read = Value(0, "Read")
   val Write = Value(1, "Write")
   val Admin = Value(2, "Admin")
+  val Denied = Value(3, "Denied")
 }
 



Mime
View raw message