You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Jamey Wood (JIRA)" <ji...@apache.org> on 2008/07/07 20:46:31 UTC

[jira] Created: (SHINDIG-428) Adding multiple newUpdatePersonAppDataRequest items to a single DataRequest does not work (for restful container)

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


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.


[jira] Updated: (SHINDIG-428) Adding multiple newUpdatePersonAppDataRequest items to a single DataRequest does not work (for restful container)

Posted by "Jamey Wood (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHINDIG-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamey Wood updated SHINDIG-428:
-------------------------------

    Attachment: fix-428-bug.patch

A simple patch which addresses this issue (but, as noted in the original description, may not be sufficiently robust as it could allow for collisions with keys selected by end users).

> 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
>         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.


[jira] Commented: (SHINDIG-428) Adding multiple newUpdatePersonAppDataRequest items to a single DataRequest does not work (for restful container)

Posted by "Cassie Doll (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614023#action_12614023 ] 

Cassie Doll commented on SHINDIG-428:
-------------------------------------

Thanks for finding this bug Jamey!

I went with a similar but slightly different solution which won't run into problems if the user specifies a key that matches the system key format. Will be committing it shortly. 

> 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
>         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.


[jira] Resolved: (SHINDIG-428) Adding multiple newUpdatePersonAppDataRequest items to a single DataRequest does not work (for restful container)

Posted by "Cassie Doll (JIRA)" <ji...@apache.org>.
     [ 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.