Author: bhofmann
Date: Fri Jan 14 15:31:31 2011
New Revision: 1059043
URL: http://svn.apache.org/viewvc?rev=1059043&view=rev
Log:
SHINDIG-952: PHP: added and corrected a lot of PHPdocs
Modified:
shindig/trunk/php/src/social/converters/OutputAtomConverter.php
shindig/trunk/php/src/social/converters/OutputConverter.php
shindig/trunk/php/src/social/converters/OutputJsonConverter.php
shindig/trunk/php/src/social/converters/OutputXmlConverter.php
shindig/trunk/php/src/social/service/ActivityHandler.php
shindig/trunk/php/src/social/service/AlbumHandler.php
shindig/trunk/php/src/social/service/AppDataHandler.php
shindig/trunk/php/src/social/service/DataRequestHandler.php
shindig/trunk/php/src/social/service/GroupHandler.php
shindig/trunk/php/src/social/service/HandlerPreconditions.php
shindig/trunk/php/src/social/service/InvalidateHandler.php
shindig/trunk/php/src/social/service/MediaItemHandler.php
shindig/trunk/php/src/social/service/MessagesHandler.php
shindig/trunk/php/src/social/service/PersonHandler.php
shindig/trunk/php/src/social/service/RequestItem.php
shindig/trunk/php/src/social/service/ResponseError.php
shindig/trunk/php/src/social/service/ResponseItem.php
shindig/trunk/php/src/social/service/RestRequestItem.php
shindig/trunk/php/src/social/service/RpcRequestItem.php
shindig/trunk/php/src/social/service/SystemHandler.php
shindig/trunk/php/src/social/servlet/ApiServlet.php
shindig/trunk/php/src/social/servlet/DataServiceServlet.php
shindig/trunk/php/src/social/servlet/JsonRpcServlet.php
Modified: shindig/trunk/php/src/social/converters/OutputAtomConverter.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/converters/OutputAtomConverter.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputAtomConverter.php (original)
+++ shindig/trunk/php/src/social/converters/OutputAtomConverter.php Fri Jan 14
15:31:31 2011
@@ -33,6 +33,11 @@ class OutputAtomConverter extends Output
'activities' => 'entry', 'messages' => 'entry');
private $doc;
+ /**
+ *
+ * @param ResponseItem $responseItem
+ * @param RestRequestItem $requestItem
+ */
function outputResponse(ResponseItem $responseItem, RestRequestItem
$requestItem) {
$doc = $this->createAtomDoc();
$requestType = $this->getRequestType($requestItem);
@@ -123,6 +128,12 @@ class OutputAtomConverter extends Output
echo $xml;
}
+ /**
+ *
+ * @param array $responses
+ * @param SecurityToken $token
+ * @throws Exception
+ */
function outputBatch(Array $responses, SecurityToken $token) {
throw new Exception("Atom batch not supported");
}
Modified: shindig/trunk/php/src/social/converters/OutputConverter.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/converters/OutputConverter.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputConverter.php (original)
+++ shindig/trunk/php/src/social/converters/OutputConverter.php Fri Jan 14
15:31:31 2011
@@ -23,9 +23,15 @@
*
*/
abstract class OutputConverter {
- private $boundry;
-
+ /**
+ * @param ResponseItem $responseItem
+ * @param RestRequestItem $requestItem
+ */
abstract function outputResponse(ResponseItem $responseItem, RestRequestItem
$requestItem);
+ /**
+ * @param array $responses
+ * @param SecurityToken $token
+ */
abstract function outputBatch(Array $responses, SecurityToken $token);
}
Modified: shindig/trunk/php/src/social/converters/OutputJsonConverter.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/converters/OutputJsonConverter.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputJsonConverter.php (original)
+++ shindig/trunk/php/src/social/converters/OutputJsonConverter.php Fri Jan 14
15:31:31 2011
@@ -24,6 +24,11 @@
*/
class OutputJsonConverter extends OutputConverter {
+ /**
+ *
+ * @param ResponseItem $responseItem
+ * @param RestRequestItem $requestItem
+ */
function outputResponse(ResponseItem $responseItem, RestRequestItem
$requestItem) {
$response = $responseItem->getResponse();
if ($response instanceof RestfulCollection) {
@@ -36,6 +41,11 @@ class OutputJsonConverter extends Output
}
}
+ /**
+ *
+ * @param array $responses
+ * @param SecurityToken $token
+ */
function outputBatch(Array $responses, SecurityToken $token) {
$this->boundryHeaders();
foreach ($responses as $response) {
@@ -46,6 +56,11 @@ class OutputJsonConverter extends Output
}
}
+ /**
+ *
+ * @param array $responses
+ * @param SecurityToken $token
+ */
function outputJsonBatch(Array $responses, SecurityToken $token) {
$this->encodeAndSendResponse(array("responses" => $responses, "error" =>
false));
}
Modified: shindig/trunk/php/src/social/converters/OutputXmlConverter.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/converters/OutputXmlConverter.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputXmlConverter.php (original)
+++ shindig/trunk/php/src/social/converters/OutputXmlConverter.php Fri Jan 14
15:31:31 2011
@@ -32,6 +32,11 @@ class OutputXmlConverter extends OutputC
'activities' => 'entry', 'messages' => 'entry');
private $doc;
+ /**
+ *
+ * @param ResponseItem $responseItem
+ * @param RestRequestItem $requestItem
+ */
function outputResponse(ResponseItem $responseItem, RestRequestItem
$requestItem) {
$doc = $this->createXmlDoc();
$requestType = $this->getRequestType($requestItem);
@@ -66,6 +71,11 @@ class OutputXmlConverter extends OutputC
echo $xml;
}
+ /**
+ *
+ * @param array $responses
+ * @param SecurityToken $token
+ */
function outputBatch(Array $responses, SecurityToken $token) {
throw new Exception("XML batch not supported");
}
Modified: shindig/trunk/php/src/social/service/ActivityHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/ActivityHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/ActivityHandler.php (original)
+++ shindig/trunk/php/src/social/service/ActivityHandler.php Fri Jan 14
15:31:31 2011
@@ -26,6 +26,11 @@ class ActivityHandler extends DataReques
parent::__construct('activity_service');
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
public function handleDelete(RequestItem $requestItem) {
$this->checkService();
$requestItem->applyUrlTemplate(self::$ACTIVITY_ID_PATH);
@@ -46,6 +51,9 @@ class ActivityHandler extends DataReques
* /activities/john.doe/@self/1
* /activities/john.doe/@self
* /activities/john.doe/@friends
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -75,6 +83,9 @@ class ActivityHandler extends DataReques
* /activities/@viewer/@self/@app
* /activities/john.doe/@self
* - postBody is an activity object
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePost(RequestItem $requestItem) {
$this->checkService();
@@ -105,6 +116,9 @@ class ActivityHandler extends DataReques
* examples:
* /activities/john.doe/@self
* - postBody is an activity object
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePut(RequestItem $requestItem) {
return $this->handlePost($requestItem);
Modified: shindig/trunk/php/src/social/service/AlbumHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/AlbumHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/AlbumHandler.php (original)
+++ shindig/trunk/php/src/social/service/AlbumHandler.php Fri Jan 14 15:31:31
2011
@@ -30,6 +30,9 @@ class AlbumHandler extends DataRequestHa
/**
* Deletes the album. The URI structure: /{userId}/{groupId}/{albumId}
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleDelete(RequestItem $requestItem) {
$this->checkService();
@@ -48,6 +51,9 @@ class AlbumHandler extends DataRequestHa
/**
* Gets the albums. The URI structure: /{userId}/{groupId}/{albumId}+.
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -69,6 +75,9 @@ class AlbumHandler extends DataRequestHa
/**
* Creates an album. The URI structure: /{userId}/{groupId}.
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePost(RequestItem $requestItem) {
$this->checkService();
@@ -87,6 +96,9 @@ class AlbumHandler extends DataRequestHa
/**
* Updates the album. The URI structure: /{userId}/{groupId}/{albumId}
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePut(RequestItem $requestItem) {
$this->checkService();
Modified: shindig/trunk/php/src/social/service/AppDataHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/AppDataHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/AppDataHandler.php (original)
+++ shindig/trunk/php/src/social/service/AppDataHandler.php Fri Jan 14 15:31:31
2011
@@ -33,6 +33,8 @@ class AppDataHandler extends DataRequest
* /appdata/john.doe/@friends/app?fields=count
* /appdata/john.doe/@self/app
*
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleDelete(RequestItem $requestItem) {
$this->checkService();
@@ -53,6 +55,9 @@ class AppDataHandler extends DataRequest
* examples:
* /appdata/john.doe/@friends/app?fields=count
* /appdata/john.doe/@self/app
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -75,6 +80,9 @@ class AppDataHandler extends DataRequest
* The post data should be a regular json object. All of the fields vars will
* be pulled from the values and set on the person object. If there are no
* fields vars then all of the data will be overridden.
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePost(RequestItem $requestItem) {
$this->checkService();
@@ -109,6 +117,9 @@ class AppDataHandler extends DataRequest
* The post data should be a regular json object. All of the fields vars will
* be pulled from the values and set on the person object. If there are no
* fields vars then all of the data will be overridden.
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handlePut(RequestItem $requestItem) {
return $this->handlePost($requestItem);
@@ -117,8 +128,8 @@ class AppDataHandler extends DataRequest
/**
* Determines whether the input is a valid key.
*
- * @param key the key to validate.
- * @return true if the key is a valid appdata key, false otherwise.
+ * @param string $key the key to validate.
+ * @return boolean true if the key is a valid appdata key, false otherwise.
*/
public static function isValidKey($key) {
if (empty($key)) {
Modified: shindig/trunk/php/src/social/service/DataRequestHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/DataRequestHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/DataRequestHandler.php (original)
+++ shindig/trunk/php/src/social/service/DataRequestHandler.php Fri Jan 14
15:31:31 2011
@@ -20,7 +20,11 @@
abstract class DataRequestHandler {
protected $service;
-
+
+ /**
+ *
+ * @param string $serviceName
+ */
public function __construct($serviceName) {
try {
$service = trim(Config::get($serviceName));
@@ -39,6 +43,11 @@ abstract class DataRequestHandler {
private static $UPDATE_SYNONYMS = array("put", "update");
private static $DELETE_SYNONYMS = array("delete");
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
public function handleItem(RequestItem $requestItem) {
try {
$token = $requestItem->getToken();
@@ -70,6 +79,12 @@ abstract class DataRequestHandler {
return $response;
}
+ /**
+ *
+ * @param int $appId
+ * @param SecurityToken $token
+ * @return int
+ */
static public function getAppId($appId, SecurityToken $token) {
if ($appId == '@app') {
return $token->getAppId();
@@ -78,6 +93,11 @@ abstract class DataRequestHandler {
}
}
+ /**
+ *
+ * @param string $string
+ * @return object
+ */
static public function convertToObject($string) {
//TODO should detect if it's atom/xml or json here really. assuming json
for now
$decoded = json_decode($string);
@@ -89,7 +109,9 @@ abstract class DataRequestHandler {
/**
* To support people/@supportedFields and activity/@supportedFields
- * @param parameters url parameters to get request type(people/activity)
+ *
+ * @param array $parameters url parameters to get request
type(people/activity)
+ * @return ResponseItem
*/
public function getSupportedFields($parameters) {
$contextClass = Config::get('gadget_context_class');
@@ -110,7 +132,9 @@ abstract class DataRequestHandler {
/**
* To get OpenSocial version for getting supportedFields
- * @param config configuration values from container's js files
+ *
+ * @param array $config configuration values from container's js files
+ * @return string
*/
private function getOpenSocialVersion($config) {
$str = "opensocial-";
@@ -136,11 +160,27 @@ abstract class DataRequestHandler {
}
}
+ /**
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
abstract public function handleDelete(RequestItem $requestItem);
+ /**
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
abstract public function handleGet(RequestItem $requestItem);
+ /**
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
abstract public function handlePost(RequestItem $requestItem);
+ /**
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
abstract public function handlePut(RequestItem $requestItem);
}
Modified: shindig/trunk/php/src/social/service/GroupHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/GroupHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/GroupHandler.php (original)
+++ shindig/trunk/php/src/social/service/GroupHandler.php Fri Jan 14 15:31:31
2011
@@ -31,6 +31,9 @@ class GroupHandler extends DataRequestHa
* examples:
* /groups/john.doe?fields=count
* /groups/@me
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -41,14 +44,30 @@ class GroupHandler extends DataRequestHa
}
return $this->service->getPersonGroups($userIds[0],
$requestItem->getGroup(), $requestItem->getToken());
}
+
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handleDelete(RequestItem $requestItem) {
throw new SocialSpiException("You can't delete groups.",
ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handlePut(RequestItem $requestItem) {
throw new SocialSpiException("You can't update groups.",
ResponseError::$NOT_IMPLEMENTED);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handlePost(RequestItem $requestItem) {
throw new SocialSpiException("You can't add groups.",
ResponseError::$NOT_IMPLEMENTED);
}
Modified: shindig/trunk/php/src/social/service/HandlerPreconditions.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/HandlerPreconditions.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/HandlerPreconditions.php (original)
+++ shindig/trunk/php/src/social/service/HandlerPreconditions.php Fri Jan 14
15:31:31 2011
@@ -25,18 +25,33 @@ class HandlerPreconditions {
private function __construct() {}
+ /**
+ *
+ * @param mixed $item
+ * @param string $message
+ */
public static function requireNotEmpty($item, $message) {
if (empty($item)) {
throw new InvalidArgumentException($message);
}
}
+ /**
+ *
+ * @param mixed $item
+ * @param string $message
+ */
public static function requireEmpty($item, $message) {
if (! empty($item)) {
throw new InvalidArgumentException($message);
}
}
+ /**
+ *
+ * @param mixed $item
+ * @param string $message
+ */
public static function requireSingular($item, $message) {
self::requireNotEmpty($item, $message);
if (count($item) != 1) {
@@ -44,6 +59,11 @@ class HandlerPreconditions {
}
}
+ /**
+ *
+ * @param mixed $item
+ * @param string $message
+ */
public static function requirePlural($item, $message) {
self::requireNotEmpty($item, $message);
if (count($item) <= 1) {
@@ -51,6 +71,11 @@ class HandlerPreconditions {
}
}
+ /**
+ *
+ * @param mixed $item
+ * @param string $message
+ */
public static function requireCondition($cond, $message) {
if (! $cond) {
throw new InvalidArgumentException($message);
Modified: shindig/trunk/php/src/social/service/InvalidateHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/InvalidateHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/InvalidateHandler.php (original)
+++ shindig/trunk/php/src/social/service/InvalidateHandler.php Fri Jan 14
15:31:31 2011
@@ -37,6 +37,11 @@ class InvalidateHandler extends DataRequ
}
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
public function handleItem(RequestItem $requestItem) {
try {
$method = strtolower($requestItem->getMethod());
@@ -50,22 +55,44 @@ class InvalidateHandler extends DataRequ
return $response;
}
+ /**
+ *
+ * @param RequestItem $request
+ * @throws SocialSpiException
+ */
public function handleDelete(RequestItem $request) {
throw new SocialSpiException("Http delete not allowed for invalidation
service", ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $request
+ * @throws SocialSpiException
+ */
public function handlePut(RequestItem $request) {
throw new SocialSpiException("Http put not allowed for invalidation
service", ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ */
public function handlePost(RequestItem $request) {
$this->handleInvalidate($request);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ */
public function handleGet(RequestItem $request) {
$this->handleInvalidate($request);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ */
public function handleInvalidate(RequestItem $request) {
$this->checkService();
if (!$request->getToken()->getAppId() &&
!$request->getToken()->getAppUrl()) {
Modified: shindig/trunk/php/src/social/service/MediaItemHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/MediaItemHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/MediaItemHandler.php (original)
+++ shindig/trunk/php/src/social/service/MediaItemHandler.php Fri Jan 14
15:31:31 2011
@@ -27,6 +27,9 @@ class MediaItemHandler extends DataReque
/**
* Deletes the media items. The URI structure:
/{userId}/{groupId}/{albumId}/{mediaItemId}+
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handleDelete(RequestItem $requestItem) {
$this->checkService();
@@ -46,6 +49,9 @@ class MediaItemHandler extends DataReque
/**
* Gets the media items. The URI structure:
/{userId}/{groupId}/{albumId}/{mediaItemId}+
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -68,6 +74,9 @@ class MediaItemHandler extends DataReque
/**
* Creates the media item. The URI structure: /{userId}/{groupId}/{albumId}.
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handlePost(RequestItem $requestItem) {
$this->checkService();
@@ -113,6 +122,9 @@ class MediaItemHandler extends DataReque
/**
* Fetches the remote media content and saves it as a temporary file.
Returns the meta data of the file.
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
private function processRemoteContent($uri) {
$request = new RemoteContentRequest($uri);
@@ -132,7 +144,9 @@ class MediaItemHandler extends DataReque
/**
* Checks the $_FILES and HTTP_RAW_POST_DATA variables to write the user
uploaded content as a temporary file.
- * Returns the meta data of the file.
+ * Returns the meta data of the file.
+ *
+ * @return array
*/
private function processUploadedContent() {
$file = array();
@@ -169,6 +183,10 @@ class MediaItemHandler extends DataReque
/**
* Writes the binary content to a temporary file and returns the meta data
of the file.
+ *
+ * @param string $rawData
+ * @param string $contentType
+ * @return array
*/
private function writeBinaryContent(&$rawData, $contentType) {
$tmpName = tempnam('', 'shindig');
@@ -182,6 +200,9 @@ class MediaItemHandler extends DataReque
/**
* Returns true if the given content type is valid.
+ *
+ * @param string $contentType
+ * @return boolean
*/
private function isValidContentType($contentType) {
$acceptedMediaPrefixes = array('image', 'video', 'audio');
@@ -191,6 +212,9 @@ class MediaItemHandler extends DataReque
/**
* Updates the mediaItem. The URI structure:
/{userId}/{groupId}/{albumId}/{mediaItemId}
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handlePut(RequestItem $requestItem) {
$this->checkService();
Modified: shindig/trunk/php/src/social/service/MessagesHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/MessagesHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/MessagesHandler.php (original)
+++ shindig/trunk/php/src/social/service/MessagesHandler.php Fri Jan 14
15:31:31 2011
@@ -28,6 +28,9 @@ class MessagesHandler extends DataReques
/**
* Deletes the message collection or the messages.
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handleDelete(RequestItem $requestItem) {
$this->checkService();
@@ -53,6 +56,9 @@ class MessagesHandler extends DataReques
* /messages/john.doe
* /messages/john.doe/notification
* /messages/john.doe/notification/1,2,3
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handleGet(RequestItem $requestItem) {
$this->checkService();
@@ -82,6 +88,9 @@ class MessagesHandler extends DataReques
* Exapmples:
* /messages/john.doe
* /messages/john.doe/notification
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handlePost(RequestItem $requestItem) {
$this->checkService();
@@ -126,6 +135,9 @@ class MessagesHandler extends DataReques
/**
* Updates a message or a message collection.
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handlePut(RequestItem $requestItem) {
$this->checkService();
Modified: shindig/trunk/php/src/social/service/PersonHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/PersonHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/PersonHandler.php (original)
+++ shindig/trunk/php/src/social/service/PersonHandler.php Fri Jan 14 15:31:31
2011
@@ -35,14 +35,29 @@ class PersonHandler extends DataRequestH
parent::__construct('person_service');
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handleDelete(RequestItem $request) {
throw new SocialSpiException("You can't delete people.",
ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handlePut(RequestItem $request) {
throw new SocialSpiException("You can't update right now.",
ResponseError::$NOT_IMPLEMENTED);
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @throws SocialSpiException
+ */
public function handlePost(RequestItem $request) {
throw new SocialSpiException("You can't add people right now.",
ResponseError::$NOT_IMPLEMENTED);
}
@@ -51,6 +66,9 @@ class PersonHandler extends DataRequestH
* Allowed end-points /people/{userId}+/{groupId}
/people/{userId}/{groupId}/{optionalPersonId}+
*
* examples: /people/john.doe/@all /people/john.doe/@friends
/people/john.doe/@self
+ *
+ * @param RequestItem $request
+ * @return ResponseItem
*/
public function handleGet(RequestItem $request) {
$this->checkService();
Modified: shindig/trunk/php/src/social/service/RequestItem.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/RequestItem.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/RequestItem.php (original)
+++ shindig/trunk/php/src/social/service/RequestItem.php Fri Jan 14 15:31:31
2011
@@ -59,12 +59,22 @@ abstract class RequestItem {
protected $service;
+ /**
+ *
+ * @param object $service
+ * @param string $operation
+ * @param SecurityToken $token
+ */
public function __construct($service, $operation, SecurityToken $token) {
$this->service = $service;
$this->operation = $operation;
$this->token = $token;
}
+ /**
+ *
+ * @return int
+ */
public function getAppId() {
$appId = $this->getParameter(self::$APP_ID);
if ($appId != null && $appId == self::$APP_SUBSTITUTION_TOKEN) {
@@ -74,6 +84,10 @@ abstract class RequestItem {
}
}
+ /**
+ *
+ * @return array
+ */
public function getUsers() {
$ids = $this->getListParameter(self::$USER_ID);
if (empty($ids)) {
@@ -91,10 +105,18 @@ abstract class RequestItem {
return $userIds;
}
+ /**
+ *
+ * @return string
+ */
public function getGroup() {
return GroupId::fromJson($this->getParameter(self::$GROUP_ID, "@self"));
}
+ /**
+ *
+ * @return int
+ */
public function getStartIndex() {
$startIndex = $this->getParameter(self::$START_INDEX);
if ($startIndex == null) {
@@ -106,6 +128,10 @@ abstract class RequestItem {
}
}
+ /**
+ *
+ * @return int
+ */
public function getCount() {
$count = $this->getParameter(self::$COUNT);
if ($count == null) {
@@ -117,11 +143,19 @@ abstract class RequestItem {
}
}
+ /**
+ *
+ * @return string
+ */
public function getSortBy() {
$sortBy = $this->getParameter(self::$SORT_BY);
return $sortBy == null ? CollectionOptions::TOP_FRIENDS_SORT : $sortBy;
}
+ /**
+ *
+ * @return string
+ */
public function getSortOrder() {
$sortOrder = $this->getParameter(self::$SORT_ORDER);
if (empty($sortOrder)) {
@@ -133,10 +167,18 @@ abstract class RequestItem {
}
}
+ /**
+ *
+ * @return string
+ */
public function getFilterBy() {
return $this->getParameter(self::$FILTER_BY);
}
+ /**
+ *
+ * @return string
+ */
public function getFilterOperation() {
$filterOp = $this->getParameter(self::$FILTER_OPERATION);
if (empty($filterOp)) {
@@ -148,11 +190,20 @@ abstract class RequestItem {
}
}
+ /**
+ *
+ * @return string
+ */
public function getFilterValue() {
$filterValue = $this->getParameter(self::$FILTER_VALUE);
return empty($filterValue) ? "" : $filterValue;
}
+ /**
+ *
+ * @param array $defaultValue
+ * @return array
+ */
public function getFields(Array $defaultValue = array()) {
$result = array();
$fields = $this->getListParameter(self::$FIELDS);
@@ -174,10 +225,20 @@ abstract class RequestItem {
return $result;
}
+ /**
+ *
+ * @param string $rpcMethod
+ * @return string
+ */
public function getOperation($rpcMethod = null) {
return $this->operation;
}
+ /**
+ *
+ * @param string $rpcMethod
+ * @return object
+ */
public function getService($rpcMethod = null) {
return $this->service;
}
Modified: shindig/trunk/php/src/social/service/ResponseError.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/ResponseError.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/ResponseError.php (original)
+++ shindig/trunk/php/src/social/service/ResponseError.php Fri Jan 14 15:31:31
2011
@@ -55,8 +55,7 @@ class ResponseError {
/**
* Construct a Response Error from the jsonValue as a string and the Http
Error Code.
- * @param jsonValue the json String representation of the error code.
- * @param httpErrorCode the numeric HTTP error code.
+ * @param string $jsonValue the json String representation of the error code.
*/
public function __construct($jsonValue) {
$this->jsonValue = $jsonValue;
@@ -97,6 +96,8 @@ class ResponseError {
/**
*
* Converts the ResponseError to a String representation
+ *
+ * @return string
*/
public function toString() {
return $this->jsonValue;
@@ -104,7 +105,7 @@ class ResponseError {
/**
* Get the HTTP error code.
- * @return the Http Error code.
+ * @return string the Http Error code.
*/
public function getHttpErrorCode() {
return $this->httpErrorCode;
@@ -112,7 +113,7 @@ class ResponseError {
/**
* Get the HTTP error response header.
- * @return the Http response header.
+ * @return string the Http response header.
*/
public function getHttpErrorMsg() {
return $this->httpErrorMsg;
Modified: shindig/trunk/php/src/social/service/ResponseItem.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/ResponseItem.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/ResponseItem.php (original)
+++ shindig/trunk/php/src/social/service/ResponseItem.php Fri Jan 14 15:31:31
2011
@@ -27,6 +27,12 @@ class ResponseItem {
public $errorMessage;
public $response;
+ /**
+ *
+ * @param string $error
+ * @param string $errorMessage
+ * @param mixed $response
+ */
public function __construct($error = null, $errorMessage = null, $response =
null) {
$this->error = $error;
$this->errorMessage = $errorMessage;
@@ -67,26 +73,50 @@ class ResponseItem {
return $object;
}
+ /**
+ *
+ * @return string
+ */
public function getError() {
return isset($this->error) ? $this->error : null;
}
+ /**
+ *
+ * @param string $error
+ */
public function setError($error) {
$this->error = $error;
}
+ /**
+ *
+ * @return string
+ */
public function getErrorMessage() {
return $this->errorMessage;
}
+ /**
+ *
+ * @param string $errorMessage
+ */
public function setErrorMessage($errorMessage) {
$this->errorMessage = $errorMessage;
}
+ /**
+ *
+ * @return mixed
+ */
public function getResponse() {
return $this->response;
}
+ /**
+ *
+ * @param mixed $response
+ */
public function setResponse($response) {
$this->response = $response;
}
Modified: shindig/trunk/php/src/social/service/RestRequestItem.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/RestRequestItem.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/RestRequestItem.php (original)
+++ shindig/trunk/php/src/social/service/RestRequestItem.php Fri Jan 14
15:31:31 2011
@@ -22,7 +22,15 @@
* Represents the request items that come from the restful request.
*/
class RestRequestItem extends RequestItem {
+ /**
+ *
+ * @var string
+ */
private $url;
+ /**
+ *
+ * @var array
+ */
private $params;
/**
@@ -34,8 +42,21 @@ class RestRequestItem extends RequestIte
* @var OutputConverter
*/
private $outputConverter;
+
+ /**
+ *
+ * @var string
+ */
private $postData;
+ /**
+ *
+ * @param object $service
+ * @param string $method
+ * @param SecurityToken $token
+ * @param string $inputConverterMethod
+ * @param OutputConverter $outputConverter
+ */
public function __construct($service, $method, SecurityToken $token,
$inputConverterMethod, $outputConverter) {
parent::__construct($service, $method, $token);
$this->inputConverterMethod = $inputConverterMethod;
@@ -43,6 +64,10 @@ class RestRequestItem extends RequestIte
}
/**
+ * @param $servletRequest
+ * @param SecurityToken $token
+ * @param string $inputConverterMethod
+ * @param OutputConverter $outputConverter
* @return RestRequestItem
*/
public static function createWithRequest($servletRequest, $token,
$inputConverterMethod, $outputConverter) {
@@ -64,14 +89,26 @@ class RestRequestItem extends RequestIte
return $restfulRequestItem;
}
+ /**
+ *
+ * @param string $url
+ */
public function setUrl($url) {
$this->url = $url;
}
+ /**
+ *
+ * @param array $params
+ */
public function setParams($params) {
$this->params = $params;
}
+ /**
+ *
+ * @param string $postData
+ */
public function setPostData($postData) {
$this->postData = $postData;
$service = $this->getServiceFromPath($this->url);
@@ -97,6 +134,9 @@ class RestRequestItem extends RequestIte
/**
* '/people/@me/@self' => 'people'
* '/invalidate?invalidationKey=1' => 'invalidate'
+ *
+ * @param string $pathInfo
+ * @return $pathInfo
*/
static function getServiceFromPath($pathInfo) {
$pathInfo = substr($pathInfo, 1);
@@ -114,6 +154,10 @@ class RestRequestItem extends RequestIte
return $pathInfo;
}
+ /**
+ *
+ * @return string
+ */
static function getMethod() {
if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
return $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
@@ -145,10 +189,19 @@ class RestRequestItem extends RequestIte
}
}
+ /**
+ *
+ * @return aray
+ */
public function getParameters() {
return $this->params;
}
+ /**
+ *
+ * @param string $paramName
+ * @param string $paramValue
+ */
public function setParameter($paramName, $paramValue) {
// Ignore nulls
if ($paramValue == null) {
@@ -159,6 +212,10 @@ class RestRequestItem extends RequestIte
/**
* Return a single param value
+ *
+ * @param string $paramName
+ * @param string $defaultValue
+ * @return string
*/
public function getParameter($paramName, $defaultValue = null) {
$paramValue = isset($this->params[$paramName]) ? $this->params[$paramName]
: null;
@@ -170,6 +227,9 @@ class RestRequestItem extends RequestIte
/**
* Return a list param value
+ *
+ * @param string $paramName
+ * @return array
*/
public function getListParameter($paramName) {
$stringList = isset($this->params[$paramName]) ? $this->params[$paramName]
: null;
Modified: shindig/trunk/php/src/social/service/RpcRequestItem.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/RpcRequestItem.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/RpcRequestItem.php (original)
+++ shindig/trunk/php/src/social/service/RpcRequestItem.php Fri Jan 14 15:31:31
2011
@@ -25,6 +25,11 @@ class RpcRequestItem extends RequestItem
private $data;
+ /**
+ *
+ * @param array $rpc
+ * @param SecurityToken $token
+ */
public function __construct($rpc, SecurityToken $token) {
if (empty($rpc['method'])) {
throw new SocialSpiException("Missing method in RPC call");
@@ -37,6 +42,11 @@ class RpcRequestItem extends RequestItem
}
}
+ /**
+ *
+ * @param string $rpcMethod
+ * @return string
+ */
public function getService($rpcMethod = null) {
$service = null;
if ($rpcMethod != null) {
@@ -51,6 +61,11 @@ class RpcRequestItem extends RequestItem
return $service;
}
+ /**
+ *
+ * @param string $rpcMethod
+ * @return string
+ */
public function getOperation($rpcMethod = null) {
if ($rpcMethod != null) {
$op = substr($rpcMethod, strpos($rpcMethod, '.') + 1);
@@ -60,14 +75,29 @@ class RpcRequestItem extends RequestItem
return $op;
}
+ /**
+ *
+ * @param string $rpcMethod
+ * @return string
+ */
public function getMethod($rpcMethod = null) {
return $this->getOperation($rpcMethod);
}
+ /**
+ *
+ * @return array
+ */
public function getParameters() {
return $this->data;
}
+ /**
+ *
+ * @param string $paramName
+ * @param string $defaultValue
+ * @return string
+ */
public function getParameter($paramName, $defaultValue = null) {
if (isset($this->data[$paramName])) {
return $this->data[$paramName];
@@ -76,6 +106,11 @@ class RpcRequestItem extends RequestItem
}
}
+ /**
+ *
+ * @param string $paramName
+ * @return array
+ */
public function getListParameter($paramName) {
if (isset($this->data[$paramName])) {
if (is_array($this->data[$paramName])) {
@@ -89,6 +124,10 @@ class RpcRequestItem extends RequestItem
}
}
+ /**
+ *
+ * @param string $urlTemplate
+ */
public function applyUrlTemplate($urlTemplate) { // No params in the URL
}
}
Modified: shindig/trunk/php/src/social/service/SystemHandler.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/service/SystemHandler.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/service/SystemHandler.php (original)
+++ shindig/trunk/php/src/social/service/SystemHandler.php Fri Jan 14 15:31:31
2011
@@ -26,6 +26,11 @@ class SystemHandler extends DataRequestH
public function __construct() { // do nothing, listMethods doesn't have a
service implementation since it depends on the container.js configuration
}
+ /**
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
+ */
public function handleItem(RequestItem $requestItem) {
try {
$method = strtolower($requestItem->getMethod());
@@ -39,22 +44,44 @@ class SystemHandler extends DataRequestH
return $response;
}
+ /**
+ *
+ * @param RequestItem $request
+ */
public function handleDelete(RequestItem $request) {
throw new SocialSpiException("Http delete not allowed for invalidation
service", ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $request
+ */
public function handlePut(RequestItem $request) {
throw new SocialSpiException("Http put not allowed for invalidation
service", ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $request
+ */
public function handlePost(RequestItem $request) {
throw new SocialSpiException("Http put not allowed for invalidation
service", ResponseError::$BAD_REQUEST);
}
+ /**
+ *
+ * @param RequestItem $request
+ * @return array
+ */
public function handleGet(RequestItem $request) {
return $this->handleListMethods($request);
}
+ /**
+ *
+ * @param RequestItem $request
+ * @return array
+ */
public function handleListMethods(RequestItem $request) {
$containerConfigClass = Config::get('container_config_class');
$containerConfig = new
$containerConfigClass(Config::get('container_path'));
Modified: shindig/trunk/php/src/social/servlet/ApiServlet.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/servlet/ApiServlet.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/servlet/ApiServlet.php (original)
+++ shindig/trunk/php/src/social/servlet/ApiServlet.php Fri Jan 14 15:31:31 2011
@@ -80,6 +80,10 @@ abstract class ApiServlet extends HttpSe
}
}
+ /**
+ *
+ * @return SecurityToken
+ */
public function getSecurityToken() {
// Support a configurable host name ('http_host' key) so that OAuth
signatures don't fail in reverse-proxy type situations
$scheme = (! isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ?
'http' : 'https';
@@ -123,6 +127,9 @@ abstract class ApiServlet extends HttpSe
return $gadgetSigner->createToken($token);
}
+ /**
+ * @param ResponseItem $responseItem
+ */
protected abstract function sendError(ResponseItem $responseItem);
protected function sendSecurityError() {
@@ -131,6 +138,9 @@ abstract class ApiServlet extends HttpSe
/**
* Delivers a request item to the appropriate DataRequestHandler.
+ *
+ * @param RequestItem $requestItem
+ * @return ResponseItem
*/
protected function handleRequestItem(RequestItem $requestItem) {
// lazy initialization of the service handlers, no need to instance them
all for each request
@@ -153,6 +163,11 @@ abstract class ApiServlet extends HttpSe
return $handler->handleItem($requestItem);
}
+ /**
+ *
+ * @param mixed $result
+ * @return ResponseItem
+ */
protected function getResponseItem($result) {
if ($result instanceof ResponseItem) {
return $result;
@@ -161,6 +176,11 @@ abstract class ApiServlet extends HttpSe
}
}
+ /**
+ *
+ * @param Exception $e
+ * @return ResponseItem
+ */
protected function responseItemFromException($e) {
if ($e instanceof SocialSpiException) {
return new ResponseItem($e->getCode(), $e->getMessage(), null);
Modified: shindig/trunk/php/src/social/servlet/DataServiceServlet.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/servlet/DataServiceServlet.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/servlet/DataServiceServlet.php (original)
+++ shindig/trunk/php/src/social/servlet/DataServiceServlet.php Fri Jan 14
15:31:31 2011
@@ -62,6 +62,10 @@ class DataServiceServlet extends ApiServ
}
}
+ /**
+ *
+ * @param ResponseItem $responseItem
+ */
public function sendError(ResponseItem $responseItem) {
$unauthorized = false;
$errorMessage = $responseItem->getErrorMessage();
@@ -98,6 +102,10 @@ class DataServiceServlet extends ApiServ
/**
* Handler for non-batch requests (REST only has non-batch requests)
+ *
+ * @param SecurityToken $token
+ * @param string $inputConverterMethod
+ * @param OutputConverter $outputConverter
*/
private function handleSingleRequest(SecurityToken $token,
$inputConverterMethod, $outputConverter) {
//uri example: /social/rest/people/@self
/gadgets/api/rest/cache/invalidate
Modified: shindig/trunk/php/src/social/servlet/JsonRpcServlet.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/social/servlet/JsonRpcServlet.php?rev=1059043&r1=1059042&r2=1059043&view=diff
==============================================================================
--- shindig/trunk/php/src/social/servlet/JsonRpcServlet.php (original)
+++ shindig/trunk/php/src/social/servlet/JsonRpcServlet.php Fri Jan 14 15:31:31
2011
@@ -66,6 +66,11 @@ class JsonRpcServlet extends ApiServlet
}
}
+ /**
+ *
+ * @param array $batch
+ * @param SecurityToken $token
+ */
public function dispatchBatch($batch, $token) {
$responses = array();
// Gather all Futures. We do this up front so that
@@ -89,6 +94,11 @@ class JsonRpcServlet extends ApiServlet
$this->encodeAndSendResponse($result);
}
+ /**
+ *
+ * @param array $request
+ * @param SecurityToken $token
+ */
public function dispatch($request, $token) {
$key = null;
if (isset($request["id"])) {
@@ -102,6 +112,12 @@ class JsonRpcServlet extends ApiServlet
$this->encodeAndSendResponse($result);
}
+ /**
+ *
+ * @param string $key
+ * @param ResponseItem $responseItem
+ * @return array
+ */
private function getJSONResponse($key, ResponseItem $responseItem) {
$result = array();
if ($key != null) {
@@ -129,6 +145,11 @@ class JsonRpcServlet extends ApiServlet
// TODO(doll): Refactor the responseItem so that the fields on it line up
with this format.
// Then we can use the general converter to output the response to the
client and we won't
// be harcoded to json.
+ /**
+ *
+ * @param ResponseItem $responseItem
+ * @return array
+ */
private function getErrorJson(ResponseItem $responseItem) {
$error = array();
$error["code"] = $responseItem->getError();
@@ -141,6 +162,7 @@ class JsonRpcServlet extends ApiServlet
* to client
*
* @param array $data
+ * @return string
*/
private function encodeAndSendResponse($data) {
// TODO: Refactor this class to use the OutputJsonConverter, so that we do
not have to duplicate
@@ -152,12 +174,12 @@ class JsonRpcServlet extends ApiServlet
echo json_encode($data);
}
+ /**
+ *
+ * @param ResponseItem $responseItem
+ */
public function sendError(ResponseItem $responseItem) {
$error = $this->getErrorJson($responseItem);
$this->encodeAndSendResponse($error);
}
-
- private function sendBadRequest($t, $response) {
- $this->sendError($response, new ResponseItem(ResponseError::$BAD_REQUEST,
"Invalid batch - " + $t->getMessage()));
- }
}