Difference between revisions of "Resource Registry Service - Context Management"

From Gcube Wiki
Jump to: navigation, search
(Created page with "This sections provide information regarding hot to interact with Resource Registry Service . REST and JAVA...")
 
(Resource Registry Context Client)
 
(257 intermediate revisions by the same user not shown)
Line 1: Line 1:
This sections provide information regarding hot to interact with [[Information System Resource Registry#Resource_Registry Service | Resource Registry Service ]]. REST and JAVA API are presented for each functionality.
+
[[Category: Developer's Guide]]
 +
[[Category: Information System]]
 +
{| align="right"
 +
||__TOC__
 +
|}
 +
 
 +
These sections provide information regarding how to interact with [[Information System Resource Registry#Resource Registry Service | Resource Registry Service]] for Context Management.  
 +
REST API are presented for each functionality.
  
 
Please note that the provided examples can intentionally hide some details in the response to avoid unneeded complexity.
 
Please note that the provided examples can intentionally hide some details in the response to avoid unneeded complexity.
  
=== Context Management ===
+
== Context Management ==
  
It is responsible for managing [[Facet_Based_Resource_Model#Context| Context]] belonging to the same Application Domain.
+
Context Management is responsible for managing hierarchical [[Facet_Based_Resource_Model#Context| Context]] as defined by the [[Facet_Based_Resource_Model|IS Model]].
 
+
Security configuration based on [[Authorization Framework]] make this port type accessible only from [[Information System Resource Manager|Resource Manager]]. In other words no others client is allowed to manage [[Facet_Based_Resource_Model#Context| Context]] rather than [[Information System Resource Manager|Resource Manager]].
+
  
 
[[Facet_Based_Resource_Model#Context|Context]] requirements:
 
[[Facet_Based_Resource_Model#Context|Context]] requirements:
* No predefined number of levels.
+
* No predefined number of levels;
* Possibility to change the name of the Context with no impact for any component.
+
* Possibility to change the name of the Context with no impact for any component;
 
* Possibility to move a [[Facet_Based_Resource_Model#Context| Context]] from a parent [[Facet_Based_Resource_Model#Context| Context]] to another.
 
* Possibility to move a [[Facet_Based_Resource_Model#Context| Context]] from a parent [[Facet_Based_Resource_Model#Context| Context]] to another.
  
Available Methods:
+
Any request to this port type has success if the following guarantees are satisfied:
  
* [[#Create|Create]]
+
* the hierarchy of contexts is a tree with an arbitrary number of levels;
* [[#Rename|Rename]]
+
* two contexts with the same name can only exist if they have different parents;
* [[#Move|Move]]
+
* any update to a context does not have any side effect on the instances belonging to the context;
* [[#Delete|Delete]]
+
* it is not possible to delete a context if
 +
** it contains instances. It is the responsibility of the clients to remove the instances from the context (or delete them) before trying to delete the context;
 +
** it has children context. It is the responsibility of the clients to remove or move the children context before trying to delete the context.
  
Any action made to Contexts succeed if the following requirements are guaranteed:
 
* Two Context with same name can exist but only if they have different parents. The operation which will try to obtain a Context with the same name to the same parent will fails with no effect.
 
* Any operation made in any Context has effect only to the Context. In other words, there will be no effect on the associated Entity and Relations.
 
  
At time of writing this port type is only accessible by using REST API. [[Information System Resource Registry#Resource_Registry_Context_Client | Resource Registry Context Client]] (java client) is under development.
+
Context Management exposes the following APIs:
  
==== Create ====
+
* '''[[#List Contexts|List]]''': allows to enumerate the contexts;
 +
* '''[[#Create Context|Create]]''': allows to create a new context as a child of another context (if any). The context has a name;
 +
* '''[[#Exists|Exists]]''': allows to check if a Context exists;
 +
* '''[[#Read Context|Read]]''': allows to read a Context;
 +
* '''[[#Update Context|Update]]''':
 +
** '''[[#Rename Context|Rename]]''': rename a context;
 +
** '''[[#Move Context|Move]]''': move a context as a child of another Context.
 +
* '''[[#Delete Context|Delete]]''': allows to delete a Context.
  
<pre>PUT /resource-registry/context</pre>
+
== Context Collection ==
  
===== Description =====
+
The following table shows the exposed APIs as REST Collection
  
Create new Context as child of another Context (if any).
+
{| class="wikitable"
 
+
! Operation || HTTP Method || URL
===== Parameters =====
+
 
+
{|class="wikitable"
+
! Name
+
! Type
+
! Required
+
! Description
+
 
|-
 
|-
| '''name'''
+
| List || GET || <code>/contexts</code>
| String
+
| true
+
| The name of the context.
+
 
|-
 
|-
| '''parentContextId'''
+
| Create || PUT || <code>/contexts/{UUID}</code>
| String (UUID)
+
| false
+
| The UUID of the parent Context if any
+
|}
+
 
+
===== Responses =====
+
 
+
{|class="wikitable"
+
! Code
+
! Type
+
! Description
+
 
|-
 
|-
| 200
+
| Exists || HEAD || <code>/contexts/{UUID}</code>
| String
+
|-
| The json representation of the Context.
+
| Read || GET || <code>/contexts/{UUID}</code>
 +
|-
 +
| Update || PUT || <code>/contexts/{UUID}</code>
 +
|-
 +
| Delete || DELETE || <code>/contexts/{UUID}</code>
 
|}
 
|}
  
===== Examples =====
+
Security configuration based on [[Authorization Framework]] make this port type accessible only from [[Information System Resource Manager|Resource Manager]]. In other words, no others client is allowed to manage [[Facet_Based_Resource_Model#Context| Context]] rather than [[Information System Resource Manager|Resource Manager]].
  
Create a new Context with name '''gcube''' with no parent. It is a ROOT Context.
+
== Resource Registry Context Client ==
  
''Request URL''
+
Resource Registry Context Client is a java library providing RPC facilities to interact with [[#Context Collection|Context Collection]].
 +
The library hides all the complexity of marshalling and unmarshalling of requests and results.
 +
By using this library any client is able to manage java classes instead of JSON objects.
  
<pre>PUT /resource-registry/context?name=gcube</pre>
+
To use the Java library to interact with Context Collection declare the following dependency in your pom.xml file.
  
''Response Body''
+
<source lang="xml">
 +
<dependency>
 +
<groupId>org.gcube.information-system</groupId>
 +
<artifactId>resource-registry-context-client</artifactId>
 +
<version>[4.0.0,5.0.0-SNAPSHOT)</version>
 +
<dependency>
 +
</source>
  
<pre>
 
{
 
"@class":"Context",
 
"name":"gcube",
 
"header": {
 
"@class":"Header",
 
"uuid":"2705dd32-c857-444b-818a-3ec69e339e5d",
 
"creator":"luca.frosini",
 
"lastUpdater":"luca.frosini",
 
"creationTime":"2017-03-17 11:47:55",
 
"lastUpdateTime":"2017-03-17 11:47:55"
 
}
 
}
 
</pre>
 
  
 +
To use the client you just need to instantiate the client via the provided factory.
  
 +
<source lang="java">
 +
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
 +
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory;
  
Create a new Context with name '''devsec''' as child of Context with UUID '''2705dd32-c857-444b-818a-3ec69e339e5d (gcube)'''
+
....
  
''Request URL''
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
</source>
  
<pre>/resource-registry/context?name=devsec&parentContextId=2705dd32-c857-444b-818a-3ec69e339e5d</pre>
+
The provided client exposes the available methods and options as explained below.
  
''Response Body''
+
The source code of the resource-registry-context-client is available at [https://code-repo.d4science.org/gCubeSystem/resource-registry-context-client https://code-repo.d4science.org/gCubeSystem/resource-registry-context-client]
  
<pre>
+
== APIs ==
{
+
"@class":"Context",
+
"name":"devsec",
+
"header": {
+
"@class":"Header",
+
"uuid":"30f6254c-c87a-451e-bc0f-7cfcbd94a84a",
+
"creator":"luca.frosini",
+
"lastUpdater":"luca.frosini",
+
"creationTime":"2017-03-17 11:47:56",
+
"lastUpdateTime":"2017-03-17 11:47:56"
+
}
+
}
+
</pre>
+
  
 
+
The provided examples are based on the following Context tree
Create a new Context with name '''devVRE''' as child of Context with UUID '''30f6254c-c87a-451e-bc0f-7cfcbd94a84a (devsec)'''
+
 
+
''Request URL''
+
 
+
<pre>/resource-registry/context?name=devVRE&parentContextId=30f6254c-c87a-451e-bc0f-7cfcbd94a84a</pre>
+
 
+
''Response Body''
+
  
 
<pre>
 
<pre>
{
+
-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
"@class":"Context",
+
|
"name":"devVRE",
+
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
"header": {
+
|  |
"@class":"Header",
+
|  |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
+
|
"lastUpdater":"luca.frosini",
+
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
"creator":"luca.frosini",
+
    |
"creationTime":"2017-03-17 11:47:57",
+
    |---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)
"lastUpdateTime":"2017-03-17 11:47:57"
+
}
+
}
+
 
</pre>
 
</pre>
  
If you try to create again a Context with name '''gcube''' with no parent. You will obtain a '''400 Bad Request''' HTTP error
+
=== List Contexts ===
  
''Request URL''
+
List all available contexts.
  
<pre>PUT /resource-registry/context?name=gcube</pre>
 
  
''Response Body''
+
==== List via Java client ====
<pre>
+
{
+
    "@class": "ContextCreationException",
+
    "message": "A root context with the same name (gcube) already exist"
+
}
+
</pre>
+
  
This will happen anytime you try to create a context with the same name, having the same parent, of an existing Context.
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
List<Context> contexts = resourceRegistryContextClient.all();
 +
</source>
  
==== Rename ====
 
  
<pre>POST /resource-registry/context/rename/{UUID}</pre>
+
==== List via REST API ====
  
===== Description =====
+
<pre>GET /resource-registry/contexts</pre>
 
+
Rename a Context identified by the UUID provided as path parameter to the new name provided as query parameter.
+
 
+
===== Parameters =====
+
 
+
{|class="wikitable"
+
! Name
+
! Type
+
! Required
+
! Description
+
|-
+
| '''{''Path Parameter''}'''
+
| String (UUID)
+
| true
+
| The UUID of the target context.
+
|-
+
| '''name'''
+
| String
+
| true
+
| The new name of the target context.
+
|}
+
  
===== Responses =====
 
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 192: Line 135:
 
| 200
 
| 200
 
| String
 
| String
| The json representation of the context.
+
| A JSON array containing as an element the representation of each Context
 
|}
 
|}
  
===== Examples =====
+
'''Request URL'''
  
Rename a Context '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52''' (was '''devVRE''') to the new name '''devNext'''.
+
<pre>GET /resource-registry/contexts</pre>
  
''Request URL''
+
'''Response Body'''
  
<pre>POST /resource-registry/context/rename/9d73d3bd-1873-490c-b0a7-e3c0da11ad52?name=devNext</pre>
+
<source lang="JavaScript">
 +
[
 +
{
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.464 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
},
 +
"name": "gcube",
 +
"parent": null,
 +
"children": [
 +
{
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "c470a070-83e8-45e8-8630-440225702acc",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.967 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
 +
},
 +
"target": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.978 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
},
 +
"name": "devNext"
 +
}
 +
},
 +
{
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.410 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
 +
},
 +
"target": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.418 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
 +
},
 +
"name": "devsec"
 +
}
 +
}
 +
]
 +
},
 +
{
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "4c0c3500-32d6-11ea-867c-af3c989f8e41",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:30.098 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:30.098 +0000"
 +
},
 +
"name": "devVRE",
 +
"parent": {
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "347f0e81-7407-485d-9698-946cf3b10c0b",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:30.090 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:30.090 +0000"
 +
},
 +
"source": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.418 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
 +
},
 +
"name": "devsec"
 +
}
 +
},
 +
"children": []
 +
},
 +
{
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.978 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
},
 +
"name": "devNext",
 +
"parent": {
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "c470a070-83e8-45e8-8630-440225702acc",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.967 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
 +
},
 +
"source": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.464 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
},
 +
"name": "gcube"
 +
}
 +
},
 +
"children": [
 +
{
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.835 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
 +
},
 +
"target": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.846 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
 +
},
 +
"name": "NextNext"
 +
}
 +
}
 +
]
 +
},
 +
{
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.418 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
 +
},
 +
"name": "devsec",
 +
"parent": {
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.410 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
 +
},
 +
"source": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.464 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
},
 +
"name": "gcube"
 +
}
 +
},
 +
"children": [
 +
{
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "347f0e81-7407-485d-9698-946cf3b10c0b",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:30.090 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:30.090 +0000"
 +
},
 +
"target": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "4c0c3500-32d6-11ea-867c-af3c989f8e41",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:30.098 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:30.098 +0000"
 +
},
 +
"name": "devVRE"
 +
}
 +
}
 +
]
 +
},
 +
{
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.846 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
 +
},
 +
"name": "NextNext",
 +
"parent": {
 +
"@class": "IsParentOf",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:27.835 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
 +
},
 +
"source": {
 +
"@class": "Context",
 +
"header": {
 +
"@class": "Header",
 +
"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
 +
"createdBy": "luca.frosini",
 +
"creationTime": "2021-06-30 09:38:26.978 +0000",
 +
"lastUpdateBy": "luca.frosini",
 +
"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
},
 +
"name": "devNext"
 +
}
 +
},
 +
"children": []
 +
}
 +
]
 +
</source>
  
''Response Body''
+
=== Create Context ===
  
<pre>
+
Create new Context as a child of another Context (if any).
{
+
"@class":"Context",
+
"header": {
+
"@class":"Header",
+
"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
+
"creator":"luca.frosini",
+
"creationTime":"2017-03-17 11:47:56",
+
"lastUpdateTime":"2017-03-17 11:52:56"
+
}
+
"name":"devNext"
+
}
+
</pre>
+
  
==== Move ====
+
==== Create via Java Client ====
  
<pre>POST /resource-registry/context/move/{{UUID}}</pre>
+
===== Create via Java Client Example 1 =====
  
===== Description =====
+
This Java code snippet shows how to create a new Context with name '''gcube''' with no parent. It is a ROOT Context.
  
Move a Context identified by the UUID provided as path parameter as child of the Context provided as query parameter.
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
  
===== Parameters =====
+
Context gcubeContext = new ContextImpl("gcube");
 +
// Java class generate a random UUID and use to interact with Resource Regsitry Service
 +
// To specify the UUID
 +
// UUID gcubeUUID = UUID.fromString("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
 +
// Context gcubeContext = new ContextImpl("gcube", gcubeUUID);
 +
gcubeContext = resourceRegistryContextClient.create(gcubeContext);
 +
</source>
  
{|class="wikitable"
+
===== Create via Java Client Example 2 =====
! Name
+
 
! Type
+
This Java code snippet shows how to create a new Context with name '''devNext''' as child of Context with UUID '''c470a070-83e8-45e8-8630-440225702acc''' (gcube).
! Required
+
 
! Description
+
<source lang="java">
|-
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
| '''{''Path Parameter''}'''
+
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
| String (UUID)
+
 
| true
+
Context devNextContext = new ContextImpl("devNext");
| The UUID of the target Context
+
// To specify the UUID
|-
+
// UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
| '''parentContextId'''
+
// Context testVOContext = new ContextImpl("devNext", devNextUUID);
| String (UUID)
+
devNextContext.setParent(gcubeContext);
| true
+
devNextContext = resourceRegistryContextClient.create(devNextContext);
| The parent Context UUID
+
</source>
|}
+
 
 +
==== Create via REST API ====
  
===== Responses =====
+
<pre>PUT /resource-registry/contexts/{{UUID}}</pre>
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 255: Line 450:
 
| 200
 
| 200
 
| String
 
| String
| The json representation of the context.
+
| The JSON representation of the newly created Context
 
|}
 
|}
  
===== Examples =====
 
  
Rename a Context '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52''' as child of the Context '''761d9e99-a4dc-4838-9b16-4bf73813b625'''
+
===== Create via REST API Example 1 =====
  
''Request URL''
+
Create a new Context with name '''gcube''' with no parent. It is a ROOT Context.
  
<pre>POST /resource-registry/context/move/9d73d3bd-1873-490c-b0a7-e3c0da11ad52?parentContextId=761d9e99-a4dc-4838-9b16-4bf73813b625</pre>
+
'''Request URL'''
  
''Response Body''
+
<pre>PUT /resource-registry/context/ca50eb95-b76c-44fd-9182-229d39c3c9e2</pre>
  
<pre>
+
'''Request Body'''
 +
 
 +
<source lang="javascript">
 
{
 
{
"@class":"Context",
+
"@class": "Context",
"name":"devNext"
+
"name": "gcube",
 
"header": {
 
"header": {
"@class":"Header",
+
"@class": "Header",
"uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52",
+
"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
"creator":"luca.frosini",
+
"lastUpdater":"luca.frosini",
+
"creationTime":"2017-03-17 11:47:56",
+
"lastUpdateTime":"2017-03-17 11:52:56"
+
 
}
 
}
 
}
 
}
</pre>
+
</source>
  
==== Delete ====
 
  
<pre>DELETE /resource-registry/context/{{UUID}}</pre>
+
'''Response Body'''
  
===== Description =====
+
<source lang="javascript">
 +
{
 +
    "@class": "Context",
 +
    "header": {
 +
        "@class": "Header",
 +
        "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
        "createdBy": "luca.frosini",
 +
        "creationTime": "2021-06-30 09:38:26.464 +0000",
 +
        "lastUpdateBy": "luca.frosini",
 +
        "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
    },
 +
    "name": "gcube",
 +
    "parent": null,
 +
    "children": []
 +
}
 +
</source>
  
Delete the Context identified by the UUID provided as path parameter.
+
===== Create via REST API Example 2 =====
  
===== Parameters =====
+
Create a new Context with name '''devNext''' as child of Context with UUID '''c470a070-83e8-45e8-8630-440225702acc''' (gcube).
  
{|class="wikitable"
+
'''Request URL'''
! Name
+
! Type
+
! Required
+
! Description
+
|-
+
| '''{''Path Parameter''}'''
+
| String (UUID)
+
| true
+
| The UUID of the target Context
+
|}
+
  
===== Responses =====
+
<pre>PUT /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771</pre>
  
{|class="wikitable"
+
'''Request Body'''
! Code
+
! Type
+
! Description
+
|-
+
| 200
+
| String
+
| NO CONTENT
+
|}
+
  
===== Examples =====
+
<source lang="javascript">
 +
{
 +
    "@class": "Context",
 +
    "header": {
 +
        "@class": "Header",
 +
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
 +
    },
 +
    "name": "devNext",
 +
    "parent": {
 +
        "@class": "IsParentOf",
 +
        "header": null,
 +
        "source": {
 +
            "@class": "Context",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
 +
            }
 +
        }
 +
    }
 +
}
 +
</source>
  
Delete the Context having UUID '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52'''
+
'''Response Body'''
  
''Request URL''
+
<source lang="javascript">
 +
{
 +
    "@class": "Context",
 +
    "header": {
 +
        "@class": "Header",
 +
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
 +
        "createdBy": "luca.frosini",
 +
        "creationTime": "2021-06-30 09:38:26.978 +0000",
 +
        "lastUpdateBy": "luca.frosini",
 +
        "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
    },
 +
    "name": "devNext",
 +
    "parent": {
 +
        "@class": "IsParentOf",
 +
        "header": {
 +
            "@class": "Header",
 +
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
 +
            "createdBy": "luca.frosini",
 +
            "creationTime": "2021-06-30 09:38:26.967 +0000",
 +
            "lastUpdateBy": "luca.frosini",
 +
            "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
 +
        },
 +
        "source": {
 +
            "@class": "Context",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
                "createdBy": "luca.frosini",
 +
                "creationTime": "2021-06-30 09:38:26.464 +0000",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
            },
 +
            "name": "gcube"
 +
        }
 +
    },
 +
    "children": []
 +
}
 +
</source>
  
<pre>DELETE /resource-registry/context/9d73d3bd-1873-490c-b0a7-e3c0da11ad52</pre>
+
=== Read Context ===
  
=== Schema Management ===
+
Return the definition of the Context identified by the UUID provided as the path parameter.
  
At time of writing this port type is only accessible by using REST API. [[Information System Resource Registry#Resource_Registry_Schema_Client | Resource Registry Schema Client]] (java client) is under development.
+
==== Read via Java Client ====
  
==== Type Definition ====
 
  
Any Type is described by the following attributes:
+
===== Read via Java Client Example 1 =====
  
* '''name''' (String): Type Name
 
* '''description''' (String): The description of the Type. <code>default=null</code>.
 
* '''abstractType''' (Boolean): Indicate if the type is abstract so that it cannot be instatiated. In other words only subtypes of this type can be isntantiated. <code>default=false</code>.
 
* '''superclasses''' (List<String>): The list of all supertypes of this type. Multiple Inheritance is supported.
 
* Zero o more [[Facet_Based_Resource_Model#Property | Properties]]
 
  
===== Property =====
+
Read the Context having UUID '''ca50eb95-b76c-44fd-9182-229d39c3c9e2''' (gcube)
  
Any [[Facet_Based_Resource_Model#Property | Property]] is described by the following attributes:
+
Read using a string representing the UUID.
  
* '''name''' : Property Name
+
<source lang="java">
* '''type''' : The Type of the Property (e.g. String, Integer, ...). See [[#Property_Type|Property Type]]
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
* '''description''' : The description of the Property. <code>default=null</code>.
+
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
* '''mandatory''' : Indicate if the Property is mandatory. <code>default=false</code>.
+
</source>
* '''readOnly''' : The Property cannot change its value. <code>default=false</code>.
+
* '''notNull''' : Whether the property must assume a value diverse from 'null' or not. <code>default=false</code>
+
* '''max''' : <code>default=null</code>
+
* '''min''' : <code>default=null</code>
+
* '''regexpr''' : A [https://en.wikipedia.org/wiki/Regular_expression Regular Expression] to validate the property value, <code>default=null</code>. A good online tool for regex is avalable at [https://regex101.com/ https://regex101.com/]
+
  
====== Property Type Mapping ======
+
===== Read via Java Client Example 2 =====
  
[[Facet_Based_Resource_Model#Basic_Property_Type | Property Type]] are mapped to and integer to be used in property definition:
+
Read the Context having UUID '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (devNext)
  
Type binder is defined here:
+
Read using UUID. This normally used when we already have the UUID instance.
[http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/information-system-model/src/main/java/org/gcube/informationsystem/types/Type.java]
+
 
 +
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
 +
Context devNextContext = resourceRegistryContextClient.read(devNextUUID);
 +
</source>
 +
 
 +
 
 +
Read using context instance. This normally used when we already have the context instance.
 +
 
 +
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
 +
Context devNextContext = new ContextImpl("devNext", devNextUUID);
 +
devNextContext = resourceRegistryContextClient.read(devNextContext);
 +
</source>
 +
 
 +
 
 +
==== Read via REST API  ====
 +
 
 +
<pre>GET /resource-registry/context/{UUID}</pre>
  
 
{|class="wikitable"
 
{|class="wikitable"
 +
! Code
 
! Type
 
! Type
! Integer Mapping
 
! Java type
 
 
! Description
 
! Description
 
|-
 
|-
| Boolean
+
| 200
| 0
+
| <code>java.lang.Boolean</code> or <code>boolean</code>
+
| Handles only the values <em>True</em> or <em>False</em>.
+
|-
+
| Integer
+
| 1
+
| <code>java.lang.Integer</code> or <code>int</code> or  <code>java.math.BigInteger</code>
+
| 32-bit signed Integers.
+
|-
+
| Short
+
| 2
+
| <code>java.lang.Short</code> or <code>short</code>
+
| Small 16-bit signed integers.
+
|-
+
| Long
+
| 3
+
| <code>java.lang.Long</code> or <code>long</code>
+
| Big 64-bit signed integers.
+
|-
+
| Float
+
| 4
+
| <code>java.lang.Float</code> or <code>float</code>
+
| Decimal numbers
+
|-
+
| Double
+
| 5
+
| <code>java.lang.Double</code> or <code>double</code>
+
| Decimal numbers with high precision.
+
|-
+
| Date
+
| 6
+
| <code>java.util.Date</code>
+
| Any date with the precision up to milliseconds.
+
|-
+
 
| String
 
| String
| 7
+
| The JSON representation of the requested Context
| <code>java.lang.String</code>
+
| Any string as alphanumeric sequence of chars.
+
|-
+
| Binary
+
| 8
+
| <code>java.lang.Byte[]</code> or <code>byte[]</code>
+
| Can contain any value as byte array.
+
|-
+
| Embedded
+
| 9
+
| <code>?  extends org.gcube.informationsystem.model.embedded.Embedded</code>
+
| This is an Object contained inside the owner Entity and has no [[#Header|Header]]. It is reachable only by navigating the owner Entity.
+
|-
+
| Embedded list
+
| 10
+
| <code>List&lt;?  extends org.gcube.informationsystem.model.embedded.Embedded&gt;</code>
+
| List of Objects contained inside the owner Entity and have no [[#Header|Header]]. They are reachable only by navigating the owner Entity.
+
|-
+
| Embedded set
+
| 11
+
| <code>Set&lt;? extends org.gcube.informationsystem.model.embedded.Embedded&gt;</code>
+
| Set (no duplicates) of Objects contained inside the owner Entity and have no [[#Header|Header]]. They are reachable only by navigating the owner Entity.
+
|-
+
| Embedded map
+
| 12
+
| <code>Map&lt;String, ? extends org.gcube.informationsystem.model.embedded.Embedded&gt;</code>
+
| Map of Objects contained inside the owner Entity and have no [[#Header|Header]]. They are reachable only by navigating the owner Entity.
+
|-
+
| Byte
+
| 17
+
| <code>java.lang.Byte</code> or <code>byte</code>
+
| Single byte. usesful to store small 8-bit signed integers.
+
 
|}
 
|}
  
==== Resource Type Creation ====
 
  
<pre>
+
===== Read via REST API Example 1 =====
PUT /resource-registry/schema/Resource
+
</pre>
+
  
'''''Request Body'''''
+
Read the Context having UUID '''ca50eb95-b76c-44fd-9182-229d39c3c9e2''' (gcube)
<pre>
+
{
+
"name":"Actor",
+
"description":"Any entity (human or machine) playing an active role.",
+
"abstractType":true, /* If the Resource cannot be instantiated */
+
"superclasses":["Resource"], /* Resource or any registered specialization. */
+
"properties":null /* MUST be null. The Resource cannot have any property. */
+
}
+
</pre>
+
  
==== Facet Type Creation ====
+
'''Request URL'''
  
<pre>
+
<pre>GET /resource-registry/contexts/ca50eb95-b76c-44fd-9182-229d39c3c9e2</pre>
PUT /resource-registry/schema/Facet
+
 
</pre>
+
'''Response Body'''
  
'''''Request Body'''''
+
<source lang="javascript">
<pre>
+
 
{
 
{
"name":"ContactFacet",
+
    "@class": "Context",
"description":"This facet is expected to capture contact information",
+
    "header": {
"abstractType": false,
+
        "@class": "Header",
"superclasses":["Facet"],
+
        "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
"properties":[
+
        "createdBy": "luca.frosini",
{
+
        "creationTime": "2021-06-30 09:38:26.464 +0000",
"name":"name",
+
        "lastUpdateBy": "luca.frosini",
"description":"First Name",
+
        "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
"mandatory":true,
+
    },
"readonly":false,
+
    "name": "gcube",
"notnull":true,
+
    "parent": null,
"max":null,
+
    "children": [
"min":null,
+
        {
"regexpr":null,
+
            "@class": "IsParentOf",
"linkedType":null,
+
            "header": {
"linkedClass":null,
+
                "@class": "Header",
"type":7 /* String*/
+
                "uuid": "c470a070-83e8-45e8-8630-440225702acc",
},{
+
                "createdBy": "luca.frosini",
"name":"eMail",
+
                "creationTime": "2021-06-30 09:38:26.967 +0000",
"description": "A restricted range of RFC‑822 compliant email address. ... ",
+
                "lastUpdateBy": "luca.frosini",
"mandatory":true,
+
                "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
"readonly":false,
+
            },
"notnull":true,
+
            "target": {
"max":null,
+
                "@class": "Context",
"min":null,
+
                "header": {
"regexpr":"^[a-z0-9._%+-]{1,128}@[a-z0-9.-]{1,128}$",
+
                    "@class": "Header",
"linkedType":null,
+
                    "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
"linkedClass":null,
+
                    "createdBy": "luca.frosini",
"type":7 /* String */
+
                    "creationTime": "2021-06-30 09:38:26.978 +0000",
}
+
                    "lastUpdateBy": "luca.frosini",
]
+
                    "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
                },
 +
                "name": "devNext"
 +
            }
 +
        },
 +
        {
 +
            "@class": "IsParentOf",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
 +
                "createdBy": "luca.frosini",
 +
                "creationTime": "2021-06-30 09:38:27.410 +0000",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
 +
            },
 +
            "target": {
 +
                "@class": "Context",
 +
                "header": {
 +
                    "@class": "Header",
 +
                    "uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
 +
                    "createdBy": "luca.frosini",
 +
                    "creationTime": "2021-06-30 09:38:27.418 +0000",
 +
                    "lastUpdateBy": "luca.frosini",
 +
                    "lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
 +
                },
 +
                "name": "devsec"
 +
            }
 +
        }
 +
    ]
 
}
 
}
</pre>
+
</source>
  
==== IsRelatedTo Type Creation ====
+
===== Read via REST API Example 2 =====
<pre>
+
PUT /resource-registry/schema/IsRelatedTo
+
</pre>
+
  
'''''Request Body'''''
+
Read the Context having UUID '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (devNext)
<pre>
+
{
+
"name":"Hosts",
+
"description": "…”,
+
"abstractType":false,
+
"superclasses":["IsRelatedTo"],
+
"properties":[]
+
}
+
</pre>
+
  
==== ConsistsOf Type Creation ====
+
'''Request URL'''
  
<pre>
+
<pre>GET /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771</pre>
PUT /resource-registry/schema/ConsistsOf
+
 
</pre>
+
'''Response Body'''
  
'''''Request Body'''''
+
<source lang="javascript">
<pre>
+
 
{
 
{
"name":"HasContact",
+
    "@class": "Context",
"description":"",
+
    "header": {
"abstractType":true,
+
        "@class": "Header",
"superclasses":["ConsistsOf"],
+
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
"properties":[]
+
        "createdBy": "luca.frosini",
 +
        "creationTime": "2021-06-30 09:38:26.978 +0000",
 +
        "lastUpdateBy": "luca.frosini",
 +
        "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
 +
    },
 +
    "name": "devNext",
 +
    "parent": {
 +
        "@class": "IsParentOf",
 +
        "header": {
 +
            "@class": "Header",
 +
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
 +
            "createdBy": "luca.frosini",
 +
            "creationTime": "2021-06-30 09:38:26.967 +0000",
 +
            "lastUpdateBy": "luca.frosini",
 +
            "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
 +
        },
 +
        "source": {
 +
            "@class": "Context",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
                "createdBy": "luca.frosini",
 +
                "creationTime": "2021-06-30 09:38:26.464 +0000",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
 +
            },
 +
            "name": "gcube"
 +
        }
 +
    },
 +
    "children": [
 +
        {
 +
            "@class": "IsParentOf",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
 +
                "createdBy": "luca.frosini",
 +
                "creationTime": "2021-06-30 09:38:27.835 +0000",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
 +
            },
 +
            "target": {
 +
                "@class": "Context",
 +
                "header": {
 +
                    "@class": "Header",
 +
                    "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
 +
                    "createdBy": "luca.frosini",
 +
                    "creationTime": "2021-06-30 09:38:27.846 +0000",
 +
                    "lastUpdateBy": "luca.frosini",
 +
                    "lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
 +
                },
 +
                "name": "NextNext"
 +
            }
 +
        }
 +
    ]
 
}
 
}
</pre>
+
</source>
  
==== Embedded Type Creation ====
+
=== Update Context ===
<pre>
+
PUT /resource-registry/schema/Embedded
+
</pre>
+
  
'''''Request Body'''''
+
Update a Context identified by the UUID provided as the path parameter.
<pre>
+
{
+
"name":"AccessPolicy",
+
"description":"",
+
"abstractType":false,
+
"superclasses":["Embedded"],
+
"properties":[{
+
"name":"policy",
+
"description":"",
+
"mandatory":false,
+
"readonly":false,
+
"notnull":false,
+
"max":null,
+
"min":null,
+
"regexpr":null,
+
"linkedType":null,
+
"linkedClass":”ValueSchema”,
+
"type": 9  /* Embedded */
+
},{
+
"name":"note",
+
"description":"",
+
"mandatory": false,
+
"readonly":false,
+
"notnull":false,
+
"max":null,
+
"min":null,
+
"regexpr":null,
+
"linkedType":null,
+
"linkedClass":null,
+
"type":7 /* String */
+
}]
+
}
+
</pre>
+
  
=== ER Management ===
+
The possible updates are on:
 +
* name;
 +
* parent Context.
  
Apart the REST API this port type can be used also by using [[Information System Resource Registry#Resource_Registry_Publisher | Resource Registry Publisher]] java client.
 
  
 +
==== Update via Java Client ====
  
[[Information System Resource Registry#Resource_Registry_Publisher | Resource Registry Publisher]] has the following maven coordinates
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
  
<pre>
+
Context contextToBeUpdated = ....;
<dependency>
+
<groupId>org.gcube.information-system</groupId>
+
<artifactId>resource-registry-publisher</artifactId>
+
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
+
</dependency>
+
</pre>
+
  
To use the client you need first get a ''ResourceRegistryPublisher'' instance.  
+
Context updatedContext = resourceRegistryContextClient.update(contextToBeUpdated);
By using ResourceRegistryPublisher.create() method the library discover the correct endpoint to interact with the Resource Registry for the current context.
+
</source>
  
<pre>
+
==== Update via REST API ====
SecurityTokenProvider.instance.set("Your-NextNext-Token-Here"); //If not already set
+
ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
+
</pre>
+
  
 +
<pre>PUT /resource-registry/contexts/{UUID}</pre>
  
==== Facet Instances APIs ====
+
{|class="wikitable"
 +
! Code
 +
! Type
 +
! Description
 +
|-
 +
| 200
 +
| String
 +
| The JSON representation of the updated Context
 +
|}
  
===== Create Facet Instance =====
+
==== Rename Context ====
  
====== REST API ======
+
===== Rename via Java Client =====
<pre>
+
PUT /resource-registry/er/facet/CPUFacet
+
</pre>
+
  
'''''Request Body'''''
+
Rename a Context '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (was '''devNext''') to the new name '''newDevNext'''.
<pre>
+
{
+
"@class":"CPUFacet",
+
"header":null,
+
"model":"Opteron",
+
"vendor":"AMD",
+
"clockSpeed":"1 GHz"
+
}
+
</pre>
+
  
'''''Response Body'''''
+
<source lang="java">
<pre>
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
{
+
Context devNextContext = resourceRegistryContextClient.read("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
"@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz",
+
devNextContext.setName("newDevNext");
"header": {
+
Context newDevNext = resourceRegistryContextClient.update(devNextContext);
"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
+
</source>
"creator":"luca.frosini", "creationTime":"2016-10-05 11:16:24",
+
"lastUpdateTime":"2016-10-05 11:16:24
+
}
+
}
+
</pre>
+
  
====== Java API ======
+
===== Rename via REST API =====
<pre>
+
CPUFacet cpuFacet = new CPUFacetImpl();
+
cpuFacet.setClockSpeed("1 GHz");
+
cpuFacet.setModel("Opteron");
+
cpuFacet.setVendor("AMD");
+
  
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet);
+
Rename a Context '''aa860961-6eb0-4c1c-89fb-c406fe2a2771''' (was '''devNext''') to the new name '''newDevNext'''.
UUID uuid = createdCpuFacet.getHeader().getUUID(); // 69f0b376-38d2-4a85-bc63-37f9fa323f82
+
</pre>
+
  
===== Update Facet Instance =====
+
'''Request URL'''
  
====== REST API ======
+
<pre>PUT /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771</pre>
<pre>
+
POST /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
+
</pre>
+
  
'''''Request Body'''''
+
'''Request Body'''
<pre>
+
 
 +
<source lang="javascript">
 
{
 
{
"@class":"CPUFacet",
+
    "@class": "Context",
"header":{"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82"}, /* if you pass the header only the UUID is checked and must be the same of the one provided in the URL*/
+
    "header": {
"model":"Opteron",
+
        "@class": "Header",
"vendor":"AMD",
+
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
"clockSpeed":"2 GHz"
+
    },
 +
    "name": "newDevNext",
 +
    "parent": {
 +
        "@class": "IsParentOf",
 +
        "header": {
 +
            "@class": "Header",
 +
            "uuid": "c470a070-83e8-45e8-8630-440225702acc"
 +
        },
 +
        "source": {
 +
            "@class": "Context",
 +
            "header": {
 +
                "@class": "Header",
 +
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
 +
            },
 +
            "name": "gcube"
 +
        }
 +
    }
 
}
 
}
</pre>
+
</source>
  
'''''Response Body'''''
+
'''Response Body'''
<pre>
+
 
{  
+
<source lang="javascript">
"@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"2 GHz",
+
{
"header": {
+
    "name": "newDevNext",
"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
+
    "header": {
"creator":"luca.frosini", "creationTime":"2016-10-05 11:16:24",
+
        "@class": "Header",
"lastUpdateTime":"2016-10-05 11:17:32"
+
        "creationTime": "2021-06-30 11:38:26.978 +0200",
}
+
        "createdBy": "luca.frosini",
 +
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
 +
        "lastUpdateBy": "luca.frosini",
 +
        "lastUpdateTime": "2021-07-01 16:44:46.592 +0200"
 +
    },
 +
    "@class": "Context",
 +
    "parent": {
 +
        "header": {
 +
            "@class": "Header",
 +
            "creationTime": "2021-07-01 16:43:57.358 +0200",
 +
            "createdBy": "luca.frosini",
 +
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
 +
            "lastUpdateBy": "luca.frosini",
 +
            "lastUpdateTime": "2021-07-01 16:43:57.358 +0200"
 +
        },
 +
        "@class": "IsParentOf",
 +
        "source": {
 +
            "name": "gcube",
 +
            "header": {
 +
                "@class": "Header",
 +
                "creationTime": "2021-06-30 11:38:26.464 +0200",
 +
                "createdBy": "luca.frosini",
 +
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 11:38:26.464 +0200"
 +
            },
 +
            "@class": "Context"
 +
        }
 +
    },
 +
    "children": [
 +
        {
 +
            "header": {
 +
                "@class": "Header",
 +
                "creationTime": "2021-06-30 11:38:27.835 +0200",
 +
                "createdBy": "luca.frosini",
 +
                "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
 +
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 11:38:27.835 +0200"
 +
            },
 +
            "@class": "IsParentOf",
 +
            "target": {
 +
                "name": "NextNext",
 +
                "header": {
 +
                    "@class": "Header",
 +
                    "creationTime": "2021-06-30 11:38:27.846 +0200",
 +
                    "createdBy": "luca.frosini",
 +
                    "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
 +
                    "lastUpdateBy": "luca.frosini",
 +
                    "lastUpdateTime": "2021-06-30 11:38:27.846 +0200"
 +
                },
 +
                "@class": "Context"
 +
            }
 +
        }
 +
    ]
 
}
 
}
</pre>
+
</source>
  
====== Java API ======
+
==== Move Context ====
<pre>
+
createdCpuFacet.setClockSpeed("2 GHz");
+
CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(CPUFacet.class, createdCpuFacet);
+
</pre>
+
  
===== Delete Facet Instance =====
+
We have 5 Contexts organized in the following Context Tree:
  
====== REST API ======
 
 
<pre>
 
<pre>
DELETE /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
+
- ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
 +
|
 +
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
 +
|  |
 +
|  |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
 +
|
 +
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
 +
    |
 +
    |---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)
 
</pre>
 
</pre>
  
'''''Response Body'''''
+
We want to move Context '''bad5f350-345c-11e9-9f49-cef9b1608c3f''' (NextNext) as child of the Context '''ca50eb95-b76c-44fd-9182-229d39c3c9e2''' (gcube) in palce of aa860961-6eb0-4c1c-89fb-c406fe2a2771  (devNext)
<pre>
+
In other words, NextNext will be a VO in place of a VRE.
true
+
 
</pre>
+
We will obtain the following Context tree
  
====== Java API ======
 
 
<pre>
 
<pre>
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
+
-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
 +
|
 +
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
 +
|  |
 +
|  |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
 +
|
 +
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
 +
|
 +
|---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)
 
</pre>
 
</pre>
  
==== Resource Instances APIs ====
 
  
===== Create Resource Instance =====
+
===== Move with Java client =====
  
====== REST API ======
+
<source lang="java">
<pre>
+
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
PUT /resource-registry/er/resource/HostingNode
+
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
</pre>
+
Context nextNextContext = resourceRegistryContextClient.read("bad5f350-345c-11e9-9f49-cef9b1608c3f");
 +
nextNextContext.setParent(gcubeContext);
 +
nextNextContext = resourceRegistryContextClient.update(nextNextContext);
 +
</source>
  
'''''Request Body'''''
 
<pre>
 
{
 
"@class":"HostingNode",
 
"consistsOf":[
 
{
 
"@class":"ConsistsOf",
 
"target":{
 
"@class":"CPUFacet",
 
"model":"Opteron",
 
"vendor":"AMD",
 
"clockSpeed":"3 GHz"
 
}
 
},{
 
"@class":"IsIdentifiedBy",
 
"target":{
 
"@class":"NetworkingFacet",
 
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"},
 
/* In this example we suppose that the NetworkingFacet was already created, so the UUID is enought to attach it by using IsIdentifiedBy relation */
 
}
 
}
 
],
 
"isRelatedTo":[
 
{
 
"@class":"Hosts",
 
"propagationConstraint":{
 
"add":"unpropagate",
 
"remove": "cascade"
 
},
 
"target":{
 
"@class":"EService",
 
"header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3"}
 
/* The EService was already created, so the UUID is enought to attach it by using Hosts relation */
 
}
 
}
 
]
 
}
 
  
</pre>
+
===== Move via REST API =====
  
'''''Response'''''
+
If we read the Context ''bad5f350-345c-11e9-9f49-cef9b1608c3f''' (NextNext) before moving it we have:
<pre>
+
 
 +
<source lang="javascript">
 
{
 
{
"@class":"HostingNode",
+
    "@class": "Context",
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"},
+
    "header": {
"consistsOf":[
+
        "@class": "Header",
{  
+
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
"@class":"ConsistsOf",
+
        "createdBy": "luca.frosini",
"header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", ...},
+
        "creationTime": "2021-06-30 09:38:27.846 +0000",
"target":{
+
        "lastUpdateBy": "luca.frosini",
"@class":"CPUFacet",
+
        "lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
+
    },
"model":"Opteron",
+
    "name": "NextNext",
"vendor":"AMD",
+
    "parent": {
"clockSpeed":"1 GHz"
+
        "@class": "IsParentOf",
}
+
        "header": {
},{
+
            "@class": "Header",
"@class":"IsIdentifiedBy",
+
            "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
+
            "createdBy": "luca.frosini",
"target":{  
+
            "creationTime": "2021-06-30 09:38:27.835 +0000",
"@class":"NetworkingFacet",
+
            "lastUpdateBy": "luca.frosini",
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
+
            "lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
"ipAddress" : "146.48.87.183",
+
        },
"hostName": "pc-frosini.isti.cnr.it",
+
        "source": {
"domainName" : "isti.cnr.it",
+
            "@class": "Context",
"mask" : "255.255.248.0",
+
            "header": {
"broadcastAddress":"146.48.87.255"
+
                "@class": "Header",
}
+
                "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
}
+
                "createdBy": "luca.frosini",
],
+
                "creationTime": "2021-06-30 09:38:26.978 +0000",
"isRelatedTo":[
+
                "lastUpdateBy": "luca.frosini",
{
+
                "lastUpdateTime": "2021-07-01 14:44:46.592 +0000"
"@class":"Hosts",
+
            },
"header":{"uuid":"47494ad0-e606-4630-9def-4c607761ae14", ...},
+
            "name": "devNext"
"propagationConstraint":{
+
        }
"add":"unpropagate",
+
    },
"remove": "cascade"
+
    "children": []
},
+
"target":{
+
"@class":"EService",
+
"header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3", ...}
+
}
+
}
+
]
+
 
}
 
}
</pre>
+
</source>
  
====== Java API ======
+
'''Request URL'''
<pre>
+
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
+
networkingFacet.setIPAddress("146.48.87.183");
+
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
+
networkingFacet.setDomainName("isti.cnr.it");
+
networkingFacet.setMask("255.255.248.0");
+
networkingFacet.setBroadcastAddress("146.48.87.255");
+
  
networkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
+
<pre>PUT /resource-registry/contexts/bad5f350-345c-11e9-9f49-cef9b1608c3f</pre>
  
HostingNode hostingNode = new HostingNodeImpl();
+
'''Request Body'''
  
CPUFacet cpuFacet = new CPUFacetImpl();
+
<source lang="javascript">
cpuFacet.setClockSpeed("1 GHz");
+
cpuFacet.setModel("Opteron");
+
cpuFacet.setVendor("AMD");
+
hostingNode.addFacet(cpuFacet);
+
 
+
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
+
hostingNode.attachFacet(isIdentifiedBy);
+
 
+
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
+
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
+
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
+
 
+
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, propagationConstraint);
+
hostingNode.attachResource(hosts);
+
 
+
hostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
+
</pre>
+
 
+
===== Update Resource Instance =====
+
 
+
====== REST API ======
+
<pre>
+
POST /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
+
</pre>
+
 
+
'''''Request Body'''''
+
<pre>
+
 
{
 
{
"@class":"HostingNode",
+
    "@class": "Context",
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84", ...},
+
    "header": {
"consistsOf":[
+
        "@class": "Header",
{
+
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
"@class":"ConsistsOf",
+
    },
"header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", ...},
+
    "name": "NextNext",
"target":{
+
    "parent": {
"@class":"CPUFacet",
+
        "header": {
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
+
            "@class": "Header",
"model":"Opteron",
+
            "uuid": "c470a070-83e8-45e8-8630-440225702acc"
"vendor":"AMD",
+
        },
"clockSpeed":"1 GHz"  
+
        "@class": "IsParentOf"
}
+
        "source": {
},{
+
            "name": "gcube",
"@class":"IsIdentifiedBy",
+
            "header": {
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
+
                "@class": "Header",
"target":{  
+
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
"@class":"NetworkingFacet",
+
            },
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
+
            "@class": "Context"
"ipAddress" : "146.48.87.183",
+
        }
"hostName": "pc-frosini.isti.cnr.it",
+
    },
"domainName" : "isti.cnr.it",
+
    "children": []
"mask" : "255.255.248.0",
+
"broadcastAddress":"146.48.87.255",
+
"username":"luca.frosini" /* Added this property */
+
}
+
}
+
]
+
 
}
 
}
</pre>
+
</source>
 +
 
 +
'''Response Body'''
  
'''''Response'''''
+
<source lang="javascript">
<pre>
+
 
{
 
{
"@class":"HostingNode",
+
    "name": "NextNext",
"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84", ...},
+
    "header": {
"consistsOf":[
+
        "@class": "Header",
{
+
        "creationTime": "2021-06-30 11:38:27.846 +0200",
"@class":"ConsistsOf",
+
        "createdBy": "luca.frosini",
"header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", ...},
+
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
"target":{
+
        "lastUpdateBy": "luca.frosini",
"@class":"CPUFacet",
+
        "lastUpdateTime": "2021-07-01 16:51:34.143 +0200"
"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
+
    },
"model":"Opteron",
+
    "@class": "Context"
"vendor":"AMD",
+
    "parent": {
"clockSpeed":"1 GHz"
+
        "header": {
}
+
            "@class": "Header",
},{
+
            "creationTime": "2021-07-01 16:51:34.131 +0200",
"@class":"IsIdentifiedBy",
+
            "createdBy": "luca.frosini",
"header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f", ...},
+
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
"target":{  
+
            "lastUpdateBy": "luca.frosini",
"@class":"NetworkingFacet",
+
            "lastUpdateTime": "2021-07-01 16:51:34.131 +0200"
"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933", ...},
+
        },
"ipAddress" : "146.48.87.183",
+
        "@class": "IsParentOf"
"hostName": "pc-frosini.isti.cnr.it",
+
        "source": {
"domainName" : "isti.cnr.it",
+
            "name": "gcube",
"mask" : "255.255.248.0",
+
            "header": {
"broadcastAddress":"146.48.87.255",
+
                "@class": "Header",
"username":"luca.frosini"
+
                "creationTime": "2021-06-30 11:38:26.464 +0200",
}
+
                "createdBy": "luca.frosini",
}
+
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
]
+
                "lastUpdateBy": "luca.frosini",
 +
                "lastUpdateTime": "2021-06-30 11:38:26.464 +0200"
 +
            },
 +
            "@class": "Context"
 +
        }
 +
    }
 
}
 
}
</pre>
+
</source>
  
====== Java API ======
+
=== Delete Context ===
<pre>
+
  
/* This is just a code example, here we suppose that there is only one identification Facet of the type (NetworkingFacet). This could not be true  in real scenario*/
 
networkingFacet = (NetworkingFacet) hostingNode.getIdentificationFacets().get(0);
 
networkingFacet.setAdditionalProperty("username", "luca.frosini");
 
 
hostingNode = resourceRegistryPublisher.updateResource(HostingNode.class, hostingNode);
 
  
</pre>
+
Delete the Context identified by the UUID provided as the path parameter.
  
===== Delete Resource Instance =====
+
'''The resource registry performs the following checks before deleting a context:'''
 +
* '''the context MUST have no children: this implies that you can't delete the ''testVO'' context if you don't have deleted (or moved to another parent) the context ''testVRE'';'''
 +
* '''the context MUST NOT have associated entities and relation instances: this implies that the client must remove in advance the available instances from the context.'''
  
====== REST API ======
+
==== Delete via Java Client ====
<pre>
+
DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
+
</pre>
+
  
====== Java API ======
+
Delete using UUID. This normally used when we already have the UUID instance.
<pre>
+
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
+
</pre>
+
  
==== Relation Instances APIs ====
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
resourceRegistryContextClient.delete("bad5f350-345c-11e9-9f49-cef9b1608c3f");
 +
</source>
  
<pre>
+
Delete using context instance. This normally used when we already have the context instance.
</pre>
+
  
=== Query & Access ===
+
<source lang="java">
 +
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 +
Context nextNextContext = resourceRegistryContextClient.read("bad5f350-345c-11e9-9f49-cef9b1608c3f");
 +
resourceRegistryContextClient.delete(nextNextContext);
 +
</source>
  
 +
==== Delete via REST API ====
  
==== Exists ====
+
<pre>DELETE /resource-registry/contexts/{{UUID}}</pre>
  
<pre>HEAD /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre>
+
{|class="wikitable"
 
+
! Code
Example
+
! Type
 
+
! Description
<pre>HEAD /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9</pre>
+
|-
 
+
| 204 - No Content
 
+
| N/A
==== Get Instance ====
+
| N/A
 
+
|}
<pre>GET /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre>
+
 
+
Example
+
 
+
<pre>GET /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9</pre>
+
 
+
 
+
 
+
==== Get All Instances of a Specific Type ====
+
 
+
<pre>GET /resource-registry/access/instances/{ER-Type}?[polymorphic=(true|false)][&reference={INSTANCE UUID}][&direction=(in|out|both)]</pre>
+
 
+
Default:
+
* polymorphic : false
+
* direction : both
+
 
+
direction has sense only if reference UUID is provided, is ignored otherwise.
+
 
+
 
+
<pre>GET /resource-registry/access/instances/EService?polymorphic=true</pre>
+
  
<pre>GET /resource-registry/access/instances/EService?polymorphic=true&reference=4d28077b-566d-4132-b073-f4edaf61dcb9&direction=(in|out|both)</pre>
 
  
 +
'''Request URL'''
  
==== Raw Query ====
+
For example to delete the Context having UUID '''bad5f350-345c-11e9-9f49-cef9b1608c3f''' (NextNext) we just need to perform the following HTTP request
  
<pre>GET /resource-registry/access?query=SELECT FROM Facet</pre>
+
<pre>DELETE /resource-registry/contexts/bad5f350-345c-11e9-9f49-cef9b1608c3f</pre>

Latest revision as of 10:38, 9 September 2021

These sections provide information regarding how to interact with Resource Registry Service for Context Management. REST API are presented for each functionality.

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

Context Management

Context Management is responsible for managing hierarchical Context as defined by the IS Model.

Context requirements:

  • No predefined number of levels;
  • Possibility to change the name of the Context with no impact for any component;
  • Possibility to move a Context from a parent Context to another.

Any request to this port type has success if the following guarantees are satisfied:

  • the hierarchy of contexts is a tree with an arbitrary number of levels;
  • two contexts with the same name can only exist if they have different parents;
  • any update to a context does not have any side effect on the instances belonging to the context;
  • it is not possible to delete a context if
    • it contains instances. It is the responsibility of the clients to remove the instances from the context (or delete them) before trying to delete the context;
    • it has children context. It is the responsibility of the clients to remove or move the children context before trying to delete the context.


Context Management exposes the following APIs:

  • List: allows to enumerate the contexts;
  • Create: allows to create a new context as a child of another context (if any). The context has a name;
  • Exists: allows to check if a Context exists;
  • Read: allows to read a Context;
  • Update:
    • Rename: rename a context;
    • Move: move a context as a child of another Context.
  • Delete: allows to delete a Context.

Context Collection

The following table shows the exposed APIs as REST Collection

Operation HTTP Method URL
List GET /contexts
Create PUT /contexts/{UUID}
Exists HEAD /contexts/{UUID}
Read GET /contexts/{UUID}
Update PUT /contexts/{UUID}
Delete DELETE /contexts/{UUID}

Security configuration based on Authorization Framework make this port type accessible only from Resource Manager. In other words, no others client is allowed to manage Context rather than Resource Manager.

Resource Registry Context Client

Resource Registry Context Client is a java library providing RPC facilities to interact with Context Collection. The library hides all the complexity of marshalling and unmarshalling of requests and results. By using this library any client is able to manage java classes instead of JSON objects.

To use the Java library to interact with Context Collection declare the following dependency in your pom.xml file.

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


To use the client you just need to instantiate the client via the provided factory.

import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory;
 
....
 
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();

The provided client exposes the available methods and options as explained below.

The source code of the resource-registry-context-client is available at https://code-repo.d4science.org/gCubeSystem/resource-registry-context-client

APIs

The provided examples are based on the following Context tree

-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
|
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
|   |
|   |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
|
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
    |
    |---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)

List Contexts

List all available contexts.


List via Java client

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
List<Context> contexts = resourceRegistryContextClient.all();


List via REST API

GET /resource-registry/contexts


Code Type Description
200 String A JSON array containing as an element the representation of each Context

Request URL

GET /resource-registry/contexts

Response Body

[
	{
		"@class": "Context",
		"header": {
			"@class": "Header",
			"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
			"createdBy": "luca.frosini",
			"creationTime": "2021-06-30 09:38:26.464 +0000",
			"lastUpdateBy": "luca.frosini",
			"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
		},
		"name": "gcube",
		"parent": null,
		"children": [
			{
				"@class": "IsParentOf",
				"header": {
					"@class": "Header",
					"uuid": "c470a070-83e8-45e8-8630-440225702acc",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:26.967 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
				},
				"target": {
					"@class": "Context",
					"header": {
						"@class": "Header",
						"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
						"createdBy": "luca.frosini",
						"creationTime": "2021-06-30 09:38:26.978 +0000",
						"lastUpdateBy": "luca.frosini",
						"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
					},
					"name": "devNext"
				}
			},
			{
				"@class": "IsParentOf",
				"header": {
					"@class": "Header",
					"uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:27.410 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
				},
				"target": {
					"@class": "Context",
					"header": {
						"@class": "Header",
						"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
						"createdBy": "luca.frosini",
						"creationTime": "2021-06-30 09:38:27.418 +0000",
						"lastUpdateBy": "luca.frosini",
						"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
					},
					"name": "devsec"
				}
			}
		]
	},
	{
		"@class": "Context",
		"header": {
			"@class": "Header",
			"uuid": "4c0c3500-32d6-11ea-867c-af3c989f8e41",
			"createdBy": "luca.frosini",
			"creationTime": "2021-06-30 09:38:30.098 +0000",
			"lastUpdateBy": "luca.frosini",
			"lastUpdateTime": "2021-06-30 09:38:30.098 +0000"
		},
		"name": "devVRE",
		"parent": {
			"@class": "IsParentOf",
			"header": {
				"@class": "Header",
				"uuid": "347f0e81-7407-485d-9698-946cf3b10c0b",
				"createdBy": "luca.frosini",
				"creationTime": "2021-06-30 09:38:30.090 +0000",
				"lastUpdateBy": "luca.frosini",
				"lastUpdateTime": "2021-06-30 09:38:30.090 +0000"
			},
			"source": {
				"@class": "Context",
				"header": {
					"@class": "Header",
					"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:27.418 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
				},
				"name": "devsec"
			}
		},
		"children": []
	},
	{
		"@class": "Context",
		"header": {
			"@class": "Header",
			"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
			"createdBy": "luca.frosini",
			"creationTime": "2021-06-30 09:38:26.978 +0000",
			"lastUpdateBy": "luca.frosini",
			"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
		},
		"name": "devNext",
		"parent": {
			"@class": "IsParentOf",
			"header": {
				"@class": "Header",
				"uuid": "c470a070-83e8-45e8-8630-440225702acc",
				"createdBy": "luca.frosini",
				"creationTime": "2021-06-30 09:38:26.967 +0000",
				"lastUpdateBy": "luca.frosini",
				"lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
			},
			"source": {
				"@class": "Context",
				"header": {
					"@class": "Header",
					"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:26.464 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
				},
				"name": "gcube"
			}
		},
		"children": [
			{
				"@class": "IsParentOf",
				"header": {
					"@class": "Header",
					"uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:27.835 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
				},
				"target": {
					"@class": "Context",
					"header": {
						"@class": "Header",
						"uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
						"createdBy": "luca.frosini",
						"creationTime": "2021-06-30 09:38:27.846 +0000",
						"lastUpdateBy": "luca.frosini",
						"lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
					},
					"name": "NextNext"
				}
			}
		]
	},
	{
		"@class": "Context",
		"header": {
			"@class": "Header",
			"uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
			"createdBy": "luca.frosini",
			"creationTime": "2021-06-30 09:38:27.418 +0000",
			"lastUpdateBy": "luca.frosini",
			"lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
		},
		"name": "devsec",
		"parent": {
			"@class": "IsParentOf",
			"header": {
				"@class": "Header",
				"uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
				"createdBy": "luca.frosini",
				"creationTime": "2021-06-30 09:38:27.410 +0000",
				"lastUpdateBy": "luca.frosini",
				"lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
			},
			"source": {
				"@class": "Context",
				"header": {
					"@class": "Header",
					"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:26.464 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
				},
				"name": "gcube"
			}
		},
		"children": [
			{
				"@class": "IsParentOf",
				"header": {
					"@class": "Header",
					"uuid": "347f0e81-7407-485d-9698-946cf3b10c0b",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:30.090 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:30.090 +0000"
				},
				"target": {
					"@class": "Context",
					"header": {
						"@class": "Header",
						"uuid": "4c0c3500-32d6-11ea-867c-af3c989f8e41",
						"createdBy": "luca.frosini",
						"creationTime": "2021-06-30 09:38:30.098 +0000",
						"lastUpdateBy": "luca.frosini",
						"lastUpdateTime": "2021-06-30 09:38:30.098 +0000"
					},
					"name": "devVRE"
				}
			}
		]
	},
	{
		"@class": "Context",
		"header": {
			"@class": "Header",
			"uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
			"createdBy": "luca.frosini",
			"creationTime": "2021-06-30 09:38:27.846 +0000",
			"lastUpdateBy": "luca.frosini",
			"lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
		},
		"name": "NextNext",
		"parent": {
			"@class": "IsParentOf",
			"header": {
				"@class": "Header",
				"uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
				"createdBy": "luca.frosini",
				"creationTime": "2021-06-30 09:38:27.835 +0000",
				"lastUpdateBy": "luca.frosini",
				"lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
			},
			"source": {
				"@class": "Context",
				"header": {
					"@class": "Header",
					"uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
					"createdBy": "luca.frosini",
					"creationTime": "2021-06-30 09:38:26.978 +0000",
					"lastUpdateBy": "luca.frosini",
					"lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
				},
				"name": "devNext"
			}
		},
		"children": []
	}
]

Create Context

Create new Context as a child of another Context (if any).

Create via Java Client

Create via Java Client Example 1

This Java code snippet shows how to create a new Context with name gcube with no parent. It is a ROOT Context.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 
Context gcubeContext = new ContextImpl("gcube");
// Java class generate a random UUID and use to interact with Resource Regsitry Service
// To specify the UUID 
// UUID gcubeUUID = UUID.fromString("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
// Context gcubeContext = new ContextImpl("gcube", gcubeUUID);
gcubeContext = resourceRegistryContextClient.create(gcubeContext);
Create via Java Client Example 2

This Java code snippet shows how to create a new Context with name devNext as child of Context with UUID c470a070-83e8-45e8-8630-440225702acc (gcube).

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
 
Context devNextContext = new ContextImpl("devNext");
// To specify the UUID 
// UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
// Context testVOContext = new ContextImpl("devNext", devNextUUID);
devNextContext.setParent(gcubeContext);
devNextContext = resourceRegistryContextClient.create(devNextContext);

Create via REST API

PUT /resource-registry/contexts/{{UUID}}
Code Type Description
200 String The JSON representation of the newly created Context


Create via REST API Example 1

Create a new Context with name gcube with no parent. It is a ROOT Context.

Request URL

PUT /resource-registry/context/ca50eb95-b76c-44fd-9182-229d39c3c9e2

Request Body

{
	"@class": "Context",
	"name": "gcube",
	"header": {
		"@class": "Header",
		"uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
	}
}


Response Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
        "createdBy": "luca.frosini",
        "creationTime": "2021-06-30 09:38:26.464 +0000",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
    },
    "name": "gcube",
    "parent": null,
    "children": []
}
Create via REST API Example 2

Create a new Context with name devNext as child of Context with UUID c470a070-83e8-45e8-8630-440225702acc (gcube).

Request URL

PUT /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771

Request Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
    },
    "name": "devNext",
    "parent": {
        "@class": "IsParentOf",
        "header": null,
        "source": {
            "@class": "Context",
            "header": {
                "@class": "Header",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
            }
        }
    }
}

Response Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
        "createdBy": "luca.frosini",
        "creationTime": "2021-06-30 09:38:26.978 +0000",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
    },
    "name": "devNext",
    "parent": {
        "@class": "IsParentOf",
        "header": {
            "@class": "Header",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
            "createdBy": "luca.frosini",
            "creationTime": "2021-06-30 09:38:26.967 +0000",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
        },
        "source": {
            "@class": "Context",
            "header": {
                "@class": "Header",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:26.464 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
            },
            "name": "gcube"
        }
    },
    "children": []
}

Read Context

Return the definition of the Context identified by the UUID provided as the path parameter.

Read via Java Client

Read via Java Client Example 1

Read the Context having UUID ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)

Read using a string representing the UUID.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
Read via Java Client Example 2

Read the Context having UUID aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)

Read using UUID. This normally used when we already have the UUID instance.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
Context devNextContext = resourceRegistryContextClient.read(devNextUUID);


Read using context instance. This normally used when we already have the context instance.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
UUID devNextUUID = UUID.fromString("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
Context devNextContext = new ContextImpl("devNext", devNextUUID);
devNextContext = resourceRegistryContextClient.read(devNextContext);


Read via REST API

GET /resource-registry/context/{UUID}
Code Type Description
200 String The JSON representation of the requested Context


Read via REST API Example 1

Read the Context having UUID ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)

Request URL

GET /resource-registry/contexts/ca50eb95-b76c-44fd-9182-229d39c3c9e2

Response Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
        "createdBy": "luca.frosini",
        "creationTime": "2021-06-30 09:38:26.464 +0000",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
    },
    "name": "gcube",
    "parent": null,
    "children": [
        {
            "@class": "IsParentOf",
            "header": {
                "@class": "Header",
                "uuid": "c470a070-83e8-45e8-8630-440225702acc",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:26.967 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
            },
            "target": {
                "@class": "Context",
                "header": {
                    "@class": "Header",
                    "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
                    "createdBy": "luca.frosini",
                    "creationTime": "2021-06-30 09:38:26.978 +0000",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
                },
                "name": "devNext"
            }
        },
        {
            "@class": "IsParentOf",
            "header": {
                "@class": "Header",
                "uuid": "9966f136-25c9-4e73-aa54-5357ac5e09d1",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:27.410 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 09:38:27.410 +0000"
            },
            "target": {
                "@class": "Context",
                "header": {
                    "@class": "Header",
                    "uuid": "d0544ff9-8f61-416f-b685-589a2262e2c4",
                    "createdBy": "luca.frosini",
                    "creationTime": "2021-06-30 09:38:27.418 +0000",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-06-30 09:38:27.418 +0000"
                },
                "name": "devsec"
            }
        }
    ]
}
Read via REST API Example 2

Read the Context having UUID aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)

Request URL

GET /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771

Response Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
        "createdBy": "luca.frosini",
        "creationTime": "2021-06-30 09:38:26.978 +0000",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-06-30 09:38:26.978 +0000"
    },
    "name": "devNext",
    "parent": {
        "@class": "IsParentOf",
        "header": {
            "@class": "Header",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
            "createdBy": "luca.frosini",
            "creationTime": "2021-06-30 09:38:26.967 +0000",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-06-30 09:38:26.967 +0000"
        },
        "source": {
            "@class": "Context",
            "header": {
                "@class": "Header",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:26.464 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 09:38:26.464 +0000"
            },
            "name": "gcube"
        }
    },
    "children": [
        {
            "@class": "IsParentOf",
            "header": {
                "@class": "Header",
                "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:27.835 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
            },
            "target": {
                "@class": "Context",
                "header": {
                    "@class": "Header",
                    "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
                    "createdBy": "luca.frosini",
                    "creationTime": "2021-06-30 09:38:27.846 +0000",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
                },
                "name": "NextNext"
            }
        }
    ]
}

