incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r818625 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Action.scala
Date Thu, 24 Sep 2009 21:02:57 GMT
Author: vdichev
Date: Thu Sep 24 21:02:57 2009
New Revision: 818625

URL: http://svn.apache.org/viewvc?rev=818625&view=rev
Log:
Refactor resender and pool tests for action parsing.

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala?rev=818625&r1=818624&r2=818625&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala Thu Sep
24 21:02:57 2009
@@ -63,19 +63,19 @@
       }
   }
   
-  lazy val poolName: Parser[MsgInfo] = acceptCI("pool:") ~> poolNameStr ^^ {
+  lazy val poolName: Parser[PoolName] = acceptCI("pool:") ~> poolNameStr ^^ {
     case name => 
       AccessPool.findPool(name, AccessPool.Native) match {
         case Full(p) => PoolName(p)
-        case _ => MsgText("pool:"+name)
+        case _ => throw new RuntimeException("Unknown pool name")
       }
   }
   
-  lazy val resenderName: Parser[MsgInfo] = acceptCI("resent:") ~> userNameStr ^^ {
+  lazy val resenderName: Parser[ResenderName] = acceptCI("resent:") ~> userNameStr ^^
{
     case name => 
       User.find(By(User.nickname, name)) match {
         case Full(u) => ResenderName(u)
-        case _ => MsgText("resent:"+name)
+        case _ => throw new RuntimeException("Unknown user name for resender")
       }
   }
   
@@ -399,7 +399,8 @@
 sealed trait MsgInfo
 case class MsgText(text: String) extends MsgInfo
 case class AtName(user: User) extends MsgInfo
-case class ResenderName(user: User) extends MsgInfo
 case class HashTag(tag: Tag) extends MsgInfo
 case class URL(url: UrlStore) extends MsgInfo
-case class PoolName(pool: AccessPool) extends MsgInfo
+
+case class ResenderName(user: User)
+case class PoolName(pool: AccessPool)

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala?rev=818625&r1=818624&r2=818625&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala Thu Sep
24 21:02:57 2009
@@ -237,10 +237,14 @@
   }
   import MsgParser._
 
-  def setTest(in: String): Box[Action] = testExpr(in) match {
-    case Success(v, _) => Full(this.theTest(v.toStr))
-    case Failure(m, _) => net.liftweb.util.Failure(m, Empty, Empty)
-    case Error(m, _) => net.liftweb.util.Failure(m, Empty, Empty)
+  def setTest(in: String): Box[Action] = try {
+    testExpr(in) match {
+      case Success(v, _) => Full(this.theTest(v.toStr))
+      case Failure(m, _) => net.liftweb.util.Failure(m, Empty, Empty)
+      case Error(m, _) => net.liftweb.util.Failure(m, Empty, Empty)
+    }
+  } catch {
+    case e: Exception => net.liftweb.util.Failure(e.getMessage, Empty, Empty)
   }
 
   def testText = theTest.is



Mime
View raw message