You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/05/01 14:36:33 UTC
svn commit: r652498 [3/4] - in /incubator/shindig/trunk/php: ./ gadgets/
src/ src/common/ src/gadgets/ src/gadgets/http/
src/gadgets/samplecontainer/ src/socialdata/ src/socialdata/http/
src/socialdata/opensocial/ src/socialdata/opensocial/model/ src/s...
Added: incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicRemoteContentFetcher.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicRemoteContentFetcher.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicRemoteContentFetcher.php (added)
+++ incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicRemoteContentFetcher.php Thu May 1 05:36:31 2008
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/*
+ * Basic remote content fetcher, uses curl_multi to fetch multiple resources at the same time
+ */
+
+class BasicRemoteContentFetcher extends RemoteContentFetcher {
+ private $requests = array();
+
+ public function fetchRequest($request)
+ {
+ $request->handle = curl_init();
+ curl_setopt($request->handle, CURLOPT_URL, $request->getUrl());
+ curl_setopt($request->handle, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($request->handle, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($request->handle, CURLOPT_AUTOREFERER, 1);
+ curl_setopt($request->handle, CURLOPT_MAXREDIRS, 10);
+ curl_setopt($request->handle, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($request->handle, CURLOPT_TIMEOUT, 20);
+ curl_setopt($request->handle, CURLOPT_HEADER, 1);
+ if ($request->hasHeaders()) {
+ $headers = explode("\n", $request->getHeaders());
+ $outHeaders = array();
+ foreach ( $headers as $header ) {
+ if (strpos($header, ':')) {
+ $key = trim(substr($header, 0, strpos($header, ':')));
+ $val = trim(substr($header, strpos($header, ':') + 1));
+ if (strcasecmp($key, "Transfer-Encoding") != 0 && strcasecmp($key, "Cache-Control") != 0 && strcasecmp($key, "Expires") != 0 && strcasecmp($key, "Content-Length") != 0) {
+ $outHeaders[] = "$key: $val";
+ }
+ }
+ }
+ curl_setopt($request->handle, CURLOPT_HTTPHEADER, $outHeaders);
+ }
+ if ($request->isPost()) {
+ curl_setopt($request->handle, CURLOPT_POST, 1);
+ curl_setopt($request->handle, CURLOPT_POSTFIELDS, $request->getPostBody());
+ }
+ // Execute the request
+ $content = @curl_exec($request->handle);
+ $header = '';
+ $body = '';
+ // on redirects and such we get multiple headers back from curl it seems, we really only want the last one
+ while ( substr($content, 0, strlen('HTTP')) == 'HTTP' && strpos($content, "\r\n\r\n") !== false ) {
+ $header = substr($content, 0, strpos($content, "\r\n\r\n"));
+ $body = substr($content, strlen($header) + 4);
+ $content = substr($content, strlen($header) + 4);
+ }
+ $httpCode = curl_getinfo($request->handle, CURLINFO_HTTP_CODE);
+ $contentType = curl_getinfo($request->handle, CURLINFO_CONTENT_TYPE);
+ if (! $httpCode) {
+ $httpCode = '404';
+ }
+ $request->setHttpCode($httpCode);
+ $request->setContentType($contentType);
+ $request->setResponseHeaders($header);
+ $request->setResponseContent($body);
+ $request->setResponseSize(strlen($content));
+ curl_close($request->handle);
+ unset($request->handle);
+ return $request;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/DataResponse.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/DataResponse.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/DataResponse.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/DataResponse.php Thu May 1 05:36:31 2008
@@ -0,0 +1,50 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class DataResponse {
+
+ public $responses;
+ public $error;
+
+ public function __construct($responses = array(), $error = null)
+ {
+ $this->error = $error;
+ $this->responses = $responses;
+ }
+
+ public function getResponses()
+ {
+ return $this->responses;
+ }
+
+ public function setResponses($responses)
+ {
+ $this->responses = $responses;
+ }
+
+ public function getError()
+ {
+ return $this->error;
+ }
+
+ public function setError($error)
+ {
+ $this->error = $error;
+ }
+}
\ No newline at end of file
Added: incubator/shindig/trunk/php/src/socialdata/GadgetDataHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/GadgetDataHandler.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/GadgetDataHandler.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/GadgetDataHandler.php Thu May 1 05:36:31 2008
@@ -0,0 +1,38 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+abstract class GadgetDataHandler {
+
+ /**
+ * Determines whether this handler should be used to process the request
+ *
+ * @param requestType The type of request made
+ * @return true if this handler should be called to create a response item for
+ * this json request
+ */
+ abstract function shouldHandle($requestType);
+
+ /**
+ * Constructs a ResponseItem based on the parameters in the RequestItem
+ *
+ * @param request The request from the json
+ * @return The corresponding response item
+ */
+ abstract function handleRequest($request);
+}
Added: incubator/shindig/trunk/php/src/socialdata/RequestItem.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/RequestItem.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/RequestItem.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/RequestItem.php Thu May 1 05:36:31 2008
@@ -0,0 +1,65 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * Represents the request items that come from the json. Each RequestItem should
+ * map to one ResponseItem.
+ */
+class RequestItem {
+ private $type;
+ private $params;
+ private $token;
+
+ public function __construct($type, $params, $token)
+ {
+ $this->type = $type;
+ $this->params = $params;
+ $this->token = $token;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ public function getParams()
+ {
+ return $this->params;
+ }
+
+ public function setParams($params)
+ {
+ $this->params = $params;
+ }
+
+ public function getToken()
+ {
+ return $this->token;
+ }
+
+ public function setToken($token)
+ {
+ $this->token = $token;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/ResponseItem.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/ResponseItem.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/ResponseItem.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/ResponseItem.php Thu May 1 05:36:31 2008
@@ -0,0 +1,65 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * Represents the response items that get handed back as json within the
+ * DataResponse
+ */
+class ResponseItem {
+ public $error;
+ public $errorMessage;
+ public $response;
+
+ public function __construct($error = null, $errorMessage = null, $response = null)
+ {
+ $this->error = $error;
+ $this->errorMessage = $errorMessage;
+ $this->response = $response;
+ }
+
+ public function getError()
+ {
+ return $this->error;
+ }
+
+ public function setError($error)
+ {
+ $this->error = $error;
+ }
+
+ public function getErrorMessage()
+ {
+ return $this->errorMessage;
+ }
+
+ public function setErrorMessage($errorMessage)
+ {
+ $this->errorMessage = $errorMessage;
+ }
+
+ public function getResponse()
+ {
+ return $this->response;
+ }
+
+ public function setResponse($response)
+ {
+ $this->response = $response;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php Thu May 1 05:36:31 2008
@@ -0,0 +1,80 @@
+<?php
+// Response item error codes
+define('NOT_IMPLEMENTED', "notImplemented");
+define('UNAUTHORIZED', "unauthorized");
+define('FORBIDDEN', "forbidden");
+define('BAD_REQUEST', "badRequest");
+define('INTERNAL_ERROR', "internalError");
+
+class GadgetDataServlet extends HttpServlet {
+ private $handlers = array();
+
+ public function __construct()
+ {
+ global $config;
+ if (empty($config['handlers'])) {
+ $this->handlers[] = new OpenSocialDataHandler();
+ $this->handlers[] = new StateFileDataHandler();
+ } else {
+ $handlers = explode(',', $config['handlers']);
+ foreach ( $handlers as $handler ) {
+ $this->handlers[] = new $handler();
+ }
+ }
+ }
+
+ public function doPost()
+ {
+ $requestParam = isset($_POST['request']) ? $_POST['request'] : '';
+ $token = isset($_POST['st']) ? $_POST['st'] : '';
+ $request = json_decode($requestParam, true);
+ if ($request == $requestParam) {
+ // oddly enough if the json_decode function can't parse the code,
+ // it just returns the original string (instead of something usefull like 'null' or false :))
+ throw new Exception("Invalid request JSON");
+ }
+
+ try {
+ $response = new DataResponse($this->createResponse($requestParam, $token));
+ } catch ( Exception $e ) {
+ $response = new DataResponse(false, BAD_REQUEST);
+ }
+ echo json_encode($response);
+ }
+
+ private function createResponse($requestParam, $token)
+ {
+ global $config;
+ if (empty($token)) {
+ throw new Exception("INVALID_GADGET_TOKEN");
+ }
+ $gadgetSigner = new $config['gadget_signer']();
+ //FIXME currently don't have a propper token, impliment and re-enable this asap
+ $securityToken = $gadgetSigner->createToken($token);
+ $responseItems = array();
+ $requests = json_decode($requestParam, true);
+ if ($requests == $requestParam) {
+ // oddly enough if the json_decode function can't parse the code,
+ // it just returns the original string
+ throw new Exception("Invalid request JSON");
+ }
+ foreach ( $requests as $request ) {
+ $requestItem = new RequestItem($request['type'], $request, $securityToken);
+ $response = new ResponseItem(NOT_IMPLEMENTED, $request['type'] . " has not been implemented yet.", array());
+ foreach ( $this->handlers as $handler ) {
+ if ($handler->shouldHandle($request['type'])) {
+ $response = $handler->handleRequest($requestItem);
+ }
+ }
+ $responseItems[] = $response;
+ }
+ return $responseItems;
+ }
+
+ public function doGet()
+ {
+ echo
+ header("HTTP/1.0 400 Bad Request", true, 400);
+ die("<h1>Bad Request</h1>");
+ }
+}
\ No newline at end of file
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/ActivitiesService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/ActivitiesService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/ActivitiesService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/ActivitiesService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,39 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+abstract class ActivitiesService {
+
+ /**
+ * Returns a list of activities that correspond to the passed in person ids.
+ * @param ids The ids of the people to fetch activities for.
+ * @param token A valid GadgetToken
+ * @return a response item with the list of activities.
+ */
+ abstract public function getActivities($ids, $token);
+
+ /**
+ * Creates the passed in activity for the given user. Once createActivity is
+ * called, getActivities will be able to return the Activity.
+ * @param personId The id of the person to create the activity for.
+ * @param activity The activity to create.
+ * @param token A valid GadgetToken
+ * @return a response item containing any errors
+ */
+ abstract public function createActivity($personId, $activity, $token);
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/DataService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/DataService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/DataService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/DataService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,43 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+abstract class DataService {
+
+ /**
+ * Fetch data for a list of ids.
+ * @param ids The list of ids
+ * @param keys The list of keys to fetch
+ * @param token The GadgetToken for this request
+ * @return ResponseItem a response item with the error code set if
+ * there was a problem
+ */
+ abstract public function getPersonData($ids, $keys, $token);
+
+ /**
+ * Updates the data key for the given person with the new value.
+ *
+ * @param id The person the data is for.
+ * @param key The key of the data.
+ * @param value The new value of the data.
+ * @param token The GadgetToken for this request
+ * @return ResponseItem a response item with the error code set if
+ * there was a problem
+ */
+ abstract public function updatePersonData($id, $key, $value, $token);
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/PeopleService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/PeopleService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/PeopleService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/PeopleService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,44 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+abstract class PeopleService {
+ public $sortOrder = array('topFriends', 'name');
+ public $filterType = array('all', 'hasApp');
+
+ /**
+ * Returns a list of people ids that the other handlers (currently data
+ * and activities) can use to fetch their own objects
+ *
+ * @param idSpec The idSpec to translate into ids
+ * @return a list of person ids
+ * @throws JSONException If the idSpec is malformed
+ */
+ abstract public function getIds($idSpec, $token);
+
+ /**
+ * Returns a list of people that correspond to the passed in person ids.
+ * @param ids The ids of the people to fetch.
+ * @param sortOrder How to sort the people
+ * @param filter How the people should be filtered.
+ * @param first The index of the first person to fetch.
+ * @param max The max number of people to fetch.
+ * @return a list of people.
+ */
+ abstract public function getPeople($ids, $sortOrder, $filter, $first, $max, $profileDetails, $token);
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Activity.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Activity.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Activity.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Activity.php Thu May 1 05:36:31 2008
@@ -0,0 +1,214 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class Activity {
+ public $appId;
+ public $body;
+ public $bodyId;
+ public $externalId;
+ public $id;
+ public $mediaItems;
+ public $postedTime;
+ public $priority;
+ public $streamFaviconUrl;
+ public $streamSourceUrl;
+ public $streamTitle;
+ public $streamUrl;
+ public $templateParams;
+ public $title;
+ public $titleId;
+ public $url;
+ public $userId;
+
+ public function __construct($id, $userId)
+ {
+ $this->id = $id;
+ $this->userId = $userId;
+ }
+
+ public function getAppId()
+ {
+ return $this->appId;
+ }
+
+ public function setAppId($appId)
+ {
+ $this->appId = $appId;
+ }
+
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ public function setBody($body)
+ {
+ $this->body = $body;
+ }
+
+ public function getBodyId()
+ {
+ return $this->bodyId;
+ }
+
+ public function setBodyId($bodyId)
+ {
+ $this->bodyId = $bodyId;
+ }
+
+ public function getExternalId()
+ {
+ return $this->externalId;
+ }
+
+ public function setExternalId($externalId)
+ {
+ $this->externalId = $externalId;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function setId($id)
+ {
+ $this->id = $id;
+ }
+
+ public function getMediaItems()
+ {
+ return $this->mediaItems;
+ }
+
+ public function setMediaItems($mediaItems)
+ {
+ $this->mediaItems = $mediaItems;
+ }
+
+ public function getPostedTime()
+ {
+ return $this->postedTime;
+ }
+
+ public function setPostedTime($postedTime)
+ {
+ $this->postedTime = $postedTime;
+ }
+
+ public function getPriority()
+ {
+ return $this->priority;
+ }
+
+ public function setPriority($priority)
+ {
+ $this->priority = $priority;
+ }
+
+ public function getStreamFaviconUrl()
+ {
+ return $this->streamFaviconUrl;
+ }
+
+ public function setStreamFaviconUrl($streamFaviconUrl)
+ {
+ $this->streamFaviconUrl = $streamFaviconUrl;
+ }
+
+ public function getStreamSourceUrl()
+ {
+ return $this->streamSourceUrl;
+ }
+
+ public function setStreamSourceUrl($streamSourceUrl)
+ {
+ $this->streamSourceUrl = $streamSourceUrl;
+ }
+
+ public function getStreamTitle()
+ {
+ return $this->streamTitle;
+ }
+
+ public function setStreamTitle($streamTitle)
+ {
+ $this->streamTitle = $streamTitle;
+ }
+
+ public function getStreamUrl()
+ {
+ return $this->streamUrl;
+ }
+
+ public function setStreamUrl($streamUrl)
+ {
+ $this->streamUrl = $streamUrl;
+ }
+
+ public function getTemplateParams()
+ {
+ return $this->templateParams;
+ }
+
+ public function setTemplateParams($templateParams)
+ {
+ $this->templateParams = $templateParams;
+ }
+
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ }
+
+ public function getTitleId()
+ {
+ return $this->titleId;
+ }
+
+ public function setTitleId($titleId)
+ {
+ $this->titleId = $titleId;
+ }
+
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+
+ public function getUserId()
+ {
+ return $this->userId;
+ }
+
+ public function setUserId($userId)
+ {
+ $this->userId = $userId;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Address.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Address.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Address.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Address.php Thu May 1 05:36:31 2008
@@ -0,0 +1,153 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Address.Field.html
+ *
+ */
+class Address {
+ public $country;
+ public $extendedAddress;
+ public $latitude;
+ public $longitude;
+ public $locality;
+ public $poBox;
+ public $postalCode;
+ public $region;
+ public $streetAddress;
+ public $type;
+ public $unstructuredAddress;
+
+ public function __construct($unstructuredAddress)
+ {
+ $this->unstructuredAddress = $unstructuredAddress;
+ }
+
+ public function getCountry()
+ {
+ return $this->country;
+ }
+
+ public function setCountry($country)
+ {
+ $this->country = $country;
+ }
+
+ public function getExtendedAddress()
+ {
+ return $this->extendedAddress;
+ }
+
+ public function setExtendedAddress($extendedAddress)
+ {
+ $this->extendedAddress = $extendedAddress;
+ }
+
+ public function getLatitude()
+ {
+ return $this->latitude;
+ }
+
+ public function setLatitude($latitude)
+ {
+ $this->latitude = $latitude;
+ }
+
+ public function getLocality()
+ {
+ return $this->locality;
+ }
+
+ public function setLocality($locality)
+ {
+ $this->locality = $locality;
+ }
+
+ public function getLongitude()
+ {
+ return $this->longitude;
+ }
+
+ public function setLongitude($longitude)
+ {
+ $this->longitude = $longitude;
+ }
+
+ public function getPoBox()
+ {
+ return $this->poBox;
+ }
+
+ public function setPoBox($poBox)
+ {
+ $this->poBox = $poBox;
+ }
+
+ public function getPostalCode()
+ {
+ return $this->postalCode;
+ }
+
+ public function setPostalCode($postalCode)
+ {
+ $this->postalCode = $postalCode;
+ }
+
+ public function getRegion()
+ {
+ return $this->region;
+ }
+
+ public function setRegion($region)
+ {
+ $this->region = $region;
+ }
+
+ public function getStreetAddress()
+ {
+ return $this->streetAddress;
+ }
+
+ public function setStreetAddress($streetAddress)
+ {
+ $this->streetAddress = $streetAddress;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ public function getUnstructuredAddress()
+ {
+ return $this->unstructuredAddress;
+ }
+
+ public function setUnstructuredAddress($unstructuredAddress)
+ {
+ $this->unstructuredAddress = $unstructuredAddress;
+ }
+
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/ApiCollection.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/ApiCollection.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/ApiCollection.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/ApiCollection.php Thu May 1 05:36:31 2008
@@ -0,0 +1,65 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Collection.html
+ */
+class ApiCollection {
+ public $items = array();
+ public $offset;
+ public $totalSize;
+
+ public function __construct($items, $offset = false, $totalSize = false)
+ {
+ $this->items = $items;
+ $this->offset = $offset;
+ $this->totalSize = $totalSize;
+ }
+
+ public function getItems()
+ {
+ return $this->items;
+ }
+
+ public function setItems($items)
+ {
+ $this->items = $items;
+ }
+
+ public function getOffset()
+ {
+ return $this->offset;
+ }
+
+ public function setOffset($offset)
+ {
+ $this->offset = $offset;
+ }
+
+ public function getTotalSize()
+ {
+ return $this->totalSize;
+ }
+
+ public function setTotalSize($totalSize)
+ {
+ $this->totalSize = $totalSize;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/BodyType.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/BodyType.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/BodyType.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/BodyType.php Thu May 1 05:36:31 2008
@@ -0,0 +1,81 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.BodyType.Field.html
+ *
+ */
+class BodyType {
+ public $build;
+ public $eyeColor;
+ public $hairColor;
+ public $height;
+ public $weight;
+
+ public function getBuild()
+ {
+ return $this->build;
+ }
+
+ public function setBuild($build)
+ {
+ $this->build = $build;
+ }
+
+ public function getEyeColor()
+ {
+ return $this->eyeColor;
+ }
+
+ public function setEyeColor($eyeColor)
+ {
+ $this->eyeColor = $eyeColor;
+ }
+
+ public function getHairColor()
+ {
+ return $this->hairColor;
+ }
+
+ public function setHairColor($hairColor)
+ {
+ $this->hairColor = $hairColor;
+ }
+
+ public function getHeight()
+ {
+ return $this->height;
+ }
+
+ public function setHeight($height)
+ {
+ $this->height = $height;
+ }
+
+ public function getWeight()
+ {
+ return $this->weight;
+ }
+
+ public function setWeight($weight)
+ {
+ $this->weight = $weight;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Email.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Email.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Email.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Email.php Thu May 1 05:36:31 2008
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Email.Field.html
+ *
+ */
+class Email {
+ public $address;
+ public $type;
+
+ public function __constructor($address, $type)
+ {
+ $this->address = $address;
+ $this->type = $type;
+ }
+
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ public function setAddress($address)
+ {
+ $this->address = $address;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Enum.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Enum.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Enum.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Enum.php Thu May 1 05:36:31 2008
@@ -0,0 +1,101 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Enum.html
+ *
+ * Base class for all Enum objects. This class allows containers to use constants
+ * for fields that have a common set of values.
+ *
+ */
+
+abstract class Enum {
+ public $displayValue;
+ private $jsonString;
+ public $values = array();
+
+ public function __construct($jsonString, $displayValue)
+ {
+ //FIXME should add enum restriction checking to this
+ if (!isset($this->values[$jsonString])) {
+ throw new Exception("Invalid Enum key");
+ }
+ $this->jsonString = $jsonString;
+ $this->displayValue = $displayValue;
+ }
+
+ public function getDisplayValue()
+ {
+ return $this->displayValue;
+ }
+
+ public function setDisplayValue($displayValue)
+ {
+ $this->displayValue = $displayValue;
+ }
+
+ public function toString()
+ {
+ return $this->jsonString;
+ }
+}
+
+
+/**
+ * public Enum for opensocial.Enum.Drinker
+ */
+class EnumDrinker extends Enum {
+ public $values = array (
+ 'HEAVILY' => "Heavily",
+ 'NO' => "No",
+ 'OCCASIONALLY' => "Occasionally",
+ 'QUIT' => "Quit",
+ 'QUITTING' => "Quitting",
+ 'REGULARLY' => "Regularly",
+ 'SOCIALLY' => "Socially",
+ 'YES' => "Yes"
+ );
+}
+
+/**
+ * public Enum for opensocial.Enum.Gender
+ */
+class EnumGender extends Enum {
+ public $values = array (
+ 'FEMALE' => "Female",
+ 'MALE' => "Male"
+ );
+}
+
+/**
+ * public Enum for opensocial.Enum.Smoker
+ */
+class EnumSmoker extends Enum {
+ public $values = array(
+ 'HEAVILY' => "Heavily",
+ 'NO' => "No",
+ 'OCCASIONALLY' => "Ocasionally",
+ 'QUIT' => "Quit",
+ 'QUITTING' => "Quitting",
+ 'REGULARLY' => "Regularly",
+ 'SOCIALLY' => "Socially",
+ 'YES' => "Yes"
+ );
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/MediaItem.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/MediaItem.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/MediaItem.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/MediaItem.php Thu May 1 05:36:31 2008
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.MediaItem.Field.html
+ *
+ */
+class MediaItem {
+ public $mimeType;
+ public $type;
+ public $url;
+
+ public $types = array('AUDIO', 'VIDEO', 'IMAGE');
+
+ public function __construct($mimeType, $type, $url)
+ {
+ $this->setMimeType($mimeType);
+ $this->setType($type);
+ $this->setUrl($url);
+ }
+
+ public function getMimeType()
+ {
+ return $this->mimeType;
+ }
+
+ public function setMimeType($mimeType)
+ {
+ $this->mimeType = $mimeType;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ if (! in_array($type, $this->types)) {
+ throw new Exception("Invalid Media type");
+ }
+ $this->type = $type;
+ }
+
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Message.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Message.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Message.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Message.php Thu May 1 05:36:31 2008
@@ -0,0 +1,119 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ *
+ * Base interface for all message objects.
+ *
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Message.html
+ *
+ */
+class Message {
+ public $body;
+ public $title;
+ public $type;
+ public $types = array(
+ /* An email */
+ 'EMAIL',
+ /* A short private message */
+ 'NOTIFICATION',
+ /* A message to a specific user that can be seen only by that user */
+ 'PRIVATE_MESSAGE',
+ /* A message to a specific user that can be seen by more than that user */
+ 'PUBLIC_MESSAGE');
+
+ public function __construct($initBody, $initTitle, $initType)
+ {
+ $this->setBody($initBody);
+ $this->setTitle($initTitle);
+ $this->setType($initType);
+ }
+
+ /**
+ * Gets the main text of the message.
+ * @return the main text of the message
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * Sets the main text of the message.
+ * HTML attributes are allowed and are sanitized by the container
+ * @param newBody the main text of the message
+ */
+ public function setBody($newBody)
+ {
+ $this->body = $newBody;
+ }
+
+ /**
+ * Gets the title of the message
+ * @return the title of the message
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Sets the title of the message
+ * HTML attributes are allowed and are sanitized by the container.
+ * @param newTitle the title of the message
+ */
+ public function setTitle($newTitle)
+ {
+ $this->title = $newTitle;
+ }
+
+ /**
+ * Gets the type of the message, as specified by opensocial.Message.Type
+ * @return the type of message (enum Message.Type)
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Sets the type of the message, as specified by opensocial.Message.Type
+ * @param newType the type of message (enum Message.Type)
+ */
+ public function setType($newType)
+ {
+ if (! in_array($newType)) {
+ throw new Exception('Invalid message type');
+ }
+ $this->type = $newType;
+ }
+
+ /**
+ * TODO implement either a standard 'sanitizing' facility or
+ * define an interface that can be set on this class so
+ * others can plug in their own.
+ * @param htmlStr String to be sanitized.
+ * @return the sanitized HTML String
+ */
+ public function sanitizeHTML($htmlStr)
+ {
+ return $htmlStr;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Name.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Name.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Name.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Name.php Thu May 1 05:36:31 2008
@@ -0,0 +1,97 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Name.Field.html
+ *
+ */
+class Name {
+ public $additionalName;
+ public $familyName;
+ public $givenName;
+ public $honorificPrefix;
+ public $honorificSuffix;
+ public $unstructured;
+
+ public function __construct($unstructured)
+ {
+ $this->unstructured = $unstructured;
+ }
+
+ public function getUnstructured()
+ {
+ return $this->unstructured;
+ }
+
+ public function setUnstructured($unstructured)
+ {
+ $this->unstructured = $unstructured;
+ }
+
+ public function getAdditionalName()
+ {
+ return $this->additionalName;
+ }
+
+ public function setAdditionalName($additionalName)
+ {
+ $this->additionalName = $additionalName;
+ }
+
+ public function getFamilyName()
+ {
+ return $this->familyName;
+ }
+
+ public function setFamilyName($familyName)
+ {
+ $this->familyName = $familyName;
+ }
+
+ public function getGivenName()
+ {
+ return $this->givenName;
+ }
+
+ public function setGivenName($givenName)
+ {
+ $this->givenName = $givenName;
+ }
+
+ public function getHonorificPrefix()
+ {
+ return $this->honorificPrefix;
+ }
+
+ public function setHonorificPrefix($honorificPrefix)
+ {
+ $this->honorificPrefix = $honorificPrefix;
+ }
+
+ public function getHonorificSuffix()
+ {
+ return $this->honorificSuffix;
+ }
+
+ public function setHonorificSuffix($honorificSuffix)
+ {
+ $this->honorificSuffix = $honorificSuffix;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Organization.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Organization.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Organization.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Organization.php Thu May 1 05:36:31 2008
@@ -0,0 +1,137 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Organization.Field.html
+ *
+ */
+class Organization {
+ public $address;
+ public $description;
+ public $endDate;
+ public $field;
+ public $name;
+ public $salary;
+ public $startDate;
+ public $subField;
+ public $title;
+ public $webpage;
+
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ public function setAddress($address)
+ {
+ $this->address = $address;
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ }
+
+ public function getEndDate()
+ {
+ return $this->endDate;
+ }
+
+ public function setEndDate($endDate)
+ {
+ $this->endDate = $endDate;
+ }
+
+ public function getField()
+ {
+ return $this->field;
+ }
+
+ public function setField($field)
+ {
+ $this->field = $field;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getSalary()
+ {
+ return $this->salary;
+ }
+
+ public function setSalary($salary)
+ {
+ $this->salary = $salary;
+ }
+
+ public function getStartDate()
+ {
+ return $this->startDate;
+ }
+
+ public function setStartDate($startDate)
+ {
+ $this->startDate = $startDate;
+ }
+
+ public function getSubField()
+ {
+ return $this->subField;
+ }
+
+ public function setSubField($subField)
+ {
+ $this->subField = $subField;
+ }
+
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ }
+
+ public function getWebpage()
+ {
+ return $this->webpage;
+ }
+
+ public function setWebpage($webpage)
+ {
+ $this->webpage = $webpage;
+ }
+
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Person.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Person.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Person.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Person.php Thu May 1 05:36:31 2008
@@ -0,0 +1,639 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Person.Field.html
+ *
+ */
+class Person {
+ public $aboutMe;
+ public $activities;
+ public $addresses;
+ public $age;
+ public $bodyType;
+ public $books;
+ public $cars;
+ public $children;
+ public $currentLocation;
+ public $dateOfBirth;
+ public $drinker;
+ public $emails;
+ public $ethnicity;
+ public $fashion;
+ public $food;
+ public $gender;
+ public $happiestWhen;
+ public $heroes;
+ public $humor;
+ public $id;
+ public $interests;
+ public $jobInterests;
+ public $jobs;
+ public $languagesSpoken;
+ public $livingArrangement;
+ public $lookingFor;
+ public $movies;
+ public $music;
+ public $name;
+ public $nickname;
+ public $pets;
+ public $phoneNumbers;
+ public $politicalViews;
+ public $profileSong;
+ public $profileUrl;
+ public $profileVideo;
+ public $quotes;
+ public $relationshipStatus;
+ public $religion;
+ public $romance;
+ public $scaredOf;
+ public $schools;
+ public $sexualOrientation;
+ public $smoker;
+ public $sports;
+ public $status;
+ public $tags;
+ public $thumbnailUrl;
+ public $timeZone;
+ public $turnOffs;
+ public $turnOns;
+ public $tvShows;
+ public $urls;
+
+ // Note: Not in the opensocial js person object directly
+ public $isOwner = false;
+ public $isViewer = false;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+
+ public function getAboutMe()
+ {
+ return $this->aboutMe;
+ }
+
+ public function setAboutMe($aboutMe)
+ {
+ $this->aboutMe = $aboutMe;
+ }
+
+ public function getActivities()
+ {
+ return $this->activities;
+ }
+
+ public function setActivities($activities)
+ {
+ $this->activities = $activities;
+ }
+
+ public function getAddresses()
+ {
+ return $this->addresses;
+ }
+
+ public function setAddresses($addresses)
+ {
+ $this->addresses = $addresses;
+ }
+
+ public function getAge()
+ {
+ return $this->age;
+ }
+
+ public function setAge($age)
+ {
+ $this->age = $age;
+ }
+
+ public function getBodyType()
+ {
+ return $this->bodyType;
+ }
+
+ public function setBodyType($bodyType)
+ {
+ $this->bodyType = $bodyType;
+ }
+
+ public function getBooks()
+ {
+ return $this->books;
+ }
+
+ public function setBooks($books)
+ {
+ $this->books = $books;
+ }
+
+ public function getCars()
+ {
+ return $this->cars;
+ }
+
+ public function setCars($cars)
+ {
+ $this->cars = $cars;
+ }
+
+ public function getChildren()
+ {
+ return $this->children;
+ }
+
+ public function setChildren($children)
+ {
+ $this->children = $children;
+ }
+
+ public function getCurrentLocation()
+ {
+ return $this->currentLocation;
+ }
+
+ public function setCurrentLocation($currentLocation)
+ {
+ $this->currentLocation = $currentLocation;
+ }
+
+ public function getDateOfBirth()
+ {
+ return $this->dateOfBirth;
+ }
+
+ public function setDateOfBirth($dateOfBirth)
+ {
+ $this->dateOfBirth = $dateOfBirth;
+ }
+
+ public function getDrinker()
+ {
+ return $this->$this->drinker;
+ }
+
+ public function setDrinker($newDrinker)
+ {
+ $this->drinker = $newDrinker;
+ }
+
+ public function getEmails()
+ {
+ return $this->emails;
+ }
+
+ public function setEmails($emails)
+ {
+ $this->emails = $emails;
+ }
+
+ public function getEthnicity()
+ {
+ return $this->ethnicity;
+ }
+
+ public function setEthnicity($ethnicity)
+ {
+ $this->ethnicity = $ethnicity;
+ }
+
+ public function getFashion()
+ {
+ return $this->fashion;
+ }
+
+ public function setFashion($fashion)
+ {
+ $this->fashion = $fashion;
+ }
+
+ public function getFood()
+ {
+ return $this->food;
+ }
+
+ public function setFood($food)
+ {
+ $this->food = $food;
+ }
+
+ public function getGender()
+ {
+ return $this->$this->gender;
+ }
+
+ public function setGender($newGender)
+ {
+ $this->gender = $newGender;
+ }
+
+ public function getHappiestWhen()
+ {
+ return $this->happiestWhen;
+ }
+
+ public function setHappiestWhen($happiestWhen)
+ {
+ $this->happiestWhen = $happiestWhen;
+ }
+
+ public function getHeroes()
+ {
+ return $this->heroes;
+ }
+
+ public function setHeroes($heroes)
+ {
+ $this->heroes = $heroes;
+ }
+
+ public function getHumor()
+ {
+ return $this->humor;
+ }
+
+ public function setHumor($humor)
+ {
+ $this->humor = $humor;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function setId($id)
+ {
+ $this->id = $id;
+ }
+
+ public function getInterests()
+ {
+ return $this->interests;
+ }
+
+ public function setInterests($interests)
+ {
+ $this->interests = $interests;
+ }
+
+ public function getJobInterests()
+ {
+ return $this->jobInterests;
+ }
+
+ public function setJobInterests($jobInterests)
+ {
+ $this->jobInterests = $jobInterests;
+ }
+
+ public function getJobs()
+ {
+ return $this->jobs;
+ }
+
+ public function setJobs($jobs)
+ {
+ $this->jobs = $jobs;
+ }
+
+ public function getLanguagesSpoken()
+ {
+ return $this->languagesSpoken;
+ }
+
+ public function setLanguagesSpoken($languagesSpoken)
+ {
+ $this->languagesSpoken = $languagesSpoken;
+ }
+
+ public function getLivingArrangement()
+ {
+ return $this->livingArrangement;
+ }
+
+ public function setLivingArrangement($livingArrangement)
+ {
+ $this->livingArrangement = $livingArrangement;
+ }
+
+ public function getLookingFor()
+ {
+ return $this->lookingFor;
+ }
+
+ public function setLookingFor($lookingFor)
+ {
+ $this->lookingFor = $lookingFor;
+ }
+
+ public function getMovies()
+ {
+ return $this->movies;
+ }
+
+ public function setMovies($movies)
+ {
+ $this->movies = $movies;
+ }
+
+ public function getMusic()
+ {
+ return $this->music;
+ }
+
+ public function setMusic($music)
+ {
+ $this->music = $music;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getNickname()
+ {
+ return $this->nickname;
+ }
+
+ public function setNickname($nickname)
+ {
+ $this->nickname = $nickname;
+ }
+
+ public function getPets()
+ {
+ return $this->pets;
+ }
+
+ public function setPets($pets)
+ {
+ $this->pets = $pets;
+ }
+
+ public function getPhoneNumbers()
+ {
+ return $this->phoneNumbers;
+ }
+
+ public function setPhoneNumbers($phoneNumbers)
+ {
+ $this->phoneNumbers = $phoneNumbers;
+ }
+
+ public function getPoliticalViews()
+ {
+ return $this->politicalViews;
+ }
+
+ public function setPoliticalViews($politicalViews)
+ {
+ $this->politicalViews = $politicalViews;
+ }
+
+ public function getProfileSong()
+ {
+ return $this->profileSong;
+ }
+
+ public function setProfileSong($profileSong)
+ {
+ $this->profileSong = $profileSong;
+ }
+
+ public function getProfileUrl()
+ {
+ return $this->profileUrl;
+ }
+
+ public function setProfileUrl($profileUrl)
+ {
+ $this->profileUrl = $profileUrl;
+ }
+
+ public function getProfileVideo()
+ {
+ return $this->profileVideo;
+ }
+
+ public function setProfileVideo($profileVideo)
+ {
+ $this->profileVideo = $profileVideo;
+ }
+
+ public function getQuotes()
+ {
+ return $this->quotes;
+ }
+
+ public function setQuotes($quotes)
+ {
+ $this->quotes = $quotes;
+ }
+
+ public function getRelationshipStatus()
+ {
+ return $this->relationshipStatus;
+ }
+
+ public function setRelationshipStatus($relationshipStatus)
+ {
+ $this->relationshipStatus = $relationshipStatus;
+ }
+
+ public function getReligion()
+ {
+ return $this->religion;
+ }
+
+ public function setReligion($religion)
+ {
+ $this->religion = $religion;
+ }
+
+ public function getRomance()
+ {
+ return $this->romance;
+ }
+
+ public function setRomance($romance)
+ {
+ $this->romance = $romance;
+ }
+
+ public function getScaredOf()
+ {
+ return $this->scaredOf;
+ }
+
+ public function setScaredOf($scaredOf)
+ {
+ $this->scaredOf = $scaredOf;
+ }
+
+ public function getSchools()
+ {
+ return $this->schools;
+ }
+
+ public function setSchools($schools)
+ {
+ $this->schools = $schools;
+ }
+
+ public function getSexualOrientation()
+ {
+ return $this->sexualOrientation;
+ }
+
+ public function setSexualOrientation($sexualOrientation)
+ {
+ $this->sexualOrientation = $sexualOrientation;
+ }
+
+ public function getSmoker()
+ {
+ return $this->$this->smoker;
+ }
+
+ public function setSmoker($newSmoker)
+ {
+ $this->smoker = $newSmoker;
+ }
+
+ public function getSports()
+ {
+ return $this->sports;
+ }
+
+ public function setSports($sports)
+ {
+ $this->sports = $sports;
+ }
+
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ }
+
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ public function setTags($tags)
+ {
+ $this->tags = $tags;
+ }
+
+ public function getThumbnailUrl()
+ {
+ return $this->thumbnailUrl;
+ }
+
+ public function setThumbnailUrl($thumbnailUrl)
+ {
+ $this->thumbnailUrl = $thumbnailUrl;
+ }
+
+ public function getTimeZone()
+ {
+ return $this->timeZone;
+ }
+
+ public function setTimeZone($timeZone)
+ {
+ $this->timeZone = $timeZone;
+ }
+
+ public function getTurnOffs()
+ {
+ return $this->turnOffs;
+ }
+
+ public function setTurnOffs($turnOffs)
+ {
+ $this->turnOffs = $turnOffs;
+ }
+
+ public function getTurnOns()
+ {
+ return $this->turnOns;
+ }
+
+ public function setTurnOns($turnOns)
+ {
+ $this->turnOns = $turnOns;
+ }
+
+ public function getTvShows()
+ {
+ return $this->tvShows;
+ }
+
+ public function setTvShows($tvShows)
+ {
+ $this->tvShows = $tvShows;
+ }
+
+ public function getUrls()
+ {
+ return $this->urls;
+ }
+
+ public function setUrls($urls)
+ {
+ $this->urls = $urls;
+ }
+
+ public function getIsOwner()
+ {
+ return $this->isOwner;
+ }
+
+ public function setIsOwner($isOwner)
+ {
+ $this->isOwner = $isOwner;
+ }
+
+ public function getIsViewer()
+ {
+ return $this->isViewer;
+ }
+
+ public function setIsViewer($isViewer)
+ {
+ $this->isViewer = $isViewer;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Phone.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Phone.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Phone.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Phone.php Thu May 1 05:36:31 2008
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Phone.Field.html
+ *
+ */
+class Phone {
+ public $number;
+ public $type;
+
+ public function __construct($number, $type)
+ {
+ $this->number = $number;
+ $this->type = $type;
+ }
+
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ public function setNumber($number)
+ {
+ $this->number = $number;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/Url.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/Url.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/Url.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/Url.php Thu May 1 05:36:31 2008
@@ -0,0 +1,66 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * see
+ * http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Url.Field.html
+ */
+class Url {
+ public $address;
+ public $linkText;
+ public $type;
+
+ public function __construct($address, $linkText, $type)
+ {
+ $this->address = $address;
+ $this->linkText = $linkText;
+ $this->type = $type;
+ }
+
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ public function setAddress($address)
+ {
+ $this->address = $address;
+ }
+
+ public function getLinkText()
+ {
+ return $this->linkText;
+ }
+
+ public function setLinkText($linkText)
+ {
+ $this->linkText = $linkText;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+}
Added: incubator/shindig/trunk/php/src/socialdata/opensocial/model/idSpec.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/opensocial/model/idSpec.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/opensocial/model/idSpec.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/opensocial/model/idSpec.php Thu May 1 05:36:31 2008
@@ -0,0 +1,66 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class IdSpec {
+ public static $types = array('VIEWER', 'OWNER', 'VIEWER_FRIENDS', 'OWNER_FRIENDS', 'USER_IDS');
+
+ public $jsonSpec;
+ public $type;
+
+ public function __construct($jsonSpec, $type)
+ {
+ $this->jsonSpec = $jsonSpec;
+ $this->type = $type;
+ }
+
+ static public function fromJson($jsonIdSpec)
+ {
+ if (! empty($jsonIdSpec) && in_array((string)$jsonIdSpec, idSpec::$types)) {
+ $idSpecEnum = (string)$jsonIdSpec;
+ } elseif (empty($jsonIdSpec)) {
+ $idSpecEnum = 'USER_IDS';
+ } else {
+ throw new Exception("The json request had a bad idSpec");
+ }
+ return new IdSpec($jsonIdSpec, $idSpecEnum);
+ }
+
+ /**
+ * Only valid for IdSpecs of type USER_IDS
+ * @return A list of the user ids in the id spec
+ *
+ */
+ public function fetchUserIds()
+ {
+ $userIdArray = json_decode($this->jsonSpec, true);
+ if (! is_array($userIdArray)) {
+ $userIdArray = array($userIdArray);
+ }
+ $userIds = array();
+ foreach ( $userIdArray as $id ) {
+ $userIds[] = (string)$id;
+ }
+ return $userIds;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicActivitiesService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicActivitiesService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicActivitiesService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicActivitiesService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,43 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class BasicActivitiesService {
+
+ public function getActivities($ids, $token)
+ {
+ $allActivities = XmlStateFileFetcher::get()->getActivities();
+ $activities = array();
+ foreach ( $ids as $id ) {
+ if (isset($allActivities[$id])) {
+ $activities[] = $allActivities[$id];
+ }
+ }
+ // TODO: Sort them
+ return new ResponseItem(null, null, $activities);
+ }
+
+ public function createActivity($personId, $activity, $token)
+ {
+ // TODO: Validate the activity and do any template expanding
+ $activity->setUserId($personId);
+ $activity->setPostedTime(time());
+ XmlStateFileFetcher::get()->createActivity($personId, $activity);
+ return new ResponseItem(null, null, array());
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicDataService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicDataService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicDataService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicDataService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class BasicDataService extends DataService {
+
+ public function getPersonData($ids, $keys, $token)
+ {
+ $allData = XmlStateFileFetcher::get()->getAppData();
+ $data = array();
+ foreach ( $ids as $id ) {
+ if (isset($allData[$id])) {
+ $allPersonData = $allData[$id];
+ $personData = array();
+ foreach ( array_keys($allPersonData) as $key ) {
+ if (in_array($key, $keys)) {
+ $personData[$key] = $allPersonData[$key];
+ }
+ }
+ $data[$id] = $personData;
+ }
+ }
+ return new ResponseItem(null, null, $data);
+ }
+
+ public function updatePersonData($id, $key, $value, $token)
+ {
+ if (! BasicDataService::isValidKey($key)) {
+ return new ResponseItem(BAD_REQUEST, "The person data key had invalid characters", null);
+ }
+ XmlStateFileFetcher::get()->setAppData($id, $key, $value);
+ return new ResponseItem(null, null, array());
+ }
+
+ /**
+ * Determines whether the input is a valid key. Valid keys match the regular
+ * expression [\w\-\.]+.
+ *
+ * @param key the key to validate.
+ * @return true if the key is a valid appdata key, false otherwise.
+ */
+ public static function isValidKey($key)
+ {
+ if (empty($key)) {
+ return false;
+ }
+ for($i = 0; $i < strlen($key); ++ $i) {
+ $c = substr($key, $i, 1);
+ if (($c >= 'a' && $c <= 'z') || ($c >= 'A' && $c <= 'Z') || ($c >= '0' && $c <= '9') || ($c == '-') || ($c == '_') || ($c == '.')) {
+ continue;
+ }
+ return false;
+ }
+ return true;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicPeopleService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicPeopleService.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicPeopleService.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicPeopleService.php Thu May 1 05:36:31 2008
@@ -0,0 +1,104 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class BasicPeopleService extends PeopleService {
+
+ private function comparator($person, $person1)
+ {
+ $name = $person['name']->getUnstructured();
+ $name1 = $person1['name']->getUnstructured();
+ if ($name == $name1) {
+ return 0;
+ }
+ return ($name < $name1) ? - 1 : 1;
+ }
+
+ public function getPeople($ids, $sortOrder, $filter, $first, $max, $profileDetails, $token)
+ {
+ $allPeople = XmlStateFileFetcher::get()->getAllPeople();
+ $people = array();
+ foreach ( $ids as $id ) {
+ $person = null;
+ if (isset($allPeople[$id])) {
+ $person = $allPeople[$id];
+ if ($id == $token->getViewerId()) {
+ $person->setIsViewer(true);
+ }
+ if ($id == $token->getOwnerId()) {
+ $person->setIsOwner(true);
+ }
+ //FIXME (see note below)
+ // The java sample container code returns everything that is listed in the XML file
+ // and filters out all the null values. I -think- the more correct thing to do is
+ // return a json object with only the requested profile details ...
+ // but double check later to make sure :)
+ if (is_array($profileDetails) && count($profileDetails)) {
+ $newPerson = array();
+ $newPerson['isOwner'] = $person->isOwner;
+ $newPerson['isViewer'] = $person->isViewer;
+ $newPerson['name'] = $person->name;
+ foreach ( $profileDetails as $field ) {
+ if (isset($person->$field) && ! isset($newPerson[$field])) {
+ $newPerson[$field] = $person->$field;
+ }
+ $person = $newPerson;
+ }
+ // return only the requested profile detail fields
+ }
+ $people[] = $person;
+ }
+ }
+ // We can pretend that by default the people are in top friends order
+ if ($sortOrder == 'name') {
+ usort($people, array($this, 'comparator'));
+ }
+
+ //TODO: The samplecontainer doesn't support any filters yet. We should fix this.
+ $totalSize = count($people);
+ $last = $first + $max;
+ $last = min($last, $totalSize);
+ $people = array_slice($people, $first, $last);
+ $collection = new ApiCollection($people, $first, $totalSize);
+ return new ResponseItem(null, null, $collection);
+ }
+
+ public function getIds($idSpec, $token)
+ {
+ $friendIds = XmlStateFileFetcher::get()->getFriendIds();
+ $ids = array();
+ switch ( $idSpec->getType()) {
+ case 'OWNER' :
+ $ids[] = $token->getOwnerId();
+ break;
+ case 'VIEWER' :
+ $ids[] = $token->getViewerId();
+ break;
+ case 'OWNER_FRIENDS' :
+ $ids = $friendIds[$token->getOwnerId()];
+ break;
+ case 'VIEWER_FRIENDS' :
+ $ids = $friendIds[$token->getViewerId()];
+ break;
+ case 'USER_IDS' :
+ $ids = $idSpec->fetchUserIds();
+ break;
+ }
+ return $ids;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php Thu May 1 05:36:31 2008
@@ -0,0 +1,97 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * Servlet for serving the data required for opensocial.
+ * This will expand to be more sophisticated as time goes on.
+ */
+class OpenSocialDataHandler extends GadgetDataHandler {
+ private $handles = array('FETCH_PEOPLE', 'FETCH_PERSON_APP_DATA', 'UPDATE_PERSON_APP_DATA', 'FETCH_ACTIVITIES', 'CREATE_ACTIVITY');
+ private $peopleHandler;
+ private $dataHandler;
+ private $activitiesHandler;
+
+ public function __construct()
+ {
+ $this->peopleHandler = new BasicPeopleService();
+ $this->dataHandler = new BasicDataService();
+ $this->activitiesHandler = new BasicActivitiesService();
+ }
+
+ public function shouldHandle($requestType)
+ {
+ return in_array($requestType, $this->handles);
+ }
+
+ public function handleRequest($request)
+ {
+ try {
+ $params = $request->getParams();
+ $type = $params['type'];
+ $response = new ResponseItem(NOT_IMPLEMENTED, $type . " has not been implemented yet.", array());
+ $idSpec = idSpec::fromJson($params['idSpec']);
+ $peopleIds = $this->peopleHandler->getIds($idSpec, $request->getToken());
+ switch ( $type) {
+
+ case 'FETCH_PEOPLE' :
+ $profileDetail = $params["profileDetail"];
+ $profileDetailFields = Array();
+ foreach ( $profileDetail as $detail ) {
+ $profileDetailFields[] = $detail;
+ }
+ $sortOrder = ! empty($params["sortOrder"]) ? $params["sortOrder"] : 'topFriends';
+ $filter = ! empty($params["filter"]) ? $params["filter"] : 'all';
+ $first = intval($params["first"]);
+ $max = intval($params["max"]);
+ // TODO: Should we put this in the requestitem and pass the whole
+ // thing along?
+ $response = $this->peopleHandler->getPeople($peopleIds, $sortOrder, $filter, $first, $max, $profileDetailFields, $request->getToken());
+ break;
+
+ case 'FETCH_PERSON_APP_DATA' :
+ $jsonKeys = $params["keys"];
+ $keys = array();
+ foreach ( $jsonKeys as $key ) {
+ $keys[] = $key;
+ }
+ $response = $this->dataHandler->getPersonData($peopleIds, $keys, $request->getToken());
+ break;
+
+ case 'UPDATE_PERSON_APP_DATA' :
+ // this is either viewer or owner right? lets hack in propper support shall we?
+ // We only support updating one person right now
+ $id = $peopleIds[0];
+ $key = $params["key"];
+ $value = ! empty($params["value"]) ? $params["value"] : '';
+ $response = $this->dataHandler->updatePersonData($id, $key, $value, $request->getToken());
+ break;
+
+ case 'FETCH_ACTIVITIES' :
+ $response = $this->activitiesHandler->getActivities($peopleIds, $request->getToken());
+ break;
+
+ case 'CREATE_ACTIVITY' :
+ break;
+ }
+ } catch ( Exception $e ) {
+ $response = new ResponseItem(BAD_REQUEST, $e->getMessage());
+ }
+ return $response;
+ }
+}
Added: incubator/shindig/trunk/php/src/socialdata/samplecontainer/StateFileDataHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/StateFileDataHandler.php?rev=652498&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/samplecontainer/StateFileDataHandler.php (added)
+++ incubator/shindig/trunk/php/src/socialdata/samplecontainer/StateFileDataHandler.php Thu May 1 05:36:31 2008
@@ -0,0 +1,15 @@
+<?php
+
+class StateFileDataHandler extends GadgetDataHandler {
+ private $handles = array('DUMP_STATE', 'SET_STATE', 'SET_EVILNESS');
+
+ public function shouldHandle($requestType)
+ {
+ return in_array($requestType, $this->handles);
+ }
+
+ public function handleRequest($request)
+ {
+ // do stuff
+ }
+}
\ No newline at end of file