Update Context

Update a Context identified by the UUID provided as the path parameter.

The possible updates are on:

  • name;
  • parent Context.


Update via Java Client

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
 
Context contextToBeUpdated = ....;
 
Context updatedContext = resourceRegistryContextClient.update(contextToBeUpdated);

Update via REST API

PUT /resource-registry/contexts/{UUID}
Code Type Description
200 String The JSON representation of the updated Context

Rename Context

Rename via Java Client

Rename a Context aa860961-6eb0-4c1c-89fb-c406fe2a2771 (was devNext) to the new name newDevNext.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
Context devNextContext = resourceRegistryContextClient.read("aa860961-6eb0-4c1c-89fb-c406fe2a2771");
devNextContext.setName("newDevNext");
Context newDevNext = resourceRegistryContextClient.update(devNextContext);
Rename via REST API

Rename a Context aa860961-6eb0-4c1c-89fb-c406fe2a2771 (was devNext) to the new name newDevNext.

Request URL

PUT /resource-registry/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771

Request Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
    },
    "name": "newDevNext",
    "parent": {
        "@class": "IsParentOf",
        "header": {
            "@class": "Header",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc"
        },
        "source": {
            "@class": "Context",
            "header": {
                "@class": "Header",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
            },
            "name": "gcube"
        }
    }
}

