incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r940339 - in /incubator/esme/trunk/server/src: main/scala/org/apache/esme/actor/Distributor.scala main/scala/org/apache/esme/actor/UserActor.scala main/scala/org/apache/esme/api/API2.scala test/scala/org/apache/esme/api/API2Test.scala
Date Sun, 02 May 2010 23:50:01 GMT
Author: esjewett
Date: Sun May  2 23:50:00 2010
New Revision: 940339

URL: http://svn.apache.org/viewvc?rev=940339&view=rev
Log:
[ESME-197] Respond to api2/user/message POST with full message XML including ID

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/api/API2.scala
    incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

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=940339&r1=940338&r2=940339&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 Sun
May  2 23:50:00 2010
@@ -50,8 +50,13 @@ object Distributor extends LiftActor {
                               inReplyTo,
                               pool) =>
         val toact = findOrCreateUser(user)
-        toact ! UserActor.CreateMessage(text, tags,
-                                        when, metaData, source, inReplyTo, pool)
+        // toact ! UserActor.CreateMessage(text, tags,
+        //                                when, metaData, source, inReplyTo, pool)
+		
+		forwardMessageTo(
+			UserActor.CreateMessage(text,tags,when,metaData,source,inReplyTo,pool),
+			toact)
+
         toact ! text
 
       case AddMessageToMailbox(user, message, reason) =>
@@ -72,7 +77,7 @@ object Distributor extends LiftActor {
       case nm @ NewMessage(msg) =>
         val toSend = UserActor.TestForTracking(msg)
         users.values.foreach(_ ! toSend)
-        listeners.foreach(_ ! nm)
+        listeners.foreach(_ ! nm)    
 
       case UpdateTrackingFor(userId, ttype) =>
         for (user <- users.get(userId))

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=940339&r1=940338&r2=940339&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 Sun May
 2 23:50:00 2010
@@ -129,7 +129,8 @@ class UserActor extends LiftActor {
                rtm <- Message.find(mb.message.is)) 
                  if (rtm.pool == msg.pool) msg.replyTo(rt)
 
-          msg.saveMe
+          msg.saveMe           
+
           Stats incr "userMessagesCreated"
           Stats incr "messagesCreated"
 
@@ -149,8 +150,10 @@ class UserActor extends LiftActor {
                                                 IHaveValidatedThisSQL("dpp", "Aug 27. 2008")))
                           (mb => Full(mb.user.is))).removeDuplicates)
           Distributor ! Distributor.AddMessageToMailbox(userId, msg, ConversationReason(convId))
+                                             
+          Distributor ! Distributor.NewMessage(msg)     
 
-          Distributor ! Distributor.NewMessage(msg)
+		  reply(msg)  
         }
 
       case AddToMailbox(msg, reason) =>

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala?rev=940339&r1=940338&r2=940339&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/API2.scala Sun May  2 23:50:00
2010
@@ -335,16 +335,18 @@ object API2 extends ApiHelper with XmlHe
           S.param("metadata").flatMap(md =>
             tryo(XML.loadString(md)))
 
-        Distributor !
-        Distributor.UserCreatedMessage(user, msg,
+        Distributor !! Distributor.UserCreatedMessage(user, msg,
                                        Tag.split(S.param("tags")
                                                  openOr ""),
                                        millis,
                                        xml,
                                        from,
                                        S.param("replyto").map(toLong),
-                                       pool)
-        (200,Map(),Empty)
+                                       pool) match {
+           case Full(m: Message) => (200,Map(),Full(msgToXml(m)))
+           case other => (200,Map(),Empty)
+		}
+//		(200,Map(),Empty)
       }
 
     val r: Box[Tuple3[Int,Map[String,String],Box[Elem]]] =
@@ -790,7 +792,7 @@ object API2 extends ApiHelper with XmlHe
           case _ =>
             msg match {
               case _ if msgMatch(msg) =>
-                msgs = (msg, reason) :: msgs                          
+                msgs = (msg, reason) :: msgs    
                 listener.foreach {
                   who =>
                     who.satisfy(msgs)

Modified: incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala?rev=940339&r1=940338&r2=940339&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala (original)
+++ incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala Sun May
 2 23:50:00 2010
@@ -354,8 +354,10 @@ object Api2Specs extends Specification w
             "pool" -> "test_pool1")
           timeout <- sleep(1000)
           all_msgs <- session.get("user/messages?timeout=2")
-        } {                    
-          mess_res.code must be equalTo 200
+        } {                                  
+          mess_res.code must be equalTo 200               
+		  (mess_res.xml \ "message") must \\ (<body>test POST message</body>)
+          (mess_res.xml \ "message") must \\ (<tags><tag>Test</tag><tag>Tag</tag></tags>)
           (all_msgs.xml \ "messages") must \\(<body>test POST message</body>)
           (all_msgs.xml \ "messages") must \\(<tags><tag>Test</tag><tag>Tag</tag></tags>)
         }
@@ -555,8 +557,7 @@ object Api2Specs extends Specification w
       }
     }
 
-// This is very ... shall we say ... brittle  
-// Also adding in a check to make sure that the message contains the reply-to message ID
+// This is very ... shall we say ... brittle                                            

     "conversations/CONVERSATIONID GET" in {
       "with valid session" in {
         for{
@@ -759,12 +760,14 @@ object Api2Specs extends Specification w
         for{
           sess <- post_session 
           pool_res <- sess.post("pools", "poolName" -> "test_pool6")    
-          init <- sess.get("pool/6/messages") 
+          init <- sess.get("pools/6/messages")    
+		  timeout <- sleep(2000)
 		  mess_res <- sess.post("user/messages",
             "message" -> "test message for pool timeout",
-            "pool" -> "test_pool6") 
+            "pool" -> "test_pool6")          
+		  timeout <- sleep(2000)
           res <- sess.get("pools/6/messages?timeout=2")
-        } {                               
+        } {                   
           res.code must be equalTo 200
         }
       }    



Mime
View raw message