esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r790974 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Action.scala
Date Fri, 03 Jul 2009 18:00:01 GMT
Author: vdichev
Date: Fri Jul  3 18:00:01 2009
New Revision: 790974

URL: http://svn.apache.org/viewvc?rev=790974&view=rev
Log:
ESME-74 Action filter for pools

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=790974&r1=790973&r2=790974&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 Fri Jul
 3 18:00:01 2009
@@ -51,6 +51,8 @@
     case first ~ more => first + more.mkString
   }
   
+  lazy val poolNameStr = atNameStr
+  
   lazy val atName: Parser[MsgInfo] = '@' ~> atNameStr ~ rep('.' ~> atNameStr) ^^ {
     case name ~ domainlist => 
       val nickName: String = name
@@ -61,6 +63,14 @@
       }
   }
   
+  lazy val poolName: Parser[MsgInfo] = acceptCI("pool:") ~> poolNameStr ^^ {
+    case name => 
+      AccessPool.findPool(name, "Native") match {
+        case Full(p) => PoolName(p)
+        case _ => MsgText("pool:"+name)
+      }
+  }
+  
   // def ip_schemepart = (accept("//") ~> login) ~> opt( '/' ~> urlpath)
 
   lazy val login: Parser[String] = userPass ^^ {
@@ -233,7 +243,7 @@
   
   lazy val testFactor: Parser[TestAction] = (notTest |
   testAt | testRegex | testString |
-  testTag | 
+  testTag | testPool |
   testParen | testPercent |
   testDates | testLogin |
   testFollowed | testUnfollowed |
@@ -312,6 +322,12 @@
     case x => ParenAction(x)
   }
 
+  lazy val testPool: Parser[PoolAction] =
+  (whiteSpace ~ acceptCI("pool:") ~> rep1(digit) <~ whiteSpace ^^ {case id => PoolAction(id.mkString.toLong)})
|
+  (poolName ^^ {
+      case PoolName(pool) => PoolAction(pool.id)
+    })
+  
   lazy val testAt: Parser[AtUserAction] =
   (whiteSpace ~ '@' ~> rep1(digit) <~ whiteSpace ^^ {case dig => AtUserAction(dig.mkString.toLong)})
|
   (atName ^^ {
@@ -366,3 +382,4 @@
 case class AtName(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

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=790974&r1=790973&r2=790974&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 Fri Jul
 3 18:00:01 2009
@@ -93,6 +93,9 @@
     case AtUserAction(userId) =>
       (m, u, c, r) => m.author.is == userId 
         
+    case PoolAction(poolId) =>
+      (m, u, c, r) => m.pool.is == poolId
+        
     case SentToMeAction =>
       SentToMe
       
@@ -294,6 +297,10 @@
   def toStr = "@"+userId
 }
 
+case class PoolAction(poolId: Long) extends TestAction {
+  def toStr = "pool:" + poolId
+}
+
 case class RegexAction(re: String) extends TestAction {
   def toStr = "/"+fix+"/"
   



Mime
View raw message