Response Body

{
    "name": "newDevNext",
    "header": {
        "@class": "Header",
        "creationTime": "2021-06-30 11:38:26.978 +0200",
        "createdBy": "luca.frosini",
        "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-07-01 16:44:46.592 +0200"
    },
    "@class": "Context",
    "parent": {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 16:43:57.358 +0200",
            "createdBy": "luca.frosini",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 16:43:57.358 +0200"
        },
        "@class": "IsParentOf",
        "source": {
            "name": "gcube",
            "header": {
                "@class": "Header",
                "creationTime": "2021-06-30 11:38:26.464 +0200",
                "createdBy": "luca.frosini",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 11:38:26.464 +0200"
            },
            "@class": "Context"
        }
    },
    "children": [
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-06-30 11:38:27.835 +0200",
                "createdBy": "luca.frosini",
                "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 11:38:27.835 +0200"
            },
            "@class": "IsParentOf",
            "target": {
                "name": "NextNext",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-06-30 11:38:27.846 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-06-30 11:38:27.846 +0200"
                },
                "@class": "Context"
            }
        }
    ]
}

Move Context

We have 5 Contexts organized in the following Context Tree:

-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
|
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
|   |
|   |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
|
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
    |
    |---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)

We want to move Context bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext) as child of the Context ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube) in palce of aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext) In other words, NextNext will be a VO in place of a VRE.

