Author: chabotc
Date: Sat Jul 12 18:27:15 2008
New Revision: 676256

URL: http://svn.apache.org/viewvc?rev=676256&view=rev
Log:
First jab at Atom support, most of it seems to be working. Code is a bit quick 
and dirty but will be cleaned up asap

Modified:
    incubator/shindig/trunk/php/src/socialrest/ActivityHandler.php
    incubator/shindig/trunk/php/src/socialrest/DataRequestHandler.php
    incubator/shindig/trunk/php/src/socialrest/OutputConverter.php
    incubator/shindig/trunk/php/src/socialrest/PersonHandler.php
    incubator/shindig/trunk/php/src/socialrest/RestRequestItem.php
    
incubator/shindig/trunk/php/src/socialrest/converters/OutputAtomConverter.php
    
incubator/shindig/trunk/php/src/socialrest/converters/OutputJsonConverter.php
    incubator/shindig/trunk/php/src/socialrest/http/RestServlet.php
    incubator/shindig/trunk/php/src/socialrest/opensocial/ActivitiesService.php
    
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicActivitiesService.php
    
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicPeopleService.php

Modified: incubator/shindig/trunk/php/src/socialrest/ActivityHandler.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/ActivityHandler.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/ActivityHandler.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/ActivityHandler.php Sat Jul 12 
18:27:15 2008
@@ -49,9 +49,9 @@
                // TODO: Filter by fields
                // TODO: do we need to add pagination and sorting support?
                if ($optionalActivityId != null) {
-                       return 
$this->service->getActivity($requestItem->getUser(), $requestItem->getGroup(), 
$optionalActivityId, $requestItem->getToken());
+                       return 
$this->service->getActivity($requestItem->getUser(), $requestItem->getGroup(), 
$optionalActivityId, $requestItem->getStartIndex(), $requestItem->getCount(), 
$requestItem->getToken());
                }
-               return $this->service->getActivities($requestItem->getUser(), 
$requestItem->getGroup(), $requestItem->getToken());
+               return $this->service->getActivities($requestItem->getUser(), 
$requestItem->getGroup(), $requestItem->getStartIndex(), 
$requestItem->getCount(), $requestItem->getToken());
        }
 
        /**

Modified: incubator/shindig/trunk/php/src/socialrest/DataRequestHandler.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/DataRequestHandler.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/DataRequestHandler.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/DataRequestHandler.php Sat Jul 
12 18:27:15 2008
@@ -27,8 +27,8 @@
                $method = $requestItem->getMethod();
                if ($owner == 0 && $viewer == 0 && $method != 'GET') {
                        // Anonymous requests are only allowed to GET data (not 
create/edit/delete)
-                       $response = new ResponseItem(BAD_REQUEST, "", null);
-               } elseif ($method == 'GET') {
+                       $response = new ResponseItem(BAD_REQUEST, "[$method] 
not allowed for anonymous users", null);
+               } elseif ($method == 'GET') {                   
                        $response = $this->handleGet($requestItem);
                } elseif ($method == 'POST') {
                        $response = $this->handlePost($requestItem);

Modified: incubator/shindig/trunk/php/src/socialrest/OutputConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/OutputConverter.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/OutputConverter.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/OutputConverter.php Sat Jul 12 
18:27:15 2008
@@ -22,6 +22,6 @@
  *
  */
 abstract class OutputConverter {
-       abstract function outputResponse(ResponseItem $responseItem);
-       abstract function outputBatch(Array $responses);
+       abstract function outputResponse(ResponseItem $responseItem, 
RestRequestItem $requestItem);
+       abstract function outputBatch(Array $responses, SecurityToken $token);
 }

Modified: incubator/shindig/trunk/php/src/socialrest/PersonHandler.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/PersonHandler.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/PersonHandler.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/PersonHandler.php Sat Jul 12 
18:27:15 2008
@@ -42,7 +42,7 @@
                $parameters = $requestItem->getParameters();
                $optionalPersonId = in_array('personId', $parameters) ? 
$parameters['personId'] : null;
                $fields = 
$requestItem->getFieldsWithDefaultValue(self::$DEFAULT_PERSON_FIELDS);
-               if ($optionalPersonId || $requestItem->getGroup()->getType() == 
'self') {
+               if ($optionalPersonId || (is_object($requestItem->getGroup()) 
&& $requestItem->getGroup()->getType() == 'self')) {
                        //FIXME same logic as the java code here, but doesn't 
seem to do much with the optionalPersonId which seems odd
                        return 
$this->service->getPerson($requestItem->getUser(), $requestItem->getGroup(), 
$fields, $requestItem->getToken());
                }
@@ -63,4 +63,4 @@
        {
                return new ResponseItem(NOT_IMPLEMENTED, "You can't add people 
right now.", null);
        }
-}
\ No newline at end of file
+}

Modified: incubator/shindig/trunk/php/src/socialrest/RestRequestItem.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/RestRequestItem.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/RestRequestItem.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/RestRequestItem.php Sat Jul 12 
18:27:15 2008
@@ -119,28 +119,29 @@
 
        public function getAppId()
        {
-               $appId = $this->parameters[self::$APP_ID];
-               if ($appId != null && $appId == self::$APP_SUBSTITUTION_TOKEN) {
+               if (isset($this->parameters[self::$APP_ID]) && 
$this->parameters[self::$APP_ID] == self::$APP_SUBSTITUTION_TOKEN) {
                        return $this->token->getAppId();
+               } elseif (isset($this->parameters[self::$APP_ID])) {
+                       return $this->parameters[self::$APP_ID];
                } else {
-                       return $appId;
+                       return 0;
                }
        }
 
        public function getUser()
        {
-               return UserId::fromJson($this->parameters[self::$USER_ID]);
+               return isset($this->parameters[self::$USER_ID]) ? 
UserId::fromJson($this->parameters[self::$USER_ID]) : false;
        }
 
        public function getGroup()
        {
-               return GroupId::fromJson($this->parameters[self::$GROUP_ID]);
+               return isset($this->parameters[self::$GROUP_ID]) ? 
GroupId::fromJson($this->parameters[self::$GROUP_ID]) : false;
        }
 
        public function getStartIndex()
        {
-               if (!empty(self::$DEFAULT_START_INDEX)) {
-                       return self::$DEFAULT_START_INDEX;
+               if (!empty($this->parameters[self::$START_INDEX])) {
+                       return $this->parameters[self::$START_INDEX];
                } else {
                        return self::$DEFAULT_START_INDEX;
                }

Modified: 
incubator/shindig/trunk/php/src/socialrest/converters/OutputAtomConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/converters/OutputAtomConverter.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialrest/converters/OutputAtomConverter.php 
(original)
+++ 
incubator/shindig/trunk/php/src/socialrest/converters/OutputAtomConverter.php 
Sat Jul 12 18:27:15 2008
@@ -18,18 +18,197 @@
  */
 
 /**
- * Format = atom output converter
- *
+ * Format = atom output converter, for format definition see:
+ * 
http://www.opensocial.org/Technical-Resources/opensocial-specification----implementation-version-08/restful-api-specification
  */
 class OutputAtomConverter extends OutputConverter {
-       
-       function outputResponse(ResponseItem $responseItem)
+       private static $nameSpace = 'http://www.w3.org/2005/Atom';
+       private static $osNameSpace = 
'http://ns.opensocial.org/2008/opensocial';
+       private static $xmlVersion = '1.0';
+       private static $charSet = 'UTF-8';
+       private static $formatOutput = true;
+       // this maps the REST url to the atom content type
+       private static $entryTypes = array(
+               'people' => 'person', 'appdata' => 'appdata', 'activities' => 
'activity'
+       );
+
+       function outputResponse(ResponseItem $responseItem, RestRequestItem 
$requestItem)
        {
+               $doc = new DOMDocument(self::$xmlVersion, self::$charSet);
+               $doc->formatOutput = self::$formatOutput;
+               $data = $responseItem->getResponse();
+               $params = $requestItem->getParameters();
+               // map the Request URL to the content type to use  
+               if (empty(self::$entryTypes[$params[0]])) {
+                       throw new Exception("Unsupported request type");
+               }
+               $requestType = self::$entryTypes[$params[0]];
+               // Check to see if this is a single entry, or a collection, and 
construct either an atom 
+               // feed (collection) or an entry (single)
                
-       }
+               if ($responseItem->getResponse() instanceof RestFulCollection) {
+                       $entry = 
$doc->appendChild($doc->createElementNS(self::$nameSpace, "feed"));
+                       
+                       // osearch fields and next link
+                       $total = 
$entry->appendChild($doc->createElement('osearch:totalResults'));
+                       
$total->appendChild($doc->createTextNode($responseItem->getResponse()->getTotalResults()));
+                       $startIndex = 
$entry->appendChild($doc->createElement('osearch:startIndex'));
+                       
$startIndex->appendChild($doc->createTextNode($requestItem->getStartIndex()));
+                       $itemsPerPage = 
$entry->appendChild($doc->createElement('osearch:itemsPerPage'));
+                       
$itemsPerPage->appendChild($doc->createTextNode($requestItem->getCount()));
+                       
+                       // fabricate a next link based on our current url if 
this is a pageable collection
+                       if (($requestItem->getStartIndex() + 
$requestItem->getCount()) < $responseItem->getResponse()->getTotalResults()) {
+                               $nextStartIndex = $requestItem->getStartIndex() 
+ $requestItem->getCount();
+                               if (($uri = $_SERVER['REQUEST_URI']) === false) 
{
+                                       throw new Exception("Could not parse 
URI : {$_SERVER['REQUEST_URI']}");
+                               }
+                               $uri = parse_url($uri);
+                               if (isset($uri['query'])) {
+                                       parse_str($uri['query'], $params);
+                               } else {
+                                       $params = array();
+                               }
+                               $params[RestRequestItem::$START_INDEX] = 
$nextStartIndex;
+                               $params[RestRequestItem::$COUNT] = 
$requestItem->getCount();
+                               foreach ($params as $paramKey => $paramVal) {
+                                       $outParams[] = $paramKey . '=' . 
$paramVal;
+                               }
+                               $outParams = '?' . implode('&', $outParams);
+                               $nextUri = 'http://' . $_SERVER['HTTP_HOST'] . 
$uri['path'] . $outParams;
+                               // <link rel="next" 
href="http://api.example.org/..."; />
+                               $link = 
$entry->appendChild($doc->createElement('link'));
+                               $linkRel = 
$link->appendChild($doc->createAttribute('rel'));
+                               
$linkRel->appendChild($doc->createTextNode('next'));
+                               $linkHref = 
$link->appendChild($doc->createAttribute('href'));
+                               
$linkHref->appendChild($doc->createTextNode($nextUri));
+                       }
+                       
+                       // Atom fields
+                       $title = 
$entry->appendChild($doc->createElement('title'));
+                       $author = 
$entry->appendChild($doc->createElement('author'));
+                       $updated = 
$entry->appendChild($doc->createElement('updated'));
+                       
$updated->appendChild($doc->createTextNode(date(DATE_ATOM)));
+                       $id = $entry->appendChild($doc->createElement('id'));
+                       $id->appendChild($doc->createTextNode('urn:guid:' . 
$requestItem->getToken()->getDomain() . ':' . 
htmlentities($requestItem->getUser()->getUserId($requestItem->getToken(), 
ENT_NOQUOTES, 'UTF-8'))));
+                       
+                       // Add response entries to feed
+                       $responses = $responseItem->getResponse()->getEntry();
+                       foreach ($responses as $response) {
+                               $feedEntry = 
$entry->appendChild($doc->createElement("entry"));
+                               $type = 
$feedEntry->appendChild($doc->createElement('content'));
+                               if ($response instanceof Activity) {
+                                       // Special hoisting rules for activities
+                                       $updated = 
$feedEntry->appendChild($doc->createElement('updated'));
+                                       
$updated->appendChild($doc->createTextNode(date(DATE_ATOM, 
$response->postedTime)));
+                                       $id = 
$feedEntry->appendChild($doc->createElement('id'));
+                                       //FIXME these should get proper URL's 
in the ID and link:
+                                       // <link rel="self" 
type="application/atom+xml" 
href="http://api.example.org/activity/feeds/.../af3778"/>
+                                       
$id->appendChild($doc->createTextNode('urn:guid:activity:' . 
htmlentities($response->id, ENT_NOQUOTES, 'UTF-8')));
+                                       $summary = 
$feedEntry->appendChild($doc->createElement('summary'));
+                                       
$summary->appendChild($doc->createTextNode(htmlentities($response->body, 
ENT_NOQUOTES, 'UTF-8')));
+                                       $title = 
$feedEntry->appendChild($doc->createElement('title'));
+                                       
$title->appendChild($doc->createTextNode(htmlentities($response->title, 
ENT_NOQUOTES, 'UTF-8')));
+                                       unset($response->id);
+                                       unset($response->title);
+                                       unset($response->body);
+                                       unset($response->postedTime);
+                               }                               
+                               $content = $this->addData($doc, $type, 
$requestType, $response, self::$osNameSpace);
+                               $contentType = 
$type->appendChild($doc->createAttribute('type'));
+                               
$contentType->appendChild($doc->createTextNode('application/xml'));
+                               
+                               // Attempt to have a real ID field, otherwise 
we fall back on the idSpec id
+                               $idField = is_object($response) && 
isset($response->id) ? $response->id : (is_array($response) && 
isset($response['id']) ? $response['id'] : 
$requestItem->getUser()->getUserId($requestItem->getToken()));
+                               
+                               // Author node
+                               $author = 
$feedEntry->appendChild($doc->createElement('author'));
+                               $authorUrl = 
$author->appendChild($doc->createElement('uri'));
+                               
$authorUrl->appendChild($doc->createTextNode('urn:guid:' . 
htmlentities($idField, ENT_NOQUOTES, 'UTF-8')));
+                               // Updated node, only if it's not an activity 
(special case)
+                               if ($response instanceof Activity) {
+                                       $title = 
$feedEntry->appendChild($doc->createElement('title'));
+                                       $updated = 
$feedEntry->appendChild($doc->createElement('updated'));
+                                       
$updated->appendChild($doc->createTextNode(date(DATE_ATOM)));
+                                       $id = 
$feedEntry->appendChild($doc->createElement('id'));
+                                       
$id->appendChild($doc->createTextNode('urn:guid:' . htmlentities($idField, 
ENT_NOQUOTES, 'UTF-8')));
+                               }
+                       }
+               } else {
+                       // Single entry = Atom:Entry
+                       $entry = 
$doc->appendChild($doc->createElementNS(self::$nameSpace, "entry"));
+                       $type = 
$entry->appendChild($doc->createElement('content'));
+                       
+                       // addData loops through the responseItem data 
recursively creating a matching XML structure
+                       // and appends the nodes to the $type element
+                       $content = $this->addData($doc, $type, $requestType, 
$data, self::$osNameSpace);
+                       $contentType = 
$type->appendChild($doc->createAttribute('type'));
+                       
$contentType->appendChild($doc->createTextNode('application/xml'));
+                       
+                       // Atom fields
+                       $title = 
$entry->appendChild($doc->createElement('title'));
+                       $author = 
$entry->appendChild($doc->createElement('author'));
+                       $authorUri = 
$author->appendChild($doc->createElement('uri'));
+                       
$authorUri->appendChild($doc->createTextNode(htmlentities($requestItem->getUser()->getUserId($requestItem->getToken(),
 ENT_NOQUOTES, 'UTF-8'))));
+                       $updated = 
$entry->appendChild($doc->createElement('updated'));
+                       
$updated->appendChild($doc->createTextNode(date(DATE_ATOM)));
+                       $id = $entry->appendChild($doc->createElement('id'));
+                       $id->appendChild($doc->createTextNode('urn:guid:' . 
htmlentities($requestItem->getUser()->getUserId($requestItem->getToken()), 
ENT_NOQUOTES, 'UTF-8')));
+               }
+               echo $doc->saveXML();
        
-       function outputBatch(Array $responses)
+       }
+
+       function outputBatch(Array $responses, SecurityToken $token)
        {
-               
+               //TODO once we support spec compliance batching, this needs to 
be added too
+       }
+
+       private function addData(DOMDocument $doc, DOMElement $element, $name, 
$data, $nameSpace = false)
+       {
+               if ($nameSpace) {
+                       $newElement = 
$element->appendChild($doc->createElementNS($nameSpace, $name));
+               } else {
+                       $newElement = 
$element->appendChild($doc->createElement($name));
+               }
+               if (is_array($data)) {
+                       foreach ($data as $key => $val) {
+                               if (is_array($val) || is_object($val)) {
+                                       // prevent invalid names.. try to guess 
a good one :)
+                                       if (is_numeric($key)) {
+                                               $key = is_object($val) ? 
get_class($val) : $key = $name;
+                                       }
+                                       $this->addData($doc, $newElement, $key, 
$val);
+                               } else {
+                                       $elm = 
$newElement->appendChild($doc->createElement($key));
+                                       
$elm->appendChild($doc->createTextNode(htmlentities($val, ENT_NOQUOTES, 
'UTF-8')));
+                               }
+                       }
+               } elseif (is_object($data)) {
+                       if ($data instanceof Enum) {
+                               // enums are output as : <NAME 
key="$key">$displayValue</NAME> 
+                               $keyEntry = 
$newElement->appendChild($doc->createAttribute('key'));
+                               
$keyEntry->appendChild($doc->createTextNode(htmlentities($data->key, 
ENT_NOQUOTES, 'UTF-8')));
+                               
$newElement->appendChild($doc->createTextNode(htmlentities($data->getDisplayValue(),
 ENT_NOQUOTES, 'UTF-8')));
+                       
+                       } else {
+                               $vars = get_object_vars($data);
+                               foreach ($vars as $key => $val) {
+                                       if (is_array($val) || is_object($val)) {
+                                               // prevent invalid names.. try 
to guess a good one :)
+                                               if (is_numeric($key)) {
+                                                       $key = is_object($val) 
? get_class($val) : $key = $name;
+                                               }
+                                               $this->addData($doc, 
$newElement, $key, $val);
+                                       } else {
+                                               $elm = 
$newElement->appendChild($doc->createElement($key));
+                                               
$elm->appendChild($doc->createTextNode(htmlentities($val, ENT_NOQUOTES, 
'UTF-8')));
+                                       }
+                               }
+                       }
+               } else {
+                       
$newElement->appendChild($doc->createTextNode(htmlentities($data, ENT_NOQUOTES, 
'UTF-8')));
+               }
+               return $newElement;
        }
-}
\ No newline at end of file
+}

Modified: 
incubator/shindig/trunk/php/src/socialrest/converters/OutputJsonConverter.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/converters/OutputJsonConverter.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialrest/converters/OutputJsonConverter.php 
(original)
+++ 
incubator/shindig/trunk/php/src/socialrest/converters/OutputJsonConverter.php 
Sat Jul 12 18:27:15 2008
@@ -23,12 +23,12 @@
  */
 class OutputJsonConverter extends OutputConverter {
        
-       function outputResponse(ResponseItem $responseItem)
+       function outputResponse(ResponseItem $responseItem, RestRequestItem 
$requestItem)
        {
                echo json_encode($responseItem->getResponse());
        }
        
-       function outputBatch(Array $responses)
+       function outputBatch(Array $responses, SecurityToken $token)
        {
                echo json_encode(array("responses" => $responses, "error" => 
false));
        }

Modified: incubator/shindig/trunk/php/src/socialrest/http/RestServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/http/RestServlet.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/http/RestServlet.php (original)
+++ incubator/shindig/trunk/php/src/socialrest/http/RestServlet.php Sat Jul 12 
18:27:15 2008
@@ -78,7 +78,7 @@
                                $outputConverter = new OutputJsonConverter();
                                break;
                        case 'atom':
-                               //$this->setContentType('application/xml');
+                               //$this->setContentType('application/atom+xml');
                                $outputConverter = new OutputAtomConverter();
                                break;
                        default:
@@ -86,11 +86,11 @@
                                break;
                }
                if ($this->isBatchUrl()) {
-                       $req = $this->handleBatchRequest($token);
-                       $outputConverter->outputBatch($req);
+                       $responses = $this->handleBatchRequest($token);
+                       $outputConverter->outputBatch($responses, $token);
                } else {
-                       $responseItem = $this->handleSingleRequest($token, 
$method);
-                       $outputConverter->outputResponse($responseItem);
+                       $response = $this->handleSingleRequest($token, $method);
+                       $outputConverter->outputResponse($response['response'], 
$response['request']);
                }
        }
 
