Define a native REST API client

This small shim of a client makes it easier to issue a REST API call
to the server and convert the results into a "Java" object available
within the UI code. To support fast conversion, requests ask to use
JSON by setting the Accept header and use JavaScript overlay types
to avoid any copying.

A NativeList utility is provided to handle a list result that
contains objects as the array members. There is no conversion cost
to using this list collection type.

A NativeMap utility is provided to handle a "map" of String to an
object, such as might appear in a JSON object. The map class can
optionally copy the map keys into the values as a property of the
value, allowing the client to convert:

  {
    "a": {"id": 1},
    "b": {"id": 2},
  }

into the following:

  {
    "a": {"id": 1, "name": "a"},
    "b": {"id": 2, "name": "b"},
  }

This is really useful if the caller just wants a list-like structure
of the children to enumerate, and doesn't wants to obtain the name
from the child object without worrying about keeping the map pair.

The client is currently only suitable for reading from the server,
to make state changes a XSRF token system must be added, and data
should be sent as part of an HTTP POST or HTTP PUT method.

Change-Id: Id07b2b62fb2239bc8bde00e109188410beb68882
6 files changed