We will obtain the following Context tree

-  ca50eb95-b76c-44fd-9182-229d39c3c9e2 (gcube)
|
|---- d0544ff9-8f61-416f-b685-589a2262e2c4 (devsec)
|   |
|   |---- 4c0c3500-32d6-11ea-867c-af3c989f8e41 (devVRE)
|
|---- aa860961-6eb0-4c1c-89fb-c406fe2a2771 (devNext)
|
|---- bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext)


Move with Java client
ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
Context gcubeContext = resourceRegistryContextClient.read("ca50eb95-b76c-44fd-9182-229d39c3c9e2");
Context nextNextContext = resourceRegistryContextClient.read("bad5f350-345c-11e9-9f49-cef9b1608c3f");
nextNextContext.setParent(gcubeContext);
nextNextContext = resourceRegistryContextClient.update(nextNextContext);


Move via REST API

If we read the Context bad5f350-345c-11e9-9f49-cef9b1608c3f' (NextNext) before moving it we have:

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
        "createdBy": "luca.frosini",
        "creationTime": "2021-06-30 09:38:27.846 +0000",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-06-30 09:38:27.846 +0000"
    },
    "name": "NextNext",
    "parent": {
        "@class": "IsParentOf",
        "header": {
            "@class": "Header",
            "uuid": "74d435c1-29ce-49f4-b3b9-cbca42c2b046",
            "createdBy": "luca.frosini",
            "creationTime": "2021-06-30 09:38:27.835 +0000",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-06-30 09:38:27.835 +0000"
        },
        "source": {
            "@class": "Context",
            "header": {
                "@class": "Header",
                "uuid": "aa860961-6eb0-4c1c-89fb-c406fe2a2771",
                "createdBy": "luca.frosini",
                "creationTime": "2021-06-30 09:38:26.978 +0000",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 14:44:46.592 +0000"
            },
            "name": "devNext"
        }
    },
    "children": []
}

