You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/07/14 21:42:07 UTC
svn commit: r676701 -
/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
Author: doll
Date: Mon Jul 14 12:42:07 2008
New Revision: 676701
URL: http://svn.apache.org/viewvc?rev=676701&view=rev
Log:
Fixed restfulcontainer.js to allow "*" to mean all keys when fetching app data for the opensocial js apis.
Also escape the security token in the restfulcontainer so that the samplecontainer works again when useRestful=true
Modified:
incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
Modified: incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js?rev=676701&r1=676700&r2=676701&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js (original)
+++ incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js Mon Jul 14 12:42:07 2008
@@ -166,7 +166,7 @@
};
gadgets.io.makeNonProxiedRequest(
- this.baseUrl_ + "/jsonBatch?st=" + shindig.auth.getSecurityToken(),
+ this.baseUrl_ + "/jsonBatch?st=" + escape(shindig.auth.getSecurityToken()),
sendResponse, makeRequestParams, "application/json");
};
@@ -259,17 +259,20 @@
}
RestfulContainer.prototype.getFieldsList = function(keys) {
- if (opensocial.Container.isArray(keys)) {
- return keys.join(',');
+ // datarequest.js guarantees that keys is an array
+ if (!keys || keys.length == 0 || keys[0] == "*") {
+ // Some containers support * to mean all keys in the js apis.
+ // This allows the RESTful apis to be compatible with them.
+ return '';
} else {
- return keys;
+ return 'fields=' + keys.join(',');
}
}
RestfulContainer.prototype.newFetchPersonAppDataRequest = function(idSpec,
keys) {
var url = "/appdata/" + this.translateIdSpec(idSpec) + "/@app"
- + "?fields=" + this.getFieldsList(keys);
+ + "?" + this.getFieldsList(keys);
return new RestfulRequestItem(url, "GET", null,
function (appData) {
return gadgets.util.escape(appData['entry'], true);
@@ -287,7 +290,7 @@
RestfulContainer.prototype.newRemovePersonAppDataRequest = function(id, keys) {
var url = "/appdata/" + this.translateIdSpec(this.makeIdSpec(id))
- + "/@app?fields=" + this.getFieldsList(keys);
+ + "/@app?" + this.getFieldsList(keys);
return new RestfulRequestItem(url, "DELETE");
};
Re: svn commit: r676701 - /incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
Posted by Cassie <do...@google.com>.
yeah.. it is.
i'll refactor it to split into two mini methods.
thanks.
- cassie
On Mon, Jul 14, 2008 at 1:07 PM, Robert Evans <bo...@google.com> wrote:
> Regarding line 263:
> if (!keys || keys.length == 0 || keys[0] == "*") {
>
> Is it safe to say this represents the following two notions,
> "hasNoKeys || isWildcardKey"?
>
> Bob
>
> On 7/14/08, doll@apache.org <do...@apache.org> wrote:
> > Author: doll
> > Date: Mon Jul 14 12:42:07 2008
> > New Revision: 676701
> >
> > URL: http://svn.apache.org/viewvc?rev=676701&view=rev
> > Log:
> > Fixed restfulcontainer.js to allow "*" to mean all keys when fetching app
> > data for the opensocial js apis.
> >
> > Also escape the security token in the restfulcontainer so that the
> > samplecontainer works again when useRestful=true
> >
> >
> >
> > Modified:
> >
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> >
> > Modified:
> > incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js?rev=676701&r1=676700&r2=676701&view=diff
> >
> ==============================================================================
> > ---
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > (original)
> > +++
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > Mon Jul 14 12:42:07 2008
> > @@ -166,7 +166,7 @@
> > };
> >
> > gadgets.io.makeNonProxiedRequest(
> > - this.baseUrl_ + "/jsonBatch?st=" + shindig.auth.getSecurityToken(),
> > + this.baseUrl_ + "/jsonBatch?st=" +
> > escape(shindig.auth.getSecurityToken()),
> > sendResponse, makeRequestParams, "application/json");
> > };
> >
> > @@ -259,17 +259,20 @@
> > }
> >
> > RestfulContainer.prototype.getFieldsList = function(keys) {
> > - if (opensocial.Container.isArray(keys)) {
> > - return keys.join(',');
> > + // datarequest.js guarantees that keys is an array
> > + if (!keys || keys.length == 0 || keys[0] == "*") {
> > + // Some containers support * to mean all keys in the js apis.
> > + // This allows the RESTful apis to be compatible with them.
> > + return '';
> > } else {
> > - return keys;
> > + return 'fields=' + keys.join(',');
> > }
> > }
> >
> > RestfulContainer.prototype.newFetchPersonAppDataRequest =
> function(idSpec,
> > keys) {
> > var url = "/appdata/" + this.translateIdSpec(idSpec) + "/@app"
> > - + "?fields=" + this.getFieldsList(keys);
> > + + "?" + this.getFieldsList(keys);
> > return new RestfulRequestItem(url, "GET", null,
> > function (appData) {
> > return gadgets.util.escape(appData['entry'], true);
> > @@ -287,7 +290,7 @@
> >
> > RestfulContainer.prototype.newRemovePersonAppDataRequest = function(id,
> > keys) {
> > var url = "/appdata/" + this.translateIdSpec(this.makeIdSpec(id))
> > - + "/@app?fields=" + this.getFieldsList(keys);
> > + + "/@app?" + this.getFieldsList(keys);
> > return new RestfulRequestItem(url, "DELETE");
> > };
> >
> >
> >
> >
>
Re: svn commit: r676701 - /incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
Posted by Robert Evans <bo...@google.com>.
Regarding line 263:
if (!keys || keys.length == 0 || keys[0] == "*") {
Is it safe to say this represents the following two notions,
"hasNoKeys || isWildcardKey"?
Bob
On 7/14/08, doll@apache.org <do...@apache.org> wrote:
> Author: doll
> Date: Mon Jul 14 12:42:07 2008
> New Revision: 676701
>
> URL: http://svn.apache.org/viewvc?rev=676701&view=rev
> Log:
> Fixed restfulcontainer.js to allow "*" to mean all keys when fetching app
> data for the opensocial js apis.
>
> Also escape the security token in the restfulcontainer so that the
> samplecontainer works again when useRestful=true
>
>
>
> Modified:
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
>
> Modified:
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js?rev=676701&r1=676700&r2=676701&view=diff
> ==============================================================================
> --- incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> (original)
> +++ incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> Mon Jul 14 12:42:07 2008
> @@ -166,7 +166,7 @@
> };
>
> gadgets.io.makeNonProxiedRequest(
> - this.baseUrl_ + "/jsonBatch?st=" + shindig.auth.getSecurityToken(),
> + this.baseUrl_ + "/jsonBatch?st=" +
> escape(shindig.auth.getSecurityToken()),
> sendResponse, makeRequestParams, "application/json");
> };
>
> @@ -259,17 +259,20 @@
> }
>
> RestfulContainer.prototype.getFieldsList = function(keys) {
> - if (opensocial.Container.isArray(keys)) {
> - return keys.join(',');
> + // datarequest.js guarantees that keys is an array
> + if (!keys || keys.length == 0 || keys[0] == "*") {
> + // Some containers support * to mean all keys in the js apis.
> + // This allows the RESTful apis to be compatible with them.
> + return '';
> } else {
> - return keys;
> + return 'fields=' + keys.join(',');
> }
> }
>
> RestfulContainer.prototype.newFetchPersonAppDataRequest = function(idSpec,
> keys) {
> var url = "/appdata/" + this.translateIdSpec(idSpec) + "/@app"
> - + "?fields=" + this.getFieldsList(keys);
> + + "?" + this.getFieldsList(keys);
> return new RestfulRequestItem(url, "GET", null,
> function (appData) {
> return gadgets.util.escape(appData['entry'], true);
> @@ -287,7 +290,7 @@
>
> RestfulContainer.prototype.newRemovePersonAppDataRequest = function(id,
> keys) {
> var url = "/appdata/" + this.translateIdSpec(this.makeIdSpec(id))
> - + "/@app?fields=" + this.getFieldsList(keys);
> + + "/@app?" + this.getFieldsList(keys);
> return new RestfulRequestItem(url, "DELETE");
> };
>
>
>
>