esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r979774 - in /incubator/esme/trunk/server: ./ src/main/resources/props/ src/main/scala/org/apache/esme/actor/ src/main/scala/org/apache/esme/api/ src/main/scala/org/apache/esme/model/ src/test/scala/org/apache/esme/api/
Date Tue, 27 Jul 2010 17:02:54 GMT
Author: esjewett
Date: Tue Jul 27 17:02:39 2010
New Revision: 979774

URL: http://svn.apache.org/viewvc?rev=979774&view=rev
Log:
[ESME-242] Commit merge of metadata branch into trunk

Modified:
    incubator/esme/trunk/server/   (props changed)
    incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml   (props
changed)
    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/main/scala/org/apache/esme/api/XMLHelper.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
    incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/API2Test.scala

Propchange: incubator/esme/trunk/server/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 27 17:02:39 2010
@@ -1,2 +1,3 @@
 /incubator/esme/branches/lift-2.0/server:928728-939625
+/incubator/esme/branches/metadata:966215-979767
 /incubator/esme/branches/ui-2010-03-05:919339-923098

Propchange: incubator/esme/trunk/server/src/main/resources/props/compass.filesystem.cfg.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 27 17:02:39 2010
@@ -0,0 +1 @@
+/incubator/esme/branches/metadata/src/main/resources/props/compass.filesystem.cfg.xml:966215-979767

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=979774&r1=979773&r2=979774&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 Tue
Jul 27 17:02:39 2010
@@ -33,7 +33,7 @@ import common._
 import org.apache.esme._
 import model._
 
-import scala.xml.{Elem}
+import scala.xml.{Node, Elem}
 
 /**
  * The Distributor actor forwards messages to the appropriate user actor
@@ -100,8 +100,8 @@ object Distributor extends LiftActor {
   }                             
 
   case class UserCreatedMessage(user: Long, text: String, tags: List[String],
-                                when: Long,
-                                metaData: Box[Elem],
+                                when: Long,               
+                                metaData: Box[Node],
                                 source: String,
                                 replyTo: Box[Long],
                                 pool: Box[Long])

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=979774&r1=979773&r2=979774&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 Tue Jul
27 17:02:39 2010
@@ -31,15 +31,15 @@ import model._
 import lib._
 
 import java.util.{TimeZone, Calendar}
-import scala.xml.{Elem}
+import scala.xml.{Node, Elem}
 //import com.twitter.stats.Stats
 import com.twitter.ostrich.Stats
 
 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],
+  private[actor] case class CreateMessage(text: String, tags: List[String],     
+                                          when: Long, metaData: Box[Node],
                                           source: String,
                                           replyTo: Box[Long],
                                           pool: Box[Long])

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=979774&r1=979773&r2=979774&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 Tue Jul 27 17:02:39
2010
@@ -56,7 +56,7 @@ import org.apache.esme._
 import model._
 import org.apache.esme.actor._
 
-import scala.xml.{NodeSeq, Text, Elem, XML, Node}
+import scala.xml._
 
 import scala.collection.mutable.ListBuffer
 
@@ -339,7 +339,10 @@ object API2 extends ApiHelper with XmlHe
                                        Tag.split(S.param("tags")
                                                  openOr ""),
                                        millis,
-                                       xml,
+                                       xml match {
+                                         case Full(x) => xml
+                                         case _ => Box({new Atom(S.param("metadata") openOr
"")})
+                                       },
                                        from,
                                        S.param("replyto").map(toLong),
                                        pool) match {

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/XMLHelper.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/XMLHelper.scala?rev=979774&r1=979773&r2=979774&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/XMLHelper.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/XMLHelper.scala Tue Jul
27 17:02:39 2010
@@ -35,7 +35,7 @@ import Helpers._ 
 import org.apache.esme._
 import model._
 
-import scala.xml.{NodeSeq, Text, Elem, UnprefixedAttribute, Null, Node}  
+import scala.xml.{NodeSeq, Text, Elem, UnprefixedAttribute, Null, Node, XML}  
   
 trait XmlHelper { 
   protected def userToXml(user: User): Elem =
@@ -60,7 +60,9 @@ trait XmlHelper { 
   <date>{toInternetDate(msg.when.is)}</date>
   <source>{msg.source.sourceAttr.getOrElse(Text(""))}</source>
   <body>{msg.body}</body>
-  <metadata>{msg.metadata}</metadata>  
+  { if ( msg.metadata != null && msg.metadata.length != 0 )
+      XML.loadString(msg.metadata)
+    else <metadata/> }  
   {
     msg.author.obj.map(u =>
       <author><nickname>{u.niceName}</nickname><id>{u.id.toString}</id></author>

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala?rev=979774&r1=979773&r2=979774&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala Tue Jul
27 17:02:39 2010
@@ -312,7 +312,8 @@ class Message extends LongKeyedMapper[Me
  
   lazy val body: String = originalXml \ "body" text
   
-  lazy val metadata: String = originalXml \ "metadata" text
+  //lazy val metadata: String = originalXml \ "metadata" text
+  lazy val metadata: String = (originalXml \ "metadata").toString
 
   lazy val metaData: String = {
     val org = originalXml
@@ -497,8 +498,9 @@ class Message extends LongKeyedMapper[Me
    * Note that the text representation of the XML must be readable
    * for clients that don't support markup formatting
    * and is recommended to result in the same XML when parsed
-   */
-  def setTextAndTags(in: String, tags: List[Tag], metaData: Box[Elem]): Box[Message] = {
+   */                                                                                   
    
+   
+  def setTextAndTags(in: String, tags: List[Tag], metaData: Box[Node]): Box[Message] = {
     MsgParser.parseMessage(in).map{
       lst =>
       val xml = <message><body>{

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=979774&r1=979773&r2=979774&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 Tue Jul
27 17:02:39 2010
@@ -370,6 +370,32 @@ object Api2Specs extends Specification w
         for (session_res <- post("user/messages", "message" -> "test message")) {
           session_res.code must be equalTo 403
         }
+      }      
+      
+      "with XML metadata" in {
+        for{
+          session <- post_session       
+          mess_res <- session.post("user/messages",
+            "message" -> "test POST message",
+            "metadata" -> """<outer><meta><metameta>"Hello"</metameta></meta><onlymeta>Meta</onlymeta></outer>""")
             
+        } {
+          mess_res.code must be equalTo 200                                     
+          (mess_res.xml.open_! \ "message") must \\ (<body>test POST message</body>)
   
+          (mess_res.xml.open_! \\ "metadata").toString must be equalTo """<metadata><outer><meta><metameta>&quot;Hello&quot;</metameta></meta><onlymeta>Meta</onlymeta></outer></metadata>"""
        
+        }
+      }  
+      
+      "with JSON metadata" in {
+        for{
+          session <- post_session       
+          mess_res <- session.post("user/messages",
+            "message" -> "test POST message",
+            "metadata" -> """"meta":[{"place":{"place_type":"city","region":"CA+"}},{"song":{"artist":"Prince","songtitle":"Never+Let+Me+Down"}}]""")
             
+        } {
+          mess_res.code must be equalTo 200                        
+          (mess_res.xml.open_! \ "message") must \\ (<body>test POST message</body>)
   
+          (mess_res.xml.open_! \\ "metadata").text must be equalTo """"meta":[{"place":{"place_type":"city","region":"CA+"}},{"song":{"artist":"Prince","songtitle":"Never+Let+Me+Down"}}]"""
        
+        }
       }
     }
 



Mime
View raw message