Request URL

PUT /resource-registry/contexts/bad5f350-345c-11e9-9f49-cef9b1608c3f

Request Body

{
    "@class": "Context",
    "header": {
        "@class": "Header",
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
    },
    "name": "NextNext",
    "parent": {
        "header": {
            "@class": "Header",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc"
        },
        "@class": "IsParentOf"
        "source": {
            "name": "gcube",
            "header": {
                "@class": "Header",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2"
            },
            "@class": "Context"
        }
    },
    "children": []
}

Response Body

{
    "name": "NextNext",
    "header": {
        "@class": "Header",
        "creationTime": "2021-06-30 11:38:27.846 +0200",
        "createdBy": "luca.frosini",
        "uuid": "bad5f350-345c-11e9-9f49-cef9b1608c3f",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-07-01 16:51:34.143 +0200"
    },
    "@class": "Context"
    "parent": {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 16:51:34.131 +0200",
            "createdBy": "luca.frosini",
            "uuid": "c470a070-83e8-45e8-8630-440225702acc",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 16:51:34.131 +0200"
        },
        "@class": "IsParentOf"
        "source": {
            "name": "gcube",
            "header": {
                "@class": "Header",
                "creationTime": "2021-06-30 11:38:26.464 +0200",
                "createdBy": "luca.frosini",
                "uuid": "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-06-30 11:38:26.464 +0200"
            },
            "@class": "Context"
        }
    }
}

Delete Context

Delete the Context identified by the UUID provided as the path parameter.

The resource registry performs the following checks before deleting a context:

  • the context MUST have no children: this implies that you can't delete the testVO context if you don't have deleted (or moved to another parent) the context testVRE;
  • the context MUST NOT have associated entities and relation instances: this implies that the client must remove in advance the available instances from the context.

Delete via Java Client

Delete using UUID. This normally used when we already have the UUID instance.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
resourceRegistryContextClient.delete("bad5f350-345c-11e9-9f49-cef9b1608c3f");

Delete using context instance. This normally used when we already have the context instance.

ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
Context nextNextContext = resourceRegistryContextClient.read("bad5f350-345c-11e9-9f49-cef9b1608c3f");
resourceRegistryContextClient.delete(nextNextContext);

Delete via REST API

DELETE /resource-registry/contexts/{{UUID}}
Code Type Description
204 - No Content N/A N/A


Request URL

For example to delete the Context having UUID bad5f350-345c-11e9-9f49-cef9b1608c3f (NextNext) we just need to perform the following HTTP request

DELETE /resource-registry/contexts/bad5f350-345c-11e9-9f49-cef9b1608c3f