Resource Registry Service - Query & Access

From Gcube Wiki
Revision as of 11:49, 9 November 2017 by Luca.frosini (Talk | contribs) (Get Instance)

Jump to: navigation, search

This sections provide information regarding how to interact with Resource Registry Service for Query and Access. REST and JAVA API are presented for each functionality.

Please note that the provided examples can intentionally hide some details in the response to avoid unneeded complexity.

Apart the REST API this port type can be used also by using Resource Registry Client java client.

Resource Registry Client has the following maven coordinates

<dependency>
	<groupId>org.gcube.information-system</groupId>
	<artifactId>resource-registry-client</artifactId>
	<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>

To use the client you need first get a ResourceRegistryClient instance.

By using ResourceRegistryClientFactory.create() method the library discover the correct endpoint to interact with the Resource Registry for the current context.

SecurityTokenProvider.instance.set("Your-NextNext-Token-Here"); //If not already set
ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();

Exists

REST API

HEAD /resource-registry/access/instance/{ER Type}/{Instance UUID}
Example
HEAD /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9

Java API

Example

Get Instance

REST API

GET /resource-registry/access/instance/{ER Type}/{Instance UUID}
Example
GET /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9

Java API

Example

Get All Instances of a Specific Type

GET /resource-registry/access/instances/{ER Type}?[polymorphic=(true|false)]

Default:

  • polymorphic : false
  • direction : both

direction has sense only if reference UUID is provided, is ignored otherwise.


GET /resource-registry/access/instances/EService?polymorphic=true


Get All Instances of a Specific Type in relation with a specific entity instance

GET /resource-registry/access/instances/{ER Type}?[polymorphic=(true|false)]&reference={Instance UUID}&direction=(in|out|both)


Default:

  • polymorphic : false
  • direction : both
GET /resource-registry/access/instances/EService?polymorphic=true&reference=4d28077b-566d-4132-b073-f4edaf61dcb9&direction=out

Get Filtered Resource Instances

GET /resource-registry/access/resourceInstances/{Resource Type}/{ConsistsOf Type}/{Facet Type}?[polymorphic=(true|false)]&key1=value1&key2=value2&...

Default:

  • polymorphic : false


GET /resource-registry/access/resourceInstances/EService/IsIdentifiedBy/SoftwareFacet?polymorphic=true&group=DataAccess&name=HomeLibraryWebapp


public <R extends Resource> List<R> getFilteredResources(Class<R> resourceClass, Class<? extends ConsistsOf> consistsOfClass, Class<? extends Facet> facetClass,boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException


Map<String, Object> map = new HashMap<>();
map.put("group", "DataAccess");
map.put("name", "HomeLibraryWebapp");
		
List<EService> eServices = resourceRegistryClient.getFilteredResources(EService.class, IsIdentifiedBy.class, SoftwareFacet.class, true, map);


public List<Resource> getFilteredResources(String resourceType, String consistsOfType, String facetType, boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException;

Raw Query

GET /resource-registry/access?query=SELECT FROM Facet


Read Context

Allow to read the definition of a Context.

REST API

This API is also exposed in Context Port Type

GET /resource-registry/access/context/{Context UUID}
Example

Read the Context having UUID 9d73d3bd-1873-490c-b0a7-e3c0da11ad52

Request URL

GET /resource-registry/context/9d73d3bd-1873-490c-b0a7-e3c0da11ad52

Response Body

{
	"@class":"Context",
	"name":"devVRE",
	"header": {
		"@class":"Header",
		"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
		"creator":"luca.frosini",
		"lastUpdater":"luca.frosini",
		"creationTime":"2017-03-17 11:47:56",
		"lastUpdateTime":"2017-03-17 11:52:56"
	}
}

Read Type Definition

Allow to read Type Definition This API is also exposed in Access Port Type

REST API

GET /resource-registry/access/schema/{ Type Name } 
Example
GET /resource-registry/schema/ContactFacet

Response

{
	"name":"ContactFacet",
	"description":"This facet is expected to capture contact information",
	"abstractType": false,
	"superclasses":["Facet"],
	"properties":[
		{
			"name":"name",
			"description":"First Name",
			"mandatory":true,
			"readonly":false,
			"notnull":true,
			"max":null,
			"min":null,
			"regexpr":null,
			"linkedType":null,
			"linkedClass":null,
			"type":7 /* String*/
		},{
			"name":"eMail",
			"description": "A restricted range of RFC‑822 compliant email address. ... ",
			"mandatory":true,
			"readonly":false,
			"notnull":true,
			"max":null,
			"min":null,
			"regexpr":"^[a-z0-9._%+-]{1,128}@[a-z0-9.-]{1,128}$",
			"linkedType":null,
			"linkedClass":null,
			"type":7 /* String */
		}
	]
}