Author: chabotc
Date: Wed Oct 15 15:15:51 2008
New Revision: 705076

URL: http://svn.apache.org/viewvc?rev=705076&view=rev
Log:
Messages are now working through the REST API too

Modified:
    incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php
    incubator/shindig/trunk/php/src/social/service/MessagesHandler.php
    incubator/shindig/trunk/php/src/social/service/RestRequestItem.php
    incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php
    incubator/shindig/trunk/php/src/social/spi/MessagesService.php

Modified: 
incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php?rev=705076&r1=705075&r2=705076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php 
(original)
+++ incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php 
Wed Oct 15 15:15:51 2008
@@ -346,7 +346,7 @@
                throw new SocialSpiException("Not implemented", 
ResponseError::$NOT_IMPLEMENTED);
        }
 
-       public function createMessage($userId, $message, SecurityToken $token)
+       public function createMessage($userId, $appId, $message, 
$optionalMessageId, SecurityToken $token)
        {
                throw new SocialSpiException("Not implemented", 
ResponseError::$NOT_IMPLEMENTED);
        }

Modified: incubator/shindig/trunk/php/src/social/service/MessagesHandler.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/service/MessagesHandler.php?rev=705076&r1=705075&r2=705076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/service/MessagesHandler.php 
(original)
+++ incubator/shindig/trunk/php/src/social/service/MessagesHandler.php Wed Oct 
15 15:15:51 2008
@@ -19,7 +19,7 @@
 
 class MessagesHandler extends DataRequestHandler {
        
-       private static $MESSAGES_PATH = "/messages/{userId}/outbox/{msgId}";
+       private static $MESSAGES_PATH = "/messages/userId/outbox/msgId";
        private $service;
 
        public function __construct()
@@ -30,28 +30,32 @@
 
        public function handleDelete(RequestItem $requestItem)
        {
-               return new ResponseItem(NOT_IMPLEMENTED, "You can't delete 
messages", null);
+               throw new SocialSpiException("You can't delete messages", 
ResponseError::$NOT_IMPLEMENTED); 
        }
 
        public function handleGet(RequestItem $requestItem)
        {
-               return new ResponseItem(NOT_IMPLEMENTED, "You can't retrieve 
messages", null);
-       }
-
-       public function handlePost(RequestItem $requestItem)
-       {
-               return new ResponseItem(NOT_IMPLEMENTED, "You can't edit 
messages", null);
+               throw new SocialSpiException("You can't retrieve messages", 
ResponseError::$NOT_IMPLEMENTED); 
        }
 
        /**
         * /messages/{groupId}/outbox/{msgId}
+        * /messages/{groupId}/outbox
         *
         * @param RequestItem $requestItem
         * @return responseItem
         */
+       public function handlePost(RequestItem $requestItem)
+       {
+               $requestItem->applyUrlTemplate(self::$MESSAGES_PATH);
+               $userIds = $requestItem->getUsers();
+               $message = $requestItem->getParameter('message');
+               $optionalMessageId = $requestItem->getParameter('msgId');
+               return $this->service->createMessage($userIds[0], 
$requestItem->getAppId(), $message, $optionalMessageId, 
$requestItem->getToken());
+       }
+
        public function handlePut(RequestItem $requestItem)
        {
-               $requestItem->parseUrlWithTemplate(self::$MESSAGES_PATH);
-               return $this->service->createMessage($requestItem->getUser(), 
$requestItem->getPostData(), $requestItem->getToken());
+               $this->handlePost($requestItem);
        }
 }

Modified: incubator/shindig/trunk/php/src/social/service/RestRequestItem.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/service/RestRequestItem.php?rev=705076&r1=705075&r2=705076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/service/RestRequestItem.php 
(original)
+++ incubator/shindig/trunk/php/src/social/service/RestRequestItem.php Wed Oct 
15 15:15:51 2008
@@ -77,6 +77,7 @@
                                break;
                        case DataServiceServlet::$MESSAGE_ROUTE:
                                $data = 
$this->inputConverter->convertMessages($this->postData);
+                               $this->params['message'] = $data;
                                break;
                        default:
                                throw new Exception("Invalid or unknown service 
endpoint: $service");

Modified: incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php?rev=705076&r1=705075&r2=705076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php 
(original)
+++ incubator/shindig/trunk/php/src/social/servlet/DataServiceServlet.php Wed 
Oct 15 15:15:51 2008
@@ -26,7 +26,7 @@
        public static $PEOPLE_ROUTE = "people";
        public static $ACTIVITY_ROUTE = "activities";
        public static $APPDATA_ROUTE = "appdata";
-       public static $MESSAGE_ROUTE = "message";
+       public static $MESSAGE_ROUTE = "messages";
 
        public function doGet()
        {

Modified: incubator/shindig/trunk/php/src/social/spi/MessagesService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/spi/MessagesService.php?rev=705076&r1=705075&r2=705076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/spi/MessagesService.php (original)
+++ incubator/shindig/trunk/php/src/social/spi/MessagesService.php Wed Oct 15 
15:15:51 2008
@@ -19,15 +19,21 @@
 
 interface MessagesService {
 
-       /**  $message is an array containing the following fields:
+       /**  
+        * Send a message to the chosen recipients.
+        * $userId - the sender
+        * $appId - the application Id
+        * $message - an array containing the following fields:
         *  [id] => {msgid}
         *  [title] => You have an invitation from Joe
         *  [body] => Click <a 
href="http://app.example.org/invites/{msgid}";>here</a> to review your 
invitation.
         *  [recipients] => Array
         *      (
-        *          [0] => example.org:AD38B3886625AAF
-        *          [1] => example.org:997638BAA6F25AD
+        *          [0] => UserId1
+        *          [1] => UserId2
         *      )
+        * $optionalMessageId - if the REST action was a PUT containing an 
message id this is filled in
+        * $token - the security token
         */
-       public function createMessage($userId, $message, SecurityToken $token);
+       public function createMessage($userId, $appId, $message, 
$optionalMessageId, SecurityToken $token);
 }


Reply via email to