Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-25201

Add JSON WebService invoker action for batching calls and merging results

    Details

      Description

      The proposal solves the problem of returning different object trees of the same object(s) in single request.

      Let's take your example with Users. User object has just contactId, but not the whole Contact object. So, if we need both User and Contact on a page, we need to invoke two services separately. Idea is to have single request that also defines the returned object tree, without the need of additional dummy backend service methods. So with just one call (whatever the syntax is) we would get an User json object that contains a Contact json object inside.

      To attend all that requirements we need a more extended syntax.

      [1] Do simple calls to a method.

      {
         "/user/get-user-by-id": {
             "userId": 123,
             "userParam1": ...
         }
      }
      

      Or with an optional "name":

      {
         "$user = /user/get-user-by-id": {
             "userId": 123,
             "userParam1": ...
         }
      }
      

      [2] Define a "name" for the request to be possible link them as
      parameter values passed to deeper calls:

      {
              "$user = /user/get-user-by-id": {
                      "userId": 123,
                      "userParam1": ...,
      
                      "$contact = /contact/get-contact-by-id": {
                              "@userId": "$user.contactId",
                              "contactParam1": ...
                      }
              }
      }
      

      This call will return the user json with a key called "contact" defined by @contact.

      { name: 'Nate', userId: 123, contact: { emailAddress:
      'nathan.cava...@life....' } }
      

      [3] Filter the keys outputted to the request. Let's say the "user" has a field called "description" that contains 1 MByte of text, we don't need that on the outputted JSON. A whitelist can be passed with the field names to have in the result:

      {
              "$user[firstName, emailAddress] = /user/get-user-by-id": {
                      "userId": 123,
                      "userParam1": ...,
      
                      "$contact = /contact/get-contact-by-id": {
                              "@userId": "$user.contactId",
                              "contactParam1": ...
                      }
              }
      }
      

      [4] Allow batching:

      [
      {/* first command */},
      {/* second command */}
      ]
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  7 years, 37 weeks ago

                  Packages

                  Version Package
                  6.1.1 CE GA2
                  6.1.20 EE GA2
                  --Sprint 11/12
                  6.2.0 CE M2