esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r826615 - in /incubator/esme/trunk/server/src/main: scala/org/apache/esme/actor/Distributor.scala scala/org/apache/esme/actor/UserActor.scala scala/org/apache/esme/lib/AccessPoolMgr.scala webapp/pools_view/index.html
Date Mon, 19 Oct 2009 09:24:13 GMT
Author: rhirsch
Date: Mon Oct 19 09:24:12 2009
New Revision: 826615

URL: http://svn.apache.org/viewvc?rev=826615&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/actor/Distributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/AccessPoolMgr.scala
    incubator/esme/trunk/server/src/main/webapp/pools_view/index.html

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala?rev=826615&r1=826614&r2=826615&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala Mon
Oct 19 09:24:12 2009
@@ -93,6 +93,9 @@
       case AllowUserInPool(userId, poolId) =>
         findOrCreateUser(userId) ! UserActor.AllowPool(poolId)
         
+      case RefreshUser(userId) =>
+          users.get(userId).foreach(_ ! UserActor.RefreshMe(userId))
+        
       case ResendMessage(userId, msgId) =>
         findOrCreateUser(userId) ! UserActor.Resend(msgId)
 
@@ -118,6 +121,7 @@
   case class PublicTimelineListeners(who: Actor)
   case class PublicTimelineUnlisteners(who: Actor)
   case class AllowUserInPool(userId: Long, poolId: Long)
+  case class RefreshUser(userId: Long)
   case class ResendMessage(userId: Long, msgId: Long)
   sealed trait TrackingType
   case object PerformTrackingType extends TrackingType

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala?rev=826615&r1=826614&r2=826615&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala Mon Oct
19 09:24:12 2009
@@ -39,6 +39,7 @@
 
 object UserActor {
   private[actor] case class StartMeUp(user: Long)
+  private[actor] case class RefreshMe(user: Long)
   private[actor] case class CreateMessage(text: String, tags: List[String],
                                           when: Long, metaData: Box[Elem],
                                           source: String,
@@ -105,7 +106,10 @@
 
         this ! UpdateTracking(Distributor.TrackTrackingType)
         this ! UpdateTracking(Distributor.PerformTrackingType)
-
+        
+      case RefreshMe(user) => 
+         pools = Privilege.findViewablePools(user)
+         
       case RunFunc(f) =>
         f()
         

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=826615&r1=826614&r2=826615&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 Mon
Oct 19 09:24:12 2009
@@ -205,6 +205,20 @@
     // 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 ||
+      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!")
+      
+      val userId = in.user.is
+
+      in.delete_!
+
+      Distributor ! Distributor.RefreshUser(userId)
+    }
       
     def doRender(): NodeSeq = {
     val accessPool = AccessPool.find(By(AccessPool.id, poolId.is))  
@@ -215,7 +229,8 @@
                       (lst => xs.flatMap(i => bind("user", lst,
                                                    "name" -> User.find(i.user).map(
                                                              _.nickname.is).getOrElse(""),
-                                                   "privilege" -> i.permission.is.toString
+                                                   "privilege" -> i.permission.is.toString,
+                                                   "operations" -> link("", () => deleteUserFromPool(i),
Text("Delete"))//delete user from pool  
                       ))))
     }
     }

Modified: incubator/esme/trunk/server/src/main/webapp/pools_view/index.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/pools_view/index.html?rev=826615&r1=826614&r2=826615&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/pools_view/index.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/pools_view/index.html Mon Oct 19 09:24:12
2009
@@ -74,15 +74,15 @@
       <br/>
        <table border="1">
        <thead>
-          <tr> <th><lift:loc>ui_pool_list_user_name</lift:loc></th>
 <th><lift:loc>ui_pool_list_user_role</lift:loc></th> </tr>
+          <tr> <th><lift:loc>ui_pool_list_user_name</lift:loc></th>
 <th><lift:loc>ui_pool_list_user_role</lift:loc></th> <th>Actions</th></tr>
         </thead>
         
         <tbody>
           <pool:user>
-            <tr> <td><user:name/></td>  <td><user:privilege/></td>
</tr>
+            <tr> <td><user:name/></td>  <td><user:privilege/></td>
<td><user:operations/></td></tr>
           </pool:user>
         </tbody>
-      </table>
+         </table>
           <br/>   
            </fieldset>
                 <br/>



Mime
View raw message