@@ -102,7 +102,7 @@
                $requestParam = $this->getRequestParams();
                $requestItem->createRequestItem($url, $token, $method, $params, 
$requestParam);
                $responseItem = $this->getResponseItem($requestItem);
-               return $responseItem;
+               return array('request' => $requestItem, 'response' => 
$responseItem);
        }
 
        private function getRouteFromParameter($pathInfo)
@@ -240,7 +240,8 @@
 
        private function getOutputFormat()
        {
-               return !empty($_POST['format']) ? 
strtolowe(trim($_POST['format'])) : 'json';
+               $output = !empty($_POST['format']) ? $_POST['format'] : 
(!empty($_GET['format']) ? $_GET['format'] : 'json');
+               return strtolower(trim($output));
        }
 
        private function getListParams()

Modified: 
incubator/shindig/trunk/php/src/socialrest/opensocial/ActivitiesService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/opensocial/ActivitiesService.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialrest/opensocial/ActivitiesService.php 
(original)
+++ incubator/shindig/trunk/php/src/socialrest/opensocial/ActivitiesService.php 
Sat Jul 12 18:27:15 2008
@@ -25,9 +25,9 @@
         * @param token A valid SecurityToken
         * @return a response item with the list of activities.
         */
-       abstract public function getActivities(UserId $userId, GroupId 
$groupId, SecurityToken $token);
+       abstract public function getActivities(UserId $userId, $groupId, 
$first, $max, SecurityToken $token);
        
