Difference between revisions of "SStorageRest"

From Gcube Wiki
Jump to: navigation, search
(Access Mode)
(Access Mode)
Line 26: Line 26:
 
<source lang="java">
 
<source lang="java">
 
               SimpleQuery query = queryFor(ServiceInstance.class);
 
               SimpleQuery query = queryFor(ServiceInstance.class);
               query.addCondition("$resource/Data/gcube:ServiceClass/text() eq 'DataAccess'").addCondition("$resource/Data/gcube:ServiceName/text() eq 'tree-manager-service'");
+
               query.addCondition("$resource/Data/gcube:ServiceClass/text() eq sc").addCondition("$resource/Data/gcube:ServiceName/text() eq sn");
 
               DiscoveryClient<ServiceInstance> client = clientFor(ServiceInstance.class);
 
               DiscoveryClient<ServiceInstance> client = clientFor(ServiceInstance.class);
 
               List<ServiceInstance> resources = client.submit(query);
 
               List<ServiceInstance> resources = client.submit(query);
 
</source>
 
</source>
  
where "sc" and "sn" are respectively the "ServiceClass" and the "ServiceName" of the resource. In this case the "ServiceClass" is: DataStorage, the "ServiceName" is "SmartStorageREST".
+
where "sc" and "sn" are respectively the "ServiceClass" and the "ServiceName" of the resource. In this case the "ServiceClass" should be set to: "content-management", and the "ServiceName" should be set to "storage".
  
The method client.submit(query) return a List of resources (tipically with only one resource) that match the query parameters.
+
The method client.submit(query) return a List of resources (in this case with only one resource) that match the query parameters.
  
For retrieving the hostname of the Query server, it's needed to scroll the resource found in the follwing way:
+
For retrieving the hostname of the SStorageRest service, it's needed to parse the resource retrieved in the following way:
  
 
<source lang="java">
 
<source lang="java">

Revision as of 10:38, 22 December 2017


Overview

A RESTful service providing functions for create, update, read a json object on MongoDB

Key features

The core of the service is java based. It offers a interface for performing CRUD operation through a remote backend over JSON object:

  • Create
  • Read
  • Update
  • Delete


Design and Architecture

The architecture implements a multiton pattern. The records are collected in two separated collection: the first one is a collection dedicated to a single SmartApps, the second One is a collection that collects all the records of all the smartApplications.

Access Mode

The Endppoint of the SStorageRest service can be discovered by IS-Collector service under the SmartArea VO. For accessing to the service it's needed to use the ic-client library in the following way:

               SimpleQuery query = queryFor(ServiceInstance.class);
               query.addCondition("$resource/Data/gcube:ServiceClass/text() eq sc").addCondition("$resource/Data/gcube:ServiceName/text() eq sn");
               DiscoveryClient<ServiceInstance> client = clientFor(ServiceInstance.class);
               List<ServiceInstance> resources = client.submit(query);

where "sc" and "sn" are respectively the "ServiceClass" and the "ServiceName" of the resource. In this case the "ServiceClass" should be set to: "content-management", and the "ServiceName" should be set to "storage".

The method client.submit(query) return a List of resources (in this case with only one resource) that match the query parameters.

For retrieving the hostname of the SStorageRest service, it's needed to parse the resource retrieved in the following way:

String server addresses=resource.profile().accessPoints().get(0).address();

where "resource" is the object returned by the query. the field address can contains one or more server separated by comma.

Supported Operations

  • create: implemented by http POST method;
  • read : implemented by http GET method;
  • update: implemented by http PUT method;
  • delete: implemented by http DELETE method.

Getting-Started

Maven artifacts

it is downloadable by the following nexus server: http://maven.research-infrastructures.eu/nexus

<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-service-rest</artifactId>

Usage examples

To insert (create) a new record in the system, we might use:

  • POST n039.smart-applications.area.pi.cnr.it:8080/storage/rest/resources?gcube-token=xxxxxxxx

To read a object with ID# 33245:

Here are proposed URIs for products:

for reading, updating, deleting object with id 66432, respectively.

For deleting all the objects in the collection: