incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esjew...@apache.org
Subject svn commit: r979695 - in /incubator/esme/branches/metadata/src/main/scala/org/apache/esme: actor/Distributor.scala actor/UserActor.scala api/API2.scala api/XMLHelper.scala model/Message.scala
Date Tue, 27 Jul 2010 13:41:20 GMT
Author: esjewett
Date: Tue Jul 27 13:41:20 2010
New Revision: 979695

URL: http://svn.apache.org/viewvc?rev=979695&view=rev
Log:
[ESME-242] Fix for remaining metadata issues with API
Patch by Imtiaz Ahmed Hajee Esmail

Modified:
    incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/Distributor.scala
    incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/UserActor.scala
    incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/API2.scala
    incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/XMLHelper.scala
    incubator/esme/branches/metadata/src/main/scala/org/apache/esme/model/Message.scala

Modified: incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/Distributor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/Distributor.scala?rev=979695&r1=979694&r2=979695&view=diff
==============================================================================
--- incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/Distributor.scala
(original)
+++ incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/Distributor.scala
Tue Jul 27 13:41:20 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/branches/metadata/src/main/scala/org/apache/esme/actor/UserActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/UserActor.scala?rev=979695&r1=979694&r2=979695&view=diff
==============================================================================
--- incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/UserActor.scala
(original)
+++ incubator/esme/branches/metadata/src/main/scala/org/apache/esme/actor/UserActor.scala
Tue Jul 27 13:41:20 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/branches/metadata/src/main/scala/org/apache/esme/api/API2.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/API2.scala?rev=979695&r1=979694&r2=979695&view=diff
==============================================================================
--- incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/API2.scala (original)
+++ incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/API2.scala Tue Jul
27 13:41:20 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/branches/metadata/src/main/scala/org/apache/esme/api/XMLHelper.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/XMLHelper.scala?rev=979695&r1=979694&r2=979695&view=diff
==============================================================================
--- incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/XMLHelper.scala (original)
+++ incubator/esme/branches/metadata/src/main/scala/org/apache/esme/api/XMLHelper.scala Tue
Jul 27 13:41:20 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/branches/metadata/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/metadata/src/main/scala/org/apache/esme/model/Message.scala?rev=979695&r1=979694&r2=979695&view=diff
==============================================================================
--- incubator/esme/branches/metadata/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ incubator/esme/branches/metadata/src/main/scala/org/apache/esme/model/Message.scala Tue
Jul 27 13:41:20 2010
@@ -497,8 +497,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>{



Mime
View raw message