Summary: The REST API exposing HTTP based interface to the Space.

Overview

The REST API exposing HTTP based interface Space. It is leveraging the GigaSpace API. It support the following methods:

  1. GET - can be used to perform a readByID or a readMultiple action by a space query.
  2. POST - can be used to perform a write / writeMultiple action.
  3. PUT - can be used to perform a single or multiple write or update actions.
  4. DELETE - can be used to perform take / takeMultiple actions either by ID or by a space query.
    POST is mapped to a WriteOnly action. An exception will be thrown when trying to write an object which already exists in space.

Examples

  • writeMultiple
    curl -XPOST -d '[{"id":"1", "data":"testdata", "data2":"common", "nestedData" : {"nestedKey1":"nestedValue1"}}, 
    {"id":"2", "data":"testdata2", "data2":"common", "nestedData" : {"nestedKey2":"nestedValue2"}}, 
    {"id":"3", "data":"testdata3", "data2":"common", "nestedData" : {"nestedKey3":"nestedValue3"}}]' http://localhost:8080/WebApp/rest/data/Item
  • readMultiple
    [http://localhost:8080/WebApp/rest/data/Item/_criteria?q=data2='common]'
    [http://localhost:8080/WebApp/rest/data/Item/_criteria?q=id=%271%27%20or%20id=%272%27%20or%20id=%273%27]

The url is encoded, the query is "id='1' or id='2' or id='3'".

  • readById
    [http://localhost:8080/WebApp/rest/data/Item/1]
    [http://localhost:8080/WebApp/rest/data/Item/2]
    [http://localhost:8080/WebApp/rest/data/Item/3]
  • updateMultiple
    curl -XPUT -d '[{"id":"1", "data":"testdata", "data2":"commonUpdated", "nestedData" : {"nestedKey1":"nestedValue1"}}, 
    {"id":"2", "data":"testdata2", "data2":"commonUpdated", "nestedData" : {"nestedKey2":"nestedValue2"}}, 
    {"id":"3", "data":"testdata3", "data2":"commonUpdated", "nestedData" : {"nestedKey3":"nestedValue3"}}]' http://localhost:8080/WebApp/rest/data/Item

See that data2 field is updated:

[http://localhost:8080/WebApp/rest/data/Item/_criteria?q=data2='commonUpdated']

Single nested update:

curl -XPUT -d '{"id":"1", "data":"testdata", "data2":"commonUpdated", "nestedData" : 
{"nestedKey1":"nestedValue1Updated"}}' http://localhost:8080/WebApp/rest/data/Item

See that Item1 nested field is updated:

http://localhost:8080/WebApp/rest/data/Item/1
  • takeMultiple (url is encoded, the query is "id=1 or id=2")
    curl -XDELETE http://localhost:8080/WebApp/rest/data/Item/_criteria?q=id=%271%27%20or%20id=%272%27

See that only Item3 remains:

[http://localhost:8080/WebApp/rest/data/Item/_criteria?q=id=%271%27%20or%20id=%272%27%20or%20id=%273%27]
  • takeById
    curl -XDELETE "http://localhost:8080/WebApp/rest/data/Item/3"

See that Item3 does not exists:

[http://localhost:8080/WebApp/rest/data/Item/_criteria?q=id=%271%27%20or%20id=%272%27%20or%20id=%273%27]

Setup Instructions

1.Download the project from the github repository
2.Edit "/RESTData/src/main/webapp/WEB-INF/config.properties"? to include your space url, for example: spaceUrl=jini://*/*/testSpace?groups=restdata
3.Package the project using maven: "mvn package". This will run the unit tests and package the project to a war file located at /target/RESTData.war
4.Deploy the war file.

GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence