incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r883194 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: actor/Distributor.scala actor/UserActor.scala lib/MsgParser.scala model/Action.scala model/Mailbox.scala model/Message.scala model/Privilege.scala
Date Mon, 23 Nov 2009 00:02:01 GMT
Author: vdichev
Date: Mon Nov 23 00:02:01 2009
New Revision: 883194

URL: http://svn.apache.org/viewvc?rev=883194&view=rev
Log:
Added Javadoc to important classes

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/lib/MsgParser.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.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=883194&r1=883193&r2=883194&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 Mon
Nov 23 00:02:01 2009
@@ -39,6 +39,11 @@
 
 import scala.xml.{Elem}
 
+/**
+ * The Distributor actor forwards messages to the approprite user actor
+ * without the need for the sender to have a reference to it.
+ * If the actor is not started, Distributor starts it up in findOrCreateUser
+ */
 object Distributor extends LiftActor {
   protected def messageHandler = {
       case StartMeUp =>

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=883194&r1=883193&r2=883194&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 Mon Nov
23 00:02:01 2009
@@ -60,6 +60,12 @@
 }
 
 
+/**
+ * The UserActor processes a user's messages
+ * The UserActor keeps track of pools a user belongs to, followers,
+ * active actions and tracking filters
+ */
+ 
 class UserActor extends LiftActor {
   import UserActor._
   
@@ -220,6 +226,9 @@
     case tz => Calendar.getInstance(tz)
   }
   
+  /**
+   * This method decides which actions should be applied to a message
+   */
   private def addToMailbox(msg: Message, reason: MailboxReason) {
     // if the message is not in my mailbox
     if (Mailbox.find(By(Mailbox.message, msg),

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=883194&r1=883193&r2=883194&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 Mon Nov
23 00:02:01 2009
@@ -35,6 +35,19 @@
 import org.apache.esme._
 import model._
 
+/**
+ * The MsgParser parses:
+ * - a message into its parts: text, usernames, hashtags, urls
+ * - the test condition for an action
+ * - what to perform for an action
+ *
+ * Several parsers are reused for the high-level parsers:
+ * - an URL parser based on RFC 1738 and extended with some parts of RFC 1630;
+ *     unique url will be stored similarly to an url-shortener service
+ * - a parser for an existing username
+ * - a parser for a hashtag, which returns an existing Tag
+ *     or creating a new one if it doesn't exist
+ */
 object MsgParser extends Parsers with ImplicitConversions with CombParserHelpers {
   def parseMessage(in: String): Box[List[MsgInfo]] = begin(in) match {
     case Success(xs, _) => Full(xs)

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=883194&r1=883193&r2=883194&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 Mon Nov
23 00:02:01 2009
@@ -45,7 +45,7 @@
   
   }
   
-   override def create: Action = {
+  override def create: Action = {
     val ap = super.create
     ap.createdDate(new Date())
     ap
@@ -68,6 +68,10 @@
   lazy val TrueFunc: TestFunc = {case _ => true}
   lazy val SentToMe: TestFunc = (m, u, c, r) => m.sentToIds.contains(u)
   
+  /**
+   * Returns a function, which determines if a set of events should trigger the action
+   * Note: in pattern matching, define more general cases later: order is important
+   */
   def toFunc(in: TestAction): TestFunc = in match {
     case AnyAction => TrueFunc
 
@@ -148,6 +152,10 @@
       (m, u, c, r) => ot.buildFunc(dt.buildFunc(c), what)
   }
   
+  /**
+   * Searches for regular actions recursively, since
+   * an action expression could have a nested structure of or/and operators and parentheses
+   */
   def regularActions(in: TestAction): List[RegularAction] = in match {
     case NotAction(a) => regularActions(a)
 
@@ -163,8 +171,23 @@
   }
 }
 
+/**
+ * The Action class represents some automatic message processing which is
+ * triggered when a certain condition is met:
+ * - a message which satisfies certain criteria is received
+ * - an internal event occurs- login, one user follows another
+ * - at regular intervals
+ *
+ * Both the condition and performance are parsed at least in the following stages:
+ * - when saving the action
+ * - when constructing the function to determine if the action should be triggered
+ */
 class Action extends LongKeyedMapper[Action] {
 
+  /**
+   * Actors related to regularly executed actions are started here
+   * This is done when the action is activated or at the start of the application
+   */
   def startActors() {
     for(regular <- regularActions) regular match { 
       case RegularAction(mins) => SchedulerActor ! SchedulerActor.StartRegular(this, mins
* 60)
@@ -306,7 +329,10 @@
 }
 
 
-
+/**
+ * The condition causing an action to be performed
+ * Note: toStr must return a String which would be parsed to an identical object!
+ */
 sealed trait TestAction {
   def toStr: String
 }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala?rev=883194&r1=883193&r2=883194&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Mailbox.scala Mon Nov
23 00:02:01 2009
@@ -33,6 +33,10 @@
 object Mailbox extends Mailbox with LongKeyedMetaMapper[Mailbox] {
   override def dbTableName = "mailbox" // define the DB table name
 
+  /**
+   * A list of the last messages are collected through the cached 
+   * Message.findMessages method
+   */
   def mostRecentMessagesFor(userId: Long, cnt: Int):
   List[(Message, MailboxReason, Boolean)] = {
     val mb = findAll(By(user, userId), OrderBy(id, Descending),
@@ -48,6 +52,14 @@
   override def dbIndexes = Index(user, message) :: super.dbIndexes
 }
 
+/**
+ * The Mailbox is a list of references to message instances,
+ * which are in the user's timeline, along with additional data:
+ * why the message got to this timeline and any conversation it's part of
+ *
+ * The Message itself is never copied when it's put in a user's timeline:
+ * only another reference to it is created
+ */
 class Mailbox extends LongKeyedMapper[Mailbox] {
   def getSingleton = Mailbox // what's the "meta" server
   def primaryKeyField = id

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=883194&r1=883193&r2=883194&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 Mon Nov
23 00:02:01 2009
@@ -62,6 +62,10 @@
   private val idCache = new LRU[Long, Message](cacheSize)
 
 
+  /**
+   * A list of messages is requested from a simple cache
+   * The cache is filtered for messages which the user has permission to view
+   */
   def findMessages(in: Seq[Long]): Map[Long, Message] = synchronized {
     val il = in.toList
     val user = User.currentUser
@@ -166,6 +170,13 @@
       }) openOr Nil
   }
   
+  /**
+   * Lift's findMapDb is overridden to ensure that message search will return
+   * only messages which the user has permission to view
+   *
+   * All Lift finder methods eventually call findMapDb, which makes it suitable
+   * to override to redefine some global behavior.
+   */
   override def findMapDb[T](dbId : ConnectionIdentifier, by : QueryParam[Message]*)(f : (Message)
=> Box[T]): List[T] = {
     // modify behavior of find methods so that results include only authorized pools of current
user
     val viewablePools =

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala?rev=883194&r1=883193&r2=883194&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Privilege.scala Mon Nov
23 00:02:01 2009
@@ -75,6 +75,18 @@
   )(p => Full(p.pool.is)) :_*)
 }
 
+/**
+ * A Privilege defines a permission for a certain user in an access pool.
+ * This acts as a join table for the user:pool many-to-many relationship.
+ *
+ * Currently a user may only have one privilege type for a pool, where one
+ * permission type will also include all rights for more restricted ones,
+ * e.g. Write permission also includes Read permissions.
+ *
+ * In order to change to multiple Privileges per user or add another type,
+ * redefining the find* methods from the companion object should be all
+ * that is necessary.
+ */
 class Privilege extends LongKeyedMapper[Privilege] {
   def getSingleton = Privilege // what's the "meta" server
   def primaryKeyField = id
@@ -90,6 +102,9 @@
   ).map(_.permission.is >= permission).getOrElse(false)
 }
 
+/**
+ * Types of permissions a user can have a Privilege to have
+ */
 object Permission extends Enumeration {
   val Read = Value(0, "Read")
   val Write = Value(1, "Write")



Mime
View raw message