You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by bh...@apache.org on 2010/09/03 18:01:11 UTC
svn commit: r992347 - in /shindig/trunk/php: config/container.php
src/gadgets/render/GadgetBaseRenderer.php
src/gadgets/templates/DataPipelining.php
src/social/servlet/CompatibilityJsonRpcServlet.php
src/social/servlet/JsonRpcServlet.php
Author: bhofmann
Date: Fri Sep 3 16:01:10 2010
New Revision: 992347
URL: http://svn.apache.org/viewvc?rev=992347&view=rev
Log:
fixes for broken data pipelining and client compatibility
Commit 949663 for issue SHINDIG-1144 broke data pipelining in PHP as well as
compatibility with older client libraries.
- changed "data" keys to "result" in DataPipelining
- Re-added /social/rpc endpoint which returns old "data" key
http://codereview.appspot.com/2133042/
Added:
shindig/trunk/php/src/social/servlet/CompatibilityJsonRpcServlet.php
Modified:
shindig/trunk/php/config/container.php
shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php
shindig/trunk/php/src/gadgets/templates/DataPipelining.php
shindig/trunk/php/src/social/servlet/JsonRpcServlet.php
Modified: shindig/trunk/php/config/container.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/config/container.php?rev=992347&r1=992346&r2=992347&view=diff
==============================================================================
--- shindig/trunk/php/config/container.php (original)
+++ shindig/trunk/php/config/container.php Fri Sep 3 16:01:10 2010
@@ -89,7 +89,8 @@ $shindigConfig = array(
'/gadgets/oauthcallback' => 'OAuthCallbackServlet',
'/gadgets/api/rpc' => 'JsonRpcServlet',
'/gadgets/api/rest' => 'DataServiceServlet',
- '/social/rest' => 'DataServiceServlet',
+ '/social/rest' => 'DataServiceServlet',
+ '/social/rpc' => 'CompatibilityJsonRpcServlet',
'/rpc' => 'JsonRpcServlet',
'/public.crt' => 'CertServlet',
'/public.cer' => 'CertServlet',
Modified: shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php?rev=992347&r1=992346&r2=992347&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php (original)
+++ shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php Fri Sep 3 16:01:10 2010
@@ -144,12 +144,12 @@ abstract class GadgetBaseRenderer extend
if (isset($val['id'])) {
$key = $val['id'];
// Pick up only the actual data part of the response, so we can do direct variable resolution
- if (isset($val['data']['list'])) {
- $this->dataContext[$key] = $val['data']['list'];
- } elseif (isset($val['data']['entry'])) {
- $this->dataContext[$key] = $val['data']['entry'];
- } elseif (isset($val['data'])) {
- $this->dataContext[$key] = $val['data'];
+ if (isset($val['result']['list'])) {
+ $this->dataContext[$key] = $val['result']['list'];
+ } elseif (isset($val['result']['entry'])) {
+ $this->dataContext[$key] = $val['result']['entry'];
+ } elseif (isset($val['result'])) {
+ $this->dataContext[$key] = $val['result'];
} else {
$this->dataContext[$key] = $val;
}
@@ -342,7 +342,7 @@ abstract class GadgetBaseRenderer extend
if (count($this->dataInserts)) {
foreach ($this->dataInserts as $data) {
$key = $data['id'];
- $data = json_encode($data['data']);
+ $data = json_encode($data['result']);
$script .= "opensocial.data.DataContext.putDataSet(\"$key\", $data);\n";
}
}
@@ -447,7 +447,7 @@ abstract class GadgetBaseRenderer extend
// this should really be set in config/container.js, but if not, we build a complete default set so at least most of it works out-of-the-box
$gadgetConfig['osapi.services'] = array(
'gadgets.rpc' => array('container.listMethods'),
- 'http://%host%/social/rpc' => array("messages.update", "albums.update",
+ 'http://%host%/rpc' => array("messages.update", "albums.update",
"activities.delete", "activities.update",
"activities.supportedFields", "albums.get",
"activities.get", "mediaitems.update",
Modified: shindig/trunk/php/src/gadgets/templates/DataPipelining.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/templates/DataPipelining.php?rev=992347&r1=992346&r2=992347&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/DataPipelining.php (original)
+++ shindig/trunk/php/src/gadgets/templates/DataPipelining.php Fri Sep 3 16:01:10 2010
@@ -122,12 +122,12 @@ class DataPipelining {
if (isset($val['id'])) {
$key = $val['id'];
// Pick up only the actual data part of the response, so we can do direct variable resolution
- if (isset($val['data']['list'])) {
- $dataContext[$key] = $val['data']['list'];
- } elseif (isset($val['data']['entry'])) {
- $dataContext[$key] = $val['data']['entry'];
- } elseif (isset($val['data'])) {
- $dataContext[$key] = $val['data'];
+ if (isset($val['result']['list'])) {
+ $dataContext[$key] = $val['result']['list'];
+ } elseif (isset($val['result']['entry'])) {
+ $dataContext[$key] = $val['result']['entry'];
+ } elseif (isset($val['result'])) {
+ $dataContext[$key] = $val['result'];
}
}
}
@@ -180,7 +180,7 @@ class DataPipelining {
}
if (count($jsonRequests)) {
// perform social api requests
- $request = new RemoteContentRequest('http://'.$_SERVER['HTTP_HOST'] . Config::get('web_prefix') . '/social/rpc?st=' . urlencode($securityToken) . '&format=json', "Content-Type: application/json\n", json_encode($jsonRequests));
+ $request = new RemoteContentRequest('http://'.$_SERVER['HTTP_HOST'] . Config::get('web_prefix') . '/rpc?st=' . urlencode($securityToken) . '&format=json', "Content-Type: application/json\n", json_encode($jsonRequests));
$request->setMethod('POST');
$remoteFetcherClass = Config::get('remote_content_fetcher');
$remoteFetcher = new $remoteFetcherClass();
@@ -225,15 +225,15 @@ class DataPipelining {
'error' => array(
'code' => $statusCode,
'message' => $statusCodeMessage,
- 'data' => array(
+ 'result' => array(
'content' => $content,
'headers' => $headers
)
)
);
}
- //$toAdd[$id] = array('id' => $id, 'data' => $httpRequests[$url]['format'] == 'json' ? json_decode($resp[$url]['body'], true) : $resp[$url]['body']);
- $decodedResponse[] = array('id' => $id, 'data' => $toAdd);
+ //$toAdd[$id] = array('id' => $id, 'result' => $httpRequests[$url]['format'] == 'json' ? json_decode($resp[$url]['body'], true) : $resp[$url]['body']);
+ $decodedResponse[] = array('id' => $id, 'result' => $toAdd);
}
}
}
@@ -282,12 +282,12 @@ class DataPipelining {
foreach ($array as $val) {
if (isset($val['id'])) {
$key = $val['id'];
- if (isset($val['data']['list'])) {
- $result[$key] = $val['data']['list'];
- } elseif (isset($val['data']['entry'])) {
- $result[$key] = $val['data']['entry'];
- } elseif (isset($val['data'])) {
- $result[$key] = $val['data'];
+ if (isset($val['result']['list'])) {
+ $result[$key] = $val['result']['list'];
+ } elseif (isset($val['result']['entry'])) {
+ $result[$key] = $val['result']['entry'];
+ } elseif (isset($val['result'])) {
+ $result[$key] = $val['result'];
}
}
}
Added: shindig/trunk/php/src/social/servlet/CompatibilityJsonRpcServlet.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/social/servlet/CompatibilityJsonRpcServlet.php?rev=992347&view=auto
==============================================================================
--- shindig/trunk/php/src/social/servlet/CompatibilityJsonRpcServlet.php (added)
+++ shindig/trunk/php/src/social/servlet/CompatibilityJsonRpcServlet.php Fri Sep 3 16:01:10 2010
@@ -0,0 +1,26 @@
+<?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.
+ */
+
+/**
+ * JSON-RPC handler servlet. for older clients going to /social/rpc endpoint
+ */
+class CompatibilityJsonRpcServlet extends JsonRpcServlet {
+ protected $resultKey = 'data';
+}
\ No newline at end of file
Modified: shindig/trunk/php/src/social/servlet/JsonRpcServlet.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/social/servlet/JsonRpcServlet.php?rev=992347&r1=992346&r2=992347&view=diff
==============================================================================
--- shindig/trunk/php/src/social/servlet/JsonRpcServlet.php (original)
+++ shindig/trunk/php/src/social/servlet/JsonRpcServlet.php Fri Sep 3 16:01:10 2010
@@ -23,6 +23,8 @@
*/
class JsonRpcServlet extends ApiServlet {
+ protected $resultKey = 'result';
+
/**
* Single request through GET
* http://api.example.org/rpc?method=people.get&id=myself&userid=@me&groupid=@self
@@ -114,11 +116,11 @@ class JsonRpcServlet extends ApiServlet
// FIXME this is a little hacky because of the field names in the RestfulCollection
$converted->list = $converted->entry;
unset($converted->entry);
- $result['result'] = $converted;
+ $result[$this->resultKey] = $converted;
} elseif ($response instanceof DataCollection) {
- $result["result"] = $converted->getEntry();
+ $result[$this->resultKey] = $converted->getEntry();
} else {
- $result["result"] = $converted;
+ $result[$this->resultKey] = $converted;
}
}
return $result;