-       abstract public function getActivity(UserId $userId, GroupId $groupId, 
$activityId, SecurityToken $token);
+       abstract public function getActivity(UserId $userId, $groupId, 
$activityId, $first, $max, SecurityToken $token);
 
        /**
         * Creates the passed in activity for the given user. Once 
createActivity is

Modified: 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicActivitiesService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicActivitiesService.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicActivitiesService.php
 (original)
+++ 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicActivitiesService.php
 Sat Jul 12 18:27:15 2008
@@ -19,7 +19,7 @@
 
 class BasicActivitiesService extends ActivitiesService {
 
-       public function getActivity(UserId $userId, GroupId $groupId, 
$activityId, SecurityToken $token)
+       public function getActivity(UserId $userId, $groupId, $activityId, 
$first, $max, SecurityToken $token)
        {
                $activities = $this->getActivities($userId, $groupId, $token);
                $activities = $activities->getResponse();
@@ -34,10 +34,11 @@
                return new ResponseItem(NOT_FOUND, "Activity not found", null);
        }
        
-       public function getActivities(UserId $userId, GroupId $groupId, 
SecurityToken $token)
+       public function getActivities(UserId $userId, $groupId, $first, $max, 
SecurityToken $token)
        {
                $ids = array();
-               switch ($groupId->getType()) {
+               $type = is_object($groupId) ? $groupId->getType() : 'self';
+               switch ($type) {
                        case 'all':
                        case 'friends':
                        $friendIds = XmlStateFileFetcher::get()->getFriendIds();

Modified: 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicPeopleService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicPeopleService.php?rev=676256&r1=676255&r2=676256&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicPeopleService.php
 (original)
+++ 
incubator/shindig/trunk/php/src/socialrest/samplecontainer/BasicPeopleService.php
 Sat Jul 12 18:27:15 2008
@@ -43,7 +43,8 @@
        public function getPeople($userId, $groupId, $sortOrder, $filter, 
$first, $max, $profileDetails, SecurityToken $token)
        {
                $ids = array();
-               switch ($groupId->getType()) {
+               $group = is_object($groupId) ? $groupId->getType() : '';
+               switch ($group) {
                        case 'all':
                        case 'friends':
                                $friendIds = 
XmlStateFileFetcher::get()->getFriendIds();


Reply via email to