[
https://issues.apache.org/jira/browse/SHINDIG-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Cassie Doll resolved SHINDIG-428.
---------------------------------
Resolution: Fixed
Assignee: Cassie Doll
> Adding multiple newUpdatePersonAppDataRequest items to a single DataRequest
> does not work (for restful container)
> -----------------------------------------------------------------------------------------------------------------
>
> Key: SHINDIG-428
> URL: https://issues.apache.org/jira/browse/SHINDIG-428
> Project: Shindig
> Issue Type: Bug
> Components: OpenSocial feature (Javascript)
> Environment: restful container
> Reporter: Jamey Wood
> Assignee: Cassie Doll
> Attachments: fix-428-bug.patch
>
>
> When using the restful container, adding multiple
> newUpdatePersonAppDataRequest items to a single DataRequest does not work.
> Specifically, only the last such item added will actually be transmitted to
> the server. For example, this javascript sequence:
> var req = opensocial.newDataRequest();
>
> req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER,
> 'key1', 'val1'));
>
> req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER,
> 'key2', 'val2'));
> req.send();
> Currently causes json like this to be sent to the server:
>
> {"undefined":{"url":"/appdata/@owner/@self/@app?fields=key2","method":"POST","postData":{"key2":"val2"}}}
> Obviously, the issue is that key1/val1 are not included in this json.
> I believe this issue arises because of these lines in
> features/opensocial-current/restfulcontainer.js:
> 116 var jsonBatchData = {};
> 117
> 118 for (var j = 0; j < totalRequests; j++) {
> 119 var requestObject = requestObjects[j];
> 120
> 121 jsonBatchData[requestObject.key] = {url : requestObject.request.url,
> 122 method : requestObject.request.method};
> 123 if (requestObject.request.postData) {
> 124 jsonBatchData[requestObject.key].postData =
> requestObject.request.postData;
> 125 }
> 126 }
> The results of newUpdatePersonAppDataRequest(...) calls do not have a "key"
> value set. So each of them ends up competing for the null entry in the
> jsonBatchData map (and the last one in wins--overwriting any previous items).
> I have a very simple patch which does get this working, but may not do so in
> a robust enough way. With it, an end user could cause problems if they chose
> an unusual key (such as "__syskey_0") for a data request in the same batch.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.